Skip to content

fix(embedding): stop windows after covering the document - #734

Merged
rng1995 merged 15 commits into
NVIDIA:mainfrom
Afloat16:fix/skip-covered-embedding-tails
Nov 23, 2026
Merged

rng1995 merged 15 commits into
NVIDIA:mainfrom
Afloat16:fix/skip-covered-embedding-tails

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Full-body embedding windows continue advancing after a chunk already covers the document end. With 20 characters, a 12-character window and four-character overlap, the current code embeds [0:12], [8:20] and the redundant [16:20]. That last input contains no new content, consumes additional embedding work and gives the document tail extra weight in average pooling.

Stop after the first window reaches the document end. A short tail that adds any new content is retained: the corresponding 21-character document still produces three windows. This applies to full-body catalog construction and full-body queries through embed_chunked.

Saved full-body catalogs must be rebuilt to use the corrected pooling; the changelog calls this out. The catalog format is unchanged and existing vectors are not automatically recomputed.

Integration refresh — 2026-11-19

Head d8e9150d33b564d49ba9af97a8cd64fb4ba537d3 merges main ac9fc0ef4999ee5eb86eae27ec3a83c880891c92 and resolves the Unreleased changelog conflict by retaining both entries. The embedding implementation and tail-coverage regression-test blobs are unchanged from the preceding PR head; all non-PR files match that main revision. Structural review confirmed that the original PR diff is preserved. Earlier test results below apply to those unchanged files; this changelog resolution does not claim a full-suite rerun. Current workflows await maintainer approval.

Verification

The new test module produced 6 failed, 5 passed on unchanged base 8fe9723; all 11 pass after the fix. It covers exact and partial final windows, high and zero overlap, one-character unique tails, the actual texts passed to the embedding provider and the resulting pooled vector. A deterministic provider fixture proves the redundant 20-character case submits two inputs instead of three; no live-provider quality or cost benchmark is claimed.

python -m pytest tests/embedding -q -k 'not test_load_rejects_socket_catalog' — 388 passed, 2 skipped, 1 deselected. The deselected existing Unix-socket catalog test raises an environment PermissionError while creating the socket, also reproduced on unchanged base.

  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated documentation for user-visible changes (Unreleased changelog)
  • Ran make lint equivalent: python -m ruff check src tests
  • Full make test did not complete successfully in this environment (see below)
  • Ran make build equivalent: python -m build (wheel and sdist)
  • Did not add credentials, private datasets, or proprietary benchmark content

The unchanged base 8fe9723, tested with python -m pytest -x -q, stops after 456 passed and 19 deselected at tests/ci/test_gateway_benchmark_workflows.py::test_gitlab_enriched_tier1_applies_the_keyless_job_baselines[extra0-expected0]. The sandbox has no /tmp, while that workflow fixture explicitly invokes mktemp -d /tmp/skillevaluator-enriched-tier1.XXXXXX. The same test fails for the same reason on the retry branch. No full-suite pass is claimed.

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

Signed-off-by: Afloat <ShuffleMonkey@163.com>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is right and nicely small. I fuzzed the old and new _fixed_size_chunks on 3000 random documents (lengths 0 to 400, window 1 to 60, overlap anywhere below the window): the new output is always a prefix of the old one, every window the fix drops is a strict suffix of the last kept window, every document is still fully covered, and the 1104 documents that had no redundant tail come out byte-identical. The rest lost between 1 and 58 redundant windows, the big numbers coming from tiny steps where the old loop kept re-embedding ever shorter tails.

The new tests fail 6 of 11 on main and pass with the fix, and the whole tests/embedding directory passes on this branch (390 passed, 1 skipped). I also checked that the other open embedding PRs do not touch this function, that the Tier 2 docs only describe the chunk size and overlap (still accurate), and that the commit is signed off. Agree with the changelog note that saved full-body catalogs keep their old pooled vectors until rebuilt, since entries are reused by content fingerprint.

One formatting nit inline on the changelog. Good to go otherwise.

Comment thread CHANGELOG.md Resolved
Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, @Afloat16. Reviewed 5b51afe2c3b1; no new actionable defects found. Stopping after a window covers the document removes redundant tail inputs without dropping unique content. I checked overlap boundaries, whitespace trimming, heading-based callers, pooling, and the catalog-rebuild note.

Validation: The embedding suite passed 390 tests with 1 skip. A further 5,000 seeded random window cases retained coverage and removed only redundant suffix windows.

The previously reported changelog formatting issue is addressed in the reviewed head.

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking: since this changes the pooled vector for any full-body document whose last window used to be followed by a redundant one, a catalog built before this fix will silently compare old-pooling entries against new-pooling queries. The changelog's "rebuild" note covers it; if you want it enforced, bumping CATALOG_SCHEMA_VERSION (or recording a chunking version in the catalog header) would make load_catalog reject stale files instead of relying on readers of the release notes.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Afloat16 for this contribution! I reviewed 5b51afe2c3. I reproduced the problem on main, confirmed this change fixes it, checked that the new tests fail on main, and ran the new and related tests on this head (all pass). I left 1 inline comment (1 P3); please take a look.

Comment thread CHANGELOG.md Resolved
Merge current main while retaining this change and the published release notes.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Describe window termination for each long section and retain the saved-catalog rebuild guidance requested in review.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
@Afloat16

Copy link
Copy Markdown
Contributor Author

Addressed in b07b90f. The entry is now under Unreleased, describes windowing each long section rather than only the document end, and retains the instruction to rebuild saved full-body catalogs. The Fixed list stays contiguous and main's published release notes are preserved. This PR's existing production and regression-test changes are preserved; this follow-up changes only CHANGELOG.md and passes git diff --check. Hosted workflows await maintainer approval.

@rng1995
rng1995 enabled auto-merge (squash) November 18, 2026 05:15
Signed-off-by: Afloat <ShuffleMonkey@163.com>
auto-merge was automatically disabled November 18, 2026 06:06

Head branch was pushed to by a user without write access

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Afloat16 for this contribution and for addressing the earlier review! I re-checked 1b592539f4: all 1 earlier comment is resolved in the code, the tests pass, and I found nothing new. Approving.

Preserve this pull request's code and tests while resolving the changelog conflict.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Afloat16 and others added 6 commits November 19, 2026 17:19
Preserve both the PR entry and current upstream release notes.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>
Synchronize with NVIDIA/SkillEvaluator main f867b7f.
Retain this PR's entry under Unreleased and preserve published release history.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Resolve CHANGELOG.md by keeping main's Unreleased entries unchanged and
retaining the embedding window entry at the top of Unreleased > Fixed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Resolve the CHANGELOG.md conflict by keeping main's entries and this change's entry under Unreleased.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Resolve the CHANGELOG.md conflict by keeping main's entries and this change's entry under Unreleased.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Afloat16 for this contribution! I re-checked b26396ef3: I merged current main into the branch (the only conflict was CHANGELOG.md, resolved by keeping main's entries and this entry under Unreleased), confirmed that every earlier review comment is addressed in the code, and ran this PR's tests and ruff, which pass. I found nothing new. Approving. Chris's optional suggestion to enforce stale catalogs through CATALOG_SCHEMA_VERSION is left as a follow-up.

@rng1995
rng1995 merged commit 6c07bd0 into NVIDIA:main Nov 23, 2026
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.

3 participants