Skip to content

fix(eval): locate split chunks without jumping to repeated passages - #5548

Merged
kovtcharov-amd merged 2 commits into
mainfrom
fix/eval-locate-split-chunks
Oct 21, 2026
Merged

kovtcharov-amd merged 2 commits into
mainfrom
fix/eval-locate-split-chunks

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

The release retrieval eval still stops on FinanceBench after #5490. SEC filings repeat whole passages. When a chunk followed the short tail of a chunk split for the embedder, the benchmark's locator matched a repeat hundreds of pages later, and every chunk after it in that filing counted as unlocated (644 chunks across four filings, over the 1% limit). The nearby copy now wins. Placements in every other filing are unchanged. This follows #5490, which merged before this commit landed on its branch. Benchmark code only; no user-facing behavior changes.

Test plan

  • The four failing filings (American Water 2022 10-K, JPMorgan 2021 Q1 10-Q and 2022 10-K, PepsiCo 2023 8-K): 644 unlocated chunks before, 0 after
  • Old vs new placements on six filings: only chunks that had jumped to a far-later duplicate moved; 3M and AMD 10-Ks are identical
  • New test fails on the old locator: an overlap through a split tail beats a later repeat, a chunk only the repeat explains stays there, and absent text stays unlocated
  • pytest tests/unit/eval/test_retrieval_bench.py tests/unit/rag/test_retrieval_bench_harness.py (87 passed), python util/lint.py --all

SEC filings repeat whole passages. When a chunk followed the short tail
of a chunk split for the embedder, the locator took the first copy of
its text after the tail, often a repeat hundreds of pages later, and
every chunk after it in that filing then counted as unlocated. Four
FinanceBench filings lost 644 chunks this way, which stopped the
release retrieval eval. The copy that runs back through the tail now
wins; chunks in other filings are placed exactly where they were.
@github-actions github-actions Bot added eval Evaluation framework changes tests Test changes performance Performance-critical changes labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This fixes the retrieval benchmark's chunk locator so that when a chunk's overlap runs back through the short tail of a split chunk, the nearby copy wins over an identical passage repeated much later in the filing. That jump is what left 644 FinanceBench chunks unlocated and pushed the release eval over its 1% limit. The change is small, sensible and covered by a test that fails on the old locator. Nothing blocks the merge.

One thing to know: the backward match now wins every time it exists, not only when the in-order search fails. In highly repetitive text, such as filler rows in a financial table, a chunk can now land a few characters earlier than before. That's harmless for page-level scoring, and the author's six-filing old-vs-new diff found no such moves. It's worth keeping in mind if placements ever look slightly off in table-heavy documents.

Real-world evidence

The evidence stage ran the CLI, but this lane has no Lemonade, so it stopped at the embedder before reaching the changed code. The end-to-end check is pending strix-halo lane. This verdict rests on static review plus the author's reported before/after numbers (644 → 0 unlocated on the four failing filings).

$ gaia eval retrieval --suite pr --out /tmp/rr   # after pip install faiss-cpu pypdf
gaia.rag.sdk.EmbeddingUnavailableError: The embedding model user.embeddinggemma-300m-GGUF failed:
Failed to register/download embedding model 'user.embeddinggemma-300m-GGUF'.
Ensure Lemonade Server is running and reachable, then retry (or run `gaia init --profile rag`).

Spot regression: gaia eval retrieval --help exits 0 with the expected flags, and harness / hard_cases import cleanly against the new locate.py.

🔍 Technical details

Issues

🟢 Stale comment above the in-order search (src/gaia/eval/retrieval/locate.py:124-125). The comment still says a match before the previous chunk "counts as unlocated". After this change a match before cursor is preferred whenever it runs through cursor. The comment in the if needle: block below explains the exception, but the first line now reads backwards.

            # Chunks come in document order; a match before the previous chunk
            # is usually repeated text elsewhere, so it is not searched for here.

🟢 Backward match now has priority over a valid in-order match (locate.py:131-134). Previously _find_through ran only when find(needle, cursor) returned -1. Now any copy in [before, cursor] that ends past cursor wins. For periodic text (repeated $ — $ — rows), that can place chunk k+1 before chunk k. cursor then moves backwards, and before becomes greater than cursor on the next iteration. Nothing crashes and the offsets stay inside identical text, so page attribution barely moves. If you want to narrow the rule, prefer back only when the in-order hit is far away, for example pos < 0 or pos - cursor > len(needle). Optional; the empirical diff says the current rule is fine.

Strengths

  • _find_through bounds the search with find(..., limit), so the extra lookup per chunk stays cheap and can't wander into the later repeat.
  • The new test covers all three branches: a near overlap beats a far repeat, a chunk only the repeat explains still goes there, and absent text stays unlocated. The PR also confirms the test fails on the old code.
  • The validation is the right kind: before/after counts on the real failing filings, plus an old-vs-new placement diff showing unrelated filings are unchanged.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Fixed the stale comment. Leaving the backward-match rule as it is: comparing old and new placements across six filings found no small backward moves, and the old code already moved the cursor backward for split tails, so a later before > cursor was already possible and is harmless.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 52d7165 Oct 21, 2026
33 of 34 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/eval-locate-split-chunks branch October 21, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval Evaluation framework changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant