AlgoViz

Retrieval-Augmented Generation (RAG)

medium 12 min

A retrieval-augmented system maintains a searchable collection and consults it for each question.

Trace the example

Follow the evidence through each stage, then test a change in the case.

Which refund policy reached the answer?

Which refund policy reached the answer?. Selected component: Source revision inside Policy collection.
Open full-size diagram

Policy collection

Policy v7 · 30 days

A revised policy extends the return period. Give its passages stable identifiers and retire superseded entries when the new index is published.

The answer says 14 days and the prompt contains only v6. Where should you investigate first?

Try a retrieval query

See it work

  1. Query“How do refunds work?”
  2. EmbeddingsConvert to a vector
  3. Vector indexSimilarity search over your data
  4. Retrieve (top-k)Keep the most relevant chunks
  5. LLMAnswer using the retrieved evidence

Chunks in the index

  • Refund timing
  • Refund policy
  • Exceptions
  • Shipping
  • Returns label
  • Warranty
1/7

Step 1 of 7 — the user asks a question

Why it matters: everything downstream depends on what the question actually says.