Model Training

How to Evaluate LLM Responses with Python and a Review Rubric

Start with a local response-checking example, then build a review process that makes failures, judge limitations and model comparisons visible.

Qvantus AI · EditorialPublished 4 min read
Performance graphs displayed on a laptop screen
Photo by Luke Chesser / Unsplash.

Quick answer

Evaluate LLM responses against explicit task criteria on a versioned set of examples. Use deterministic checks for narrow requirements, judge models for a reviewed rubric and human inspection for disputed cases. Compare the same examples across versions; a phrase pass rate is not a factual-accuracy score.

What you will take away

  • Run a local Python example without an API key or GPU.
  • Keep rule compliance, factual support and usefulness separate.
  • Save failures and compare model or prompt versions on the same examples.
On this page

1. Define what a useful answer must do

Choose one task before choosing a metric. For a support assistant, separate answering from the supplied policy, requesting missing information and escalating an unsupported request. An answer can be polite while making an unsupported promise. Your evaluation should make that difference visible.

Create records with stable identifiers, the input, any necessary source context, the generated response and reviewed criteria. Include ordinary requests, ambiguous inputs and known failures. Keep a final held-out set away from prompt development and judge calibration. A small sample helps debug the process; it does not establish performance on every future request.

2. Run the response-checking example

Download the LLM evaluation starter, unzip it and open its directory. It uses Python 3.10 or later and the standard library. The included JSON contains four synthetic responses with required and forbidden phrases. The script writes a report showing which rule failed for each response.

The unchanged sample passes two of four responses. Inspect the individual missing_required and forbidden_matches fields before looking at the aggregate rule_pass_rate. Change one response in responses.json, rerun the command and compare the affected record. This is an exercise in making a check inspectable, not a customer benchmark.

cd llm-evaluation-starter
python3 evaluate.py --output report.json
python3 -m unittest discover -s . -p 'test_*.py'

3. Understand what the rule score measures

The example normalizes case, tokenizes English letters and digits and checks complete token sequences. It catches an absent required phrase or a supplied forbidden phrase. It does not understand synonyms, negation, source evidence or whether a statement is true. Its tokenizer is also unsuitable as a general multilingual text evaluator.

Keep the metric name narrow. If two of four responses pass these rules, the phrase-rule pass rate is 50%. Calling that result model accuracy would imply a broader judgment that the script never made. Review a response that passes every phrase rule but gives the wrong advice; that counterexample explains why additional criteria are needed.

QuestionAppropriate evidence
Did a required phrase appear?A deterministic token or format check.
Is the claim supported by the supplied policy?A source-grounded review against the actual policy.
Is the answer useful for this task?A defined rubric, calibrated with reviewed examples.
Did the new version regress?A paired comparison on unchanged evaluation inputs.

4. Add a calibrated judge where it helps

Write a rubric that describes each score and includes a place for uncertainty. Give the judge the input, response and reference material it needs. Save the judge model, prompt, settings and rubric revision with the result. A score without that context is difficult to reproduce or compare.

The MT-Bench research examines position, verbosity and self-enhancement biases in LLM judges. Test the judge on human-reviewed examples and inspect disagreements. For pairwise comparisons, reversing answer order can help reveal order sensitivity. Treat instructions embedded in evaluated text as untrusted input rather than allowing them to replace the review task.

5. Compare failures before changing training data

Run the baseline and candidate through the same evaluation procedure. Record paired outcomes: both pass, both fail, candidate improves and candidate regresses. Review failure categories separately so a gain in formatting does not hide a loss in policy compliance. Document the counts and the example identifiers.

Use reviewed failures to form a development dataset or a new prompt hypothesis. Preserve an independent final test; repeatedly training on its failures changes what that test measures. In Qvantus, explore domain rules, configured evaluation and Experience Buffer review to connect this process with the next improvement cycle.

Common questions

Can I evaluate existing answers without calling an LLM?

Yes. The included example checks saved responses locally. It can validate the supplied phrase rules without generation calls. Semantic review or factual verification requires additional evidence and a suitable evaluation method.

How many examples are enough?

There is no universal sample size. Use a small set to debug the rubric and code, then plan coverage and sample size around the task, important subgroups and the decision you need to make. Report uncertainty and keep the final test independent.

Is this a Qvantus API integration?

No. The downloadable code is a standalone teaching example. Hosted Qvantus evaluation uses the models, configuration and entitlements supported by your platform plan.

Sources & further reading

Published by Qvantus AI. These guides provide practical planning frameworks; measured results depend on the model, data, software and hardware configuration.

All guides

Find your starting point

Explore a workflow around your AI task.

LLM evaluation

A useful answer needs more than fluent language. Define what your assistant should get right, test representative responses and review the failures before changing your prompt, model or training data.

Explore the workflow →

AI model fine-tuning

Start with a specific behavior your baseline model does not handle well. Prepare reviewed examples, select a supported training configuration and measure whether the resulting model improves the task.

Explore the workflow →
LLM Evaluation with Python: Rules, Rubrics & Failures | Qvantus AI