learn-rag-with-phoebe / Leader session 3 of 6
Learn RAG with Phoebe · Leader track · Session 3 of 6

Cost vs quality: the real tradeoffs

Two questions decide whether a RAG project is a good investment: where does the money actually go, and where is quality actually won? The surprising answer to both is that they barely overlap. The parts that dominate your bill are not the parts that most improve your answers - which means the smart moves raise accuracy without moving the invoice much. This session gives you the cost model on one page, the lever board that separates cheap wins from expensive ones, and enough real numbers to sanity-check any proposal your team brings you.

🟡 Leader track Leaders: C-level · managers No code, ever 45 min
0-3 · Welcome 3-20 · Concepts 20-40 · Exercises 40-45 · Q&A
Part 0

Why cost and quality are two different maps

In session a2 you learned the nine parts and the line between index-time work (done once) and query-time work (paid per question). This session puts money and quality on that same anatomy - and the lesson is that the two do not line up. The biggest cost in a RAG system is the model writing the answer, on every call, forever. But the biggest quality gains come from cheap places: how you cut the documents, whether you re-score results, and whether the system knows when to refuse. A leader who understands this stops approving expensive upgrades that barely help and starts funding cheap changes that quietly double the accuracy.

Live - presented in session Self-study - read after class ★ Try it now prompt Sources covered at the end
★ What you walk out with today A three-bucket cost model (one-time indexing, storage, per-query) and the knowledge that generation dominates the per-query bill; a lever board that sorts quality moves into cheap wins and expensive ones; real numbers from Anthropic's contextual retrieval; a clear-eyed build-vs-buy frame; and questions to ask your data team this week.
Part 1 · covers the three cost buckets and the long-context anti-pattern

Where the money actually goes 9 min live

RAG cost falls into three buckets, and only one of them grows with use. Index-time embedding is a one-off. Storage is a steady monthly hosting fee. Per-query cost - embedding the question, optionally reranking, and the model generating the answer - is paid on every single question, and inside it the generation step dominates. Picture the three buckets, sized the way they actually behave at scale.

Bucket 1 · one-time indexing Embed all docs once project cost · paid on re-index Bucket 2 · storage Vector DB hosting steady monthly fee Bucket 3 · per-query cost · paid every question, grows with use Query embed · tiny Rerank optional · small Generation · the model writes the answer the dominant per-query cost · scales with every token in and out Generation dominates the per-query bill. Cut what you feed it and how often you call it before you cut anything else.
🔍 Click to zoom - three cost buckets, and why generation is the one that scales
LiveThe three cost buckets, and which one keeps you up at night3 min

Every RAG bill sorts into three buckets. Knowing which is which stops you from optimizing the one that does not matter.

  • One-time indexing. Embedding all your documents is paid once (again only when you re-index). It can feel large the day you run it, but it is a project cost, not a running one. Do not let its size scare you off a good design.
  • Storage. Hosting the vector database is a steady monthly fee that grows slowly with the size of your corpus. Predictable, and usually the smallest of the three at real scale.
  • Per-query cost. This is the one that keeps you up at night, because it grows with adoption. It is the query embedding (tiny), optional reranking (small), and the model generating the answer (large). Success - more people using the system - makes this bucket bigger.

The uncomfortable truth: the more successful your assistant, the more the per-query bucket dominates. So the per-query design - especially how much text you feed the model and how often - is the number a leader should watch.

★ Try it now (any chat AI)I run a RAG assistant. Explain, using a restaurant analogy, the difference between a one-time cost (fitting out the kitchen), a fixed monthly cost (rent), and a per-order cost (ingredients for each dish). Then tell me which one grows as the restaurant gets more popular, and what that means for how I should watch costs.
LiveWhy generation dominates - and why "paste everything" is the expensive trap3 min

Inside the per-query bucket, the model writing the answer costs far more than the search that found the passages. Search over numbers is cheap and fast; a language model reading a prompt and composing a reply is where the tokens - and the money - are spent. Two consequences follow directly:

  • Feed the model less, pay less. The cost of generation scales with how many tokens go in and come out. Handing it five tight passages instead of fifty loose ones is a direct saving on every call.
  • The long-context anti-pattern from a1 is a cost story. "Just paste the whole document into every prompt" means you pay for every token in, on every single call. It looks free in a demo of ten questions; at production volume it is the bill that shocks finance. Retrieval exists partly to keep the generation prompt short.
Real world

The month the meter moved. A team (anonymized) launched an internal assistant and watched usage climb from a few dozen questions a day to a few thousand. The one-time indexing cost never changed and storage barely moved - but the per-query generation cost tracked usage almost exactly, because each answer called the model. The lever that brought the bill back under control was not a cheaper model; it was retrieving fewer, better passages so each call fed the model less text.

Self-studyA note on why no pricing tables appear here2 min read

You will notice this session names shapes and ratios but not dollar-per-token vendor prices. That is deliberate and honest: model and vector-database pricing changes often enough that any table printed here would be wrong within a quarter, and quoting a specific vendor's rate would date the whole course. What does not change is the shape - one-time indexing, steady storage, per-query generation that dominates and scales with use. Learn the shape and you can drop today's live prices into it in five minutes. The one durable cost figure worth carrying is Anthropic's published contextual-retrieval number in the next section, because it is a ratio (cost per million tokens with prompt caching) rather than a list price, and it illustrates how cheap a strong quality lever can be.

Part 2 · covers the quality levers and build vs buy

Where quality is won - and the cheap levers 8 min live

Now the good news. The levers that most improve answer quality are mostly cheap, and the expensive ones give less than you would hope. Below is the lever board: on the left, high-impact low-cost moves; on the right, high-cost moves that barely move the needle. A leader's job is to keep the team reaching left before it reaches right.

Cheap wins · reach here first Expensive levers · reach here last Better chunking test the cut · big quality gain · near-zero extra run cost Add reranking re-score a small candidate set · large accuracy lift · cheap A refusal threshold say "I don't know" when retrieval is weak · trust, ~free Bigger embedding model costs to re-embed everything · modest quality gain Retrieve more passages more tokens into every call · cost up · can hurt focus Bigger language model highest per-query cost · often the smallest real gain Fix retrieval before you upgrade the model. Chunking and reranking buy more accuracy per dollar than a bigger LLM.
🔍 Click to zoom - the lever board: cheap wins on the left, expensive moves on the right
LiveThe cheap wins: chunking, reranking, and knowing when to refuse3 min

Three levers give the most quality per dollar, and none of them means buying a bigger model.

  • Better chunking. Cutting documents into the right-sized passages helps retrieval find the truly relevant text. It is a one-time index-time change with almost no extra running cost, and it caps the quality of everything downstream - so it pays back on every query forever.
  • Adding reranking. Instead of trusting the first search, you fetch a larger candidate set and re-score it, keeping only the best few. Because you rerank a small set, the cost is small - but the accuracy lift is large, since the model now sees the genuinely best passages, not just the first ones the search returned.
  • A refusal threshold. Teaching the system to say "I don't know" when retrieval comes back weak costs essentially nothing and buys the thing leaders value most: trust. An assistant that refuses when it should is worth more than one that always answers.
The reranking funnel, in one image A common, cheap pattern: retrieve a wide net of about 150 candidates, rerank them, and keep the top ~20 to hand the model. You only pay the rerank cost on that small candidate set - never on the whole corpus - which is why reranking is affordable even though scoring millions of records would not be.
LiveContextual retrieval - real numbers for a real lever3 min

Here is a concrete, published example of a cheap lever with big returns. Anthropic's contextual retrieval technique adds a short piece of context (roughly 50 to 100 tokens) to each chunk before embedding it, so a passage carries a hint of where it came from. Measured as the reduction in retrieval failures (the share of times the right passage is missing from the top 20 results, baseline 5.7%):

Lever addedReduction in retrieval failures
Contextual embeddings-35%
+ contextual keyword search (BM25)-49%
+ reranking-67%

Two-thirds fewer retrieval failures by stacking cheap levers - not by buying a bigger model. And the cost of adding that context is a one-time roughly $1.02 per million document tokens, thanks to prompt caching and a small model (Claude 3 Haiku) doing the contextualizing. That is the shape of a good RAG investment: a small, one-time index-time spend that lifts quality on every query forever.

Real world

The upgrade nobody needed. A team (anonymized) was ready to sign off on a far pricier flagship model to "fix accuracy". A quick test first added reranking to their existing retrieval and set a refusal threshold. Accuracy rose enough that the model upgrade was shelved - the fix was in retrieval, at a fraction of the cost, exactly as the lever board predicts.

Self-studyBuild vs buy - the honest frame2 min read

Most teams should buy the hard, undifferentiated parts and build only what is theirs. A managed vector database (hosted storage and fast search) and an embeddings API (someone else runs the model that turns text into numbers) let a small team stand up real retrieval in days, with predictable per-query costs and no infrastructure to babysit. Self-hosting the vector store and running your own embedding models can be cheaper at very large scale, or necessary for strict data-residency rules - but it trades a running fee for a team's time and on-call burden, which is rarely the right trade early. The leader's frame: buy the plumbing, build the parts that make your assistant yours - your documents, your chunking choices, your evaluation, your refusal policy. Session a5 turns the data-residency side of this into a governance checklist. Note that fast vector search typically returns in well under 100 milliseconds, so "buy" rarely costs you speed - it is a cost and control decision, not a performance one.

Exercise 1 of 2

Sketch the cost model for your RAG idea ★ 12 min · pen and paper

Take the RAG idea you mapped in session a2 and put money on it - not exact dollars, but the shape. The goal is to find your dominant cost before your team does.

Draw three boxes: one-time indexing (embed all our docs once), storage (monthly vector DB hosting), and per-query (query embed + optional rerank + generation).

Estimate rough size for each. You will not have exact numbers - use small / medium / large. Ask: how big is our corpus (indexing), and how many questions a day do we expect (per-query)?

Now project forward: at 10x today's usage, which box grows? Circle it. For almost every real assistant it is the per-query box, driven by generation.

Write one sentence: "Our dominant cost is ____, and the lever that controls it is ____." For most, the honest answer is "generation, controlled by feeding the model fewer, better passages".

★ Your cost-model partner (paste into any chat AI)Help me sketch the cost model for a RAG assistant. There are three buckets: one-time indexing (embed all docs once), storage (monthly vector DB), and per-query (query embedding + optional reranking + model generation). I will describe my corpus size and expected daily question volume. Walk me through which bucket dominates today and which grows fastest as usage scales, then name the single lever that most controls my dominant cost. Be honest that generation usually dominates. Here is my situation: [describe corpus size and volume]
Exercise 2 of 2

The "cheapest quality win" audit ★ 8 min · a system you have

For a RAG system you run or are considering, rank the six levers by return on spend. The exercise trains the instinct to reach left on the lever board before reaching right.

List the six levers: better chunking, add reranking, a refusal threshold (the cheap three) and bigger embedding model, retrieve more passages, bigger LLM (the expensive three).

For your system, mark which of the cheap three you have not yet done. Each un-done cheap lever is quality you are leaving on the table for almost no money.

Check whether anyone has proposed an expensive lever - a bigger model, more passages - to "fix accuracy". If so, ask whether the cheap three were tried first. Usually they were not.

Write your first move: the single cheapest lever you have not pulled. For most systems it is reranking or a refusal threshold - large accuracy or trust gain, small cost.

The order that saves money When a team says "accuracy is not good enough", the disciplined response is a sequence, not a purchase: first test chunking, then add reranking, then set a refusal threshold - and only if all three are exhausted, consider a bigger model. The contextual-retrieval numbers show why: the cheap stack removed two-thirds of retrieval failures before a bigger model was ever on the table.
Homework

Before session a4 ◐ 30 min total

★ Questions to ask your data team this week
  1. Which of our three cost buckets - one-time indexing, storage, per-query - is biggest today, and which grows fastest as we scale?
  2. Are we anywhere feeding the model more text than it needs, and what would retrieving fewer, better passages save per month?
  3. Have we added reranking and a refusal threshold - and if not, why are we considering a bigger model first?
  4. Could contextual retrieval reduce our retrieval failures, and what would the one-time contextualizing cost be for our corpus?
  5. For storage and embeddings, are we buying managed services or self-hosting - and is that a cost, control, or data-residency decision?
Source material

Official sources covered

The leader track teaches from published engineering guidance and course curricula - no vendor marketing, and no pricing tables reproduced (list prices date too fast; only durable ratios are cited). This page covers:

Anthropic · Contextual RetrievalPart 2 · the -35% / -49% / -67% failure-reduction figures and the ~$1.02 per million tokens one-time cost
Pinecone · Rerankers and rerankingParts 1 & 2 · the retrieve-wide-then-rerank funnel and why you only rerank a small candidate set
DeepLearning.AI · Advanced RAGPart 2 · quality levers and the build-vs-buy framing
Check yourself

Three questions before you go 🎯 ◐ 90 seconds

1 · Inside the per-query cost of a RAG system, the dominant expense is usually...

Generation dominates per-query cost and grows with adoption. That is why feeding the model fewer, better passages saves more than almost anything else.

2 · A team says accuracy is too low and wants to buy a bigger language model. The disciplined first move is...

The cheap levers live in retrieval. Anthropic's contextual retrieval stacked cheap levers to cut retrieval failures by two-thirds before any model upgrade was needed.

3 · Why do you rerank only a small candidate set (say ~150 fetched, ~20 kept) rather than reranking the whole corpus?

Fast vector search narrows millions of passages to a small candidate set in under 100ms; reranking that small set is cheap, while reranking everything would be prohibitively slow.

Leader session 3 cheat sheet · pin this

Three cost bucketsOne-time indexing (embed once), storage (monthly hosting), per-query (embed + rerank + generate).
Generation dominatesThe model writing the answer is the biggest per-query cost, and it grows with adoption.
The expensive anti-pattern"Paste everything" pays per token in, on every call - a bill that shocks finance at scale.
Cheap winsBetter chunking, add reranking, a refusal threshold. Reach here before buying anything.
Contextual retrieval-35% / -49% / -67% fewer retrieval failures stacking cheap levers; ~$1.02 per million doc tokens, one time.
The rerank funnelRetrieve ~150, rerank, keep ~20. You only pay rerank on the small candidate set.
Build vs buyBuy the plumbing (managed vector DB + embeddings API); build what makes the assistant yours.
The money-saving orderChunk → rerank → refuse → only then a bigger model. Fix retrieval before you upgrade the LLM.