π€ Transformers
State-of-the-art Machine Learning for PyTorch, TensorFlow, and JAX.
π€ Transformers provides APIs and tools to easily download and train state-of-the-art pretrained models. Using pretrained models can reduce your compute costs, carbon footprint, and save you the time and resources required to train a model from scratch. These models support common tasks in different modalities, such as:
π Natural Language Processing: text classification, named entity recognition, question answering, language modeling, code generation, summarization, translation, multiple choice, and text generation.
πΌοΈ Computer Vision: image classification, object detection, and segmentation.
π£οΈ Audio: automatic speech recognition and audio classification.
π Multimodal: table question answering, optical character recognition, information extraction from scanned documents, video classification, and visual question answering.
π€ Transformers support framework interoperability between PyTorch, TensorFlow, and JAX. This provides the flexibility to use a different framework at each stage of a modelβs life; train a model in three lines of code in one framework, and load it for inference in another. Models can also be exported to a format like ONNX and TorchScript for deployment in production environments.
Join the growing community on the Hub, forum, or Discord today!
If you are looking for custom support from the Hugging Face team
Contents
The documentation is organized into five sections:
GET STARTED provides a quick tour of the library and installation instructions to get up and running.
TUTORIALS are a great place to start if youβre a beginner. This section will help you gain the basic skills you need to start using the library.
HOW-TO GUIDES show you how to achieve a specific goal, like finetuning a pretrained model for language modeling or how to write and share a custom model.
CONCEPTUAL GUIDES offers more discussion and explanation of the underlying concepts and ideas behind models, tasks, and the design philosophy of π€ Transformers.
API describes all classes and functions:
- MAIN CLASSES details the most important classes like configuration, model, tokenizer, and pipeline.
- MODELS details the classes and functions related to each model implemented in the library.
- INTERNAL HELPERS details utility classes and functions used internally.
Supported models and frameworks
The table below represents the current support in the library for each of those models, whether they have a Python tokenizer (called βslowβ). A βfastβ tokenizer backed by the π€ Tokenizers library, whether they have support in Jax (via Flax), PyTorch, and/or TensorFlow.
Model | PyTorch support | TensorFlow support | Flax Support |
---|---|---|---|
ALBERT | β | β | β |
ALIGN | β | β | β |
AltCLIP | β | β | β |
Audio Spectrogram Transformer | β | β | β |
Autoformer | β | β | β |
Bark | β | β | β |
BART | β | β | β |
BARThez | β | β | β |
BARTpho | β | β | β |
BEiT | β | β | β |
BERT | β | β | β |
Bert Generation | β | β | β |
BertJapanese | β | β | β |
BERTweet | β | β | β |
BigBird | β | β | β |
BigBird-Pegasus | β | β | β |
BioGpt | β | β | β |
BiT | β | β | β |
Blenderbot | β | β | β |
BlenderbotSmall | β | β | β |
BLIP | β | β | β |
BLIP-2 | β | β | β |
BLOOM | β | β | β |
BORT | β | β | β |
BridgeTower | β | β | β |
BROS | β | β | β |
ByT5 | β | β | β |
CamemBERT | β | β | β |
CANINE | β | β | β |
Chameleon | β | β | β |
Chinese-CLIP | β | β | β |
CLAP | β | β | β |
CLIP | β | β | β |
CLIPSeg | β | β | β |
CLVP | β | β | β |
CodeGen | β | β | β |
CodeLlama | β | β | β |
Cohere | β | β | β |
Conditional DETR | β | β | β |
ConvBERT | β | β | β |
ConvNeXT | β | β | β |
ConvNeXTV2 | β | β | β |
CPM | β | β | β |
CPM-Ant | β | β | β |
CTRL | β | β | β |
CvT | β | β | β |
DAC | β | β | β |
Data2VecAudio | β | β | β |
Data2VecText | β | β | β |
Data2VecVision | β | β | β |
DBRX | β | β | β |
DeBERTa | β | β | β |
DeBERTa-v2 | β | β | β |
Decision Transformer | β | β | β |
Deformable DETR | β | β | β |
DeiT | β | β | β |
DePlot | β | β | β |
Depth Anything | β | β | β |
DETA | β | β | β |
DETR | β | β | β |
DialoGPT | β | β | β |
DiNAT | β | β | β |
DINOv2 | β | β | β |
DistilBERT | β | β | β |
DiT | β | β | β |
DonutSwin | β | β | β |
DPR | β | β | β |
DPT | β | β | β |
EfficientFormer | β | β | β |
EfficientNet | β | β | β |
ELECTRA | β | β | β |
EnCodec | β | β | β |
Encoder decoder | β | β | β |
ERNIE | β | β | β |
ErnieM | β | β | β |
ESM | β | β | β |
FairSeq Machine-Translation | β | β | β |
Falcon | β | β | β |
FalconMamba | β | β | β |
FastSpeech2Conformer | β | β | β |
FLAN-T5 | β | β | β |
FLAN-UL2 | β | β | β |
FlauBERT | β | β | β |
FLAVA | β | β | β |
FNet | β | β | β |
FocalNet | β | β | β |
Funnel Transformer | β | β | β |
Fuyu | β | β | β |
Gemma | β | β | β |
Gemma2 | β | β | β |
GIT | β | β | β |
GLM | β | β | β |
GLPN | β | β | β |
GPT Neo | β | β | β |
GPT NeoX | β | β | β |
GPT NeoX Japanese | β | β | β |
GPT-J | β | β | β |
GPT-Sw3 | β | β | β |
GPTBigCode | β | β | β |
GPTSAN-japanese | β | β | β |
Granite | β | β | β |
GraniteMoeMoe | β | β | β |
Graphormer | β | β | β |
Grounding DINO | β | β | β |
GroupViT | β | β | β |
HerBERT | β | β | β |
Hiera | β | β | β |
Hubert | β | β | β |
I-BERT | β | β | β |
IDEFICS | β | β | β |
Idefics2 | β | β | β |
Idefics3 | β | β | β |
ImageGPT | β | β | β |
Informer | β | β | β |
InstructBLIP | β | β | β |
InstructBlipVideo | β | β | β |
Jamba | β | β | β |
JetMoe | β | β | β |
Jukebox | β | β | β |
KOSMOS-2 | β | β | β |
LayoutLM | β | β | β |
LayoutLMv2 | β | β | β |
LayoutLMv3 | β | β | β |
LayoutXLM | β | β | β |
LED | β | β | β |
LeViT | β | β | β |
LiLT | β | β | β |
LLaMA | β | β | β |
Llama2 | β | β | β |
Llama3 | β | β | β |
LLaVa | β | β | β |
LLaVA-NeXT | β | β | β |
LLaVa-NeXT-Video | β | β | β |
LLaVA-Onevision | β | β | β |
Longformer | β | β | β |
LongT5 | β | β | β |
LUKE | β | β | β |
LXMERT | β | β | β |
M-CTC-T | β | β | β |
M2M100 | β | β | β |
MADLAD-400 | β | β | β |
Mamba | β | β | β |
mamba2 | β | β | β |
Marian | β | β | β |
MarkupLM | β | β | β |
Mask2Former | β | β | β |
MaskFormer | β | β | β |
MatCha | β | β | β |
mBART | β | β | β |
mBART-50 | β | β | β |
MEGA | β | β | β |
Megatron-BERT | β | β | β |
Megatron-GPT2 | β | β | β |
MGP-STR | β | β | β |
Mimi | β | β | β |
Mistral | β | β | β |
Mixtral | β | β | β |
Mllama | β | β | β |
mLUKE | β | β | β |
MMS | β | β | β |
MobileBERT | β | β | β |
MobileNetV1 | β | β | β |
MobileNetV2 | β | β | β |
MobileViT | β | β | β |
MobileViTV2 | β | β | β |
Moshi | β | β | β |
MPNet | β | β | β |
MPT | β | β | β |
MRA | β | β | β |
MT5 | β | β | β |
MusicGen | β | β | β |
MusicGen Melody | β | β | β |
MVP | β | β | β |
NAT | β | β | β |
Nemotron | β | β | β |
Nezha | β | β | β |
NLLB | β | β | β |
NLLB-MOE | β | β | β |
Nougat | β | β | β |
NystrΓΆmformer | β | β | β |
OLMo | β | β | β |
OLMo November 2024 | β | β | β |
OLMoE | β | β | β |
OmDet-Turbo | β | β | β |
OneFormer | β | β | β |
OpenAI GPT | β | β | β |
OpenAI GPT-2 | β | β | β |
OpenLlama | β | β | β |
OPT | β | β | β |
OWL-ViT | β | β | β |
OWLv2 | β | β | β |
PaliGemma | β | β | β |
PatchTSMixer | β | β | β |
PatchTST | β | β | β |
Pegasus | β | β | β |
PEGASUS-X | β | β | β |
Perceiver | β | β | β |
Persimmon | β | β | β |
Phi | β | β | β |
Phi3 | β | β | β |
Phimoe | β | β | β |
PhoBERT | β | β | β |
Pix2Struct | β | β | β |
Pixtral | β | β | β |
PLBart | β | β | β |
PoolFormer | β | β | β |
Pop2Piano | β | β | β |
ProphetNet | β | β | β |
PVT | β | β | β |
PVTv2 | β | β | β |
QDQBert | β | β | β |
Qwen2 | β | β | β |
Qwen2Audio | β | β | β |
Qwen2MoE | β | β | β |
Qwen2VL | β | β | β |
RAG | β | β | β |
REALM | β | β | β |
RecurrentGemma | β | β | β |
Reformer | β | β | β |
RegNet | β | β | β |
RemBERT | β | β | β |
ResNet | β | β | β |
RetriBERT | β | β | β |
RoBERTa | β | β | β |
RoBERTa-PreLayerNorm | β | β | β |
RoCBert | β | β | β |
RoFormer | β | β | β |
RT-DETR | β | β | β |
RT-DETR-ResNet | β | β | β |
RWKV | β | β | β |
SAM | β | β | β |
SeamlessM4T | β | β | β |
SeamlessM4Tv2 | β | β | β |
SegFormer | β | β | β |
SegGPT | β | β | β |
SEW | β | β | β |
SEW-D | β | β | β |
SigLIP | β | β | β |
Speech Encoder decoder | β | β | β |
Speech2Text | β | β | β |
SpeechT5 | β | β | β |
Splinter | β | β | β |
SqueezeBERT | β | β | β |
StableLm | β | β | β |
Starcoder2 | β | β | β |
SuperPoint | β | β | β |
SwiftFormer | β | β | β |
Swin Transformer | β | β | β |
Swin Transformer V2 | β | β | β |
Swin2SR | β | β | β |
SwitchTransformers | β | β | β |
T5 | β | β | β |
T5v1.1 | β | β | β |
Table Transformer | β | β | β |
TAPAS | β | β | β |
TAPEX | β | β | β |
Time Series Transformer | β | β | β |
TimeSformer | β | β | β |
Trajectory Transformer | β | β | β |
Transformer-XL | β | β | β |
TrOCR | β | β | β |
TVLT | β | β | β |
TVP | β | β | β |
UDOP | β | β | β |
UL2 | β | β | β |
UMT5 | β | β | β |
UniSpeech | β | β | β |
UniSpeechSat | β | β | β |
UnivNet | β | β | β |
UPerNet | β | β | β |
VAN | β | β | β |
VideoLlava | β | β | β |
VideoMAE | β | β | β |
ViLT | β | β | β |
VipLlava | β | β | β |
Vision Encoder decoder | β | β | β |
VisionTextDualEncoder | β | β | β |
VisualBERT | β | β | β |
ViT | β | β | β |
ViT Hybrid | β | β | β |
VitDet | β | β | β |
ViTMAE | β | β | β |
ViTMatte | β | β | β |
ViTMSN | β | β | β |
VITS | β | β | β |
ViViT | β | β | β |
Wav2Vec2 | β | β | β |
Wav2Vec2-BERT | β | β | β |
Wav2Vec2-Conformer | β | β | β |
Wav2Vec2Phoneme | β | β | β |
WavLM | β | β | β |
Whisper | β | β | β |
X-CLIP | β | β | β |
X-MOD | β | β | β |
XGLM | β | β | β |
XLM | β | β | β |
XLM-ProphetNet | β | β | β |
XLM-RoBERTa | β | β | β |
XLM-RoBERTa-XL | β | β | β |
XLM-V | β | β | β |
XLNet | β | β | β |
XLS-R | β | β | β |
XLSR-Wav2Vec2 | β | β | β |
YOLOS | β | β | β |
YOSO | β | β | β |
Zamba | β | β | β |
ZoeDepth | β | β | β |