EasyDeepLearn

What is prompt caching and when does it help?

hard

Answer

  • Cache the KV attention state of a large prefix (system prompt, few-shot examples, retrieved context) and reuse it across many requests that share that prefix.
  • On subsequent calls, prefill only the new suffix — huge savings on TTFT (10-100x) and cost (50-90%).
  • Supported by Anthropic API (explicit  cachecontrol)(\mathrm{explicit}\;\mathrm{cache}_{\mathrm{control}}), Google (implicit), OpenAI (implicit prefix cache), and open-source (vLLM automatic prefix caching).
  • Essential for RAG apps and agent loops with stable system prompts.
Check yourself — multiple choice
  • Cache the outputs
  • Cache KV state of a shared prefix → prefill only new suffix → 10-100× faster TTFT + 50-90% cost cut on RAG / agents
  • Same as embedding cache
  • Only training

Prompt caching: reuse KV of a shared prefix → massive TTFT + cost savings on RAG / agents.

#production#inference#kv-cache#cost

Practise LLMs & GenAI

214 interview questions in this topic.

Related questions