-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Chat template rendering extensions to match transformers #1486
base: main
Are you sure you want to change the base?
Conversation
Since the merging of a similar patch to |
@abetlen Even more |
@abetlen It would be really nice to have this merged soon, it's starting to cause issues with quite a few templates not to have this in place. Additionally this is a requirement for implementing inverse templates (which I'd like to do, as soon as it's merged in transformers, since it will be super useful for universal function calling and parsing). |
I've been using the jinja2 tojson filter in a couple of chat templates to render function calling instructions, which is working very well, however sometimes this will introduce escaped unicode characters, which is undesirable.
This PR
simply changes the default parameters of tojsonreplaces tojson so that the JSON is rendered in unicode without escaped HTML characters.Examples of models using tojson:
I've also removed the leftover (and unnecessary) loader parameter since I was touching this code area anyway.
Update:
Further changes to chat templates are being made in
transformers
and since they are dependant on the changes already made here I will simply append them to this PR:loopcontrols
jinja2 extension (adds break and continue)strftime_now
to render the current timeSee huggingface/transformers#32684