Intermediate #rag#embeddings#retrieval#llm

How a RAG answer actually gets built

Retrieval-augmented generation, one stage at a time: chunking, embeddings, hybrid search, reranking and grounded answers. Watch where accuracy is won and lost before the model ever writes a word.

Note: this is an illustrative client-side model — the numbers teach the why, they aren't from a real database.

Step 1 of 7

The model has never seen your documents

A language model knows what was in its training data. It does not know your refund policy, last quarter's numbers, or the runbook your team wrote in March.

Ask anyway and you get fluent, confident, wrong. Retrieval-augmented generation fixes the input rather than the model: find the right passages first, then ask the question with those passages attached.

WatchEverything that follows is about one thing: putting the correct passage in front of the model.
Question→Model→Guess
Question user asks
Model training data only
Answer plausible, unverifiable

No retrieval step: the model answers from memory alone.

Right chunk retrieved
0%
Context tokens sent
—
Answer grounded
No
Added latency (ms)
—

Nothing here is checkable. The model cannot cite a source it never saw.

Run this simulator free

Sign in once to unlock every simulator. Takes 20 seconds.

Questions people ask about this

What chunk size should I use?+

There is no universal number, which is why splitting on document structure beats splitting on a character count. Start by keeping each heading with its section, cap chunks at a few hundred tokens, and add a small overlap so a sentence split across a boundary still appears whole in one chunk. Then measure recall on real questions rather than guessing.

Do I still need keyword search if I have embeddings?+

Usually yes. Vector search matches meaning, so it handles paraphrasing well but is unreliable on exact strings such as error codes, SKUs, version numbers and surnames. Running both and fusing the ranked lists is the standard fix and is typically the largest single accuracy win in a weak system.

What is reciprocal rank fusion?+

A way to merge several ranked lists without comparing their scores. Each document scores one divided by a constant plus its rank in each list, and the sums are added. Because only positions matter, you avoid trying to normalise a cosine similarity against a keyword relevance score.

Why retrieve twenty chunks and then send four?+

The first search is fast and approximate so it can run across millions of chunks. A reranker reads the question and a candidate together and scores them accurately, but is far too slow for the whole corpus. Retrieving wide and reranking narrow combines the speed of one with the accuracy of the other.

Does RAG eliminate hallucination?+

No. It reduces it and, more importantly, makes it detectable. If every claim must cite a passage, an unsupported claim is a failure you can catch automatically in evaluation, rather than a plausible sentence nobody questions.

Should I fine-tune instead?+

They solve different problems. Fine-tuning teaches format, tone and task behaviour. Retrieval supplies facts that change, and it lets you update an answer by editing a document instead of retraining. Most production systems need retrieval first and fine-tuning only afterwards, if at all.