Verba/Rapida

Explainers

Prompt caching

A chat sends the whole conversation again every turn. If the beginning of the new request is identical to the previous one, the model can reuse the work it already did on that beginning instead of reading it again.

EXPrompt cachingillustrative

Three turns of a chat. Lit cells were reused from the cache, grey cells had to be computed. Sizes are illustrative.

turn 1turn 2turn 3
  • reused from the cache
  • computed again

The model computed 24 of 54 tokens; the rest came from the cache.

The picture and its numbers are illustrative.

The takeaway

Reuse stops at the first token that changed. So put what never changes at the start and what changes at the end: one edited word near the top throws away the cache for everything after it.

What the lab knows

On this lab's benchmark an 8k-token prompt takes 0.69 s to the first token cold and 0.11 s when the prefix is cached (Gemma 4 E4B). measured here

See it in the atlas

Want to see what these experiments produced? Lesto, the Gemma 4 inference engine for Apple silicon Macs, is on lestoengine.com

Made by Federico Andrioli, @fedeandri on X A research lab's own measurements, generated from its files. Data built