modelscope / modelscope/ms-swift
Qwen3-VL-Reranker-2B swift sft 训练数据的格式是啥样的
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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