Index Ai Academy
Glossary · Phase 5 · Transformers

KV cache

Saving the keys and values of earlier tokens so the model doesn't recompute them for every new token.

Try it now

Without a cache, every step redoes every earlier token, so the work grows with the square of the length.

Learn it properly

Inference and the KV cache · Why generation is fast after the first token. About 35 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write