transformers - 💡(How to fix) Fix transformers>=5.1.0 fails when loading physical-intelligence/fast [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#44987Fetched 2026-04-08 01:26:15
View on GitHub
Comments
2
Participants
3
Timeline
10
Reactions
0
Author
Timeline (top)
mentioned ×3subscribed ×3commented ×2cross-referenced ×1

Error Message

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "../lib/python3.10/site-packages/transformers/models/auto/processing_auto.py", line 394, in from_pretrained
    return processor_class.from_pretrained(
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1402, in from_pretrained
    args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, processor_dict, **kwargs)
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1516, in _get_arguments_from_pretrained
    tokenizer = cls._load_tokenizer_from_pretrained(
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1469, in _load_tokenizer_from_pretrained
    tokenizer = auto_processor_class.from_pretrained(
  File "../lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 725, in from_pretrained
    return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1712, in from_pretrained
    return cls._from_pretrained(
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1900, in _from_pretrained
    tokenizer = cls(*init_inputs, **init_kwargs)
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_tokenizers.py", line 274, in __init__
    raise ValueError(
ValueError: Couldn't instantiate the backend tokenizer from one of: 
(1) a `tokenizers` library serialization file, 
(2) a slow tokenizer instance to convert or 
(3) an equivalent slow tokenizer class to instantiate and convert. 
You need to have sentencepiece or tiktoken installed to convert a slow tokenizer to a fast one.

Code Example

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "../lib/python3.10/site-packages/transformers/models/auto/processing_auto.py", line 394, in from_pretrained
    return processor_class.from_pretrained(
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1402, in from_pretrained
    args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, processor_dict, **kwargs)
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1516, in _get_arguments_from_pretrained
    tokenizer = cls._load_tokenizer_from_pretrained(
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1469, in _load_tokenizer_from_pretrained
    tokenizer = auto_processor_class.from_pretrained(
  File "../lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 725, in from_pretrained
    return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1712, in from_pretrained
    return cls._from_pretrained(
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1900, in _from_pretrained
    tokenizer = cls(*init_inputs, **init_kwargs)
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_tokenizers.py", line 274, in __init__
    raise ValueError(
ValueError: Couldn't instantiate the backend tokenizer from one of: 
(1) a `tokenizers` library serialization file, 
(2) a slow tokenizer instance to convert or 
(3) an equivalent slow tokenizer class to instantiate and convert. 
You need to have sentencepiece or tiktoken installed to convert a slow tokenizer to a fast one.

---

from transformers import AutoProcessor
p = AutoProcessor.from_pretrained("../physical-intelligence/fast", trust_remote_code=True)

---

from transformers import AutoProcessor
p = AutoProcessor.from_pretrained("../physical-intelligence/fast", trust_remote_code=True, use_fast=False)
RAW_BUFFERClick to expand / collapse

System Info

System info:

  • model: physical-intelligence/fast
  • Python version: 3.10.19
  • PyTorch: 2.8.0+cu128 (CUDA)
  • huggingface-hub: 1.7.2
  • transformers: 5.2.0

Error message

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "../lib/python3.10/site-packages/transformers/models/auto/processing_auto.py", line 394, in from_pretrained
    return processor_class.from_pretrained(
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1402, in from_pretrained
    args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, processor_dict, **kwargs)
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1516, in _get_arguments_from_pretrained
    tokenizer = cls._load_tokenizer_from_pretrained(
  File "../lib/python3.10/site-packages/transformers/processing_utils.py", line 1469, in _load_tokenizer_from_pretrained
    tokenizer = auto_processor_class.from_pretrained(
  File "../lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 725, in from_pretrained
    return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1712, in from_pretrained
    return cls._from_pretrained(
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1900, in _from_pretrained
    tokenizer = cls(*init_inputs, **init_kwargs)
  File "../lib/python3.10/site-packages/transformers/tokenization_utils_tokenizers.py", line 274, in __init__
    raise ValueError(
ValueError: Couldn't instantiate the backend tokenizer from one of: 
(1) a `tokenizers` library serialization file, 
(2) a slow tokenizer instance to convert or 
(3) an equivalent slow tokenizer class to instantiate and convert. 
You need to have sentencepiece or tiktoken installed to convert a slow tokenizer to a fast one.

My attempts

  1. pip install sentencepiece tiktoken
  2. set use_fast=False
  3. transformers==4.57.3 works fine but I need to use Qwen3.5, which requires transformers>=5.2.0

Who can help?

@ArthurZucker @itazap

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 version

I tried transformers==5.1.0, 5.2.0, 5.3.0, and they all give me the same error message:

Reproduction

from transformers import AutoProcessor
p = AutoProcessor.from_pretrained("../physical-intelligence/fast", trust_remote_code=True)

and

from transformers import AutoProcessor
p = AutoProcessor.from_pretrained("../physical-intelligence/fast", trust_remote_code=True, use_fast=False)

Expected behavior

no error message

extent analysis

Fix Plan

To resolve the ValueError caused by the inability to instantiate the backend tokenizer, you need to ensure that the required libraries (sentencepiece or tiktoken) are installed and properly utilized. Given that you've already attempted installing these libraries, the issue might stem from the version compatibility or the way you're loading the tokenizer. Here's a step-by-step solution:

  1. Install Required Libraries: Ensure sentencepiece and tiktoken are installed. You've mentioned you've done this, but for clarity:

pip install sentencepiece tiktoken


2. **Specify `use_fast` Parameter**: When loading the `AutoProcessor`, try setting `use_fast=False` explicitly to avoid any potential issues with fast tokenizers:
   ```python
from transformers import AutoProcessor
p = AutoProcessor.from_pretrained("../physical-intelligence/fast", trust_remote_code=True, use_fast=False)
  1. Check Model Compatibility: Since you're constrained to using transformers>=5.2.0 due to Qwen3.5 requirements, ensure that the model you're trying to load ("../physical-intelligence/fast") is compatible with this version of transformers. If the model is not compatible, you might need to find an alternative model or adjust your project requirements.

  2. Alternative Approach: If the above steps don't work, consider loading the tokenizer and model separately to better diagnose the issue:

from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("../physical-intelligence/fast", use_fast=False) model = AutoModelForSequenceClassification.from_pretrained("../physical-intelligence/fast")


### Verification
To verify that the fix worked, successfully execute the code without encountering the `ValueError`. You should be able to load the `AutoProcessor` or the tokenizer and model without any errors.

### Extra Tips
- Ensure your environment is clean and managed (e.g., using `venv` or `conda`) to avoid version conflicts.
- If you're working in a team or planning to deploy your model, consider adding the required libraries and versions to your project's `requirements.txt` to ensure reproducibility.
- Always check the Hugging Face model hub for the most current information on model compatibility and requirements.

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

no error message

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

transformers - 💡(How to fix) Fix transformers>=5.1.0 fails when loading physical-intelligence/fast [2 comments, 3 participants]