From d1b47b7ee426b65e6a541711ac4aca643444fe09 Mon Sep 17 00:00:00 2001 From: Afloat Date: Tue, 17 Nov 2026 11:53:42 +0800 Subject: [PATCH 1/3] fix: stop embedding windows after covering the document Signed-off-by: Afloat --- CHANGELOG.md | 4 ++ src/skillevaluator/embedding/client.py | 2 + tests/embedding/test_chunk_tail_coverage.py | 54 +++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 tests/embedding/test_chunk_tail_coverage.py diff --git a/CHANGELOG.md b/CHANGELOG.md index f3a4fafc6..d1bb5af8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -438,6 +438,10 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed +- Full-body embeddings stop once a chunk covers the document end, avoiding extra + embedding inputs and pooled weight for already-covered tails. Rebuild saved + full-body catalogs to use the corrected pooling. + - Direct Tier 1 validates the target, selected checks and LLM configuration before preparing scanners, so configuration errors do not trigger downloads or stdout noise. - Documentation-only CI follows imports through collected test modules and diff --git a/src/skillevaluator/embedding/client.py b/src/skillevaluator/embedding/client.py index 22b0b9618..d3a203073 100644 --- a/src/skillevaluator/embedding/client.py +++ b/src/skillevaluator/embedding/client.py @@ -397,6 +397,8 @@ def _fixed_size_chunks(text: str, max_chars: int, overlap_chars: int) -> list[st chunk = text[start:end].strip() if chunk: chunks.append(chunk) + if end >= len(text): + break start += max_chars - overlap_chars return chunks diff --git a/tests/embedding/test_chunk_tail_coverage.py b/tests/embedding/test_chunk_tail_coverage.py new file mode 100644 index 000000000..bc59324f8 --- /dev/null +++ b/tests/embedding/test_chunk_tail_coverage.py @@ -0,0 +1,54 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Embedding windows must add new document content, including a short unique tail.""" + +import string + +import pytest + +from skillevaluator.embedding.client import EmbeddingClient, _fixed_size_chunks + + +@pytest.mark.parametrize( + ("length", "overlap", "starts"), + [ + (19, 4, [0, 8]), + (20, 4, [0, 8]), + (21, 4, [0, 8, 16]), + (27, 4, [0, 8, 16]), + (28, 4, [0, 8, 16]), + (29, 4, [0, 8, 16, 24]), + (20, 8, [0, 4, 8]), + (24, 0, [0, 12]), + (25, 0, [0, 12, 24]), + ], +) +def test_windows_stop_once_the_document_is_covered(length, overlap, starts): + text = string.ascii_letters[:length] + + assert _fixed_size_chunks(text, max_chars=12, overlap_chars=overlap) == [ + text[start : start + 12] for start in starts + ] + + +@pytest.mark.parametrize("last_character", ["", "u"]) +def test_embed_chunked_pools_only_windows_with_new_content(monkeypatch, last_character): + client = EmbeddingClient(model="test-model", api_key="test-key", base_url="http://127.0.0.1:12345/v1") + text = "abcdefghijklmnopqrst" + last_character + expected_chunks = [text[:12], text[8:20]] + if last_character: + expected_chunks.append(text[16:]) + observed = [] + + def embed(chunks): + observed.extend(chunks) + return [[1.0, 0.0] if chunk == text[:12] else [0.0, 1.0] for chunk in chunks] + + monkeypatch.setattr(client, "embed", embed) + + vector = client.embed_chunked(text, chunk_size=3, overlap=1) + + assert observed == expected_chunks + count = len(expected_chunks) + assert vector == pytest.approx([1 / count, (count - 1) / count]) From ad5c90144e4d866e0b33bdaf3f7e25d95c152afa Mon Sep 17 00:00:00 2001 From: Afloat Date: Tue, 17 Nov 2026 15:44:33 +0800 Subject: [PATCH 2/3] Keep the embedding changelog entry in the Fixed list Signed-off-by: Afloat --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1bb5af8d..1252ba5bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -441,7 +441,6 @@ All notable changes to SkillEvaluator are documented in this file. - Full-body embeddings stop once a chunk covers the document end, avoiding extra embedding inputs and pooled weight for already-covered tails. Rebuild saved full-body catalogs to use the corrected pooling. - - Direct Tier 1 validates the target, selected checks and LLM configuration before preparing scanners, so configuration errors do not trigger downloads or stdout noise. - Documentation-only CI follows imports through collected test modules and From b07b90f10475ebbf135f456fe0a5ed275b95ee86 Mon Sep 17 00:00:00 2001 From: Afloat Date: Wed, 18 Nov 2026 12:25:24 +0800 Subject: [PATCH 3/3] docs: clarify per-section embedding window tails Describe window termination for each long section and retain the saved-catalog rebuild guidance requested in review. Signed-off-by: Afloat --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ada958f8..9e3236fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,9 @@ All notable changes to SkillEvaluator are documented in this file. ### Fixed -- Full-body embeddings stop once a chunk covers the document end, avoiding extra - embedding inputs and pooled weight for already-covered tails. Rebuild saved - full-body catalogs to use the corrected pooling. +- Full-body embeddings stop windowing a long section once a window reaches its end, + avoiding extra embedding inputs and pooled weight for already-covered tails. + Rebuild saved full-body catalogs to use the corrected pooling. - Allow GitHub all-tier CI to opt out of deployment records while retaining environment secrets. Existing consumers keep deployment tracking by default. - Point the PyPI Documentation link at the NVIDIA documentation instead of the GitHub