All notable changes to this project will be documented in this file. The format is based on Keep a Changelog.
- (BREAKING) Upgraded to
torch2.4 (viatch0.17.0).
- Addition of
new_with_tokenizerconstructor forSentenceEmbeddingsModelallowing passing custom tokenizers for sentence embeddings pipelines. - Support for Tokenizers in pipelines, allowing loading
tokenizer.jsonandspecial_token_map.jsontokenizer files. - (BREAKING) Most model configuration can now take an optional
kindparameter to specify the model weight precision. If not provided, will default to full precision on CPU, or the serialized weights precision otherwise.
- (BREAKING) Fixed the keyword extraction pipeline for n-gram sizes > 2. Add new configuration
option
tokenizer_forbidden_ngram_charsto specify characters that should be excluded from n-grams (allows filtering n-grams spanning multiple sentences). - Improved MPS device compatibility setting the
sparse_gradflag to false forgatheroperations - Updated ONNX runtime backend version to 1.15.x
- Issue with incorrect results for QA models with a tokenizer not using segment ids
- Issue with GPT-J that was incorrectly tracking the gradients for the attention bias
- (BREAKING) Upgraded to
torch2.1 (viatch0.14.0). - (BREAKING) Text generation traits and pipelines (including conversation, summarization and translation) now return
a
Resultfor improved error handling
- Addition of the LongT5 model architecture and pretrained weights.
- Addition of
add_tokensandadd_extra_idsinterface methods to theTokenizerOption. Allow building most pipeline with custom tokenizer vianew_with_tokenizer. - Addition of
get_tokenizerandget_tokenizer_mutmethods to all pipelines allowing to get a (mutable) reference to the pipeline tokenizer. - Addition of a
get_embedding_dimmethod to get the dimension of the embeddings for sentence embeddings pipelines get_vocab_size,get_decoder_start_token_idandget_prefix_and_forced_bos_idfor theTokenizerOptionin pipelines- Addition of the GPT-J model architecture
- Addition of the NLLB model architecture and pretrained weights
- Addition of support for ONNX models (encoder, decoders, encoder-decoders) via the ort onnxruntime bindings
- Integration of ONNX models to the sequence classification, token classification, question answering, zero-shot classification, text generation, summarization and translation pipelines
- Bumped the tokenizers dependency from 7.x to 8.x, exposing additional options for special token mapping and adding the NLLBTokenizer
- (BREAKING) Simplified the generation traits (removal of LMHeadModel and elimination of unnecessary specification for LanguageGenerator)
- (BREAKING) Upgraded to
torch2.0 (viatch0.13.0). The process to automatically download the dependencies have changed, it must now be enabled via thedownload-libtorchfeature flag. - Read the
decoder_start_token_idfrom the provided configuration rather than using a hard-coded default value - (BREAKING) Changed the return type of the
LanguageGeneratorand pipelines functionsfloat,half,set_devicetoResult<(), RustBertError>as these become fallible for ONNX models - (BREAKING) Wrapped the model resources specification for the pipeline
Configobjects into anEnumto allow handling both torch-based and ONNX models. Themodel_resourcesfield now needs to be wrapped in the corresponding enum variant, e.g.model_resources: ModelResources::TORCH(model_resource)for Torch-based models - (BREAKING) Added the
forced_bos_token_idandforced_eos_token_idfields to text generation models. If these are not None, this will trigger a forced BOS/EOS token generation at the first ofmax_lengthpositions ( aligns with the Pytorch Transformers library) - Project structure refactoring (torch-based models moved under common module). Non-breaking change via re-exports.
- MIN/MAX computation for float-like (was set to infinity instead of min/max)
- Remove the (unused) pooler from the set of weights for BERT Masked LM architecture
- Addition of All-MiniLM-L6-V2 model weights
- Addition of Keyword/Keyphrases extraction pipeline based on KeyBERT (https://github.com/MaartenGr/KeyBERT)
- Addition of Masked Language Model pipeline, allowing to predict masked words.
- Support for the CodeBERT language model with pretrained models for language detection and masked token prediction
- Addition of type aliases for the controlled generation (
PrefixAllowedFunction) and zero-shot classification (ZeroShotTemplate). - (BREAKING)
merges_resourcenow optional for all pipelines. - Allow mixing local and remote resources in pipelines.
- Upgraded to
torch1.13 (viatch0.9.0). - (BREAKING) Made the
max_lengthargument for generation methods and pipelines optional. - (BREAKING) Changed return type of
ModelForSequenceClassificationandModelForTokenClassificationtoResult<Self, RustBertError>allowing error handling if no labels are provided in the configuration.
- Fixed configuration check for RoBERTa models for sentence classification.
- Fixed a bug causing the input prompt to be truncated for text generation if the prompt length was longer
than
max_length
- Support for sentence embeddings models and pipelines, based on SentenceTransformers.
- Upgraded to
torch1.12 (viatch0.8.0)
- Allow empty slices or slices of empty prompts for text generation.
- Addition of the DeBERTa language model and support for question answering, sequence and token classification
- Addition of the DeBERTa v2/v3 language model and support for question answering, sequence and token classification
- Addition of a
new_with_tokenizermethod allowing building language model generator with a custom tokenizer (or pairing a tokenizer that was not originally designed with the model, e.g. T5 tokenizer with GPT2 model). - (BREAKING) Addition of support for mT5 model, addition of new optional fields to T5Config
- Addition of
token_scoresfield whenoutput_scoresis set totruefor generation, returning the score for each token generated - Addition of
offsetsto entities generated in theNERpipeline
- (BREAKING) Updated
Resources, movingRemoteResourceand associated download utilities/dependencies behind a feature gate (enabled by default). Reworked the API for building and using resources. - Upgraded to
torch1.11 (viatch0.7.2) - Simplified token classification pipeline and mode aggregation now deterministic (fall back to the highest score for equally common labels)
- Fixed sinusoidal embeddings not being updated when loading a state dictionary (DistilBERT)
- Updated to
tch0.6.1 (libtorch 1.10) - (BREAKING) Simplified the generics for multiple library traits taking as a rule
&[AsRef<str>]or&stras inputs ( no longer accepts owned typesVecandString)
- (BREAKING) Support for
bad_word_idsgeneration, allowing to ban a set of word ids for all model supporting text generation - Support for half-precision mode for all models (reducing memory footprint). A model can be converted to half-precision
by calling the
half()method on theVarStoreis it currently stored in. Half-precision Torch kernels are not available for CPU (limited to CUDA devices) - (BREAKING) Extension of the generation options that can be provided at runtime (after a model has been instantiated
with a
GenerateConfig), allowing to update the generation options from one text generation to another with the same model. This feature is implemented at theLanguageGeneratortrait level, the high-levelTextGenerationpipeline API remains unchanged. - Addition of the FNet language model and support for sequence, token and multiple choice classification, question answering
- Addition of a full entities' prediction method supporting the IOBES scheme (merging entities token such as + -> )
- (BREAKING) Support for
prefix_allowed_tokens_fnargument for generation, allowing users to control the generation via custom functions - (BREAKING) Support for
forced_bos_token_idargument for generation, allowing users to force a given BOS token for generation (useful for MBart/M2M-class models) - (BREAKING) Support for
output_scoresboolean argument for generation, allowing users to output the log-probability scores of generated sequences. Updated the return type of low-level generate API toGeneratedTextOutputandGeneratedIndicesOutputcontaining optional scores along with the generated output. - Addition of the MBart Language model and support for text generation / direct translation between 50 language
- Addition of the M2M100 Language model and support for text generation / direct translation between 100 language
- Updated GPT2 architecture to re-use embeddings for the output projection layer (resulting in smaller model weights files and memory footprint)
- Upgraded
tchversion to 0.5.0 (usinglibtorch1.9.0) - Changed default value of
no_repeat_ngram_sizefor text generation from 3 to 0, aligning with Python's Transformers - Added the possibility to handle long inputs for token classification tasks (exceeding the model maximum length) using sliding windows over the input
- (BREAKING) Generalized borrowing of Tensors as input for models
- Aligned the optional
all_hidden_statesoutput for all models
- Updated T5 Decoder cross-attention to no longer use relative position bias (aligned with Python reference update)
- Removed hardcoded maximum length for sequence and token classification tasks, now using the model maximum position embeddings instead
- Fixed conversation model panic for user inputs exceeding the maximum model length (1000 tokens)
- Fixed translation model panic for user inputs exceeding the maximum number of position embeddings
- Addition of translation language pairs:
- English <-> Chinese (Simplified)
- English <-> Chinese (Traditional)
- English <-> Dutch
- English <-> Swedish
- English <-> Arabic
- English <-> Hebrew
- English <-> Hindi
- Addition of a Part of Speech pipeline. This pipeline allows predicting the POS tag (e.g. Noun, Adjective, Verb) of words in input sentences.
- Addition of a lightweight English Part of Speech tagging pretrained MobileBERT model
- Addition of the Pegasus language model and support for conditional generation
- Addition of a model for Pegasus summarization pretrained on the CNN-DM dataset
- Addition of the GPT-Neo language model and pretrained snapshots (125M, 1.3B and 2.7B parameters). Registration of
GPT-Neo as an option for
TextGenerationPipeline.
- (BREAKING) Changed
classif_dropoutinBartConfigto be an optional field. This affects dependencies instantiatingBartConfigfrom scratch, or usingclassif_configfor custom model heads. - (BREAKING) Changed token classification pipelines to return a Vec<Vec> instead of a Vec. The token-level predictions are now returned in separate vectors for each input sequence provided as an input (they were previously returned in a flattened vector)
- Simplification of the BART language model code base (also used for Marian and Pegasus language models)
- (BREAKING) Updated to
tch 0.4.1(based onlibtorch 1.8.1)
- Fixed character indexing error for Question Answering pipeline answers
- Dependency to
itertoolscrate
- Addition of the Longformer language model, task-specific heads and registration in relevant pipelines
- (BREAKING) Exposed additional settings for the Question Answering pipeline related to the maximum question, context
and answer length. This is not backward compatible if the question answering configuration was created without using
the
newcreator. - Simplified the Question answering pipeline to rely on the offsets calculated by the tokenizers instead of a manual alignment. This results in moderate execution speed improvements for this pipeline.
- Updated the padding strategy for the Question answering pipeline. While before all sequences were padded to a
fixed
max_length(defaulting to 384), the padding is now done dynamically based on the length of the inputs. This results in a significant speed improvement for this pipeline.
- Fixed a bug for Question Answering for models that were not based on Wordpiece tokenization (including BPE and unigram based tokenizers). The issue was caused by the pre-tokenization step that was stripping the leading whitespace for all tokens. The performance of these models for QA should improve significantly.
- Addition of the ProphetNet language model, task-specific heads and registration in relevant pipelines
- (BREAKING) Implementation of Diverse Beam Search. This allows the generation of
more diverse sequences within the number of beams. Addition of 2 new fields to the
GenerateConfigthat are propagated through all text generation configs (e.g.TranslationConfig):num_beam_groups(Option<i64>), indicating the number of sub-beam groups. This must be a divisor of the number of beams.diversity_penalty(Option<f64>), indicating by which amount to penalize common words between beam groups. This will default to 5.5 if not provided. The impact of this diverse beam search is illustrated in the GPT2 integration tests.
- (BREAKING) Simplified the input and output of encoder/decoder models to avoid needing to take ownership of the possibly cached encoder hidden state, offering a minor performance improvement for text generation tasks. The model output field for encoder hidden states are now optional, and only returned if the encoder hidden states were not provided for the given forward path. This may be a breaking change for low-level dependencies that manipulate directly the encoder/decoder model outputs.
- (BREAKING) Moved the language models implementation of the
PrivateLanguageGeneratorandLanguageGeneratortraits ( needed to generate text) to the model modules, cleaning up the generation_utils module. - Updated download utilities crate, now leveraging Tokio 1.0 runtimes.
- Updated padding information and addition of position ids for batched GPT2 generation. Prior to this change, inputs that required padding had a lower quality for the text generated.
- Addition of the MobileBERT language model, task-specific heads and registration in relevant pipelines
- Made all model configurations
Clone - Made several base modules of the BERT language model public, and added model output
Structfor the new publicly exposed, complex types
- Addition of the Reformer language model, task-specific heads and registration in relevant pipelines
- Pre-trained models for DistilRoBERTa, used as a default for integration tests
- Updated endpoint of the model resources reflecting changes to the Hugging Face's model hub
- Early stopping turned by default on for translation and summarization
- Support for additional models for the conversational pipeline
- Updated the version of Tokenizer crate with consistent visibility
- (BREAKING) move of teh text generation pipeline to its owned pipeline. Shared generation utilities are moved
to
generation_utils - All models, tokenizers and pipelines are now
Send
- Benchmark scripts for all pipelines
- Addition of the XLNet model and task-specific heads
- (BREAKING) Changed the download method for resources now a method of the resource itself, and leveraging the cached-path crate.
- (BREAKING) Changed the return type of models to be output
Structinstead of long tuples. - (BREAKING) Changed the naming of the model main modules from
modelnametomodel_modelnameto avoid confusion with the top level module name - Extended the range of allowed types for pipelines input, allowing both owned
Vecand slices, and bothStringand sting slice. - Handling of all activations functions is mow made from a common module and
Struct
- Zero-shot classification pipeline using a natural language inference model
- (BREAKING) Updated version of tokenizers crate with added options for lower casing, accent stripping and prefix addition
- Updated BART classification model to allow running their
forwardmethod without being mutable.
- (BREAKING) Improved error handling via the addition of
RustBertErrorand error propagation throughout the crate.
- Updated version of tokenizers crate with improved error handling
- Addition of the reformer language model and its integration for language generation
- Changed model resources endpoints to leverage updated Hugging Face's model hub
- Updated the beam search processing to use vectorized operations
- Generalization of the accepted input for several pipelines to accept both
Vecand slices, and to accept bothStringand&str
- Addition of the ALBERT language model and task-specific heads
- Addition of German - English translation models
- Addition of the T5 language model and integration in supported pipelines (translation and summarization)
- Updated the modules throughout the crate to accept both owned and references to varstore paths.
- Addition of a multi-turn conversational pipeline based on DialoGPT.
- Code formatting using
rustfmt
- Removed the requirement for generation models to be mutable. Models are now all stateless, and no longer store an internal cache (now provided as an input).
- Updated BART model to take past layer states as an input instead of storing in internally.
- Fixed sequence classification model logits squeeze causing it to crash for batched inputs.
- Addition of translation between Russian and English
- Fixed a bug causing downloads to be incomplete, and removes the creation of a tokio runtime for the download of resources.
- Addition of the Marian model, leveraging a shared language model implementation with the BART model.
- Addition of translation capabilities. Supports translation between English and French, Spanish, Portuguese, Italian, Catalan and German, and between German and French.
- Addition of multi-label classification capabilities for sequence classification via the
predict_mutilabelfunction.
- Generalization of pipelines to allow leveraging multiple model architectures. Leveraging
Enumunpacking, introducesConfigOption,TokenizerOptionand pipeline-specific Options. - Addition of generic
SentenceClassificationModelpipeline. TheSentimentModelnow leverages shared implementation for sentence classification. - Addition of
TokenClassificationModelpipeline. TheNERModelnow leverages shared implementation for token classification.
- Major rework of tokenization crate, alignment with updated API
- Minor bug fixes for tokenization
- Implementation of the Electra model (generator, discriminator, task-specific heads)
- GPT2-medium and GPT2-large models
- Addition of Resources for handling file dependencies (e.g. vocabularies, model weights, configurations). Resources may
be
LocalResources(pointing to a filesystem location) orRemoteResources(pointing to a remote endpoint). These resources can be passed to adownload_resourcemethod that returns the location in the local filesystem for both types of resources, downloading them if necessary. - Resources specifications for all existing architectures, pointing to model files hosted on Hugging Face's model hub.
- (BREAKING) moved the resources' specification to the
GenerateConfigforGPT2Generator. - (BREAKING) creation of pipeline configurations to contain the resources required to build the pipeline, used as an input rather than paths to local files.
- Updated the configuration for the number of target labels to use the
id2labelfield instead ofnum_labels( aligning with changes in standard configuration in the Transformers library). Removednum_labelsfrom configurations. - Made the
output_attentions,output_hidden_statesandtorchscriptfields for DistilBERT configuration optional - Fixed the device placement for sinusoidal embeddings for DistilBERT model.
- Optimization of the BART model avoiding unnecessary tensor copies for cache manipulation and residual connections.
- Optimization of DistilBERT model when embeddings are provided as an input
- Minor optimizations to question answering and sentiment analysis pipelines
- Addition of a cache reset for text generation routines
- Implementation of cache reset for BART language model
- BART language model
- Implementation of
LanguageModelandPrivateLanguageModelfor BART - Summarization capabilities
- Tanh activation
- (BREAKING) Moved the
LMHeadModelTrait from GPT2 module to the pipelines module - Updated the
LMHeadModelinputs to includeencoder_outputsanddecoder_input_idsto support causal language model (e.g. BART) - (BREAKING) Added methods to the
PrivateLanguageGeneratorto support encoder-decoder models - (BREAKING) changed the type of
Generatorlanguage model to require mutability (BART caching mechanism stores the cache in the model requiring the entire model mutability - changed at a later point) - Optimization of the
get_banned_tokenmethod
- Updated the device location of the token update when EOS is not allowed because the minimum sequence length was not reached
- No longer process a given beam hypothesis if it is marked as done
- No longer add beams to a hypothesis if the rank is lower than the number of beams
- Updated final beam update to skip completed hypotheses
- Documentation throughout the crate
- Creation of a
GenerateConfigconfiguration structure to hold generation options
- Visibility of low-level utilities in the crate
- Updated the generation options to be passed at the text generation model instantiation, rather than at every call to
the
generatemethod - Updated visibility of generation routines into a public API and private lower level methods
- Text generation now takes a
Option<Vec<&str>>instead of aOption<&str>. Shorter sequences are left-padded withpadif available, otherwise witheos. - Turned-off gradient calculations for generation process
- Beam search completion validation
- Padding sequence for sentences shorter than the maximum length moved to correct device
- DistilGPT2 pretrained weights for GPT2
LMHeadModeltrait for model supporting text generation, offering an interface between the model specific input/output, and the generic set of inputs/outputs expected for model supporting text generation- Implementation of
LMHeadModelfor GPT2 and GPT - Text generation pipeline, supporting beam search, top-k/top-p decoding, repeated tokens banning, repetition and length
penalties as
LanguageGeneratorTrait - Implementation of
LanguageGeneratorfor GPT and GPT2 - Examples and tests for language generation
- Fixed concatenation dimension for GPT2 past
- Updated input type for
QuestionAnsweringModel'spredictto be&[QaInput]instead of a pair of question and context strings. QuestionAnsweringModel now works with a list of inputs and returns a list of predictions, processing inputs as batches.
- Swish and gelu_new activation functions
- GPT2 language model
- GPT language model
- Addition of a NER pipeline
- Addition of a QuestionAnswering pipeline
- Moved
SentimentClassifierfrom DistilBERT module to the newly created pipelines - Changed precision of id to label mapping of BERT config from
i32toi64 - Simplified calculation of sinusoidal embeddings for DistilBERT
- Addition of RoBERTa language model
- Addition of
BertEmbeddingtrait for BERT-like models
- Updated
BertEmbeddingsto implement the newly createdBertEmbeddingTrait - Updated
BertModel's embeddings to be of typeimpl BertEmbeddingrather than specific embeddings, allowing to re-use the BERT structure for other models, only replacing the embeddings layer.
- Fixed the variable path for BERT models with task-specific heads to allow loading a snapshot from models trained on Transformers.
- BERT Model and examples
- Addition of
DistilBertForTokenClassificationandDistilBertForQuestionAnsweringmodel heads - Collection of activation functions (gelu, relu, mish)
- Dropout module
- Custom Linear layer, allowing a creation without bias
- Config trait allowing to deserialize from
jsonfiles
- (BREAKING) Updated
DistilBertConfigto use the newly createdConfigTrait
- Integration tests
- Migrated from
rust_transformersv0.2.0 (deprecated) to `rust_tokenizers v1.0.0
- Example for DistilBERT masked language modeling
- Download utilities script for DistilBERT (base and SST2)
- made
label2id,id2label,is_decoder,output_pastanduse_bfloatconfiguration fields optional for DistilBertConfig
- Tensor conversion tools from Pytorch to Libtorch format
- DistilBERT model architecture
- Ready-to-use
SentimentClassifierusing a DistilBERT model fine-tuned on SST2