model2vec 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {model2vec-0.2.0 → model2vec-0.2.1}/PKG-INFO +5 -1
  2. {model2vec-0.2.0 → model2vec-0.2.1}/README.md +4 -0
  3. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/model.py +5 -0
  4. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec.egg-info/PKG-INFO +5 -1
  5. {model2vec-0.2.0 → model2vec-0.2.1}/pyproject.toml +1 -1
  6. {model2vec-0.2.0 → model2vec-0.2.1}/.github/workflows/ci.yaml +0 -0
  7. {model2vec-0.2.0 → model2vec-0.2.1}/.gitignore +0 -0
  8. {model2vec-0.2.0 → model2vec-0.2.1}/.pre-commit-config.yaml +0 -0
  9. {model2vec-0.2.0 → model2vec-0.2.1}/LICENSE +0 -0
  10. {model2vec-0.2.0 → model2vec-0.2.1}/Makefile +0 -0
  11. {model2vec-0.2.0 → model2vec-0.2.1}/assets/images/logo.png +0 -0
  12. {model2vec-0.2.0 → model2vec-0.2.1}/assets/images/model2vec_model_diagram.png +0 -0
  13. {model2vec-0.2.0 → model2vec-0.2.1}/assets/images/sentences_per_second_vs_average_score.png +0 -0
  14. {model2vec-0.2.0 → model2vec-0.2.1}/assets/images/speed_vs_accuracy.png +0 -0
  15. {model2vec-0.2.0 → model2vec-0.2.1}/assets/images/tutorial_ezlo.png +0 -0
  16. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/__init__.py +0 -0
  17. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/distill/__init__.py +0 -0
  18. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/distill/__main__.py +0 -0
  19. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/distill/distillation.py +0 -0
  20. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/distill/inference.py +0 -0
  21. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/distill/tokenizer.py +0 -0
  22. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/model_card_template.md +0 -0
  23. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec/utils.py +0 -0
  24. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec.egg-info/SOURCES.txt +0 -0
  25. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec.egg-info/dependency_links.txt +0 -0
  26. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec.egg-info/requires.txt +0 -0
  27. {model2vec-0.2.0 → model2vec-0.2.1}/model2vec.egg-info/top_level.txt +0 -0
  28. {model2vec-0.2.0 → model2vec-0.2.1}/setup.cfg +0 -0
  29. {model2vec-0.2.0 → model2vec-0.2.1}/tests/__init__.py +0 -0
  30. {model2vec-0.2.0 → model2vec-0.2.1}/tests/conftest.py +0 -0
  31. {model2vec-0.2.0 → model2vec-0.2.1}/tests/data/test_tokenizer/special_tokens_map.json +0 -0
  32. {model2vec-0.2.0 → model2vec-0.2.1}/tests/data/test_tokenizer/tokenizer.json +0 -0
  33. {model2vec-0.2.0 → model2vec-0.2.1}/tests/data/test_tokenizer/tokenizer_config.json +0 -0
  34. {model2vec-0.2.0 → model2vec-0.2.1}/tests/test_distillation.py +0 -0
  35. {model2vec-0.2.0 → model2vec-0.2.1}/tests/test_model.py +0 -0
  36. {model2vec-0.2.0 → model2vec-0.2.1}/tests/test_utils.py +0 -0
  37. {model2vec-0.2.0 → model2vec-0.2.1}/tutorials/README.md +0 -0
  38. {model2vec-0.2.0 → model2vec-0.2.1}/tutorials/recipe_search.ipynb +0 -0
  39. {model2vec-0.2.0 → model2vec-0.2.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: model2vec
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Distill a Small Fast Model from any Sentence Transformer
5
5
  Author-email: Stéphan Tulkens <stephantul@gmail.com>, Thomas van Dongen <thomas123@live.nl>
6
6
  License: MIT License
@@ -87,6 +87,10 @@ Requires-Dist: ruff; extra == "dev"
87
87
  <a href="https://pypi.org/project/model2vec/"><img src="https://img.shields.io/pypi/pyversions/model2vec" alt="Supported Python versions"></a>
88
88
  <a href="https://pepy.tech/project/model2vec">
89
89
  <img src="https://static.pepy.tech/badge/model2vec" alt="Downloads">
90
+ </a>
91
+ <a href="https://app.codecov.io/gh/MinishLab/model2vec">
92
+ <img src="https://codecov.io/gh/MinishLab/model2vec/graph/badge.svg?token=21TWJ6B5ET" alt="Codecov">
93
+ </a>
90
94
  </a>
91
95
  <a href="https://github.com/MinishLab/model2vec/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License - MIT"></a>
92
96
  </h2>
@@ -24,6 +24,10 @@
24
24
  <a href="https://pypi.org/project/model2vec/"><img src="https://img.shields.io/pypi/pyversions/model2vec" alt="Supported Python versions"></a>
25
25
  <a href="https://pepy.tech/project/model2vec">
26
26
  <img src="https://static.pepy.tech/badge/model2vec" alt="Downloads">
27
+ </a>
28
+ <a href="https://app.codecov.io/gh/MinishLab/model2vec">
29
+ <img src="https://codecov.io/gh/MinishLab/model2vec/graph/badge.svg?token=21TWJ6B5ET" alt="Codecov">
30
+ </a>
27
31
  </a>
28
32
  <a href="https://github.com/MinishLab/model2vec/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License - MIT"></a>
29
33
  </h2>
@@ -56,6 +56,7 @@ class StaticModel(nn.Module):
56
56
  else:
57
57
  self.unk_token_id = None
58
58
 
59
+ self.median_token_length = int(np.median([len(token) for token in self.tokens]))
59
60
  self.config = config
60
61
  self.base_model_name = base_model_name
61
62
  self.language = language
@@ -123,6 +124,10 @@ class StaticModel(nn.Module):
123
124
  :param max_length: The maximum length of the sentence.
124
125
  :return: The tokens.
125
126
  """
127
+ if max_length is not None:
128
+ m = max_length * self.median_token_length
129
+ sentences = [sentence[:m] for sentence in sentences]
130
+
126
131
  encodings: list[Encoding] = self.tokenizer.encode_batch(sentences, add_special_tokens=False)
127
132
  encodings_ids = [encoding.ids for encoding in encodings]
128
133
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: model2vec
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Distill a Small Fast Model from any Sentence Transformer
5
5
  Author-email: Stéphan Tulkens <stephantul@gmail.com>, Thomas van Dongen <thomas123@live.nl>
6
6
  License: MIT License
@@ -87,6 +87,10 @@ Requires-Dist: ruff; extra == "dev"
87
87
  <a href="https://pypi.org/project/model2vec/"><img src="https://img.shields.io/pypi/pyversions/model2vec" alt="Supported Python versions"></a>
88
88
  <a href="https://pepy.tech/project/model2vec">
89
89
  <img src="https://static.pepy.tech/badge/model2vec" alt="Downloads">
90
+ </a>
91
+ <a href="https://app.codecov.io/gh/MinishLab/model2vec">
92
+ <img src="https://codecov.io/gh/MinishLab/model2vec/graph/badge.svg?token=21TWJ6B5ET" alt="Codecov">
93
+ </a>
90
94
  </a>
91
95
  <a href="https://github.com/MinishLab/model2vec/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License - MIT"></a>
92
96
  </h2>
@@ -3,7 +3,7 @@ name = "model2vec"
3
3
  description = "Distill a Small Fast Model from any Sentence Transformer"
4
4
  readme = { file = "README.md", content-type = "text/markdown" }
5
5
  license = { file = "LICENSE" }
6
- version = "0.2.0"
6
+ version = "0.2.1"
7
7
  requires-python = ">=3.10"
8
8
  authors = [{ name = "Stéphan Tulkens", email = "stephantul@gmail.com"}, {name = "Thomas van Dongen", email = "thomas123@live.nl"}]
9
9
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes