The Problem
Your LLM judge keeps scoring paraphrased medical responses too low. You correct it, but the next time a similar case comes up, it makes the same mistake. There is no learning between evaluations. You need a feedback loop: store your corrections, and when a similar input comes up again, retrieve those corrections as few-shot examples so the judge knows how to handle it.What You Will Learn
- How to store evaluation corrections in ChromaDB with semantic embeddings
- How to retrieve similar past corrections via vector search
- How to inject feedback as few-shot examples into the LLM judge prompt
- How to compare results with and without feedback
- How to calibrate optimal thresholds from your feedback data
Prerequisites
This cookbook requires
chromadb for persistent vector storage and a GOOGLE_API_KEY for the LLM judge. For testing without ChromaDB, an InMemoryFeedbackStore is also available.Step 1: Run Faithfulness Without Feedback
First, establish a baseline. Run the faithfulness metric on a case where the heuristic typically struggles — a paraphrased response.Step 2: Submit Feedback Corrections
Create a feedback store and submit developer corrections. Each correction maps an (input, output) pair to the score and reason you think is correct.Step 3: See What Gets Retrieved
Before running the evaluation, inspect which past corrections are retrieved for our test input. The retriever uses semantic similarity to find the most relevant examples.Step 4: Run Faithfulness With Feedback
Now re-run the same evaluation, but pass thefeedback_store. The SDK retrieves similar past corrections and injects them as few-shot examples into the LLM prompt.
Step 5: Compare
Bonus: Test an Unfaithful Case
Verify that the feedback loop does not blindly boost scores. When the output genuinely contradicts the context, the judge should still score low.Bonus: Calibrate Thresholds
Use your accumulated feedback data to statistically determine the optimal pass/fail threshold.How It Works
What to Try Next
You have taught the judge to handle text. Now teach it to handle images and audio.Next: Multimodal Judge
Pass images and audio URLs to the LLM judge to verify product descriptions, check transcriptions, and more.