DEV Community

Valenx
Valenx

Posted on

Debugging a RAG app in an interview: split retrieval from generation

"How would you build a RAG pipeline?" is the most common AI engineer design question. The usual answer lists parts: vector DB, embeddings, LLM. The step that gets skipped is the one that makes it work: the retrieved passages have to go into the prompt, with the question, before the model answers.

Say the full path in order

  • 1. Ingest and clean documents, then split into chunks (a few hundred tokens with overlap is a fine start).
  • 2. Embed chunks and index them. Add keyword search (BM25) for exact terms like product codes.
  • 3. At query time: retrieve candidates (hybrid), rerank, keep the top few.
  • 4. Assemble the prompt: instructions + retrieved passages + the question. Ask for citations and allow "not enough information".
  • 5. Evaluate retrieval (was the right chunk retrieved?) separately from generation (did the answer use it faithfully?).

The follow-up: "Your RAG app gives wrong answers. How do you debug it?" Split it. If the right chunk was not retrieved, fix chunking, embeddings, hybrid search or filters. If it was, fix the prompt, the context noise or the model.

for q, gold_chunk_id, gold_answer in eval_set:
    hits = retrieve(q, k=5)
    retrieval_ok = gold_chunk_id in [h.id for h in hits]
    answer = generate(q, hits)
    record(q, retrieval_ok, faithful(answer, hits), correct(answer, gold_answer))
Enter fullscreen mode Exit fullscreen mode

90-second drill: say steps 1-5 out loud without notes, then answer the debug follow-up.

12 must-know questions with model answers, free cheat sheet → https://valenx.org/go/free-aie?utm_source=devto&utm_medium=article&utm_campaign=dp1127&utm_content=D02

Valenx Press. Practice material, no interview promise.

Top comments (0)