You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw some code snippets which are explicitly verifying compliance with a <5 version of transformers i.e. around phi-4.
I think it would be neat if docling itself would be less coupled to a specific version and the user could more flexibly choose based on what models they use to find a compatible setup.
If someone wants to create a checklist of sorts of the various parts of docling that need to be updated and assign tasks I'd be willing to help, just FYI. I'm familiar with the API changes if an outline would help as well?
# Transformers v5: Unified Migration Guide
Hugging Face Transformers v5.0.0, released January 26, 2026, is the library's first major version bump in five years. It touches nearly every public API surface: TensorFlow and JAX are gone, tokenization is rebuilt from the ground up, weight loading is rearchitected, Trainer sheds dozens of parameters, generation is consolidated, and pipelines are pruned. Weekly releases (v5.1–v5.3 already shipped) continue landing breaking changes, so pinning to an exact minor version is advisable during migration.
This guide catalogs every significant change, organized by subsystem.
---## 1. TensorFlow and JAX Removal — PyTorch Is the Sole Backend
The single largest breaking change is the **complete removal of all TensorFlow and Flax/JAX model code**. Every `TF*` and `Flax*` class — `TFAutoModel`, `TFBertModel`, `FlaxAutoModel`, `FlaxBertModel`, and hundreds of others — no longer exists. Any import of these classes raises `ImportError`. If your codebase touches TensorFlow or JAX through Transformers, you must rewrite it in PyTorch.
This decision allows the team to focus fully on `torch` and greatly reduces maintenance cost. Work with Jax ecosystem tools (such as MaxText) continues to explore compatibility while keeping `torch` as the only backend.
Linked PR: https://github.com/huggingface/transformers/pull/40760### Minimum Requirements-**Python ≥ 3.10** is required from v5.0.0 onward (`setup.py` specifies `python_requires=">=3.10.0"`)
-**PyTorch ≥ 2.4** is the minimum required version
-**`huggingface_hub` ≥ 1.3.0, < 2.0** — see [Requirements Update](#17-requirements-update) below
-**`typer-slim`** added as a required dependency (powers the redesigned CLI)
---## 2. Dynamic Weight Loading (WeightConverter API)
A new weight loading API significantly improves on the previous one. Instead of loading a checkpoint exactly as serialized, operations can reshape, merge, and split layers — a necessity for quantization and parallelism algorithms.
The API centers on the `WeightConverter` class:
```pythonclassWeightConverter(WeightTransform):
operations: list[ConversionOps]
source_keys: Union[str, list[str]]
target_keys: Union[str, list[str]]
For example, fusing query/key/value attention layers:
The from_pretrained() method looks the same but behaves differently in three critical ways:
3a. Default dtype is now auto instead of float32
Models load in whatever dtype they were saved in. Code that assumed float32 and never specified torch_dtype may now get float16 or bfloat16 weights, silently changing numerical behavior. Specify torch_dtype=torch.float32 explicitly if you need the old behavior.
3b. Only safetensors serialization is supported
The safe_serialization parameter has been removed from all save_pretrained and push_to_hub methods. Passing safe_serialization=False raises an error. You cannot save pickle-based .bin files through the API — use torch.save(model.state_dict(), ...) manually if needed.
The default shard size went from 5 GB to 50 GB, avoiding tens or hundreds of weight files for large models. This was made possible by the Xet backend allowing efficient serving of very large files. The decision was taken after careful benchmarking of load speed and optimization.
Just as models moved to a single backend, tokenizers are being made much more intuitive. With v5, tokenizer definition is simpler: you can initialize an empty tokenizer and train it directly on your corpus, making tokenizers behave like models — trained or empty, defined entirely by their class.
Backend Architecture: Ending the Slow/Fast Split
Up to now, transformers maintained two parallel implementations:
"Slow" tokenizers (tokenization_<model>.py) — Python-based, often using SentencePiece
"Fast" tokenizers (tokenization_<model>_fast.py) — Rust-based, using 🤗 tokenizers
In v5, these consolidate to a single file per model: tokenization_<model>.py, using the most appropriate backend:
TokenizersBackend (preferred): Rust-based from 🤗 tokenizers. Provides optimal performance plus features like added token handling, full Python API, automatic parallelization, offsets, customization, and training.
SentencePieceBackend: For tokenizers requiring sentencepiece. Inherits from PythonBackend.
PythonBackend (formerly PreTrainedTokenizer): Python implementation of tokenizer features. Allows adding tokens and custom implementations without relying on external backends.
MistralCommonBackend (formerly MistralCommonTokenizer): Relies on MistralCommon's tokenization library.
AutoTokenizer automatically selects the appropriate backend based on available files and dependencies — transparent to the user.
Defining Custom Tokenizers
For the highest-level custom implementation, PreTrainedTokenizerBase (what PythonBackend inherits from) provides the core API: encode, decode, vocab_size, get_vocab, convert_tokens_to_ids, convert_ids_to_tokens, from_pretrained, save_pretrained, and others.
Note for SentencePiece-based tokenizers: Override the convert_from_spm class method in your converter to customize vocabulary structure, normalizers, regexes, and anything passed to the tokenizers you are converting.
Tokenizer API Changes
Direct initialization with vocab and merges
You can now initialize blank, untrained tokenizers:
Simplified file loading:vocab and merges accept file paths directly. The tokenizer auto-detects format (SentencePiece .model, Tekken tekken.json, or plain files). For BPE tokenizers, if vocab is provided without merges, merges are auto-generated (excluding special tokens). Note: File-path loading is primarily for quick testing.
Unified decode method
batch_decode and decode are unified. Both single and batch decoding now use decode:
tokenizer=AutoTokenizer.from_pretrained("t5-small")
inputs= ["hey how are you?", "fine"]
tokenizer.decode(tokenizer.encode(inputs))
# v4: 'hey how are you?</s> fine</s>'# v5: ['hey how are you?</s>', 'fine</s>']
encode_plus → __call__
The encode_plus method is deprecated in favor of the single __call__ method.
apply_chat_template returns BatchEncoding
Previously returned raw input_ids; now consistently returns a BatchEncoding dict:
special_tokens_map.json — special tokens now stored in tokenizer_config.json
added_tokens.json — added tokens now stored in tokenizer.json
added_tokens_decoder — only stored when there is no tokenizer.json
add_bos_token / add_eos_token — no longer saved in tokenizer_config.json when tokenizer.json exists
Backend synchronization removed: Automatic post-initialization synchronization of backend settings (add_prefix_space, do_lower_case, strip_accents, tokenize_chinese_chars) is gone. Behavior is now fully determined by tokenizer.json or the class definition at initialization time.
Model-specific consolidations
Models with identical tokenizers now import from their base:
LayoutLM → BertTokenizer
LED → BartTokenizer
Longformer → RobertaTokenizer
LXMert → BertTokenizer
MT5 → T5Tokenizer
MVP → BartTokenizer
These wrapper modules will eventually be removed.
Removed: The internal _eventually_correct_t5_max_length method. T5 tokenizers now handle max length consistently with other models.
Special tokens restructured
SpecialTokensMixin merged into PreTrainedTokenizerBase
special_tokens_map now only stores named special tokens (bos_token, eos_token, etc.)
additional_special_tokens → extra_special_tokens (auto-converted during init)
special_tokens_map_extended and all_special_tokens_extended → removed
extra_special_tokens only accepts list/tuple and is for initialization; for model-specific named tokens (e.g., image_token), pass directly as keyword arguments
# v4tokenizer.special_tokens_map# Included 'additional_special_tokens'# v5tokenizer.special_tokens_map# Only named tokenstokenizer.extra_special_tokens# Additional tokens
Deprecated and removed methods
Deprecated:
sanitize_special_tokens() — removed in v5 (was already deprecated in v4)
prepare_seq2seq_batch() — use __call__() with text_target:
Quantization is now integrated at the core weight-loading level through the WeightConverter system, enabling combinations like quantization + MoE or tensor parallelism + quantization that weren't previously possible.
New quantization backends added in v5.3: MLX for Apple MPS, NVFP4 (Four Over Six), and CPU MXFP4. Minimum bitsandbytes version is 0.46.1.
6. Configuration Changes
from_xxx_config() factory methods deleted. Use the __init__ method directly. See #41314.
Config loading from URLs removed. Configs must be loaded from a local path or a Hub repo. See #42383.
RoPE parameters unified. All rotary embedding parameters are now under config.rope_parameters (a dict), including rope_theta and rope_type. Accessing config.rope_theta directly throws AttributeError. For models like Gemma3 and ModernBert, rope_parameters is a nested dict with per-layer-type parameterizations. See #39847 and #42255.
Qwen-VL family uses nested configuration. config.vocab_size throws an error — use config.text_config.vocab_size.
Non-generative models no longer carry a generation_config. Accessing model.config.generation_config on encoder-only models throws AttributeError.
7. Attention and Model Architecture Changes
Removed attention features
Several features are removed because they were only supported in a few old models and never integrated into current model additions:
Head masking — allowed turning off certain heads during attention (eager only). #41076
Relative positional biases in BERT-like models — introduced for relative position scores within attention (similar to T5); barely used in official models, eager-only. #41170
Head pruning — allowed pruning heads within attention layers. #41417
If you need output_attentions=True, you must now explicitly set attn_implementation="eager".
BetterTransformer — use torch.compile or native SDPA instead
These were deprecated by the PyTorch team; the focus is now on torch.dynamo and torch.export.
New abstractions
A new AttentionInterface provides centralized abstraction across eager, Flash Attention 1/2/3, FlexAttention, and SDPA.
All model forward() methods now accept **kwargs for vLLM integration compatibility (PR #42603, introduced in RC1). Code that introspects forward() signatures or subclasses with strict forward() overrides may break.
RotaryEmbeddings changes
Some RotaryEmbeddings layers now return a dict of tuples when the model uses several RoPE configurations (Gemma2, ModernBert). Each value is a (cos, sin) tuple per RoPE type. Backward compatibility will be maintained as much as possible during the transition.
Vision-Language model access
The shortcut model.language_model no longer works for VLMs. Use model.model.language_model or model.get_decoder(). See #42156.
Feature extraction helpers: get_*_features
Multi-modal model methods (get_text_features, get_image_features, get_audio_features, get_video_features) now return a BaseModelOutputWithPooling (or subclass) instead of only a pooled embedding tensor. (This change is tracked in issue #42401 and PR #42564; verify merge status for your version.)
last_hidden_state: unpooled embeddings
pooler_output: pooled representation (what was previously returned)
hidden_states: all layer hidden states (when output_hidden_states=True)
Old deprecated aliases like GreedySearchEncoderDecoderOutput and BeamSearchDecoderOnlyOutput are removed. Only four output classes remain, defined by two axes: decoder-only vs. encoder-decoder, and beam vs. no-beam. See #40998.
Beam scoring and constraints moved to the Hub
Deprecated beam scoring and constraint classes were moved to transformers-community/group-beam-search, requiring trust_remote_code=True for features like Diverse Beam Search with num_beam_groups. See #41223.
Default KV cache is model-defined
If generate receives no KV Cache argument, the default cache class is now defined by the model rather than always being DynamicCache. The legacy cache format is removed entirely. See #41505.
Generation parameters moved off model config
Generation parameters are no longer accessible via model.config. If serialized in config.json for an old model, they are loaded into model.generation_config. Use model.generation_config exclusively (e.g., model.generation_config.do_sample = True).
v5.1 generation changes
Generation input preparation was refactored to pass pre-sliced input_ids/inputs_embeds directly to prepare_inputs_for_generation instead of relying on cache_position.
Models with sliding window attention now enforce window size limits during generation (PR #43679), potentially changing output behavior.
9. Processing Classes
Processor attributes are now serialized as nested dicts in processor_config.json instead of separate config files. Loading supports all old formats. See #41474.
All vision XXXFeatureExtractor classes are completely removed in favor of XXXImageProcessor. For vision models, use AutoImageProcessor instead of AutoFeatureExtractor. Audio feature extractors (e.g., Wav2Vec2FeatureExtractor) are retained. See #41174.
Fast image processors now require torchvision as a dependency.
XXXFastImageProcessorKwargs → unified XXXImageProcessorKwargs (shared between fast and slow). See #40931.
10. Auto-Classes
AutoModelWithLMHead → removed. Use AutoModelForCausalLM, AutoModelForMaskedLM, or AutoModelForSeq2SeqLM.
AutoModelForVision2Seq → removed. Use AutoModelForImageTextToText.
11. Trainer Changes
Constructor and method renames
tokenizer parameter → processing_class
model_path in train() → resume_from_checkpoint
report_to default changed
The default changed from auto-detection to "none". Logging integrations (WandB, TensorBoard, etc.) must now be explicitly specified.
use_cache default
use_cache in the model config is now set to False by default during training. You can override it via TrainingArguments's use_cache argument.
Parameters removed without deprecation cycle (low usage)
mp_parameters — legacy SageMaker param
_n_gpu — not intended for users; auto-initialized
overwrite_output_dir — replaced by resume_from_checkpoint; was only used in example scripts
logging_dir — set TENSORBOARD_LOGGING_DIR env var instead
jit_mode_eval — use use_torch_compile instead
tpu_num_cores — set TPU_NUM_CORES env var instead
past_index — only used for a handful of models with special architectures
ray_scope — set RAY_SCOPE env var instead
warmup_ratio — merged into warmup_step, which now accepts float values
SigOpt hyperparameter search — library archived, API stopped working
SageMaker support requires API ≥ 1.10
Minimum Accelerate version bumped to 1.1.0
12. Pipelines
Text pipelines removed
question-answering, Text2TextGenerationPipeline, SummarizationPipeline, and TranslationPipeline are removed. For nearly all text-to-text or Q&A tasks, a modern chat model via TextGenerationPipeline provides much higher quality output:
importtorchfromtransformersimportpipelinesummarizer=pipeline("text-generation", model="Qwen/Qwen3-4B-Instruct-2507")
message_history= [
{"role": "user", "content": "Summarize the following text:\n\n[TEXT_TO_SUMMARIZE]"}
]
print(summarizer(message_history)[0]["generated_text"][-1]["content"])
Vision pipelines removed
image-to-text and visual-question-answering pipelines are removed. Use a VLM via the image-text-to-text pipeline:
image-to-image pipeline removed — use 🤗 Diffusers instead.
Image-text-to-text pipelines no longer accept images as a separate argument — image data must be embedded in the chat message's "content" field. See #42359.
The grouped_entities parameter was removed.
The transformers.onnx module was removed entirely.
16. Hidden Breakage: trust_remote_code Models and Internal API Removal
A particularly insidious class of breaks affects models loaded with trust_remote_code=True:
is_torch_fx_available was removed from transformers.utils.import_utils, causing ImportError on Hub models like deepseek-ai/deepseek-moe-16b-base that copied this utility in their v4-era code (GitHub issue #44561, filed March 10, 2026).
Removed tokenization_*_fast.py file paths break projects (e.g., Microsoft's VibeVoice) that hardcoded fast tokenizer imports.
The HybridCache import path in cache_utils changed.
When both embed_tokens.weight and lm_head.weight exist in a checkpoint, they are no longer automatically tied — potentially changing model behavior silently.
Import path changes
Paths like transformers.tokenization_utils and transformers.tokenization_utils_fast no longer exist. They redirect to transformers.tokenization_utils_sentencepiece and transformers.tokenization_utils_tokenizers respectively.
17. Requirements Update
transformers v5 pins huggingface_hub to ≥ 1.3.0, < 2.0. Key changes from that major release:
HTTP backend switched from requests to httpx. Catch httpx.HTTPError instead of requests.HTTPError.
Proxy configuration moved exclusively to environment variables (HTTP_PROXY / HTTPS_PROXY). Setting proxies from scripts is no longer possible.
hf_transfer replaced by hf_xet — HF_HUB_ENABLE_HF_TRANSFER is dropped. Should be transparent for most users.
typer-slim added as a required dependency for the hf and transformers CLIs.
Tensor parallelism and expert parallelism aren't working as expected during the vLLM MoE support streamlining. Known and actively worked on.
Custom pretrained models
For anyone inheriting from a PreTrainedModel, weights are automatically initialized with a general scheme (normal distribution for Linear, Conv, Embedding; ones/zeros for norms). To avoid this, override _init_weights:
The MoE refactoring in v5 — fusing experts into single modules with stacked nn.Parameter tensors — can cause quantization to not apply correctly in some configurations, leading to OOM errors on setups that previously worked under v4.x. See axolotl #3374 and trl #5222 for community reports.
19. Additional v5.1–v5.3 Breaking Changes
Several additional breaking changes landed in post-v5.0 weekly releases:
is_torch_sdpa_available removed/relocated from transformers.utils.import_utils, causing breakage in downstream projects like LLaMA-Factory that imported it directly.
Unified 3D position IDs for VLMs (#43972, v5.3) — changes how position information is passed to vision-language models.
New model architectures continue to ship exclusively targeting v5 (EuroBERT, VibeVoice ASR, TimesFM2.5, OlmoHybrid, ModernVBert, and others in v5.3).
Quick Reference: Most Likely Breakage Points
The three changes most likely to break existing code immediately:
TF/Flax import removal — instant ImportError
Default dtype change to auto — silent numerical behavior shift
Removal of load_in_4bit/load_in_8bit shortcuts — runtime error on quantized model loading
The next wave will catch: Trainer parameter purge, generation output type consolidation, feature extractor removal, and use_auth_token removal.
Many downstream libraries have responded by pinning transformers<5.0 — pragmatic short-term, but with a ticking clock as all new model architectures target v5 exclusively.
Activity
geoHeil commentedon Mar 9, 2026
main problem seems to be that we currently still have
huggingface-hub>=1.3.0,<2.0somehow if I understand the problem correctly.dolfim-ibm commentedon Mar 10, 2026
The current blocker is that some Docling models fail running with the new transformers. We are trying to address this.
geoHeil commentedon Mar 10, 2026
would it make sense to stage this into 2 steps
I saw some code snippets which are explicitly verifying compliance with a <5 version of transformers i.e. around phi-4.
I think it would be neat if docling itself would be less coupled to a specific version and the user could more flexibly choose based on what models they use to find a compatible setup.
dolfim-ibm commentedon Mar 10, 2026
We might have to make some workaround, yes. But first let's assess the situation in a few days, it might just all align properly.
BBC-Esq commentedon Mar 12, 2026
If someone wants to create a checklist of sorts of the various parts of docling that need to be updated and assign tasks I'd be willing to help, just FYI. I'm familiar with the API changes if an outline would help as well?
geoHeil commentedon Mar 29, 2026
any update here?
geoHeil commentedon Mar 29, 2026
new models like glm-ocr or lightonocr-2 are blocked by this transformers-v4 limitation
PeterStaar-IBM commentedon Mar 30, 2026
@geoHeil we are actively working on it, hopefully today should be resolved (#3200). We needed to wait for a fix in transformers v5.
BBC-Esq commentedon Mar 30, 2026
Here's a guide that I've found somewhat useful:
GUIDE HERE
For example, fusing query/key/value attention layers:
Key improvements:
Expect varying levels of support across release candidates while implementation continues.
Linked PR: huggingface/transformers#41580
3. Model Loading Default Changes
The
from_pretrained()method looks the same but behaves differently in three critical ways:3a. Default dtype is now
autoinstead offloat32Models load in whatever dtype they were saved in. Code that assumed
float32and never specifiedtorch_dtypemay now getfloat16orbfloat16weights, silently changing numerical behavior. Specifytorch_dtype=torch.float32explicitly if you need the old behavior.3b. Only safetensors serialization is supported
The
safe_serializationparameter has been removed from allsave_pretrainedandpush_to_hubmethods. Passingsafe_serialization=Falseraises an error. You cannot save pickle-based.binfiles through the API — usetorch.save(model.state_dict(), ...)manually if needed.Linked PR: huggingface/transformers#42556
3c. Default shard size increased to 50 GB
The default shard size went from 5 GB to 50 GB, avoiding tens or hundreds of weight files for large models. This was made possible by the Xet backend allowing efficient serving of very large files. The decision was taken after careful benchmarking of load speed and optimization.
Linked PR: huggingface/transformers#42556
3d.
use_auth_tokenremoved everywhereThe
use_auth_tokenparameter is replaced bytokenin all methods (from_pretrained(),push_to_hub(), etc.). A global search-and-replace handles it.Linked PR: huggingface/transformers#41666
4. Tokenization Overhaul
Design Philosophy
Just as models moved to a single backend, tokenizers are being made much more intuitive. With v5, tokenizer definition is simpler: you can initialize an empty tokenizer and train it directly on your corpus, making tokenizers behave like models — trained or empty, defined entirely by their class.
Backend Architecture: Ending the Slow/Fast Split
Up to now, transformers maintained two parallel implementations:
tokenization_<model>.py) — Python-based, often using SentencePiecetokenization_<model>_fast.py) — Rust-based, using 🤗 tokenizersIn v5, these consolidate to a single file per model:
tokenization_<model>.py, using the most appropriate backend:sentencepiece. Inherits fromPythonBackend.PreTrainedTokenizer): Python implementation of tokenizer features. Allows adding tokens and custom implementations without relying on external backends.MistralCommonTokenizer): Relies on MistralCommon's tokenization library.AutoTokenizerautomatically selects the appropriate backend based on available files and dependencies — transparent to the user.Defining Custom Tokenizers
For the highest-level custom implementation,
PreTrainedTokenizerBase(whatPythonBackendinherits from) provides the core API:encode,decode,vocab_size,get_vocab,convert_tokens_to_ids,convert_ids_to_tokens,from_pretrained,save_pretrained, and others.Example of defining a new tokenizer:
Note for SentencePiece-based tokenizers: Override the
convert_from_spmclass method in your converter to customize vocabulary structure, normalizers, regexes, and anything passed to the tokenizers you are converting.Tokenizer API Changes
Direct initialization with vocab and merges
You can now initialize blank, untrained tokenizers:
Or initialize from vocab and merges:
Simplified file loading:
vocabandmergesaccept file paths directly. The tokenizer auto-detects format (SentencePiece.model, Tekkentekken.json, or plain files). For BPE tokenizers, if vocab is provided without merges, merges are auto-generated (excluding special tokens). Note: File-path loading is primarily for quick testing.Unified
decodemethodbatch_decodeanddecodeare unified. Both single and batch decoding now usedecode:encode_plus→__call__The
encode_plusmethod is deprecated in favor of the single__call__method.apply_chat_templatereturnsBatchEncodingPreviously returned raw
input_ids; now consistently returns aBatchEncodingdict:Legacy file saving removed
special_tokens_map.json— special tokens now stored intokenizer_config.jsonadded_tokens.json— added tokens now stored intokenizer.jsonadded_tokens_decoder— only stored when there is notokenizer.jsonadd_bos_token/add_eos_token— no longer saved intokenizer_config.jsonwhentokenizer.jsonexistsBackend synchronization removed: Automatic post-initialization synchronization of backend settings (
add_prefix_space,do_lower_case,strip_accents,tokenize_chinese_chars) is gone. Behavior is now fully determined bytokenizer.jsonor the class definition at initialization time.Model-specific consolidations
Models with identical tokenizers now import from their base:
These wrapper modules will eventually be removed.
Removed: The internal
_eventually_correct_t5_max_lengthmethod. T5 tokenizers now handle max length consistently with other models.Special tokens restructured
SpecialTokensMixinmerged intoPreTrainedTokenizerBasespecial_tokens_mapnow only stores named special tokens (bos_token,eos_token, etc.)additional_special_tokens→extra_special_tokens(auto-converted during init)additional_special_tokens_ids→extra_special_tokens_idsspecial_tokens_map_extendedandall_special_tokens_extended→ removedextra_special_tokensonly accepts list/tuple and is for initialization; for model-specific named tokens (e.g.,image_token), pass directly as keyword argumentsDeprecated and removed methods
Deprecated:
sanitize_special_tokens()— removed in v5 (was already deprecated in v4)prepare_seq2seq_batch()— use__call__()withtext_target:BatchEncoding.words()→ useword_ids()insteadRemoved from base class:
create_token_type_ids_from_sequences()— subclasses needing it must implement directlyprepare_for_model(),build_inputs_with_special_tokens(),truncate_sequences()— moved totokenization_python.pyforPythonBackendonly_switch_to_input_mode(),_switch_to_target_mode(),as_target_tokenizer()— use__call__()withtext_target:parse_response()— removed from base classTesting changes
add_tokens,encode,decode) are centralized and auto-applied across all tokenizersWhitespaceTokenizer,BasicTokenizer, etc.) is preserved inbert_legacy.pyfor referenceLinked PRs
tokenizationin v5 huggingface/transformers#409385. Quantization Changes
The
load_in_4bitandload_in_8bitshortcut arguments tofrom_pretrained()are gone. You must construct aBitsAndBytesConfigexplicitly:Quantization is now integrated at the core weight-loading level through the WeightConverter system, enabling combinations like quantization + MoE or tensor parallelism + quantization that weren't previously possible.
New quantization backends added in v5.3: MLX for Apple MPS, NVFP4 (Four Over Six), and CPU MXFP4. Minimum
bitsandbytesversion is 0.46.1.6. Configuration Changes
from_xxx_config()factory methods deleted. Use the__init__method directly. See #41314.config.rope_parameters(a dict), includingrope_thetaandrope_type. Accessingconfig.rope_thetadirectly throwsAttributeError. For models like Gemma3 and ModernBert,rope_parametersis a nested dict with per-layer-type parameterizations. See #39847 and #42255.config.vocab_sizethrows an error — useconfig.text_config.vocab_size.generation_config. Accessingmodel.config.generation_configon encoder-only models throwsAttributeError.7. Attention and Model Architecture Changes
Removed attention features
Several features are removed because they were only supported in a few old models and never integrated into current model additions:
If you need
output_attentions=True, you must now explicitly setattn_implementation="eager".Removed torch APIs
torch.fx— #41683torch.compileor native SDPA insteadThese were deprecated by the PyTorch team; the focus is now on
torch.dynamoandtorch.export.New abstractions
AttentionInterfaceprovides centralized abstraction across eager, Flash Attention 1/2/3, FlexAttention, and SDPA.forward()methods now accept**kwargsfor vLLM integration compatibility (PR #42603, introduced in RC1). Code that introspectsforward()signatures or subclasses with strictforward()overrides may break.RotaryEmbeddings changes
Some
RotaryEmbeddingslayers now return a dict of tuples when the model uses several RoPE configurations (Gemma2, ModernBert). Each value is a(cos, sin)tuple per RoPE type. Backward compatibility will be maintained as much as possible during the transition.Vision-Language model access
The shortcut
model.language_modelno longer works for VLMs. Usemodel.model.language_modelormodel.get_decoder(). See #42156.Feature extraction helpers:
get_*_featuresMulti-modal model methods (
get_text_features,get_image_features,get_audio_features,get_video_features) now return aBaseModelOutputWithPooling(or subclass) instead of only a pooled embedding tensor. (This change is tracked in issue #42401 and PR #42564; verify merge status for your version.)last_hidden_state: unpooled embeddingspooler_output: pooled representation (what was previously returned)hidden_states: all layer hidden states (whenoutput_hidden_states=True)attentions: attention maps (whenoutput_attentions=True)Migration:
Linked PR: huggingface/transformers#42564
8. Generation API Changes
Output types consolidated
Old deprecated aliases like
GreedySearchEncoderDecoderOutputandBeamSearchDecoderOnlyOutputare removed. Only four output classes remain, defined by two axes: decoder-only vs. encoder-decoder, and beam vs. no-beam. See #40998.Beam scoring and constraints moved to the Hub
Deprecated beam scoring and constraint classes were moved to
transformers-community/group-beam-search, requiringtrust_remote_code=Truefor features like Diverse Beam Search withnum_beam_groups. See #41223.Default KV cache is model-defined
If
generatereceives no KV Cache argument, the default cache class is now defined by the model rather than always beingDynamicCache. The legacy cache format is removed entirely. See #41505.Generation parameters moved off model config
Generation parameters are no longer accessible via
model.config. If serialized inconfig.jsonfor an old model, they are loaded intomodel.generation_config. Usemodel.generation_configexclusively (e.g.,model.generation_config.do_sample = True).v5.1 generation changes
input_ids/inputs_embedsdirectly toprepare_inputs_for_generationinstead of relying oncache_position.9. Processing Classes
processor_config.jsoninstead of separate config files. Loading supports all old formats. See #41474.XXXFeatureExtractorclasses are completely removed in favor ofXXXImageProcessor. For vision models, useAutoImageProcessorinstead ofAutoFeatureExtractor. Audio feature extractors (e.g.,Wav2Vec2FeatureExtractor) are retained. See #41174.torchvisionas a dependency.XXXFastImageProcessorKwargs→ unifiedXXXImageProcessorKwargs(shared between fast and slow). See #40931.10. Auto-Classes
AutoModelWithLMHead→ removed. UseAutoModelForCausalLM,AutoModelForMaskedLM, orAutoModelForSeq2SeqLM.AutoModelForVision2Seq→ removed. UseAutoModelForImageTextToText.11. Trainer Changes
Constructor and method renames
tokenizerparameter →processing_classmodel_pathintrain()→resume_from_checkpointreport_todefault changedThe default changed from auto-detection to
"none". Logging integrations (WandB, TensorBoard, etc.) must now be explicitly specified.use_cachedefaultuse_cachein the model config is now set toFalseby default during training. You can override it viaTrainingArguments'suse_cacheargument.Parameters removed without deprecation cycle (low usage)
mp_parameters— legacy SageMaker param_n_gpu— not intended for users; auto-initializedoverwrite_output_dir— replaced byresume_from_checkpoint; was only used in example scriptslogging_dir— setTENSORBOARD_LOGGING_DIRenv var insteadjit_mode_eval— useuse_torch_compileinsteadtpu_num_cores— setTPU_NUM_CORESenv var insteadpast_index— only used for a handful of models with special architecturesray_scope— setRAY_SCOPEenv var insteadwarmup_ratio— merged intowarmup_step, which now accepts float valuesPreviously deprecated parameters removed
fsdp_min_num_params,fsdp_transformer_layer_cls_to_wrapfsdp_configtpu_metrics_debugdebugpush_to_hub_tokenhub_tokenpush_to_hub_model_id,push_to_hub_organizationhub_model_idinclude_inputs_for_metricsinclude_for_metricsper_gpu_train_batch_sizeper_device_train_batch_sizeper_gpu_eval_batch_sizeper_device_eval_batch_sizeuse_mps_deviceno_cudause_cpufp16_backend,half_precision_backendtorch.amp)include_tokens_per_secondinclude_num_input_tokens_seenuse_legacy_prediction_loopevaluation_loop)Removed integrations
12. Pipelines
Text pipelines removed
question-answering,Text2TextGenerationPipeline,SummarizationPipeline, andTranslationPipelineare removed. For nearly all text-to-text or Q&A tasks, a modern chat model viaTextGenerationPipelineprovides much higher quality output:Vision pipelines removed
image-to-textandvisual-question-answeringpipelines are removed. Use a VLM via theimage-text-to-textpipeline:Other pipeline changes
image-to-imagepipeline removed — use 🤗 Diffusers instead."content"field. See #42359.grouped_entitiesparameter was removed.transformers.onnxmodule was removed entirely.13. PushToHubMixin
organization,repo_url,ignore_metadata_errors,use_temp_dir,safe_serializationpush_to_hubno longer accepts**kwargs— all accepted parameters are explicitly documentedrepo_idare now keyword-onlyrepo_idinstead oforganization+repo_urlLinked PR: huggingface/transformers#42391
14. CLI Changes
The deprecated
transformers-clicommand is gone.transformersis the only CLI entry point.The CLI was rebuilt on Typer with improved help and autocompletion.
transformers chatredesignedNo longer starts a server (that moved to
transformers serve). New signature:Works hand in hand with
transformers serve:transformers runremovedWas undocumented, untested, and not part of public documentation. See #42447.
Linked PRs:
15. Environment Variables
Legacy cache variables removed:
TRANSFORMERS_CACHEHF_HOMEPYTORCH_TRANSFORMERS_CACHEHF_HOMEPYTORCH_PRETRAINED_BERT_CACHEHF_HOMERemoved constants:
HUGGINGFACE_CO_EXAMPLES_TELEMETRYHUGGINGFACE_CO_PREFIXHUGGINGFACE_CO_RESOLVE_ENDPOINTUse
huggingface_hub.constants.ENDPOINTinstead.Linked PR: huggingface/transformers#42391
16. Hidden Breakage:
trust_remote_codeModels and Internal API RemovalA particularly insidious class of breaks affects models loaded with
trust_remote_code=True:is_torch_fx_availablewas removed fromtransformers.utils.import_utils, causingImportErroron Hub models likedeepseek-ai/deepseek-moe-16b-basethat copied this utility in their v4-era code (GitHub issue #44561, filed March 10, 2026).tokenization_*_fast.pyfile paths break projects (e.g., Microsoft's VibeVoice) that hardcoded fast tokenizer imports.HybridCacheimport path incache_utilschanged.embed_tokens.weightandlm_head.weightexist in a checkpoint, they are no longer automatically tied — potentially changing model behavior silently.Import path changes
Paths like
transformers.tokenization_utilsandtransformers.tokenization_utils_fastno longer exist. They redirect totransformers.tokenization_utils_sentencepieceandtransformers.tokenization_utils_tokenizersrespectively.17. Requirements Update
transformersv5 pinshuggingface_hubto ≥ 1.3.0, < 2.0. Key changes from that major release:requeststohttpx. Catchhttpx.HTTPErrorinstead ofrequests.HTTPError.HTTP_PROXY/HTTPS_PROXY). Setting proxies from scripts is no longer possible.hf_transferreplaced byhf_xet—HF_HUB_ENABLE_HF_TRANSFERis dropped. Should be transparent for most users.typer-slimadded as a required dependency for thehfandtransformersCLIs.See the huggingface_hub migration guide for full details.
18. RC0 Disclaimers and Known Issues
PEFT + MoE
The switch from naive MoE (
nn.ModuleListfor experts) creates issues with MoEs that have adapters. See huggingface/transformers#42491 (comment).Tensor Parallel and Expert Parallel + MoE
Tensor parallelism and expert parallelism aren't working as expected during the vLLM MoE support streamlining. Known and actively worked on.
Custom pretrained models
For anyone inheriting from a
PreTrainedModel, weights are automatically initialized with a general scheme (normal distribution for Linear, Conv, Embedding; ones/zeros for norms). To avoid this, override_init_weights:Tracker: huggingface/transformers#42418
QLoRA + MoE regression
The MoE refactoring in v5 — fusing experts into single modules with stacked
nn.Parametertensors — can cause quantization to not apply correctly in some configurations, leading to OOM errors on setups that previously worked under v4.x. See axolotl #3374 and trl #5222 for community reports.19. Additional v5.1–v5.3 Breaking Changes
Several additional breaking changes landed in post-v5.0 weekly releases:
is_torch_sdpa_availableremoved/relocated fromtransformers.utils.import_utils, causing breakage in downstream projects like LLaMA-Factory that imported it directly.Quick Reference: Most Likely Breakage Points
The three changes most likely to break existing code immediately:
ImportErrorauto— silent numerical behavior shiftload_in_4bit/load_in_8bitshortcuts — runtime error on quantized model loadingThe next wave will catch: Trainer parameter purge, generation output type consolidation, feature extractor removal, and
use_auth_tokenremoval.Many downstream libraries have responded by pinning
transformers<5.0— pragmatic short-term, but with a ticking clock as all new model architectures target v5 exclusively.