Concept icon
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.

0

1

Concept icon
Updated 2026-09-07

Tags

Ch.2 Generative Models - Foundations of Large Language Models

Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences

D2L

Dive into Deep Learning @ D2L

Prep Sessions

Transformer Architecture and Large Language Model Capabilities @ University of Michigan - Ann Arbor

Ch.1 Transformer Architecture Fundamentals - Transformer Architecture and Large Language Model Capabilities @ University of Michigan - Ann Arbor

Self-Attention and Query-Key-Value Mechanisms - Transformer Architecture and Large Language Model Capabilities @ University of Michigan - Ann Arbor

Related
Learn After