modelscope / modelscope/ms-swift

Qwen3-VL-Reranker-2B swift sft 训练数据的格式是啥样的

Open
#7,382 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

这种标准格式会出错
{"messages": [{"role": "system", "content": "You are a helpful and harmless assistant"}, {"role": "user", "content": "What's in the image, what's in the video?"}, {"role": "assistant", "content": "There's an elephant in the image, and a puppy running on the grass in the video"}], "images": ["/xxx/x.jpg"], "videos": ["/xxx/x.mp4"]}

报错信息
File "/usr/local/lib/python3.11/site-packages/swift/llm/template/base.py", line 565, in encode
raise ValueError(f'lengths should not be empty. batched: {batched}')
ValueError: lengths should not be empty. batched: [defaultdict(<class 'list'>, {'labels': []})]

训练参数是这样的
https://github.com/modelscope/ms-swift/blob/main/examples/train/reranker/qwen3/qwen3_vl_reranker.sh

必须要这种格式吗
{"messages": [{"role": "user", "content": "query"}], "images": ["/some/images.jpg"], "positive_messages": [[{"role": "assistant", "content": "relevant_doc1"}]], "positive_images": [["/some/positive_images.jpg"]], "negative_messages": [[{"role": "assistant", "content": "irrelevant_doc1"}], [{"role": "assistant", "content": "irrelevant_doc2"}]], "negative_images": [["/some/negative_images1.jpg", "/some/negative_images2.jpg"], ["/some/negative_images3.jpg"]]}

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 with the training parameters in examples/train/reranker/qwen3/qwen3_vl_reranker.sh and trace the supplied dataset through swift/llm/template/base.py at the reported encode failure on line 565. Reproduce the error with the two formats shown; done means the accepted Qwen3-VL reranker SFT format and the cause of the empty labels are clearly established, with a documented or corrected path for training.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.