modelscope / modelscope/ms-swift

Resolved: When fine-tuning DeepSeekOCR models using the ms-swift framework, training with mixed text and multimodal data cannot be processed.

Open
#6,887 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
Python
Stars
15.7k
Forks
1.7k
Avg merge
1d 16h
Merged PRs (30d)
136

Description

Describe the bug

Image

在 swift/llm/template/template/deepseek.py 函数中,数据加载时,只将带有 images 和相应的 seq_mask 的数据取出进行处理;

如果同一个批次的数据(夹杂纯文本和多模态数据时),DeepseekOCRModel 的前向传播时,在模型处理图像特征后,通过:
inputs_embeds[idx].masked_scatter_(images_seq_mask[idx].unsqueeze(-1).to(device), images_in_this_batch)

将图像特征插入到带有占位符的文本特征中;

会导致无法准确地从批次数据里,找到对应的文本特征。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in swift/llm/template/template/deepseek.py and inspect the data-loading function that selects examples with images and seq_mask. Trace how mixed text and multimodal batches reach the DeepSeekOCRModel forward pass and the masked_scatter_ operation. Done means a batch containing both kinds of data is processed without losing the correspondence between image features and text features.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.