Book a free call

How to Implement LLM Evaluation Step by Step

LLM evaluation means testing your model on fixed cases with known good answers, so you can tell whether a prompt or model change made things better or worse.

Hertiv engineering teamReviewed by a senior engineer
6 min read
How to Implement LLM Evaluation Step by Step
On this page

Short answer

LLM evaluation is the practice of testing a language model on a fixed set of real cases with known good answers, then scoring each answer against clear rules. It turns arguments about quality into numbers you can compare, so a prompt or model change is kept only when it improves the score.

What is LLM evaluation?

LLM evaluation is the practice of testing a language model on a fixed set of real cases with known good answers, then scoring each answer against clear rules. Instead of asking whether the model 'feels better', you run the same cases through each version and compare the results.

It matters because language models change behaviour in ways that are hard to see by reading a few answers. A new prompt can fix one failure and quietly create three more. An evaluation set catches that, because the same cases are scored every time.

Evaluation is not the same as testing the software around the model. Unit tests check that the code runs. Evaluation checks that the model's answers are correct, grounded in your sources, safe and fast enough for the people who use them. Both are needed, and they answer different questions.

What should you test?

You should test the behaviours that cost you money or trust when they go wrong, not everything the model could ever do. A small set of focused tests beats a large set of vague ones.

What to test What good looks like How to score it
Correctness Answer matches the known answer Exact or graded match
Groundedness Every claim comes from a cited source Source check per claim
Safety Refuses or redirects harmful requests Pass or fail per case
Format Output follows the required structure Schema validation
Latency and cost Answers arrive fast enough and cheaply Seconds and cost per case

Start with correctness and groundedness, because those are the failures users notice first. Safety tests matter most for products that face the public. Format and latency tests matter when the model's output feeds another system. The LLM evaluation basics explain how these test types fit together.

How to build an evaluation set

You build an evaluation set by collecting real cases from your own product, labelling the right answer for each one, and keeping the set fixed so results stay comparable over time.

A workable sequence:

  1. Collect real inputs. Take 50 to 200 real questions, documents or conversations from logs, support tickets or past work. Real cases beat invented ones, because they show the awkward phrasing users actually use.
  2. Write the expected answer for each case. Keep it short: the facts the answer must contain, and the facts it must not invent. A second person should check the labels.
  3. Cover the hard cases. Include edge cases, ambiguous questions and the failures you have already seen. A set of only easy cases will always pass.
  4. Split the set. Keep most cases for regular testing and hold back a smaller set for final checks, so you do not tune the prompt to the test itself.
  5. Freeze the set. Once the set is fixed, changes to it should be rare and recorded, or you lose the ability to compare versions.

Twenty well-labelled cases will guide design more than a hundred vague ones. If labelling feels slow, label the cases that caused real problems first and grow the set as failures appear.

How to run the evaluation

You run an evaluation by feeding each case through the model with the same prompt and settings, scoring the answers, and recording the results so the next run can be compared.

A practical routine:

  1. Fix the settings. Use the same model version, temperature and prompt for every run, and record them with the results.
  2. Run the full set. Send each case through the system exactly as a user would, including retrieval and tools, not just the raw model.
  3. Score with rules first. Use exact checks where possible: does the answer contain the required facts, does it cite a source, does it match the required format?
  4. Use a judge model for the rest. For open answers, a second model can grade against a rubric, but spot-check its grades by hand on a sample.
  5. Record everything. Save the prompt, the model version, the scores and the failing cases, so a later run can be compared fairly.

Run the evaluation before every release that touches the prompt, the model or the retrieval step. The cost of LLM evaluation is mostly the time spent labelling and reviewing, not the model calls themselves.

Example (hypothetical): evaluating a support assistant

Example (hypothetical): a support team builds an evaluation set of 200 real tickets, each labelled with the correct answer and the source article it must cite. The first run of their assistant answers 164 of 200 correctly, which is 164 / 200 = 82 percent. Of the 36 failures, 22 cite the wrong article and 14 invent a policy that does not exist.

The team changes the prompt to require a citation before the answer and re-runs the same set. This time 178 of 200 are correct, which is 178 / 200 = 89 percent. The citation errors fall from 22 to 9, while the invented-policy errors fall from 14 to 8. The change is kept because the score improved on the same fixed set.

The team also tracks cost and speed. Each run costs 200 cases x $0.02 per case = $4.00 in model calls, and takes about 10 minutes. That is cheap enough to run before every release, which is the point: an evaluation that is cheap and fast gets used, and one that is slow and costly gets skipped.

How to read the results and act on them

You read evaluation results by looking at the failures, not just the score. A score of 85 percent tells you little on its own. The 15 percent that failed tells you what to fix next.

Group the failures by cause. If most failures cite the wrong source, the retrieval step needs work. If most invent facts, the prompt needs stricter grounding rules. If most fail on one type of question, the evaluation set needs more cases of that type, or the product needs a fallback for it.

Then decide what to change, and change one thing at a time. If you change the prompt, the model and the retrieval step together, you cannot tell which change helped. Re-run the same fixed set after each change and keep only the changes that improve the score without breaking another test type.

When a failure is a safety issue, fix it before release even if the overall score looks good. A single harmful answer can cost more than a small drop in correctness across the set. The best LLM evaluation tools for startups can help automate the scoring once the set is stable.

What are the common mistakes?

The most common LLM evaluation mistakes are testing with invented cases, changing the set to make the score look better, and never looking at the actual failures.

  • Invented test cases. Cases written by the same person who wrote the prompt tend to match what the prompt already does well.
  • Moving the goalposts. Editing or removing failing cases after a run makes the score meaningless.
  • One overall score. A single number hides whether correctness, safety or format is the problem.
  • Testing the model, not the system. Scoring the raw model while users get answers from a pipeline with retrieval and tools measures the wrong thing.
  • No held-out set. Tuning the prompt against the same cases you test on produces a score that flatters the system.
  • Skipping the review. An evaluation that runs but is never read is a report nobody acts on.

If you are planning an LLM feature and want the evaluation designed before launch, LLM development covers the full build.

For the checks to run before release, see how to evaluate an LLM application before launch.

Key takeaways

  • Evaluation turns quality arguments into numbers you can compare across versions
  • Real cases with known answers beat invented cases every time
  • Fix the set, the prompt and the model version per run, or the scores cannot be compared
  • Read the failures by cause. The score tells you how much is wrong; the failures tell you what to fix
  • Change one thing at a time and keep only changes that improve the score

Frequently asked questions

How many cases do I need for LLM evaluation?

Start with 50 to 200 real cases with known good answers. Twenty well-labelled cases are enough to guide early design, and the set can grow as failures appear. The cases should include edge cases and past failures, not just easy questions the model already answers well.

Should I use a judge model to score answers?

A judge model works well for open answers that cannot be scored with exact rules, as long as you give it a clear rubric and spot-check its grades by hand. Use rule-based checks first for facts, citations and format, since those are cheaper and more reliable.

How often should I run an LLM evaluation?

Run it before every release that touches the prompt, the model, the retrieval step or the tools. The run itself is usually cheap, so the cost is in labelling and reviewing. Teams that evaluate only before big launches miss the small regressions that add up.

What is the difference between evaluation and testing?

Testing checks that the software runs correctly, such as the API responding and the output parsing. Evaluation checks that the model's answers are correct, grounded, safe and well formatted. A system can pass all its software tests and still give wrong answers.

Can evaluation prevent hallucinations?

It cannot prevent them entirely, but it measures how often they happen and whether a change makes them rarer. Groundedness tests that check every claim against a cited source are the most direct way to catch invented facts before users see them.

Do I need special tools for LLM evaluation?

Not at first. A spreadsheet of cases, a script that runs them and a scoring rubric are enough for most teams. Dedicated evaluation tools become useful once the set is large, the runs are frequent, or several people need to see the results in one place.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building an LLM feature and need to know if it is ready? Talk to Hertiv.

A senior engineer replies within one business day. Or see our LLM Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call