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

fix apply_chat_template() padding choice #35828

Conversation

baoyf4244
Copy link
Contributor

@baoyf4244 baoyf4244 commented Jan 22, 2025

What does this PR do?

fix apply_chat_template() padding choice to bool, str, PaddingStrategy and the docstring of pad()

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 or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

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.

Copy link
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

The type hint correction is good, but I'm not sure about the docstring! In the code, we pass the padding argument through to PreTrainedTokenizer.encode() unchanged, so I think the documentation of that arg should match the documentation on the underlying tokenizer method

@baoyf4244
Copy link
Contributor Author

I find in the encode() method, it will pass padding to encode_plus() method, and in this method, it will process padding through _get_padding_truncation_strategies() method. This method do the same with the docstring. And this arg will be finally used in pad() method, which has the same docstring with this arg.

Copy link
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

Good point! Merging, and thanks for the PR!

@Rocketknight1 Rocketknight1 merged commit 328e2ae into huggingface:main Jan 23, 2025
25 checks passed
@baoyf4244 baoyf4244 deleted the fix_apply_chat_template_padding_choice branch January 24, 2025 07:22
bursteratom pushed a commit to bursteratom/transformers that referenced this pull request Jan 31, 2025
fix apply_chat_template() padding choice to bool, str, PaddingStrategy and the docstring of pad()
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.

2 participants