Applied AI

What Is a RAG Chatbot? Architecture, Failure Points and Evaluation

How retrieval augmented generation actually works, the seven ways retrieval fails, and how to tell whether yours is any good.

AL
Aryma Labs
Aryma Labs
19 min read

Definition

A RAG chatbot is a conversational system that retrieves relevant passages from an external knowledge base at query time and passes them to a language model as context, so answers are grounded in a controlled corpus rather than in model weights alone. Retrieval quality, not model choice, is what determines whether the answers are trustworthy.

A RAG chatbot is a conversational AI system that searches a private knowledge base for relevant passages and passes them to a large language model, which answers using only that retrieved evidence. RAG stands for retrieval augmented generation. The retrieval step grounds every response in source material, so answers stay current and can be traced back to a citable document.

That definition is the easy part. The harder part, and the part most explanations skip, is that a RAG chatbot is not really a chatbot project. It is a retrieval engineering project with a chat interface bolted on the front. We learned that building MMMGPT, a RAG chatbot trained on more than ten years of marketing mix modeling, causal inference and experimentation knowledge. Almost every quality problem we have shipped a fix for lived in retrieval, not in the model. This piece is written from that side of the problem.

What retrieval augmented generation actually is

The term comes from a specific paper. In Lewis et al., 2020, presented at NeurIPS that year, the authors combined a pre-trained sequence-to-sequence model with a dense vector index of Wikipedia accessed by a neural retriever. They called the model weights parametric memory and the external index non-parametric memory. The reported result was state of the art on three open-domain question answering tasks, with language that was more specific, diverse and factual than a parametric-only baseline.

That split is still the whole idea. A language model's weights are a compressed, frozen summary of whatever it saw during training. They cannot be updated cheaply, they cannot be audited, and they cannot tell you where a fact came from. An index can be updated this afternoon, inspected line by line, and cited.

Retrieval augmented generation simply means putting the second kind of memory in front of the first, and making the model answer from what it was handed rather than from what it happens to remember.

What is a RAG chatbot?

A RAG chatbot is the applied form of that technique: a multi-turn conversational interface where every user question triggers a retrieval against a controlled corpus before generation happens. The chatbot part matters more than it sounds, because conversation adds requirements that single-shot RAG does not have.

  • Query rewriting. "What about last quarter?" is meaningless to a retriever. The system has to resolve the follow-up against conversation history into a standalone query before it searches.
  • State without contamination. Earlier turns need to inform the current answer without earlier retrieved chunks silently persisting into a new topic.
  • Citation surfacing. A chat answer that cannot show its sources is indistinguishable from a confident guess, which defeats the point.
  • Refusal behaviour. When retrieval returns nothing useful, the correct output is "I do not have that", not a fluent paragraph assembled from adjacent material.

So a search engine that speaks is not a RAG chatbot, and a language model with a nice interface is not one either. The defining property is that the answer is constrained by retrieved evidence and traceable back to it.

How a RAG chatbot works

There are two separate pipelines, and confusing them is the most common source of muddled architecture diagrams. One runs offline on a schedule. The other runs on every single question.

AWS describes the standard mechanism in four steps: create external data as vector representations in a database, retrieve relevant information by matching the query vector against that database, augment the model prompt with what came back, and update the external data on a real-time or batch schedule. The benefits it names are the ones that hold up in production, namely lower cost than retraining, current information, source attribution that builds user trust, and more developer control over what the model sees.

INDEXING runs offline, on a schedule Source documents PDFs, decks, tickets, wikis Chunk split + attach metadata Embed chunk becomes a vector Vector index chunk text + embedding + metadata (source, date, permissions) top-k chunks ANSWERING runs on every question User question rewritten in context Embed query same model as index Retrieve hybrid + rerank Augment prompt context + rules Generate answer + citations What breaks here semantic gap missed top documents lost in the middle not extracted wrong embedding fit bad chunk boundaries token budget overflow wrong format
The two pipelines inside a retrieval augmented generation chatbot. Indexing is a batch job; answering is a request path. Most quality problems are created in the top row and only become visible in the bottom one.

The asymmetry in that diagram is the practical lesson. Chunking decisions made once during indexing constrain every answer the chatbot will ever give, but you cannot see their effect until a user asks a question that lands across a bad boundary.

RAG chatbot architecture and components

Strip away vendor naming and a RAG chatbot architecture has six parts. What matters is not the list, but who owns each failure.

Component Responsibility Typical failure it causes
Knowledge base Holds the source of truth and its refresh schedule Answer is confidently wrong because the source was never ingested or is stale
Chunker Splits documents into retrievable units and attaches metadata The right document exists, but the answer sits across two chunks, so neither is sufficient
Embedding model Maps text to vectors so meaning can be compared Query and document use different vocabulary for the same concept and never match
Vector store and retriever Returns the candidate set for a query, with filters The right chunk exists and is never returned, or is returned below the cut-off
Orchestration layer Rewrites queries, routes, assembles the prompt, enforces limits Follow-up questions retrieve against the wrong topic, or context is truncated silently
Generator (the LLM) Writes the answer from the supplied context Ignores supplied evidence, ignores format instructions, or fills gaps from memory

Two components on that list get almost all of the attention in tutorials, namely the vector store and the LLM, and they are the two least likely to be the cause of a bad answer. The chunker and the orchestration layer get almost none, and they cause most of them.

RAG chatbot vs traditional chatbots, fine-tuning and long context

The comparison people actually want is not RAG against rule-based bots. It is RAG against the other three ways to make a model know something.

Rule-based chatbot LLM only Fine-tuned model RAG chatbot
Knowledge source Hand-written decision tree Frozen training data Frozen training data plus tuned behaviour Live external index
Updating knowledge Edit the tree Wait for the next model Retrain or re-tune Re-index the changed documents
Can cite sources Not applicable No No Yes, by design
Handles unseen phrasing Poorly Well Well Well
Cost of a knowledge change Low but manual Not possible High Low
Genuinely best at Deterministic flows and transactions General reasoning and writing Style, tone and output structure Factual answers over a corpus that changes

The important row is the last one. Fine-tuning teaches a model how to behave. Retrieval tells it what is true right now. They solve different problems and combine cleanly, which is why framing RAG against fine-tuning as competitors misleads people into picking one when the honest answer is often both, or neither.

How to build a RAG chatbot

The build order that survives contact with real users looks like this.

  1. Define the corpus and its refresh contract. Which sources, who owns them, how often they change, and what happens to the index when they do. Get this wrong and everything downstream inherits the error.
  2. Parse and clean before you chunk. Tables, headers, footers and boilerplate cause more retrieval noise than any hyperparameter. Extraction quality sets your ceiling.
  3. Chunk structurally, not arbitrarily. Split on document structure such as headings and sections wherever the format allows, and fall back to fixed windows with overlap only where it does not.
  4. Attach metadata at index time. Source, date, document type, owning team, access level. Metadata you did not capture during indexing is metadata you cannot filter on later.
  5. Retrieve with hybrid search, then rerank. Vector similarity alone misses exact identifiers, product names and codes. Keyword search alone misses paraphrase.
  6. Constrain the generator explicitly. Instruct it to answer only from the supplied context, to cite, and to refuse when that context is insufficient. Refusal is a feature.
  7. Build the evaluation set before launch, not after. A hundred real questions with known-correct source documents are worth more than any amount of prompt tinkering.

Steps five and seven are where teams under-invest, and they are the two that decide whether the thing is still trusted six months in.

Related product

MMMGPT

A RAG-based AI trained on a decade of marketing mix modeling, answering with sourced, grounded responses.

See MMMGPT

Chunking, hybrid search and reranking decide answer quality

Most RAG chatbot content asserts that retrieval quality matters, then moves on. It is possible to be more precise than that, because the effect has been measured.

Anthropic published benchmarks in September 2024 for stacked retrieval techniques, measured as the failure rate of the top 20 retrieved chunks:

  • Contextual embeddings alone reduced the retrieval failure rate by 35 percent, from 5.7 percent to 3.7 percent.
  • Contextual embeddings combined with contextual BM25, which is keyword search running alongside vector search, reduced it by 49 percent, from 5.7 percent to 2.9 percent.
  • Adding a reranking step on top of both reduced it by 67 percent, from 5.7 percent to 1.9 percent.

Read that as a hierarchy of leverage. The single biggest improvement available to most RAG chatbots is not a better language model. It is putting keyword search next to vector search, and then reordering what comes back.

Microsoft's Azure AI Search guidance reaches the same conclusion from a platform perspective, recommending hybrid queries that combine keyword and vector search for maximum recall, then semantic ranking and vector weighting for relevance. It also names the five constraints every production retrieval system runs into: query understanding, multi-source data access, token constraints, response time expectations, and security and governance.

There is a related reason not to solve retrieval by simply retrieving more. Liu et al., "Lost in the Middle" found that model performance is highest when relevant information sits at the beginning or the end of the input context, and degrades significantly when the model has to use information buried in the middle of a long context. Stuffing thirty chunks into a prompt does not raise the chance of a correct answer proportionally. It raises the chance that the one useful chunk lands in the position the model attends to least. Ordering is a design decision, not an implementation detail.

Where RAG chatbots break, and how to diagnose it

The most useful engineering artefact in this field is the failure taxonomy in Barnett et al., 2024, which drew seven named failure points from three case studies across research, education and biomedical domains. Mapped to what a user actually reports, it becomes a diagnostic table.

What the user says Failure point Where it lives What to change
"It made that up entirely" FP1 Missing Content Ingestion The source was never indexed, or the parser dropped it. Fix coverage, then teach the system to refuse
"The answer is in our handbook, page four" FP2 Missed the Top Ranked Documents Retrieval Hybrid search, reranking, per-source thresholds, a larger initial candidate pool
"It found the right document and answered half the question" FP3 Not in Context Consolidation Too many candidates collapsed into too small a context window. Rerank and cut, do not truncate blindly
"Everything it needed was right there" FP4 Not Extracted Generation Context was noisy or too long. Reduce top-k, reorder, tighten the instruction to use only supplied evidence
"I asked for a table and got prose" FP5 Wrong Format Prompting The format instruction is drowned out by retrieved context. Move it after the context, or enforce structured output
"Too vague" or "far too much detail" FP6 Incorrect Specificity Chunking and prompting Chunk granularity does not match question granularity. Consider indexing at more than one chunk size
"It only covered two of the three products" FP7 Incomplete Query planning One query cannot cover a multi-part question. Decompose it and retrieve per sub-question

The paper's broader conclusion is the one worth internalising: validation of a RAG system is only feasible during operation, and its robustness evolves rather than being designed in at the start. You cannot specify your way to a reliable RAG chatbot in advance. You can only instrument it and iterate.

How to evaluate a RAG chatbot

This is the single largest gap in public writing on the subject, and the thing most teams discover they never built. "It seems good" is not an evaluation.

A workable evaluation harness has four layers.

  • A golden question set. Fifty to two hundred real user questions, each labelled with the document or documents that contain the answer. Build it from actual support tickets and internal queries, not from imagination.
  • Retrieval metrics, measured separately from generation. Recall at k tells you whether the right chunk made it into the candidate set at all. If recall at k is poor, no prompt change will save the answer. Measuring retrieval in isolation is what stops teams tuning the generator to compensate for a broken retriever.
  • Groundedness and answer relevance. Groundedness, sometimes called faithfulness, asks whether every claim in the answer is supported by the retrieved context. Answer relevance asks whether the response addresses the question. A response can be perfectly grounded and completely unhelpful.
  • Regression testing after every re-index. Re-embedding a corpus, changing chunk size or swapping an embedding model silently changes every retrieval in the system. Run the golden set before and after, then compare.

Underneath all of it sits tracing. If you cannot see the exact chunks that produced yesterday afternoon's bad answer, you are debugging by reconstruction. We wrote separately about how we instrument every MMMGPT query end to end, and the operational payoff is simple: logging retrieved context alongside each trace is what lets you tell a retrieval problem apart from a reasoning problem. Without it the two look identical from the outside and get the same wrong fix.

What a RAG chatbot costs to run

Published price tables date within months, so the durable way to think about cost is as unit economics with three components.

  • Indexing cost scales with corpus size and re-embedding frequency. It is a one-off charge per chunk, repeated whenever you change the embedding model or the chunking strategy. Corpus churn, not corpus size, is what makes this expensive.
  • Per-answer cost is driven almost entirely by how much retrieved context you put in the prompt. That is top-k multiplied by average chunk size, plus conversation history. Doubling top-k roughly doubles the input token cost of every answer for the rest of the product's life.
  • Reranking cost is an extra model call per query. It pays for itself when a wrong answer is expensive, which in an internal knowledge or decision-support setting it almost always is.

The counterintuitive consequence: better retrieval usually makes a RAG chatbot cheaper, not dearer. Precise retrieval lets you cut top-k, which is the largest recurring line item. Teams that skip reranking to save money frequently spend more, because they compensate with a larger context window on every single request.

When a RAG chatbot is the wrong answer

Every vendor page on this topic sells RAG. It is not always the right architecture.

  • Your data is structured. If the answer lives in a table with a schema, a generated SQL query or a tool call is more accurate, cheaper and fully auditable. Embedding rows and hoping similarity search finds the right ones is a downgrade.
  • The corpus is small and stable. A few dozen pages that rarely change can go straight into a long context window. You lose nothing and remove an entire subsystem.
  • The problem is style, not knowledge. Consistent tone, house format or a rigid output schema are fine-tuning and prompting problems. Retrieval will not fix them.
  • The task requires computation. Retrieval finds text. It does not calculate, forecast or optimise. Those need a model or a solver behind a tool call.
  • The question is about one known document. If the user has already identified the file, just read it. Retrieval only adds a lossy step.

The honest test is whether the corpus is large, changes often, and needs citations. Two out of three usually still justifies retrieval. One out of three usually does not.

Agentic retrieval and query routing

The pattern has moved on from the single-query loop most tutorials still teach. Microsoft now documents agentic retrieval, in which a model plans the query, issues parallel subqueries and returns structured responses with citations, and recommends it over the classic single-query approach for new chatbot builds.

The reason is FP7 in the table above. Real questions are compound. "How do we validate the incrementality estimate our model is producing?" is three questions wearing one coat, and a single similarity search against a single index will answer at most one of them well.

Routing is the other half of it. When a knowledge base spans several genuinely distinct domains, deciding which corpora to search becomes a first-class problem rather than an afterthought. We published our approach in an R&D study on a multi-label retrieval-based domain router: instead of asking a model which domain a query belongs to, we run the query against the store and read each domain's retrieval as evidence of its own relevance. The corpus answers the routing question, which means the router and the retriever can never disagree about what exists.

The other lesson from building this in production was about restraint. A domain expert chatbot improves at least as much from what you stop it saying as from what you teach it to say, a principle we call via negativa. An assistant that refuses cleanly beats one that improvises fluently.

Security, privacy and governance

A RAG chatbot changes your security surface, because it turns a document repository into an answering service that will happily summarise anything it can retrieve.

  • Permission-aware retrieval. The retriever must filter by the requesting user's access rights before ranking, not after. Microsoft documents this as document-level security trimming. Retrieving first and filtering later leaks information through summaries and citations.
  • Indirect prompt injection. A document inside your corpus can contain instructions aimed at the model. If any part of the knowledge base is user-contributed or externally sourced, retrieved content must be treated as untrusted data, never as instructions.
  • PII in embeddings. Vectors are derived from source text and deserve the same governance as the text. Deletion policies must cover the index, not just the original documents.
  • Tenant isolation. In multi-customer deployments, metadata filtering is a correctness control rather than a convenience feature, and it deserves its own tests.

The OWASP Top 10 for Large Language Model Applications is the reference framework here, and it is worth walking your architecture against it before launch rather than after an incident.

Grounding a RAG chatbot in business data, not documents

Almost every explanation of RAG chatbots assumes the knowledge base is documents: support articles, PDFs, wikis. That is the easy case. The harder and more valuable case is grounding a chatbot in measured business data, where the source of truth is a model output rather than a paragraph.

This is the territory we work in. A marketing mix model produces contributions, saturation curves, elasticities and incrementality estimates, and those numbers only mean something alongside the assumptions, validation checks and caveats that produced them. A retrieval layer over that material has to do something a document chatbot never has to, which is preserve the link between a number and the conditions under which it is valid. Retrieve the number without its caveat and you have built a very fluent way to mislead a budget owner.

That constraint shapes what we build. MMMGPT is a RAG chatbot over more than a decade of marketing mix modeling, causality and experimentation knowledge, designed so a practitioner can interrogate the method rather than just receive an answer. MMM Synapse applies the same retrieval discipline to institutional memory, indexing an organisation's own past models, decks and reports. Both sit inside the pattern we call Peripheral Agentic MMM, where AI handles the work around the model while the statistical core stays rigorous and human-led.

If you take one thing from this piece, make it the diagnostic table. When the chatbot gives a bad answer, the useful question is never "is the model good enough". It is "which of the seven failure points is this", and the answer is almost always upstream of generation.

Frequently asked questions

What does RAG stand for in a chatbot?

RAG stands for retrieval augmented generation. The term comes from Lewis et al. in 2020, who paired a language model's internal parametric memory with an external non-parametric memory, a searchable vector index. In a chatbot it means the system retrieves relevant passages from a knowledge base first, then generates an answer constrained by what it retrieved rather than by what the model memorised during training.

Does a RAG chatbot eliminate hallucinations?

No. It reduces them substantially by grounding answers in retrieved evidence, but several of the documented failure points still produce wrong answers even when retrieval works. A model can ignore supplied context, extract the wrong part of it, or fill a gap from memory when the retrieved passages are incomplete. Explicit refusal instructions, citation surfacing and groundedness checks are what close the remaining gap.

What is the difference between RAG and fine-tuning?

Fine-tuning changes model behaviour by adjusting weights, so it is the right tool for tone, format and domain-specific output structure. RAG changes what the model knows at answer time by supplying external evidence, so it is the right tool for facts that change or that need citing. Updating knowledge through fine-tuning means retraining; updating it through RAG means re-indexing a document. The two combine well.

Is RAG still needed with long-context language models?

Usually, yes. Long context helps, but three constraints persist. Cost scales with every token you send on every request, latency scales with context length, and model attention is uneven. "Lost in the Middle" showed that performance drops significantly when relevant information sits in the middle of a long input. For a small, stable corpus, long context is genuinely simpler. For a large or frequently changing one, retrieval still wins.

How do you measure whether a RAG chatbot is working?

Build a golden set of real questions labelled with their correct source documents, then measure retrieval and generation separately. Recall at k tells you whether the right chunk was retrieved at all. Groundedness tells you whether the answer is supported by what was retrieved. Answer relevance tells you whether it addressed the question. Re-run all three after every re-index, because re-embedding silently changes every retrieval in the system.

What chunk size should a RAG chatbot use?

There is no universal number, and treating it as a single tunable is the mistake. Chunk on document structure such as headings and sections wherever the source format supports it, so each chunk is a coherent unit rather than an arbitrary window. Use fixed-size windows with overlap only as a fallback. If questions arrive at very different levels of granularity, index the same corpus at more than one chunk size rather than compromising on one.

AL
Aryma Labs
Aryma Labs

Aryma Labs is a marketing mix modeling consultancy founded in 2019. Aryma AI is its Gen AI division, applying agents to the periphery of MMM while keeping the statistical core human-led.

Explore the Aryma AI suite

Gen AI products for marketing mix modeling, built on a human-led statistical core. Explore the suite, or talk to the team.