Add clean Path A proof of concept

Spoken-English math to Typst with a small from-scratch encoder-decoder
Transformer, following the build guide: compile-checked synthetic data
generator, shared BPE tokenizer, nn.Transformer model, training loop with
an overfit sanity check, greedy decoding CLI, and evaluation on synthetic
and hand-written test sets. ./run.sh runs the whole pipeline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
paultalandClaude Opus 5.5 committed 2026-11-27 00:14:06 +02:00
1 parent 5926731546
commit fa472f8abd
20 files changed
+2398 -1

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import random
from isotope_typst.generate import TreeGen
from isotope_typst.render import to_english, to_typst
from isotope_typst.tokenizer import BOS, EOS, PAD, train
def test_round_trip(tmp_path):
rng = random.Random(0)
gen = TreeGen(rng)
trees = [gen.tree() for _ in range(2000)]
texts = [s for t in trees for s in (to_english(t, rng), to_typst(t))]
tok = train(texts, str(tmp_path / "tok.json"), vocab=1000)
assert (tok.token_to_id("[PAD]"), tok.token_to_id("[BOS]"), tok.token_to_id("[EOS]")) == (PAD, BOS, EOS)
for t in trees[:1000]: # guide §5: decode(encode(s)) == s, or nothing downstream can be right
s = to_typst(t)
assert tok.decode(tok.encode(s).ids) == s