Repository navigation
feat(disfluency): the tree cutter and the cut filter run after the rules - #396
Conversation
With `parse: vectors`, disfluency.py reads the parse's reparandum arcs as proposed cuts and scores each with the cut filter V. A cut V gives 0.75 or more is applied when no rule already cut one of its words and it is not a doubled letter the rules keep as a spelling. With `parse: true` nothing changes. The training code is ported in pure Python: groups, of_clip, the text features, the vector pooling and V. V's weights are cut-filter.json beside the script. score.py records every case with vectors. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
Eight cases are French. score.py read every case as English, so their recorded parse split elisions with the English table. `lang: fr` on each, as `--eval` reads it, and score.py records and scores each case in its language. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2 Signed-off-by: Nathan Zylbersztejn <[email protected]>
|
Automatic reviews are disabled for this repository. |
|
Local CodeRabbit review (
|
WalkthroughThe disfluency transform now applies filler processing and can score parse-based tree-cut proposals when word vectors are available. It applies proposals scoring at least 0.75, records tree-cut counts, and reports them in JSON output. The scorer records vector parses for cases and passes each case’s language and parse to the transform. Validation cases and documentation cover the new behavior. Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Pre-merge checks:
|
|
CodeRabbit's docstring coverage warning (66.67% against 80%). I will not add docstrings here. The functions without one are the ported training functions ( |
With
parse: vectors,disfluency.pynow runs the tree cutter after its rules. The parse'sreparandumarcs propose cuts, the cut filter V scores each one, and a cut with P(real) >= 0.75 is applied when no rule already cut one of its words. Withparse: true, the default inconfig.example.yaml, nothing changes. The live gate shows 0 differences forparse: true.On real dev, through the transform as the app runs it, the tree cutter takes fixed corrections from 122 to 146 and false-cut words from 12 to 16, with the filler rule off. That is the R+T number the training code measured. Real dev half 2 has been scored several times, so turning it on by default needs fresh dictations.
One addition to the measured R+T, for the owner to accept or not: a tree cut that is the first copy of a doubled letter the rules keep as a spelling is not applied. Without it, the keep case "it takes A A batteries" was cut (V 0.95). "I I" is exempt, because "I" is a word. On the public dev sets this changes no output. Vetoing on every
KEPTguard instead cost 6 fixes on AMI dev and was rejected.Out of scope: the too-big cuts that arc merging in
groupsmakes (ported as it is; the next PR), retraining V on cleaned-text candidates, andparse: vectorsby default.Review first:
tree_cutandguardedindisfluency.py.tree_cutis the wiring.guardedkeeps a doubled letter the rules keep as a spelling ("it takes A A batteries").cut_spans, factored out ofresolve, so the filler rule and the tree cutter delete text with the same code.subtreetocut_filter). It is kept close to the training code so the two diff by eye.One step after the rules, standard library only; V's weights are a 74 KB JSON file beside the script
placed()maps the rules' output back onto the parse words. A proposal is applied only when all its words survived the rules, so the filler rule's cuts count as rules' cuts. There is no second parse.vector, which onlyparse: vectorssends. There is no new config key.training/syntax-parser:groups,derive_tags,gap_cues,of_clip,text_cue,text_features, the vector pooling (word_vectors,of_cand) and V. The vectors are decoded withstruct(<384e).built-in/transforms/disfluency/cut-filter.json(74 KB):w,b,muandsdas exact doubles, plus the sha256 ofclf-parser.pt. P(real) = sigmoid(((x - mu) / sd) . w + b).THRESHOLD = 0.75. The app copies every file of a built-in transform folder, so the file ships beside the script.disfluency.appliedgainstree cut.disfluency.tree_cutscounts the cuts applied anddisfluency.tree_droppedthe cuts V dropped. Both appear only when the tree cutter ran.disfluency.declinedsaystree cut: <reason>.Parity with the training code: same candidates and decisions; every difference comes from the parse
The envelopes come from a release build of main's Swift, which this PR does not change (
--parse --batch --vectors, tags rounded to 4 places as the envelope does). The reference isrules_reparse's [email protected]: the stored fp32 PyTorch parse, its candidates and its V scores. The filler rule is off for this comparison, as it was inrules_reparse. Its cuts are reported apart.Every difference, and its cause:
CutFilter) gives the same candidates on all 2,844 rows, a max |dP| of 2.3e-7, and 0 flips.Real dev, confirm only: 146 / 16, as the training code measured
500 dictations, 254 corrections. Each envelope is piped into
disfluency.pywithPARROTFLOW_PROTOCOL=json, as the app runs it. Counts only. No text was printed, and nothing was chosen on this set.parse: true(rules + filler rule)parse: vectors(rules + filler rule + tree cutter)rules_reparse's [email protected]: 146 / 21 / 85 / 2, 16 false-cut words.Cases: keep 44/44; the tree cutter changes no case that main passes
score.pynow records every case with--vectors, and scores each one with its parse, asparse: vectorshands it over. The 10 French cases carrylang: fr, which--evalalready reads. They are now parsed and scored in French.parses.jsongrows from 25 to 107 entries and to 1.29 MB, about 1 KB per word.--eval disfluencyruns the config's ownparse:. On aparse: vectorsconfig it gives 103/107, the 4 known misses. Onparse: trueit gives 101/107: the 3treecases need vectors.groupsmerges the fragment's arc with them. That group scores 0.54 and is dropped. The "I I" group scores 0.98 and is kept, so a stray "Wa" is left.Live gate and cost: `parse: true` changes nothing; `parse: vectors` changes 3 of 165 bench outputs and 4 of 573 French ones, all by a tree cut, for 3 to 6 ms
Release binary. Pipeline
vocabularythendisfluency, incp -ccopies of the scratch homes. The PR changes no Swift, so one binary serves every arm, and onlydisfluency.pydiffers. Outputs are compared by hash; no text was kept.parse: truevs main: outputs differparse: vectorsvs main: outputs differparse: true, the branch'sappliedanddeclinedequal main's on every row, and no tree var is published.disfluency.declinedis empty on everyparse: vectorsrow, so the weights file was found every time.Cost. 3 to 6 ms of Python at 20 to 120 words. The stage time difference is inside the run-to-run noise. Release binary,
--pipeline --vars --warm, one process per run, 5 interleaved runs. The text is invented and holds one self-correction, so the tree cutter applies one cut at every length. Thedisfluency.msvar includes the parse.parse: true, median ms (runs)parse: vectors, median ms (runs)Importing the module and reading
cut-filter.jsonadds 1.4 ms per process. The Python numbers are medians of 20 warm calls oftree_cut.🤖 Generated with Claude Code
https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2