Learned Projections Define Matching and Content

The query and key projections determine learned matching, while the value projection determines the content carried along that route. Controlled ablations show these roles without assigning unsupported human meanings to individual coordinates.

The input representation xix_i does not arrive with separate fields named “what I need,” “how I should be found,” and “what I should send.” The matrices WQW_Q, WKW_K, and WVW_V learn those three projections from data.

For model width dmodeld_{model},

WQ,WKRdmodel×dk,WVRdmodel×dv.W_Q,W_K\in\mathbb R^{d_{model}\times d_k},\qquad W_V\in\mathbb R^{d_{model}\times d_v}.

Queries and keys require the same width because their dot product contracts over that axis. Values may use another width because they are combined only after the attention weights have been calculated.

Change One Projection at a Time

Use the two input rows

x1=[1,0],x2=[0,1],x_1=[1,0],\qquad x_2=[0,1],

and let WQ=WK=WV=IW_Q=W_K=W_V=I. The first query has dot products

q1k1=1,q1k2=0.q_1k_1^\top=1,\qquad q_1k_2^\top=0.

It therefore favors the first value. We can now perform three controlled changes.

Change only WQW_Q

Swap the query coordinates:

WQ=[0110].W_Q'=\begin{bmatrix}0&1\\1&0\end{bmatrix}.

Now q1=[0,1]q_1'=[0,1], so its two dot products become 0 and 1. The match reverses, while the keys and values themselves do not change.

Change only WKW_K

Restoring WQ=IW_Q=I and applying the same coordinate swap to WKW_K also reverses which key matches the first query. This change alters how every source position presents itself for matching.

Change only WVW_V

Keep WQ=WK=IW_Q=W_K=I and let

WV=[2003].W_V'=\begin{bmatrix}2&0\\0&-3\end{bmatrix}.

The scores and attention weights remain exactly the same, but the values become [2,0][2,0] and [0,3][0,-3]. The routed content changes even though the routing pattern does not.

Changed parameterDirectly changesDoes not directly change
WQW_Qeach position's requestssource values
WKW_Khow source positions matchsource values
WVW_Vcontent carried by source positionsattention weights

These descriptions refer to one forward pass while the other parameters are held fixed. During training, all projections may adapt together, so observed effects need not remain isolated.

Matching Coordinates Do Not Have Fixed Names

It is tempting to label a query-key coordinate “subject,” “plural,” or “earlier name.” Such a label is a hypothesis about a trained model, not part of the definition. The basis can change while dot products remain the same.

For example, let RR be an orthogonal matrix, so RR=IRR^\top=I. Replacing

Q=QR,K=KRQ' = QR,\qquad K'=KR

does not change the score matrix:

QK=QRRK=QK.Q'K'^\top=QRR^\top K^\top=QK^\top.

The individual coordinates rotated, but every query-key score stayed fixed. This simple symmetry shows why a coordinate should not receive a semantic name without additional evidence.

Ablate one projection

Change one matrix at a time. Compare the score row with the values and weighted reading.

Command/Ctrl + Enter. Python runs in your browser.

Ready to run.

Q1. Change content without changing routing

Which single projection can be changed while leaving all query-key scores and attention weights fixed in the current forward pass?

Choose one

Select one choice, then check.

Hint
The score matrix is QK/dkQK^\top/\sqrt{d_k}.
Solution
Change WVW_V. It changes V=XWVV=XW_V and therefore the reading AVAV, but it does not enter the score or softmax equations.
Not attempted
Review

Not marked done.

Treat Labels as Testable Hypotheses

A projection determines a mathematical role. A trained feature may also have a useful human interpretation, but that claim needs evidence from examples, ablations, or interventions. The equations alone establish matching and content flow—not a semantic dictionary for coordinates.

Pause and reflect

In your own words, note what you understood, what remains unclear, or what you want to revisit. The note stays with this lesson.

0 of 1 exercises marked done

Review

Not marked done.

LLM PrimerLearned Projections Define Matching and Contenthttps://llmprimer.com/transformers/from-attention-to-self-attention/learned-projections-define-matching-and-content© 2026 LLM Primer