Lesson 6.4

The Whole Service

Every piece in one place: embed (cached), search, rerank, augment, generate, all under one latency and cost budget. This is monkrag.

concepts 9 min read

Everything you learned, on one path.

You started with four hops: embed, search, augment, generate. That was the honest skeleton. Over six units you added the parts that make it actually work, and now they all sit on one request path. A question comes in and runs the whole gauntlet, once, while the user waits.

Here is the assembled picture. Each step is a lesson you already have.

question

cache? hit returns the vector, miss embeds it (and stores it)

search the index for the nearest passages

rerank those candidates with the cross-encoder (if it earns its cost)

augment, paste the top passages into the prompt, mind the order

generate the grounded answer with citations

All of it inside one p99 budget, with one cost-per-query total. The cache sits in front of embed; rerank sits between search and augment.

Where the time and money land.

Two things wrap the whole path: a time budget and a money budget. They do not land evenly. Most of the time usually sits in generation, because the model writes token by token, and a chunk sits in reranking if you turned it on. The cache claws time back on the embed step whenever a query repeats.

The money lands wherever you call an outside model: embedding each query and miss, and generating each answer. The cache cuts the embedding bill on hits. Reranking adds compute. Searching your own index is cheap because you built it and it runs on your machine. The skill is knowing which step is the expensive one for your traffic, and spending your attention there.

What "done" looks like.

A RAG pipeline that runs is not finished. Wiring is the easy part. The senior bar, the thing that makes this a real artifact instead of glue, is the measurement. Three things mark it done.

A measured budget: a p99 number you can defend, broken down across the stages, produced by a script anyone can rerun. A written verdict on each upgrade: does the cache earn its cost, does reranking, stated in recall and milliseconds, not in adjectives. And a baseline it beats: the naive version measured the same way, so every claim of "better" has a number behind it and something to be better than.

A pipeline that runs is the start, not the finish. "Done" is a measured p99 budget, a written verdict on each upgrade in recall and milliseconds, and a baseline it provably beats. The measurement is the deliverable.

Now you write the system.

This course taught the ideas. How text becomes geometry, how nearest-neighbor search finds the right passages, how the prompt gets assembled and ordered, how the model answers from sources, how a scout and a judge sharpen the ranking, and how the whole thing holds under one budget. You have the concepts and the worked numbers behind every step.

What is left is the part where understanding sticks: the code. The course deliberately did not hand you monkrag's implementation, because the point was never to copy a system. It was to understand one well enough to build your own. So that is the handoff. You know what each hop does and why, what to measure, and what "done" means. Now go write the system, measure it honestly, and let the numbers tell you whether it earned its keep.

Key takeaways

1

The full service is the four hops plus a cache in front of embed and rerank between search and augment, all under one budget.

2

Most time lands in generation (and rerank if on); money lands wherever you call an outside model, and the cache claws both back on hits.

3

Done means a measured p99 budget, a written verdict on each upgrade, and a baseline it beats. The course gave you the ideas; now you write the system.