Activity (Process)

Single-Step Autoregressive Generation with a Key-Value (KV) Cache

During each step ii of autoregressive generation, the model computes a new query (qi\mathbf{q}_i), key (ki\mathbf{k}_i), and value (vi\mathbf{v}_i) vector from the current input token. The new key-value pair (ki,vi\mathbf{k}_i, \mathbf{v}_i) is appended to the Key-Value (KV) cache, which holds the pairs for all preceding tokens. The attention operation is then performed using the new query qi\mathbf{q}_i and the complete set of keys and values stored in the cache up to the current step, denoted as Ki\mathbf{K}_{\leq i} and Vi\mathbf{V}_{\leq i}. This process generates the output for step ii by allowing the current token to attend to itself and all previous tokens in the sequence.

Image 0

0

1

Updated 2026-06-24

Contributors are:

Who are from:

Tags

Ch.5 Inference - Foundations of Large Language Models

Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences

Ch.2 Generative Models - Foundations of Large Language Models

Related