Transformers and LLMs

KV Cache, explained

A KV cache stores attention keys and values from previous tokens so autoregressive generation does not recompute them every step.
Back to Glossary

Part of the Semantic Notion technical glossary.

Short Definition

A KV cache stores attention keys and values from previous tokens so autoregressive generation does not recompute them every step.

Intuition

When a model generates one token at a time, it can remember earlier attention data instead of rebuilding it from scratch.

Technical Definition

KV cache is the stored set of key and value tensors for prior sequence positions used during transformer decoding.

Example

A chat model uses a KV cache to speed up each next-token generation step.

Common Misunderstandings

KV cache improves decoding speed but consumes memory.
It does not make the model remember information outside its context window.

Start here

Need the broader concept map?

Return to the glossary index to move from this definition into adjacent AI, ML, mathematics, and computer science terms.