The table
Each row is one test case: a prompt, and the criteria the answer is judged against.The answer under test
The judge prompt
Build it withpxtf.string.format, not Python’s str.format.
The verdict and the score
The judge returns prose. A UDF pulls the number out so you can sort and aggregate on it.None rather than 0.0 on a malformed verdict matters: a zero is indistinguishable
from a genuinely bad answer, and it drags any average you compute.
Run it
openai.chat_completions() calls need OPENAI_API_KEY. Inserting a row runs the answer, the
judge prompt, the verdict, and the score in order, because each column depends on the one above it.
A UDF cannot be defined in the global namespace of a plain Python script. In a notebook or a REPL
the definition above works as written; in a script, put
extract_score in an importable module
and import it.Notes
- Add a criterion and only the affected columns recompute; the answers already generated are not called again.
- To grade the same answers under two judges, add a second
judge_responsecolumn with a different model rather than a second table. - To grade answers your application already produced, put these columns on that table instead of a separate one. The judge does not need its own copy of the data.
pxt.create_table()here is the notebook and test form. An application declares the same columns on aTableModelinapp.pyand creates them withpxt schema update.