Skip to the page

Retrieval-augmented generation · senior

Debugging and designing a RAG system

When a RAG answer is wrong, split the problem into retrieval and generation using the trace, then fix the stage that failed. A full design adds ingestion, versions, hybrid retrieval, tools for personal data and citations.

The notes

What you must know

  • Debug from the trace: rewritten query, retrieved chunks with scores, reranked order, final prompt and raw answer.
  • First question: did retrieval fail, or generation? Retrieval failures: different words, a chunk boundary separating a rule from its exception, a wrong chunk ranking higher, a filter that excluded the document, a stale index, k too small.
  • Generation failures: two chunks conflict, the answer sits in the middle of a long context, a be concise instruction dropped the exception, or the model used general knowledge.
  • Fixes: query rewriting, hybrid search, a reranker, better chunking, a rule to reconcile conflicts, and an instruction to answer only from the context.
  • Design checklist: users and volume, languages, scope, latency, regulation, data residency, ingestion with versions, hybrid retrieval with filters, reranking, citations checked in code, evals and monitoring.
  • Personal questions (my claim status) go to tools over core systems, not to RAG. Policy terms go to RAG.
  • Every citation carries a chunk id, document, page and section, and code checks that cited ids were really retrieved.

The red pen

Common traps: mistake → fix

  • Mistake: A wrong answer means the model is bad

    Fix: often retrieval failed; check the chunks first.

  • Mistake: RAG can answer personal account questions

    Fix: use authenticated tools for personal data.

  • Mistake: Citations are true because the model wrote them

    Fix: check in code that they point to retrieved text.

Easy to hard

Questions interviewers ask, easy to hard

  1. The policy is in the index but the bot gives the wrong answer. How do you debug?
  2. How do you tell a retrieval failure from a generation failure?
  3. Design a RAG assistant for 40,000 insurance PDFs.
  4. How do you make citations trustworthy?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview