Fix max_length/max_new_tokens conflict in Chapter 1.3 - #1287
Open
sihan-bzwj wants to merge 2 commits into
Open
Conversation
## Summary Fix the text-generation example in Chapter 1.3 by replacing `max_length` with `max_new_tokens`. In recent versions of `transformers`, the text-generation pipeline may already define `max_new_tokens`, which causes a conflict when the course example explicitly passes `max_length`. Since `max_new_tokens` takes precedence, the example may not control the generated output length as intended. ## Changes * Replace `max_length=30` with `max_new_tokens=30` * Update the surrounding explanation to use `max_new_tokens` * Clarify that generation length is measured in tokens, not words This PR intentionally updates only the English source. Localized versions can be synchronized separately through the translation workflow. Fixes huggingface#1285
Updated text to clarify the maximum number of newly generated tokens.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the text-generation example in Chapter 1.3 by replacing
max_lengthwithmax_new_tokens.In recent versions of
transformers, the text-generation pipeline may already definemax_new_tokens, which causes a conflict when the course example explicitly passesmax_length. Sincemax_new_tokenstakes precedence, the example may not control the generated output length as intended.Changes
max_length=30withmax_new_tokens=30max_new_tokensThis PR intentionally updates only the English source. Localized versions can be synchronized separately through the translation workflow.
Fixes #1285