# TFAutoModel

#### class transformers.TFAutoModel

[\<source>](https://github.com/huggingface/transformers/blob/v4.34.1/src/transformers/models/auto/modeling_tf_auto.py#L529)

( \*args\*\*kwargs )

This is a generic model class that will be instantiated as one of the base model classes of the library when created with the [from\_pretrained()](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained) class method or the [from\_config()](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_config) class method.

This class cannot be instantiated directly using `__init__()` (throws an error).

**from\_config**

[\<source>](https://github.com/huggingface/transformers/blob/v4.34.1/src/transformers/models/auto/auto_factory.py#L417)

( \*\*kwargs )

Parameters

* **config** ([PretrainedConfig](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/configuration#transformers.PretrainedConfig)) — The model class to instantiate is selected based on the configuration class:
  * [AlbertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/albert#transformers.AlbertConfig) configuration class: [TFAlbertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/albert#transformers.TFAlbertModel) (ALBERT model)
  * [BartConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bart#transformers.BartConfig) configuration class: [TFBartModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bart#transformers.TFBartModel) (BART model)
  * [BertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bert#transformers.BertConfig) configuration class: [TFBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bert#transformers.TFBertModel) (BERT model)
  * [BlenderbotConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blenderbot#transformers.BlenderbotConfig) configuration class: [TFBlenderbotModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blenderbot#transformers.TFBlenderbotModel) (Blenderbot model)
  * [BlenderbotSmallConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blenderbot-small#transformers.BlenderbotSmallConfig) configuration class: [TFBlenderbotSmallModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blenderbot-small#transformers.TFBlenderbotSmallModel) (BlenderbotSmall model)
  * [BlipConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blip#transformers.BlipConfig) configuration class: [TFBlipModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blip#transformers.TFBlipModel) (BLIP model)
  * [CLIPConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/clip#transformers.CLIPConfig) configuration class: [TFCLIPModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/clip#transformers.TFCLIPModel) (CLIP model)
  * [CTRLConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/ctrl#transformers.CTRLConfig) configuration class: [TFCTRLModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/ctrl#transformers.TFCTRLModel) (CTRL model)
  * [CamembertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/camembert#transformers.CamembertConfig) configuration class: [TFCamembertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/camembert#transformers.TFCamembertModel) (CamemBERT model)
  * [ConvBertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convbert#transformers.ConvBertConfig) configuration class: [TFConvBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convbert#transformers.TFConvBertModel) (ConvBERT model)
  * [ConvNextConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.ConvNextConfig) configuration class: [TFConvNextModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.TFConvNextModel) (ConvNeXT model)
  * [CvtConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/cvt#transformers.CvtConfig) configuration class: [TFCvtModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/cvt#transformers.TFCvtModel) (CvT model)
  * [DPRConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/dpr#transformers.DPRConfig) configuration class: [TFDPRQuestionEncoder](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/dpr#transformers.TFDPRQuestionEncoder) (DPR model)
  * [Data2VecVisionConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/data2vec#transformers.Data2VecVisionConfig) configuration class: [TFData2VecVisionModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/data2vec#transformers.TFData2VecVisionModel) (Data2VecVision model)
  * [DebertaConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deberta#transformers.DebertaConfig) configuration class: [TFDebertaModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deberta#transformers.TFDebertaModel) (DeBERTa model)
  * [DebertaV2Config](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deberta-v2#transformers.DebertaV2Config) configuration class: [TFDebertaV2Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deberta-v2#transformers.TFDebertaV2Model) (DeBERTa-v2 model)
  * [DeiTConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deit#transformers.DeiTConfig) configuration class: [TFDeiTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deit#transformers.TFDeiTModel) (DeiT model)
  * [DistilBertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/distilbert#transformers.DistilBertConfig) configuration class: [TFDistilBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/distilbert#transformers.TFDistilBertModel) (DistilBERT model)
  * [EfficientFormerConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/efficientformer#transformers.EfficientFormerConfig) configuration class: [TFEfficientFormerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/efficientformer#transformers.TFEfficientFormerModel) (EfficientFormer model)
  * [ElectraConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/electra#transformers.ElectraConfig) configuration class: [TFElectraModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/electra#transformers.TFElectraModel) (ELECTRA model)
  * [EsmConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/esm#transformers.EsmConfig) configuration class: [TFEsmModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/esm#transformers.TFEsmModel) (ESM model)
  * [FlaubertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/flaubert#transformers.FlaubertConfig) configuration class: [TFFlaubertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/flaubert#transformers.TFFlaubertModel) (FlauBERT model)
  * [FunnelConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/funnel#transformers.FunnelConfig) configuration class: [TFFunnelModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/funnel#transformers.TFFunnelModel) or [TFFunnelBaseModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/funnel#transformers.TFFunnelBaseModel) (Funnel Transformer model)
  * [GPT2Config](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/gpt2#transformers.GPT2Config) configuration class: [TFGPT2Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/gpt2#transformers.TFGPT2Model) (OpenAI GPT-2 model)
  * [GPTJConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/gptj#transformers.GPTJConfig) configuration class: [TFGPTJModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/gptj#transformers.TFGPTJModel) (GPT-J model)
  * [GroupViTConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/groupvit#transformers.GroupViTConfig) configuration class: [TFGroupViTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/groupvit#transformers.TFGroupViTModel) (GroupViT model)
  * [HubertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/hubert#transformers.HubertConfig) configuration class: [TFHubertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/hubert#transformers.TFHubertModel) (Hubert model)
  * [LEDConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/led#transformers.LEDConfig) configuration class: [TFLEDModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/led#transformers.TFLEDModel) (LED model)
  * [LayoutLMConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlm#transformers.LayoutLMConfig) configuration class: [TFLayoutLMModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlm#transformers.TFLayoutLMModel) (LayoutLM model)
  * [LayoutLMv3Config](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlmv3#transformers.LayoutLMv3Config) configuration class: [TFLayoutLMv3Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlmv3#transformers.TFLayoutLMv3Model) (LayoutLMv3 model)
  * [LongformerConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/longformer#transformers.LongformerConfig) configuration class: [TFLongformerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/longformer#transformers.TFLongformerModel) (Longformer model)
  * [LxmertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/lxmert#transformers.LxmertConfig) configuration class: [TFLxmertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/lxmert#transformers.TFLxmertModel) (LXMERT model)
  * [MBartConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mbart#transformers.MBartConfig) configuration class: [TFMBartModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mbart#transformers.TFMBartModel) (mBART model)
  * [MPNetConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mpnet#transformers.MPNetConfig) configuration class: [TFMPNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mpnet#transformers.TFMPNetModel) (MPNet model)
  * [MT5Config](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mt5#transformers.MT5Config) configuration class: [TFMT5Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mt5#transformers.TFMT5Model) (MT5 model)
  * [MarianConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/marian#transformers.MarianConfig) configuration class: [TFMarianModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/marian#transformers.TFMarianModel) (Marian model)
  * [MobileBertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilebert#transformers.MobileBertConfig) configuration class: [TFMobileBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilebert#transformers.TFMobileBertModel) (MobileBERT model)
  * [MobileViTConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilevit#transformers.MobileViTConfig) configuration class: [TFMobileViTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilevit#transformers.TFMobileViTModel) (MobileViT model)
  * [OPTConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/opt#transformers.OPTConfig) configuration class: [TFOPTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/opt#transformers.TFOPTModel) (OPT model)
  * [OpenAIGPTConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/openai-gpt#transformers.OpenAIGPTConfig) configuration class: [TFOpenAIGPTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/openai-gpt#transformers.TFOpenAIGPTModel) (OpenAI GPT model)
  * [PegasusConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/pegasus#transformers.PegasusConfig) configuration class: [TFPegasusModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/pegasus#transformers.TFPegasusModel) (Pegasus model)
  * [RegNetConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/regnet#transformers.RegNetConfig) configuration class: [TFRegNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/regnet#transformers.TFRegNetModel) (RegNet model)
  * [RemBertConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/rembert#transformers.RemBertConfig) configuration class: [TFRemBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/rembert#transformers.TFRemBertModel) (RemBERT model)
  * [ResNetConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/resnet#transformers.ResNetConfig) configuration class: [TFResNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/resnet#transformers.TFResNetModel) (ResNet model)
  * [RoFormerConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roformer#transformers.RoFormerConfig) configuration class: [TFRoFormerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roformer#transformers.TFRoFormerModel) (RoFormer model)
  * [RobertaConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roberta#transformers.RobertaConfig) configuration class: [TFRobertaModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roberta#transformers.TFRobertaModel) (RoBERTa model)
  * [RobertaPreLayerNormConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roberta-prelayernorm#transformers.RobertaPreLayerNormConfig) configuration class: [TFRobertaPreLayerNormModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roberta-prelayernorm#transformers.TFRobertaPreLayerNormModel) (RoBERTa-PreLayerNorm model)
  * [SamConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/sam#transformers.SamConfig) configuration class: [TFSamModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/sam#transformers.TFSamModel) (SAM model)
  * [SegformerConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/segformer#transformers.SegformerConfig) configuration class: [TFSegformerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/segformer#transformers.TFSegformerModel) (SegFormer model)
  * [Speech2TextConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/speech_to_text#transformers.Speech2TextConfig) configuration class: [TFSpeech2TextModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/speech_to_text#transformers.TFSpeech2TextModel) (Speech2Text model)
  * [SwinConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/swin#transformers.SwinConfig) configuration class: [TFSwinModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/swin#transformers.TFSwinModel) (Swin Transformer model)
  * [T5Config](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/t5#transformers.T5Config) configuration class: [TFT5Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/t5#transformers.TFT5Model) (T5 model)
  * [TapasConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/tapas#transformers.TapasConfig) configuration class: [TFTapasModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/tapas#transformers.TFTapasModel) (TAPAS model)
  * [TransfoXLConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/transfo-xl#transformers.TransfoXLConfig) configuration class: [TFTransfoXLModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/transfo-xl#transformers.TFTransfoXLModel) (Transformer-XL model)
  * [ViTConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTConfig) configuration class: [TFViTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.TFViTModel) (ViT model)
  * [ViTMAEConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit_mae#transformers.ViTMAEConfig) configuration class: [TFViTMAEModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit_mae#transformers.TFViTMAEModel) (ViTMAE model)
  * [VisionTextDualEncoderConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vision-text-dual-encoder#transformers.VisionTextDualEncoderConfig) configuration class: [TFVisionTextDualEncoderModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vision-text-dual-encoder#transformers.TFVisionTextDualEncoderModel) (VisionTextDualEncoder model)
  * [Wav2Vec2Config](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/wav2vec2#transformers.Wav2Vec2Config) configuration class: [TFWav2Vec2Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/wav2vec2#transformers.TFWav2Vec2Model) (Wav2Vec2 model)
  * [WhisperConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/whisper#transformers.WhisperConfig) configuration class: [TFWhisperModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/whisper#transformers.TFWhisperModel) (Whisper model)
  * [XGLMConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xglm#transformers.XGLMConfig) configuration class: [TFXGLMModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xglm#transformers.TFXGLMModel) (XGLM model)
  * [XLMConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlm#transformers.XLMConfig) configuration class: [TFXLMModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlm#transformers.TFXLMModel) (XLM model)
  * [XLMRobertaConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlm-roberta#transformers.XLMRobertaConfig) configuration class: [TFXLMRobertaModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlm-roberta#transformers.TFXLMRobertaModel) (XLM-RoBERTa model)
  * [XLNetConfig](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlnet#transformers.XLNetConfig) configuration class: [TFXLNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlnet#transformers.TFXLNetModel) (XLNet model)

Instantiates one of the base model classes of the library from a configuration.

Note: Loading a model from its configuration file does **not** load the model weights. It only affects the model’s configuration. Use [from\_pretrained()](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained) to load the model weights.



Examples:

Copied

```
>>> from transformers import AutoConfig, TFAutoModel

>>> # Download configuration from huggingface.co and cache.
>>> config = AutoConfig.from_pretrained("bert-base-cased")
>>> model = TFAutoModel.from_config(config)
```

**from\_pretrained**

[\<source>](https://github.com/huggingface/transformers/blob/v4.34.1/src/transformers/models/auto/auto_factory.py#L448)

( \*model\_args\*\*kwargs )

Parameters

* **pretrained\_model\_name\_or\_path** (`str` or `os.PathLike`) — Can be either:
  * A string, the _model id_ of a pretrained model hosted inside a model repo on huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`.
  * A path to a _directory_ containing model weights saved using [save\_pretrained()](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/model#transformers.PreTrainedModel.save_pretrained), e.g., `./my_model_directory/`.
  * A path or url to a _PyTorch state\_dict save file_ (e.g, `./pt_model/pytorch_model.bin`). In this case, `from_pt` should be set to `True` and a configuration object should be provided as `config` argument. This loading path is slower than converting the PyTorch model in a TensorFlow model using the provided conversion scripts and loading the TensorFlow model afterwards.
* **model\_args** (additional positional arguments, _optional_) — Will be passed along to the underlying model `__init__()` method.
* **config** ([PretrainedConfig](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/configuration#transformers.PretrainedConfig), _optional_) — Configuration for the model to use instead of an automatically loaded configuration. Configuration can be automatically loaded when:
  * The model is a model provided by the library (loaded with the _model id_ string of a pretrained model).
  * The model was saved using [save\_pretrained()](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/model#transformers.PreTrainedModel.save_pretrained) and is reloaded by supplying the save directory.
  * The model is loaded by supplying a local directory as `pretrained_model_name_or_path` and a configuration JSON file named _config.json_ is found in the directory.
* **cache\_dir** (`str` or `os.PathLike`, _optional_) — Path to a directory in which a downloaded pretrained model configuration should be cached if the standard cache should not be used.
* **from\_pt** (`bool`, _optional_, defaults to `False`) — Load the model weights from a PyTorch checkpoint save file (see docstring of `pretrained_model_name_or_path` argument).
* **force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist.
* **resume\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to delete incompletely received files. Will attempt to resume the download if such a file exists.
* **proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
* **output\_loading\_info(`bool`,** _optional_, defaults to `False`) — Whether ot not to also return a dictionary containing missing keys, unexpected keys and error messages.
* **local\_files\_only(`bool`,** _optional_, defaults to `False`) — Whether or not to only look at local files (e.g., not try downloading the model).
* **revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git.
* **trust\_remote\_code** (`bool`, _optional_, defaults to `False`) — Whether or not to allow for custom models defined on the Hub in their own modeling files. This option should only be set to `True` for repositories you trust and in which you have read the code, as it will execute code present on the Hub on your local machine.
* **code\_revision** (`str`, _optional_, defaults to `"main"`) — The specific revision to use for the code on the Hub, if the code leaves in a different repository than the rest of the model. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git.
* **kwargs** (additional keyword arguments, _optional_) — Can be used to update the configuration object (after it being loaded) and initiate the model (e.g., `output_attentions=True`). Behaves differently depending on whether a `config` is provided or automatically loaded:
  * If a configuration is provided with `config`, `**kwargs` will be directly passed to the underlying model’s `__init__` method (we assume all relevant updates to the configuration have already been done)
  * If a configuration is not provided, `kwargs` will be first passed to the configuration class initialization function ([from\_pretrained()](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/configuration#transformers.PretrainedConfig.from_pretrained)). Each key of `kwargs` that corresponds to a configuration attribute will be used to override said attribute with the supplied `kwargs` value. Remaining keys that do not correspond to any configuration attribute will be passed to the underlying model’s `__init__` function.

Instantiate one of the base model classes of the library from a pretrained model.

The model class to instantiate is selected based on the `model_type` property of the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when it’s missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:

* **albert** — [TFAlbertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/albert#transformers.TFAlbertModel) (ALBERT model)
* **bart** — [TFBartModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bart#transformers.TFBartModel) (BART model)
* **bert** — [TFBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bert#transformers.TFBertModel) (BERT model)
* **blenderbot** — [TFBlenderbotModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blenderbot#transformers.TFBlenderbotModel) (Blenderbot model)
* **blenderbot-small** — [TFBlenderbotSmallModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blenderbot-small#transformers.TFBlenderbotSmallModel) (BlenderbotSmall model)
* **blip** — [TFBlipModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blip#transformers.TFBlipModel) (BLIP model)
* **camembert** — [TFCamembertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/camembert#transformers.TFCamembertModel) (CamemBERT model)
* **clip** — [TFCLIPModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/clip#transformers.TFCLIPModel) (CLIP model)
* **convbert** — [TFConvBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convbert#transformers.TFConvBertModel) (ConvBERT model)
* **convnext** — [TFConvNextModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.TFConvNextModel) (ConvNeXT model)
* **ctrl** — [TFCTRLModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/ctrl#transformers.TFCTRLModel) (CTRL model)
* **cvt** — [TFCvtModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/cvt#transformers.TFCvtModel) (CvT model)
* **data2vec-vision** — [TFData2VecVisionModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/data2vec#transformers.TFData2VecVisionModel) (Data2VecVision model)
* **deberta** — [TFDebertaModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deberta#transformers.TFDebertaModel) (DeBERTa model)
* **deberta-v2** — [TFDebertaV2Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deberta-v2#transformers.TFDebertaV2Model) (DeBERTa-v2 model)
* **deit** — [TFDeiTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deit#transformers.TFDeiTModel) (DeiT model)
* **distilbert** — [TFDistilBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/distilbert#transformers.TFDistilBertModel) (DistilBERT model)
* **dpr** — [TFDPRQuestionEncoder](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/dpr#transformers.TFDPRQuestionEncoder) (DPR model)
* **efficientformer** — [TFEfficientFormerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/efficientformer#transformers.TFEfficientFormerModel) (EfficientFormer model)
* **electra** — [TFElectraModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/electra#transformers.TFElectraModel) (ELECTRA model)
* **esm** — [TFEsmModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/esm#transformers.TFEsmModel) (ESM model)
* **flaubert** — [TFFlaubertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/flaubert#transformers.TFFlaubertModel) (FlauBERT model)
* **funnel** — [TFFunnelModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/funnel#transformers.TFFunnelModel) or [TFFunnelBaseModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/funnel#transformers.TFFunnelBaseModel) (Funnel Transformer model)
* **gpt-sw3** — [TFGPT2Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/gpt2#transformers.TFGPT2Model) (GPT-Sw3 model)
* **gpt2** — [TFGPT2Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/gpt2#transformers.TFGPT2Model) (OpenAI GPT-2 model)
* **gptj** — [TFGPTJModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/gptj#transformers.TFGPTJModel) (GPT-J model)
* **groupvit** — [TFGroupViTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/groupvit#transformers.TFGroupViTModel) (GroupViT model)
* **hubert** — [TFHubertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/hubert#transformers.TFHubertModel) (Hubert model)
* **layoutlm** — [TFLayoutLMModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlm#transformers.TFLayoutLMModel) (LayoutLM model)
* **layoutlmv3** — [TFLayoutLMv3Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlmv3#transformers.TFLayoutLMv3Model) (LayoutLMv3 model)
* **led** — [TFLEDModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/led#transformers.TFLEDModel) (LED model)
* **longformer** — [TFLongformerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/longformer#transformers.TFLongformerModel) (Longformer model)
* **lxmert** — [TFLxmertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/lxmert#transformers.TFLxmertModel) (LXMERT model)
* **marian** — [TFMarianModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/marian#transformers.TFMarianModel) (Marian model)
* **mbart** — [TFMBartModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mbart#transformers.TFMBartModel) (mBART model)
* **mobilebert** — [TFMobileBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilebert#transformers.TFMobileBertModel) (MobileBERT model)
* **mobilevit** — [TFMobileViTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilevit#transformers.TFMobileViTModel) (MobileViT model)
* **mpnet** — [TFMPNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mpnet#transformers.TFMPNetModel) (MPNet model)
* **mt5** — [TFMT5Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mt5#transformers.TFMT5Model) (MT5 model)
* **openai-gpt** — [TFOpenAIGPTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/openai-gpt#transformers.TFOpenAIGPTModel) (OpenAI GPT model)
* **opt** — [TFOPTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/opt#transformers.TFOPTModel) (OPT model)
* **pegasus** — [TFPegasusModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/pegasus#transformers.TFPegasusModel) (Pegasus model)
* **regnet** — [TFRegNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/regnet#transformers.TFRegNetModel) (RegNet model)
* **rembert** — [TFRemBertModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/rembert#transformers.TFRemBertModel) (RemBERT model)
* **resnet** — [TFResNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/resnet#transformers.TFResNetModel) (ResNet model)
* **roberta** — [TFRobertaModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roberta#transformers.TFRobertaModel) (RoBERTa model)
* **roberta-prelayernorm** — [TFRobertaPreLayerNormModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roberta-prelayernorm#transformers.TFRobertaPreLayerNormModel) (RoBERTa-PreLayerNorm model)
* **roformer** — [TFRoFormerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/roformer#transformers.TFRoFormerModel) (RoFormer model)
* **sam** — [TFSamModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/sam#transformers.TFSamModel) (SAM model)
* **segformer** — [TFSegformerModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/segformer#transformers.TFSegformerModel) (SegFormer model)
* **speech\_to\_text** — [TFSpeech2TextModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/speech_to_text#transformers.TFSpeech2TextModel) (Speech2Text model)
* **swin** — [TFSwinModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/swin#transformers.TFSwinModel) (Swin Transformer model)
* **t5** — [TFT5Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/t5#transformers.TFT5Model) (T5 model)
* **tapas** — [TFTapasModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/tapas#transformers.TFTapasModel) (TAPAS model)
* **transfo-xl** — [TFTransfoXLModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/transfo-xl#transformers.TFTransfoXLModel) (Transformer-XL model)
* **vision-text-dual-encoder** — [TFVisionTextDualEncoderModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vision-text-dual-encoder#transformers.TFVisionTextDualEncoderModel) (VisionTextDualEncoder model)
* **vit** — [TFViTModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.TFViTModel) (ViT model)
* **vit\_mae** — [TFViTMAEModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit_mae#transformers.TFViTMAEModel) (ViTMAE model)
* **wav2vec2** — [TFWav2Vec2Model](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/wav2vec2#transformers.TFWav2Vec2Model) (Wav2Vec2 model)
* **whisper** — [TFWhisperModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/whisper#transformers.TFWhisperModel) (Whisper model)
* **xglm** — [TFXGLMModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xglm#transformers.TFXGLMModel) (XGLM model)
* **xlm** — [TFXLMModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlm#transformers.TFXLMModel) (XLM model)
* **xlm-roberta** — [TFXLMRobertaModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlm-roberta#transformers.TFXLMRobertaModel) (XLM-RoBERTa model)
* **xlnet** — [TFXLNetModel](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/xlnet#transformers.TFXLNetModel) (XLNet model)



Examples:

Copied

```
>>> from transformers import AutoConfig, TFAutoModel

>>> # Download model and configuration from huggingface.co and cache.
>>> model = TFAutoModel.from_pretrained("bert-base-cased")

>>> # Update configuration during loading
>>> model = TFAutoModel.from_pretrained("bert-base-cased", output_attentions=True)
>>> model.config.output_attentions
True

>>> # Loading from a PyTorch checkpoint file instead of a TensorFlow model (slower)
>>> config = AutoConfig.from_pretrained("./pt_model/bert_pt_model_config.json")
>>> model = TFAutoModel.from_pretrained(
...     "./pt_model/bert_pytorch_model.bin", from_pt=True, config=config
... )
```
