Chat template rendering extensions to match transformers #1486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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