Q, K, V (query, key, value)
In attention: queries Q, keys K and values V, each a matrix with one row per token.
In ML papers
In attention, each token is projected three ways. Its query ( row) says what it is looking for, its key ( row) what it offers to be matched on, and its value ( row) what it passes on if matched. Scores are query-key dot products, ; after a softmax they weight the values. They come from the input by learned matrices: , , . Here the superscripts are labels, not powers.
Other meanings, by context
- Outside attention. is often the number of classes or a kernel matrix; a value function in RL; an action-value function.
How to type it
| LaTeX | Shows |
|---|---|
Q, K, V | |
\mathbf{Q}, \mathbf{K}, \mathbf{V} |
A worked example
One query-key score in a 2-dimensional head.