---
source: https://iinventedlight.com/library/notes/hf-transformers-auto-classes.md
title: "AutoModel classes and from_pretrained"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (huggingface/transformers, huggingface_hub, diffusers docs; LICENSE verified in each repo); prose restates cited source lines in own words"
license_family: hf-apache
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-09
status: published
checked_on: 2026-11-09
as_of: 2026-11-09
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Hugging Face"
tags: [hugging-face, transformers, automodel, from-pretrained]
client: Librarian
sources:
  - id: S1
    title: "Loading models"
    publisher: Hugging Face docs
    url: https://huggingface.co/docs/transformers/models
    accessed: 2026-11-09
    license: "Apache-2.0 (huggingface docs repos)"
  - id: S2
    title: "Tokenizers"
    publisher: Hugging Face docs
    url: https://huggingface.co/docs/transformers/fast_tokenizers
    accessed: 2026-11-09
    license: "Apache-2.0 (huggingface docs repos)"
---
# 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 `AutoModel` outputs 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)](https://iinventedlight.com/library/artifacts/hf-load-choices.table.json)
- [Hugging Face model load choices (markdown table)](https://iinventedlight.com/library/artifacts/hf-load-choices.table.md)
- [from_pretrained options schema](https://iinventedlight.com/library/artifacts/hf-from-pretrained.schema.json)
- [Topic packet: huggingface](https://iinventedlight.com/library/packets/huggingface.json)

## See also

- [hf-transformers-pipeline](https://iinventedlight.com/library/notes/hf-transformers-pipeline/)
- [hf-safetensors](https://iinventedlight.com/library/notes/hf-safetensors/)
- [hf-transformers-big-model-loading](https://iinventedlight.com/library/notes/hf-transformers-big-model-loading/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
