Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions app/nullius/catalogue/benchmarks/simpleqa/benchmark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"key": "simpleqa",
"title": "SimpleQA",
"category": "Factuality",
"domain": "Short fact-seeking questions, each with a single answer, collected to be hard for GPT-4.",
"scoring": "GPT-4.1 judge",
"harness": [
"standard",
"harbor"
],
"origin": "official",
"good_to_know": [
"The rate is the share of questions graded correct. Incorrect and not attempted both count as a miss; each trial keeps its grade.",
"The grader runs at temperature 0.5, the upstream's setting: the same answer can get another grade on another run.",
"Agents run with their web tools off, as the upstream asks a model with no tools. In a container an agent reaches only its model; unsandboxed on this machine, it has the machine's network.",
"Like the paper offers the upstream's OpenAI models that the provider lists under their own ID. Another model, or one the provider names differently, runs as Any of your choice, asked as the listed model you choose.",
"On Harbor the tasks have internet access, and their own script grades with gpt-5-mini on OpenAI's API: that route needs an OpenAI key. Compare Harbor scores with Harbor scores only."
],
"upstream_limitations": [
"The grade is the first capital A, B or C in the judge's reply. A judge that writes the word instead is misread: NOT_ATTEMPTED counts as correct, CORRECT and INCORRECT as not attempted.",
"A judge call the provider refuses as a bad request raises no error: the answer is graded not attempted.",
"The authors estimate that about 3% of the reference answers are wrong or ambiguous.",
"The README's SimpleQA numbers were graded by GPT-4o. The code has graded with GPT-4.1 since May 2025, so a run does not compare with them.",
"The network does not block a web search the model's provider runs: each agent needs its own switch to turn web search off, for a fair comparison."
],
"limitations": [
"A job reports the correct rate alone: the upstream's incorrect and not attempted rates, its accuracy given attempted and its F1 are not computed.",
"A limit takes the first questions of the file. The upstream's --examples draws a seeded random sample.",
"The upstream's three Claude models are not offered: they are asked through Anthropic's API while the grader is asked through OpenAI's, and a run has one provider.",
"A model call the provider refuses ends the question as an API error, with no score. The upstream grades its placeholder reply as a miss.",
"Runs and Compare show an Original run under its model ID: listed models that share one, such as o3 and o3_low, read alike there. A run's Reasoning setting replaces a listed model's own effort."
],
"datasets": [
{
"key": "simpleqa",
"title": "SimpleQA",
"tasks": 4326,
"official": "https://github.com/openai/simple-evals",
"source": "Harbor hub",
"registry": "openai/simpleqa",
"hub": "openai/simpleqa",
"verifier": "SimpleQA's grader prompt, answered by a judge model: correct, incorrect or not attempted. Nullius runs the upstream's own grader; Harbor's tasks run a script of their own.",
"notes": "4,326 questions. MIT License."
}
],
"timeouts": {
"env_setup": 300,
"agent_setup": 360,
"agent_run": 3000,
"verify": 600
},
"report": {
"sources": [
"simpleqa",
"openai/simpleqa"
]
},
"citation": "@misc{wei2024measuringshortformfactualitylarge,\n title={Measuring short-form factuality in large language models}, \n author={Jason Wei and Nguyen Karina and Hyung Won Chung and Yunxin Joy Jiao and Spencer Papay and Amelia Glaese and John Schulman and William Fedus},\n year={2024},\n eprint={2411.04368},\n archivePrefix={arXiv},\n primaryClass={cs.CL},\n url={https://arxiv.org/abs/2411.04368}, \n}",
"citation_source": "https://arxiv.org/abs/2411.04368",
"evidence": [
{
"label": "Grade",
"path": "grade",
"values": {
"CORRECT": "Correct",
"INCORRECT": "Incorrect",
"NOT_ATTEMPTED": "Not attempted"
}
},
{
"label": "Answer",
"path": "answer",
"reply": true
},
{
"label": "Expected answer",
"path": "expected"
},
{
"label": "Judge said",
"path": "judge_said"
}
]
}
251 changes: 251 additions & 0 deletions app/nullius/catalogue/benchmarks/simpleqa/driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
"""SimpleQA's driver for the Nullius standard (JSON lines on stdin and stdout).

What SimpleQA's authors decide - which models they ask and how, the grader's
prompt, the sampler that asks it, how its reply is read, what counts as
correct - is their code, simple-evals at the tested commit ($NULLIUS_UPSTREAM),
imported, not copied. It needs pandas and the openai package, so the driver
runs in the environment of its own that standard.json declares (driver.install).

units - one per row of the test set, named by its row number ("0001"): the
data has no ids
describe - the question as its title and text, its topic and answer type from
the row's metadata; never its answer
setup - the question alone is the prompt, as SimpleQAEval sends it to a
sampler; the workspace stays empty
answer - the original and model setups: the question asked once through the
unit's relay, as SimpleQAEval asks a sampler, by the sampler
simple_evals.py builds for the model's name (its --model): that row
of its models table, evaluated from its own source. A model of the
run's choice is asked by the row its Asked as option names
score - the upstream's own evaluation of one question, SimpleQAEval.__call__,
with the answer handed over as the sampler it evaluates (Said): its
grade_sample fills GRADER_TEMPLATE and asks the judge through the
grading sampler simple_evals.py builds, on the unit's judge route,
and reads the grade; its score, whether the grade is CORRECT, is the
reward
oracle - the reference control: the row's answer field, the gold target
preflight - each role's first request, made by the same samplers on a made-up
question and caught before it is sent

Ours: reading the pinned copy of the test set (the same pandas call as the
upstream's constructor, which is not run: it downloads the file again from its
address at every start, and nothing pins it), the row numbers, Said, reading
simple_evals.py's models table and grading sampler from its source, keeping the
judge's reply for the trial, and the endpoint variables the OpenAI client reads.

The gold target is never in the prompt or the workspace: it is read from the
dataset only when the score is taken.
"""
import ast
import importlib
import json
import os
import sys
import warnings

import pandas

PROTOCOL, sys.stdout = sys.stdout, sys.stderr # the upstream prints (its metrics, its retries): stdout is the protocol's

UP = os.environ["NULLIUS_UPSTREAM"].rstrip("/")
# The repository is a package with relative imports and a types.py of its own: it is imported by its
# folder's name from its parent, never with its own folder on the path, where its types.py would hide Python's.
sys.path.append(os.path.dirname(UP))


def upstream(module):
with warnings.catch_warnings():
warnings.simplefilter("ignore", SyntaxWarning) # its common.py writes \s in plain strings: forty lines of the log at every start
return importlib.import_module(os.path.basename(UP) + "." + module) # as published


simpleqa = upstream("simpleqa_eval")
upstream_types = upstream("types")
# simple_evals.py is read, never imported: it imports every eval of the repository and their packages, and its
# models table and grading sampler are local names of its main().
with open(os.path.join(UP, "simple_evals.py"), encoding="utf-8") as f:
MAIN = ast.parse(f.read())
ROWS = {}
QUESTION = "Compatibility check. Reply OK." # what preflight asks: never a question of the test set


def rows():
"""The test set as SimpleQAEval's constructor reads it - pandas.read_csv, a dict per row - from the
pinned copy, each row under its number."""
if not ROWS:
df = pandas.read_csv(os.environ["NULLIUS_DATASET"])
ROWS.update((f"{n:04d}", row.to_dict()) for n, (_, row) in enumerate(df.iterrows(), 1))
return ROWS


def assigned(name, kind):
"""The expression simple_evals.py's main() assigns to a name."""
for node in ast.walk(MAIN):
if isinstance(node, ast.Assign) and [ast.unparse(t) for t in node.targets] == [name] and isinstance(node.value, kind):
return node.value
raise RuntimeError(f"simple_evals.py no longer assigns {name} where the driver reads it")


def built(expression, base_url, key):
"""An expression of simple_evals.py that builds a sampler, evaluated as that file would - each name it uses
bound as the file imports it - on a route: its samplers make their client as OpenAI(), which reads both variables."""
os.environ["OPENAI_BASE_URL"], os.environ["OPENAI_API_KEY"] = base_url, key
names = {n.id for n in ast.walk(expression) if isinstance(n, ast.Name)}
bound = {alias.asname or alias.name: getattr(upstream(node.module), alias.name)
for node in MAIN.body if isinstance(node, ast.ImportFrom) and node.level == 1 and node.module
for alias in node.names if (alias.asname or alias.name) in names}
return eval(compile(ast.Expression(expression), "simple_evals.py", "eval"), bound)


def row_sampler(setup, model, base_url, key):
"""The sampler simple_evals.py builds for a model's name, as its --model does: that row of its models table.
The original's model is asked as itself. A model of the run's choice (the model setup, which is told the
row it runs as) is asked as the row its Asked as option names, when it names one."""
if setup not in ("original", "model"):
raise ValueError(f"SimpleQA has no {setup} setup")
name = os.environ.get("NULLIUS_OPTION_ASKED_AS", "default")
if setup == "original" and name not in ("default", model):
raise ValueError(f"{model} is a listed model, asked as itself: leave Asked as at default, or choose Any of your "
f"choice (the model setup) to ask a model as {name}")
table = assigned("models", ast.Dict)
table = {ast.literal_eval(k): v for k, v in zip(table.keys, table.values)}
name = model if name == "default" else name
if name not in table:
raise ValueError(f"simple_evals.py has no model {name}")
try:
return built(table[name], base_url, key)
except ImportError as e: # a row whose sampler needs a package the environment has not
raise ValueError(f"simple_evals.py asks {name} with a package the driver's environment has not: {e}") from None


def ask(sampler, question):
"""One question, as SimpleQAEval.__call__ asks its sampler: alone, in one user message."""
return sampler([sampler._pack_message(content=question, role="user")])


class Said(upstream_types.SamplerBase):
"""What was answered, as the sampler SimpleQAEval evaluates: asked the question, it says the answer."""

def __init__(self, text):
self.text = text

def _pack_message(self, role, content):
return {"role": str(role), "content": content}

def __call__(self, message_list):
return upstream_types.SamplerResponse(response_text=self.text, actual_queried_message_list=message_list,
response_metadata={})


class Heard(upstream_types.SamplerBase):
"""The upstream's grading sampler, unchanged, its reply kept: the trial's evidence beside the score."""
reply = None

def __init__(self, sampler):
self.sampler = sampler

def _pack_message(self, **message):
return self.sampler._pack_message(**message)

def __call__(self, message_list):
self.reply = self.sampler(message_list)
return self.reply


def graded(examples, base_url, key):
"""SimpleQAEval over these rows, without its constructor (see the docstring), its grader the grading sampler
simple_evals.py builds: the judge's route sends the run's judge model in the place of the one it names."""
evaluation = simpleqa.SimpleQAEval.__new__(simpleqa.SimpleQAEval)
evaluation.examples = examples
evaluation.grader_model = Heard(built(assigned("grading_sampler", ast.Call), base_url, key))
return evaluation


GRADES = dict(zip(("is_correct", "is_incorrect", "is_not_attempted"), simpleqa.CHOICE_STRINGS)) # its metrics, its words


def units(dataset, setup=None):
return {"units": list(rows())}


def describe(dataset=None, **_):
out = {}
for unit, row in rows().items():
about = ast.literal_eval(row["metadata"]) # the row's own tags: {'topic': ..., 'answer_type': ..., 'urls': [...]}
out[unit] = {"title": " ".join(row["problem"].split()), "text": row["problem"],
"categories": {"topic": str(about["topic"]), "answer_type": str(about["answer_type"])}}
return {"units": out}


def setup(unit, dir, **_):
return {"prompt": rows()[unit].get("problem", "")}


def answer(unit, dir, setup, model, base_url, key, **_):
"""The original and model setups: one question, asked as SimpleQAEval.__call__ asks its sampler. The answer
is the reply as that loop hands it to its grader, whose template formats it: a reply with no content, which
the o-series sampler returns unchecked, reads None there, and is graded as that."""
reply = ask(row_sampler(setup, model, base_url, key), rows()[unit].get("problem", ""))
return {"answer": "{}".format(reply.response_text), "model": model}


def score(unit, dir, transcript, answer, judge=None, setup=None, **_):
if not judge:
raise ValueError("SimpleQA is graded by a judge model, and none was given")
row = rows()[unit]
evaluation = graded([row], judge["base_url"], judge["key"])
result = evaluation(Said(answer or ""))
grade = next(word for metric, word in GRADES.items() if result.metrics[metric])
return {"reward": float(result.score), "passed": bool(result.score),
"detail": {"grade": grade, "judge": judge["model"], "judge_said": evaluation.grader_model.reply.response_text,
"expected": str(row["answer"]), "answer": (answer or "")[-4000:]}}


def oracle(unit, dir):
return {"answer": str(rows()[unit]["answer"])}


def preflight(participant, model, roles, setup=None, **_):
"""Each role's first request as the upstream's own sampler makes it, on a made-up question, with no
network: the client's send is cut, so nothing leaves. A setup's model is asked as answer asks it, the judge
as grade_sample asks it; an agent's own request is not the upstream's, and is left unchecked."""
import httpx
from unittest.mock import patch

class Captured(BaseException): # not an Exception: the samplers retry those without end
def __init__(self, request):
self.request = {"path": request.url.raw_path.decode(), "body": json.loads(request.content)}

def send(client, request, **kw):
raise Captured(request)

nowhere = ("http://127.0.0.1:9/v1", "nullius-relay")
asks = {"judge": lambda: graded([], *nowhere).grade_sample(QUESTION, "OK", "OK")}
if participant == "setup":
asks["agent"] = lambda: ask(row_sampler(setup, model, *nowhere), QUESTION)
requests = []
with patch.object(httpx.Client, "send", send):
for role in roles:
if role not in asks:
continue
try:
asks[role]()
except Captured as captured:
requests.append(dict(captured.request, role=role))
else:
raise RuntimeError(f"{role}: the upstream's sampler returned without a request")
return {"requests": requests}


HANDLERS = {"units": units, "describe": describe, "setup": setup, "answer": answer, "score": score, "oracle": oracle,
"preflight": preflight}
for line in sys.stdin:
if not line.strip():
continue
try:
req = json.loads(line)
out = HANDLERS[req.pop("op")](**req)
except Exception as e:
out = {"error": f"{type(e).__name__}: {e}"}
PROTOCOL.write(json.dumps(out) + "\n")
PROTOCOL.flush()
45 changes: 45 additions & 0 deletions app/nullius/catalogue/benchmarks/simpleqa/proofs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"schema": "nullius.proofs/v1",
"kind": "benchmark",
"key": "simpleqa",
"versions": {
"": {
"proven": {
"simpleqa": {
"units": {
"units": 4326,
"passed": "4326 ids, the same twice, unique"
},
"leak": {
"units": 20,
"looked_for": 13,
"short": 7,
"passed": "20/20",
"note": "7 reference(s) under 12 characters not looked for: too short to tell a leak from chance",
"limit": 20
},
"nop": {
"passed": "0/20",
"value": 0.0,
"expect": {
"at_most": 0.05
},
"units": 20,
"judge": "gpt-4.1-2025-04-14",
"limit": 20
},
"oracle": {
"passed": "20/20",
"value": 1.0,
"expect": {
"at_least": 0.95
},
"units": 20,
"judge": "gpt-4.1-2025-04-14",
"limit": 20
}
}
}
}
}
}
Loading
Loading