# What Are LLM Evals? by [kirupa](https://www.kirupa.com/me/index.htm) | filed under [AI Fundamentals](https://www.kirupa.com/ai_fundamentals/index.htm) **TL;DR:** Evals are repeatable checks that tell us how well an AI system does its job, replacing a quick look at a few answers. Each eval pairs an input with what a good result must include, and the checks come from code, an LLM judge, or a person, run before shipping and on real traffic after. - Dana's three hand-picked questions looked fine, but the 46-case eval set showed that version 7 broke handoff-02, a case that used to pass. - Code checks are fast and cheap but only check exact things, LLM judges handle judgment calls once they're tested against people, and human review catches the most but costs the most. - Offline evals run a golden dataset before shipping, online evals watch real traffic after, and every new failure becomes a new test case. - Start by saving traces and reading about 100 of them, then turn the most common failures into a few dozen cases that run on every change. Here's a scene that plays out on a lot of teams building with language models. Someone tweaks a prompt, types three questions into the app, reads the answers, and says ***looks good to me!*** The change ships. A week later, a customer finds the thing it broke. Nobody did anything careless there. Trying a few examples by hand is a perfectly natural way to check a change, and for a demo it's fine. It just stops working once real people depend on the app. The fix is a set of checks we can run again and again that tell us how well our AI system is doing its job. Those checks are called **evals**, short for evaluations. This section of AI Fundamentals has a whole shelf of articles on evals, each one going deep on one piece. This article is the map. We'll look at what an eval actually is, why judging by feel (aka **vibes**) doesn't scale, the three kinds of checks, the difference between checking before and after we ship, and how all of the pieces connect into one loop. Along the way, I'll point you to the article that covers each piece in detail. Onwards! ## Meet Sprocket We'll use the same running example as the rest of the evals articles. Imagine we run an online bike-parts shop, and we've added a support assistant to our site called **Sprocket**. Sprocket reads our help center articles, can look up a customer's order, and answers questions in a chat window. Our engineer Dana works on Sprocket's prompt, and our support lead Marcus knows our policies better than anyone. Here is Sprocket, sitting in the corner of the shop's website, ready to help: ![Sprocket sits in a chat panel in the corner of our online bike-parts shop. The panel header shows a robot avatar with a gear badge, the name Sprocket, and the tagline Bike-parts help desk. A customer asks, My chain keeps slipping, can I return it? Sprocket replies, Sure! You can return any item within 60 days. A handwritten note says This is Sprocket!](https://www.kirupa.com/ai_fundamentals/images/error_analysis_on_traces_meet_sprocket.png) That reply looks friendly and confident. It's also wrong. Our return window is 30 days. Catching mistakes like that one, before customers do, is what evals are for. ## What Is an Eval? An eval is a lot like a unit test for an AI feature. We give the system an input, collect what it does, and check the result against what a good result must look like. Here is one of Sprocket's evals, end to end: ![One eval for Sprocket, end to end. The input is a customer asking, My chain keeps slipping. Can I still return it? I bought it 5 weeks ago. Sprocket writes a reply: 5 weeks is past our 30-day return window, but your chain may be covered by our warranty. The check asks whether the reply mentions 30 days and never says 60 days. The result is PASS.](https://www.kirupa.com/ai_fundamentals/images/what_are_llm_evals_anatomy.png) Notice that the check doesn't demand one perfect reply, word for word. A model rarely phrases the same answer the same way twice, so instead we pin down what must be true of any good answer. Some of those things are easy to check (does it mention 30 days?), and some need judgment (does it offer the warranty route politely?). We'll see how to handle both in a moment. One eval tells us very little. The value comes from having a whole set of them and running the set every time something changes. A fixed set of cases like this is called a **golden dataset**, and [Golden Datasets](https://www.kirupa.com/ai_fundamentals/golden_datasets.htm) covers what goes in one and how to keep it trustworthy. ## Why Don't Vibes Scale? Let's go back to that opening scene, with Dana in the starring role. Dana has a new prompt, version 7, that's supposed to make Sprocket's answers shorter. Here is the difference between checking it by vibes and checking it with an eval set: ![Two ways to check prompt version 7. On the left, a vibe check: Dana tries 3 questions, all three answers look fine, and the change ships. On the right, an eval set: all 46 cases run, and 43 pass. One of the 3 failures, handoff-02, passed under version 6, so version 7 broke it.](https://www.kirupa.com/ai_fundamentals/images/what_are_llm_evals_vibes.png) The three questions Dana tried all looked great. The eval set agrees that version 7 is better overall, 43 of 46 passing instead of 40. But it also shows that one case, ***handoff-02***, used to pass and now fails. Dana would never have found that by trying three questions, because it wasn't one of the three. That's the heart of the problem, and a few things about language models make it worse: - A prompt is one big piece of text, so changing one sentence can change behavior that sentence was never about. [Regression Tests on Every Prompt Change](https://www.kirupa.com/ai_fundamentals/prompt_regression_tests.htm) has a great example of this going wrong. - The same input can produce different outputs on different runs, so one good-looking answer doesn't prove the next one will be good too. - Customers ask a nearly endless variety of questions, and nobody remembers which ones they tried last month. - A feeling can't be shared. ***Looks good to me*** doesn't tell a teammate what was checked, and it can't be rerun next week. Hamel Husain makes the same argument in [Your AI Product Needs Evals](https://hamel.dev/blog/posts/evals/), which describes evals in three levels: quick automated assertions, human and model review, and A/B tests. The rest of this article follows a similar shape. ## The Three Kinds of Checks Every eval ends in a check, and there are three ways to do the checking. They trade speed and cost against how much nuance they can handle: ![Three kinds of checks for Sprocket's replies. A code check, like did Sprocket ask for an order number before looking one up, is fastest and cheapest but can only check exact things. An LLM judge, like does the reply state a policy the help articles don't support, is fast and handles judgment calls but has to be checked against people. Human review, like Marcus reading a conversation, catches the most but is slowest and most expensive.](https://www.kirupa.com/ai_fundamentals/images/what_are_llm_evals_checks.png) A **code check** is a few lines of ordinary code. Did the reply mention 30 days? Is it valid JSON? Did Sprocket call the order tool without an order number? These checks run in milliseconds, cost nothing, and give the same answer every time, so we use them for everything they can handle. An **LLM judge** is a second model that reads a conversation and answers one specific question about it, like whether the reply states a policy the help articles don't support. That kind of question has a hundred ways to go wrong (60 days, two months, eight weeks or so), so plain code can't catch it. A judge can, but only after we've checked that its verdicts match a person's. [LLM-as-Judge, Checked Against Human Labels](https://www.kirupa.com/ai_fundamentals/llm_as_judge.htm) walks through writing a judge and testing it, and [Faithfulness and Groundedness](https://www.kirupa.com/ai_fundamentals/faithfulness_and_groundedness.htm) covers one of the most useful judges for apps that answer from documents. **Human review** is a person who knows the domain reading what the system did. For Sprocket, that's Marcus. People catch problems nobody thought to write a check for, but they're slow and expensive, so we save them for the places where nothing else works: reading real conversations to find out what's going wrong, and labeling examples so we can test our judges. [Error Analysis on Real Traces](https://www.kirupa.com/ai_fundamentals/error_analysis_on_traces.htm) shows how Marcus does that reading. Anthropic's guide to [building evals](https://docs.claude.com/en/docs/test-and-evaluate/develop-tests) gives the same advice in a nutshell: use the fastest, most reliable method that can do the job, automate whatever we can, and test an LLM grader's reliability before leaning on it. OpenAI's [evaluation best practices](https://developers.openai.com/api/docs/guides/evaluation-best-practices) adds that automated scores should be calibrated against human feedback. ## Before and After We Ship The other big split is about timing. **Offline evals** run before a change reaches anyone. We take our golden dataset, run the old and new versions against it, and compare. They're repeatable and safe, and they're fast enough to run on every pull request, which is exactly what [Regression Tests on Every Prompt Change](https://www.kirupa.com/ai_fundamentals/prompt_regression_tests.htm) sets up. **Online evals** run after a change is live, on real traffic. We can run a judge on a sample of real conversations each day, watch for signals like customers asking for a person, and collect thumbs-up and thumbs-down votes. Online evals are noisy and slow, and any problem they find has already reached a customer. But they're the only way to find the problems nobody thought to test. [Offline vs. Online Evals](https://www.kirupa.com/ai_fundamentals/offline_vs_online_evals.htm) compares the two side by side, [User Feedback Loops](https://www.kirupa.com/ai_fundamentals/user_feedback_loops.htm) covers what customer feedback can and can't tell us, and [A/B Testing](https://www.kirupa.com/ai_fundamentals/ab_testing.htm) covers the fairest way to compare two versions on real traffic. All of this depends on one thing being in place first. We need a full record of every conversation (what the customer said, which prompt was used, what Sprocket looked up, and what it replied). That record is called a **trace**, and if we aren't saving traces yet, [Tracing and Prompt Logs](https://www.kirupa.com/ai_fundamentals/tracing_and_prompt_logs.htm) is the place to start. ## How Do the Pieces Fit Together? Each of these pieces is useful on its own, but they're designed to feed each other. Here is the whole thing as one loop: ![The eval loop in six steps. Before shipping: read real traces to find failures, write checks and golden cases for those failures, and run them on every change. After shipping: roll the change out to some customers, watch live traffic with judges and feedback, and find new failures. The new failures lead back to reading traces, and around it goes.](https://www.kirupa.com/ai_fundamentals/images/what_are_llm_evals_loop.png) Let's walk around it once with Sprocket: 1. Marcus reads 100 real traces and notes what went wrong. Getting our policies wrong turns out to be the most common failure. 2. Dana turns each failure into checks. A code check makes sure Sprocket asks for an order number, a judge looks for made-up policy details, and each failure gets a few golden cases. 3. Every prompt change runs the whole set, and any case that newly fails blocks the change until someone looks at it. 4. A change that passes goes out to a slice of customers first. 5. A judge samples live conversations, and we watch feedback and requests for a person. 6. A customer types an order number with a space in it, Sprocket fumbles it, and that conversation becomes a brand new golden case. Then we're back at step 1. Every trip around the loop makes the offline checks a little closer to reality. It also means our evals keep changing. Shreya Shankar and her coauthors noticed this in [Who Validates the Validators?](https://arxiv.org/abs/2404.12272), where they describe **criteria drift**: people need criteria to grade outputs, but grading outputs is how they figure out what their criteria are. That's normal. An eval set is something we grow and keep up to date, the same way we do with tests for any other code. ## Where Should We Start? All of this can look like a lot, but nobody builds the whole loop on day one. If Sprocket had no evals at all, here is the order I'd go in: 1. Start saving traces, if we aren't already. 2. Read about 100 of them and write down what went wrong, which is the advice Hamel Husain and Shreya Shankar give in their [evals FAQ](https://hamel.dev/blog/posts/evals-faq/why-is-error-analysis-so-important-in-llm-evals-and-how-is-it-performed.html). 3. Turn the most common failures into a few dozen golden cases, with code checks wherever code can do the job. 4. Run those cases on every prompt or model change. 5. Add an LLM judge only for the failures that code can't catch, and check it against Marcus's labels before trusting it. Online evals and A/B tests come later, once there's enough traffic to learn from. ## Conclusion Evals are the checks that tell us whether our AI system is doing its job, written down so we can run them again and again. They replace ***looks good to me*** with a list of cases that passed, failed, or changed. Some checks are plain code, some are an LLM judge that we've tested against people, and some are a person like Marcus reading what happened. Offline evals catch known problems before they ship, online evals find new ones after, and the loop between them turns every new failure into a test that keeps it from coming back. If you're new to all of this, the best place to go next is [Error Analysis on Real Traces](https://www.kirupa.com/ai_fundamentals/error_analysis_on_traces.htm). It's the first step in the loop, and it's the one that tells us what all of the other checks should be looking for. ## Test your knowledge! [Take the LLM Evals Quiz](https://www.kirupa.com/quizzes/what_are_llm_evals.htm). Practice with 5 multiple-choice questions and an explanation after every answer.