Skip to content

Exercise 06 — RAG Hardening

Timebox: 45-60 minutes

Goal

Take the naive RAG app in rag_app.py and make it feel production-shaped.

Work in

  • rag_app.py

Tasks

  1. Add retries around the generation step.
  2. Return source citations in the answer.
  3. Refuse when the retrieved context is not strong enough.
  4. Add basic logging for prompt, latency, and selected documents.
  5. Add a tiny eval set once the main path works.

Done when

  • The answer includes citations
  • Weak retrieval does not produce confident hallucinations
  • The script captures enough signals to debug failures later