Skip to course content
Free LangChain course

LangChain for LLM Applications and RAG

Module 06 Activity

Scenario

Retrieval works. Now the answer has to stay inside it, cite it, and refuse when nothing clears the bar.

What you build

A grounded retrieval chain returning sources, with a working refusal path and an unsupported-terms check running on every answer.

Steps

  1. Build the retrieval chain with the dict join, formatting documents so the chunk id appears in the context text.
  2. Write the grounding prompt as a list where every line names a failure it prevents.
  3. Return sources alongside the answer using a parallel branch, so retrieval runs once. Include the updated date.
  4. Switch to scored retrieval and add a threshold set from the distributions you measured in Module 5.
  5. Log the best score on every refusal.
  6. Run the unsupported-terms check on every answer and classify the three worst flags as real or false positives.

Evidence to hand in

Review checklist