# Query, key and value

> Query, key and value: Three learned projections of each token's vector. A query is compared with every key to get attention weights; the weights then mix…

Canonical: https://llmdojo.dev/glossary/qkv

Also called queries, keys and values.

Three learned projections of each token's vector. A query is compared with every key to get attention weights; the weights then mix the values.

Learn it in the lesson: [Queries, keys and values](https://llmdojo.dev/learn/model-foundations/attention/queries-keys-values) (Model Foundations · Attention: How Tokens Use Their Context).

## Interview questions about Query, key and value

- [Walk me through scaled dot-product attention. What are queries, keys and values, and why divide by the square root of d?](https://llmdojo.dev/interview/q/walk-me-through-scaled-dot-product-attention-what-are-queries-keys-and)
- [In a recommender that uses cross-attention between a user's behavior sequence and a candidate item, what exactly are the query, key and value?](https://llmdojo.dev/interview/q/in-a-recommender-that-uses-cross-attention-between-a-user-s-behavior)
- [What is attention, exactly how are the queries, keys and values computed, and how does a KV cache speed up decoding?](https://llmdojo.dev/interview/q/what-is-attention-exactly-how-are-the-queries-keys-and-values-computed)
- [Cover the fundamentals: self- versus cross-attention, autoregressive decoding and sampling, where RL fits, and how you evaluate the result.](https://llmdojo.dev/interview/q/cover-the-fundamentals-self-versus-cross-attention-autoregressive-decoding-and-sampling-where)
- [What are multi-head and grouped-query attention, and what does GQA do to the KV cache?](https://llmdojo.dev/interview/q/what-are-multi-head-and-grouped-query-attention-and-what-does-gqa)

## Related
- [Attention](https://llmdojo.dev/glossary/attention)
- [Attention head](https://llmdojo.dev/glossary/attention-head)
- [Causal mask](https://llmdojo.dev/glossary/causal-mask)
- [Softmax](https://llmdojo.dev/glossary/softmax)
- [Transformer block](https://llmdojo.dev/glossary/transformer-block)
- [Residual connection](https://llmdojo.dev/glossary/residual-connection)
- [Layer norm](https://llmdojo.dev/glossary/layer-norm)
- [Feed-forward network (MLP)](https://llmdojo.dev/glossary/mlp)
- [Glossary of every term](https://llmdojo.dev/glossary)
