Files
isotope-typst/eval/hand_test.jsonl
T
paultal 98e88cac04 Add clean Path A proof of concept (#1)
Spoken-English math to Typst with a small (~8M parameter) encoder-decoder Transformer trained from scratch, following the build guide (Path A only).

## What's in it
- `generate.py` / `render.py` / `ast.py`: random expression trees rendered to Typst (deterministic) and English (random phrasings); every Typst string is compile-checked, split by a hash of the Typst string
- `tokenizer.py`: byte-level BPE shared by both sides
- `model.py`: `nn.Transformer` seq2seq with `encode()` / `decode()` for inference
- `train.py`: teacher forcing, AdamW, warmup + cosine, overfit-100 sanity check, checkpoints
- `translate.py`: greedy decoding CLI (`uv run isotope "..."`)
- `evaluate.py`: exact match + compile rate on the synthetic test split and `eval/hand_test.jsonl`
- `run.sh`: whole pipeline; `./run.sh --quick` is a 2-minute smoke run
- `AGENTS.md`: commit and workflow rules for agents

## Checked
- `uv run pytest` (8 tests: Typst compiles, English is unambiguous, tokenizer round-trips, causal mask) and `ruff check` pass
- `./run.sh --quick` and the full `./run.sh` run end to end on an M-series Mac

Reviewed-on: #1
Co-authored-by: Paul Tal <[email protected]>
2026-11-27 00:24:05 +02:00

33 lines
1.9 KiB
JSON

{"en": "the integral from 0 to infinity of e to the minus x squared dx", "typ": "integral_0^infinity e^(-x^2) dif x"}
{"en": "x squared plus y squared equals r squared", "typ": "x^2 + y^2 = r^2"}
{"en": "a squared plus b squared equals c squared", "typ": "a^2 + b^2 = c^2"}
{"en": "e to the x", "typ": "e^x"}
{"en": "e to the minus x", "typ": "e^(-x)"}
{"en": "one over x", "typ": "frac(1, x)"}
{"en": "x over 2", "typ": "frac(x, 2)"}
{"en": "the square root of 2", "typ": "sqrt(2)"}
{"en": "square root of x plus one", "typ": "sqrt(x) + 1"}
{"en": "the square root of the quantity x plus 1", "typ": "sqrt(x + 1)"}
{"en": "sine of x", "typ": "sin(x)"}
{"en": "sin x squared", "typ": "sin(x^2)"}
{"en": "sine squared of x plus cosine squared of x equals 1", "typ": "sin(x)^2 + cos(x)^2 = 1"}
{"en": "ln of x", "typ": "ln(x)"}
{"en": "2 x plus 3", "typ": "2 x + 3"}
{"en": "3x squared minus 2x plus 1", "typ": "3 x^2 - 2 x + 1"}
{"en": "y equals m x plus b", "typ": "y = m x + b"}
{"en": "the integral of x squared dx", "typ": "integral x^2 dif x"}
{"en": "the integral from 0 to 1 of x squared dx", "typ": "integral_0^1 x^2 dif x"}
{"en": "integral from 0 to pi of sine of x dx", "typ": "integral_0^pi sin(x) dif x"}
{"en": "the sum from i equals 1 to n of i", "typ": "sum_(i = 1)^n i"}
{"en": "the sum from k equals 0 to infinity of x to the k", "typ": "sum_(k = 0)^infinity x^k"}
{"en": "the limit as x approaches 0 of sine of x over x", "typ": "lim_(x -> 0) frac(sin(x), x)"}
{"en": "the limit as n goes to infinity of 1 over n", "typ": "lim_(n -> infinity) frac(1, n)"}
{"en": "minus b over 2 a", "typ": "frac(-b, 2 a)"}
{"en": "x to the n", "typ": "x^n"}
{"en": "x cubed minus 1", "typ": "x^3 - 1"}
{"en": "alpha plus beta", "typ": "alpha + beta"}
{"en": "2 pi r", "typ": "2 pi r"}
{"en": "e to the i pi plus 1 equals 0", "typ": "e^(i pi) + 1 = 0"}
{"en": "one half", "typ": "frac(1, 2)"}
{"en": "f equals m a", "typ": "f = m a"}