Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 4 min read

How I Evaluate an LLM Feature Before Shipping It - By Gopi Gugan

I'm Gopi Gugan, a software engineer building AI features with FastAPI, Postgres/pgvector, and React/TypeScript. You can find more of my work at https://www.gopigugan.ca/. The hardest lesson I have learned shipping LLM fe

I'm Gopi Gugan, a software engineer building AI features with FastAPI, Postgres/pgvector, and React/TypeScript. You can find more of my work at https://www.gopigugan.ca/. The hardest lesson I have learned shipping LLM features is this: a demo that looks good in a chat window tells you almost nothing about whether the feature works.

An LLM will happily produce a confident, fluent answer. It will do that whether the answer is right or wrong. So before I ship anything with a model in it, I evaluate it β€” with real inputs, real expectations, and numbers I can compare over time.

Why "it looks good" is not an evaluation

When I first built LLM features, my testing was me typing a few questions and nodding. That is not testing. It has three problems:

  • I only tried questions I already knew the answer to
  • I judged the output by how fluent it sounded, not whether it was correct
  • I had no way to know if a prompt change made things better or worse

An LLM feature needs the same discipline as any other feature: a test set, a pass/fail rule, and a way to rerun it. The only difference is that the "test" is a question and the "expected output" is a judgment, not an exact string.

Build a small eval set first

Before I touch the prompt, I collect 20 to 30 real examples. Not examples I invent β€” real questions from users, support tickets, or documents the feature will actually see.

Each example in my eval set has:

  • The input, exactly as a user would send it
  • What a good answer looks like, in plain words
  • What a bad answer looks like β€” the specific failure I am worried about

I keep the set in a simple JSON file so anyone can add to it. Twenty good examples beat two hundred synthetic ones, because they reflect what users actually ask. I also include a few adversarial cases: vague questions, questions with no good answer, and questions where the model should say "I don't know."

The rule I follow: if a question has no right answer in my data, "I don't know" is the correct answer, and I score it that way.

Measure what matters, not what is easy

For most features I build, three measurements are enough:

  • Correctness: did the answer match the expected facts? I check this with a simple rubric, sometimes with a second LLM as a judge, and sometimes by hand for a small set.
  • Grounding: did the answer come from the retrieved context, or did the model invent it? I check whether the key facts appear in the sources I gave it.
  • Refusal quality: when there was no good answer, did it say so clearly instead of guessing?

I run the eval as a plain Python script, so it fits into the same workflow as my other tests:

import json

def run_eval(eval_file, ask):
    cases = json.load(open(eval_file))
    results = []

    for case in cases:
        answer = ask(case["input"])
        passed = check_answer(answer, case)
        results.append({"id": case["id"], "passed": passed})

    passed = sum(r["passed"] for r in results)
    print(f"{passed}/{len(results)} passed")
    return results

def check_answer(answer, case):
    # A simple rubric: required facts present, forbidden claims absent
    has_facts = all(f in answer for f in case["must_include"])
    no_bad = not any(f in answer for f in case.get("must_not_include", []))
    return has_facts and no_bad

This is deliberately simple. The point is not a fancy framework β€” it is having a number that goes up or down when I change the prompt, the retrieval, or the model. If I change something and the score drops, I know before my users do.

Watch it in production, because evals are not enough

An eval set is a snapshot. Real users will ask things I never imagined, and the model will fail in ways my 30 examples never covered. So I treat production as the second half of evaluation:

  • Log the question, the retrieved context, and the answer β€” not just the answer
  • Sample a few conversations every week and score them by hand
  • Track how often users rephrase, retry, or abandon the feature
  • Add every real failure I find back into the eval set

That loop β€” eval, ship, observe, add the failure to the eval set β€” is the whole system. The eval set grows from real usage, and the feature gets harder to break over time.

What I would do first

If you are adding an LLM feature to an existing app, do not start with an evaluation framework. Start with this:

  1. Write down 20 real questions your users would ask
  2. Write down what a good answer looks like for each one
  3. Run them through your feature and score the results honestly
  4. Fix the worst failure, then rerun the same set

Evaluation is not about proving the model is good. It is about knowing exactly where it is weak, so you can design around it β€” with better retrieval, clearer prompts, or a human in the loop where it matters.

AI does not remove the need for testing. It makes testing more important, because the failures are confident, fluent, and easy to miss. A small eval set and the habit of rerunning it is the cheapest reliability work you can do on an LLM feature.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.