import whileai.simulations as wai, then wai.name.
SimulationData
whileai/simulations/data.py.
SimulationData.compare_judges
judges maps a name to a spec string ("typesafe:jev-latest"),
a backend object, a wai.Judge or any judge callable. Each grades
its own copy of the rows under this run’s system prompt and tools,
then is scored the way judge_trust scores one judge: agreement
with a Wilson interval, kappa, leak rate, unsure and unjudged
counts, seconds per row. Returns a JudgeComparison that prints
as a table ranked by kappa; whileai.judge_comparison.compare_judges
has the full account and takes a bare row list.
SimulationData.grade
simulate to score the rows without
leaving the object. Simulation never calls it on its own. Three paths,
chosen by what you pass:
- No callable (or
llm=True):grade_llm, the hosted LLM judge (Phi-4 unlessWHILEAI_JUDGEis set, a different family from the hosted Qwen policy), read fromVLLM_API_KEY. It writesreward(0 or 1) andreasononto the rows in place and returns the judge report, a dict withgraded,n0,n1,backend,judge_versionandwarnings. grader=, a plain callable returning a number or{"reward": ..., "reason": ...}per row: scores every row in place overconcurrencythreads and returns the run itself, sodata.grade(my_grader).pass_atreads through.judge=, the contract path: any callable honoring the judge contract, which returns{"reward": 0 or 1, "reason": str, "markers": {name: value}}per row (a bare number works too). The contract and its failure modes are written out in full inwhileai.simulations.score.judging(note thescore.; there is nowhileai.simulations.judging). It returns aScoredDataof copies: the trajectories here stay unmodified, judge errors are marked per row instead of coerced to 0, and its output feedsexport_datasetandsimulate(traces=...)directly.
version: names the judge’s version (model, rubric hash) and is recorded on every scored row; the hosted grader stamps its own.rubric: what doing the job means, as text, for the hosted judge; without it the judge grades the conduct floor only, and says so.use_privileged:Trueshows the hosted judge each row’sprivilegedblock (principle, reference, hidden state) the agent never saw.trust: the judge check against the rows’ human labels (attach_labels(kind="human")), run on every path, with the summary stamped on each graded row’sjudge_meta["trust"]."warn"(the default) logs one line when the check failed or no labels exist,"require"raises instead,"off"skips it.path: write the graded run’s JSONL there afterwards.spec: which model judges on the hosted path, as a backend spec ("typesafe:jev-latest","openai:gpt-4.1-mini"); the same keywordgrade_llm,pairwise_judgeandrubric_judgetake.llm_specis its older name and still works.
SimulationData.grade_llm
WHILEAI_JUDGE is set), never the policy model.
use_privileged shows the judge each row’s privileged block
(principle, reference, hidden state) the agent never saw. trust
is the judge check against human labels: see grade.
payload_chars caps the evidence the judge reads per row and
max_tokens its reply (defaults JUDGE_PAYLOAD_CHARS and
JUDGE_MAX_TOKENS in defaults.py); both land in
judge_meta.
SimulationData.leak_report
privileged block? Reads the
trajectories, which still carry the block; rows() is scrubbed
and would check nothing. Same report as leak_report.
SimulationData.llm_grade
SimulationData.push
purpose is the section it lands in on the Datasets page
("train" by default; "holdout" or "eval").
holdout=0.2 keeps a fifth of the tasks (by scenario_id) out
of the training set and pushes them as a second, linked dataset
with purpose "holdout"; the entry carries it as ["holdout"].
The simulation mode is recorded on both.
api_key defaults to the WHILEAI_API_KEY env var, then the
key saved by wai login. Pass parent (a ds_...
id) when this run iterates on an existing dataset, so lineage shows
on the platform. publish=True with an agent name also puts it
on the public catalog at huggingface.co/while-ai as a card. Returns
the registry entry with datasetId.
gate=True runs publish_gate first: every graded row gets a
calibration stamp (per-task pass rate, k, producing policy),
and an RL-shaped run that is ungraded or has no mixed group is
refused with PublishGateError. The gate report is returned as
entry["gate"]. gate=False uploads rows as they are.
endorsed names what the reward should track (feature-name
substrings, e.g. "tool:lookup_order") for the gate’s
hack_scan; strict_hacks=True refuses a set whose reward
is best explained by something else.
SimulationData.rank
reward untouched.
Writes quality, quality_reason, quality_scores on each
trajectory and rewrites the saved JSONL, or path if you pass one.
SimulationData.report
data.coverage).
SimulationData.select
Selection that prints its report.
With no mode: diverse pass-labeled demonstrations via
select_for_sft, one of each distinct way of being right before
any repeats, junk and duplicate prompts dropped. With
mode="rl" or "sft": optimize, the full gate sequence
(privileged leaks, difficulty band, unanimous groups, duplicates,
truncation, hack scan), with band, endorsed and
truncated as there.
Requires graded rows — grade in-loop (grade=True, grader=)
or afterwards with grade(). The report lands in
search["selection"] and on the result’s .report.
SimulationData.training_set
select() picks diverse pass-labeled rows, export_training
writes them as chat JSONL with this run’s system prompt and tools
and the tool-call round-trip gate. Returns the export report with
the selection report attached; pass output to write the file.
Raw simulation rows are not the training artifact — this is.
conversation
whileai/simulations/data.py.
User/agent turns from prompt + steps. Tool calls stay on the assistant turn.
grade
whileai/simulations/data.py.
Grade rows 0 or 1 with the hosted LLM judge and write a reason beside each.
Reach for it when the rows are a JSONL path or a row list rather than
a SimulationData you hold (that object has the same call as
data.grade()). It writes reward (0 or 1) and a one-sentence
reason on each row, keeps a previous score as qwen_reward
when present, and returns the judge report, a dict with graded,
n0, n1, backend, judge_version, warnings and
path. It does not run during simulate(), and search never
reads reward. The default judge is the hosted Phi-4 unless
WHILEAI_JUDGE is set; it reads VLLM_API_KEY.
source: aSimulationData, a JSONL path, or a row list. A path source is rewritten graded, unlessoutputnames another file; a row list is updated in place.policyandtools: for a path or row list, pass the agent’s system prompt and tool schemas so the judge sees the rules the agent was under; aSimulationDatasupplies its own.limit: grade that many rows, then stop.spec,base_url,model,api_key: point the judge at another OpenAI-compatible server instead of the hosted one.use_privileged:Trueshows the judge each row’sprivilegedblock (principle, reference, hidden state) the agent never saw.trust: the judge check against human labels ("warn","require","off"), the same asSimulationData.grade.payload_chars(8000) caps the evidence the judge reads per row andmax_tokens(120) its reply; both land injudge_meta.
grade_llm
whileai/simulations/data.py.
Grade rows 0 or 1 with the hosted LLM judge and write a reason beside each.
Reach for it when the rows are a JSONL path or a row list rather than
a SimulationData you hold (that object has the same call as
data.grade()). It writes reward (0 or 1) and a one-sentence
reason on each row, keeps a previous score as qwen_reward
when present, and returns the judge report, a dict with graded,
n0, n1, backend, judge_version, warnings and
path. It does not run during simulate(), and search never
reads reward. The default judge is the hosted Phi-4 unless
WHILEAI_JUDGE is set; it reads VLLM_API_KEY.
source: aSimulationData, a JSONL path, or a row list. A path source is rewritten graded, unlessoutputnames another file; a row list is updated in place.policyandtools: for a path or row list, pass the agent’s system prompt and tool schemas so the judge sees the rules the agent was under; aSimulationDatasupplies its own.limit: grade that many rows, then stop.spec,base_url,model,api_key: point the judge at another OpenAI-compatible server instead of the hosted one.use_privileged:Trueshows the judge each row’sprivilegedblock (principle, reference, hidden state) the agent never saw.trust: the judge check against human labels ("warn","require","off"), the same asSimulationData.grade.payload_chars(8000) caps the evidence the judge reads per row andmax_tokens(120) its reply; both land injudge_meta.
llm_grade
whileai/simulations/data.py.
Module helper: advisory LLM scores on an existing SimulationData.
rank
whileai/simulations/data.py.
Score already-generated rows. source is a JSONL path, a row list,
or a SimulationData. Does not change simulate() or reward.