Add tokenizer_kwargs argument to the text generation pipeline - #40364
Conversation
|
The test failure seems to be an unrelated flake: Pushing an empty commit to re-run the CI. |
|
A disjoint set of tests have failed in the re-run. |
|
@Rocketknight1 Please review this PR when you have a chance. The CI failures seem to be caused by unrelated, flaky tests. |
92b4d49 to
2fe0979
Compare
Rocketknight1
left a comment
There was a problem hiding this comment.
This LGTM! cc @gante just in case you have opinions about the max_length generate kwarg clash.
|
Also @Joshua-Chin you may need to rebase to fix some conflicts before we can merge the PR! That should also clear up the CI issues. |
gante
left a comment
There was a problem hiding this comment.
One question about variable names, otherwise lgtm :)
| - `None` : default strategy where nothing in particular happens | ||
| - `"hole"`: Truncates left of input, and leaves a gap wide enough to let generation happen (might | ||
| truncate a lot of the prompt and not suitable when generation exceed the model capacity) | ||
| tokenizer_kwargs (`dict`, *optional*): |
There was a problem hiding this comment.
perhaps tokenizer_encode_kwargs? There are also kwargs used at decode time, and we don't want to mix the two
There was a problem hiding this comment.
@gante I updated the argument to tokenizer_encode_kwargs. Please take another look when you have a chance.
2fe0979 to
e484dbb
Compare
|
The CI is currently failing because of the following test, added by a recently merged change (HunYuan opensource #39606):
|
d80a814 to
f1d1dc1
Compare
|
@Joshua-Chin I've clicked on "Update branch" (= pull from main new code), in hopes the CI error was a transient issue in our codebase 🤗 |
|
Nope, didn't fix it. It's unrelated to this PR, I'll have a look to see what's wrong |
|
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. |
What does this PR do?
This PR adds a
tokenizer_kwargsargument to theTextGenerationPipeline, allowing users to pass arbitrary arguments to the tokenizer during preprocessing. In particular, this lets users set chat template arguments, such as theenable_thinkingflag for Qwen3 or SmolLM3.Before submitting
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.