﻿# Multi-head attention: split, combine and project representations

How multi-head attention forms separate matching and value spaces, concatenates head outputs and learns a final projection, without assuming human-readable head roles.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/multihead-attention-concatenate-project/
Language: en

Multi-head attention evaluates several learned matching-and-aggregation paths before combining their results. The design lets a layer use different projections of its input. Understanding the combination step is as important as drawing several arrows labelled attention heads on an architecture diagram.

## Separate projection spaces create distinct comparisons

Each head can use its own learned query, key and value transformations under the architecture’s parameter arrangement. This allows different matching relationships over the same eligible sequence positions. A head is not simply another copy of the identical score matrix. At the same time, a diagram does not establish what semantic role a trained head will learn. Subject matching, positional patterns or other behaviors require evidence from the actual trained system rather than a predetermined assignment of grammatical labels to head indices.

## Aggregation happens inside each head before combination

Within a head, normalized weights combine its value representations into an output for each query position. The model then collects head outputs and applies its defined output projection. In the familiar Transformer formulation, concatenation exposes the head-feature results together before a learned linear transformation mixes them. Concatenation alone does not average all heads into one scalar opinion. Reading the actual operation explains both the output width and how information from different head computations can influence the following residual update.

## A small intervention can isolate a combination mistake

In a proposed reference test, make each head’s output distinguishable and use a deliberately simple output projection. Verify which coordinates arrive at which places before restoring learned parameters. An accidental head-position permutation can preserve total tensor size while combining the wrong objects. Comparing only the final shape would miss that error. This diagnostic uses controlled artificial values to establish wiring; it is separate from studying whether a trained head makes useful distinctions on natural-language examples.

## Keep head count separate from service claims

The number of heads is one architectural parameter among projection widths, key-value sharing and layer count. It does not independently rank intelligence or determine end-to-end speed. Implementation choices and hardware affect execution cost, while training determines useful behavior. A reproducible comparison records the actual architecture and tests the intended workload. Multi-head attention is therefore best understood as a structured collection of learned computations with an explicit combination rule, not a set of independent experts whose individual natural-language explanations can be assumed without investigation.

## Primary research and implementation references

- [Attention Is All You Need](https://arxiv.org/abs/1706.03762).

- [PyTorch: MultiheadAttention](https://docs.pytorch.org/docs/2.15/generated/torch.nn.MultiheadAttention.html).

- [PyTorch: Scaled Dot Product Attention](https://docs.pytorch.org/docs/2.15/generated/torch.nn.functional.scaled_dot_product_attention.html).

## Related engineering context

[Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/).
