BuildSpark AI

Map · Retrieval & Grounding · 01 · RAG

Concept card · Retrieval & Grounding

RAG

Retrieval-augmented generation (RAG) retrieves relevant text, then asks the model to answer from that text.

Retrieve relevant text, then ask the model to answer from that text.

Last checked 2026-10-18 Free card 4 min

Ask about RAG

What changed

Oct 18: The definition uses the full name, retrieval-augmented generation. Oct 17: First card. The picture compares a question with no source and the same question with one retrieved chunk. Sources are the Gemini File Search guide, the OpenAI retrieval guide, and LlamaIndex's RAG overview.

1 What it is

Retrieval-augmented generation is the full name. This card uses RAG for short. Search returns pieces of your documents, and those pieces go into the request with the question. Gemini's File Search guide calls this retrieval augmented generation: the tool imports, chunks, and indexes files, then the retrieved text is context for the model. LlamaIndex's RAG overview says the query filters data down to relevant context, and that context and the query go to the model with a prompt.

Illustration. The question is fixed. The replies are written for this picture. They are not model output, and the search is not a live retriever.

Question: When does the warehouse close?

Picture reply

2 Why it matters

Cost

The retrieved text is still input. Gemini's File Search guide says retrieved document tokens are charged as regular context tokens, and that embeddings are charged when you index a file. OpenAI's retrieval guide says vector store storage is charged from the size of the parsed chunks and their embeddings. This card does not add a price.

Quality

The model can use the text you retrieved and cannot use a passage you left out. OpenAI's retrieval guide says retrieval is especially useful when a model then synthesizes a response. If the chunk that holds the fact was not retrieved, that fact is not in the request.

Risk

A retrieved chunk can be outdated or wrong, and the model can still add a sentence the chunk does not contain. Retrieval does not check who is allowed to see the file.

3 How to apply · try today

Take one question you answer from a document you already have. Paste only the paragraph that contains the answer, and tell the model to answer from that paragraph. Then send the same question with no paragraph.

Common mistake

Calling it RAG when the prompt has the whole file, or no file, and when you do not look at the text that was retrieved.

Self-check

You want an answer from a policy document. What is RAG?

Questions

What is retrieval-augmented generation?
Retrieval-augmented generation (RAG) retrieves relevant text, then asks the model to answer from that text.
Is pasting a whole file into the prompt the same as RAG?
No. RAG puts retrieved pieces into the request. A whole file is the file, not a retrieval step.
Does retrieval make the reply true?
No. The reply can still add a claim the retrieved text does not support, and the retrieved text can itself be wrong.