Skip to content

Fix max_length/max_new_tokens conflict in Chapter 1.3 - #1287

Open
sihan-bzwj wants to merge 2 commits into
huggingface:mainfrom
sihan-bzwj:fix-chapter1-max-new-tokens
Open

Fix max_length/max_new_tokens conflict in Chapter 1.3#1287
sihan-bzwj wants to merge 2 commits into
huggingface:mainfrom
sihan-bzwj:fix-chapter1-max-new-tokens

Conversation

@sihan-bzwj

Copy link
Copy Markdown

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 #1285

## 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.
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

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.

Chapter 1.3 distilgpt2 example triggers a max_length/max_new_tokens conflict

2 participants