summaryrefslogtreecommitdiff
path: root/README.md
blob: bae6cf7641c0d8c8e63f283f630d66f93bb62011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Prime Grokking

Can minimal architectures learn the next-prime function — or *grok* it rather than memorize it?

Experiment 1 (seed 0): weight-tied 2-layer RNN cell (K=20 tied steps, ACT learned halting)
vs. a fixed-d_model transformer baseline, range n ∈ [2, 100], 30% holdout.

## Layout

```
design/experiment-spec.md    design doc (copied from the research repo, provenance noted)
design/preregistration.md    pre-registered outcome→interpretation matrix (LOCK: commit 00c696d in research repo)
src/                         config, data, model API, models, train, eval
tests/                       pytest suite (data correctness, model shapes, halting)
scripts/                     run_experiment.sh, plot.py
runs/                        metrics CSVs + plots (gitignored)
```

## Quick start

```bash
python3 -m venv .venv
.venv/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu numpy matplotlib pytest
.venv/bin/pytest tests/ -q
scripts/run_experiment.sh rnn 0          # full run, ~35 min on 2 cores
scripts/run_experiment.sh transformer 0
scripts/plot.py
```

## Notes

- Results are interpreted ONLY against `design/preregistration.md` (outcome codes O1–O8, H1–H4, P1–P4).
- Seed-0 runs are anecdotes until seeds {1, 2}; no hyperparameter tuning on the val set.
- Remote: `ssh://meru/~/projects/prime-grokking.git` (private; MIT license included for future publishing).