Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ All notable changes to SkillEvaluator are documented in this file.

- Malformed optional trajectory `final_metrics` leave condition usage unavailable
and no longer abort fresh or reused Tier 3 result collection.
- 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
Expand Down
2 changes: 2 additions & 0 deletions src/skillevaluator/embedding/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
54 changes: 54 additions & 0 deletions tests/embedding/test_chunk_tail_coverage.py
Original file line number Diff line number Diff line change
@@ -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])
Loading