TapCub is live — analytics, insights and live chat, free on one platform
Glossary

Retrieval-Augmented Generation (RAG): Meaning and Example

RAG means retrieving relevant passages from your documents and having a language model answer from them. How it works, a support knowledge-base example with hit rate and grounding, lexical vs vector retrieval, and agentic RAG.

Emma Collins Reviewed by Chloe Morgan Also called RAG Last updated Nov 29, 2026 Glossary

Quick answer

Retrieval-augmented generation (RAG) is a method where a system first retrieves relevant passages from a document collection, then has a language model generate the answer from them. Facts come from documents you can edit and cite; if nothing relevant is found, the question should go to a person.

Formula: Knowledge-base hit rate = (questions answered by an exact Q&A match + questions answered from retrieved passages) ÷ all questions × 100

What is retrieval-augmented generation?

Retrieval-augmented generation (RAG) is a way of answering questions with a language model in which the system first retrieves relevant passages from a document collection and then has the model generate the answer from those passages. The model's own training data supplies the language; your documents supply the facts.

The term comes from Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks", submitted in May 2020 and published at NeurIPS 2020 (arXiv:2005.11401). The paper combined a pretrained sequence-to-sequence model (parametric memory) with a dense vector index of Wikipedia (non-parametric memory) and reported state-of-the-art results on three open-domain question-answering tasks. The paper's argument is still why RAG is used: knowledge stored in a model's weights is hard to update and hard to trace, while knowledge in a document index can be edited today and cited in the answer.

For a support team the meaning is concrete: RAG lets an AI assistant answer from your help articles and policies instead of from whatever the model happened to learn, and lets you see which passage each answer came from.

How RAG works: retrieve, then generate

  1. Split documents into chunks. Help articles are cut into passages small enough to be specific, typically a few hundred characters to a few hundred words.
  2. Index the chunks. Either a full-text (lexical) index, a vector index of embeddings, or both.
  3. Retrieve. The visitor's question is matched against the index and the top-scoring chunks are returned. A minimum score decides whether anything relevant was found at all.
  4. Augment the prompt. The retrieved chunks are placed in the prompt with an instruction to answer only from them.
  5. Generate. The model drafts the answer, ideally pointing to the passages it used.
  6. Hand off when retrieval fails. If no chunk clears the threshold, or the model judges the material insufficient, the question goes to a person instead of being answered from the model's general knowledge.

Step 6 is what separates a support RAG system from a general chatbot. Without it, a miss in retrieval turns into a confident answer built on nothing.

RAG in a support knowledge base: a worked example

Sample data: a store's chat assistant receives 1,000 visitor questions in a month.

OutcomeQuestionsShare
Matched a stored Q&A entry exactly (no model call)38038%
Answered by the model from retrieved document chunks41041%
No relevant chunk found, handed to a person21021%
Knowledge-base hit rate(380 + 410) ÷ 1,00079%

The hit rate says how often the knowledge base had something. It does not say whether the 410 generated answers were faithful to the chunks. To check that, sample them: if a reviewer reads 50 of the 410 and finds 44 fully supported by the retrieved text (88%), the estimated share of all questions answered correctly from your own material is (380 + 410 × 0.88) ÷ 1,000 ≈ 74%.

The 210 misses are the most useful output of the month. Group them by topic, and the largest groups are the articles to write next. A knowledge base improved this way raises the hit rate without touching the model.

Lexical vs vector retrieval

Lexical (full-text) searchVector (embedding) search
Matches onShared words, weighted by raritySimilar meaning, even with different words
Strong atProduct names, error codes, order statuses, exact policy termsParaphrased questions ("can I send it back" vs "return policy")
Weak atSynonyms and paraphrasesExact identifiers and rare terms
InfrastructureA database full-text indexAn embedding model plus a vector store
Explaining a missEasy: the words did not matchHarder: similarity scores are opaque

Many production systems combine both (hybrid retrieval). For support content full of SKUs, plan names and error messages, lexical search alone often performs well; the cost of misses on paraphrases can be reduced by adding common phrasings as Q&A entries.

Chunking choices

Chunk size trades precision against context. Sample: a 3,000-character returns article split at 600 characters gives five chunks; a question about "return shipping for damaged items" retrieves the one chunk about damaged items rather than the whole article, which keeps the prompt short and the answer specific. Split at 3,000 characters, the same question pulls in exchange rules and refund timing too, and the answer starts mixing them.

Rules that hold in practice:

  • One topic per chunk. Write help articles with clear headings so splits fall between topics.
  • Keep the condition next to the rule. "Free returns within 30 days, except sale items" must not be split across two chunks.
  • Repeat the subject. A chunk that starts "It costs $5" is unusable on its own; "Return shipping costs $5" is not.

RAG vs fine-tuning vs agentic RAG

RAGFine-tuningAgentic RAG
Where knowledge livesDocument indexModel weightsDocument index plus tools
Updating a factEdit the documentRetrainEdit the document
TraceabilityAnswer can cite its passagesHard to traceCan cite, but steps are longer
Control flowFixed: retrieve once, then generateNoneAgents plan, retrieve repeatedly, reflect and call tools
Typical useHelp-centre answersTone, format, domain languageMulti-step research questions

Agentic RAG, as surveyed by Singh et al. in January 2025, embeds autonomous agents in the pipeline that use reflection, planning, tool use and multi-agent collaboration to adapt retrieval as they go (arXiv:2501.09136). That flexibility costs latency and makes behaviour harder to audit. For a support widget answering "where is my order" questions, a fixed retrieve-then-generate pipeline with a clear hand-off is usually the easier system to trust. For how such an assistant fits into a support workflow, see AI support agents and the build guide in knowledge base chatbots.

Metrics that show whether answers are grounded

MetricFormulaRead it as
Knowledge-base hit rate(exact matches + retrieved answers) ÷ all questionsCoverage of the knowledge base
Hand-off ratequestions handed to a person ÷ all questionsThe gap list, by topic
Grounded share (sampled)answers fully supported by retrieved text ÷ answers reviewedFaithfulness of generation
Reopen or "not solved" ratefollow-ups after an AI answer ÷ AI answersAnswers that looked fine but did not help

A rising hit rate with a falling grounded share means retrieval is returning loosely related chunks and the model is stretching them. The fix is a higher score threshold or better articles, not a bigger model. A survey of RAG for large language models by Gao et al. (December 2023) groups evaluation along the same lines: retrieval quality and generation quality are scored separately (arXiv:2312.10997).

How RAG works in TapCub's knowledge base

TapCub's chat assistant follows the retrieve-then-generate pattern with a hand-off. The 1,000-question example maps onto it like this:

  1. Two entry types. In Live chat › Knowledge base, a Q&A entry is sent exactly as written when the question matches, and uses no AI call; a document is split into passages of about 600 characters. These are the 380 and 410 rows of the example. See the knowledge base definition.
  2. Lexical retrieval with a threshold. When no Q&A matches, a database full-text index (natural-language mode, not a vector store) returns the highest-scoring passages and the model drafts from them. A score that is too low counts as no match.
  3. Hand-off instead of guessing. In Live chat › Chat settings › AI assistant, the modes are off, only when all agents are offline, or AI answers first. When the material is not enough, the chat goes to a person; the inbox labels the reason, such as no knowledge match or the model cannot answer. The AI only drafts replies and cannot change orders or call other systems.
  4. Read the hit rate. Live chat › Reports shows the knowledge-base hit rate: the share of questions answered by a direct Q&A match or a retrieved answer.
  5. Close the gaps. Turn the handed-off topics into new entries, and use Fix & save on a wrong answer in the inbox to store the corrected version as a Q&A entry, so the same question skips the model next time.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Emma Collins

Product Analyst

Focuses on event analysis, conversion funnels, and retention, using clear metric definitions and structured analysis to explain product performance.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What does RAG stand for in AI?

RAG stands for retrieval-augmented generation. The system retrieves relevant passages from a document collection and passes them to a language model, which generates the answer from that material. The term comes from a 2020 paper by Lewis et al., published at NeurIPS 2020.

What is agentic RAG?

Agentic RAG adds autonomous agents to the pipeline. Instead of retrieving once and answering, agents plan steps, retrieve several times, reflect on intermediate results and call tools. It handles multi-step questions better but is slower and harder to audit than a fixed retrieve-then-generate pipeline.

Does RAG need a vector database?

No. The original paper used a dense vector index, but retrieval can also be a full-text (lexical) index. Lexical search works well for exact product names, codes and policy terms; vector search handles paraphrases better. Many systems combine both.

Does RAG stop hallucinations?

It reduces them when retrieval finds the right passage and the model is told to answer only from it. It does not help when retrieval returns loosely related text. That is why a minimum relevance score, a hand-off on misses and sampled grounding checks are part of a reliable setup.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics