AI GLOSSARY · AI CONCEPTS

Multi-head attention

Markdown version · Wikidata Q108750000

Definition

Multi-head attention runs several attention operations in parallel, each with its own learned projections of the queries, keys and values. Their outputs are joined and projected again, letting a model attend to different information at once.

Also called: multihead attention, self-attention heads, attention heads, MHA, multi head attention.

In plain language

When a language model reads a sentence, attention is how it decides which other words matter for understanding each word. Multi-head attention does this several times side by side, like several readers each underlining different things in the same page, and then combines what they found. Each reader is called a head. Documented Transformer architectures use it in their layers; the selected model's documentation determines a product's architecture. You will meet the idea in model descriptions and papers. The limit: more heads do not mean a better model by themselves, and what any head attends to is not guaranteed to be a clear human-readable pattern.

Technical definition

Vaswani et al. (2017) describe multi-head attention as linearly projecting the queries, keys and values several times with learned projections, running attention on each projection in parallel, then concatenating the outputs and projecting again. They state that it lets the model jointly attend to information from different representation subspaces at different positions. In their base model they use eight parallel heads, each with reduced dimensions so that total computation is similar to single-head attention at full dimensionality. The Dive into Deep Learning text describes each of the h attention outputs as a head. Multi-head attention can be self-attention or cross-attention; the latter takes queries and keys/values from different sequences.

Worked examples in this catalogue

Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.

  1. Guide · Illustrative, not executed

    What Is an LLM? The Facts Agent Users Need

    What you see
    A guide contrasting the original Transformer decoder with BERT's masked pretraining, and runtime context with learned parameters.
    Why it exercises the concept
    The guide supplies architecture and objective context for this mechanism. It is useful context for why the model, not the agent application, handles how input is weighed. Illustrative reading, not executed.
  2. Skill by Skill Almanac · Illustrative, not executed

    context-window-packer 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill is designed to propose which supplied material to keep, compress or omit within a stated context budget.
    Why it exercises the concept
    Attention operates over the input the application supplies, so what you include in the context is what the heads can attend to. This skill does not inspect attention or measure it. Illustrative, not executed.
  3. Skill by Skill Almanac · Illustrative, not executed

    llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
    Why it exercises the concept
    Claims about what a model does with its attention are tested by behaviour on held-out cases, not by head count. This skill builds such a test set but does not examine heads. Illustrative, not executed.

How it shows up when you use agents

You do not usually touch multi-head attention directly when you use Claude Code, Codex or Cursor. In a selected model documented to use it, multi-head attention runs inside the model. It appears when you read a model card or paper that lists layers and heads, or when you tune or serve an open model and meet terms such as head count, KV cache or FlashAttention, which are implementation matters built around attention.

What breaks when it is misunderstood: people read heads as separate experts with separate jobs. The original paper says multi-head attention lets the model attend to information from different representation subspaces. It does not claim each head has a tidy human-readable role. Another error is thinking attention gives the model memory beyond what was supplied: it works over the input in the context window.

A practical next step: when a vendor describes an architecture, ask what the head count claim is meant to support, and judge the model on your own tasks rather than on its internals. The wider idea is in attention mechanism. The catalogue has no skill that inspects model internals, so the examples are contrast cases.

Common confusions

  • Multi-head versus single-head attention. Single-head runs one attention operation. Multi-head runs several in parallel on separately projected inputs, then concatenates and projects the result.
  • Heads versus layers. Heads run in parallel inside one attention block. Layers are stacked one after another.
  • Self-attention versus multi-head attention. Self-attention describes where queries, keys and values come from, the same sequence. Multi-head describes running that operation in several projected copies.
  • Myth: more heads means more compute. In the original paper each head uses reduced dimensions so total cost is similar to single-head attention at full dimensionality.

Terms that mention Multi-head attention

1 terms mention this one

More in AI concepts

Next steps

  1. What Is an LLM? The Facts Agent Users Need The long-form guide.
  2. context-window-packer A skill that exercises it.
  3. Transformer Related term.
  4. Attention mechanism Related term.
  5. All glossary terms A to Z and by family.

Sources

Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-25. Wikipedia is never the only source.

Review record

Last verified

Drafted by Claude (original draft) and OpenAI Codex (targeted revisions); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-25. Last verified .

Change log (5)
  • : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
  • : Bounded batch-13 source and illustration repairs; independent affected recheck pending, publication disabled.
  • : First version.
  • : Verifier pass: applied verifier corrections to unsupported or overstated claims.
  • : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.