Simple RAG: single-pass embedding retrieval done properly

Simple RAG searches by meaning, passes the best chunks to the model, and asks for cited answers or an honest 'I do not know'. Use it for support and FAQ bots with predictable questions.

Simple RAG in 60 seconds

  • What: one retrieval by embedding similarity, one grounded prompt, one answer with citations.
  • What makes it simple, not naive: sensible chunking, metadata, a similarity threshold, and a prompt that allows 'I do not know'.
  • Best for: FAQ, help-centre, and policy bots where questions are predictable and answers live in one place.
  • Weak spots: questions that need several sources, vague questions, and anything that needs a feedback loop.
  • Origin: the original RAG paper (Lewis et al., 2020) set out the retrieve-then-generate idea this pattern builds on.

Where this type fits

Simple RAG is in the single-pass family with naive RAG and RAG with memory. It runs one retrieval and one generation per question. Many sources use 'simple' and 'naive' for the same thing. Here they differ: naive RAG is the bare minimum, and simple RAG is the same shape built with care. See the overview of RAG types for the full map.

The problem it solves

A bare pipeline fails in boring, repeatable ways. Documents are split at arbitrary points, so a sentence about the refund window ends up in one piece and its exception in another. Keyword search misses a question phrased differently from the text. The prompt does not say what to do when the answer is absent, so the model improvises. None of these failures needs a clever algorithm to fix. They need ordinary engineering.

Think of a library. Naive RAG is a librarian who grabs three books that mention your words and slides them over. Simple RAG is a librarian who has indexed the books by topic, brings back the relevant chapters rather than whole shelves, tells you which book each fact came from, and says 'we do not have that' when it is true.

This is also where most of the value is. For a large share of real products (a help-centre bot, an internal policy assistant, a product documentation search), a careful single pass is enough. The more elaborate types on this site exist for questions this pattern cannot handle, so it pays to know exactly where its limits are before reaching for them.

How it works

  • Prepare once, offline: split each document into chunks of a few hundred words along natural boundaries such as headings and paragraphs, with a small overlap. Attach metadata to each chunk: source title, section, version, language, and who may read it.
  • Embed and store: turn each chunk into an embedding and store it in a vector index with its metadata.
  • Embed the question: at question time, use the same embedding model, since vectors from different models cannot be compared.
  • Filter and search: apply metadata filters first (permissions, product, language), then fetch the top k nearest chunks by similarity.
  • Apply a threshold: drop chunks whose similarity is below a minimum. If nothing is left, skip generation and reply that the answer was not found.
  • Build a grounded prompt: place the chunks in labelled slots, tell the model to answer only from them, cite the labels, and say 'I do not know' when the context is not enough.
  • Generate and return: return the answer with its citations so the reader can open the source.
An offline row builds the index; an online row answers each question with one search and one generation.

The two lanes matter for ownership. The offline lane is a data pipeline: it runs when documents change, and its quality sets the ceiling for everything else. The online lane is a request path with a latency budget. Bugs in the first lane look like model problems in the second, so keep the chunks visible in your logs.

The threshold step is the one most often skipped, and it is cheap. Similarity search always returns something, even for a question about the weather in a document set about tents. Without a minimum score, the model is handed unrelated chunks and asked to answer anyway. With one, the system can decline before spending a model call.

A worked example

Acme Outdoors has indexed its help centre into 240 chunks. Each carries metadata such as doc: returns-policy, section: Unused items, version: 2026-09, and audience: public. A customer asks: 'Can I send back a tent I never opened?'

  • Embed: the question becomes a vector. It shares almost no words with the policy, but the meaning is close.
  • Filter: the search is limited to audience: public, so internal staff notes are never candidates.
  • Search: the top 4 chunks by similarity are 'Unused items: 60-day returns' (0.82), 'Return shipping and labels' (0.71), 'Opened or used items' (0.64), and 'Tent care guide: pitching' (0.41).
  • Threshold: the minimum is 0.55, so the tent care chunk is dropped. Three chunks remain.
  • Prompt: the chunks are labelled [1], [2], [3] with the instruction to answer only from them and cite labels.
  • Answer: 'Yes. Unused items can be returned within 60 days of delivery [1]. A prepaid label is available from your order page [2].'
  • Return: the reply includes links to the two cited sources.
The chunk records behind that request (illustrative) (python)
chunks = [
    {'id': 'returns-3', 'doc': 'returns-policy', 'section': 'Unused items',
     'version': '2026-09', 'audience': 'public', 'score': 0.82},
    {'id': 'returns-5', 'doc': 'returns-policy', 'section': 'Return shipping and labels',
     'version': '2026-09', 'audience': 'public', 'score': 0.71},
    {'id': 'returns-4', 'doc': 'returns-policy', 'section': 'Opened or used items',
     'version': '2026-09', 'audience': 'public', 'score': 0.64},
]  # the fourth chunk (score 0.41) fell below the 0.55 threshold

Notice what the metadata bought. The version tag lets the team tell which policy text produced the answer. The audience filter kept internal notes out. The score made the weak match drop out, and the citations let a reader verify the claim in seconds.

Building it

The code below shows the online lane. embed(), vector_store, and llm are placeholders for your own embedding model, index, and model client. The offline lane is one loop that chunks, embeds, and writes records in the same shape.

Simple RAG online path (illustrative) (python)
# Illustrative only. embed(), vector_store and llm are placeholders.

TOP_K = 5
MIN_SCORE = 0.55          # tune on your own evaluation set
MAX_CONTEXT_CHARS = 6000  # keeps cost and latency predictable
TIMEOUT_SECONDS = 20

NOT_FOUND = 'I could not find this in the documentation.'

SYSTEM_RULES = (
    'Answer using only the numbered sources below. '
    'Cite sources like [1]. '
    'If the sources do not contain the answer, reply exactly: I do not know.'
)


def retrieve(question, user):
    query_vector = embed(question)  # placeholder: same model as the index
    # Filter by permission BEFORE ranking, so restricted text never appears.
    hits = vector_store.search(
        vector=query_vector,
        top_k=TOP_K,
        filter={'audience': user.allowed_audiences},
    )
    # Similarity search always returns something, so apply a floor.
    return [h for h in hits if h.score >= MIN_SCORE]


def build_prompt(question, hits):
    blocks, used = [], 0
    for number, hit in enumerate(hits, start=1):
        text = hit.text[: MAX_CONTEXT_CHARS - used]
        if not text:
            break
        blocks.append('[' + str(number) + '] (' + hit.doc + ', ' + hit.section + ')\n' + text)
        used += len(text)
    sources = '\n\n'.join(blocks)
    return SYSTEM_RULES + '\n\nSources:\n' + sources + '\n\nQuestion: ' + question


def simple_rag(question, user):
    hits = retrieve(question, user)
    if not hits:
        return {'answer': NOT_FOUND, 'sources': []}  # skip the model call

    prompt = build_prompt(question, hits)
    answer = llm.generate(prompt, timeout=TIMEOUT_SECONDS)  # placeholder
    return {
        'answer': answer,
        'sources': [{'doc': h.doc, 'section': h.section, 'version': h.version} for h in hits],
    }

Two choices are worth explaining. The empty-hits branch returns before any model call, which saves money and removes a chance to invent an answer. The character cap bounds the prompt size, so a document with unusually long chunks cannot blow up cost or latency on one request.

Design decisions

  • Chunk size and overlap: start with 200 to 400 words along headings, with a small overlap, and tune on your questions. Small chunks retrieve precisely but lose context, and large chunks carry noise. See vector search and chunking.
  • Storage: a managed or self-hosted vector index with metadata filtering is the default. Choose one that filters before ranking, since post-filtering can return empty results for restricted users.
  • Access control: store permissions as metadata and filter in the query, never in the prompt. Prompts are not a security boundary. See security.
  • Re-indexing and versions: re-embed changed documents only, tag chunks with a version, and keep the old index until the new one passes your evaluation. Mixing embedding models in one index breaks similarity.
  • Latency: one embedding call, one search, one generation. Cache embeddings of frequent questions and stream the answer. See caching types.
  • Failure handling: timeouts on each call, a fixed fallback message when retrieval is empty, and a clear error path when the model call fails. There is no loop, so there is no retry storm to fear.
  • Cost: prompt tokens dominate. Control them with k, the context cap, and the threshold, and track cost per answered question.

Measuring it

  • Recall at k: the share of test questions whose source chunk appears in the top k. Compute it on a labelled set of at least a few dozen real questions.
  • Mean reciprocal rank: for each question, take 1 divided by the position of the first correct chunk, then average. It rewards putting the right chunk first.
  • Citation accuracy: for each cited label, check whether the cited chunk really supports the sentence it is attached to.
  • Faithfulness: the share of claims in the answer that the retrieved chunks support, labelled by people or a grading prompt.
  • Decline quality: on questions with no answer in the documents, measure how often the system declines, and on answerable questions, how often it wrongly declines. Tune the threshold using both.
Mean reciprocal rank on a labelled set (illustrative) (python)
# test_set: list of {'question': str, 'source_id': str} (placeholder data)
# search_ids(question, k) returns ranked chunk ids (placeholder)

def mean_reciprocal_rank(test_set, k=5):
    total = 0.0
    for case in test_set:
        ranked = search_ids(case['question'], k)
        if case['source_id'] in ranked:
            total += 1.0 / (ranked.index(case['source_id']) + 1)
    return total / len(test_set)

When to use it, and when not to

SituationUse this type?Why
FAQ or help-centre bot with predictable questionsYesAnswers sit in one or two chunks, and one retrieval finds them.
Internal policy or documentation searchYesCitations let staff verify the source quickly.
Latency-sensitive chat with a tight budgetYesOne search and one generation is the cheapest dependable design.
Follow-up questions in a conversationNot aloneAdd memory so 'what about the blue one?' makes sense.
Questions that combine several documentsNoA single pass rarely gathers every needed piece. Consider agentic or branched designs.
Vague or badly phrased questionsNot aloneQuery rewriting in advanced RAG helps.
Facts that change by the minuteNoIndexes lag behind live data. Query the live source through a tool instead.

Trade-offs

DimensionEffectWhat to do about it
QualityStrong when answers live in one chunk. Weak on multi-source or vague questions.Check recall on real questions. Upgrade to advanced RAG where it is low.
LatencyLow and predictable: one embedding, one search, one generation.Stream the answer and cache frequent question embeddings.
CostModest. Prompt tokens are the main line item.Limit k, chunk length, and context size.
ComplexityA data pipeline plus a short request path. Easy to run and debug.Invest in logging chunks and scores per request.
Failure modesPoor chunking, stale index, wrong threshold, permission leaks, citations that do not support the claim.Test each stage on its own, and check citations as well as answers.

Against naive RAG, the difference is care rather than architecture: the same single pass, but with chunking, metadata, thresholds, and a grounded prompt. Against advanced RAG, simple RAG leaves out the extra stages (query rewriting, hybrid search, reranking, answer checks), so it is cheaper and faster but less robust on messy questions. Against RAG with memory, it treats every question as standalone, so a follow-up such as 'and the blue one?' loses its meaning.

What this means for your role

Common mistakes

Further reading

A careful single pass is often all a knowledge bot needs. Build it well, measure it on real questions, and move to a more elaborate type only when the numbers say so.

Search topics

↑↓ to move · Enter to open · Esc to close