Skip to content

fix(chunklets): stop one-line paragraphs from collapsing boundary cues - #6

Merged
emerose merged 1 commit into
mainfrom
claude/keen-thompson-7aff6f
May 29, 2026
Merged

emerose merged 1 commit into
mainfrom
claude/keen-thompson-7aff6f

Conversation

@emerose

@emerose emerose commented May 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes a stage-2 root cause in boundary-cue assignment that surfaced in the chunk-coherence review (Qasper papers, ~1700-char target). Rebased onto current main (v0.6.0); this releases as 0.6.1.

_per_sentence_boundary_probas assigned paragraph_open strength to every sentence sharing a one-line paragraph's source line (the normal Qasper shape). With no 0.0 separators between blocks, SPEC-CHUNK-241 suppression then collapsed the whole document to a single surviving boundary, discarding every heading and paragraph cue after the first.

The fix adds a block-opener guard: only the sentence whose first non-whitespace character actually opens the block earns the structural strength; interior sentences score 0.0.

Relationship to existing work

main already added stage-3 mechanisms — SPEC-CHUNK-324 (MID_PARAGRAPH_PENALTY) and SPEC-CHUNK-323 (small-chunk badness). Those operate on the partition objective; they depend on stage 2 actually emitting the paragraph/heading cues. This fix restores those cues at the source, so the stage-3 preferences fire as intended. chunklets.py was untouched by main, so this is complementary, not overlapping.

Restored behavior:

  • Paragraph-aligned splits (no mid-paragraph cuts when a \n\n boundary is within budget).
  • Abstracts kept whole with the break landing at ## Introduction.
  • Headings never stranded at a chunk's tail.

Verified across the 7 reported papers: 0 heading-tails, 0 stubs.

Issue 5 (the , which mid-clause split in 1912.11637) was investigated and is a source-data artifact — the raw Qasper markdown contains a stray . , ("...CIDEr. , which..."); SaT correctly splits at the genuine period. No code change.

Changes

  • src/fancychunk/chunklets.py — block-opener guard in _per_sentence_boundary_probas.
  • docs/specs/02-chunklet-grouping.md — SPEC-CHUNK-240 documents the guard.
  • docs/specs/test-vectors/02-chunklet-grouping.md — new TV-209.
  • Regression tests (each confirmed to fail on pre-fix code): TV-209, paragraph-boundary split, heading-tail/stub across 8 embedding seeds, abstract-whole-break-at-heading.
  • Version bump to 0.6.1; CHANGELOG entry.

Test plan

  • uv run pytest -q — 212 passed, 20 skipped (on the rebased base)
  • uv run ruff check clean on touched files; my edits format-clean
  • uv run pyright — 0 errors
  • Empirical re-run across all 7 papers: 0 heading-tails, 0 stubs

🤖 Generated with Claude Code

A one-line paragraph holding several sentences leaked paragraph_open
strength to every interior sentence, leaving no zero-probability
separators between blocks. SPEC-CHUNK-241 suppression then collapsed the
whole document to a single surviving boundary, discarding every
heading/paragraph cue after the first.

Add a block-opener guard in _per_sentence_boundary_probas so only the
sentence that opens a block earns the structural strength. Restores
paragraph-aligned splits, keeps abstracts whole (break at ## Introduction),
and prevents headings from being stranded at a chunk's tail.

Update SPEC-CHUNK-240 + add TV-209; regression tests for paragraph
boundary, heading-tail/stub, and abstract-whole. Bump to 0.6.1.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@emerose
emerose force-pushed the claude/keen-thompson-7aff6f branch from 0a2243b to ae72a97 Compare May 29, 2026 12:54
@emerose
emerose merged commit c4fdb58 into main May 29, 2026
2 checks passed

This branch was previously deployed

1 inactive deployment
pypi — ae72a973 Deployed May 29, 2026 by emerose via publish #9
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