transformers - 💡(How to fix) Fix transformers in Python 3.14 failed to load [3 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#44938Fetched 2026-04-08 01:16:50
View on GitHub
Comments
3
Participants
3
Timeline
9
Reactions
0
Author
Timeline (top)
commented ×3mentioned ×2subscribed ×2closed ×1
RAW_BUFFERClick to expand / collapse

System Info

Python 3.14

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 v5.3.0 has failed to load AutoModelForImageTextToText in Python 3.14, but it worked on Python 3.12. It saids I need tensorflow even I only use torch.

ValueError: Backend should be defined in the BACKENDS_MAPPING. Offending backend: tf

Expected behavior

It seems old code is used for Python 3.14 wheel

extent analysis

Fix Plan

The fix involves ensuring the correct backend is used for the transformers library.

  • Step 1: Install the required backend
    • The error indicates that the tf backend is required, but you're using torch. You can try installing tensorflow to see if it resolves the issue:

pip install tensorflow

    *   Alternatively, you can try to force the use of the `torch` backend by setting the `TF_FORCE_GPU_ALLOW_GROWTH` environment variable or by using the `torch` backend explicitly in your code.
*   **Step 2: Specify the backend in your code**
    *   You can specify the backend when loading the model:
    ```python
from transformers import AutoModelForImageTextToText

# Specify the backend
model = AutoModelForImageTextToText.from_pretrained("model_name", torch_dtype="auto", trust_remote_code=True)
*   Make sure to replace `"model_name"` with the actual name of the model you're trying to load.

Verification

To verify that the fix worked, try running your code again after applying the above steps. If you're still encountering issues, ensure that your transformers library is up-to-date:

pip install --upgrade transformers

Extra Tips

  • Be aware of the version compatibility between your Python version, transformers library, and the backend you're using.
  • If you're using a virtual environment, ensure that the required packages are installed in the correct environment.

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

It seems old code is used for Python 3.14 wheel

Still need to ship something?

×6

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

Back to top recommendations

TRENDING