From 4dae0d7bfaffbb87a02fa8f6f8d7516c025ae5d1 Mon Sep 17 00:00:00 2001 From: Paul Tal <1+paultal@noreply.git.paultal.online> Date: Fri, 27 Nov 2026 00:48:55 +0200 Subject: [PATCH] Simplify README to a description and how to run it Keep README short and tell agents not to use it as documentation. --- AGENTS.md | 5 +++++ README.md | 58 ++++++------------------------------------------------- 2 files changed, 11 insertions(+), 52 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d7bbd5b..49e01e9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,3 +11,8 @@ - `./run.sh` runs the whole pipeline (data → tokenizer → overfit check → train → evaluate); `./run.sh --quick` is a two-minute smoke run. - `uv run pytest` and `uv run ruff check .` must pass before committing. - `data/` and `artifacts/` are generated outputs and are not tracked. + +## README + +- Keep `README.md` to a short description of the project and how to run it. Do not use it as documentation: no module lists, command tables, design conventions or roadmaps. +- Document code in docstrings and comments next to the code, and track planned work in Gitea issues. diff --git a/README.md b/README.md index 236392e..80f022c 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,13 @@ # isotope-typst -**isotope-typst** is a Transformer model that translates math written in plain English into [Typst](https://typst.app) markup. +isotope-typst turns math written in plain English into [Typst](https://typst.app) markup. For example, `the integral from 0 to infinity of e to the minus x squared dx` becomes `$integral_0^infinity e^(-x^2) dif x$`. It is a small encoder–decoder Transformer, built and trained from scratch in PyTorch on synthetic data. -For example, `the integral from 0 to infinity of e to the minus x squared dx` becomes `$integral_0^infinity e^(-x^2) dif x$`. +## Running it -The current code is the **Path A proof of concept**: a small (~8M parameter) encoder–decoder Transformer trained from scratch on synthetic data, following the [build guide](https://git.paultal.online/paultal/generated-books/src/branch/main/isotope-typst-guide.pdf). - -## Run it - -Needs [uv](https://docs.astral.sh/uv/) and the Typst CLI (`brew install typst`). +You need [uv](https://docs.astral.sh/uv/) and the Typst CLI (`brew install typst`). ```bash -./run.sh # everything, ~20 min on an M-series Mac -./run.sh --quick # smoke run, ~2 min, tiny model -uv run isotope "x squared plus y squared equals r squared" -uv run isotope # interactive prompt +./run.sh # generate data, train, and evaluate (~20 min on an M-series Mac) +uv run isotope "x squared plus 1" # translate a sentence +uv run isotope # interactive prompt ``` - -Or one stage at a time: - -| guide | command | what it does | -|---|---|---| -| §4 data | `uv run isotope-gen -n 200000` | random trees → English + Typst pairs, compile-checked, into `data/` | -| §5 tokens | `uv run isotope-tokenizer` | byte-level BPE shared by both sides → `artifacts/tokenizer.json` | -| §7 sanity | `uv run isotope-train --overfit 100` | a tiny model must memorise 100 pairs, or the pipeline has a bug | -| §7 training | `uv run isotope-train` | `--config tiny/small/medium`, `--steps`, Ctrl-C saves a checkpoint | -| §8 inference | `uv run isotope "..."` | greedy decoding; `--check` compiles the output | -| §9 evaluation | `uv run isotope-eval` | exact match and compile rate on synthetic test + `eval/hand_test.jsonl` | -| tests | `uv run pytest` | renderer compiles, English is unambiguous, tokenizer round-trips, causal mask works | - -`data/` and `artifacts/` are generated and not tracked in git. - -## Code - -``` -src/isotope_typst/ - ast.py expression nodes: Var Num Neg Add Sub Mul Pow Frac Sqrt Func Integral Sum Lim Eq - render.py to_typst() (deterministic) and to_english() (random phrasings) - generate.py random trees -> data/{train,valid,test}.jsonl, split by a hash of the Typst string - validate.py `typst compile` checks - tokenizer.py BPE tokenizer - model.py Seq2Seq on nn.Transformer, with encode()/decode() for inference - train.py teacher forcing, AdamW, warmup + cosine, checkpoints, train_log.csv - translate.py greedy decoding + CLI - evaluate.py metrics + failure dumps in artifacts/errors_*.txt -eval/hand_test.jsonl hand-written test sentences: never generated, never trained on -``` - -## Conventions the English follows - -* "e to the minus x squared" means `e^(-x^2)`: a bare exponent takes everything after it (guide Appendix A, Q1). -* Grouping is said with "( … )", "open paren … close paren", or, at the end of a phrase, "the quantity …". -* "sine of x squared" means `sin(x^2)`; `sin(x)^2` is "sine squared of x". -* Integrals, sums and limits appear only at the top level of an expression. - -## Not in this PoC (yet) - -Beam search, constrained decoding, render-match evaluation, a hand-written attention module, paraphrase augmentation, and Path B fine-tuning.