Learn Before
Concept

Query, Key, and Value in Attention Mechanisms

Query, Key, and Value are fundamental components of attention mechanisms, which allow a model to focus on relevant parts of an input sequence.

  • Query: Represents the current context or element for which attention is being calculated. In the provided diagram, these are the multiple blue squares.
  • Key: A label or identifier for a piece of information stored in memory. It is compared with the query to determine relevance. In the diagram, this is the green square labeled 'key'.
  • Value: The actual content or information associated with a key. When a key is deemed relevant by a query, its corresponding value is retrieved. In the diagram, this is the green square labeled 'value'. The interaction involves comparing a query with a set of keys to compute weights, which are then applied to the corresponding values to produce an output.
Image 0

0

1

Updated 2026-04-18

Contributors are:

Who are from:

Tags

Ch.2 Generative Models - Foundations of Large Language Models

Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences

Related
Learn After