Lesson 0.3

The Pipeline, End to End

Four stations on an assembly line: embed, search, augment, generate. Follow one question through all four, and notice where the time and money go.

concepts 9 min read

One question, four stations.

A RAG service is an assembly line. A question enters, passes through four stations, and a grounded answer comes out. Each station does one job and hands its result to the next. Here is the whole line, then we trace a single question through it.

1

Embed

Turn the question into a vector, a list of numbers that captures its meaning. Now it can be compared to passages by meaning, not by matching words.

2

Search

Compare that vector to every passage's vector and return the few closest in meaning (the top-k). This is nearest-neighbor search over the index.

3

Augment

Build the prompt: the question plus the retrieved passages as context, kept within the model's token budget. This is where the model gets its source.

4

Generate

Call the language model, which writes the answer grounded in that context and cites the passages it used.

Trace one question.

embed   "what shipped in Q3?" → [0.12, -0.04, ...]

search   nearest 3 passages → launch-notes, changelog, faq

augment   prompt = question + those 3 passages

generate → "The billing API and SSO." [launch-notes]

Notice the data changes shape at each station: text, then a vector, then a short list of passages, then a prompt, then an answer. Each unit of this course builds one of these stations. Reranking (Unit 5) slips a smarter step between search and augment.

Where the time and money go.

Four stations chained together means four places to spend time and money. Embedding and the model call usually dominate the clock; the model call usually dominates the bill. Because the stations run in sequence, the total time is their sum, and the slowest one drags the whole answer.

That is the question monkrag's second stage is built to answer, with real numbers: where does each millisecond and each cent go, and which upgrades (a reranker, a cache) actually earn their cost? A pipeline that works is v1. A pipeline you can account for is the senior part.

The pipeline is four hops in sequence, so latency adds up and the slowest hop sets the pace. Measuring that budget, not just wiring the hops, is the whole point of v2.

Key takeaways

1

A RAG service is four stations in order: embed, search, augment, generate.

2

The data changes shape at each hop: text, vector, passages, prompt, answer.

3

Because the hops run in sequence, latency adds up, which is why measuring the budget is the senior work.