NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #269 most downloaded on PyPI
Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
Latest stable
5.23.0
Last release 7 days ago
13 Nov 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
6 versions withdrawn
withdrawn after publishing
10 years old
253 releases · first in 2016
Drag across the ruler to compare, or tap a release to open it.
Tokenizers for Bert, Roberta, OpenAI GPT, OpenAI GPT2, TransformerXL are now leveraging tokenizers library for fast tokenization :rocket:
Known Issues:
The distilled version of the bert-base-cased BERT checkpoint has been released.
Model cards are now stored directly in the repository
We now host a CLI script that gathers all the environment information when reporting an issue. The issue templates have been updated accordingly.
The main contributors as identified by Sourcerer are now visible directly on the repository.
The language fine-tuning script has been renamed from run_lm_finetuning to run_language_modeling as it is now also able to train language models from scratch.
cached_path (@thomwolf )Slight modification to cached_path so that zip and tar archives can be automatically extracted.
extract_compressed_file=True when calling cached_file.force_extract=True, in which case the cached extraction directory is removed and the archive is extracted again.Several activation functions (relu, swish, gelu, tanh and gelu_new) can now be accessed from the activations.py file and be used in the different PyTorch models.
test_attention_weights (@sshleifer)run_language_modeling (@LysandreJik )TokenClassificationPipeline, which is an alias over NerPipeline (@julien-c )Your coding agent can read these notes before it upgrades. Set up the MCP server →
Patched an issue where FlauBERT couldn't be loaded with AutoModel and AutoTokenizer classes.
Patched an issue where FlauBERT couldn't be loaded with AutoModel and AutoTokenizer classes.
MMBT was added to the list of available models, as the first multi-modal model to make it in the library. It can accept a transformer model as well as
wietsedv/bert-base-dutch-cased identifier. Added by @wietsedv. Model pageblack, isort and flake8. A test was added, check_code_quality, which checks that the contributions respect the contribution guidelines related to those tools.setup.py for the necessary dev dependencies.make style
make quality
The documentation was uniformized and some better guidelines have been defined. This work is part of an ongoing effort of making transformers accessible to a larger audience. A glossary has been added, adding definitions for most frequently used inputs.
Furthermore, some tips are given concerning each model in their documentation pages.
The code samples are now tested on a weekly basis alongside other slow tests.
The source code was moved from ./transformers to ./src/transformers. Since it changes the location of the source code, contributors must update their local development environment by uninstalling and re-installing the library.
Version 2.3.0 was the last version to support Python 2. As we begin the year 2020, official Python 2 support has been dropped.
Tests can now be run in parallel
An abstract method was added to PreTrainedModel, which is implemented in all models trained with CLM. This abstract method is generate, which offers an API for text generation:
Previously, when stopping a training the only saved values would be the model weights/configuration. Now the different scripts save several other values: the global step, current epoch, and the steps trained in the current epoch. When resuming a training, all those values will be leveraged to correctly resume the training.
This applies to the following scripts: run_glue, run_squad, run_ner, run_xnli.
The run_lm_finetuning.py script now handles training from scratch.
The configuration files now contain the architecture they're referring to. There is no need to have the architecture in the file name as it was necessary before. This should ease the naming of community models.
A new type of AutoModel was added: AutoModelForPreTraining. This model returns the base model that was used during the pre-training. For most models it is the base model alongside a language modeling head, whereas for others it is a different model, e.g. BertForPreTraining for BERT.
The HANS dataset was added to the examples. It allows for testing a model with adversarial evaluation of natural language.
When using PyTorch, certain values can be ignored when computing the loss. In order for the loss function to understand which indices must be ignored, those have to be set to a certain value. Most of our models required those indices to be set to -1. We decided to set this value to -100 instead as it is PyTorch's default value. This removes the discrepancy between user-implemented losses and the losses integrated in the models.
Further help from @r0mainK.
generate method which did not correctly handle the repetition penalty (@patrickvonplaten)repeating_words_penalty_for_language_generation (@patrickvonplaten)run_generation now leverages cached past input for models that have access to it (@patrickvonplaten)DistilHeisenBug or HeisenDistilBug (@LysandreJik, with the help of @julien-c and @thomwolf).run_tf_ner (@karajan1001).run_generation (@alberduris)run_gluerp_bucket (@mschrimpf)prepare_for_model when tensorizing and returning token type IDs (@LysandreJik).never_split parameters (@DeNeutoy)We have added a new class called Pipeline to simply run and use models for several down-stream NLP tasks.
Pipeline (beta): easily run and use models on down-stream NLP tasksWe have added a new class called Pipeline to simply run and use models for several down-stream NLP tasks.
A Pipeline is just a tokenizer + model wrapped so they can take human-readable inputs and output human-readable results.
The Pipeline will take care of :
tokenizing inputs strings => convert in tensors => run in the model => post-process output
Currently, we have added the following pipelines with a default model for each:
There are three ways to use pipelines:
from transformers import pipeline
# Test the default model for QA (Bert large finetuned on SQuAD 1.0)
nlp = pipeline('question-answering')
nlp(question= "Where does Amy live ?", context="Amy lives in Amsterdam.")
>>> {'answer': 'Amsterdam', 'score': 0.9657156007786263, 'start': 13, 'end': 21}
# Test a specific model for NER (XLM-R finetuned by @stefan-it on CoNLL03 English)
nlp = pipeline('ner', model='xlm-roberta-large-finetuned-conll03-english')
nlp("My name is Amy. I live in Paris.")
>>> [{'word': 'Amy', 'score': 0.9999586939811707, 'entity': 'I-PER'},
{'word': 'Paris', 'score': 0.9999983310699463, 'entity': 'I-LOC'}]
bash $ echo -e "Where does Amy live?\tAmy lives in Amsterdam" | transformers-cli run --task question-answering
{'score': 0.9657156007786263, 'start': 13, 'end': 22, 'answer': 'Amsterdam'}
transformers-cli serve --task question-answering
This new feature is currently in beta and will evolve in the coming weeks.
Users can now create accounts on the huggingface.co website and then login using the transformers CLI. Doing so allows users to upload their models to our S3 in their respective directories, so that other users may download said models and use them in their tasks.
Users may upload files or directories.
It's been tested by @stefan-it for a German BERT and by @singletongue for a Japanese BERT.
The run_squad script has been massively refactored. The reasons are the following:
It now leverages the full capacity of encode_plus, easing the addition of new models to the script. A new method squad_convert_examples_to_features encapsulates all of the tokenization.
This method can handle tensorflow_datasets as well as squad v1 json files and squad v2 json files.
A contribution by @rlouf building on the encoder-decoder mechanism to do abstractive summarization.
from_pretrained())@alexzubiaga added XLNetForTokenClassification and TFXLNetForTokenClassification
run_bertology.py was updated with correct imports and the ability to overwrite the cacherun_lm_finetuning.py @bkkagglefrom_pretrained() can now load from urls directly.run_squad.py @ethanjperezPatched error where the tokenizers would split the special tokens.
Patched error where the tokenizers would split the special tokens.
This patch fixes a bug related to the input shape in several models in TensorFlow.
This patch fixes a bug related to the input shape in several models in TensorFlow.
A tokenization message was too present and overloaded the output, hiding the relevant information. It was removed.
Four new models have been added in v2.2.0
Four new models have been added in v2.2.0
We welcome the possibility to create fully seq2seq models by incorporating Encoder-Decoder architectures using a PreTrainedEncoderDecoder class that can be initialized from pre-trained models. The base BERT class has be modified so that it may behave as a decoder.
Furthermore, a Model2Model class that simplifies the definition of an encoder-decoder when both encoder and decoder are based on the same model has been added. @rlouf
Works by @tlkh and @LysandreJik aiming to benchmark the library models with different technologies: with TensorFlow and Pytorch, with mixed precision (AMP and FP-16) and with model tracing (Torchscript and XLA). A new section was created in the documentation: benchmarks pointing to Google sheets with the results.
Tokenizers now add special tokens by default. @LysandreJik
Model templates to ease the addition of new models to the library have been added. @thomwolf
A new input has been added to all models' forward (for Pytorch) and call (for TensorFlow) methods. These inputs_embeds are a direct embedded representation. This is useful as it gives more control over how to convert input_ids indices into associated vectors than the model's internal embedding lookup matrix. @julien-c
A new API for the input and output embeddings are available. These methods are model-independent and allow easy acquisition/modification of the models' embeddings. @thomwolf
New model architectures are available, namely: DistilBertForTokenClassification, CamembertForTokenClassification @stefan-it
Two new models have been added since release 2.0.
Two new models have been added since release 2.0.
Several updates have been made to the distillation script, including the possibility to distill GPT-2 and to distill on the SQuAD task. By @VictorSanh.
The run_glue.py example script can now run on a Pytorch TPU.
Several example scripts have been improved and refactored to use the full potential of the new tokenizer functions:
run_multiple_choice.py has been refactored to include encode_plus by @julien-c and @erenuprun_lm_finetuning.py has been improved with the help of @dennymarcels, @jinoobaek-qz and @LysandreJikrun_glue.py has been improved with the help of @brian41005Enhancements have been made on the tokenizers. Two new methods have been added: get_special_tokens_mask and truncate_sequences .
The former returns a mask indicating which tokens are special tokens in a token list, and which are tokens from the initial sequences. The latter truncate sequences according to a strategy.
Both of those methods are called by the encode_plus method, which itself is called by the encode method. The encode_plus now returns a larger dictionary which holds information about the special tokens, as well as the overflowing tokens.
Thanks to @julien-c, @thomwolf, and @LysandreJik for these additions.
The two methods add_special_tokens_single_sequence and add_special_tokens_sequence_pair have been removed. They have been replaced by the single method build_inputs_with_special_tokens which has a more comprehensible name and manages both sequence singletons and pairs.
The boolean parameter truncate_first_sequence has been removed in tokenizers' encode and encode_plus methods, being replaced by a strategy in the form of a string: 'longest_first', 'only_second', 'only_first' or 'do_not_truncate' are accepted strategies.
When the encode or encode_plus methods are called with a specified max_length, the sequences will now always be truncated or throw an error if overflowing.
New contributing guidelines have been added, alongside library development requirements by @rlouf, the newest member of the HuggingFace team.
tensorflow_datasets. This work has been done by @agrinh and @philipp-eisen.Nothing published for this version
model(inputs_ids, attention_mask=attention_mask, token_type_ids=token_type_ids), this should not cause any breaking change.
Following the extension to TensorFlow 2.0, pytorch-transformers => transformers
Install with pip install transformers
Also, note that PyTorch is no longer in the requirements so don't forget to install TensorFlow 2.0 and/or PyTorch to be able to use (and load) the models.
All the PyTorch nn.Module classes now have their counterpart in TensorFlow 2.0 as tf.keras.Model classes. TensorFlow 2.0 classes have the same name as their PyTorch counterparts prefixed with TF.
The interoperability between TensorFlow and PyTorch is actually a lot deeper than what is usually meant when talking about libraries with multiple backends:
from_pretrained can load weights saved from models saved in one or the other framework),Training on TPU using free TPUs provided in the TensorFlow Research Cloud (TFRC) program is possible but requires to implement a custom training loop (not possible with keras.fit at the moment). We will add an example of such a custom training loop soon.
Tokenizers have been improved to provide extended encoding methods encoding_plus and additional arguments to encoding. Please refer to the doc for detailed usage of the new options.
To be able to better use Torchscript both on CPU and GPUs (see #1010, #1204 and #1195) the specific order of some models keywords inputs (attention_mask, token_type_ids...) has been changed.
If you used to call the models with keyword names for keyword arguments, e.g. model(inputs_ids, attention_mask=attention_mask, token_type_ids=token_type_ids), this should not cause any breaking change.
If you used to call the models with positional inputs for keyword arguments, e.g. model(inputs_ids, attention_mask, token_type_ids), you should double-check the exact order of input arguments.
PyTorch is no longer in the requirements so don't forget to install TensorFlow 2.0 and/or PyTorch to be able to use (and load) the models.
The method add_special_tokens_sentence_pair has been renamed to the more appropriate name add_special_tokens_sequence_pair.
The same holds true for the method add_special_tokens_single_sentence which has been changed to add_special_tokens_single_sequence.
Nothing published for this version
One column per quarter.