Skip to content
AI-Arena

RAG Explained

· AI-Arena Editorial

RAG — retrieval-augmented generation — is a simple contract: before the model answers, it reads your documents. It’s the standard fix for “the model doesn’t know our internal docs” and “it hallucinated our pricing.”

The Pipeline

  1. Chunk your documents into passages that each make sense alone.
  2. Embed the chunks (see Embeddings Explained) and store the vectors.
  3. Retrieve the top-k chunks nearest to the user’s question.
  4. Generate: hand the question plus the retrieved chunks to the model and ask for an answer grounded in them.

Steps 1–3 are search; step 4 is a language model with citations. Most “RAG failures” are actually search failures.

Where Quality Is Won and Lost

  • Chunking is the biggest lever. Chunks too small lose context; too large drown the signal. A paragraph that survives being read alone is the right size.
  • Retrieval sets the ceiling. If the right passage isn’t in the top-k, no model can recover. Test retrieval separately from generation: 50 real questions, check the passages, not the answers.
  • Grounding is a prompt, not a feature. Tell the model to answer only from the passages and to say “not in the documents” otherwise — then verify that behavior with adversarial questions.
  • Context budget: chunks share the same context window as conversation history. A long-context model isn’t a license to stuff; relevance still beats volume.

When RAG Is the Wrong Tool

  • Structured lookups: if the answer lives in a database row, call the database — tool use beats retrieval for exact facts.
  • Tiny static corpora: paste the docs into the prompt and skip the vector store.
  • Fresh public web answers: a browsing tool is retrieval too; RAG over your own index won’t help.

Choosing the Models

Two choices, not one: the embedding model (sticky — switching means re-encoding everything) and the generation model (swap freely). The generation side mostly needs strong instruction-following and low hallucination rates — check the cited rows on each model sheet rather than headlines. For self-hosted options, see Open Weights and the servers directory.