AutoModel classes and from_pretrained
Answer: from_pretrained downloads and loads a model's weights and configuration from the Hub or a local directory; an AutoModel class picks the right model class from the configuration file.
Architecture vs checkpoint
An architecture is the model's skeleton; a checkpoint is the weights for a given architecture. BERT is an architecture; google-bert/bert-base-uncased is a checkpoint.
Two kinds of model class
- A barebones model like
AutoModeloutputs hidden states. - A model with a task head attached, like
AutoModelForCausalLM, performs a specific task.
The AutoModel class selects the correct model class based on the configuration file, so you only need the task and checkpoint. Use a model-specific class directly if you already know which class you want.
Tokenizer twin
AutoTokenizer.from_pretrained reads the model config and resolves the correct tokenizer class, so you don't need to know it beforehand.
from_pretrained loads safetensors files if they're available; pickle-serialized PyTorch weights are known to be insecure.
Artifacts
- Hugging Face model load choices (table)
- Hugging Face model load choices (markdown table)
- from_pretrained options schema
- Topic packet: huggingface
See also
Claims
- id: C1 claim: from_pretrained loads weights and configuration from the Hub. source: S1 evidence: "download and load a model's weights and configuration stored on the Hugging Face Hub"
- id: C2 claim: AutoModel picks the model class from the config file. source: S1 evidence: "It automatically selects the correct model class based on the configuration file."
- id: C3 claim: A checkpoint is the weights for an architecture. source: S1 evidence: "a checkpoint refers to the model's weights for a given architecture"
- id: C4 claim: AutoTokenizer resolves the tokenizer class from config. source: S2 evidence: "reads the model config, resolves the correct tokenizer class, and returns an instance of it"
Sources
- [S1] Loading models. Hugging Face docs. https://huggingface.co/docs/transformers/models . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.
- [S2] Tokenizers. Hugging Face docs. https://huggingface.co/docs/transformers/fast_tokenizers . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs (huggingface/transformers, huggingface/huggingface_hub, huggingface/diffusers on GitHub), Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs, Loading models, Apache-2.0 (huggingface docs repos); Hugging Face docs, Tokenizers, Apache-2.0 (huggingface docs repos).
Cite this
iinventedlight. 2026. "AutoModel classes and from_pretrained." iinventedlight Library, iil:note:z3nkefvg, version of 2026-11-09. https://iinventedlight.com/library/notes/hf-transformers-auto-classes/. License: CC-BY-4.0.
@misc{iil_note_z3nkefvg,
author = {{iinventedlight}},
title = {{AutoModel classes and from\_pretrained}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-09},
url = {https://iinventedlight.com/library/notes/hf-transformers-auto-classes/},
note = {Permanent ID iil:note:z3nkefvg. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/hf-transformers-auto-classes.md.