-
Notifications
You must be signed in to change notification settings - Fork 6
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
Handle Llama 3.2 chat template #4
Conversation
The chat template of Llama3.2 uses tojson, but Swift Jinja has not been implemented yet. You can refer to the commits of jinja.js for porting. huggingface/huggingface.js@78e6a5e |
Would you be willing to become a Swift Jinja Collaborator? I hope to find like-minded partners to co-build Swift Jinja, as my abilities are limited on my own. If you're willing, I will grant you access to Swift Jinja. |
78c5d56
to
45e2747
Compare
Sure, I'm happy to help out, although Jinja and the way it's used in these chat templates are still quite new to me. |
I think this line is not being evaluated as false: {%- if tools is not none %} Because then it tries to iterate over |
Yes, You can port the commit. |
Thank you. Is there a point in time at which this package fully mirrored the JavaScript implementation? That would be helpful to know so that I can see which new additions might need to be added here. |
This package started development on May 20 huggingface/swift-transformers#77 (comment) , but at that time it did not fully mirror the JavaScript implementation. It only completed the mainstream LLM chat template Tests/ChatTemplateTests.swift . It should be at huggingface/huggingface.js@80cd456. |
Both |
These Jinja packages are complex enough that at the moment the best I can do is hand the problem off to Claude 3.5 Sonnet, and that seems to only get part of the way to a solution. So feel free to take it from here if you want to. It would probably take me several days to get up to speed, and I unfortunately don't have enough capacity to do that right now. |
It's okay, I can help you solve the problem. |
0f062f4
to
e73afaa
Compare
Okay, I got this working with Llama 3.2. I haven't implemented the tools part with |
4014d8a
to
62be81a
Compare
I added a test for |
23f163d
to
4afffc9
Compare
I checked huggingface/huggingface.js#846 again and fixed a few things that I think now bring this in line with the TypeScript implementation. I think this is now ready for review. |
Thanks a lot for the PR! |
This is a work in progress, and I'm not sure how to proceed, since I'm not very familiar with Jinja or this package. I think I managed to solve the test for if
tools
is defined, but now it's failing when it tries to iterate through an undefinedtools
.