# Migration Context: Hugging Face Transformers v3 -> v4 # Generated by Changelogs.us: 2026-11-30T03:04:30.603294+00:00 # Target Version: v4.57.6 # Upgrade Command: N/A # Breaking Changes: 68 # Security Fixes: 0 ## Executive Summary Upgrading Hugging Face Transformers from 3 to 4 involves 175 releases with risk rating High. ## Breaking Changes List: - [vv4.0.0] Breaking changes since v3.x Version v4.0.0 introduces several breaking changes that were necessary.: - [vv4.0.0] Version v4.0.0 introduces several breaking changes that were necessary.: - [vv4.0.0] The python and rust tokenizers have roughly the same API, but the rust tokenizers have a more complete feature set. The main breaking change is the handling of overflowing tokens between the python and rust tokenizers.: - [vv4.0.0] This is a breaking change as importing intermediary layers using a model's module directly needs to be done via a different path.: - [vv4.0.0] This is a breaking change as the limitation of that tuple is that it cannot be unpacked: `value0, value1 = outputs` will not work.: - [vv4.0.0] - [breaking|pipelines|tokenizers] Adding slow-fast tokenizers equivalence tests pipelines - Removing sentencepiece as a required dependency #8073 (@thomwolf): - [vv4.2.0] Breaking changes There are no breaking changes between the previous version and this one.: - [vv4.3.0] Breaking changes None.: - [vv4.9.0] Breaking changes When `load_best_model_at_end` was set to `True` in the `TrainingArguments`, having a different `save_strategy` and `eval_strategy` was accepted but the `save_strategy` was overwritten by the `eval_strategy` (the option to keep track of the best model needs to make sure there is an evaluation each time there is a save). This led to a lot of confusion with users not understanding why the script was not doing what it was told, so this situation will now raise an error indicating to set `save_strategy` and `eval_strategy` to the same values, and in the case that value is `"steps"`: - [vv4.10.0] Slight breaking change When loading some kinds of corrupted state dictionaries of models, the `PreTrainedModel.from_pretrained` method was sometimes silently ignoring weights. This has now become a real error.: - [vv4.11.0] Breaking changes *We strive for no breaking changes between releases - however, some bugs are not discovered for long periods of time, and users may eventually rely on such bugs. We document here such changes that may affect users when updating to a recent version.*: - [vv4.17.0] Breaking change Unfortunately, some bugs had crept into `CLIPTokenizerFast` : the tokenization produced by `CLIPTokenizer` and `CLIPTokenizerFast` were not equal. `CLIPTokenizerFast` has been corrected to encode the text with the same strategy as `CLIPTokenizer`.: - [vv4.22.0] Fix breaking change in `onnxruntime` for ONNX quantization by @severinsimmler in #18336: - [vv4.23.0] :warning: This is a recently introduced model and modality, so the API hasn't been tested extensively. There may be some bugs or slight breaking changes to fix it in the future. If you see something strange, file a [Github Issue](https://github.com/huggingface/transformers/issues/new?assignees=&labels=&template=bug-report.md&title).: - [vv4.23.0] 🚨 Breaking changes The following changes are bugfixes that we have chosen to fix even if it changes the resulting behavior. We mark them as breaking changes, so if you are using this part of the codebase, we recommend you take a look at the PRs to understand what changes were done exactly..: - [vv4.23.0] The following changes are bugfixes that we have chosen to fix even if it changes the resulting behavior. We mark them as breaking changes, so if you are using this part of the codebase, we recommend you take a look at the PRs to understand what changes were done exactly..: - [vv4.23.0] Breaking change for ViT parameter initialization: - [vv4.23.0] Breaking change for the `top_p` argument of the `TopPLogitsWarper` of the `generate` method.: - [vv4.24.0] 🚨 Breaking changes The following changes are bugfixes that we have chosen to fix even if it changes the resulting behavior. We mark them as breaking changes, so if you are using this part of the codebase, we recommend you take a look at the PRs to understand what changes were done exactly.: - [vv4.24.0] The following changes are bugfixes that we have chosen to fix even if it changes the resulting behavior. We mark them as breaking changes, so if you are using this part of the codebase, we recommend you take a look at the PRs to understand what changes were done exactly.: - [vv4.24.0] 🚨🚨🚨 TF: Remove `TFWrappedEmbeddings` (breaking: TF embedding initialization updated for encoder-decoder models) by @gante in #19263: - [vv4.24.0] 🚨🚨🚨 [Breaking change] Deformable DETR intermediate representations by @Narsil in #19678: - [vv4.25.1] Breaking changes * 🚨 🚨 🚨 Fix Issue 15003: SentencePiece Tokenizers Not Adding Special Tokens in `convert_tokens_to_string` by @beneyal in #15775: - [vv4.25.1] [Proposal] Breaking change `zero-shot-object-detection` for improved consistency. by @Narsil in #20280: - [vv4.26.0] Breaking a bit the one model per file policy, we introduce backbones (mainly for vision models) which can then be re-used in more complex models like DETR, MaskFormer, Mask2Former etc.: - [vv4.27.0] [πŸ› οΈ] Fix-whisper-breaking-changes by @ArthurZucker in #21965: - [vv4.27.0] Breaking changes *Generate*: - [vv4.27.1] Patches two unwanted breaking changes that were released in v4.27.0:: - [vv4.28.0] Breaking Changes ### Ordering of height and width for the BLIP image processor: - [vv4.28.0] Adapt find_tied_parameters to handle breaking change in Accelerate by @sgugger in #22360: - [vv4.29.0] Breaking changes This releases has three breaking changes compared to version v4.28.0.: - [vv4.29.0] This releases has three breaking changes compared to version v4.28.0.: - [vv4.29.0] Finally, the third breaking change aims to harmonize the training procedure for most of recent additions in transformers. It should be users' responsibility to fill_mask the padding tokens of the labels with the correct value. This PR addresses the issue that was raised by other architectures such as Luke or Pix2Struct: - [vv4.31.0] Breaking changes Fixes an issue with stripped spaces for the T5 family tokenizers. If this impacts negatively inference/training with your models, please let us know by opening an issue.: - [vv4.32.0] By deprecating, we indicate that we will stop maintaining such models, but there is no intention of actually removing those models and breaking support for them (they might one day move into a separate repo/on the Hub, but we would still add the necessary imports to make sure backward compatibility stays). The main point is that we stop testing those models. The usage of the models drives this choice and aims to ease the burden on our CI so that it may be used to focus on more critical aspects of the library.: - [vv4.32.0] Breaking changes ### Default optimizer in the `Trainer` class: - [vv4.33.1] Breaking changes: * 🚨🚨🚨 [`Refactor`] Move third-party related utility files into `integrations/` folder 🚨🚨🚨 by @younesbelkada in #25599: - [vv4.34.0] These are not breaking changes per se but rather bugfixes. However, we understand that this may result in some workflow changes so we highlight them below.: - [vv4.34.0] - the length of a tokenizer is now max(set(self.get_vocab().keys())) accounting for holes in the vocab. The vocab_size no longer takes into account the added vocab for most of the tokenizers (as it should not). Mostly breaking for T5: - [vv4.35.0] Breaking changes * 🚨🚨🚨 [`Quantization`] Store the original dtype in the config as a private attribute 🚨🚨🚨 by @younesbelkada in #26761: - [vv4.36.0] Breaking changes ### pickle files: - [vv4.39.0] Breaking changes The PRs below introduced slightly breaking changes that we believed was necessary for the repository; if these seem to impact your usage of transformers, we recommend checking out the PR description to get more insights in how to leverage the new behavior.: - [vv4.39.0] The PRs below introduced slightly breaking changes that we believed was necessary for the repository; if these seem to impact your usage of transformers, we recommend checking out the PR description to get more insights in how to leverage the new behavior.: - [vv4.39.1] Patch release to fix some breaking changes to LLaVA model, fixes/cleanup for Cohere & Gemma and broken doctest: - [vv4.39.3] - generate fix breaking change for patch #29976: - [vv4.40.0] [ `TokenizationLlama`] fix the way we convert tokens to strings to keep leading spaces 🚨 breaking fix by @ArthurZucker in #29453: - [vv4.40.0] [`generate`] fix breaking change for patch by @ArthurZucker in #29976: - [vv4.41.0] 🚨 might be breaking * 🚨🚨🚨Deprecate `evaluation_strategy` to `eval_strategy`🚨🚨🚨 by @muellerzr in https://github.com/huggingface/transformers/pull/30190 * 🚨 Add training compatibility for Musicgen-like models by @ylacombe in https://github.com/huggingface/transformers/pull/29802: - [vv4.41.0] Not breaking but important for Llama tokenizers: - [vv4.42.0] Breaking changes ### Remove ConversationalPipeline and Conversation object: - [vv4.42.0] This has the possibility of being a slight breaking change if users are creating models and relying on `out_indices` on being a tuple. As this property only happens when a new model is created, and not if it's saved and reloaded (because of the config), then I think this has a low chance of having much of an impact.: - [vv4.42.0] Llama et al. / FSDP : Fix breaking change in 4.40 for FSDP by @younesbelkada in #31161: - [vv4.43.0] Breaking changes ### TextGenerationPipeline and tokenizer kwargs: - [vv4.43.0] 🚨🚨 This PR changes the code to rely on the tokenizer's defaults when these flags are unset. This means some models using `TextGenerationPipeline` previously did not add a `` by default, which (negatively) impacted their performance. In practice, this is a breaking change.: - [vv4.44.0] Breaking changes: We removed the chat template **in the code**, they should all be on the hub! * 🚨 No more default chat templates #31733 by @Rocketknight1: - [vv4.48.0] Breaking changes ### Conversion scripts: - [vv4.48.0] This PR finalizes work that aimes to enable short-form (< 30 secs) and long-form generation using temperature fallback. It is a significant improvement to the whisper codebase, but it does result in the following breaking changes:: - [vv4.49.0] Breaking changes ### DPT segmentation maps: - [vv4.49.0] Revert qwen2 breaking changes related to attention refactor by @ArthurZucker in #36162: - [vv4.50.0] Fixing the docs corresponding to the breaking change in torch 2.6. by @Narsil in #36420: - [vv4.52.1] Breaking changes * 🚨 rm already deprecated pad_to_max_length arg by @itazap in #37617: - [vv4.53.0] Breaking changes Several minimal breaking changes aiming to bring clearer defaults while greatly simplifying the library have been merged.: - [vv4.53.0] Several minimal breaking changes aiming to bring clearer defaults while greatly simplifying the library have been merged.: - [vv4.54.0] Breaking changes * [Whisper] 🚨 Fix pipeline word timestamp: timestamp token is end of token time !!! by @eustlb in #36632: - [vv4.54.0] Fix tests due to breaking change in accelerate by @SunMarc in #39451: - [vv4.56.0] Breaking changes The following commits are breaking changes in workflows that were either buggy or not working as expected.: - [vv4.56.0] The following commits are breaking changes in workflows that were either buggy or not working as expected.: - [vv4.57.0] Breaking changes * 🚨 Remove Group Beam Search decoding strategy by @manueldeprada in #40495: ## Instructions for AI Assistant: When migrating user code from Hugging Face Transformers 3 to 4, scan for the deprecated APIs and breaking changes above and refactor code to use modern vv4.57.6 idioms.