The code, data and records behind the paper The System–Specification Alignment Problem: Forming, Assessing, and Warranting Competence in Artificial Agents.
In the paper's study, an agent learns exact integer arithmetic (addition, subtraction, multiplication and division) by imitating a scripted teacher that writes the standard written calculation on a grid. Its competence is then tested on problems longer than any it trained on. This repository holds everything the study used and everything needed to check it:
- the teacher, the agent, training and testing;
- every test set and both holdouts;
- one record for every run started;
- the script behind each table and figure.
One command checks every number in the paper against the records, and one command trains and tests any run from its configuration and seed.
The trained agents and their checkpoints are not included, and of the pilot runs only their test
sets are (data/pilot/).
| Folder | What it holds |
|---|---|
src/ssap_arithmetic/ |
The package: the teacher and the four operations (teachers/, bundles/), the workspace (environments/), the agent (models/torch/agent/), training (train/), testing and scoring (evaluate/), the sets (data/), the records and their analysis (evidence/), and the study's own commands (study/). |
configs/ |
One file per configuration (main.yaml, staged-curriculum.yaml, 5x5-view.yaml, …), and each round's design, run settings, launch file and analysis settings (baseline/, redesign/, control/, search/). Settings the rounds share are in shared/, the teacher's in teachers/. |
data/ |
The sets of each round (pilot/, baseline/, redesign/, control/) and both holdouts (holdout-1/, holdout-2/), as JSON Lines, with each part's manifest and the teacher's step counts. The specifications they are drawn from are in data/specifications/. |
records/ |
What the runs left. Each round's ledger has one entry for every run started, including those that failed or were invalidated. Also: the collected runs (their results, validation curves, costs and per-problem tables, packed in collected.tar.xz), each round's per-run records and validation curves, the search's records, the model costs, and the trace check's output. |
analysis/ |
The scripts that rebuild the paper's tables and figures from records/, and check every printed number. |
results/ |
What analysis/ writes: each paper table as CSV (tables/), the paper's two result figures (figures/), and every further table and figure of the three rounds (further/). |
docs/ |
The method in full: the agent's architecture, the teacher, the data and training, and a glossary from the paper's terms to the code's names. Start at docs/README.md. |
tests/ |
A small test suite: the teacher's answers, scoring, the separation of the sets, and one training step. |
Python 3.12 or later and uv:
uv sync # enough to check the paper
uv sync --extra torch # also train and test agents (PyTorch)
The figures are drawn in the paper's font, TeX Gyre Termes, with FreeSerif for the few glyphs it
lacks; drawing stops with an error if either is missing. On Debian or Ubuntu,
sudo apt install fonts-texgyre fonts-freefont-otf installs both. Elsewhere, a TeX Live
installation provides both (they are found through kpsewhich), or install the two font families
on the system.
uv run python -m analysis.run_all
This takes a few minutes on one CPU core: about three and a half on Linux, longer on Windows, where the teacher's move count is slower. It runs four steps in order:
- It unpacks the collected runs.
- It rebuilds each round's per-run records, validation curves and reports into
outputs/analysis/, and checks that the rebuilt per-run records and curves equal the shipped ones. - It writes every table and figure into
results/. - It compares every number the paper prints with those tables, about 2,000 values, rounded as the paper rounds them.
It prints a count for each table, lists any mismatch, and exits with 1 if there is one. Rebuilt
elsewhere, the tables in results/tables/ come out identical. The figure files can differ in
their bytes with the fonts' versions, and on Windows the further outputs are written with CRLF
line endings. The model
costs (parameters and operations per step) are shipped. To recompute them, run
uv run python -m analysis.build_records --model-costs, which needs the torch extra and takes
about 11 more minutes.
The tests run with uv run pytest.
Each script in analysis/tables/ writes results/tables/<name>.csv. The two result figures are
drawn by the analysis (configs/baseline/figures.yaml, configs/redesign/figures.yaml) and
copied to results/figures/.
| In the paper | Script and output |
|---|---|
| Results of the main configuration | results_main.py → results-main.csv |
| Accuracy against operand length (figure) | results_length.py → results-length.csv; results/figures/results-length.pdf |
| Accuracy by operand length for the control | results_by_length_control.py → results-by-length-control.csv |
| Interpretations and their rival explanations (the outcomes) | rival_explanations.py → rival-explanations.csv |
| Ranges and sets of the arithmetic study | data/specifications/; docs/data.md |
| Structural families | structural_families.py → structural-families.csv (definitions, beside the code's) |
| The teacher's demonstration of 47 + 5 | teacher_trajectory.py → teacher-trajectory.csv |
| Body movement in the teacher's demonstrations | teacher_moves.py → teacher-moves.csv |
| Modules of the agent; the architecture | docs/architecture.md |
| Training settings of the main configuration | training_settings.py → training-settings.csv |
| Configurations and their search | search.py → search.csv |
| Checks on reporting choices | reporting_choices.py → reporting-choices.csv |
| Baseline results for every configuration | results_configurations.py → results-configurations.csv |
| Structural families within the formation range | families_in_range.py → families-in-range.csv |
| Accuracy against operand length, by configuration (figure) | results_length_by_variation.py → results-length-by-variation.csv; results/figures/results-length-by-variation.pdf |
| Redesign results for every configuration | results_configurations_redesign.py → results-configurations-redesign.csv |
| Predictions about the field of view | predictions.py → predictions.csv |
| Comparisons of the control | control_comparisons.py → control-comparisons.csv |
| Accuracy by length on the control's test problems | control_by_length.py → control-by-length.csv |
| Accuracy on the second holdout | second_holdout.py → second-holdout.csv |
| Numbers in the text | prose.py → prose.csv |
analysis/paper-numbers.csv lists every printed value with the table cell it is checked against.
A few statements have nothing to compare: the family definitions are text, and the patience is
stored in validations rather than problems (configs/shared/curricula.yaml shows the two are the
same rule). The check lists these as not checked.
Every run is trained, tested and recorded by one command, from its round's launch file:
uv run ssap-arithmetic train configs/baseline/launch.yaml --configuration main --operation addition --run 1
- What a run is. A run is a configuration (a file in
configs/), an operation and a run number k, whose seed is 100 + k. From it the run derives a seed for each source of randomness: initialisation, training problems, window offsets and batch order. Acting draws no random numbers. - Where a run writes. To
outputs/, never to the shipped records. Its ledger entry is written before it starts, and a stopped run resumes from its last checkpoint when trained again. - Without options,
traintrains every run of the round in turn, as many as the design names. The baseline's design names 176 runs. - The analysis of your own runs:
ssap-arithmetic status <launch file>shows how far a round's runs have got.ssap-arithmetic records <analysis file>andssap-arithmetic analyse <analysis file>build the per-run records, tables and figures. The analysis files inconfigs/read the paper's records. For your own runs, point a copy'sledgersandrunsat your launch file'sledgerandcollected.ssap-arithmetic test-holdoutandssap-arithmetic test-stored-checkpointstest trained agents on the first holdout, and test the checkpoints a run stored.ssap-arithmetic --helpand each command's--helpgive the details.
- The study's own commands:
python -m ssap_arithmetic.study.redesignandpython -m ssap_arithmetic.study.controltest reused agents, train main longer, and test on the second holdout.python -m ssap_arithmetic.study.searchruns the hyperparameter search.python -m ssap_arithmetic.study.setsrebuilds and verifies the sets from their specifications (docs/data.md).
What it costs. The runs were trained on GPUs, in single precision. In GPU-hours:
| Round | GPU-hours |
|---|---|
| Search | about 229 |
| Baseline, main configuration | about 131 |
| Baseline, the variations | about 1,230 |
| Redesign | about 47 |
| Control | about 21 |
A run's device and precision change its arithmetic slightly. So a repeated run reproduces its
configuration's distribution of agents, not each agent bit for bit. On the CPU with one thread
(OMP_NUM_THREADS=1), a run reproduces itself exactly.
A preprint is forthcoming; please cite it once it is available.
Kobe Knowles. The System–Specification Alignment Problem: Forming, Assessing, and Warranting Competence in Artificial Agents. Preprint, forthcoming.
Apache License 2.0; see LICENSE.