transformers - ✅(Solved) Fix v5.4.0 breaks `PretrainedConfig` type checking [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#45071Fetched 2026-04-08 01:40:45
View on GitHub
Comments
2
Participants
3
Timeline
13
Reactions
0
Author
Timeline (top)
cross-referenced ×5referenced ×3commented ×2labeled ×1

Error Message

transformers_typing.py:3: error: Unexpected keyword argument "vocab_size" for "LlamaConfig" [call-arg] Found 1 error in 1 file (checked 1 source file)

Fix Action

Fixed

PR fix notes

PR #372: Cap transformers at <5.4.0

Description (problem / solution / changelog)

<!-- markdownlint-disable -->

PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.

Purpose

Transformers v5.4.0 released March 26, 2026 introduced a couple issues that break speculators.

Issues:

<!--- Why your changes are needed -->

Description

This pr temporarily caps the transformers version until the issues are resolved.

<!--- High-level concise summary of changes -->

Related Issue

<!--- Link related issue if applicable -->

Tests

Run CI and confirm everything is working with transformers capped

<!--- Please describe in detail how you tested your changes. -->

I have filled in:

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan/results, such as providing test command and pasting the results.
  • (Optional) The necessary documentation update.
  • I (a human) have written or reviewed the code in this pr to the best of my ability.

Changed files

  • pyproject.toml (modified, +1/-1)

Code Example

# transformers_typing.py
from transformers import LlamaConfig
llama_config = LlamaConfig(vocab_size=32000)

---

mypy transformers_typing.py

---

transformers_typing.py:3: error: Unexpected keyword argument "vocab_size" for "LlamaConfig"  [call-arg]
Found 1 error in 1 file (checked 1 source file)
RAW_BUFFERClick to expand / collapse

System Info

transformers 5.4.0 mypy 1.19.1 python 3.10

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

# transformers_typing.py
from transformers import LlamaConfig
llama_config = LlamaConfig(vocab_size=32000)

Run mypy type checker

mypy transformers_typing.py

Output:

transformers_typing.py:3: error: Unexpected keyword argument "vocab_size" for "LlamaConfig"  [call-arg]
Found 1 error in 1 file (checked 1 source file)

Note: It's not just vocab_size that's missing. As far as I can tell, this fails with all config attributes.

Expected behavior

Type checking passes. Note: this is the case for transformers<5.4.0.

extent analysis

Fix Plan

The fix is to update the LlamaConfig initialization to match the expected arguments in transformers version 5.4.0.

  • Check the documentation for LlamaConfig in transformers version 5.4.0 to find the correct arguments.
  • Update the transformers_typing.py script to use the correct arguments.

Example code:

# transformers_typing.py
from transformers import LlamaConfig
llama_config = LlamaConfig(
    max_position_embeddings=512,
    vocab_size=32000,  # This might need to be removed or replaced
    hidden_size=4096,
    num_hidden_layers=24,
    num_attention_heads=64,
    # Add other required arguments here
)

Alternatively, you can try downgrading the transformers library to a version that supports the vocab_size argument, such as 4.24.0:

pip install transformers==4.24.0

Verification

Run the mypy type checker again to verify that the fix worked:

mypy transformers_typing.py

If the fix is correct, the type checker should not report any errors.

Extra Tips

  • Always check the documentation for the library version you are using to ensure you are using the correct arguments.
  • If you are using a newer version of a library, be prepared for potential breaking changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Type checking passes. Note: this is the case for transformers<5.4.0.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING