[v4] refactor ms-swift v4#7238
Conversation
Summary of ChangesHello @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 significantly refactors the model registration system by enhancing the flexibility of template assignments. It shifts the definition of the Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-executed refactoring of the model registration mechanism. By making the template parameter optional in ModelMeta and introducing it in ModelGroup, you've successfully consolidated numerous model registrations, which greatly simplifies the codebase and improves maintainability. The changes are consistently applied across all relevant files, including documentation. I have a couple of minor suggestions for further cleanup, but overall, this is a great improvement.
swift/model/constant.py
Outdated
| @@ -8,19 +8,10 @@ class LLMModelType: | |||
| qwen = 'qwen' | |||
| qwen2 = 'qwen2' | |||
| qwen2_5 = 'qwen2_5' | |||
There was a problem hiding this comment.
The model_type qwen2_5 is kept here, but its registration in swift/llm/model/model/qwen.py has been removed. The models previously under this type are now merged into the qwen2 model registration, using qwen2_5 as a template type. To maintain consistency and avoid potential confusion, it would be best to remove qwen2_5 from LLMModelType as it's no longer a registered model type.
| tags=['math']), | ||
| ModelGroup([Model('AIDC-AI/Marco-o1', 'AIDC-AI/Marco-o1')], TemplateType.marco_o1), |
There was a problem hiding this comment.
There's an extra space at the beginning of this line, which makes the indentation inconsistent with the surrounding ModelGroup definitions. Please remove the leading space for consistency.
| ModelGroup([Model('AIDC-AI/Marco-o1', 'AIDC-AI/Marco-o1')], TemplateType.marco_o1), | |
| ModelGroup([Model('AIDC-AI/Marco-o1', 'AIDC-AI/Marco-o1')], TemplateType.marco_o1), |
…_template' into refactor_model_type_template
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a major refactoring for the v4 release of ms-swift. The changes are extensive and well-executed, significantly improving the project's structure and maintainability. Key changes include a reorganization of the package structure, with the swift.llm and swift.plugin modules being broken down into more focused sub-packages like swift.model, swift.template, swift.dataset, swift.infer_engine, and swift.arguments. This is accompanied by several API changes, such as renaming get_model_tokenizer to get_model_processor, PtEngine to TransformersEngine, and TrainArguments to SftArguments. The model loading mechanism has also been refactored to use a more object-oriented ModelLoader approach. All documentation and examples have been diligently updated to reflect these new APIs. The refactoring appears consistent and thoughtful, and I found no issues or bugs in the implementation. This is a great step forward for the library.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a major refactoring of the ms-swift library for version 4.0. The swift.llm module has been broken down into several more specific and well-organized packages such as swift.model, swift.template, swift.dataset, swift.infer_engine, and swift.pipelines. This significantly improves the project structure and maintainability. Many classes and functions have been renamed for clarity and consistency, such as PtEngine to TransformersEngine and get_model_tokenizer to get_model_processor. The documentation and examples have been updated accordingly to reflect these changes. Overall, this is an excellent and well-executed refactoring effort. I've found a couple of minor issues in the English documentation where warning messages were not translated.
No description provided.