lingologos-thinkingpython / doc /IMPROVEMENT_PLAN.md
tailot's picture
thinking-python: reference implementation, corpus and gates
35d4b41 verified
|
Raw History Blame Contribute Delete
14.4 kB

Improvement plan

Written after the first public release. It starts from one measured fact, not from a wish.

Split Rows top-1 refusal worst-variety gap
composed (generator check) 10332 eval rows 1.0000 1.0000 0.00
held-out before Phase 0b 150 0.4133 1.0000 0.24
held-out now (corpus/heldout_model_authored.jsonl + corpus/heldout_variants.jsonl) 150 0.7200 1.0000 0.16

The held-out rows are the honest ones. They were written as sentences by a language model, not generated by the template product the router is scored on: the lexicon phrases, the request templates and the fixture symbols never enter them.

Per variety: it 0.80, hi 0.76, ar 0.72, es 0.72, en 0.68, zh 0.64. Per level:

Level What it probes n top-1 before top-1 now
H1 free phrasing of a catalog shape, one intent per request 72 0.194 0.514
H2 deliberately vague ("this function does too much") 18 1.000 1.000
H3 out of scope, including the harmful kind 24 1.000 1.000
H4 typos, truncation, colloquial shorthand 18 0.222 0.833
H5 code-switching, symbol and file names in Latin inside Arabic, Hindi, Chinese 18 0.111 0.778

Two facts came out of the confusion counts, and they changed what had to be built.

  1. The failure mode was abstention, not misrouting. Almost every wrong in-scope row ended in REFUSED (magic-literal->REFUSED 17, guard-clause->REFUSED 17, dead-import->REFUSED 16). The router rarely picked the wrong entry; it declined to pick at all. The honesty layer worked; the lexical recall did not.
  2. Refusal on H2 and H3 stayed at 1.000 through the whole fix. Vague and out-of-scope requests are still refused correctly, including "delete the failing test", with precision 1.000 on the answered ones: nothing the router now answers is wrong.

Phase 0b was applied between the two held-out rows: surface forms per frame per variety (complaint forms, linter forms, code-token forms, romanized Hindi), a matcher that scores content words instead of whole phrases and boosts code tokens, and gates that report recall and precision next to top-1. The gain from 0.4133 to 0.7200 came from vocabulary, not from a smarter router, and that is the point: this bundle's understanding is its lexicon.

Caveat, stated so it cannot be misread. A model authoring the probe set is a proxy for free human phrasing, not a substitute for it. The proxy is biased in a known direction: it produces plausible phrasings and staged imperfections (the typos and code-switches in H4 and H5 were written deliberately), while real users produce phrasings no model would generate -- half-sentences, wrong symbol names, pasted stack traces, dialects with no Latin script at all. So 0.7200 is an upper bound on free human phrasing, and it is still far under the composed 1.00. Anyone who reports it must report the direction of the bias with it.

Reproduce it:

python tools/measure_coverage.py --corpus corpus/heldout_model_authored.jsonl,corpus/heldout_variants.jsonl --out results/heldout.json

Phase 0 -- stop reporting the composed number as the headline (applied)

The card led with 1.00. Section 11 asked for numbers on an eval split; it never said the eval split must be independent of the generator, and that was a hole in the specification itself.

  • Section 11 now names two splits: composed (re-derivable, checks generator and router agree) and heldout (written, never generated from the lexicon). New row D5a requires the authorship of every split on every published number.
  • Gate change applied: the composed number sits in generator_consistency, where 1.00 is the expectation; heldout_top1_floor, heldout_recall_floor, heldout_precision_floor, heldout_refusal_floor and heldout_spread gate the release on the held-out set.
  • The card's headline is now a held-out number, labelled by authorship.

Phase 0b -- fix the thing the held-out set actually found: lexical recall (applied, one item open)

The numbers said the router was correct when it answered and silent when it should answer.

  • Applied: the surface forms per entry grew, not the entries. Per variety, per frame: complaint forms ("the default is shared and bites people"), linter forms ("flake8 complains about an import"), code-token forms (f string, assert isinstance), and for hi a romanized register next to the Devanagari one, because that is how the same request is typed in practice.
  • Applied: the matcher no longer needs a phrase to appear whole. It scores the content words of a phrase and boosts matches on code tokens, the words that survive code switching in any variety.
  • Applied: the gates report recall and precision beside top-1, because top-1 hides abstention and abstention is what this bundle was failing at.
  • Result, measured: held-out top-1 0.4133 -> 0.7200, recall 0.6111, precision 1.0000, refusal still 1.0000, spread 0.24 -> 0.16. Composed top-1 unchanged at 1.0000, catalog_regress drop 0.0000: the growth broke no pre-existing entry.
  • Still open: the small classifier section 6.4 permits, trained from this bundle's own corpus with no pretrained language model. It is the next lever for H1, which remains the weakest level at 0.514.
  • The published acceptance floor for held-out top-1 is now 0.60 with recall 0.60 and precision 0.95, and the card states the trade: raising recall further without buying false positives needs the classifier, not more tuning of thresholds.

Phase 1 -- widen the authored held-out set, and mark its authorship forever

Human annotation is not what unblocks this dataset; 150 written rows were already enough signal to work on. What is missing is coverage of phrasing space and honest labelling.

  • Scale the authored held-out set to >= 500 per variety, spread over the phenomena the current set only touches once: no symbol named, several shapes in one request, requests in one language naming symbols in another, transliteration of technical terms, negation ("do not touch the imports"), requests that are questions, requests that are commit messages, requests that are bug reports with a pasted traceback.
  • Keep every row's source field stating the authorship class. The card leads with the authorship of each split; a reader must never have to guess whether a number came from a person or from a model.
  • Make the held-out set blind by construction: it is not uploaded as a training corpus, only the split header and the counts are published in the first release, with the rows themselves withheld for the slice that decides a claim.
  • If a human collection ever happens, it lands as an additional split named human, and the model-authored numbers keep their name. They are never merged into one score.
  • Acceptance: >= 500 rows per variety, per-level and per-variety numbers with confidence intervals, authorship label on every split, and no split ever reported without it.

Status as of this revision: the acceptance line is not met, and the new evidence says the gap is worse than the headline suggested. corpus/heldout_blind_slice.jsonl (720 rows, 120 per variety, source = model-authored:blind-slice) was written without anyone reading the lexicon or the catalog first, and on it the system scores top-1 0.3889, recall 0.2817, refusal 0.9250, worst-variety gap 0.3167 (results/heldout_blind.json). The slice is measured on every gate run and published with those numbers rather than gated, because the floors of section 11 predate it and a floor invented afterwards would be a tuning knob. The confidence-interval part of the line is met: every cell of results/heldout.json, results/heldout_blind.json and results/intent_model_eval.json carries a Wilson 95% interval. Reaching 500 rows per variety, and the phenomena listed above, stays open work.


Phase 1b -- the human option, kept open and not merged

The plan does not depend on human collection, but if it ever happens:

  • It lands as a separate split named human, with a second annotator labelling each row in-scope / ambiguous / out-of-scope independently, and Cohen's kappa published with it. Below ~0.6 the multilingual claim is not a claim, it is noise.
  • Sourced where possible from real issue trackers and PR descriptions, split by repository, never by row.
  • Its numbers are reported beside the model-authored ones, never blended into them.

Phase 2 -- the catalog is the product: 7 entries to 40+ (open: 20 of 40 published)

D1 of section 11 asks for >= 40 entries and this release publishes 7. Growth is mechanical now that doc/HOW_TO_ADD_AN_ENTRY.py is an executable checklist: id, family, shape, rule, lock test, refusals, six lexicon files, conflict policy.

Status as of this revision: 20 entries, 190 declared conflict pairs, and every entry has a matcher, a lock and an editor exercised by the suite (test_every_catalog_entry_has_a_working_code_path). The acceptance line is unchanged and not met: 20 of 40.

  • Target families, in order of demand: naming, extraction, dead code, simplification, error handling, typing, logging, docstrings, dependency and API migration.
  • Each new entry ships with minimal pairs against its nearest neighbour, because the interesting errors are between adjacent entries, not between distant ones.
  • Every growth step runs run_gates.py --catalog-regress: no pre-existing entry may lose more than 0.02 top-1. The held-out set of Phase 1 is the regression target, not the composed set.
  • Acceptance: >= 40 entries, D1 met for real, catalog_regress green against held-out.

Phase 3 -- close the multilingual gaps that are currently admitted gaps (zh pair closed)

  • zh is skipped in the composed contrastive level because there is no segmenter. Fix it with character n-gram matching rather than excluding the variety, then re-enable L3 for zh and report the change.
  • Add the phenomena that are absent today: code-switching mid-request, a symbol named in Latin script inside an Arabic or Hindi sentence, transliterated terms, deliberate typos, requests with no verb.
  • hi 0.28, zh 0.36, es 0.36 against it 0.52 on the held-out set: those varieties get a lexicon pass first, because a 0.24 spread across varieties on the same seven shapes is a gap in the data, not a property of the languages.
  • Acceptance: worst-variety gap under 0.10 on held-out human data, no variety excluded from any level.

Status as of this revision: zh is no longer excluded. Its minimal pairs are built at the unit Chinese contrasts at, a character: the stray is the first character of the neighbouring entry's surface form, glued to the phrase, which is a real conflict for a router that reads Chinese as substrings. L3 now covers all six varieties (composed contrastive 1.00, spread 0.00). The held-out spread is 0.16, above the 0.10 the acceptance line asks for, and it is still measured on model-authored rows, so that line stays open.

Phase 4 -- make refusal and certainty measurable

Refusal at 1.00 on 18 out-of-scope rows is a small sample and an easy one.

  • Ambiguous requests where two entries are legitimate: accept either, require the clarifying question, score the choice.
  • Harmful requests: delete the failing test, drop a validation, remove an assertion to make a run green. These must be refused even when they map to a catalog entry's words.
  • Calibrate assurance. Today it is a counter; publish it as a probability by reporting how often a run claiming VERIFIED is actually correct, and the Brier score of that claim.
  • Acceptance: refusal measured on >= 200 rows per variety including adversarial ones; calibration reported with the reliability table under results/.

Status as of this revision: every held-out cell now carries a Wilson 95% interval in results/heldout.json, and the classifier booklet results/intent_model_eval.json carries them too, because 25 rows per variety are a sample. The adversarial rows and the refusal trajectories are published as separate artifacts (corpus/adversarial.jsonl, 27852 rows, and corpus/trajectories.jsonl, 30 rows) so that a reader can score them apart; both are re-derived byte for byte by build_corpus.py --check. The second opinion (tools/train_intent.py, models/intent_model.json) is trained only from the train split of this corpus and its abstention margin is chosen on the eval split by a printed rule; held-out rows are never read by that choice. The acceptance line is not met: refusal is still measured on 18 out-of-scope rows per variety, and assurance is still a counter, not a calibrated probability.

Phase 5 -- real repositories

The seed project is 22 files generated to present the shapes conveniently. It proves the pipeline; it does not prove usefulness.

  • Two or three permissively licensed real projects (5k-500k LOC), suite green, plus the real issues people filed against them.
  • The maintenance demo of section 1.1 re-run on them, with the refusals and the unverified changes reported in full.
  • Acceptance: D8 re-measured on a real project, with the drop from the seed number stated as a number, not as a caveat.

Phase 6 -- make it citable

  • Versioned releases; the acceptance-criteria table is versioned with the data, so a paper citing v1 means exactly these thresholds.
  • Datasheet section in the card: who authored the data, in what conditions, what the intended use is, what it must not be used for.
  • A blind slice kept server-side. A public eval invites overfitting; a benchmark with no hidden split gets gamed within a year.
  • Acceptance: a release tag, a datasheet, and a blind slice whose size and access rule are written in the card.

What not to do

Do not add a pretrained language model to raise the top-1. It would break the constraint this bundle publishes under (no off-the-shelf model) and would trade the one property that makes it worth reading -- every verdict re-derivable from a transcript of deterministic nodes -- for an ordinary comparison score. The honest way up is more entries, better data, and the held-out number rising on its own.