File size: 41,453 Bytes
9382e3f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
<!--Copyright 2020 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
β οΈ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->
# π€ Transformers
State-of-the-art Machine Learning for [PyTorch](https://pytorch.org/), [TensorFlow](https://www.tensorflow.org/), and [JAX](https://jax.readthedocs.io/en/latest/).
π€ 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, summarization, translation, multiple choice, and text generation.<br>
πΌοΈ **Computer Vision**: image classification, object detection, and segmentation.<br>
π£οΈ **Audio**: automatic speech recognition and audio classification.<br>
π **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](https://huggingface.co/models), [forum](https://discuss.huggingface.co/), or [Discord](https://discord.com/invite/JfAtkvEtRb) today!
## If you are looking for custom support from the Hugging Face team
<a target="_blank" href="https://huggingface.co/support">
<img alt="HuggingFace Expert Acceleration Program" src="https://cdn-media.huggingface.co/marketing/transformers/new-support-improved.png" style="width: 100%; max-width: 600px; border: 1px solid #eee; border-radius: 4px; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);">
</a>
## 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.
<!--This table is updated automatically from the auto modules with _make fix-copies_. Do not update manually!-->
| Model | PyTorch support | TensorFlow support | Flax Support |
|:------------------------------------------------------------------------:|:---------------:|:------------------:|:------------:|
| [ALBERT](model_doc/albert) | β
| β
| β
|
| [ALIGN](model_doc/align) | β
| β | β |
| [AltCLIP](model_doc/altclip) | β
| β | β |
| [Audio Spectrogram Transformer](model_doc/audio-spectrogram-transformer) | β
| β | β |
| [Autoformer](model_doc/autoformer) | β
| β | β |
| [Bark](model_doc/bark) | β
| β | β |
| [BART](model_doc/bart) | β
| β
| β
|
| [BARThez](model_doc/barthez) | β
| β
| β
|
| [BARTpho](model_doc/bartpho) | β
| β
| β
|
| [BEiT](model_doc/beit) | β
| β | β
|
| [BERT](model_doc/bert) | β
| β
| β
|
| [Bert Generation](model_doc/bert-generation) | β
| β | β |
| [BertJapanese](model_doc/bert-japanese) | β
| β
| β
|
| [BERTweet](model_doc/bertweet) | β
| β
| β
|
| [BigBird](model_doc/big_bird) | β
| β | β
|
| [BigBird-Pegasus](model_doc/bigbird_pegasus) | β
| β | β |
| [BioGpt](model_doc/biogpt) | β
| β | β |
| [BiT](model_doc/bit) | β
| β | β |
| [Blenderbot](model_doc/blenderbot) | β
| β
| β
|
| [BlenderbotSmall](model_doc/blenderbot-small) | β
| β
| β
|
| [BLIP](model_doc/blip) | β
| β
| β |
| [BLIP-2](model_doc/blip-2) | β
| β | β |
| [BLOOM](model_doc/bloom) | β
| β | β
|
| [BORT](model_doc/bort) | β
| β
| β
|
| [BridgeTower](model_doc/bridgetower) | β
| β | β |
| [BROS](model_doc/bros) | β
| β | β |
| [ByT5](model_doc/byt5) | β
| β
| β
|
| [CamemBERT](model_doc/camembert) | β
| β
| β |
| [CANINE](model_doc/canine) | β
| β | β |
| [Chinese-CLIP](model_doc/chinese_clip) | β
| β | β |
| [CLAP](model_doc/clap) | β
| β | β |
| [CLIP](model_doc/clip) | β
| β
| β
|
| [CLIPSeg](model_doc/clipseg) | β
| β | β |
| [CLVP](model_doc/clvp) | β
| β | β |
| [CodeGen](model_doc/codegen) | β
| β | β |
| [CodeLlama](model_doc/code_llama) | β
| β | β
|
| [Cohere](model_doc/cohere) | β
| β | β |
| [Conditional DETR](model_doc/conditional_detr) | β
| β | β |
| [ConvBERT](model_doc/convbert) | β
| β
| β |
| [ConvNeXT](model_doc/convnext) | β
| β
| β |
| [ConvNeXTV2](model_doc/convnextv2) | β
| β
| β |
| [CPM](model_doc/cpm) | β
| β
| β
|
| [CPM-Ant](model_doc/cpmant) | β
| β | β |
| [CTRL](model_doc/ctrl) | β
| β
| β |
| [CvT](model_doc/cvt) | β
| β
| β |
| [Data2VecAudio](model_doc/data2vec) | β
| β | β |
| [Data2VecText](model_doc/data2vec) | β
| β | β |
| [Data2VecVision](model_doc/data2vec) | β
| β
| β |
| [DBRX](model_doc/dbrx) | β
| β | β |
| [DeBERTa](model_doc/deberta) | β
| β
| β |
| [DeBERTa-v2](model_doc/deberta-v2) | β
| β
| β |
| [Decision Transformer](model_doc/decision_transformer) | β
| β | β |
| [Deformable DETR](model_doc/deformable_detr) | β
| β | β |
| [DeiT](model_doc/deit) | β
| β
| β |
| [DePlot](model_doc/deplot) | β
| β | β |
| [Depth Anything](model_doc/depth_anything) | β
| β | β |
| [DETA](model_doc/deta) | β
| β | β |
| [DETR](model_doc/detr) | β
| β | β |
| [DialoGPT](model_doc/dialogpt) | β
| β
| β
|
| [DiNAT](model_doc/dinat) | β
| β | β |
| [DINOv2](model_doc/dinov2) | β
| β | β |
| [DistilBERT](model_doc/distilbert) | β
| β
| β
|
| [DiT](model_doc/dit) | β
| β | β
|
| [DonutSwin](model_doc/donut) | β
| β | β |
| [DPR](model_doc/dpr) | β
| β
| β |
| [DPT](model_doc/dpt) | β
| β | β |
| [EfficientFormer](model_doc/efficientformer) | β
| β
| β |
| [EfficientNet](model_doc/efficientnet) | β
| β | β |
| [ELECTRA](model_doc/electra) | β
| β
| β
|
| [EnCodec](model_doc/encodec) | β
| β | β |
| [Encoder decoder](model_doc/encoder-decoder) | β
| β
| β
|
| [ERNIE](model_doc/ernie) | β
| β | β |
| [ErnieM](model_doc/ernie_m) | β
| β | β |
| [ESM](model_doc/esm) | β
| β
| β |
| [FairSeq Machine-Translation](model_doc/fsmt) | β
| β | β |
| [Falcon](model_doc/falcon) | β
| β | β |
| [FastSpeech2Conformer](model_doc/fastspeech2_conformer) | β
| β | β |
| [FLAN-T5](model_doc/flan-t5) | β
| β
| β
|
| [FLAN-UL2](model_doc/flan-ul2) | β
| β
| β
|
| [FlauBERT](model_doc/flaubert) | β
| β
| β |
| [FLAVA](model_doc/flava) | β
| β | β |
| [FNet](model_doc/fnet) | β
| β | β |
| [FocalNet](model_doc/focalnet) | β
| β | β |
| [Funnel Transformer](model_doc/funnel) | β
| β
| β |
| [Fuyu](model_doc/fuyu) | β
| β | β |
| [Gemma](model_doc/gemma) | β
| β | β
|
| [GIT](model_doc/git) | β
| β | β |
| [GLPN](model_doc/glpn) | β
| β | β |
| [GPT Neo](model_doc/gpt_neo) | β
| β | β
|
| [GPT NeoX](model_doc/gpt_neox) | β
| β | β |
| [GPT NeoX Japanese](model_doc/gpt_neox_japanese) | β
| β | β |
| [GPT-J](model_doc/gptj) | β
| β
| β
|
| [GPT-Sw3](model_doc/gpt-sw3) | β
| β
| β
|
| [GPTBigCode](model_doc/gpt_bigcode) | β
| β | β |
| [GPTSAN-japanese](model_doc/gptsan-japanese) | β
| β | β |
| [Graphormer](model_doc/graphormer) | β
| β | β |
| [Grounding DINO](model_doc/grounding-dino) | β
| β | β |
| [GroupViT](model_doc/groupvit) | β
| β
| β |
| [HerBERT](model_doc/herbert) | β
| β
| β
|
| [Hubert](model_doc/hubert) | β
| β
| β |
| [I-BERT](model_doc/ibert) | β
| β | β |
| [IDEFICS](model_doc/idefics) | β
| β | β |
| [Idefics2](model_doc/idefics2) | β
| β | β |
| [ImageGPT](model_doc/imagegpt) | β
| β | β |
| [Informer](model_doc/informer) | β
| β | β |
| [InstructBLIP](model_doc/instructblip) | β
| β | β |
| [Jamba](model_doc/jamba) | β
| β | β |
| [Jukebox](model_doc/jukebox) | β
| β | β |
| [KOSMOS-2](model_doc/kosmos-2) | β
| β | β |
| [LayoutLM](model_doc/layoutlm) | β
| β
| β |
| [LayoutLMv2](model_doc/layoutlmv2) | β
| β | β |
| [LayoutLMv3](model_doc/layoutlmv3) | β
| β
| β |
| [LayoutXLM](model_doc/layoutxlm) | β
| β | β |
| [LED](model_doc/led) | β
| β
| β |
| [LeViT](model_doc/levit) | β
| β | β |
| [LiLT](model_doc/lilt) | β
| β | β |
| [LLaMA](model_doc/llama) | β
| β | β
|
| [Llama2](model_doc/llama2) | β
| β | β
|
| [Llama3](model_doc/llama3) | β
| β | β
|
| [LLaVa](model_doc/llava) | β
| β | β |
| [LLaVA-NeXT](model_doc/llava_next) | β
| β | β |
| [Longformer](model_doc/longformer) | β
| β
| β |
| [LongT5](model_doc/longt5) | β
| β | β
|
| [LUKE](model_doc/luke) | β
| β | β |
| [LXMERT](model_doc/lxmert) | β
| β
| β |
| [M-CTC-T](model_doc/mctct) | β
| β | β |
| [M2M100](model_doc/m2m_100) | β
| β | β |
| [MADLAD-400](model_doc/madlad-400) | β
| β
| β
|
| [Mamba](model_doc/mamba) | β
| β | β |
| [Marian](model_doc/marian) | β
| β
| β
|
| [MarkupLM](model_doc/markuplm) | β
| β | β |
| [Mask2Former](model_doc/mask2former) | β
| β | β |
| [MaskFormer](model_doc/maskformer) | β
| β | β |
| [MatCha](model_doc/matcha) | β
| β | β |
| [mBART](model_doc/mbart) | β
| β
| β
|
| [mBART-50](model_doc/mbart50) | β
| β
| β
|
| [MEGA](model_doc/mega) | β
| β | β |
| [Megatron-BERT](model_doc/megatron-bert) | β
| β | β |
| [Megatron-GPT2](model_doc/megatron_gpt2) | β
| β
| β
|
| [MGP-STR](model_doc/mgp-str) | β
| β | β |
| [Mistral](model_doc/mistral) | β
| β | β
|
| [Mixtral](model_doc/mixtral) | β
| β | β |
| [mLUKE](model_doc/mluke) | β
| β | β |
| [MMS](model_doc/mms) | β
| β
| β
|
| [MobileBERT](model_doc/mobilebert) | β
| β
| β |
| [MobileNetV1](model_doc/mobilenet_v1) | β
| β | β |
| [MobileNetV2](model_doc/mobilenet_v2) | β
| β | β |
| [MobileViT](model_doc/mobilevit) | β
| β
| β |
| [MobileViTV2](model_doc/mobilevitv2) | β
| β | β |
| [MPNet](model_doc/mpnet) | β
| β
| β |
| [MPT](model_doc/mpt) | β
| β | β |
| [MRA](model_doc/mra) | β
| β | β |
| [MT5](model_doc/mt5) | β
| β
| β
|
| [MusicGen](model_doc/musicgen) | β
| β | β |
| [MusicGen Melody](model_doc/musicgen_melody) | β
| β | β |
| [MVP](model_doc/mvp) | β
| β | β |
| [NAT](model_doc/nat) | β
| β | β |
| [Nezha](model_doc/nezha) | β
| β | β |
| [NLLB](model_doc/nllb) | β
| β | β |
| [NLLB-MOE](model_doc/nllb-moe) | β
| β | β |
| [Nougat](model_doc/nougat) | β
| β
| β
|
| [NystrΓΆmformer](model_doc/nystromformer) | β
| β | β |
| [OLMo](model_doc/olmo) | β
| β | β |
| [OneFormer](model_doc/oneformer) | β
| β | β |
| [OpenAI GPT](model_doc/openai-gpt) | β
| β
| β |
| [OpenAI GPT-2](model_doc/gpt2) | β
| β
| β
|
| [OpenLlama](model_doc/open-llama) | β
| β | β |
| [OPT](model_doc/opt) | β
| β
| β
|
| [OWL-ViT](model_doc/owlvit) | β
| β | β |
| [OWLv2](model_doc/owlv2) | β
| β | β |
| [PatchTSMixer](model_doc/patchtsmixer) | β
| β | β |
| [PatchTST](model_doc/patchtst) | β
| β | β |
| [Pegasus](model_doc/pegasus) | β
| β
| β
|
| [PEGASUS-X](model_doc/pegasus_x) | β
| β | β |
| [Perceiver](model_doc/perceiver) | β
| β | β |
| [Persimmon](model_doc/persimmon) | β
| β | β |
| [Phi](model_doc/phi) | β
| β | β |
| [Phi3](model_doc/phi3) | β
| β | β |
| [PhoBERT](model_doc/phobert) | β
| β
| β
|
| [Pix2Struct](model_doc/pix2struct) | β
| β | β |
| [PLBart](model_doc/plbart) | β
| β | β |
| [PoolFormer](model_doc/poolformer) | β
| β | β |
| [Pop2Piano](model_doc/pop2piano) | β
| β | β |
| [ProphetNet](model_doc/prophetnet) | β
| β | β |
| [PVT](model_doc/pvt) | β
| β | β |
| [PVTv2](model_doc/pvt_v2) | β
| β | β |
| [QDQBert](model_doc/qdqbert) | β
| β | β |
| [Qwen2](model_doc/qwen2) | β
| β | β |
| [Qwen2MoE](model_doc/qwen2_moe) | β
| β | β |
| [RAG](model_doc/rag) | β
| β
| β |
| [REALM](model_doc/realm) | β
| β | β |
| [RecurrentGemma](model_doc/recurrent_gemma) | β
| β | β |
| [Reformer](model_doc/reformer) | β
| β | β |
| [RegNet](model_doc/regnet) | β
| β
| β
|
| [RemBERT](model_doc/rembert) | β
| β
| β |
| [ResNet](model_doc/resnet) | β
| β
| β
|
| [RetriBERT](model_doc/retribert) | β
| β | β |
| [RoBERTa](model_doc/roberta) | β
| β
| β
|
| [RoBERTa-PreLayerNorm](model_doc/roberta-prelayernorm) | β
| β
| β
|
| [RoCBert](model_doc/roc_bert) | β
| β | β |
| [RoFormer](model_doc/roformer) | β
| β
| β
|
| [RWKV](model_doc/rwkv) | β
| β | β |
| [SAM](model_doc/sam) | β
| β
| β |
| [SeamlessM4T](model_doc/seamless_m4t) | β
| β | β |
| [SeamlessM4Tv2](model_doc/seamless_m4t_v2) | β
| β | β |
| [SegFormer](model_doc/segformer) | β
| β
| β |
| [SegGPT](model_doc/seggpt) | β
| β | β |
| [SEW](model_doc/sew) | β
| β | β |
| [SEW-D](model_doc/sew-d) | β
| β | β |
| [SigLIP](model_doc/siglip) | β
| β | β |
| [Speech Encoder decoder](model_doc/speech-encoder-decoder) | β
| β | β
|
| [Speech2Text](model_doc/speech_to_text) | β
| β
| β |
| [SpeechT5](model_doc/speecht5) | β
| β | β |
| [Splinter](model_doc/splinter) | β
| β | β |
| [SqueezeBERT](model_doc/squeezebert) | β
| β | β |
| [StableLm](model_doc/stablelm) | β
| β | β |
| [Starcoder2](model_doc/starcoder2) | β
| β | β |
| [SuperPoint](model_doc/superpoint) | β
| β | β |
| [SwiftFormer](model_doc/swiftformer) | β
| β
| β |
| [Swin Transformer](model_doc/swin) | β
| β
| β |
| [Swin Transformer V2](model_doc/swinv2) | β
| β | β |
| [Swin2SR](model_doc/swin2sr) | β
| β | β |
| [SwitchTransformers](model_doc/switch_transformers) | β
| β | β |
| [T5](model_doc/t5) | β
| β
| β
|
| [T5v1.1](model_doc/t5v1.1) | β
| β
| β
|
| [Table Transformer](model_doc/table-transformer) | β
| β | β |
| [TAPAS](model_doc/tapas) | β
| β
| β |
| [TAPEX](model_doc/tapex) | β
| β
| β
|
| [Time Series Transformer](model_doc/time_series_transformer) | β
| β | β |
| [TimeSformer](model_doc/timesformer) | β
| β | β |
| [Trajectory Transformer](model_doc/trajectory_transformer) | β
| β | β |
| [Transformer-XL](model_doc/transfo-xl) | β
| β
| β |
| [TrOCR](model_doc/trocr) | β
| β | β |
| [TVLT](model_doc/tvlt) | β
| β | β |
| [TVP](model_doc/tvp) | β
| β | β |
| [UDOP](model_doc/udop) | β
| β | β |
| [UL2](model_doc/ul2) | β
| β
| β
|
| [UMT5](model_doc/umt5) | β
| β | β |
| [UniSpeech](model_doc/unispeech) | β
| β | β |
| [UniSpeechSat](model_doc/unispeech-sat) | β
| β | β |
| [UnivNet](model_doc/univnet) | β
| β | β |
| [UPerNet](model_doc/upernet) | β
| β | β |
| [VAN](model_doc/van) | β
| β | β |
| [VideoMAE](model_doc/videomae) | β
| β | β |
| [ViLT](model_doc/vilt) | β
| β | β |
| [VipLlava](model_doc/vipllava) | β
| β | β |
| [Vision Encoder decoder](model_doc/vision-encoder-decoder) | β
| β
| β
|
| [VisionTextDualEncoder](model_doc/vision-text-dual-encoder) | β
| β
| β
|
| [VisualBERT](model_doc/visual_bert) | β
| β | β |
| [ViT](model_doc/vit) | β
| β
| β
|
| [ViT Hybrid](model_doc/vit_hybrid) | β
| β | β |
| [VitDet](model_doc/vitdet) | β
| β | β |
| [ViTMAE](model_doc/vit_mae) | β
| β
| β |
| [ViTMatte](model_doc/vitmatte) | β
| β | β |
| [ViTMSN](model_doc/vit_msn) | β
| β | β |
| [VITS](model_doc/vits) | β
| β | β |
| [ViViT](model_doc/vivit) | β
| β | β |
| [Wav2Vec2](model_doc/wav2vec2) | β
| β
| β
|
| [Wav2Vec2-BERT](model_doc/wav2vec2-bert) | β
| β | β |
| [Wav2Vec2-Conformer](model_doc/wav2vec2-conformer) | β
| β | β |
| [Wav2Vec2Phoneme](model_doc/wav2vec2_phoneme) | β
| β
| β
|
| [WavLM](model_doc/wavlm) | β
| β | β |
| [Whisper](model_doc/whisper) | β
| β
| β
|
| [X-CLIP](model_doc/xclip) | β
| β | β |
| [X-MOD](model_doc/xmod) | β
| β | β |
| [XGLM](model_doc/xglm) | β
| β
| β
|
| [XLM](model_doc/xlm) | β
| β
| β |
| [XLM-ProphetNet](model_doc/xlm-prophetnet) | β
| β | β |
| [XLM-RoBERTa](model_doc/xlm-roberta) | β
| β
| β
|
| [XLM-RoBERTa-XL](model_doc/xlm-roberta-xl) | β
| β | β |
| [XLM-V](model_doc/xlm-v) | β
| β
| β
|
| [XLNet](model_doc/xlnet) | β
| β
| β |
| [XLS-R](model_doc/xls_r) | β
| β
| β
|
| [XLSR-Wav2Vec2](model_doc/xlsr_wav2vec2) | β
| β
| β
|
| [YOLOS](model_doc/yolos) | β
| β | β |
| [YOSO](model_doc/yoso) | β
| β | β |
<!-- End table-->
|