A RAG architecture has three steps: indexing, retrieval and generation. The indexing path cleans documents, splits them into chunks, encodes them with an embedding model and stores the vectors. The online query path encodes the question with the same model, retrieves the closest chunks and passes them to an LLM together with the question, and the LLM generates the answer. The idea goes back to Lewis et al. (2020), who paired a pre-trained parametric language model with a non-parametric memory: a dense vector index read by a neural retriever. For an operator-facing assistant on an inspection line, drawing the diagram is the easy part. The real question is what goes in the vector store. A flat dump of PDFs will produce confident answers from whichever document scores closest, and that can include one describing a camera setup the line retired months ago.
We treat the retrieval corpus for that kind of assistant as a governed artefact: the same drift telemetry summaries, rollback runbooks and model-version pins that keep the inspection model in service, as catalogued in our industrial CV reliability pack. The rest of this article walks through the architecture with that corpus in mind.
Which Boxes Belong on a RAG Architecture Diagram?
A typical RAG architecture diagram has an embedding model, a vector store, a retriever, a reranker, a prompt template and a generator. The table below gives each component’s job and the decision it forces on the team building it.
| Component | What it does | The decision it forces |
|---|---|---|
| Loader and cleaner | Converts PDF, HTML, Word and Markdown into uniform plain text | Which source formats are admitted, and with what metadata |
| Chunker | Splits text into units small enough for the model’s context | Chunk size: too small and some questions cannot be answered, too long and answers pick up noise |
| Embedding model | Encodes chunks at index time and queries at run time, with the same model | Which model to use at both index and query time |
| Vector store | Holds embeddings in an approximate nearest neighbour index for dense search; sparse search uses an inverted index | Dense, sparse or both |
| Retriever | Returns the top-k chunks by similarity score | k, and whether to fuse keyword and vector results |
| Reranker | Reorders candidates so the most relevant come first; a common pattern is a bi-encoder fetching 10 to 50 documents and a cross-encoder narrowing them to 3 to 5 | Latency budget versus precision |
| Prompt template and consolidator | Assembles the query and chunks within the model’s token and rate limits | Ordering, compression and the grounding instruction |
| Generator | The LLM writes the answer, and its quality sets the upper limit for the whole system | Model choice (see below) |
| Evaluator | Measures retrieval quality, faithfulness and groundedness as separate gates | Whether a gate blocks or reroutes a response |
Dense vectors compress meaning, and that compression can cost recall on exact-match and out-of-distribution queries in specialised domains, where lexical precision still counts. Defect codes, part numbers and model version strings are exactly that kind of token, so we would default to hybrid retrieval that runs BM25 alongside embeddings. Contextual retrieval, which prepends chunk-specific context before embedding and building the BM25 index, cut the top-20 retrieval failure rate by 49% (5.7% to 2.9%). Adding a reranking step on top took the reduction to 67% (5.7% to 1.9%).
What Are the Stages of a RAG Pipeline, from Ingestion to Generation?
A RAG pipeline runs from chunking through retrieval and reranking to generation, and each stage introduces failure modes. Barnett et al. catalogued seven failure points, placed below at the pipeline stage where we locate each:
- Ingest. Raw documents are extracted and cleaned into plain text. If the answer was never in the corpus, the system can still be fooled into answering a question related to the content when it should say it does not know (missing content).
- Chunk and index. Text is segmented, embedded and stored, and the quality of this step decides whether the right context can be found at all. In Chroma’s chunking evaluation, the default settings of some popular chunking strategies performed relatively poorly.
- Rewrite the query. An LLM can generalise the user’s question, for example by folding in chat history, before it is embedded.
- Retrieve. Top-k chunks are returned by similarity. The answer may exist in the corpus but rank below the cutoff (missed the top-ranked documents).
- Rerank and consolidate. Candidates are reordered and trimmed to fit the prompt. Retrieved documents that hold the answer can be dropped during consolidation (not in context).
- Augment. The query and the selected chunks are combined into one prompt. Placement within that prompt matters: Liu et al. (TACL 2024) found that performance is often highest when relevant information sits at the start or end of the context and drops significantly when it sits in the middle.
- Generate and read out. The LLM answers, and a reader step filters noise and enforces the output format. The remaining failure points are all here: the answer is in context but not extracted, the wrong format, the wrong specificity, or an incomplete answer.
Failures cascade down the stages. A retriever can score well on precision and still bury the critical document at a rank the LLM never reads, and a perfect retrieval can still produce a hallucinated answer if the prompt does not insist on grounding.
Why Answers Come Out Stale or Hallucinated Even with Retrieval
Retrieval improves accuracy but does not remove these failure modes. The RGB benchmark (AAAI 2024) found that ChatGPT’s accuracy fell from 96.33% to 76.00% once the share of noisy documents passed 80%, and the best rejection rate any tested model achieved when no retrieved document held the answer was 45% in English. RGB also found that models tend to trust retrieved information over their own correct knowledge, even after being warned that it might be wrong. Several design choices shape what reaches the prompt: chunk boundaries that strip a fact of its subject, retrieval that ignores document timestamps, and contexts so long that the relevant passage is lost in the middle. The model is the last line of defence, and not a strong one.
When Should You Choose RAG over Fine-Tuning or a Long-Context LLM on Its Own?
Use RAG when the knowledge changes or answers must be traceable to their sources. An LLM on its own answers from parametric memory, and Lewis et al. (2020) named provenance and updating that knowledge as open problems for such models. Because the retrievable store is non-parametric memory, it can be updated without retraining the model.
Against fine-tuning, a direct comparison exists. Ovadia et al. (Microsoft) compared unsupervised fine-tuning with RAG on knowledge-intensive tasks and found that RAG consistently outperformed it, both for knowledge seen during training and for entirely new knowledge. As a way of loading facts, unsupervised fine-tuning lost to RAG in that comparison.
Against simply feeding a long context, the results cut both ways. One comparative study found that long-context prompting beat RAG by 7.6% on Gemini-1.5-Pro, 13.1% on GPT-4O and 3.6% on GPT-3.5-Turbo. The same study’s hybrid approach let the model answer from retrieved chunks first and fall back to the full context only when it judged a query unanswerable. With that routing, 82% of queries were resolved at the RAG step on Gemini-1.5-Pro, and cost fell by 65% for Gemini-1.5-Pro and 39% for GPT-4O. Retrieval also leaves a record. RAG lets users check an answer against its original references, whereas generation from a long context alone remains a black box. For an incident assistant, that audit trail is the reason to build it at all.
Choosing the LLM for RAG comes down to how it behaves at the context length you will actually use, not the window it advertises. Databricks found that most models degrade beyond a certain context size: Llama-3.1-405b after 32k tokens and GPT-4-0125-preview after 64k. The failures also differ in kind. In the same tests, Claude-3-sonnet’s copyright refusals rose from 3.7% at 16k to 49.5% at 64k, and DBRX’s instruction-following failures rose from 5.2% at 8k to 50.4% at 32k. Instruction following matters most for the refusal path, because RGB found that models often ignore instructions, which makes them unreliable as triggers for “insufficient information”. Cost scales linearly with context length. Shortlist models on measured negative rejection and instruction following at the target context length, and only then compare price.
Is ChatGPT a RAG LLM, or Just a Chatbot?
RAG is an architecture that passes retrieved documents to an LLM, and ChatGPT can be that LLM. Barnett et al. describe a RAG system as passing semantically matched documents to an LLM “such as ChatGPT” to extract the answer, and RGB tested ChatGPT as the generator inside a retrieval-augmented setup. Two properties distinguish a retrieval-augmented system from a standalone chatbot: whether each answer is tied to specific evidence passages you can inspect, and whether the knowledge can be updated without retraining the model.
Naive, Advanced, Modular, Graph or Agentic RAG: Which Fits?
The variants differ in how fixed the retrieve-and-read structure is and how far the system adapts at run time. The survey literature describes naive, advanced and modular RAG as progressive paradigms. Graph and agentic designs add structure and autonomy, and they cost more compute to get it.
| Variant | How it works | Fits when | Breaks or costs |
|---|---|---|---|
| Naive | Index, retrieve top-k once, generate | Questions that need no multi-step reasoning | Weak precision and recall, hallucination, and single-shot retrieval that cannot handle multi-step questions |
| Advanced | Adds pre- and post-retrieval steps: sliding windows, metadata, reranking, context compression | Improving retrieval quality over naive RAG | Each added stage needs its own evaluation metrics |
| Modular | Modules can be swapped or reordered: query rewriting, iterative retrieve-read loops, adaptive retrieval such as FLARE and Self-RAG | Tasks where retrieval needs vary by query | Iteration can pile up irrelevant information |
| Graph | An LLM builds an entity knowledge graph and pre-generates community summaries | Global questions across a whole corpus, which naive RAG fails | Additional computational resources |
| Agentic | Agents use reflection, planning, tool use and multi-agent collaboration to manage retrieval | Complex or conversational queries | More compute and more components to govern |
The practical argument for moving up the table comes from an enterprise document pipeline that moved from naive RAG through hybrid retrieval to agentic retrieval. In that pipeline, deterministic retrieval could not correct itself when the reranker missed the right chunks, and the only lever left was to raise k, which increased cost and latency. The agentic stage gave the LLM a retrieval tool that accepted metadata filters and let it reformulate queries over several calls. Its logs showed roughly one full-document read for every 9.6 chunk retrievals.
For a line-side assistant, we would start with advanced RAG and hard metadata filters, then add a graph index once operators ask cross-incident questions such as which lines showed a failure pattern after a fixture change. Agentic retrieval earns its cost when one question spans runbooks, telemetry and records that live in a separate search store, as when searching incident logs alongside the vector index.
Why a Line-Side Assistant Needs Versioned, Dated Artefacts, Not a Document Dump
In a line-side corpus, the right document is the one that applies to the model version and line configuration in service. Index freshness is a critical challenge in production RAG, because stale information damages both answer quality and user trust. Chunking makes this worse: a chunk split away from its document can lose the very context that says which entity and time period it refers to. A chunk reading “reject threshold raised after recalibration” is harmless in its source document and dangerous on its own, with no model version attached.
The literature offers two fixes. Contextual retrieval prepends chunk-specific explanatory context before embedding. On a line, that context should include the model version, the line or cell, and the effective dates. Time-aware RAG weights document timestamps during retrieval to avoid outdated information.
What Happens to a RAG Assistant’s Answers When the Line Lighting or Fixturing Changes?
An ungrounded assistant keeps citing the retired configuration. Similarity search retrieves the top-K chunks by their similarity score to the query.
One study defines stale-document poisoning as outdated evidence making a model wrong on a question it answers correctly without retrieval. In that study, outdated retrieval flipped 30% of Llama answers and 37% of Qwen answers with no instruction to trust the document, and 66% and 75% when the models were told to follow it. Matched up-to-date evidence was followed in 97 to 100% of trials. A recency-aware hybrid reranker reduced poisoning by 4.6 to 10.0 points, but only when the dates were accurate. The study’s own conclusion is that reliable RAG needs selective trust: the model must judge whether retrieved evidence still applies, not only what it says.
Recency weighting therefore depends on reliable temporal metadata. We would make the configuration change itself the trigger: when the pack is updated for line lighting or fixturing changes, superseded artefacts get an end date and drop out of the admissible set, rather than staying in the set and losing on rank.
How Do You Keep RAG Answers Tied to the Inspection Model Version Currently in Service?
Filter on version metadata before retrieval scoring, not after. The production compliance pipeline above applies an admissibility gate: only chunks that meet the scope constraints enter the candidate set at all. “Filter first” is the first of its context-management rules. The metadata is attached at ingestion, alongside chunking and embedding. Applied to an inspection stack, the procedure runs in this order:
- At ingestion, tag every chunk with the inspection model version, the line or cell, the artefact type and its effective-from and effective-to dates.
- At query time, resolve which model version is actually deployed from the deployment record, not from the operator’s question.
- Restrict retrieval to chunks admissible for that version and date, then run hybrid search and reranking inside that set.
- Require the answer to cite the version and the artefact it drew on.
- If no admissible chunk supports an answer, return “insufficient information” instead of falling back to the wider corpus; that is the negative-rejection behaviour RGB tests for.
Given RGB’s 45% best-case rejection rate, the refusal should come from the pipeline’s gate rather than from the model’s judgement.
How Does a Grounded RAG Layer Shorten Recovery from a Drift Incident Without Touching Rejection-Rate Accuracy?
The assistant does not change rejection-rate accuracy. The inspection model owns that number. What the assistant shortens is the time the on-call owner spends reconstructing an incident’s context: which model version is live, what the line-side drift telemetry showed before the alert, and which steps the rollback runbook prescribes for that version. Citation traceability links each generated statement to specific evidence passages. Because answers are pinned to the version in service, a root-cause call is less likely to rest on the behaviour of a model that is no longer running. Recovery from drift incidents is the metric that improves. Detection accuracy stays where the inspection model puts it.
Retrieval-Provenance Checks That Belong in the Validation Pack
A single accuracy score for a RAG assistant hides where it breaks, because production failures split across retrieval quality, faithfulness and groundedness. Groundedness asks whether the answer is supported by the retrieved context. Faithfulness asks whether it represents that context without distortion. An answer can stay inside the retrieved material and still misread it, or quote a source faithfully while actually relying on memory for the current query. Scoring the two separately tells you whether to fix the retriever or the generator. The survey literature splits the targets the same way: context relevance and noise robustness measure retrieval, while faithfulness, answer relevance, negative rejection, information integration and counterfactual robustness measure generation.
A RAG assistant over inspection knowledge is a production reliability surface, and its gates need reliability artefacts like the inspection model’s. Our guide to the end-to-end ML pipeline notes that a pipeline whose validation box is one accuracy number is an incomplete picture.
A diagnostic checklist for the pack:
- Retrieval, measured on its own: context precision, context recall and mean reciprocal rank, so you know whether the best chunk survives truncation.
- Admissibility: every retrieved chunk carries a version and effective dates that match the deployed model.
- Staleness probe: a test set of questions whose answers changed at a known configuration change, checked to confirm that the post-change answer wins.
- Groundedness and faithfulness, scored separately.
- Negative rejection: questions whose retrieved documents hold no answer must produce a refusal.
- Retrieval-quality fallback: a lightweight evaluator, in the style of CRAG, that scores retrieved documents and triggers a different action when confidence is low.
- Inference-time gating: groundedness and faithfulness checks that can block or reroute a response before the user sees it.
- End-to-end score kept, but not used as the only release gate.
Who Can Build a RAG Assistant Grounded in Our Inspection Reliability Artefacts?
TechnoLynx builds generative AI into products, including operator-facing RAG assistants grounded in an inspection stack’s validated, version-pinned reliability artefacts. This work sits under Generative & Agentic AI R&D. On build versus buy: an in-house build is realistic if your team already maintains an artefact registry with version and date metadata and runs an eval harness for the inspection model, because the RAG gates extend that harness. When choosing a partner, ask how they would score groundedness separately from faithfulness, and what their pipeline does with an artefact superseded by a lighting change. The answers show quickly whether they treat the corpus as governed.
The scope has limits. This work does not change the inspection model’s rejection-rate accuracy, which stays owned by that model. Teams that need a simpler setup have other routes: Azure AI Search offers a classic hybrid-search RAG pattern and an agentic retrieval pattern in preview.
FAQ
Can RAG Work Without a Large Language Model?
Yes. The original RAG models of Lewis et al. (2020) used a pre-trained seq2seq model as the generator, and canonical pipelines pair a dense retriever with generators such as BART or T5.
What Type of Data Can a RAG System Retrieve?
Dense retrieval can be applied to all modalities, including visual RAG over images. Structured sources such as knowledge graphs and tables also serve as retrieval sources.