AI Blog

AI Blog

by Michele Laurelli

Query, Key, Value (QKV)

/ˈkwɪəri kiː ˈvæljuː/
Concept
Definition

Three vectors used in attention mechanisms to compute weighted combinations of input elements.

In attention, inputs are projected to Query (what we're looking for), Key (what each element offers), and Value (actual content). Attention scores are computed as similarity between Query and Keys, then used to weight Values.

Examples

1

Transformer attention

2

Self-attention computation

3

Cross-attention in encoder-decoder

Michele Laurelli - AI Research & Engineering