Insight: recover cross-chunk quote matches in fact extraction#71
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from @rapsoj's #66.
What
When retrieval routes a chunk adjacent to the one the model actually quoted,
extract_facts_from_chunknow 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_matcheshallucination guard is unchanged — and the provenancechunk_idis 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.