-
Notifications
You must be signed in to change notification settings - Fork 282
✨ feat: Add support for Qwen3 model #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Looks great!! Can you add a model configuration for Qwen3 1.7B: Assume it will be here: And can you update the default model in the LLM app to use that config (as apposed to the dated older qwen of a similar size? |
Received, sir.🫡🫡🫡 |
Thanks for the changes @johnmai-dev. The model runs and produces ok output.. but it looks like there may be something off with the chat template 🤔 . |
Yes, it is indeed an issue with Jinja. I will only have time to fix it after work in the evening. The error message is: Runtime: Cannot call something that is not a function: got UndefinedValue |
I added some missing string methods here: johnmai-dev/Jinja#15 This seems to fix the error. |
Awesome thanks @DePasqualeOrg. Let us know when it lands. We may need to make a PR on swift transformers to bump the jinja package version as well. |
The update is available now. Because swift-transformers uses |
Jinja version 1.1.2 has been released. Only ![]() |
Awesome! Tested locally and it works well now. Regarding the thinking toggle.. I think we should find a way to keep it cause it's fun to play with. But there are a couple issues to think through there:
|
I don't know if it will be possible to reliably determine this based on the tokenizer config files. My app Local Chat adds a lot of metadata about the models, such as whether they use thinking tags, whether the response starts with the start thinking tag, etc. To work reliably, this should probably be part of the model preset configurations, and more options may need to be added over time as models become more diverse. |
Yes, I'm also debating whether to add a non-thinking mode.😂 But if we don't add it, we'll have to default to thinking mode. |
# Conflicts: # mlx-swift-examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Indeed.. I was thinking something similar. Models may need optional additional config info including which toggles they have (tools, thinking). And we can dynamically set that based on the config.. I'm ok keeping it the way it is for now. But with the intention of keeping an eye on it and refactoring / redesigning if it becomes more important. |
03dbb5f
to
76efd3c
Compare
I had planned to expose |
If we keeping it, this PR is ready for review & merge. 🍻 |
Yes, something like that could also work. Though I think it may be better to read it as an optinoal field in the config rather than hard code the model types that should have different features. But, let's do this type of stuff in a follow on PR so we can prioritize merging this without the extra complication. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Yeah, I think we can keep the toggle there in the example (just like we have the tool piece showing how to integrate that). If there is some metadata in the tokenizer config we can hook that up -- maybe there is something similar for tools? |
Looks great, thank you for the contribution! @johnmai-dev and @DePasqualeOrg |
Thank you all for the awesome work, can't wait to integrate it in my mlx swift projects. |
It might be easier to maintain if you use a field related to the functionality you want to control. For this type of additional functionality that is specific to some models, my app has a field that is a list of features, one of which could be an enum case |
Add support for Qwen3 model
Port of https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/models/qwen3.py