GENAI 102
M08 · L03
Evaluation

Code-Based Evals

The cheapest, most reliable eval is plain code. A deterministic check runs in milliseconds, costs nothing, and never disagrees with itself — the same input always gives the same verdict.

01 / 08
GENAI 102
M08 · L03
What Code Can Check

Facts, Not Opinions

If a rule can be written down, code can enforce it — instantly and without judgment.

  • Exact match — does the output equal the expected answer?
  • Valid format — is it valid JSON?
  • Required fields present — nothing missing
  • A number in range — is the score between 0 and 100?
  • A rule satisfied — no forbidden words, length under a limit
02 / 08
GENAI 102
M08 · L03
When To Reach For Them

Whenever “Correct” Is Checkable

Use a code-based eval any time correctness is objective. They are fast, free, and repeatable, so there is no reason to skip them.

The habit
Run them on every change — they become the first line of your test suite in CI (Module 9).
03 / 08
GENAI 102
M08 · L03
Where Code Stops

The Limit

Code checks facts, not taste. Some questions have no rule to test against:

  • Is this summary good?
  • Is this tone right?
  • Is the answer helpful and clear?

That is where LLM-as-judge and humans come in — the next lesson.

04 / 08
GENAI 102
M08 · L03
Turn Vibes Into Numbers

Build a Small Labeled Set

A handful of input → expected pairs is enough to start. It turns “seems fine” into a number you can track over time — so you know whether a change helped or hurt.

05 / 08
GENAI 102
Build It
From Concept to Capstone

Build It

How to implement: write one deterministic check for your tool — for example, the output is valid JSON with the required fields — and run it on your examples.

  • Weekly AI Tasks tracker — code-check that a parsed task has a valid date and a known status; reject and re-ask otherwise.
  • Personal brand site — code-check that every project entry has a source link and no empty fields.
06 / 08
GENAI 102
Knowledge Check

Check what stuck

Three questions from this lesson. Answer to see why — the explanation appears whether you were right or wrong. Nothing is scored or saved.

Question 1 of 0
Score 0/0

07 / 08
GENAI 102
Summary
Recap

What you learned

Code-based evals are fast, free, and deterministic — use them wherever correctness is objectively checkable, and run them on every change. They can't judge nuance, so a small labeled set of input→expected pairs turns quality into a trackable number.

08 / 08