-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Render chat template tojson filter as unicode #31041
Conversation
The failing tests seem to be an unrelated issue in |
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!
Also @CISC and @junrae6454, since you're both interested in tool use with chat templates, we're actually planning an overhaul of that, and several of the model templates as well. Please see PR #30621, and let me know if you have any feedback! |
@Rocketknight1 Oh, hey, that might impact some of my ongoing work in |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Merging without core maintainer review because it's a one-line fix that only affects the |
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.
Thanks and LGTM
What does this PR do?
Rant about lack of special capabilties templates...
I wish more models that have extra capabilities like f.ex. function calling would start using the power available in chat templates instead of implementing their own inference mini-stacks (
Mistral
,Berkeley
, et al.; I'm looking at you) that you would have to add as model-specific dependencies to use those features "as intended".Shout out to
Cohere
for actually making an effort here, however it's a shame they did not follow it to completion to also include the finaltool
role to enable the full round-trip with natural language response to the function call (see my MistralGGUF
for a fully functional example of this).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.I'm mainly using
GGUF
s, so have not usedtojson
withtransformers
yet, but I imagine this could be a useful feature for many recent models if only they started using chat templates properly (see rant).This PR simply changes the default parameters of
tojson
so that the JSON is rendered in unicode.Examples of (
GGUF
) models usingtojson
:Submitted similar PR to abetlen/llama-cpp-python#1486
Who can review?
@ArthurZucker