Skip to content

feat: make setters for max_length - #356

Open
stephantul wants to merge 5 commits into
mainfrom
allow-setters
Open

feat: make setters for max_length#356
stephantul wants to merge 5 commits into
mainfrom
allow-setters

Conversation

@stephantul

@stephantul stephantul commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

This PR allows users to set max_length on the model2vec model object itself. When set to None, truncation is disabled as before. This setting is correctly stored on the model, like normalize. As before, it is still possible to override max_length from encode. When max_length is not specified, we set it to a default of 512. This ensures that old models still have the same behavior.

One new feature is that max_length is propagated to the pipeline and the training. These previously both used hardcoded constants of 512 (training) and a similar construct to the main StaticModel (pipeline). The end result is that users now have a central way to set max_length on their models, and that this setting is respected by all consumers.

I also turned the config we load into a TypedDict, and had to create a sentinel type to distinguish between max_length not being set and the user disabling max_length (None)

@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.40260% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
model2vec/onnx.py 75.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
model2vec/distill/distillation.py 94.52% <100.00%> (+0.07%) ⬆️
model2vec/inference/model.py 100.00% <100.00%> (ø)
model2vec/model.py 97.39% <100.00%> (+1.74%) ⬆️
model2vec/persistence/persistence.py 98.73% <100.00%> (+0.01%) ⬆️
model2vec/train/base.py 97.97% <100.00%> (+0.06%) ⬆️
model2vec/train/classifier.py 98.33% <100.00%> (+0.01%) ⬆️
model2vec/train/similarity.py 100.00% <100.00%> (ø)
model2vec/types.py 100.00% <100.00%> (ø)
model2vec/onnx.py 97.03% <75.00%> (-1.45%) ⬇️
🚀 新建 features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stephantul
stephantul requested a review from Pringled August 30, 2026 05:26
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

1 participant