Skip to content
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

Jinja - add missing features for DeepSeek R1 #1142

Merged
merged 12 commits into from
Jan 30, 2025

Conversation

giladgd
Copy link
Contributor

@giladgd giladgd commented Jan 27, 2025

This PR adds support for the following Jinja features:

DeepSeek R1's chat template used to fail on this expression, which now works in this PR:

{%- set content = content.split('</think>')[-1] -%}

Fixes #1141

@giladgd giladgd requested a review from xenova as a code owner January 27, 2025 01:26
@giladgd
Copy link
Contributor Author

giladgd commented Jan 29, 2025

I'm not sure why the CI tests don't run on my branch, but they pass when I run them on my machine

@xenova
Copy link
Contributor

xenova commented Jan 29, 2025

Hey! I'm in the process of reviewing the PR and I'll trigger the CI shortly!

I found a few minor issues with the current implementation, so I'm just fixing a few things.

Copy link
Contributor

@xenova xenova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I cleaned up & fixed a few issues with the implementation of split, but other than that, it looks good!

If you're interested, here were the failing strings, which I've now added as unit tests

SPLIT_4: `|{{ "  1 2  3   ".split() | tojson }}|{{ "babbaccabbb".split("b") | tojson }}|{{ "babbaccabbb".split("b", 2) | tojson }}|`,
SPLIT_5: `|{{ " 1 2 3 4 5 ".split(none, 0) | join(",") }}|{{ " 1 2 3 4 5 ".split(none, 3) | join(",") }}|{{ " 1 2 3 4 5 ".split(" ", 0) | join(",") }}|{{ " 1 2 3 4 5 ".split(" ", 3) | join(",") }}|{{ " 1 2 3 4 5 ".split(" ", 10) | join(",") }}|`,

@xenova
Copy link
Contributor

xenova commented Jan 29, 2025

I'll merge after a final check by @giladgd :)

@giladgd
Copy link
Contributor Author

giladgd commented Jan 29, 2025

@xenova LGTM
Thanks for implementing join BTW, it was the next thing I was planning to do :)

@xenova
Copy link
Contributor

xenova commented Jan 30, 2025

I just updated the e2e unit test to include text so that the split branch is taken. Ready to merge now!

Thanks again!

@xenova xenova merged commit c35bd61 into huggingface:main Jan 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jinja fails to parse array subscript operator applied to complex expressions
2 participants