SteelReed

Search

Search posts, questions…

AI & LLMQuestion 18 / 25

Middle

LLM output is free text, so you can't `assertEquals`. How do you test a feature that uses an LLM?

Short answer

Split it in two: the code around the LLM gets ordinary unit tests with a mocked model; prompt + model behavior is measured as a pass rate on a golden set of 100–300 cases, and the merge gate compares to the version in production, not to 100%.

vs production versionPR changes prompt, modelRun golden set100–300 casesHard checks: schema,sourcesReference match: numbers,codesLLM-as-judge with rubricMerge gate

3 points to say:

  1. Code around the LLM (JSON parsing, errors, timeouts): unit tests with a mocked model; behavior: pass rate on the golden set.
  2. The golden set comes from real logs, incidents and edge cases; answers are human-reviewed.
  3. Check cheap to expensive: hard checks → reference match → judge → human spot checks; read results per slice.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.