Skip to content

Fix Wav2Vec2Config.vocab_size type to allow None#45108

Merged
Rocketknight1 merged 1 commit intohuggingface:mainfrom
jiqing-feng:ac
Apr 9, 2026
Merged

Fix Wav2Vec2Config.vocab_size type to allow None#45108
Rocketknight1 merged 1 commit intohuggingface:mainfrom
jiqing-feng:ac

Conversation

@jiqing-feng
Copy link
Copy Markdown
Contributor

Description

Some wav2vec2 models (e.g. audio classification variants) have vocab_size: null in their config.json. The current type annotation vocab_size: int = 32 causes huggingface_hub's strict dataclass validation to reject None, making these models fail to load.

The fix changes the type annotation to int | None.

Reproduction

from transformers import pipeline

pipe = pipeline("audio-classification", "audeering/wav2vec2-large-robust-12-ft-emotion-msp-dim")
huggingface_hub.errors.StrictDataclassFieldValidationError: Validation error for field 'vocab_size':
    TypeError: Field 'vocab_size' expected int, got NoneType (value: None)

Fix

- vocab_size: int = 32
+ vocab_size: int | None = 32

@jiqing-feng jiqing-feng marked this pull request as ready for review March 30, 2026 03:06
Copy link
Copy Markdown
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.

Seems safe so I'm happy to accept!

@Rocketknight1 Rocketknight1 enabled auto-merge March 30, 2026 14:29
@Rocketknight1 Rocketknight1 added this pull request to the merge queue Mar 30, 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 Mar 30, 2026
@jiqing-feng
Copy link
Copy Markdown
Contributor Author

Hi @ydshieh . Would you please review this PR? Thanks!

@jiqing-feng
Copy link
Copy Markdown
Contributor Author

Hi @Rocketknight1 . Would you please review this PR? The auto-merge is failed because of the CI which is not related to my changes.

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
@Rocketknight1
Copy link
Copy Markdown
Member

@jiqing-feng yes, I'll try to merge now.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

[For maintainers] Suggested jobs to run (before merge)

run-slow: wav2vec2

@Rocketknight1 Rocketknight1 enabled auto-merge April 9, 2026 14:26
@Rocketknight1 Rocketknight1 added this pull request to the merge queue Apr 9, 2026
Merged via the queue into huggingface:main with commit 83c3672 Apr 9, 2026
28 checks passed
sirzechs66 pushed a commit to sirzechs66/transformers that referenced this pull request Apr 18, 2026
fix wav2vec2 config

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
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.

3 participants