← All notes

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

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

See also

Claims

Sources

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

Permanent ID: iil:note:z3nkefvg

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.},
}

Markdown

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.