Why are queries, keys, and values produced through learned linear projections rather than using raw token embeddings directly?

Last updated 22 November 2026

  • Raw embeddings give a symmetric score x_i·x_j where each token matches itself most strongly. Projections make relevance a learned, asymmetric bilinear form x_iᵀ W_Q W_Kᵀ x_j.

  • Separate projections decouple roles: what makes a token findable (K) can differ from what it passes on (V).

  • Per-head W_Q, W_K, W_V enable multi-head attention, where heads specialize in different relations. They also give the layer learnable parameters.

  • https://medium.com/@hariprasannaa2001/why-transformers-use-queries-keys-and-values-q-k-v-explained-with-it-pronouns-f1e91532ed15
  • https://mbrenndoerfer.com/writing/query-key-value-attention-mechanism
  • https://dev.to/nishanthan-k/how-query-key-and-value-qkv-work-in-transformers-199a
All Transformers interview questions