{
  "markdown": "# Mathagentic\n\nMathagentic converts executable arithmetic programs into complete agentic SFT\ntrajectories for HRM-Text. It currently supports:\n\n- `TinyGSM/TinyGSM`: restricted Python programs normalized to `solve()`;\n- `niklasm222/gsm8k-prolog-prover`: SWI-Prolog programs defining `solve/1`,\n  checked against `openai/gsm8k` train answers.\n\nEach output row contains one native tool definition, a user problem, an\nassistant tool call, a precomputed tool result, and a terminal assistant target\ncontaining only `\\boxed{...}`. The bundled template renders this OpenAI-shaped\nstructure into Mimir's Gemma 4 native tool syntax. No executor is needed during\ntraining, although real inference still needs an orchestrator that executes\nmodel-requested tools.\n\n## Install\n\n```bash\nconda env create -f environment.yml\nconda activate mathagentic\nuv pip install -e '.[test]'\n```\n\nThe Conda environment supplies Python 3.12 and SWI-Prolog 10.0. Python source\nis accepted only after strict AST validation and is executed in a\nresource-limited isolated interpreter process.\n\n## Build\n\n```bash\nmathagentic download --output data/raw --workers 64\n\nmathagentic convert-prolog \\\n  --source data/raw/gsm8k-prolog-prover \\\n  --gsm8k data/raw/gsm8k \\\n  --output data/converted/gsm8k-prolog \\\n  --mismatch-verdicts verdicts/gsm8k-prolog-gold-overrides.jsonl \\\n  --program-repairs verdicts/gsm8k-prolog-program-repairs.jsonl \\\n  --workers 64\n\n# Build execution-verified candidates. Production admission should additionally\n# pass --semantic-verdicts and --require-semantic-verdict.\nmathagentic convert-tinygsm \\\n  --source data/raw/tinygsm \\\n  --output data/converted/tinygsm \\\n  --max-rows 500000 \\\n  --sample-modulus 20 \\\n  --workers 64\n\n# Semantically audit candidates using existing OpenAI-compatible servers.\nmathagentic audit-tinygsm \\\n  --source data/converted/tinygsm \\\n  --output data/audits/tinygsm/verdicts.jsonl \\\n  --failures data/audits/tinygsm/failures.jsonl \\\n  --endpoint http://127.0.0.1:8100 \\\n  --endpoint http://127.0.0.1:8101 \\\n  --endpoint http://127.0.0.1:8102 \\\n  --endpoint http://127.0.0.1:8103 \\\n  --concurrency 512 \\\n  --max-output-tokens 64\n\n# Rebuild after auditing, admitting only positive semantic verdicts.\nmathagentic convert-tinygsm \\\n  --source data/raw/tinygsm \\\n  --output data/converted/tinygsm-semantic \\\n  --max-rows 500000 \\\n  --sample-modulus 20 \\\n  --semantic-verdicts data/audits/tinygsm/verdicts.jsonl \\\n  --require-semantic-verdict \\\n  --workers 64\n\nmathagentic validate --source data/converted\n\nmathagentic tokenize \\\n  --source data/converted \\\n  --output data/tokenized \\\n  --tokenizer /work/mimir/brainsurgery/models/gemma4_31b/tokenizer.json \\\n  --max-seq-len 4096 \\\n  --workers 5\n```\n\n`data/tokenized` uses HRM-Text's task array contract:\n`tokens.npy`, `inst_start.npy`, `inst_len.npy`, `resp_start.npy`, and\n`resp_len.npy`. Tokenization accepts plain or gzip-compressed JSONL shards and\natomically commits one task directory per input shard. Every source trajectory\nyields two supervised examples. Tool definitions and prior messages are prompt\ntokens; only the current assistant call or terminal boxed answer is a response\ntarget. Train this source only with HRM-Text `data.target_only=true`; disabling\ntarget-only masking would also supervise the rendered prompt and tool-result\ntokens.\n\nThe tokenized task tree is intended to be merged into DFM11's tokenized union\nand sampled with `data_io/sample_tokenized.py`. HRM-Text itself reads the\nsampler's aggregate `tokens.npy`, `metadata.json`, and `epoch_N` indices, not a\nraw JSONL or unsampled task tree.\n\n## Quality boundary\n\nProlog rows are retained only when execution exactly matches the corresponding\nGSM8K-train answer. TinyGSM has no authoritative answer field. Its deterministic\nconversion rejects malformed, multi-question, unsafe, non-scalar, and\nnon-executable rows, but execution alone does not establish semantic\ncorrectness. A production DFM11 build must use independent row-level verdicts\nand `--require-semantic-verdict`.\n\nSee the [knowledge bundle](wiki/index.md) for the complete contract and\ndecisions.\n",
  "bytes": 4105,
  "sha": "3bcc6c1bae7383928e7c607411f398e635c719fc6071f7f0c69851039617af6d",
  "repo_slug": "schneiderkamplab/mathagentic",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/okf_schneiderkamplab_mathagentic_wiki_index__d35d1278/readme"
}