Skip to content

Make sure chat template isn't lost when truncating prompt. #3651

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

Merged

Conversation

pramodith
Copy link
Contributor

@pramodith pramodith commented Jun 25, 2025

What does this PR do?

Skipping special tokens when truncating the prompt leads to the prompt no longer being in a valid chat template, if the input dataset is conversational.

This PR disables skipping special tokens.

Fixes #3644

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

@LeonEricsson here's the quick fix.

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

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.

Copy link
Collaborator

@LeonEricsson LeonEricsson left a comment

Choose a reason for hiding this comment

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

I've run some tests and this should be sufficient for now. However as you rightfully point out in #3646, the current truncation is too naive and will butcher the chat template. This needs to be addressed

@LeonEricsson LeonEricsson merged commit 79ec242 into huggingface:main Jun 26, 2025
9 of 10 checks passed
@pramodith pramodith deleted the pramodith/disable_skip_special_tokens branch June 26, 2025 09:10
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.

0.19.0 breaks the chat format in GRPO trainer leading to severely mangled chat generations
3 participants