Your production RAG costs $1M/month. The CFO wants this cut in half with a max 1-point faithfulness regression. What highest leverage cost optimizations do you deploy, in priority order?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Production RAG cost is $1M/month. Quality budget: faithfulness can drop at most 1 point. Walk through the highest leverage cost optimizations in priority order. For each, name the expected cost reduction, the quality risk, and how you'd validate the change before rolling it out.
Profile first; the LLM eats 50-65% of cost. Ship in order: prompt caching, top-k reduction, vector quantization, generator routing, semantic cache, self-hosted Llama. Gate each change on the eval set.
Think of your RAG bill like a household budget. Before you cut anything, you figure out where the money actually goes. In most homes the rent or mortgage is the biggest line item; in RAG, it is the smart-AI call that writes the answer. Once you know that, you attack the biggest bills first, but you start with the changes that cannot hurt quality: turn on the discount card the AI provider already gives you, send shorter shopping lists, and shrink your storage closet. Only then do you try the riskier moves, like using a cheaper helper for easy questions or running your own AI on your own machines. After each change, you check that the answers are still as honest as before. If they slip more than a tiny bit, you back the change out.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
11 min: walk the profile, defend the ordering, give expected savings and validation for each of the six levers, and close with the 40-55% combined estimate.
| Optimization | Cost saved | Quality risk | Validation effort | Ship week |
|---|---|---|---|---|
| Prompt caching | 20-40% of LLM | none | shadow A/B | 1 |
| Top-k reduction | 10-25% of LLM | low (often improves) | faithfulness curve | 2 |
| Vector quantization | 50-75% of vector DB | low (reranker recovers) | recall@k | 3-4 |
| Generator routing | 30-50% of LLM | real, bounded | per-tier eval + A/B | month 2 |
| Semantic answer cache | 5-20% of pipeline | staleness | hit ratio + freshness | month 2 |
| Self-hosted Llama 4 | 3-5x on volume tier | model quality gap | 4-6 week pilot | month 3-4 |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Jumping to fixes without profiling. If you do not know the cost breakdown, you optimize the wrong layer. The LLM dominates; embedding cost is rarely worth chasing first.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.