Building a RAG system is easy. Building one you can trust in production is hard.
⠀
I’ve seen RAG systems that looked perfect in a demo fall apart in front of real users. Not because the model was weak, but because nobody designed what should happen when retrieval comes back empty or a citation points to nothing.
⠀
Here’s what actually happens to a RAG query, from question to answer:
⠀
𝟭. 𝗤𝘂𝗲𝗿𝘆 𝗽𝗿𝗲𝗽𝗮𝗿𝗮𝘁𝗶𝗼𝗻
⠀
→ 𝗦𝗺𝗮𝗹𝗹 𝘁𝗮𝗹𝗸 𝘀𝗸𝗶𝗽𝘀 𝗿𝗲𝘁𝗿𝗶𝗲𝘃𝗮𝗹
A greeting gets answered directly. No search needed.
⠀
→ 𝗧𝗵𝗲 𝗾𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝗶𝘀 𝗿𝗲𝘄𝗿𝗶𝘁𝘁𝗲𝗻
Typos are fixed, references are resolved and intent is added from the conversation.
⠀
𝟮. 𝗥𝗲𝘁𝗿𝗶𝗲𝘃𝗮𝗹 𝗮𝗻𝗱 𝗿𝗮𝗻𝗸𝗶𝗻𝗴
⠀
→ 𝗙𝗶𝗻𝗱, 𝗿𝗲𝗿𝗮𝗻𝗸, 𝘀𝗲𝗹𝗲𝗰𝘁
Hybrid search (semantic + keyword) with permission filtering, then a reranker, then the top 5 to 10 chunks.
⠀
→ 𝗜𝗳 𝗻𝗼𝘁𝗵𝗶𝗻𝗴 𝗿𝗲𝗹𝗲𝘃𝗮𝗻𝘁 𝗰𝗼𝗺𝗲𝘀 𝗯𝗮𝗰𝗸
Retry with a rewritten query. After 1 or 2 attempts, ask the user to clarify or abstain, instead of guessing.
⠀
𝟯. 𝗔𝗻𝘀𝘄𝗲𝗿 𝗴𝗲𝗻𝗲𝗿𝗮𝘁𝗶𝗼𝗻
⠀
→ 𝗚𝗿𝗼𝘂𝗻𝗱𝗲𝗱, 𝘄𝗶𝘁𝗵 𝗰𝗶𝘁𝗮𝘁𝗶𝗼𝗻𝘀
The prompt is built from the question, the top chunks and instructions. The answer links each claim to a source: [1], [2], [3].
⠀
𝟰. 𝗔𝗻𝘀𝘄𝗲𝗿 𝘃𝗮𝗹𝗶𝗱𝗮𝘁𝗶𝗼𝗻
⠀
→ 𝗘𝘃𝗲𝗿𝘆 𝗰𝗶𝘁𝗮𝘁𝗶𝗼𝗻 𝗮𝗻𝗱 𝗰𝗹𝗮𝗶𝗺 𝗶𝘀 𝗰𝗵𝗲𝗰𝗸𝗲𝗱
Do the references exist? Does each key claim have supporting evidence?
⠀
→ 𝗜𝗳 𝘃𝗮𝗹𝗶𝗱𝗮𝘁𝗶𝗼𝗻 𝗳𝗮𝗶𝗹𝘀
A hallucinated claim or a wrong citation triggers a regeneration with a stricter prompt. Up to 2 tries, then abstain or ask to clarify.
⠀
𝟱. 𝗔𝗳𝘁𝗲𝗿 𝗱𝗲𝗹𝗶𝘃𝗲𝗿𝘆
⠀
→ 𝗟𝗼𝗴 𝗲𝘃𝗲𝗿𝘆𝘁𝗵𝗶𝗻𝗴, 𝘄𝗶𝘁𝗵 𝗽𝗿𝗶𝘃𝗮𝗰𝘆 𝗰𝗼𝗻𝘁𝗿𝗼𝗹𝘀
Query, chunks, answer and citations, with PII redaction and access control.
⠀
→ 𝗙𝗲𝗲𝗱𝗯𝗮𝗰𝗸 𝗶𝗺𝗽𝗿𝗼𝘃𝗲𝘀 𝘁𝗵𝗲 𝘀𝘆𝘀𝘁𝗲𝗺
A thumbs up becomes a candidate golden example. A thumbs down goes into the eval set.
⠀
𝗪𝗵𝗮𝘁 𝘁𝗼 𝗺𝗲𝗮𝘀𝘂𝗿𝗲 𝗮𝘁 𝗲𝗮𝗰𝗵 𝘀𝘁𝗮𝗴𝗲
⠀
→ Retrieval: recall@k. Did we fetch the right evidence?
→ Rerank: nDCG. Are the most relevant chunks on top?
→ Answer: faithfulness. Is every claim supported?
→ Citations: accuracy. Does each citation point to the right chunk?
⠀
The happy path is easy to demo. The other paths are what make RAG trustworthy.
⠀
Which of these paths does your RAG system handle today?
⠀
𝗣𝗦: Found this useful?
Join 4,000+ AI architects and engineering leaders from Microsoft, Google, IBM, PwC and others reading my weekly newsletter 𝗗𝗶𝗮𝗿𝘆 𝗼𝗳 𝗮𝗻 𝗔𝗜 𝗔𝗿𝗰𝗵𝗶𝘁𝗲𝗰𝘁.
I break down real enterprise AI systems, agentic patterns, and what actually works in production.
✉️ Free subscription: https://lnkd.in/exc4upeq
⠀
#RAG #EnterpriseAI #GenerativeAI


