Repository navigation
feat(ml): encode native review round 3 — style examples in the glossary, rules 23 → 27, glossary v0.6.0 - #311
Conversation
…ry, rules 23 → 27, glossary v0.6.0 The third inline review (44 suggestion blocks on QuantEcon/lecture-python-programming.ml#13, matplotlib) found every round-2 class clean and a residue of style: clause-boundary commas, verb aspect and mood, clause order. Style resists rule statement, so this round adds a mechanism as well as rules. - Glossary.style_examples + formatStyleExamples: editor-approved sentence pairs rendered after the glossary terms as STYLE EXAMPLES. They ride the glossary object, so they reach every write path with no new input, and sit in the prompt-cached stable block (fixed set, no per-call retrieval). - ml rules 23 → 27: clause-boundary commas, verb form by meaning, idiom by plain meaning, Further Reading lists stay English (decision record D-2026-09-18-ml-further-reading-lists-stay-english). Four rules extended (hortative, teacher's register, fixed renderings, light verbs). The hortative rule no longer ends on a dangling colon (see #301). - glossary/ml.json v0.6.0: multiple, explicit (Malayalam); remove, label (kept English); 32 style examples from the three reviewed lectures. - Admission test from this round on: a pattern becomes a rule only if it recurs. Held for the editor's answers on QuantEcon/lecture-python-programming.ml#22: the rule-2 boundary, provide, prefer, draw, the plural of retained nouns. - Regeneration test archived under experiments/ml-benchmark/arms/: 2 × 2 of rules × held-out exemplars, three draws per cell, on matplotlib (in-sample) and on functions (held out). In-sample similarity to the editor's text 0.845 → 0.93; held-out unchanged (0.814 → 0.809) apart from comma density (0.56 → 0.72 against his 0.82). Exemplars: no measurable closeness effect. - ml_metrics.py: five round-3 banned renderings. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The new prompt-rendering code in formatGlossary / formatStyleExamples introduces unintended leading/trailing whitespace, undermining prompt stability and the “byte-identical” omission claim.
Pull request overview
Introduces “style examples” as a new glossary capability to better teach translation style (especially Malayalam), and encodes the third Malayalam native review round by expanding ml prompt rules, updating the ml glossary, and archiving supporting benchmark artifacts.
Changes:
- Add
Glossary.style_examples/StyleExampleand render editor-approved EN→target sentence pairs in prompts underSTYLE EXAMPLES:. - Update Malayalam rules (23→27) and glossary
ml.jsonto v0.6.0 (new terms + style examples) based on round-3 review outcomes. - Add/extend tests and archive a regeneration/benchmark arm (scripts + draw outputs + scores) documenting the evaluation.
File summaries
| File | Description |
|---|---|
| src/types.ts | Adds StyleExample type and optional Glossary.style_examples. |
| src/translator.ts | Renders glossary style examples in the prompt stable block via formatStyleExamples. |
| src/language-config.ts | Expands Malayalam additional rules (round-3: commas/aspect/idiom/further-reading scope + rule extensions). |
| src/tests/translator-prompts.test.ts | Tests style-examples rendering/omission across prompt builders and preserves rule ordinal contiguity. |
| src/tests/language-config.test.ts | Validates ml glossary v0.6.0 contents and ml rule count/constraints. |
| glossary/README.md | Documents optional style_examples in glossary schema. |
| glossary/ml.json | Bumps to v0.6.0 with new terms and style_examples set. |
| experiments/ml-benchmark/scripts/ml_metrics.py | Adds round-3 banned renderings to metrics tokens list. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/select_exemplars.py | New script to select eligible style exemplars from reviewed lecture pairs. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/scores-matplotlib.json | Archived in-sample scoring output for the benchmark arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/scores-functions.json | Archived held-out lecture scoring output for the benchmark arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/score.py | New paragraph-alignment scoring driver to produce the score JSON. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/README.md | Documents the benchmark design, results, and incidents. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/glossaries/glossary-v0.6.0-terms.json | Archived glossary snapshot used by benchmark runs (terms-only variant). |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/draws/matplotlib-Aex-draw3.md | Archived generated output for baseline+exemplars arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/draws/matplotlib-Aex-draw2.md | Archived generated output for baseline+exemplars arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/draws/matplotlib-Aex-draw1.md | Archived generated output for baseline+exemplars arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/draws/matplotlib-A-draw3.md | Archived generated output for baseline arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/draws/matplotlib-A-draw2.md | Archived generated output for baseline arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/draws/matplotlib-A-draw1.md | Archived generated output for baseline arm. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/corpus/matplotlib.en.md | Archived English source corpus used for benchmark alignment/scoring. |
| experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/align.py | New alignment utility pairing EN↔ML prose paragraphs by structural anchors. |
| docs/user/glossary.md | Adds user-facing documentation for style_examples behavior and constraints. |
| CHANGELOG.md | Records the new glossary style examples feature and Malayalam round-3 updates under Unreleased. |
| .dev/STATE.md | Updates dev state to include ml round-3 in-flight summary. |
| .dev/log/2026-09-18-ml-round3.md | Adds a dev log entry for ml round-3 encoding and benchmark findings. |
| .dev/decisions/D-2026-09-18-ml-further-reading-lists-stay-english.md | New decision record capturing Further Reading “stay English” rule for ml. |
Review details
- Files reviewed: 46/52 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…he pre-feature template Pins the claim Copilot's overview on #311 questioned: with the key absent, an empty array, or pairs for another language only, the cached stable block is unchanged to the byte — no separator line, no trailing space. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ut verdict Adds the second instrument (judge.mjs: Opus 5, randomised order, style only, 2,570 judgements, no position bias) and nine more held-out draws — contrastive triples, a 56-pair set, and the 56-pair set without the new rules. Held out, the rules are preferred 55 : 45 over baseline and rules + the shipped pairs 57 : 43 (p = 0.054); every example variant judges dead even. The exemplar line is closed pending round-4 editor data; the contrastive rendering used by one arm was a local build and is not shipped. README, CHANGELOG, dev log and STATE updated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Held for the full test programme, now complete — ready for review. Since the PR opened, the arm gained a second instrument and three exemplar variants ( Instrument. Paragraph similarity was flat on the held-out lecture for every arm (0.80–0.81), so Held-out verdict ( What this PR ships, accordingly: the four rules and the rule extensions (a real, small, consistent edge on unseen text — a preference in roughly 5–7 of every 100 paragraphs); the Copilot's overview claim about whitespace / byte-identity was checked and is wrong; |
…t set aside The held-out judge found every example form indistinguishable from the rules alone, and a prompt element with no measured return is not carried. glossary/ml.json keeps the four round-3 terms; the style_examples mechanism, its tests and docs stay for a measured case later. Tests, docs, CHANGELOG, language-config comment and STATE updated to match; the evaluated sets remain in the arm archive. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Applied the finding to the PR ( What the PR now ships: the 27 |
There was a problem hiding this comment.
🔵 Needs a closer look
It modifies shared prompt-building and prompt-cache behavior affecting every language and write path, states a byte-identity invariant the code does not fully uphold, and the author notes harness verification on the .ml lane is still pending.
Review details
- Files reviewed: 36/74 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* chore: release v0.29.0 CHANGELOG [Unreleased] promoted to [0.29.0] - 2026-09-18 with a fresh empty header above it; version 0.29.0 in package.json / package-lock.json; STATE.md in-flight entry (W1 #259 retargets to v0.30.0). dist-action/ is byte-identical — the bundle reads the version at runtime. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * dev: STATE.md — #311 is merged (847ca9f), released by v0.29.0 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…he second editor round (#328) * glossary(fr): v1.2 — Namespace, Heads, standard-normal context from the second editor round Encodes the terminology rulings from the French editor's second review round (QuantEcon/lecture-python-programming.fr#77 and #80, merged 2026-09-23) that meet the glossary bar — an explicit native ruling plus measured variation: - Namespace → Espace de nommage. The official French Python docs use « espace de nommage »; fresh init draws at v0.29.2 wrote « espace de noms » 206/206. A NEW section brought « noms » back 3/3 without the pin, 0/3 with it. - Heads (coin toss) → Face. The coin side was wrong in 6/12 fresh draws of the exercise without the pin, 0/12 with it. Tails → Pile is not pinned: no source occurrence, and it would sit beside four « queue » entries. - Standard normal keeps « Loi normale centrée réduite »; its context now steers draws and random variables to « variable normale centrée réduite » (« lois » for draws 8/32 → 0/28; distribution sense 16/16). Held for measurement: Garbage collection, Return (a value). Held for an editor ruling: Built-in function. 367 → 369 terms; docs counts updated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs: ml glossary count 61/77 -> 87 (v0.7.0) The ml glossary reached v0.7.0 / 87 terms across #303, #311 and #315, which updated glossary/ml.json but not the docs. Raised by Copilot review on #328. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Encodes the third inline native review of the Malayalam edition — 44 suggestion blocks from @adisankarmt on QuantEcon/lecture-python-programming.ml#13 (
matplotlib) — and adds the mechanism that round pointed at: editor-approved sentence pairs shown to the translator as style examples. Analysis and per-flag dispositions are in QuantEcon/project-translationreports/2026-09-18-ml-matplotlib-review-disposition.md; the editor's open questions are QuantEcon/lecture-python-programming.ml#22.What the review showed
Every class encoded from round 2 came through clean (terminal punctuation 26 → 0 flags, capitalisation 14 → 0, fixed pairs 10 → 0, connectives 7 → 0; the ml#12 pins held), and he left 22 of 66 Malayalam lines untouched against 5 of 123 in round 2, in the same reply channel. What remains is style: clause-boundary commas (16 flags, six of them nothing but a comma), verb aspect and mood (10), clause order (10). Rules state those badly; his own sentences show them well.
What changes
src/types.ts,src/translator.tsGlossary.style_examplesandformatStyleExamples: pairs render after the glossary terms underSTYLE EXAMPLES:, with an instruction to match register, rhythm, punctuation and clause order — never content — and to follow a numbered rule where the two differ. They ride the glossary object, so they reach sync,init,forwardand resync with no new input or loader, and they sit in the prompt-cached stable block (a fixed set per glossary version; no per-call retrieval, which would break the cache). A glossary without the key renders byte-identically to before. The reviewer is untouched.src/language-config.tsmlrules 23 → 27: clause-boundary commas; verb form by meaning (-തിരിക്കുന്ന,-ഇട്ടുണ്ട്, conditional-ആൽ,-ഏക്കാം); idiom and coined jargon by plain meaning; Further Reading lists stay English. Four rules extended (hortativeകരുതാം; fragment bullets, instrument-first,മറ്റൊരു; fixed renderings multiple, explicit, X-like, simple; light verbs remove, label). The hortative rule no longer ends on a dangling colon (the second residual on #301; the lint-regex residual there is untouched).glossary/ml.jsonstyle_examplesdrawn only from the three lectures he has reviewed. No example contains a banned rendering or touches a question still open with him (a test enforces both)..dev/decisions/D-2026-09-18-ml-further-reading-lists-stay-english— accepted by @mmcky; prompt rule for now, to move into code once he tells us where the boundary is.experiments/ml-benchmark/ml_metrics.py.New admission test for rules, agreed this round: a pattern is encoded only if it recurs (twice in a round, or across rounds). Two draws of this lecture at near-identical engines shared 9 of 66 lines, and at least six of his 44 edits simply restored the other draw's wording — a singleton flag is as likely sampling noise as engine habit. Held for his answers: the rule-2 boundary (which ordinary words stay English — the round-2 pendulum reversed this round), provide, prefer, draw, the plural of retained nouns, the comma between single-word
-ഉംpairs. None blocks a release; they ride the next one, as the ml#12 answers did.Regeneration test — and what it does not show
experiments/ml-benchmark/arms/2026-09-18-round3-rules-exemplars-sonnet5/: a 2 × 2 of rules × exemplars, three draws per cell, onmatplotliband — new this round — on a held-out lecture (functions, scored against his round-2 text, with nofunctionspairs among the exemplars). Score is paragraph-level character similarity to his reviewed text; means of three draws.matplotlibmedianmatplotlibcommas / parafunctionsmedianfunctionscommas / paraRead plainly: the in-sample jump is mostly the rules quoting his sentences — on the held-out lecture overall closeness does not move. What transfers is what the rules state generically (comma density 0.56 → 0.72 against his 0.82; every round-3 signature lands in the six in-sample draws, bar one
ലളിതമായslip; Further Reading verbatim 6/6). The exemplars show no measurable closeness effect in any pairing; without the rules they pull the style signatures part-way, with the rules they add nothing this metric can see. They are cheap (cached) and did no measurable harm, so they ship — but as unproven, and dropping thestyle_exampleskey fromml.jsonreverts them without touching code. Two method findings are recorded in the arm README: the seed an editor edited is anchored to his text (0.951 against 0.845 for fresh draws) and is not a baseline, and character similarity is near its ceiling as an instrument — the editor-side series (touch rate, accepted lines, edit magnitude) is the better round-over-round measure.One of 22 runs was rejected by the structural-parity guard (a dropped
{raw}directive) and re-run; it was an exemplar arm, n = 1, recorded in the README so a pattern would be visible.Verification
Full suite green (1,584), lint and
format:checkclean,check-dev-refsclean,dist-action/rebuilt. New tests cover example rendering on every prompt builder, the omission cases, glossary shape, and the rule set. Not yet done: a harness run on the.mllane with the local bundle — planned before release, per the harness-first policy. Targets v0.29.0; round 4 (numpy) is generated at@v0after it ships.🤖 Generated with Claude Code