model2vec 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
model2vec/model.py CHANGED
@@ -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>
@@ -1,5 +1,5 @@
1
1
  model2vec/__init__.py,sha256=H2Tjvc5jvBNMNKsk4nYdrvDZeeLL__nog7bcM6r5ppw,116
2
- model2vec/model.py,sha256=tOiOo6BFo9fmOdzSlhEE2ElGuhT0kWL92X55VnsEKc8,8477
2
+ model2vec/model.py,sha256=fxqd0_pz4ahWtn4idgG_q61QyzKqqC0QcaOGu6XeHu4,8721
3
3
  model2vec/model_card_template.md,sha256=rQo4bE3VPXH3XB9OUCe7FCenhBc4wv6L1sNURVT4Sro,2747
4
4
  model2vec/utils.py,sha256=gS4-_Lno3iDG0k1B1tbcAhqyINZeTOFDJ6gP46YPkTc,8227
5
5
  model2vec/distill/__init__.py,sha256=1WLSMhxifoTSpIPb-drmP4sHdroc5jHo1fTISzqP6Hg,70
@@ -7,8 +7,8 @@ model2vec/distill/__main__.py,sha256=syBzxZz1zQi3UUD7KQAM0wG0W9oqHcKlAT5RX92tn0A
7
7
  model2vec/distill/distillation.py,sha256=vQLDbgD4Si5dGK1V2LaGmTVbhHb4ALuzgmkj87-u8HY,7918
8
8
  model2vec/distill/inference.py,sha256=A-13qdkffeF5S__a0rTHx_O7n0iZQeyOwT3z9zqdQi0,4639
9
9
  model2vec/distill/tokenizer.py,sha256=-3fWtHp_Fs41uqf3TWGHAxLoyEfSbnXsCeKcz6mQTP4,2751
10
- model2vec-0.2.0.dist-info/LICENSE,sha256=sCFPFI7OrnOfkWIJ54z-FXEsS4EMi8nUS2wtHRYWqrY,1074
11
- model2vec-0.2.0.dist-info/METADATA,sha256=MO-_ODvW5C1PtSmxVfu4f8uqw8wEGF1NXsCCJGWjv5M,19251
12
- model2vec-0.2.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
13
- model2vec-0.2.0.dist-info/top_level.txt,sha256=cprhxJcbtkFiydp0BGvdCVNupTWg07-3p93jFStc78g,10
14
- model2vec-0.2.0.dist-info/RECORD,,
10
+ model2vec-0.2.1.dist-info/LICENSE,sha256=sCFPFI7OrnOfkWIJ54z-FXEsS4EMi8nUS2wtHRYWqrY,1074
11
+ model2vec-0.2.1.dist-info/METADATA,sha256=x_y5e33PjybvEGP_7rQ5KwdA4Xoknm0y9w1Ob0oO8tw,19435
12
+ model2vec-0.2.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
13
+ model2vec-0.2.1.dist-info/top_level.txt,sha256=cprhxJcbtkFiydp0BGvdCVNupTWg07-3p93jFStc78g,10
14
+ model2vec-0.2.1.dist-info/RECORD,,