Skip to content
Resources
Article

RAG: definition and architecture, lessons from Quivr

What RAG is, which parts it is made of, and why its quality is decided in retrieval: Quivr's measurements, from chunk size to response time.

Stan GirardStan Girard, Co-founderTuesday, December 1, 202611 minπŸ‡¬πŸ‡§πŸ‡«πŸ‡·
The Vibe Company mascot in a library, sorting index cards into two trays, one labeled search and one labeled answer

RAG (retrieval-augmented generation) is an architecture that fetches the right passages from your documents, then hands them to a language model so it can answer and cite its sources. It runs in two phases: index first, then retrieve and answer. Its quality depends first on retrieval.

A RAG system that answers wrong sounds as confident as one that answers right. On a diagram, the two look identical.

This guide walks through the architecture part by part. It adds what I measured in late November, during an automated tuning campaign on Quivr, The Vibe Company's open-source engine.

Updated December 1, 2026.

What does RAG mean?

RAG stands for retrieval-augmented generation. The term comes from a 2020 research paper. Its authors worked at Facebook AI Research, University College London and New York University.

Their idea pairs two memories. The first belongs to the language model and lives in its parameters. The second is an index of documents that the model consults before it answers. In the paper, that index held Wikipedia.

A model working alone has flaws, which the authors list. It can't easily expand or revise its memory. It can't straightforwardly explain its predictions. It may produce "hallucinations", meaning made-up answers. With an index, they write, knowledge can be revised and expanded directly, and you can inspect what the model accessed.

In 2023, I created Quivr with Antoine Dewez on that principle. You ask a question, it answers from your files.

That leaves the parts such a system is made of.

What is the architecture of a RAG system?

The architecture of a RAG system has two phases. Indexing prepares your documents ahead of time. The query phase runs again for every question.

Some vocabulary first. A chunk is a passage cut out of a document for search. You count its size in tokens, the word fragments a model reads. An embedding model turns each chunk into a vector: a list of numbers that captures what it means, as Quivr's documentation puts it. BM25 is a keyword search algorithm. A reranker is a model that puts the retrieved chunks back in order. The prompt is the text sent to the model.

PhasePartRoleWhat Quivr does or measured
Indexing1. Store the originalKeep the referencePostgreSQL records every document and version, object storage keeps the original bytes
Indexing2. Extract the textRead the filesA reader plugin extracts the text of a PDF
Indexing3. Cut into chunksGive search its piecesChunks searchable by keyword, usually within a second. On the campaign's news dispatches, 768 tokens beat 192 and 1024
Indexing4. Compute the vectorsMake meaning searchableOne vector per chunk
Indexing5. Fill the indexSearch fastQuivr's search index (Weaviate) holds a copy of the text and vectors
Query6. RetrieveFind the chunks, by keyword and by meaningKeywords, meaning, or both. On the campaign's news dispatches: 65% meaning, 35% keywords
Query7. RerankBring the best chunks to the topOn Quivr: 77 ms without a reranker, 7.13 s with one (time 95% of queries stay under)
Query8. AnswerBuild the prompt, generate a cited answerEvery result points to the exact passage, document and version

Two of Quivr's choices sit between those lines.

First, the index is disposable. PostgreSQL and object storage hold the real data. The search index is a copy, and Quivr's repository states that it can always be rebuilt. To change the embedding model, for example, the index rebuilds while search keeps answering from the old one.

Second, search tells the truth. Quivr checks every result against stored content and against the caller's access before returning it. When a service it depends on is down, search returns an error, never an empty "nothing found". The nuance matters. A wrong "nothing found" suggests the document doesn't exist.

In that table, every part gets one row. In production, the retrieval rows decide almost everything.

Why does retrieval decide the quality of RAG?

Retrieval decides the quality of RAG because the model can only cite what retrieval brings it. The model never reads a passage left out of the prompt.

I measured it in late November 2026, with 508 autoresearch runs on a search engine. The engine was Quivr, at a media client, over French news dispatches. Autoresearch is a loop where AI agents test a setting, measure, then keep or discard. The campaign tracked one score, nDCG@10. It rises when the right documents reach the top ten results.

The embedding model and Weaviate stayed fixed during the campaign. So the gain came from elsewhere: chunking and retrieval settings. On 7 topics never seen during tuning, default Quivr scored 0.6694. The fast setting that came out of the campaign, called the fast tier, scores 0.7540. That is 8.5 points more.

Three settings mattered.

Chunk size. On the working topics, the ones used for tuning, the score is 0.8381 with 192-token chunks. It climbs to 0.9133 with 768, then drops back to 0.8856 at 1024. Small chunks tear passing mentions out of their context. They also multiply vector memory, by 1.24 to 2.44. The winning setting keeps 768 tokens, with the title in the first chunk.

The words of the query. Stopwords are the small words with no content of their own. Stripping them, along with French elisions (l', d', qu'), before keyword search adds 0.0174 nDCG@10.

The balance between meaning and keywords. Embeddings can miss an exact match, as Anthropic explains in its post on Contextual Retrieval. BM25 finds it, for example on a unique identifier or a technical term. Hence hybrid search, which combines the two. On the dispatches, the mix that won gives 65% of the weight to meaning and 35% to keywords. Three signals come on top: they push up the dispatch that covers the subject from its title. With them, the fast tier goes from 0.8624 to 0.9026 on the working topics. None of the 11 topics regresses.

One well-known technique lost, though. Anthropic suggests adding a short piece of context to each chunk before indexing it. In its tests, that method combined with BM25 cuts failed retrievals by 49%. With reranking, 67%. In the campaign, those contextual prefixes trailed the baseline by 0.0063 to 0.0200. These dispatches are short: more than 62% fit in a single chunk.

Both results hold, each on its own documents. So judge a retrieval technique on yours. Relevance is half of the measurement. The other half is time.

What response time can a RAG system hold?

On the retrieval side, RAG can hold 77 ms or 7.13 s: those are the two tiers measured on Quivr, without and with reranking. The right number depends on who is waiting for the answer.

I faced that choice with the first Quivr. The team aimed for a quality answer in under 5 seconds. A good answer usually took 30. That is the story of the chatbot too slow for a waiting customer. By email, on Zendesk, 30 seconds to 1 minute to draft a reply bothered nobody. That is why Quivr pivoted to customer support.

The November campaign replays that trade-off inside retrieval. The fast tier answers in 77 ms at p95: 95% of queries come in under that time. No GPU at query time. The deep tier adds the Qwen3-Reranker-4B reranker and climbs to 7.13 s.

That time buys a better nDCG@10, the score the campaign tracked: 0.7987 versus 0.7540. Measured on judgments from human annotators, the gap disappears. The fast tier scores 0.3981, the deep tier 0.3982. A tie.

Anthropic's tests conclude that reranking is better than no reranking. This case adds the bill. On its own, 7.13 s of retrieval exceeds the 5 seconds the Quivr chatbot was aiming for. Reranking is a decision to make per use case.

All of that assumes RAG is the right architecture for your need.

Do you always need RAG?

No, you don't always need RAG. Under 200,000 tokens, about 500 pages, Anthropic says you can put your whole knowledge base in the prompt, with no RAG. Count your pages first.

Another limit: RAG reads your documents and stops there. To open a ticket or update a record, you need AI agents for business, equipped with tools. The two combine. With the quivr mcp command, an agent searches Quivr and quotes what it finds, with the source of every passage.

Then comes the question of who may read what. It has its own page: access rights and source citations in enterprise RAG.

One last reason not to answer "RAG" to every need, from Quivr's own history: too many use cases. One customer wanted to analyze thousands of PDFs. Another, web search. A third, charts from CSV files. Better to open RAG on a single use case, and to start with measurement.

Where should a RAG project start?

Start a RAG project with measurement, before the first setting. Five steps, in order.

  1. Write real questions, each with its reference document. Split that set in two before any tuning. In the November campaign, 11 topics served for tuning and 7 stayed locked.
  2. Start simple, with hybrid search. In Anthropic's tests, embeddings plus BM25 beat embeddings alone.
  3. Measure retrieval separately from the answer. A score such as nDCG@10 tells you whether the right passage comes up. If it doesn't, the model has nothing correct to cite.
  4. Test one idea at a time, then confirm on the locked part. That is how the campaign discarded contextual prefixes.
  5. Put latency in the decision. Quivr's public threshold requires a p95 under 400 ms on the worst query set. The 7.13 s tier does not meet it.

The winning setting is public, in Quivr PR #4043, merged on November 28, 2026.

Once you have measured retrieval, the rest has its checklist: moving an AI agent from POC to production, then putting RAG or AI agents in production.

A RAG system that answers wrong and one that answers right share the same diagram. What separates them comes down to two numbers, taken on locked questions: the retrieval score and the response time.

FAQ

RAG vs fine-tuning: what is the difference?

Fine-tuning changes the model itself, by continuing its training on your examples. RAG leaves the model untouched and gives it your documents to read at every question. The 2020 paper highlights the advantage of an index: knowledge kept in an index can be revised and expanded directly.

Do you need a vector database for RAG?

A RAG system that searches by meaning needs an index that stores vectors. Quivr uses Weaviate for that index. That index is only a copy of the data held in PostgreSQL and object storage.

What is agentic RAG?

Agentic RAG here means an AI agent that calls search as a tool, which quivr mcp allows. The agent searches and quotes what it finds, with the source of every passage.

Does RAG remove hallucinations?

No, RAG reduces hallucinations without removing them. The 2020 paper measured RAG models as more factual than a model with no index. More factual does not mean error-free. RAG answers better when retrieval brings the right passage.

Is there an open-source RAG engine?

Yes, Quivr is an open-source engine, under the MIT license. Its GitHub repository, created in May 2023, had 39,665 stars on December 1, 2026. Quivr 2 stores content, searches it by keywords, by meaning or both, and alerts you on the topics you follow. It covers the retrieval part of RAG.

If you have a RAG system to launch or audit, book a call with me and bring your real questions.