fix(#79): chunker never emits sub-50-char fragment chunks (#55 follow-up) #45

Merged
chaim merged 1 commits from fix/79-chunker-no-tiny-fragments into main 2026-06-03 08:10:39 +00:00
Owner

הבעיה (#79)

ה-chunker ההיררכי פלט chunk זעיר כשסעיף נפתח בכותרת קצרה ("דיון", "טענות המשיבים") ואחריה פסקה גדולה מ-chunk_size — הכותרת נוקזה לבדה. #55 הוסיף פילטר query-time (≥50) שמסתיר אותם; כאן מסירים אותם במקור.

התיקון — _split_section

  1. לא לנקז buffer שעדיין מתחת ל-MIN_CHUNK_CHARS (50) — לתת לו לספוג את הפסקה הבאה גם אם זה עובר את chunk_size, כך שכותרת קצרה רוכבת עם התוכן שאחריה.
  2. קיפול trailing tiny chunk לקודמו.

אימות (מקומי, מ-full_text שמור — ללא re-OCR)

re-chunk ל-4 התיקים שעוד היו להם chunk זעיר (ע"א 5138/04, בר"מ 2340/02, בג"ץ 6525/15, 403-17):

  • chunks<50 corpus-wide: 4 → 0
  • כל 4 נשארו embedded/searchable; נווה שלום (ע"א 5138/04) = תוצאה #1 לשאילתת פטור ס' 19(ג)(1). אפס רגרסיה.

סוגר את #79. ה-chunker רץ גם בקונטיינר בהעלאות → נדרש deploy כדי שהעלאות עתידיות יפיקו chunks תקינים מהמקור.

🤖 Generated with Claude Code

## הבעיה (#79) ה-chunker ההיררכי פלט chunk זעיר כשסעיף נפתח בכותרת קצרה ("דיון", "טענות המשיבים") ואחריה פסקה גדולה מ-`chunk_size` — הכותרת נוקזה לבדה. #55 הוסיף פילטר query-time (≥50) שמסתיר אותם; כאן מסירים אותם **במקור**. ## התיקון — `_split_section` 1. **לא לנקז buffer שעדיין מתחת ל-`MIN_CHUNK_CHARS` (50)** — לתת לו לספוג את הפסקה הבאה גם אם זה עובר את chunk_size, כך שכותרת קצרה רוכבת עם התוכן שאחריה. 2. **קיפול trailing tiny** chunk לקודמו. ## אימות (מקומי, מ-full_text שמור — ללא re-OCR) re-chunk ל-4 התיקים שעוד היו להם chunk זעיר (ע"א 5138/04, בר"מ 2340/02, בג"ץ 6525/15, 403-17): - chunks<50 corpus-wide: **4 → 0** - כל 4 נשארו embedded/searchable; **נווה שלום (ע"א 5138/04) = תוצאה #1** לשאילתת פטור ס' 19(ג)(1). אפס רגרסיה. סוגר את #79. ה-chunker רץ גם בקונטיינר בהעלאות → נדרש deploy כדי שהעלאות עתידיות יפיקו chunks תקינים מהמקור. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-03 08:10:32 +00:00
A section that opens with a short header line ('דיון', 'טענות המשיבים')
followed by a paragraph larger than chunk_size flushed the header alone as a
tiny chunk. #55 added a query-time >=50 filter to hide these; this removes
them at the source.

_split_section: (1) don't flush a buffer still below MIN_CHUNK_CHARS — let it
absorb the next paragraph even if that overflows chunk_size, so a short header
rides with its following content; (2) fold a trailing tiny chunk back into its
predecessor.

Verified: re-chunked the 4 corpus docs that still had a tiny chunk
(ע"א 5138/04, בר"מ 2340/02, בג"ץ 6525/15, 403-17) — corpus-wide chunks<50
went 4 -> 0; all 4 stay embedded/searchable and rank top in a relevant search
(נווה שלום #1 for the s.19(ג)(1) exemption query). No regression.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit bb42aeeff4 into main 2026-06-03 08:10:39 +00:00
chaim deleted branch fix/79-chunker-no-tiny-fragments 2026-06-03 08:10:39 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#45