Skip to content

feat: max length behavior - #363

Merged
stephantul merged 8 commits into
mainfrom
max-length-behavior
Sep 11, 2026
Merged

feat: max length behavior#363
stephantul merged 8 commits into
mainfrom
max-length-behavior

Conversation

@stephantul

Copy link
Copy Markdown
Contributor

This PR changes the max length behavior so that truncations built into tokenizers are respected and overridden.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
model2vec/model.py 97.57% <100.00%> (+0.16%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/test_model.py

def test_initialize_normalize(mock_vectors: np.ndarray, mock_tokenizer: Tokenizer) -> None:
"""Tests whether the normalization initialization is correct."""
model = StaticModel(mock_vectors, mock_tokenizer, {}, normalize=None)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

stale thing, normalize was never allowed to be None

@Pringled Pringled left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Just two questions

Comment thread model2vec/model.py
force_download=force_download,
)

def _set_max_length_in_tokenizer(self, max_length: int | None) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we also need to check for padding as well, or just truncation?

Comment thread model2vec/model.py
def encode_as_sequence(
self,
sentences: str,
max_length: int | None = None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Part of a major release right? Otherwise we should probably deprecate this first with a warning

@stephantul
stephantul merged commit 7c04ce4 into main Sep 11, 2026
11 checks passed
@stephantul
stephantul deleted the max-length-behavior branch September 11, 2026 13:57
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.

2 participants