pypi / transformers
transformers
What changed in transformers 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-27.
34 breaking4 security16 deprecations47 new APIs and options4 performance12 behavior and defaults32 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli inittransformers 5111 changes
Breaking changes 16
ColwiseParallel and RowwiseParallel now apply only to linear layers; custom tensor-parallel plans must use the dedicated embedding style for embeddings.
Every MoE tensor- and expert-parallel plan now shards experts; custom or downstream plans must add expert sharding to avoid keeping all experts on every rank.
Vision image processors now composite PNG transparency onto white rather than exposing black pixels.
The minimum supported Python version is raised to 3.11.
Fixes from_pretrained on torch 2.7; distributed checkpointing requires torch>=2.8.
Removes deprecated cache checks and methods; code calling them must switch to the current cache API.
Limits the Hub rotary kernel to CUDA inference because its backward pass produced incorrect gradients.
Raises the minimum kernels version to 0.17.2, enabling failed kernel loads to fall back to the original implementation with use_fallback=KernelizeFallback.ALL.
Entity special tokens such as <ent> are now treated as special tokens during tokenization and decoding, which may change output involving these tokens.
Removes accidental cross-model imports; imports of those names through model modules must instead come from their original modules.
Selects the query box with the highest objectness score instead of the OWL-ViT heuristic, so image-guided query embeddings and detections may differ.
Deprecated pipelines now redirect, while removed pipelines raise an error.
Allows prefix_allowed_tokens_fn to override model -inf and raises an exception when generation constraints are unsatisfiable.
The distinction between Fast and Slow tokenizers is removed as Transformers focuses on the tokenizers backend.
Flax and TensorFlow support is sunset in favor of PyTorch as the sole backend.
Image processors exist only with their fast variant, which depends on the torchvision backend.
Security 4
Adds a linear-attention cache getter for recording-past state, avoiding direct exposure of cache internals.
Adds sanitization of chat input.
huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path
HuggingFace transformers vulnerable to remote code execution
Deprecations 6
Deprecates old input names.
Assignment to rope_scaling is deprecated; legacy RoPE keys are normalized.
Deprecates the unused get_uniform_frame_indices helper.
The prefix is deprecated for SDPA and flash attention; use the regular attention implementation for continuous batching. Eager still requires paged|eager.
Deprecates min-max pixels.
Deprecates the use_mamba_kernels config flag because it no longer has any effect.
New APIs and options 38
Adds access to convolution states in linear-attention caches.
Adds expert_dtype, defaulting to fp8, with fp4 available so DeepSeek-V4.1 experts are not allocated as FP8.
Adds support for Recursive's mixture-of-experts language model.
Adds a linear-attention cache getter for recurrent state.
Adds support for Gradium's on-device text-to-speech models.
Adds support for a document-understanding model specialized for reading text-dense images.
Adds a tensor-parallel plan for Nemotron.
Adds Kyutai's text-to-speech model, which can run faster than real time on CPU and supports voice prompts in several forms.
Adds the Pocket TTS audio tokenizer, whose encoder and decoder can also be loaded independently.
Adds an fp8 backend that stores KV states in torch.float8_e4m3fn with a single scale per tensor.
Adds support for visual document understanding and retrieval with UltraVBert.
Adds support for Beam, a token-efficient model focused on coding and agentic use cases that can run on a team's own hardware, infrastructure, or cloud.
Adds native Ling 3.0 Flash support through BailingHybridForCausalLM, so it loads without trust_remote_code=True.
Adds a unified quantization API for exporting with Dynamo, ONNX, OpenVINO, and ExecuTorch, including static and dynamic quantization and INT8/INT4 weight-only compression.
Adds support for Aleph Alpha's Kolibri 1 mixture-of-experts reasoning model.
Adds MiniCPM-V 4.7 support, including canvas M-RoPE, which assigns visual tokens temporal, height, and width positions.
Adds an audio model for long-form multi-speaker transcription, diarization, and timestamps, with chunking and hotword biasing support.
Adds native support for the multimodal Muse Spark Open model, which accepts text, images, audio, and video and generates text.
Centralizes sub-config initialization; custom or existing nested configs may need to declare sub-configs through this mechanism.
Adds bidirectional UltraBERT text encoders for classification and retrieval, including encoders supporting sequences up to 32,768 tokens.
Adds a 3B-parameter OCR model with gundam and base modes, long-form transcription, and optional region detections with bounding boxes.
Adds a multimodal embedding model that encodes text, images, audio, and video into a shared vector space, with configurable embedding dimensions and modality token budgets.
Adds a token-dispatch implementation selected through this plan rule; it is now the default for Qwen3 MoE and Mellum and removes the requirement that EP size equal TP size.
Adds support for registering new processing backends.
Adds a Trainer field declaring whether compute_loss already scales for gradient accumulation.
Adds support for loading GGUF models served with the Chat CLI.
Adds the GTE BERT-style bidirectional encoder architecture, supporting multiple GTE checkpoint families and Snowflake's snowflake-arctic-embed-m-v2.0.
Adds a vision-language model supporting text, image, and video inputs, with chain-of-thought reasoning via built-in thinking tokens.
Adds support for MoE in the GGUF integration.
Adds an open-weight streaming speaker diarization model supporting streaming and offline inference, up to eight speakers, configurable latency profiles, and configurable output frame resolution.
Adds a multimodal reasoning model that reasons jointly over text, images, video, and sound.
Adds the OpenVINO HF Exporter.
Passes sampling_rate to the apply_chat_template call.
Adds Trainer.end.
A centralized abstraction for attention methods is introduced; non-eager methods such as FA1/2/3, FlexAttention, and SDPA move to the interface.
Support for continuous batching and paged attention mechanisms is shipped for inference.
GGUF files can be loaded in Transformers for further fine-tuning, and Transformers models can be converted to GGUF for llama.cpp.
A Transformers-specific serving system is introduced that deploys an OpenAI API-compatible server.
Performance 4
Avoids a host-to-device copy in eager_mask.
Speeds up Whisper generation on TPU by reducing device synchronizations and recompilation.
Encodes multimodal data only once during generation.
Kernels are packaged so they are automatically used when the hardware and software permit it.
Behavior and default changes 12
Cache continuation is now supported for chunked prefill.
On ROCm, flash_attention_2 now falls back to the AITER kernel when flash-attn is not installed.
FSDP × TP model and optimizer checkpoints can now be saved and loaded across different parallel configurations.
Now accepts whole-number floats for integer tool arguments.
Image decoding now uses torchcodec.
Continuous batching fuses index-based and block-table cache updates into a single call, affecting custom code that calls the separate update paths.
Regular flash and SDPA attention functions now support continuous batching directly; paged implementations for these are redirected to them.
Initializes each layer from its own configuration, supporting heterogeneous sliding windows, attention chunks, convolution states, and attention head counts.
Initializes each layer from its own configuration, supporting heterogeneous sliding windows, attention chunks, convolution states, and attention head counts.
The Trainer now works with expert parallelism.
Weight loading changes to make quantization a first-class citizen, with the stated goal of compatibility with major features and reliable training and inference.
The tokenizers backend becomes the main tokenization backend; Sentencepiece and MistralCommon-backed tokenizers remain supported as non-default alternatives.
Fixes and other changes 31
Fixes preservation of background_color across the DeepSeek-VL and Janus image processors.
Fixes casting of dict-like inputs so generation no longer drops their type, including for ModelOutput.
Fixes image assignment during batched generation.
Fixes generation issues, including image placeholder handling in batched or beam-search generation.
Audio generation now respects generation_mode.
Fixes multi-zoom crops and related bugs in the mask-generation pipeline.
Prevents empty frame sampling for short videos.
Fixes Flash Attention compatibility with static caches and prevents BLOOM crashes with static cache or compiled generation.
Fixes a hardcoded torch.float64 use that caused crashes on MPS.
Fixes zero expert gradients in bfloat16 when expert parallelism is used with ep_size < fsdp_size.
Declares the input modalities of VLMs that report text only.
Preserves input types in generation preparation, preventing problems with multimodal models.
Fixes a small bug in auto mappings.
Fixes DeepGEMM Mega MoE under expert parallelism.
Works on torch 2.6 and 2.7.
Fixes image assignment during batched generation.
Fixes model loading on older torch versions.
Restores behavior where enable_expert_parallel applies the expert-parallel plan alone.
Molmo2 image and video keyword arguments now follow the library's standard conventions.
Fixes residual flushing for multi-token updates.
Fixes static-cache generation with host-side inputs, nested inputs, and tensor parallelism.
Fixes chunked prefill with multi-axis position ids for Qwen3-VL.
Adds video to the model's input modalities.
Fixes handling of seed=0.
Fixes the source rows used for encoder repetition penalties after batch expansion.
Preserves masked EOS scores when applying the penalty.
No longer mutates the user's cache_config when handling quantized caches.
Repairs cache reordering for quantized layers.
MoE models that compute router logits now return them when output_router_logits=True; read them from the new output classes.
Fixes repeated-ngram counting.
Fixes AutoImageProcessor requiring torchvision when only Pillow is installed.
transformers 438 changes
Breaking changes 18
Auto-tokenizers now return Rust tokenizers by default; set use_fast=False to obtain Python tokenizers.
Replaced by past_key_values in BART-like, FSMT, and T5 models.
Replaced by past_key_values in BART-like, FSMT, and T5 models.
The argument is replaced by top_k.
The tokenizer encoding argument is replaced by is_split_into_words.
Removed in several language-model classes in favor of labels.
Removed in several masked-language-model classes in favor of labels.
The tokenizer attribute is replaced by model_max_length.
Replaced by past_key_values in CTRL and GPT-2 models.
The Transfo-XL modeling method is replaced by reset_memory_length.
Model outputs are now named-tuples-like objects by default; set return_dict=False for tuple outputs, which can be unpacked.
The tokenizer attribute is replaced by return_length.
SentencePiece is no longer a required dependency, so tokenizers that depend on it are unavailable in a standard installation; install it separately or use transformers[sentencepiece].
The TFTrainer argument is removed in favor of args.prediction_loss_only.
The Transfo-XL configuration attribute is replaced by tie_words_embeddings.
The Trainer argument is removed in favor of args.prediction_loss_only.
The Trainer argument is removed; use TensorBoardCallback(tb_writer=...) instead.
Model files now reside in model-specific folders; import BertLayer from this path instead of transformers.modeling_bert.
Deprecations 10
Deprecated in favor of prediction_loop.
Deprecated in favor of run_model.
Deprecated in favor of setup_wandb.
Deprecated in favor of evaluation_strategy.
Deprecated in favor of log.
Deprecated in favor of prediction_loop.
Deprecated in favor of training_step.
Deprecated in favor of is_local_process_zero.
Deprecated in favor of is_world_process_zero.
Deprecated in favor of evaluation_strategy.
New APIs and options 9
Experimental encoder-model templates generate model, configuration, tokenization, and test files and place and reference them in the appropriate locations.
Multilingual T5 model support and pretrained checkpoints are added.
Pipelines now include additional features out of the box, including grouped entities in token classification.
A PrefixConstrainedLogitsProcessor is added.
ProphetNet adds the prepare_seq2seq_batch function.
T5 version 1.1 model support and pretrained checkpoints are added.
TensorFlow Longformer adds SequenceClassification, MultipleChoice, and TokenClassification heads.
DPR is now available in TensorFlow to match its PyTorch counterpart.
Install this extra to obtain the SentencePiece-dependent tokenizers alongside Transformers.
Fixes and other changes 1
The data_collator attribute should be a callable.