Narration · Module 22
Q / K / V
0:00 / 0:00
Module 22 · Architecture · 8 min

Q, K, V - the projections.

The matrices that turn embeddings into queries, keys, values.

Reading time8 min Audionarration available Prerequisites12 SourceTrack A · Gemini
§ 1

What this lesson covers.

This module is one of 42 in the curriculum. Below is the canonical interactive lesson — tabs, cards, and diagrams from the source repo, rendered inside the course shell. An audio narration runs alongside it - the sticky player at the top of the page plays the full Module 22 clip.

If you prefer to read first and play with the demos after, the interactive lesson sits below this section. If you'd rather hear it narrated while you scroll, hit play on the sticky audio bar at the top — or just let it autoplay.

§ 2

The lesson itself.

Interactive lesson · ported from Gemini track Click tabs to navigate · hover cards for details

QKV Matrix Projection

Before a token can pay attention to other words, it must split its single dense embedding into three distinct mathematical roles: Query (Q), Key (K), and Value (V). It does this by multiplying its embedding vector against three massive learned weight matrices ($W_Q$, $W_K$, $W_V$).

0.412
-1.104
0.893
2.301
Token Embedding Vector (e.g. "king")
WQ Matrix
WK Matrix
WV Matrix
0.12
0.45
-0.9
1.1
Query (Q)
"What I am looking for"
1.80
-0.2
0.31
0.77
Key (K)
"What properties I contain"
-0.6
2.34
0.11
-1.9
Value (V)
"My actual semantic payload"
§ DEMO

Try it: qkv projection.

One token embedding becomes three vectors via three learned matrices. See Q (query), K (key), V (value) computed live for any token.

QKV Projection · interactiveOpen standalone
§ PAPERS

Further reading.

The canonical references for this module. External links open in a new tab.

§ NEXT

What to read next.

Use the pager below to move sequentially through the curriculum, or jump to any module from the course index. Each track has a "Prereq: ↑ foundation" callout so you can backfill anything that wasn't clear.