Skip to content
Bruno Lucildo
All experiments

EXP / 002

Proof of conceptIn development

Validating model output with rules and a judge model

Checking what a language model says with rules in code and a second model that has to quote the evidence.

Model: gpt-4o-mini

Technologies

  • TypeScript
  • Node.js
  • OpenAI API
  • SQLite

Objective

Keep every statement an analyst persona makes tied to the evidence the user supplied.

Problem investigated

Prompt instructions alone do not guarantee that a model follows a policy. In the first live tests it produced flattering adjectives, actions the data never mentioned and scores for attributes without evidence.

Approach

Deterministic rules enforce the answer format and reject numbers, adjectives and actions that are not in the user's input. A semantic verifier, a second model, judges each remaining statement and must quote the evidence; a quote that is not in the evidence is rejected, and if the verifier itself fails, the answer is accepted with a warning. A rejected answer gets one automatic correction attempt that lists the violated rules. A live evaluation harness runs the real model on fixed cases and on cases written afterwards, and reports how many answers pass.

Results

On the cases that guided the fixes, answers valid on the first attempt went from 0 of 15 to 12 of 15 over four runs, and 14 of 15 after the correction attempt; that last figure is optimistic, because the fixes were made on those same cases. On a second round written afterwards, 43 of 48 answers were valid on the first attempt and 48 of 48 after the correction (22 of 24 and 24 of 24 on those cases alone). An embedded instruction to give every attribute 99 did not change the scores. Calibrating the verifier on 30 statements labelled by the author, over three repetitions it rejected 41 of 45 unsupported statements and accepted 42 of 45 supported ones.

Limitations

The rules are lexical, check number words only up to fifty and cannot prove that every sentence is correct. The judge is itself a model: it consistently accepted one false claim of missing data. The labels were set by the author alone, and 30 statements and 15 answers per run are small samples that describe this setup, not a general error rate. The model is not fully deterministic: one score varied by ten points between runs at temperature 0. None of this replaces human review.

What I learned

Measure with cases written after the fixes, or the numbers flatter the work. A verifier should not be trusted blindly: requiring a quote made it checkable. The check costs an extra request per answer, the price of fewer unsupported statements.