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).
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.
| Name | In 5.26.0 | Releases that have it |
|---|---|---|
AdamWtransformers | gone | 2.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"). |
AutoModelWithLMHeadtransformers | gone | 2.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_filteringtransformers | gone | 2.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"). |
Conversationtransformers | gone | 3.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). |
TFAutoModeltransformers | gone | 2.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. |
TFBertModeltransformers | gone | 2.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. |
FlaxAutoModeltransformers | gone | 4.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. |
BertTokenizerFasttransformers | imports | 2.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) |
ViTFeatureExtractortransformers | gone | 4.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. |
SummarizationPipelinetransformers | gone | 2.6.0 through 4.57.6; gone in 5.0.0 (2026-01-26) |
TranslationPipelinetransformers | gone | 2.7.0 through 4.57.6; gone in 5.0.0 (2026-01-26) |
glue_convert_examples_to_featurestransformers | gone | 2.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). |
Tooltransformers | gone | 4.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"). |
HfAgenttransformers | gone | 4.29.0 through 4.40.2; gone in 4.41.0 (2024-05-17) |
LogitsWarpertransformers | gone | 3.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). |
HybridCachetransformers | gone | 4.44.0 through 4.57.6; gone in 5.0.0 (2026-01-26) |
OffloadedCachetransformers | gone | 4.44.0 through 4.57.6; gone in 5.0.0 (2026-01-26) Instead: DynamicCache(offloading=True) (its own warning). |
MambaCachetransformers | gone | 4.44.0 through 5.4.0; gone in 5.5.0 (2026-04-02) |
TRANSFORMERS_CACHEtransformers | gone | 2.0.0 through 4.57.6; gone in 5.0.0 (2026-01-26) |
is_torch_tpu_availabletransformers | gone | 3.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_LISTtransformers | gone | 2.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. |
WarmupLinearScheduletransformers | gone | 2.0.0 through 2.1.1; gone in 2.2.0 (2019-11-26) |
pipelinetransformers | imports | from 2.3.0 (2019-12-20), still in 5.26.0 |
AutoModelForSeq2SeqLMtransformers | imports | from 3.0.0 (2020-06-29), still in 5.26.0 |
AutoModelForCausalLMtransformers | imports | from 3.0.0 (2020-06-29), still in 5.26.0 |
Trainertransformers | imports | from 2.9.0 (2020-05-07), still in 5.26.0 |
get_schedulertransformers | imports | from 4.2.0 (2021-01-13), still in 5.26.0 |
BitsAndBytesConfigtransformers | imports | from 4.27.0 (2023-03-15), still in 5.26.0 |
LlamaTokenizertransformers | imports | from 4.28.0 (2023-04-13), still in 5.26.0 |
TextStreamertransformers | imports | from 4.28.0 (2023-04-13), still in 5.26.0 |
TextIteratorStreamertransformers | imports | from 4.28.0 (2023-04-13), still in 5.26.0 |
GenerationMixintransformers | imports | from 4.25.1 (2022-12-01), still in 5.26.0 |
AutoImageProcessortransformers | imports | from 4.25.1 (2022-12-01), still in 5.26.0 |
AutoProcessortransformers | imports | from 4.13.0 (2021-12-09), still in 5.26.0 |
StaticCachetransformers | imports | from 4.38.0 (2024-02-21), still in 5.26.0 |
EncoderDecoderCachetransformers | imports | from 4.43.0 (2024-07-23), still in 5.26.0 |
QuantoConfigtransformers | imports | from 4.39.0 (2024-03-21), still in 5.26.0 |
AutoModelForImageTextToTexttransformers | imports | from 4.46.1 (2024-10-29), still in 5.26.0 |
is_tokenizers_availabletransformers.utils | imports | from 4.18.0 (2022-04-06), still in 5.26.0 |
FLAX_WEIGHTS_NAMEtransformers.utils | gone | 4.18.0 through 4.57.6; gone in 5.0.0 (2026-01-26) |
SAFE_WEIGHTS_NAMEtransformers.utils | imports | from 4.23.0 (2022-10-10), still in 5.26.0 |
torch_inttransformers.utils | imports | from 4.42.0 (2024-06-27), still in 5.26.0 |
_LazyModuletransformers.file_utils | imports | from 4.9.0 (2021-07-22), still in 5.26.0 |
cached_pathtransformers.file_utils | gone | 2.0.0 through 4.21.3; gone in 4.22.0 (2022-09-14) |
is_torch_availabletransformers.file_utils | imports | from 2.0.0 (2019-09-26), still in 5.26.0 |
ModelOutputtransformers.file_utils | imports | from 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).
| Name | Gone in | Imported by |
|---|---|---|
AutoModelForVision2Seqtransformers | 5.0.0 | optimum 1.7.0 to 1.27.x, not from 2.0.0optimum/onnxruntime/modeling_seq2seq.py |
CLIPFeatureExtractortransformers | 5.0.0 | diffusers 0.3.0 to 0.29.x, not from 0.30.0src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.pyoptimum 1.7.0 to 1.27.x, not from 2.0.0 optimum/onnxruntime/modeling_diffusion.py |
DPTFeatureExtractortransformers | 5.0.0 | diffusers 0.10.0 to 0.29.x, not from 0.30.0src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py |
FlaxCLIPTextModeltransformers | 5.0.0 | diffusers 0.4.0 to 0.39.x, not from 0.40.0src/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py |
FlaxPreTrainedModeltransformers | 5.0.0 | diffusers 0.4.0 to 0.39.x, not from 0.40.0src/diffusers/pipeline_flax_utils.py |
HybridCachetransformers | 5.0.0 | peft 0.16.0 to 0.17.x, not from 0.18.0src/peft/peft_model.py |
ImageToImagePipelinetransformers | 5.3.0 | optimum 1.23.0 to 1.27.x, not from 2.0.0optimum/pipelines/pipelines_base.py |
ImageToTextPipelinetransformers | 5.0.0 | optimum 1.7.0 to 1.27.x, not from 2.0.0optimum/pipelines/pipelines_base.py |
is_tf_availabletransformers | 5.0.0 | optimum 1.5.0 to 1.27.x, not from 2.0.0optimum/exporters/tasks.py |
MT5Tokenizertransformers | 5.0.0 | diffusers 0.29.0 to 0.36.x, not from 0.37.0src/diffusers/pipelines/hunyuandit/pipeline_hunyuandit.py |
QuestionAnsweringPipelinetransformers | 5.3.0 | optimum 1.2.0 to 1.27.x, not from 2.0.0optimum/pipelines.py |
SummarizationPipelinetransformers | 5.0.0 | optimum 1.3.0 to 1.27.x, not from 2.0.0optimum/pipelines.py |
Text2TextGenerationPipelinetransformers | 5.0.0 | optimum 1.3.0 to 1.27.x, not from 2.0.0optimum/pipelines.py |
TFPreTrainedModeltransformers | 5.0.0 | optimum 1.8.0 to 1.27.x, not from 2.0.0optimum/exporters/tasks.py |
top_k_top_p_filteringtransformers | 4.39.0 | trl 0.2.0 to 0.7.x, not from 0.8.0trl/core.py |
TranslationPipelinetransformers | 5.0.0 | optimum 1.3.0 to 1.27.x, not from 2.0.0optimum/pipelines.py |
cached_pathtransformers.utils | 4.22.0 | diffusers 0.0.2 to 0.0.x, not from 0.1.0src/diffusers/configuration_utils.pyoptimum 1.5.0 to 1.24.x, not from 1.25.0 optimum/configuration_utils.py |
download_urltransformers.utils | 5.0.0 | optimum 1.5.0 to 2.0.x, not from 2.1.0optimum/configuration_utils.py |
FLAX_WEIGHTS_NAMEtransformers.utils | 5.0.0 | diffusers 0.13.0 to 0.39.x, not from 0.40.0src/diffusers/pipelines/pipeline_utils.py |
get_full_repo_nametransformers.utils | 5.0.0 | optimum 1.4.0 to 1.27.x, not from 2.0.0optimum/onnxruntime/training_args.py |
hf_bucket_urltransformers.utils | 4.22.0 | diffusers 0.0.2 to 0.0.x, not from 0.1.0src/diffusers/configuration_utils.pyoptimum 1.5.0 to 1.24.x, not from 1.25.0 optimum/configuration_utils.py |
HUGGINGFACE_CO_RESOLVE_ENDPOINTtransformers.utils | 5.0.0 | diffusers 0.0.2 to 0.0.x, not from 0.1.0src/diffusers/configuration_utils.py |
is_offline_modetransformers.utils | 5.0.0 | diffusers 0.0.2 to 0.0.x, not from 0.1.0src/diffusers/configuration_utils.pyoptimum 1.4.0 to 1.4.x, not from 1.5.0 optimum/configuration_utils.pyoptimum 1.25.0 to 1.27.x, not from 2.0.0 optimum/onnxruntime/modeling_ort.py |
is_remote_urltransformers.utils | 5.0.0 | diffusers 0.0.2 to 0.0.x, not from 0.1.0src/diffusers/configuration_utils.pyoptimum 1.5.0 to 2.0.x, not from 2.1.0 optimum/configuration_utils.py |
is_safetensors_availabletransformers.utils | 5.0.0 | optimum 1.11.0 to 1.27.x, not from 2.0.0optimum/onnxruntime/training_args.py |
is_tf_availabletransformers.utils | 5.0.0 | optimum 1.5.0 to 1.27.x, not from 2.0.0optimum/exporters/onnx/convert.py |
is_torch_bf16_availabletransformers.utils | 5.0.0 | optimum 1.4.0 to 1.6.x, not from 1.7.0optimum/onnxruntime/training_args.py |
is_torch_bf16_cpu_availabletransformers.utils | 5.0.0 | optimum 1.7.0 to 1.27.x, not from 2.0.0optimum/onnxruntime/training_args.py |
TF2_WEIGHTS_NAMEtransformers.utils | 5.0.0 | optimum 1.5.0 to 2.0.x, not from 2.1.0optimum/exporters/tasks.py |
cached_pathtransformers.file_utils | 4.22.0 | optimum 1.0.0 to 1.3.x, not from 1.4.0optimum/configuration_utils.py |
default_cache_pathtransformers.file_utils | 5.0.0 | optimum 1.2.0 to 1.5.x, not from 1.6.0optimum/onnxruntime/modeling_ort.py |
get_list_of_filestransformers.file_utils | 4.22.0 | optimum 1.0.0 to 1.3.x, not from 1.4.0optimum/configuration_utils.py |
hf_bucket_urltransformers.file_utils | 4.22.0 | optimum 1.0.0 to 1.3.x, not from 1.4.0optimum/configuration_utils.py |
is_offline_modetransformers.file_utils | 5.0.0 | optimum 1.0.0 to 1.3.x, not from 1.4.0optimum/configuration_utils.py |
is_remote_urltransformers.file_utils | 4.22.0 | optimum 1.0.0 to 1.3.x, not from 1.4.0optimum/configuration_utils.py |
is_tf_availabletransformers.file_utils | 5.0.0 | optimum 1.2.0 to 1.5.x, not from 1.6.0optimum/onnx/configuration.py |
is_torch_onnx_dict_inputs_support_availabletransformers.file_utils | 4.28.0 | optimum 1.1.0 to 1.1.x, not from 1.2.0optimum/onnxruntime/trainer.py |
is_torch_tpu_availabletransformers.file_utils | 4.39.0 | optimum 1.1.0 to 1.13.x, not from 1.14.0optimum/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.
| Release | Date (PyPI) | Names gone | What they were |
|---|---|---|---|
| 2.2.0 | 2019-11-26 | 14 | the scheduler classes (WarmupLinearSchedule and others, replaced by get_linear_schedule_with_warmup and its siblings), per-model load_..._pt_weights_in_tf2 |
| 2.11.0 | 2020-06-02 | 44 | the first archive-map constants, memory-tracing helpers of the benchmark utilities, some early TF classes |
| 4.41.0 | 2024-05-17 | 490 | 485 constants named ..._PRETRAINED_MODEL_ARCHIVE_LIST or ..._PRETRAINED_CONFIG_ARCHIVE_MAP; the first agents (HfAgent, LocalAgent, OpenAiAgent) |
| 4.45.0 | 2024-09-25 | 33 | internal layer classes that had been exported by accident (BertLayer, LongformerSelfAttention, ReformerLayer and others), ForceTokensLogitsProcessor, HfEngine |
| 4.49.0 | 2025-02-17 | 5 | LogitsWarper and the benchmark classes (PyTorchBenchmark, TensorFlowBenchmark and their arguments) |
| 4.52.1 | 2025-05-20 | 17 | the agents framework (Tool, ReactCodeAgent, load_tool ...), moved to the smolagents package |
| 4.56.0 | 2025-08-29 | 7 | cache configuration classes (CacheConfig, QuantizedCacheConfig and the cache processors) |
| 5.0.0 | 2026-01-26 | 976 | TensorFlow 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.0 | 2026-03-04 | 5 | Ernie4_5_VL_MoeProcessor, Ernie4_5_VL_MoeVideoProcessor, ImageToImagePipeline, QuestionAnsweringPipeline, VisualQuestionAnsweringPipeline |
| 5.20.0 | 2026-10-15 | 24 | the 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?
- The module after "from" tells you which table to look in.
from 'transformers'is the top level;from 'transformers.utils'andfrom 'transformers.file_utils'are the two helper modules this page also covers. - The path in parentheses is the copy of transformers that was imported. If the version there is not the one you thought you installed (a second environment, a user-site copy, a notebook kernel that was not restarted), fix that first:
python -c "import transformers; print(transformers.__version__, transformers.__file__)". - The traceback tells you who asked for the name. If it is another package, upgrading that package is the lasting fix and pinning transformers is the quick one.
- "(unknown location)" instead of a path, or an error that names a file in your own project, usually means a local file or folder called
transformersshadows the library. - A name that does import but fails when used, with a message that asks you to install PyTorch, sentencepiece or another backend, is a different case: the name exists, its backend is missing.
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.
- 2.0.0 to 4.1.1:
__init__.pyimports everything eagerly, so the names are itsfrom .module import ...statements. - 4.2.0 and later: the top level is a lazy module that serves the names listed in
_import_structure. Those lists are read, without theutils.dummy_*placeholders. - 4.52.1 and later:
__init__.pybuilds the model part of the lists withdefine_import_structure, from the__all__of every file undermodels/. Those are read too. - 5.x: the three alias rules of
_LazyModule.__getattr__described above are applied; which rules a release has is read from that method's code, and the build stops if the method starts looking at name endings it did not look at before. transformers.utilsandtransformers.file_utils: every name the module binds at module level.- The six libraries in the table above: every
.pyfile of the package at the first release of each minor version, looking forfrom transformers import ...,from transformers.utils import ...andfrom transformers.file_utils import ...at module level. - Release dates and the list of yanked releases come from PyPI. Where the
.0release of a minor version was yanked (4.14, 4.25, 4.46, 4.52, 4.57, 5.10) the first release that pip installs is used.
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
- Nothing was installed. A name that the lists promise but whose module fails to import in some environment would still raise; a name added by a package's own patching is not seen.
- The ranges use the first release of each minor version. Every release was also read once (245 releases, from the wheels on PyPI, with the same rules): 103 names of
transformers,transformers.utilsandtransformers.file_utilsdiffer in some patch release from the first release of their minor. The lookup prints those patch releases under the range. The 5.x alias rules and the six libraries were not read patch by patch. - Submodule paths are not covered:
from transformers.models.bert import ...,transformers.generation,transformers.modeling_utilsand so on. A name that left the top level can still be importable from its submodule. - Releases before 2.0.0 (pytorch-transformers, pytorch-pretrained-bert) are not covered.
- "Instead" is given only where the library's own deprecation message names a replacement, or for the whole groups described above. For other names the release notes of the release that dropped it are the place to look.
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
- huggingface/transformers, release tags v2.0.0 to v5.26.0: src/transformers/__init__.py, utils/__init__.py, utils/import_utils.py (
_LazyModule,define_import_structure,fetch__all__), convert_slow_tokenizer.py (SLOW_TO_FAST_CONVERTERS), file_utils.py at 4.17.0 and at 4.18.0. - Deprecation messages quoted for replacements: optimization.py at 4.49.0 (AdamW), modeling_auto.py at 4.57.1 (AutoModelWithLMHead), generation/utils.py at 4.38.0 (top_k_top_p_filtering), pipelines/conversational.py at 4.41.0, agents/agents.py at 4.51.0, cache_utils.py at 4.57.1, data/processors/glue.py at 5.19.0.
- PyPI release history of transformers (dates, yanked releases).
- Release tags of huggingface/diffusers, UKPLab/sentence-transformers, huggingface/peft, huggingface/accelerate, huggingface/optimum and huggingface/trl.
- Threads with the question this page answers: Hugging Face forum, cannot import name 'is_tokenizers_available' from 'transformers.utils', cannot import name 'get_scheduler' from 'transformers', AdamW in the course notebooks.
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.