LLM-as-a-Judge: Who evaluates artificial intelligence?
This post is translated from Polish. Read the original
If you have read the previous posts in this series, you already know what LLM non-determinism brings with it and why traditional QA assertions will not work here. We have covered the evaluation categories (evals) and built our reference, the Golden Set. So we have defined very precisely what we test and on what.
We are missing only one piece: who is going to do the testing?
With 2,000 test cases, evaluating every interaction with an AI assistant and checking it against 5 different categories (for example safety, accuracy, tone) would take a human dozens, or even more than 100 hours of tedious work. The cost? Thousands of euros. The time? So long that in the meantime the development team would ship more fixes, and the process would have to start over.
Manual evaluation of every generated answer is the gold standard, but it does not add up from a business point of view at all. And this is where the concept of LLM-as-a-Judge enters the stage.
What is LLM-as-a-Judge?
Put simply: it is a setup in which we use a second, strong language model to evaluate the answer generated by the assistant under test. Your AI agent is checked by another agent.
Instead of rigid assertions in the code of automated tests, we write a dedicated evaluation prompt. Such a prompt must contain the basic elements:
- Input - the question or task our bot received.
- Output - the answer our bot generated.
- Rubric - a very clear instruction that says by which criteria the judge must evaluate the text (for example from 1 to 5 in the accuracy category).
- Reference answer (optional) - when we verify, for example, factual correctness, we add to the prompt the ideal answer taken from our Golden Set. Then the judge has it easier: it does not have to guess whether the tested model tells the truth, it simply compares the generated text with the reference. This drastically reduces the risk of hallucinations by the judge itself.
This changes the balance of power. Instead of waiting weeks for the results of manual tests, you get the scoring of the same 2,000 scenarios in 30 minutes, for a fraction of the cost (for example 50 euros for API calls). With automation like this, you can actually put AI evaluation into your CI/CD pipeline.
The “Chain of Thought” mechanism - why the judge must think out loud
The basic mistake when you put an LLM Judge in place is to ask it only for a score (for example score: 4). A model that spits out a dry number right away is wrong more often and is much harder to debug.
Instead, we use the Chain-of-Thought (CoT) principle. In the judge’s prompt we force its output to have a defined structure:
reasoning- first justify your decision, list what went well and what went wrong.score- only then give the final numeric score.label- mark the test as PASS/FAIL.
Thanks to this, the judge thinks “step by step”, and you as QA get a readable log and proof of why the answer was treated as insufficient.
Traps and risks: The judge is not perfect
Of course, letting one model evaluate another is not a magic wand. You add another layer of non-determinism to the testing process. What do you need to watch out for?
- The “Echo” risk - models very often prefer the style of answer they would generate themselves. If the agent runs on GPT-4o and you also hire GPT-4o as the judge, the judge will have a natural tendency to favor those answers.
- Misalignment (A gap with human expectations) - models still have their cognitive limits. For example, a judge can rate an objectively worse and long-winded answer (pure fluff) higher than an accurate and concise one, only because it “looks more thorough”.
- Economy of scale - with a huge number of requests and very complex evaluation criteria, the cost of judge API calls can grow.
Calibration, or teaching the judge to evaluate
How do you prove that our automated judge is right? Through calibration.
You do not let the Judge into production until you are sure it thinks like you. You choose 20-30 random interactions from your Golden Set. You evaluate them yourself (on a 1-5 scale), and then you run the same cases through the LLM Judge. Then you sit down and compare the results.
Wherever there is a big gap in the scores (you gave 2, the model gave 5), you need to refine the rubric in the judge’s prompt. Your criteria were probably too vague for it. Your business goal should be at least 85-90% correlation between the judge and the human evaluation. Only then do you have the right to let such a judge into the CI/CD pipeline. Poco a poco.
Checklist for this post
- Start by building a solid Golden Set to evaluate against.
- In the judge’s prompt, always force
reasoning(justification) before the numeric score. - Where possible, give the judge the reference answer from the Golden Set - it makes its job easier and limits its hallucinations.
- Watch the calibration: aim for >85% correlation between your evaluation and the LLM’s evaluation.
- Watch out for the echo effect - consider using another provider as the judge (for example, you test an OpenAI model, but the judge is a model from Anthropic).
- Do not put the Judge into CI/CD until you have manually verified a few dozen of its verdicts.
To sum up
An automated judge lets you evaluate models at a scale that no human could compete with in terms of time and budget. On the other hand, if you think that after you put a Judge in place you can drop testers completely and hand quality control over to machines only… then you are right, you only think so.
In the next, seventh part of the series we will talk about the concept of Human-in-the-loop - that is, why behind every effective AI agent there still has to be a human with common sense.
Stay up to date with LLM and QA! 🚀
Practical notes on testing, QA processes and modern quality strategy. No fluff - for testers and leaders who want to get quality right. The newsletter is in Polish.
When you join, you agree to receive news from me. You can unsubscribe at any time.