AI CompendiumA public chart of the language
Home / Foundations / Transformer
Foundations

Transformer

The 2017 network architecture that all modern language models are built on.

Definition

A neural network architecture built around attention. Unlike earlier sequence models, it processes every token in parallel and can look directly at any other token, which is what made training on internet-scale data practical.

Introduced in the paper "Attention Is All You Need" (2017). The transformer block — attention plus a small feed-forward network, with residual connections and layernorm — is still the unit repeated dozens or hundreds of times to make a modern LLM.

Two consequences follow from the architecture and shape everything downstream. First, attention is quadratic in sequence length — doubling the window roughly quadruples that part of the compute, which is the real reason long context is expensive rather than free. Second, because the whole sequence is processed in parallel, the model has no built-in notion of order, so position has to be injected explicitly.

How people use it
Choosing a model for a long-document task.
"It is a transformer, so the cost of attention grows with sequence length. Long context is never free."
Worked examples

Why long context costs what it costs

A team assumes a 200k-token window makes retrieval unnecessary.

Pushing a whole repository into the window raises cost and latency superlinearly, and — per the long-context results — recall does not scale with it. The cheaper architecture is still to retrieve the right 5% and keep the window small.

Explaining the architecture in one sentence

Onboarding an engineer who has used the API but never read the paper.

"Every token produces a query and every token offers a key and a value; the output is a weighted sum of values, chosen by query-key similarity — and that happens in parallel at every layer." That is enough to reason about context, caching and cost.

Sources
Related terms