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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The Verifier Loop: executable grammar rules as the RL environment
|
| 2 |
+
|
| 3 |
+
**Spec for the next Dakota1890 experiment.** Version 1.0, 2026-11-12.
|
| 4 |
+
Codebase it extends: [`HarleyCoops/Dakota1890`](https://github.com/HarleyCoops/Dakota1890) (`lexgym/`).
|
| 5 |
+
Data it reads: [`HarleyCooper/riggs1890-lexicon-graph`](https://huggingface.co/datasets/HarleyCooper/riggs1890-lexicon-graph).
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## 0. What changed since the first framing
|
| 10 |
+
|
| 11 |
+
The first framing of this experiment assumed most of the pipeline had to be
|
| 12 |
+
built. Reading the repos shows otherwise. Three parts of the design **already
|
| 13 |
+
exist** and should not be rebuilt:
|
| 14 |
+
|
| 15 |
+
| Design element | Already implemented as | Where |
|
| 16 |
+
|---|---|---|
|
| 17 |
+
| Reverse clues, answers anchored | `en_to_dak` task: English word → Dakota form, scored against the accepted set | `lexgym/tasks.py`, reward in `lexgym/scoring.py` |
|
| 18 |
+
| Accepted set = every headword sharing the gloss | **Two-witness gold**: only forms attested in both halves of the book are accepted answers | graph builder rule 3 |
|
| 19 |
+
| "May vary the question surface, must not synthesize a new answer" (the Cree contract) | The Cree anchored-expansion run: 490,280 balanced rows, answers dictionary-bound | Cree1865, run `cree1865-synthetic-expansion-v1` |
|
| 20 |
+
| Frozen measures by split | `heldout_rule` (5,284 tasks, unseen families) and `recall` (600 tasks, training vocabulary) | `rl_tasks` config |
|
| 21 |
+
| Lookup / abstain behavior | `LOOKUP: <word>` tool, reward only on final `ANSWER:` | `lexgym/tinker_env.py` |
|
| 22 |
+
|
| 23 |
+
What does **not** exist yet, and is the whole delta of this experiment:
|
| 24 |
+
|
| 25 |
+
1. An **executable morphology checker** — code that can say *"this form is
|
| 26 |
+
well-built by rule X"* and *"this form breaks rule Y"*. The current Dakota
|
| 27 |
+
grammar scoring is soft overlap (character F1, affix presence); it cannot
|
| 28 |
+
reject a form.
|
| 29 |
+
2. **Three-label triage** of every synthetic row: attested / rule-licensed /
|
| 30 |
+
rejected, with a promotion rule that keeps rule-licensed rows out of gold.
|
| 31 |
+
3. The **generate → verify → retrain loop** that grows the dataset to the
|
| 32 |
+
ceiling of the book, with policy-gradient RL reserved for behavior
|
| 33 |
+
(lookup/abstain) only — the 2026-11-10 runs showed RL adds no facts
|
| 34 |
+
(English→Dakota exact match 0.00→0.03 after ~200 GRPO steps).
|
| 35 |
+
4. The **unverified control** that prices the verifier: the Stoney-RL setup
|
| 36 |
+
(model writes the answers, reward placeholder returns 0.0) run as an arm,
|
| 37 |
+
not as an accident.
|
| 38 |
+
|
| 39 |
+
Also new since the first framing: the Inkling-2-Small SFT run lifted
|
| 40 |
+
memory recall from 3% → 83.5% in three passes. The binding constraint on
|
| 41 |
+
"the maximum of what is in the book" is now (a) the quality of the extracted
|
| 42 |
+
gold and (b) how much surface area the training rows cover — exactly the two
|
| 43 |
+
things this loop works on.
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
## 1. The claim under test
|
| 48 |
+
|
| 49 |
+
> Grammar rules compiled into executable checks can (a) clean the extracted
|
| 50 |
+
> gold, (b) label synthetic rows as licensed or rejected, and (c) raise
|
| 51 |
+
> held-out recall when rule-licensed rows are added to supervised training —
|
| 52 |
+
> without ever promoting an unattested form to gold.
|
| 53 |
+
|
| 54 |
+
Falsified if: checker-approved rows do not change held-out recall, or if the
|
| 55 |
+
rule-violation rate in free output does not fall relative to the baseline arm.
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## 2. The checker
|
| 60 |
+
|
| 61 |
+
### 2.1 Rule schema
|
| 62 |
+
|
| 63 |
+
Every compiled rule is a pure function over a canonical form plus a rule file
|
| 64 |
+
that admits it:
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
@dataclass
|
| 68 |
+
class MorphRule:
|
| 69 |
+
name: str # "pronoun-affix-insertion"
|
| 70 |
+
scope: str # "v." | "n." | "adj." | ... (Riggs POS abbreviations)
|
| 71 |
+
inventory: list[str] # surface strings, e.g. ["wa", "mda", "ya", ...]
|
| 72 |
+
apply: Callable[[str, str], list[str]] # (stem, affix) -> candidate surface forms
|
| 73 |
+
notes: str # citation: Riggs page / grammar section
|
| 74 |
+
|
| 75 |
+
@dataclass
|
| 76 |
+
class Admission:
|
| 77 |
+
rule: str
|
| 78 |
+
n_attested: int # attested forms the rule explains
|
| 79 |
+
n_explained_total: int
|
| 80 |
+
coverage: float # n_explained_total / n_attested_in_scope
|
| 81 |
+
false_positives: int # rule-accepted forms NOT attested, sampled and read by hand
|
| 82 |
+
admitted: bool # coverage >= threshold AND FP rate <= threshold
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### 2.2 The admission test
|
| 86 |
+
|
| 87 |
+
A rule is **admitted** only after it passes the book's own attested forms:
|
| 88 |
+
|
| 89 |
+
- **Coverage gate.** On the attested inflected forms of in-scope entries,
|
| 90 |
+
the rule must explain ≥ 60% (the feasibility probe's simplest rule already
|
| 91 |
+
explains 63% of 6,989 forms; stricter per-rule thresholds are set at
|
| 92 |
+
admission time).
|
| 93 |
+
- **Precision gate.** Every form the rule *accepts* that is *not* attested is
|
| 94 |
+
a candidate false positive. A sample is read against the page images; a rule
|
| 95 |
+
whose accepted-but-unattested sample is > 10% wrong builds is not admitted.
|
| 96 |
+
- **Family holdout.** Coverage and precision are computed on train families
|
| 97 |
+
first; the rule is then frozen and re-scored on held-out families. A rule
|
| 98 |
+
that only works on families it was tuned on is not admitted.
|
| 99 |
+
|
| 100 |
+
### 2.3 What v0 checks without any compiled morphology (already shippable)
|
| 101 |
+
|
| 102 |
+
From `lexgym/orthography.py`, which is grounded and tested:
|
| 103 |
+
|
| 104 |
+
1. **Alphabet check** — every character in the Riggs alphabet
|
| 105 |
+
(`ALPHABET` set); anything else is `is_suspect` and is never gold.
|
| 106 |
+
2. **Shape check** — the form parses as headword syllables + one accent mark
|
| 107 |
+
(`parse_headword`); accent mark terminates its syllable; at most one accent.
|
| 108 |
+
3. **Attested check** — the form is in the entry's `inflected_forms`, or is a
|
| 109 |
+
headword, or is in the family's attested set. This is the gold criterion.
|
| 110 |
+
4. **Near-match report** — the form differs from an attested form only by
|
| 111 |
+
n/ŋ (1,494 known extraction suspects). Reported, never scored correct.
|
| 112 |
+
|
| 113 |
+
### 2.4 Milestone 1: run the checker against the gold (first build, no GPU)
|
| 114 |
+
|
| 115 |
+
The checker's first job is cleaning the gold. The feasibility probe's rule
|
| 116 |
+
("inflected form = headword with a pronoun affix inserted, optionally ± `-pi`")
|
| 117 |
+
explains 63% of the 6,989 inflected forms; the ~2,576 unexplained forms are a
|
| 118 |
+
**triage list**, and the sampled misses are mostly extraction errors (e.g.
|
| 119 |
+
`abawamdeca` for a headword printed with ć) or forms attached to the wrong
|
| 120 |
+
entry. Output of M1:
|
| 121 |
+
|
| 122 |
+
- `triage_unexplained.parquet` — one row per unexplained form: entry_id, page,
|
| 123 |
+
source_image, candidate correction, suspected error class.
|
| 124 |
+
- `rule_admission.json` — per-rule coverage and precision on train and
|
| 125 |
+
held-out families.
|
| 126 |
+
- Every fix flows back into `lexgym/build_graph.py` inputs, which raises the
|
| 127 |
+
ceiling the last SFT run hit.
|
| 128 |
+
|
| 129 |
+
**Affix inventory is M2, not M1.** The 1,497 extracted grammar rules live in
|
| 130 |
+
LFS and the pronoun/paradigm tables are Riggs grammar pp. 40–57 (scan pages,
|
| 131 |
+
already imaged in `docs/collages/tinker_grammar_tables.jpg`). The inventory
|
| 132 |
+
must be read from those sources, not invented. A rule can license a form but
|
| 133 |
+
not choose it: the affix is inserted word-internally ~60% of the time and
|
| 134 |
+
prefixed ~40%, and which one is a fact about each verb — so licensed forms are
|
| 135 |
+
a superset, and only attestation picks the winner.
|
| 136 |
+
|
| 137 |
+
### 2.5 Labels
|
| 138 |
+
|
| 139 |
+
| Label | Meaning | Use |
|
| 140 |
+
|---|---|---|
|
| 141 |
+
| `attested` | in the book, passes alphabet+shape | gold, always |
|
| 142 |
+
| `licensed` | rejected by no admitted rule, not attested | training only in the licensed arm; never gold |
|
| 143 |
+
| `rejected` | breaks an admitted rule or the alphabet | excluded; logged as the model's error signal |
|
| 144 |
+
|
| 145 |
+
**Promotion rule:** a `licensed` row becomes `attested` only with a speaker
|
| 146 |
+
confirmation or a second source. The loop amplifies its own errors the moment
|
| 147 |
+
this is skipped — this is the failure mode the Stoney arm is designed to
|
| 148 |
+
measure.
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
## 3. The loop
|
| 153 |
+
|
| 154 |
+
```
|
| 155 |
+
lexicon graph (dakota_entries)
|
| 156 |
+
│
|
| 157 |
+
┌──────────▼──────────┐ ┌─────────────────────┐
|
| 158 |
+
│ generator │ │ executable checker │
|
| 159 |
+
│ (clue templates + │───────▶│ alphabet, shape, │
|
| 160 |
+
│ model rephrasings, │ │ attested, rules │
|
| 161 |
+
│ form proposals) │ └─────────┬───────────┘
|
| 162 |
+
└─────────────────────┘ │ 3-label triage
|
| 163 |
+
▼
|
| 164 |
+
attested → SFT gold (pass 2)
|
| 165 |
+
licensed → licensed arm only
|
| 166 |
+
rejected → generator feedback
|
| 167 |
+
│
|
| 168 |
+
┌───────────▼───────────┐
|
| 169 |
+
│ SFT pass 2 (Tinker) │
|
| 170 |
+
│ + RL for lookup/abstain│
|
| 171 |
+
└───────────┬───────────┘
|
| 172 |
+
▼
|
| 173 |
+
frozen eval: rephrased-clue recall,
|
| 174 |
+
held-out families, violation rate
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
Rejected rows go back to the generator as *negative* signal (the proposal that
|
| 178 |
+
broke rule X is not retried verbatim), which is what makes this a loop and not
|
| 179 |
+
a filter.
|
| 180 |
+
|
| 181 |
+
---
|
| 182 |
+
|
| 183 |
+
## 4. Arms
|
| 184 |
+
|
| 185 |
+
| Arm | Adds to pass-2 SFT | Tests |
|
| 186 |
+
|---|---|---|
|
| 187 |
+
| A. Baseline | current mixed file, no new rows | reference |
|
| 188 |
+
| B. Rephrased clues | model-varied clue wording, answers anchored (Cree contract) | is knowledge tied to prompt wording? |
|
| 189 |
+
| C. Rule-licensed forms | checker-approved unattested forms, labeled as such | does licensed surface area help or pollute? |
|
| 190 |
+
| D. Unverified (Stoney-style) | model-written answers, no checker | what is the verifier worth? |
|
| 191 |
+
|
| 192 |
+
C vs A is the main read; D vs C prices the checker. All arms share the same
|
| 193 |
+
base model, base SFT recipe (LoRA rank 32 on Tinker), and frozen eval.
|
| 194 |
+
|
| 195 |
+
## 5. Measures (frozen before any arm runs)
|
| 196 |
+
|
| 197 |
+
1. **Recall under unseen phrasings** — held-out clue templates written after
|
| 198 |
+
training data is fixed; answers scored against the two-witness accepted set.
|
| 199 |
+
2. **Held-out families** — the existing `heldout_rule` split, unchanged.
|
| 200 |
+
3. **Rule-violation rate in free output** — sample free generation, run the
|
| 201 |
+
checker, report % rejected. Arm D is predicted to be highest.
|
| 202 |
+
4. **Neither-attested-nor-licensed rate** — forms the checker can't place.
|
| 203 |
+
This is the error-amplification detector.
|
| 204 |
+
|
| 205 |
+
## 6. Compute shape
|
| 206 |
+
|
| 207 |
+
- M1 (checker + triage): CPU only. No training.
|
| 208 |
+
- M2 (inventory compile): CPU + page-image reading.
|
| 209 |
+
- M3–M4 (generation + arms B/C/D + baseline): Tinker LoRA, ~4 passes
|
| 210 |
+
comparable to the $11.23/pass Inkling run; generation rollouts via the
|
| 211 |
+
existing Tinker sampling path.
|
| 212 |
+
- Eval: the frozen sets, temperature 0, 1,500 tasks — same harness as the
|
| 213 |
+
2026-11-12 run.
|
| 214 |
+
|
| 215 |
+
## 7. Limits
|
| 216 |
+
|
| 217 |
+
- A licensed form is a hypothesis about 1890 orthography rules, not about
|
| 218 |
+
Dakota as spoken. It never enters gold without a speaker or a second source.
|
| 219 |
+
- The book is one witness with missionary bias; the checker verifies
|
| 220 |
+
well-formedness *per Riggs*, nothing more.
|
| 221 |
+
- One seed per arm to start; the D arm exists partly because a single noisy
|
| 222 |
+
run of the Stoney pipeline already misled once.
|