Learn AI compute, then follow the market
← Back to Compute College

Compute College

Retrieval-augmented generation explained

Understand how an AI application retrieves external information and supplies it to a model before generation.

Plain-English definition

Retrieval-augmented generation, or RAG, is a workflow that finds relevant information from an external collection and places selected passages into a model’s context before the model generates an answer. The collection may use keyword search, embeddings, metadata filters, or a combination. Retrieval supplies evidence; it does not guarantee that the model will use the evidence correctly.

Memory trick: RAG retrieves the evidence. The model writes the answer. Evaluation checks whether the answer used the evidence.

Why it matters

A model’s trained knowledge may be out of date, lack private company information, or be too broad for a particular decision. RAG lets an application bring current, scoped evidence into the request. The tradeoff is an additional retrieval path, ingestion work, context tokens, latency, and new failure modes when the right document is not found.

  • RAG can connect a model to private or changing information without retraining the model.
  • Retrieval quality determines whether generation has the evidence needed to answer.
  • Each selected passage consumes context budget and can add retrieval and generation latency.

Simple example

For a policy assistant, the application embeds approved policy documents, filters for the employee’s region, retrieves the top candidates for the question, and provides the passages with source titles and effective dates. The answer must cite the passages or say that the available evidence is insufficient.

  • Ingestion quality affects retrieval before the model is involved.
  • Metadata filters can prevent a semantically similar but unauthorized document from entering context.
  • Citations make it easier to review whether the answer is grounded.

Example figures are illustrative calculations, not current quoted market prices.

Current example

RAG reference

RAG is a system pattern rather than a single vendor feature. This Google Cloud reference describes the retrieval and generation flow; treat its architecture language as a starting point and measure the latency, quality, and cost of the chosen implementation.

Google Cloud: Retrieval-augmented generation

Reference architecture and explanation of using retrieval to supply external information to a generative model.

Source discipline: the reference explains the concept or method; it is not a substitute for measuring a production workload under its actual provider, model, and data conditions.

Common mistake

Adding a vector database does not create grounded answers by itself. If documents are poorly chunked, stale, unauthorized, or ranked incorrectly, the model receives the wrong evidence with high confidence.

Practical takeaway

What you can do with this

Map a RAG pipeline from ingestion to answer: prepare documents, attach metadata, retrieve candidates, rerank, assemble context, generate, cite, and evaluate. Measure each stage before optimizing the model.

  • Builders: preserve source identity and effective dates through the pipeline.
  • Product teams: design an explicit insufficient-evidence response.
  • Operators: monitor retrieval misses, stale documents, latency, and context tokens.

Decision check: when retrieval finds no authoritative evidence, does the application say so instead of converting absence into a guess?

Compute College track

Prompt & Context Engineering

Step 12 of 18: Retrieval augmented generation