Answers for LLM inference engineers

ImportError: cannot import name 'X' from 'transformers': which releases have each name

The installed transformers release does not export that name: it is either older than the release that added it or newer than the last release that had it. The fix is to install a release inside the range that has the name, or to import the replacement. Paste the error below to get the range for any of the 6,043 names that from transformers import ... has resolved between 2.0.0 and 5.26.0: 4,282 import in 5.26.0, and 1,619 are gone (640 of them are the TensorFlow and Flax classes that 5.0.0 removed).

Published 2026-11-17 · Updated 2026-11-18: which versions of diffusers, peft, optimum and trl import a removed name · Data as of 2026-12-05 · transformers 2.0.0 to 5.26.0, the first release of each of 103 minor versions, with patch releases that differ noted · read from the source of each release tag, nothing was installed or run (how, limits) · Corrected 2026-12-05

Corrected on 2026-12-05: this page read only the first release of each minor version, so a name added or removed in a patch release was dated to the next minor. For example, from transformers import Glm4Model works from 4.51.3 (2025-04-14), not only from 4.52.1, and Wav2Vec2ForCTC from 4.3.1 (2021-02-09), not only from 4.4.0. Every release was then read once from PyPI: 103 names differ in some patch release from the first release of the same minor (93 at the top level, 48 of them after 3.x). The lookup now gives those patch releases. The per-minor ranges and the tables are unchanged.

Examples:

Runs in your browser on data.json (356 KB); nothing you paste is sent anywhere. Covers transformers, transformers.utils and transformers.file_utils.

Which release has the names people ask about most?

The table gives the releases that export each name and, for the ones that are gone, the replacement named by the library's own deprecation message. "Through" is the last patch release before the name disappeared.

NameIn 5.26.0Releases that have it
AdamW
transformers
gone2.0.0 through 4.49.0; gone in 4.50.0 (2025-03-21)
Instead: torch.optim.AdamW (the class's own warning: "Use the PyTorch implementation torch.optim.AdamW instead").
AutoModelWithLMHead
transformers
gone2.0.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
Instead: AutoModelForCausalLM for causal language models, AutoModelForMaskedLM for masked ones, AutoModelForSeq2SeqLM for encoder-decoder models (the class's own warning).
top_k_top_p_filtering
transformers
gone2.6.0 through 4.38.2; gone in 4.39.0 (2024-03-21)
Instead: TopKLogitsWarper and TopPLogitsWarper (its warning: "scheduled for deletion in v4.39").
Conversation
transformers
gone3.1.0 through 4.41.2; gone in 4.42.0 (2024-06-27)
Instead: the text-generation pipeline with a list of message dicts (the warning of ConversationalPipeline).
TFAutoModel
transformers
gone2.0.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
Instead: nothing in transformers: v5 removed TensorFlow support, so every TF... name is gone. Use the PyTorch class of the same model, or stay below 5.0.
TFBertModel
transformers
gone2.0.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
Instead: nothing in transformers: v5 removed TensorFlow support, so every TF... name is gone. Use the PyTorch class of the same model, or stay below 5.0.
FlaxAutoModel
transformers
gone4.0.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
Instead: nothing in transformers: v5 removed Flax/JAX support, so every Flax... name is gone. Use the PyTorch class of the same model, or stay below 5.0.
BertTokenizerFast
transformers
imports2.4.0 through 4.57.6; gone in 5.0.0 (2026-01-26); from 5.0.0 on it is in no list but still imports (returns BertTokenizer)
ViTFeatureExtractor
transformers
gone4.5.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
Instead: the image processor of the same model (...ImageProcessor); the vision ...FeatureExtractor classes were deprecated aliases of them.
SummarizationPipeline
transformers
gone2.6.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
TranslationPipeline
transformers
gone2.7.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
glue_convert_examples_to_features
transformers
gone2.0.0 through 5.19.0; gone in 5.20.0 (2026-10-15)
Instead: the Hugging Face Datasets library (the deprecation message: "preprocessing should be handled with the Hugging Face Datasets library", pointing to examples/pytorch/text-classification/run_glue.py).
Tool
transformers
gone4.29.0 through 4.51.3; gone in 4.52.1 (2025-05-20)
Instead: the smolagents package (the agents' deprecation message: "Switch to smolagents instead, with the same functionalities and similar API").
HfAgent
transformers
gone4.29.0 through 4.40.2; gone in 4.41.0 (2024-05-17)
LogitsWarper
transformers
gone3.5.0 through 4.48.3; gone in 4.49.0 (2025-02-17)
Instead: inherit from LogitsProcessor, "which has the same properties and interface" (its own warning).
HybridCache
transformers
gone4.44.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
OffloadedCache
transformers
gone4.44.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
Instead: DynamicCache(offloading=True) (its own warning).
MambaCache
transformers
gone4.44.0 through 5.4.0; gone in 5.5.0 (2026-04-02)
TRANSFORMERS_CACHE
transformers
gone2.0.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
is_torch_tpu_available
transformers
gone3.0.0 through 4.50.3; gone in 4.51.0 (2025-04-05)
Instead: is_torch_xla_available (its own warning).
BERT_PRETRAINED_MODEL_ARCHIVE_LIST
transformers
gone2.11.0 through 4.40.2; gone in 4.41.0 (2024-05-17)
Instead: nothing: the lists of checkpoint names per model were deleted. Code that only printed or iterated them can drop the import; checkpoints are found on the Hub.
WarmupLinearSchedule
transformers
gone2.0.0 through 2.1.1; gone in 2.2.0 (2019-11-26)
pipeline
transformers
importsfrom 2.3.0 (2019-12-20), still in 5.26.0
AutoModelForSeq2SeqLM
transformers
importsfrom 3.0.0 (2020-06-29), still in 5.26.0
AutoModelForCausalLM
transformers
importsfrom 3.0.0 (2020-06-29), still in 5.26.0
Trainer
transformers
importsfrom 2.9.0 (2020-05-07), still in 5.26.0
get_scheduler
transformers
importsfrom 4.2.0 (2021-01-13), still in 5.26.0
BitsAndBytesConfig
transformers
importsfrom 4.27.0 (2023-03-15), still in 5.26.0
LlamaTokenizer
transformers
importsfrom 4.28.0 (2023-04-13), still in 5.26.0
TextStreamer
transformers
importsfrom 4.28.0 (2023-04-13), still in 5.26.0
TextIteratorStreamer
transformers
importsfrom 4.28.0 (2023-04-13), still in 5.26.0
GenerationMixin
transformers
importsfrom 4.25.1 (2022-12-01), still in 5.26.0
AutoImageProcessor
transformers
importsfrom 4.25.1 (2022-12-01), still in 5.26.0
AutoProcessor
transformers
importsfrom 4.13.0 (2021-12-09), still in 5.26.0
StaticCache
transformers
importsfrom 4.38.0 (2024-02-21), still in 5.26.0
EncoderDecoderCache
transformers
importsfrom 4.43.0 (2024-07-23), still in 5.26.0
QuantoConfig
transformers
importsfrom 4.39.0 (2024-03-21), still in 5.26.0
AutoModelForImageTextToText
transformers
importsfrom 4.46.1 (2024-10-29), still in 5.26.0
is_tokenizers_available
transformers.utils
importsfrom 4.18.0 (2022-04-06), still in 5.26.0
FLAX_WEIGHTS_NAME
transformers.utils
gone4.18.0 through 4.57.6; gone in 5.0.0 (2026-01-26)
SAFE_WEIGHTS_NAME
transformers.utils
importsfrom 4.23.0 (2022-10-10), still in 5.26.0
torch_int
transformers.utils
importsfrom 4.42.0 (2024-06-27), still in 5.26.0
_LazyModule
transformers.file_utils
importsfrom 4.9.0 (2021-07-22), still in 5.26.0
cached_path
transformers.file_utils
gone2.0.0 through 4.21.3; gone in 4.22.0 (2022-09-14)
is_torch_available
transformers.file_utils
importsfrom 2.0.0 (2019-09-26), still in 5.26.0
ModelOutput
transformers.file_utils
importsfrom 3.1.0 (2020-09-01), still in 5.26.0

Which library versions still import a removed name?

When the traceback points into another library, upgrading that library is the lasting fix; the table gives the version from which it no longer imports the name. For example trl imports top_k_top_p_filtering from 0.2.0 to 0.7.x and not from 0.8.0; peft imports HybridCache in 0.16.x and 0.17.x and not from 0.18.0; diffusers imports CLIPFeatureExtractor from 0.3.0 to 0.29.x and not from 0.30.0. These are imports at module level, outside any try block or function, in the file shown; whether that file is loaded when you import the library depends on what you use (diffusers and optimum load most pipeline files on demand).

NameGone inImported by
AutoModelForVision2Seq
transformers
5.0.0optimum 1.7.0 to 1.27.x, not from 2.0.0
optimum/onnxruntime/modeling_seq2seq.py
CLIPFeatureExtractor
transformers
5.0.0diffusers 0.3.0 to 0.29.x, not from 0.30.0
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py
optimum 1.7.0 to 1.27.x, not from 2.0.0
optimum/onnxruntime/modeling_diffusion.py
DPTFeatureExtractor
transformers
5.0.0diffusers 0.10.0 to 0.29.x, not from 0.30.0
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py
FlaxCLIPTextModel
transformers
5.0.0diffusers 0.4.0 to 0.39.x, not from 0.40.0
src/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py
FlaxPreTrainedModel
transformers
5.0.0diffusers 0.4.0 to 0.39.x, not from 0.40.0
src/diffusers/pipeline_flax_utils.py
HybridCache
transformers
5.0.0peft 0.16.0 to 0.17.x, not from 0.18.0
src/peft/peft_model.py
ImageToImagePipeline
transformers
5.3.0optimum 1.23.0 to 1.27.x, not from 2.0.0
optimum/pipelines/pipelines_base.py
ImageToTextPipeline
transformers
5.0.0optimum 1.7.0 to 1.27.x, not from 2.0.0
optimum/pipelines/pipelines_base.py
is_tf_available
transformers
5.0.0optimum 1.5.0 to 1.27.x, not from 2.0.0
optimum/exporters/tasks.py
MT5Tokenizer
transformers
5.0.0diffusers 0.29.0 to 0.36.x, not from 0.37.0
src/diffusers/pipelines/hunyuandit/pipeline_hunyuandit.py
QuestionAnsweringPipeline
transformers
5.3.0optimum 1.2.0 to 1.27.x, not from 2.0.0
optimum/pipelines.py
SummarizationPipeline
transformers
5.0.0optimum 1.3.0 to 1.27.x, not from 2.0.0
optimum/pipelines.py
Text2TextGenerationPipeline
transformers
5.0.0optimum 1.3.0 to 1.27.x, not from 2.0.0
optimum/pipelines.py
TFPreTrainedModel
transformers
5.0.0optimum 1.8.0 to 1.27.x, not from 2.0.0
optimum/exporters/tasks.py
top_k_top_p_filtering
transformers
4.39.0trl 0.2.0 to 0.7.x, not from 0.8.0
trl/core.py
TranslationPipeline
transformers
5.0.0optimum 1.3.0 to 1.27.x, not from 2.0.0
optimum/pipelines.py
cached_path
transformers.utils
4.22.0diffusers 0.0.2 to 0.0.x, not from 0.1.0
src/diffusers/configuration_utils.py
optimum 1.5.0 to 1.24.x, not from 1.25.0
optimum/configuration_utils.py
download_url
transformers.utils
5.0.0optimum 1.5.0 to 2.0.x, not from 2.1.0
optimum/configuration_utils.py
FLAX_WEIGHTS_NAME
transformers.utils
5.0.0diffusers 0.13.0 to 0.39.x, not from 0.40.0
src/diffusers/pipelines/pipeline_utils.py
get_full_repo_name
transformers.utils
5.0.0optimum 1.4.0 to 1.27.x, not from 2.0.0
optimum/onnxruntime/training_args.py
hf_bucket_url
transformers.utils
4.22.0diffusers 0.0.2 to 0.0.x, not from 0.1.0
src/diffusers/configuration_utils.py
optimum 1.5.0 to 1.24.x, not from 1.25.0
optimum/configuration_utils.py
HUGGINGFACE_CO_RESOLVE_ENDPOINT
transformers.utils
5.0.0diffusers 0.0.2 to 0.0.x, not from 0.1.0
src/diffusers/configuration_utils.py
is_offline_mode
transformers.utils
5.0.0diffusers 0.0.2 to 0.0.x, not from 0.1.0
src/diffusers/configuration_utils.py
optimum 1.4.0 to 1.4.x, not from 1.5.0
optimum/configuration_utils.py
optimum 1.25.0 to 1.27.x, not from 2.0.0
optimum/onnxruntime/modeling_ort.py
is_remote_url
transformers.utils
5.0.0diffusers 0.0.2 to 0.0.x, not from 0.1.0
src/diffusers/configuration_utils.py
optimum 1.5.0 to 2.0.x, not from 2.1.0
optimum/configuration_utils.py
is_safetensors_available
transformers.utils
5.0.0optimum 1.11.0 to 1.27.x, not from 2.0.0
optimum/onnxruntime/training_args.py
is_tf_available
transformers.utils
5.0.0optimum 1.5.0 to 1.27.x, not from 2.0.0
optimum/exporters/onnx/convert.py
is_torch_bf16_available
transformers.utils
5.0.0optimum 1.4.0 to 1.6.x, not from 1.7.0
optimum/onnxruntime/training_args.py
is_torch_bf16_cpu_available
transformers.utils
5.0.0optimum 1.7.0 to 1.27.x, not from 2.0.0
optimum/onnxruntime/training_args.py
TF2_WEIGHTS_NAME
transformers.utils
5.0.0optimum 1.5.0 to 2.0.x, not from 2.1.0
optimum/exporters/tasks.py
cached_path
transformers.file_utils
4.22.0optimum 1.0.0 to 1.3.x, not from 1.4.0
optimum/configuration_utils.py
default_cache_path
transformers.file_utils
5.0.0optimum 1.2.0 to 1.5.x, not from 1.6.0
optimum/onnxruntime/modeling_ort.py
get_list_of_files
transformers.file_utils
4.22.0optimum 1.0.0 to 1.3.x, not from 1.4.0
optimum/configuration_utils.py
hf_bucket_url
transformers.file_utils
4.22.0optimum 1.0.0 to 1.3.x, not from 1.4.0
optimum/configuration_utils.py
is_offline_mode
transformers.file_utils
5.0.0optimum 1.0.0 to 1.3.x, not from 1.4.0
optimum/configuration_utils.py
is_remote_url
transformers.file_utils
4.22.0optimum 1.0.0 to 1.3.x, not from 1.4.0
optimum/configuration_utils.py
is_tf_available
transformers.file_utils
5.0.0optimum 1.2.0 to 1.5.x, not from 1.6.0
optimum/onnx/configuration.py
is_torch_onnx_dict_inputs_support_available
transformers.file_utils
4.28.0optimum 1.1.0 to 1.1.x, not from 1.2.0
optimum/onnxruntime/trainer.py
is_torch_tpu_available
transformers.file_utils
4.39.0optimum 1.1.0 to 1.13.x, not from 1.14.0
optimum/onnxruntime/trainer.py

Read at the first release of each minor version of six libraries (newest read: accelerate 1.16.0, diffusers 0.43.0, optimum 2.3.1, peft 0.22.0, sentence-transformers 6.3.0, trl 1.19.0). In those newest releases no module-level import of a removed name is left. accelerate and sentence-transformers never had one.

Which releases removed the most names?

Two releases account for most of it: 5.0.0 dropped TensorFlow and Flax, and 4.41.0 deleted the per-model lists of checkpoint names. Counts are names that from transformers import stopped resolving in that release; names that still import through an alias are not counted. 25 other releases removed fewer than five names each (36 names in total); the lookup above knows them.

ReleaseDate (PyPI)Names goneWhat they were
2.2.02019-11-2614the scheduler classes (WarmupLinearSchedule and others, replaced by get_linear_schedule_with_warmup and its siblings), per-model load_..._pt_weights_in_tf2
2.11.02020-06-0244the first archive-map constants, memory-tracing helpers of the benchmark utilities, some early TF classes
4.41.02024-05-17490485 constants named ..._PRETRAINED_MODEL_ARCHIVE_LIST or ..._PRETRAINED_CONFIG_ARCHIVE_MAP; the first agents (HfAgent, LocalAgent, OpenAiAgent)
4.45.02024-09-2533internal layer classes that had been exported by accident (BertLayer, LongformerSelfAttention, ReformerLayer and others), ForceTokensLogitsProcessor, HfEngine
4.49.02025-02-175LogitsWarper and the benchmark classes (PyTorchBenchmark, TensorFlowBenchmark and their arguments)
4.52.12025-05-2017the agents framework (Tool, ReactCodeAgent, load_tool ...), moved to the smolagents package
4.56.02025-08-297cache configuration classes (CacheConfig, QuantizedCacheConfig and the cache processors)
5.0.02026-01-26976TensorFlow and Flax support removed: 428 TF... and 212 Flax... names. Also 30 vision ...FeatureExtractor classes (use ...ImageProcessor), 73 ...OnnxConfig classes, AutoModelWithLMHead, the summarization, translation and text2text pipelines classes, TRANSFORMERS_CACHE, and deprecated models such as TransfoXL, Deta and EfficientFormer
5.3.02026-03-045Ernie4_5_VL_MoeProcessor, Ernie4_5_VL_MoeVideoProcessor, ImageToImagePipeline, QuestionAnsweringPipeline, VisualQuestionAnsweringPipeline
5.20.02026-10-1524the GLUE, SQuAD and XNLI helpers (glue_convert_examples_to_features, SquadDataset, InputExample, DataProcessor ...), DataCollatorForWholeWordMask, DataCollatorForSOP

Why do BertTokenizerFast and ...ImageProcessorFast still import in 5.x?

Because the lazy module answers for them even though no list has them. From 5.0.0, _LazyModule.__getattr__ (utils/import_utils.py) resolves a missing name ending in TokenizerFast to the class without the suffix, and tries the table SLOW_TO_FAST_CONVERTERS for tokenizer names whose class was merged into another one. From 5.4.0 it does the same for names ending in ImageProcessorFast, with a deprecation warning. In 5.26.0, 47 names ending in TokenizerFast and 91 ending in ImageProcessorFast import this way, and the object you get is the class without the suffix. The lookup reports these as "imports", with the class that is returned. A ...TokenizerFast name whose model lost its tokenizer class altogether is not rescued and raises the ImportError.

What about transformers.utils and transformers.file_utils?

transformers.file_utils has been a compatibility shim since 4.18.0, and both modules lost their TensorFlow and Flax helpers in 5.0.0. Up to 4.17.0, file_utils.py held the helpers themselves; 4.18.0 moved them into transformers/utils/ and left a module that re-exports part of them, so 170 names stopped being importable from transformers.file_utils in that one release (most of them are in transformers.utils from then on). 82 names are left in 5.26.0. transformers.utils exists as a package from 3.1.0 and binds 281 names in 5.26.0; 5.0.0 removed 43 (the is_tf_available and is_flax_available families, TF2_WEIGHTS_NAME, FLAX_WEIGHTS_NAME and similar). Other packages often import private helpers from these two modules, which is why diffusers, sentence-transformers or a model's remote code can fail right after a transformers upgrade.

How do I read the error?

How was this read, and how was it checked?

From the source of each release tag, with Python's ast module; no release was installed or imported.

Checks, all by a second reading rather than by running the library: (1) lazy releases keep a static copy of the lists for type checkers, the imports under if TYPE_CHECKING:; in all 83 lazy releases every name of that copy is in our reading, and 49 of them are identical (the rest have up to 26 runtime names that upstream forgot to mirror; those do import). (2) __all__ was read a second time line by line, the way the library's own fetch__all__ does, for 5,068 model files of three releases, with no difference. (3) every "library imports a removed name" range (44 of them) was confirmed by a plain-text search of that library's files at both ends of the range and in the version after it. (4) 19 known facts from release notes and forum threads (for example AdamW gone in 4.50.0, LlamaTokenizer new in 4.28.0, TF classes gone in 5.0.0) all hold.

Limits

Questions

Why do I get "ImportError: cannot import name ... from 'transformers'"?

The installed transformers release does not export that name. Either the release is older than the one that added the name, or it is newer than the last one that had it. The name usually comes from your own code, a tutorial, or another package that was written for a different transformers release. Install a release inside the range that has the name, or change the import to its replacement.

Which transformers version removed AdamW?

transformers 4.50.0 (2025-03-21). AdamW is importable from transformers 2.0.0 through 4.49.0. The class's own deprecation warning names the replacement: torch.optim.AdamW.

Why did TFBertModel, TFAutoModel and the Flax classes disappear?

transformers 5.0.0 (2026-01-26) removed TensorFlow and Flax support. 428 names starting with TF and 212 starting with Flax stopped being exported in that release. They are importable through 4.57.6; with 5.x use the PyTorch class of the same model.

Does BertTokenizerFast still import in transformers 5?

Yes. From 5.0.0 the name is not in the import lists any more, but the lazy module resolves a name ending in TokenizerFast to the class without the suffix, so the import returns BertTokenizer. 47 tokenizer names and, from 5.4.0, 91 image processor names ending in ImageProcessorFast keep importing this way in 5.26.0.

Another package fails with this ImportError. What do I pin?

Pin transformers to the range that has the name: at least the first release that exports it and below the release that dropped it, for example pip install "transformers>=4.29.0,<4.52.1" for the agents classes. Then look for a newer release of the other package; a pin that old also holds back every model added since.

Sources

The same data as JSON: data.json, licensed CC BY 4.0.

Related: "does not recognize this architecture": the Transformers, vLLM and llama.cpp version each model needs · "got an unexpected keyword argument": PEFT, TRL and TrainingArguments by version · "cannot import name 'cached_download' from 'huggingface_hub'": the hub releases that have each name.