Skip to main content

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.
The judge may or may not handle this correctly. The key question is: can we make it consistently correct by providing examples?

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.
The retriever finds corrections about paraphrased medical dosages — exactly the pattern our test case follows.

Step 4: Run Faithfulness With Feedback

Now re-run the same evaluation, but pass the feedback_store. The SDK retrieves similar past corrections and injects them as few-shot examples into the LLM prompt.

Step 5: Compare

The judge has learned from your past corrections that paraphrases in medical contexts should be scored high when the meaning is preserved.

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.
The judge retrieves the contradiction examples from our feedback store and correctly scores this 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.