Skip to content

fix: validate special token ids against attribute values#45791

Merged
zucchini-nlp merged 1 commit into
huggingface:mainfrom
CharlieKerfoot:fix/iterating
May 6, 2026
Merged

fix: validate special token ids against attribute values#45791
zucchini-nlp merged 1 commit into
huggingface:mainfrom
CharlieKerfoot:fix/iterating

Conversation

@CharlieKerfoot

Copy link
Copy Markdown
Contributor

Summary

In src/transformers/configuration_utils.py:463, the special-token-id validation loop iterated over text_config, which yields attribute name strings. The subsequent isinstance(value, int) check was therefore always False, so out-of-vocab *_token_id values silently passed validation and never produced the intended warning.

Fix

Treat the loop variable as the attribute name and fetch the value via getattr before checking the type and range. The warning message now reports the attribute name and its value separately.

@Rocketknight1

Copy link
Copy Markdown
Member

cc @zucchini-nlp since this was added in #41250 - I think the whole warning branch was probably just never used?

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good catch!

@zucchini-nlp zucchini-nlp enabled auto-merge May 6, 2026 13:02
@zucchini-nlp zucchini-nlp added this pull request to the merge queue May 6, 2026
@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.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 6, 2026
@zucchini-nlp zucchini-nlp added this pull request to the merge queue May 6, 2026
Merged via the queue into huggingface:main with commit ec4d0aa May 6, 2026
30 checks passed
louzongzhi pushed a commit to louzongzhi/transformers that referenced this pull request May 11, 2026
…#45791)

fix: validate special token ids by fetching attribute values
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.

4 participants