Transformers and Attention

Transformers and Attention

Key jargon

Term Plain-language meaning
Transformer A neural-network architecture built around attention and feed-forward blocks.
Attention A learned mechanism that mixes information from different token positions.
Query, key, value Three learned projections used to calculate what each token should read and what information it receives.
Positional information Signals that let a model distinguish token order.

Key concepts

Concept map

flowchart LR
    A["Token representations"] --> B["Create queries keys values"]
    B --> C["Compute attention"]
    C --> D["Build contextual representations"]

Learning objectives

Mental model

For each token representation, attention produces a query, key, and value. Query–key similarity determines how much each value contributes to the next representation. Multiple heads can learn different relationships. Feed-forward layers transform each position; residual connections and normalization stabilize deep networks; positional information supplies ordering.

Transformers made sequence processing highly parallel during training. Modern systems add many variations: decoder-only, encoder-only, encoder–decoder, mixture-of-experts, sparse attention, multimodal adapters, and optimized attention kernels.

Important limits

Exercise

Take: “The trophy did not fit in the suitcase because it was too large.” Identify which earlier words the representation of “it” should relate to and why context matters.

Primary source