Query, Key, Value
Also called QKV
The three roles each token plays in attention: what it’s looking for, what it offers, and what it hands over.
Think of it like
A library search: your query, each book’s label (key), and the book’s actual contents (value).
Example
A token’s query is matched against every token’s key; the closest matches decide whose values get blended in.
How it actually works
Attention derives three vectors from each token. The query says what this token wants; keys advertise what every token contains; the dot-product of a query with each key gives relevance scores; those scores then weight the values that get summed into the output. This query-key-value framing is the machinery underneath every attention mechanism.
For product teams
The conceptual gears of attention — worth knowing when you hear about KV caching and its memory costs.
For engineers
The three learned projections per token whose query-key similarity weights a sum over values.
Related
- Attention — The inputs to attention.
- Scaled Dot-Product Attention — Matched via scaled dot-product attention.
- KV Cache — Keys and values get cached.
Read anything AI without the jargon
Look up any term in plain English, or save terms as you read with the free Chrome extension.
Open DecoderAdd to Chrome