Skip to content

feat(disfluency): the parser takes back self-corrections, off by default - #374

Merged
znat merged 8 commits into
feat/syrinx-disfluencyfrom
feat/syrinx-tree-cutter
Oct 23, 2026
Merged

znat merged 8 commits into
feat/syrinx-disfluencyfrom
feat/syrinx-tree-cutter

Conversation

@znat

@znat znat commented Oct 23, 2026

Copy link
Copy Markdown
Owner

A new pass takes back self-corrections with the parser, not with rules: "ship it on Monday, no, on Tuesday" becomes "ship it on Tuesday". The parrotflow-syrinx tree cutter proposes each stretch its parse marks as a reparandum, and the cut filter keeps the ones it scores at P(real) ≥ 0.80. It is off by default, behind transcription.disfluency.enabled, and English only. Off, nothing changes and nothing is downloaded. Review the port in TreeCutter.swift against the Python spec, and the loading rule in SyrinxModel.ready(within:).

transcription:
  disfluency:
    enabled: false
    # threshold: 0.80        # the cut filter keeps a cut at P(real) >= this

Why

The cut check and the filter-vectors work measured the tree cutter plus the cut filter on the parser's own block-11 states (training/syntax-parser/CUT_CHECK.md, FILTER_VECTORS.md). This PR ports exactly that path to Swift, so it can be tried on real dictations. P1 (the repeat, marker and cue rules) is not in this PR. The Python disfluency transform stays as it is.

Scope

  • TreeCutter.swift: the filler view (the built-in fillers table and Replacements.tidy, the text the parser was measured on), the cue_rule tokenizer, windows() (sentences, then commas, then 60-word runs, each window under 256 subwords), the candidates (audio_cue.candidates.groups), the 7 text features, the vectors pooled from s_hidden10, and assemble. Kept cuts map back to the input's words, with any filler inside a cut. Fillers outside a cut stay for the fillers step.
  • CutFilter: reads cut-filter.safetensors and checks its 1,159 feature names.
  • Parser.analyse: the tree, plus the tag head's P(abandoned) and P(cue), plus s_hidden10 pooled per word.
  • A fixed pass tree_cutter, after vocabulary and before pipeline:, where spoken numbers are still words. context_spelling still runs last, as the code already has it. The stage is not called disfluency, because that namespace belongs to the Python transform.
  • Trace and scope: tree_cutter.count, kept, dropped, threshold, candidates (each candidate's words, P(real) and kept or dropped), declined, and a part span tree cutter.
  • Loading: the model is fetched and warmed only when the block is on. A dictation waits at most 2 s for a copy already on disk, and not at all for a download. Until the model is in memory the pass declines and says why.
  • --check-config validates both keys and refuses a threshold outside 0 to 1. --tree-cut runs the pass from the command line. Docs: config.example.yaml, configuration.md, pipelines.md, cli.md, the skill catalogue.

Tradeoffs

  • text_cue reads the cut words in CPython's set order, as the measured code did, not in sorted order. The Swift code emulates that order, so its decisions match what was measured.
  • Output words are joined with single spaces when a cut is kept, as the scorer assembled them. A newline in such a dictation is lost.

Blast Radius

Off by default, so no user sees a change until they turn it on. With the block off or absent, 264 inputs through --replace give byte-identical output to the base branch, and no parser files appear in a fresh home. On, it costs a 533 MB download and about 12 to 30 ms per dictation.

Verification

  • Committed parity, scripts/check-disfluency-model-parity.sh (Core ML, fp32, cpuAndGPU) against tests/disfluency-model-parity.json (PyTorch, written by scripts/disfluency-model-reference.py): 146/146 cases have the same candidates, kept cuts, cut and output. Largest P(real) difference 2.95e-05.
  • Public sets (uncommitted, outputs under training/), Swift against the measured Python at 0.80: all candidates, kept cuts and outputs agree, and the scorer's fixed and false-cut counts are equal.
  • Flag off: identical output to the base branch, and no fetch.
  • Live, from Hugging Face, under a scratch config and home: a kept cut and two dropped ones in the published variables.
  • Cost, warm, median of 5 interleaved runs: 11.7 ms at 20 words, 13.5 ms at 60, 29.5 ms at 200.
  • scripts/check-parser-parity.sh 121/121. swiftlint 0 errors, ruff, shellcheck. check-schema 70/70, check-pipeline 134/134, check-pipeline-config 98/98, check-skill 29/29, check-catalogue 52/52. These ran under a scratch config and home.
Public-set parity, per set

The texts are the cut-check sets' filler text, so the filler view equals the input. Fixed / partly / missed / damaged items, then false-cut words, with the cut-check scorer. Both sides give the same numbers on every set.

Set Texts Candidates (Swift = Python) Kept Same cut / output Max P(real) diff Fixed / partly / missed / damaged, false
CV dev v3 153 112 40 153 / 153 1.3e-5 32 / 8 / 96 / 0, 0
Written dictation dev 150 60 31 150 / 150 2.5e-5 24 / 4 / 44 / 3, 0
Adversarial tree-dev 96 61 20 96 / 96 1.3e-5 21 / 2 / 41 / 2, 0
AMI held out 1,936 1,257 606 1,936 / 1,936 4.7e-5 501 / 66 / 822 / 22, 18

Candidates are counted by distinct word set. The reference script, run on CV dev, reproduces the stored cut-check candidates and P(real) to 5e-7.

Fixtures, flag off, live and cost
  • Fixtures: the 102 disfluency cases, 43 sentences written for this repo (cuts at the start and the end, fillers inside and outside a cut, a capital after a cut, curly apostrophes, emoji, empty input), and two inputs over 256 subwords that split into windows. 90 candidates, 48 kept. One case was left out because a candidate sits 0.0002 from the threshold, where float16 noise could flip it.
  • Flag off: the base binary (5a9db5da) and this branch ran --replace on the 120 pipeline-case inputs and the 144 non-empty fixture texts, under fresh scratch configs and homes. The output is identical with enabled: false, and identical with the block removed. scripts/check-pipeline.sh prints the same 134/134 on both. No parrotflow-syrinx path appears in either home.
  • Live: off, --check-config lists no tree_cutter. On with no cache, the pass declines with "parser not downloaded". --tree-cut fetched the model from Hugging Face (f3f75830) in 26.5 s and matched every pin. Then --replace cut "on Monday, no,". --pipeline --vars published "Can" 0.244 dropped; "you," 0.754 dropped; "on Monday, no," 0.889 kept. French text with languages: [en, fr] declined with "not English".
  • Cost: --tree-cut --batch, model warm, 5 interleaved rounds per process, two processes. 20 words 11.7 / 11.8 ms, 60 words 13.7 / 13.3 ms, 200 words 29.5 / 29.0 ms. With the flag off the stage is not in the pipeline, so it adds nothing. A cached load took 0.8 to 1.3 s, under the 2 s wait.
  • scripts/check-sound.sh fails 12/13 under a fresh home, on this branch and on the base alike: the neural phoneme model is not in that home.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2

znat and others added 8 commits October 23, 2026 14:50
scripts/disfluency-model-reference.py runs the measured path of the cut
check in the training code: t-silver 42 parses the filler view in
windows that fit 256 subwords, the tree cutter groups the reparandum
arcs into candidates, and the cut filter scores each one on the text
features and the parser's own block-11 vectors. It writes
tests/disfluency-model-parity.json, one case per line.

The filler view is the built-in `fillers` table and its tidy-up, the
text the parser was measured on. Cuts map back to the input's words,
with any filler inside a cut, and the output is assembled from the
input, so fillers outside a cut stay for the `fillers` step.

146 cases: the disfluency case set, 43 written sentences and two inputs
over 256 subwords. 90 candidates, 48 kept at 0.80. A case with a
candidate within 0.002 of the threshold is left out, since float16
noise could flip it: one case.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
Parser.analyse returns the parse plus what the tree cutter reads per word: P(abandoned) and P(cue) from the tag head on the fused word features, and s_hidden10 pooled to words through float16. parse keeps its output.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
TreeCutter runs the measured Python on one text: the filler view, the windows that fit 256 subwords, the reparandum groups, the 7 text features and the three pooled vectors, then the cut filter's P(real). Kept cuts map back to the input's words and the output is assembled from the input. SyrinxModel loads the cut filter with the parser.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
Prints each candidate with its P(real) and the output. --batch reads many inputs in one loaded process and prints JSON lines.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
Runs --tree-cut --batch on tests/disfluency-model-parity.json and compares candidates, kept cuts, P(real) within 1e-3, the cut and the output. 146/146, largest P(real) difference 2.95e-05.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
`warm()` starts the load or the fetch in the background, with a
five-minute backoff after a failure. `ready(within:)` is what a
dictation asks: no cache returns at once and starts the fetch, a cached
copy is waited for up to the cap and then left loading. The setup
screen gets a row, and the first prediction runs inside the load.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
A fixed pass named `tree_cutter`, off by default. On, it runs after
`vocabulary` and before the list, English only, and publishes every
candidate with its P(real) and verdict, the counts, the threshold and
why it declined. `threshold` must be 0 to 1. With the block off or
absent nothing fetches or loads the model.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
@greptile-apps

greptile-apps Bot commented Oct 23, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cba8b362-eb5a-45c7-90d3-ffb4fd099be3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@znat

znat commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

/review

@znat

znat commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

/agentic_review

@znat
znat merged commit bfc3a6c into feat/syrinx-disfluency Oct 23, 2026
4 checks passed
@znat
znat deleted the feat/syrinx-tree-cutter branch October 23, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant