Skip to content

Insight: recover cross-chunk quote matches in fact extraction#71

Merged
smodee merged 1 commit into
mainfrom
extract/chunk-quote-routing
Jul 17, 2026
Merged

Insight: recover cross-chunk quote matches in fact extraction#71
smodee merged 1 commit into
mainfrom
extract/chunk-quote-routing

Conversation

@smodee

@smodee smodee commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Extracted from @rapsoj's #66.

What

When retrieval routes a chunk adjacent to the one the model actually quoted, extract_facts_from_chunk now falls back to searching the other chunks of the same document. A fact is accepted only when its quote appears verbatim in some sibling chunk — the existing _quote_matches hallucination guard is unchanged — and the provenance chunk_id is corrected to the chunk that actually contains the quote.

Why

Chunk-routing misses were dropping real facts whose supporting quote lived one chunk over. This recovers them without weakening the anti-fabrication guarantee (a verbatim match is still required).

Tests

Adds a cross-chunk regression test (routes via the heading chunk while the quote lives in the prose chunk) — it fails without the fix and passes with it. Full suite green.

When retrieval routes a chunk adjacent to the one the model actually
quoted, extract_facts_from_chunk now falls back to searching the other
chunks of the same document. A fact is accepted only when its quote
appears verbatim in some sibling chunk (the existing _quote_matches
hallucination guard is unchanged), and the provenance chunk_id is
corrected to the chunk that truly contains the quote. Adds a regression
test covering the routing-miss case.

Extracted from @rapsoj's #66.

Co-Authored-By: Jess Rapson <jessicakristenr@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@smodee
smodee merged commit 0661af3 into main Jul 17, 2026
@smodee
smodee deleted the extract/chunk-quote-routing branch July 17, 2026 15:00
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