Skip to content

[template] remove compat and update docs#7192

Merged
Jintao-Huang merged 8 commits intomodelscope:mainfrom
Jintao-Huang:remove_compat
Dec 24, 2025
Merged

[template] remove compat and update docs#7192
Jintao-Huang merged 8 commits intomodelscope:mainfrom
Jintao-Huang:remove_compat

Conversation

@Jintao-Huang
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Jintao-Huang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the flexibility and clarity of how rejected responses are handled within the ms-swift framework. It involves significant updates to the documentation for custom datasets, providing clearer guidelines and examples for multimodal and agent-based data. Concurrently, the underlying code has been refactored to streamline the processing of rejected_response by converting it into a more versatile rejected_messages structure, thereby improving compatibility and future extensibility.

Highlights

  • Documentation Update: The documentation for custom datasets has been updated to clarify the usage of rejected_messages and rejected_response, including new examples for multimodal and agent scenarios, specifically for ms-swift>=3.12.
  • Refactored rejected_response Handling: The internal handling of rejected_response in StdTemplateInputs has been refactored. The direct rejected_response field has been removed, and its compatibility logic now converts it into the more flexible rejected_messages format, supporting both string and list-of-message inputs.
  • Improved Agent Dataset Support: New examples and internal logic have been introduced to better support Agent datasets, particularly in how rejected_messages are constructed from rejected_response within these contexts.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes some compatibility code related to rejected_response and updates the documentation to reflect new data formats. The changes in the Python code are a good refactoring, but I found a small bug in an assertion. The documentation updates are helpful, but there are some inconsistencies and misleading comments that I've pointed out. Overall, good changes that improve code clarity and document new features.

@Jintao-Huang
Copy link
Collaborator Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on removing compatibility code related to rejected_response and updating the documentation to reflect new, more flexible data formats. The changes in swift/llm/template/template_inputs.py effectively refactor the handling of rejected_response to support both string and list-of-message formats, which is a good improvement. The documentation updates in both Chinese and English are clear and provide helpful examples for the new features. I've identified a minor typo in the Chinese documentation and suggest an improvement for input validation in the Python code by using ValueError instead of assert for better robustness. Overall, this is a solid pull request that enhances code clarity and documentation.

@Jintao-Huang
Copy link
Collaborator Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively removes legacy compatibility code for rejected_response and updates the documentation to reflect new data format capabilities, particularly for DPO/RLHF scenarios. The code changes in swift/llm/template/template_inputs.py are well-executed, introducing clearer logic for handling rejected_response as either a string or a list of messages, which aligns with the documentation. The documentation updates in both Chinese and English are clear and provide valuable examples. I've made two minor suggestions to improve formatting consistency in the markdown files.

> 注: RM 额外支持 margin 列,参考[RM文档](../Instruction/RLHF.md#rm)

当然,你也可以直接使用`rejected_messages`,而不是只提供`rejected_response`/`rejected_images`(需ms-swift>=3.8),这将提供更大的灵活度(例如多模态/agent场景)。若使用rejected_messages,在多模态场景下,你需要额外传入"rejected_images","rejected_audios","rejected_videos"等内容;在Agent场景下,你需要额外传入"rejected_tools"等内容。多模态数据格式例子如下:
- 若使用`rejected_response`,'rejected_images/rejected_audios/rejected_videos/rejected_tools'的默认值为'images/audios/videos/tools';若使用`rejected_messages`,则需要额外传入。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了保持文档格式的一致性,建议将 'rejected_images/audios/videos/tools''images/audios/videos/tools' 也使用反引号()包裹,就像文档中其他字段名(如 rejected_response`)一样。

Suggested change
- 若使用`rejected_response`'rejected_images/rejected_audios/rejected_videos/rejected_tools'的默认值为'images/audios/videos/tools';若使用`rejected_messages`,则需要额外传入。
- 若使用`rejected_response``rejected_images/audios/videos/tools`的默认值为`images/audios/videos/tools`;若使用`rejected_messages`,则需要额外传入。

> Note: RM additionally supports the margin column. For details, refer to the [RM documentation](../Instruction/RLHF.md#rm).

Sure, you can also directly use `rejected_messages` instead of only providing `rejected_response` / `rejected_images` (requires ms-swift>=3.8), which offers greater flexibility (e.g., for multimodal or agent scenarios). If you use "rejected_messages", then in multimodal scenarios you must also provide "rejected_images", "rejected_audios", "rejected_videos", etc.; in Agent scenarios you must also provide "rejected_tools", etc. An example of the multimodal data format is as follows:
- If using `rejected_response`, the default values for 'rejected_images/rejected_audios/rejected_videos/rejected_tools' are 'images/audios/videos/tools'; if using `rejected_messages`, they need to be passed in additionally.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with how other field names like rejected_response are formatted in the document, it's recommended to also wrap 'rejected_images/audios/videos/tools' and 'images/audios/videos/tools' in backticks (`).

Suggested change
- If using `rejected_response`, the default values for 'rejected_images/rejected_audios/rejected_videos/rejected_tools' are 'images/audios/videos/tools'; if using `rejected_messages`, they need to be passed in additionally.
- If using `rejected_response`, the default values for `rejected_images/audios/videos/tools` are `images/audios/videos/tools`; if using `rejected_messages`, they need to be passed in additionally.

@Jintao-Huang Jintao-Huang merged commit 2fcf01a into modelscope:main Dec 24, 2025
1 of 3 checks passed
meichangsu1 pushed a commit to tpx818/ms-swift that referenced this pull request Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants