Skip to main content

RAG

Customer framing: A customer has thousands of internal documents and wants their support team to ask questions in plain English, with answers they can trace back to a source. Here is the architecture and the tradeoffs.

Official docs:


Running example​

Every page in this section uses the same system: Meridian Support Assist, an assistant over per-customer documentation for a B2B vendor.

PropertyValue
CorpusRunbooks, policy PDFs, resolved support tickets
Size~400k chunks across 120 tenants
IsolationEach tenant sees only its own corpus. Leakage is a contract breach.
Latency targetFirst token in under 2 seconds
DeploymentCloud for most tenants, airgapped on-prem for three regulated ones

The numbers are made up. The shape is not.

See it applied: Accident Case Management case study


RAG is a retrieval problem​

The generator is rarely the reason an answer is wrong. If the right chunk never reaches the prompt, no model and no prompt rescues it. Tune retrieval first, and only then argue about the wording of the system prompt.

🟧 the two stages that decide whether the right chunk reaches the model

StagePage
Parse, chunk, embed, indexIngestion & Indexing
Retrieve, filter, fuse, rerankRetrieval
Assemble the prompt, ground and citeGeneration & Grounding
Measure it, then guard it at runtimeEvaluation & Guardrails
Latency, scale, isolation, on-premProduction

Four places an answer goes wrong​

FailureSymptomWhere to look
Bad parseAnswer cites a table that reads as scrambled numbersParsing
Chunk boundaryAnswer is half right and stops mid-thoughtChunking
Retrieval missAssistant says the corpus has nothing, but it doesHybrid search
Generator ignored contextAnswer is fluent, confident, and unsupportedFaithfulness

Each failure has a metric attached to it. Guessing which one you have is the expensive way to debug a RAG system.

Best practice

Before tuning anything, build an eval set of 30 real questions. Debugging without one is guessing with extra steps.


Do you need RAG at all​

SituationUse
Corpus fits in the context window and rarely changesStuff the whole thing into the prompt with caching
Corpus is large, changes often, answers need citationsRAG
The question is "how many orders shipped late last month"SQL, not RAG. Vector search over structured data is a downgrade.
You need the model to speak a different style or formatFine-tuning or a better prompt. RAG adds knowledge, not behaviour.
Users search by exact code, SKU, or error stringKeyword search first, RAG only if free-text questions also matter

Prompt caching keeps eating the low end of this table. A 200k-token corpus that changes monthly is no longer obviously a RAG problem. The case for RAG is corpus size, freshness, and per-answer citation.

warning

Most failed RAG projects were search problems that nobody measured as search problems. If your users' questions are keyword lookups, ship keyword search and go home.