model2vec 0.6.0__tar.gz → 0.8.0__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.
- {model2vec-0.6.0 → model2vec-0.8.0}/.github/workflows/ci.yaml +7 -23
- {model2vec-0.6.0 → model2vec-0.8.0}/.pre-commit-config.yaml +1 -1
- model2vec-0.8.0/CITATION.cff +27 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/Makefile +0 -1
- {model2vec-0.6.0 → model2vec-0.8.0}/PKG-INFO +38 -36
- {model2vec-0.6.0 → model2vec-0.8.0}/README.md +31 -30
- model2vec-0.8.0/assets/images/model2vec_logo.png +0 -0
- model2vec-0.8.0/assets/images/speed_vs_mteb_plot.png +0 -0
- model2vec-0.8.0/docs/README.md +8 -0
- model2vec-0.8.0/model2vec/__init__.py +4 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/distill/distillation.py +95 -90
- model2vec-0.8.0/model2vec/distill/inference.py +253 -0
- model2vec-0.8.0/model2vec/distill/utils.py +49 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/inference/model.py +21 -14
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/model.py +180 -83
- model2vec-0.8.0/model2vec/modelcards/__init__.py +3 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/modelcards/classifier_template.md +9 -7
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/modelcards/model_card_template.md +9 -7
- model2vec-0.8.0/model2vec/modelcards/modelcards.py +56 -0
- model2vec-0.8.0/model2vec/persistence/__init__.py +4 -0
- model2vec-0.8.0/model2vec/persistence/datamodels.py +50 -0
- model2vec-0.8.0/model2vec/persistence/hf.py +57 -0
- model2vec-0.8.0/model2vec/persistence/persistence.py +162 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/quantization.py +29 -7
- model2vec-0.8.0/model2vec/tokenizer/__init__.py +10 -0
- model2vec-0.8.0/model2vec/tokenizer/tokenizer.py +98 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/train/README.md +1 -1
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/train/base.py +48 -11
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/train/classifier.py +67 -27
- model2vec-0.8.0/model2vec/train/utils.py +21 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/utils.py +2 -30
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/version.py +1 -1
- model2vec-0.8.0/model2vec/vocabulary_quantization.py +45 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec.egg-info/PKG-INFO +38 -36
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec.egg-info/SOURCES.txt +11 -20
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec.egg-info/requires.txt +5 -1
- {model2vec-0.6.0 → model2vec-0.8.0}/pyproject.toml +8 -4
- {model2vec-0.6.0 → model2vec-0.8.0}/results/README.md +22 -26
- {model2vec-0.6.0 → model2vec-0.8.0}/results/make_speed_vs_mteb_plot.py +49 -47
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/conftest.py +73 -21
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/test_distillation.py +145 -91
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/test_model.py +47 -27
- model2vec-0.8.0/tests/test_persistence.py +88 -0
- model2vec-0.8.0/tests/test_quantization.py +76 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/test_trainable.py +70 -2
- model2vec-0.8.0/tests/test_utils.py +84 -0
- model2vec-0.8.0/uv.lock +2674 -0
- model2vec-0.6.0/assets/images/logo.png +0 -0
- model2vec-0.6.0/assets/images/logo_v2.png +0 -0
- model2vec-0.6.0/assets/images/model2vec_model_diagram.png +0 -0
- model2vec-0.6.0/assets/images/model2vec_model_diagram_transparant_dark.png +0 -0
- model2vec-0.6.0/assets/images/model2vec_model_diagram_transparant_light.png +0 -0
- model2vec-0.6.0/assets/images/sentences_per_second_vs_average_score.png +0 -0
- model2vec-0.6.0/assets/images/speed_vs_accuracy.png +0 -0
- model2vec-0.6.0/assets/images/speed_vs_accuracy_v2.png +0 -0
- model2vec-0.6.0/assets/images/speed_vs_accuracy_v3.png +0 -0
- model2vec-0.6.0/assets/images/speed_vs_accuracy_v4.png +0 -0
- model2vec-0.6.0/assets/images/speed_vs_mteb_score.png +0 -0
- model2vec-0.6.0/assets/images/speed_vs_mteb_score_v2.png +0 -0
- model2vec-0.6.0/docs/README.md +0 -6
- model2vec-0.6.0/docs/integrations.md +0 -155
- model2vec-0.6.0/docs/usage.md +0 -250
- model2vec-0.6.0/docs/what_is_model2vec.md +0 -11
- model2vec-0.6.0/model2vec/__init__.py +0 -4
- model2vec-0.6.0/model2vec/distill/inference.py +0 -158
- model2vec-0.6.0/model2vec/distill/utils.py +0 -28
- model2vec-0.6.0/model2vec/hf_utils.py +0 -225
- model2vec-0.6.0/model2vec/tokenizer/__init__.py +0 -12
- model2vec-0.6.0/model2vec/tokenizer/datamodels.py +0 -14
- model2vec-0.6.0/model2vec/tokenizer/model.py +0 -43
- model2vec-0.6.0/model2vec/tokenizer/normalizer.py +0 -42
- model2vec-0.6.0/model2vec/tokenizer/pretokenizer.py +0 -57
- model2vec-0.6.0/model2vec/tokenizer/tokenizer.py +0 -395
- model2vec-0.6.0/tests/test_quantization.py +0 -30
- model2vec-0.6.0/tests/test_tokenizer.py +0 -123
- model2vec-0.6.0/tests/test_utils.py +0 -121
- model2vec-0.6.0/uv.lock +0 -2553
- {model2vec-0.6.0 → model2vec-0.8.0}/.gitignore +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/LICENSE +0 -0
- /model2vec-0.6.0/assets/images/model2vec_logo.png → /model2vec-0.8.0/assets/images/logo_v2.png +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/assets/images/speed_vs_mteb_score_v3.png +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/assets/images/training_speed_vs_score.png +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/assets/images/tutorial_ezlo.png +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/distill/__init__.py +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/inference/README.md +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/inference/__init__.py +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/py.typed +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec/train/__init__.py +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec.egg-info/dependency_links.txt +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/model2vec.egg-info/top_level.txt +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/scripts/export_to_onnx.py +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/setup.cfg +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/__init__.py +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/data/test_tokenizer/special_tokens_map.json +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/data/test_tokenizer/tokenizer.json +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/data/test_tokenizer/tokenizer_config.json +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tests/test_inference.py +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tutorials/README.md +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tutorials/recipe_search.ipynb +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tutorials/semantic_chunking.ipynb +0 -0
- {model2vec-0.6.0 → model2vec-0.8.0}/tutorials/train_classifier.ipynb +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
name: Run tests and upload coverage
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
push
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
5
8
|
|
|
6
9
|
jobs:
|
|
7
10
|
test:
|
|
@@ -9,15 +12,8 @@ jobs:
|
|
|
9
12
|
runs-on: ${{ matrix.os }}
|
|
10
13
|
strategy:
|
|
11
14
|
matrix:
|
|
12
|
-
os: ["ubuntu-latest"
|
|
13
|
-
python-version: ["3.
|
|
14
|
-
exclude:
|
|
15
|
-
- os: windows-latest
|
|
16
|
-
python-version: "3.9"
|
|
17
|
-
- os: windows-latest
|
|
18
|
-
python-version: "3.11"
|
|
19
|
-
- os: windows-latest
|
|
20
|
-
python-version: "3.12"
|
|
15
|
+
os: ["ubuntu-latest"]
|
|
16
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
21
17
|
fail-fast: false
|
|
22
18
|
|
|
23
19
|
steps:
|
|
@@ -29,19 +25,7 @@ jobs:
|
|
|
29
25
|
python-version: ${{ matrix.python-version }}
|
|
30
26
|
allow-prereleases: true
|
|
31
27
|
|
|
32
|
-
# Step for Windows: Create and activate a virtual environment
|
|
33
|
-
- name: Create and activate a virtual environment (Windows)
|
|
34
|
-
if: ${{ runner.os == 'Windows' }}
|
|
35
|
-
run: |
|
|
36
|
-
irm https://astral.sh/uv/install.ps1 | iex
|
|
37
|
-
$env:Path = "C:\Users\runneradmin\.local\bin;$env:Path"
|
|
38
|
-
uv venv .venv
|
|
39
|
-
"VIRTUAL_ENV=.venv" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
40
|
-
"$PWD/.venv/Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append
|
|
41
|
-
|
|
42
|
-
# Step for Unix: Create and activate a virtual environment
|
|
43
28
|
- name: Create and activate a virtual environment (Unix)
|
|
44
|
-
if: ${{ runner.os != 'Windows' }}
|
|
45
29
|
run: |
|
|
46
30
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
47
31
|
uv venv .venv
|
|
@@ -55,7 +39,7 @@ jobs:
|
|
|
55
39
|
# Run tests with coverage
|
|
56
40
|
- name: Run tests under coverage
|
|
57
41
|
run: |
|
|
58
|
-
coverage run -m pytest
|
|
42
|
+
coverage run --source=model2vec -m pytest
|
|
59
43
|
coverage report
|
|
60
44
|
|
|
61
45
|
# Upload results to Codecov
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use Model2Vec in your research, please cite it as below."
|
|
3
|
+
title: "Model2Vec: Fast State-of-the-Art Static Embeddings"
|
|
4
|
+
authors:
|
|
5
|
+
- family-names: "Tulkens"
|
|
6
|
+
given-names: "Stephan"
|
|
7
|
+
- family-names: "van Dongen"
|
|
8
|
+
given-names: "Thomas"
|
|
9
|
+
doi: 10.5281/zenodo.17270888
|
|
10
|
+
license: MIT
|
|
11
|
+
url: "https://github.com/MinishLab/model2vec"
|
|
12
|
+
repository-code: "https://github.com/MinishLab/model2vec"
|
|
13
|
+
date-released: "2024-09-20"
|
|
14
|
+
|
|
15
|
+
preferred-citation:
|
|
16
|
+
type: software
|
|
17
|
+
title: "Model2Vec: Fast State-of-the-Art Static Embeddings"
|
|
18
|
+
authors:
|
|
19
|
+
- family-names: "Tulkens"
|
|
20
|
+
given-names: "Stephan"
|
|
21
|
+
- family-names: "van Dongen"
|
|
22
|
+
given-names: "Thomas"
|
|
23
|
+
year: 2024
|
|
24
|
+
publisher: Zenodo
|
|
25
|
+
doi: 10.5281/zenodo.17270888
|
|
26
|
+
url: "https://github.com/MinishLab/model2vec"
|
|
27
|
+
license: MIT
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: model2vec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Fast State-of-the-Art Static Embeddings
|
|
5
5
|
Author-email: Stéphan Tulkens <stephantul@gmail.com>, Thomas van Dongen <thomas123@live.nl>
|
|
6
6
|
License: MIT License
|
|
@@ -35,14 +35,13 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
35
35
|
Classifier: Topic :: Software Development :: Libraries
|
|
36
36
|
Classifier: License :: OSI Approved :: MIT License
|
|
37
37
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
38
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
39
38
|
Classifier: Programming Language :: Python :: 3.10
|
|
40
39
|
Classifier: Programming Language :: Python :: 3.11
|
|
41
40
|
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
42
|
Classifier: Natural Language :: English
|
|
43
|
-
Requires-Python: >=3.
|
|
43
|
+
Requires-Python: >=3.10
|
|
44
44
|
Description-Content-Type: text/markdown
|
|
45
|
-
License-File: LICENSE
|
|
46
45
|
Requires-Dist: jinja2
|
|
47
46
|
Requires-Dist: joblib
|
|
48
47
|
Requires-Dist: numpy
|
|
@@ -61,8 +60,9 @@ Requires-Dist: pytest-cov; extra == "dev"
|
|
|
61
60
|
Requires-Dist: ruff; extra == "dev"
|
|
62
61
|
Provides-Extra: distill
|
|
63
62
|
Requires-Dist: torch; extra == "distill"
|
|
64
|
-
Requires-Dist: transformers
|
|
63
|
+
Requires-Dist: transformers; extra == "distill"
|
|
65
64
|
Requires-Dist: scikit-learn; extra == "distill"
|
|
65
|
+
Requires-Dist: skeletoken>=0.3.2; extra == "distill"
|
|
66
66
|
Provides-Extra: onnx
|
|
67
67
|
Requires-Dist: onnx; extra == "onnx"
|
|
68
68
|
Requires-Dist: torch; extra == "onnx"
|
|
@@ -76,7 +76,8 @@ Requires-Dist: scikit-learn; extra == "inference"
|
|
|
76
76
|
Requires-Dist: skops; extra == "inference"
|
|
77
77
|
Provides-Extra: tokenizer
|
|
78
78
|
Requires-Dist: transformers; extra == "tokenizer"
|
|
79
|
-
|
|
79
|
+
Provides-Extra: quantization
|
|
80
|
+
Requires-Dist: scikit-learn; extra == "quantization"
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
<h2 align="center">
|
|
@@ -89,17 +90,16 @@ Dynamic: license-file
|
|
|
89
90
|
<div align="center">
|
|
90
91
|
<h2>
|
|
91
92
|
<a href="https://huggingface.co/minishlab"><strong>🤗 Models</strong></a> |
|
|
92
|
-
<a href="https://
|
|
93
|
-
<a href="https://minishlab.github.io/"><strong>🌐 Blog</strong></a> |
|
|
93
|
+
<a href="https://minish.ai/packages/model2vec/introduction"><strong>📖 Docs</strong></a> |
|
|
94
94
|
<a href="https://github.com/MinishLab/model2vec/blob/main/results/README.md"><strong>🏆 Results</strong></a> |
|
|
95
|
-
<a href="https://github.com/MinishLab/model2vec/
|
|
96
|
-
|
|
95
|
+
<a href="https://github.com/MinishLab/model2vec/tree/main/tutorials"><strong>📚 Tutorials</strong></a> |
|
|
96
|
+
<a href="https://minish.ai/blog"><strong>🌐 Blog</strong></a>
|
|
97
97
|
</div>
|
|
98
98
|
|
|
99
99
|
<div align="center">
|
|
100
100
|
<h2>
|
|
101
101
|
<a href="https://pypi.org/project/model2vec/"><img src="https://img.shields.io/pypi/v/model2vec?color=%23007ec6&label=pypi%20package" alt="Package version"></a>
|
|
102
|
-
<a href="https://
|
|
102
|
+
<a href="https://minish.ai/packages/model2vec/introduction"><img src="https://img.shields.io/badge/docs-minish.ai-blue.svg" alt="Docs"></a>
|
|
103
103
|
<a href="https://pepy.tech/project/model2vec">
|
|
104
104
|
<img src="https://static.pepy.tech/badge/model2vec" alt="Downloads">
|
|
105
105
|
</a>
|
|
@@ -112,6 +112,9 @@ Dynamic: license-file
|
|
|
112
112
|
<a href="https://github.com/MinishLab/model2vec/blob/main/LICENSE">
|
|
113
113
|
<img src="https://img.shields.io/badge/license-MIT-green" alt="License - MIT">
|
|
114
114
|
</a>
|
|
115
|
+
<a href="https://github.com/MinishLab/model2vec/stargazers">
|
|
116
|
+
<img src="https://img.shields.io/github/stars/minishlab/model2vec.svg" alt=Stars">
|
|
117
|
+
</a>
|
|
115
118
|
</h2>
|
|
116
119
|
</div>
|
|
117
120
|
|
|
@@ -119,7 +122,7 @@ Dynamic: license-file
|
|
|
119
122
|
|
|
120
123
|
|
|
121
124
|
|
|
122
|
-
Model2Vec is a technique to turn any sentence transformer into a
|
|
125
|
+
Model2Vec is a technique to turn any sentence transformer into a small, fast static embedding model. Model2Vec reduces model size by a factor up to 50 and makes models up to 500 times faster, with a small drop in performance. Our [best model](https://huggingface.co/minishlab/potion-base-32M) is the most performant static embedding model in the world. See our [results](results/README.md), read our [docs](https://minish.ai/packages/model2vec/introduction), or dive in to see how it works.
|
|
123
126
|
|
|
124
127
|
<div align="center">
|
|
125
128
|
<h3>
|
|
@@ -140,8 +143,8 @@ You can start using Model2Vec by loading one of our [flagship models from the Hu
|
|
|
140
143
|
```python
|
|
141
144
|
from model2vec import StaticModel
|
|
142
145
|
|
|
143
|
-
# Load a model from the HuggingFace hub (in this case the potion-base-
|
|
144
|
-
model = StaticModel.from_pretrained("minishlab/potion-base-
|
|
146
|
+
# Load a model from the HuggingFace hub (in this case the potion-base-32M model)
|
|
147
|
+
model = StaticModel.from_pretrained("minishlab/potion-base-32M")
|
|
145
148
|
|
|
146
149
|
# Make embeddings
|
|
147
150
|
embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."])
|
|
@@ -149,30 +152,29 @@ embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to ever
|
|
|
149
152
|
# Make sequences of token embeddings
|
|
150
153
|
token_embeddings = model.encode_as_sequence(["It's dangerous to go alone!", "It's a secret to everybody."])
|
|
151
154
|
```
|
|
152
|
-
|
|
153
|
-
Instead of using one of our models, you can also distill your own Model2Vec model from a Sentence Transformer model. First, install the `distillation` extras with:
|
|
155
|
+
For advanced usage, see our [inference docs](https://minish.ai/packages/model2vec/inference). Instead of using one of our models, you can also distill your own Model2Vec model from a Sentence Transformer model. First, install the `distillation` extras with:
|
|
154
156
|
|
|
155
157
|
```bash
|
|
156
158
|
pip install model2vec[distill]
|
|
157
159
|
```
|
|
158
160
|
|
|
159
161
|
|
|
160
|
-
|
|
162
|
+
Then, you can distill a model in ~30 seconds on a CPU with the following code snippet:
|
|
161
163
|
|
|
162
164
|
```python
|
|
163
165
|
from model2vec.distill import distill
|
|
164
166
|
|
|
165
167
|
# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
|
|
166
|
-
m2v_model = distill(model_name="BAAI/bge-base-en-v1.5"
|
|
168
|
+
m2v_model = distill(model_name="BAAI/bge-base-en-v1.5")
|
|
167
169
|
|
|
168
170
|
# Save the model
|
|
169
171
|
m2v_model.save_pretrained("m2v_model")
|
|
170
172
|
```
|
|
171
173
|
|
|
172
|
-
After distillation, you can also fine-tune your own classification models on top of the distilled model, or on a pre-trained model. First, make sure you install the `training` extras with:
|
|
174
|
+
For advanced usage, see our [distillation docs](https://minish.ai/packages/model2vec/distillation), which includes some [distillation best practices](https://minish.ai/packages/model2vec/distillation#distillation-best-practices). After distillation, you can also fine-tune your own classification models on top of the distilled model, or on a pre-trained model. First, make sure you install the `training` extras with:
|
|
173
175
|
|
|
174
176
|
```bash
|
|
175
|
-
pip install model2vec[
|
|
177
|
+
pip install model2vec[train]
|
|
176
178
|
```
|
|
177
179
|
|
|
178
180
|
Then, you can fine-tune a model as follows:
|
|
@@ -195,13 +197,13 @@ classifier.fit(ds["train"]["text"], ds["train"]["label"])
|
|
|
195
197
|
classification_report = classifier.evaluate(ds["test"]["text"], ds["test"]["label"])
|
|
196
198
|
```
|
|
197
199
|
|
|
198
|
-
For advanced usage,
|
|
200
|
+
For advanced usage, see our [training docs](https://minish.ai/packages/model2vec/training).
|
|
199
201
|
|
|
200
202
|
## Updates & Announcements
|
|
201
203
|
|
|
202
204
|
- **23/05/2025**: We released [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M), a multilingual model trained on 101 languages. It is the best performing static embedding model for multilingual tasks, and is capable of generating embeddings for any text in any language. The results can be found in our [results](results/README.md#mmteb-results-multilingual) section.
|
|
203
205
|
|
|
204
|
-
- **01/05/2025**: We released backend support for `BPE` and `Unigram` tokenizers, along with quantization and dimensionality reduction. New Model2Vec models are now 50% of the original models, and can be quantized to int8 to be 25% of the size, without loss of performance.
|
|
206
|
+
- **01/05/2025**: We released backend support for `BPE` and `Unigram` tokenizers, along with quantization and dimensionality reduction. New Model2Vec models are now 50% of the original models size, and can be quantized to int8 to be 25% of the size, without loss of performance.
|
|
205
207
|
|
|
206
208
|
- **12/02/2025**: We released **Model2Vec training**, allowing you to fine-tune your own classification models on top of Model2Vec models. Find out more in our [training documentation](https://github.com/MinishLab/model2vec/blob/main/model2vec/train/README.md) and [results](results/README.md#training-results).
|
|
207
209
|
|
|
@@ -217,24 +219,18 @@ For advanced usage, please refer to our [usage documentation](https://github.com
|
|
|
217
219
|
- **Lightning-fast Inference**: up to 500 times faster on CPU than the original model.
|
|
218
220
|
- **Fast, Dataset-free Distillation**: distill your own model in 30 seconds on a CPU, without a dataset.
|
|
219
221
|
- **Fine-tuning**: fine-tune your own classification models on top of Model2Vec models.
|
|
220
|
-
- **Integrated in many popular libraries**: Model2Vec is integrated direclty into popular libraries such as [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) and [LangChain](https://github.com/langchain-ai/langchain). For more information, see our [integrations documentation](https://
|
|
222
|
+
- **Integrated in many popular libraries**: Model2Vec is integrated direclty into popular libraries such as [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) and [LangChain](https://github.com/langchain-ai/langchain). For more information, see our [integrations documentation](https://minish.ai/packages/model2vec/integrations).
|
|
221
223
|
- **Tightly integrated with HuggingFace hub**: easily share and load models from the HuggingFace hub, using the familiar `from_pretrained` and `push_to_hub`. Our own models can be found [here](https://huggingface.co/minishlab).
|
|
222
224
|
|
|
223
225
|
## What is Model2Vec?
|
|
224
226
|
|
|
225
227
|
Model2vec creates a small, fast, and powerful model that outperforms other static embedding models by a large margin on all tasks we could find, while being much faster to create than traditional static embedding models such as GloVe. Like BPEmb, it can create subword embeddings, but with much better performance. Distillation doesn't need _any_ data, just a vocabulary and a model.
|
|
226
228
|
|
|
227
|
-
The core idea is to forward pass a vocabulary through a sentence transformer model, creating static embeddings for the indiviudal tokens. After this, there are a number of post-processing steps we do that results in our best models. For a more extensive deepdive, please refer to
|
|
228
|
-
- Our initial [Model2Vec blog post](https://huggingface.co/blog/Pringled/model2vec). Note that, while this post gives a good overview of the core idea, we've made a number of substantial improvements since then.
|
|
229
|
-
- Our [Tokenlearn blog post](https://minishlab.github.io/tokenlearn_blogpost/). This post describes the Tokenlearn method we used to train our [potion models](https://huggingface.co/collections/minishlab/potion-6721e0abd4ea41881417f062).
|
|
230
|
-
- Our official [documentation](https://github.com/MinishLab/model2vec/blob/main/docs/what_is_model2vec.md). This document provides a high-level overview of how Model2Vec works.
|
|
229
|
+
The core idea is to forward pass a vocabulary through a sentence transformer model, creating static embeddings for the indiviudal tokens. After this, there are a number of post-processing steps we do that results in our best models, as well as an optional pre-training step to further boost performance. For a more extensive deepdive, please refer to our [official documentation on how Model2Vec works](https://minish.ai/packages/model2vec/introduction#how-mode2vec-works).
|
|
231
230
|
|
|
232
231
|
## Documentation
|
|
233
232
|
|
|
234
|
-
Our official documentation can be found [here](https://
|
|
235
|
-
- [Usage documentation](https://github.com/MinishLab/model2vec/blob/main/docs/usage.md): provides a technical overview of how to use Model2Vec.
|
|
236
|
-
- [Integrations documentation](https://github.com/MinishLab/model2vec/blob/main/docs/integrations.md): provides examples of how to use Model2Vec in various downstream libraries.
|
|
237
|
-
- [Model2Vec technical documentation](https://github.com/MinishLab/model2vec/blob/main/docs/what_is_model2vec.md): provides a high-level overview of how Model2Vec works.
|
|
233
|
+
Our official documentation can be found [here](https://minish.ai/packages/model2vec/introduction). This includes in-depth documentation on [inference](https://minish.ai/packages/model2vec/inference), [distillation](https://minish.ai/packages/model2vec/distillation), [training](https://minish.ai/packages/model2vec/training), and [integrations](https://minish.ai/packages/model2vec/integrations).
|
|
238
234
|
|
|
239
235
|
|
|
240
236
|
## Model List
|
|
@@ -259,6 +255,8 @@ We provide a number of models that can be used out of the box. These models are
|
|
|
259
255
|
|
|
260
256
|
We have performed extensive experiments to evaluate the performance of Model2Vec models. The results are documented in the [results](results/README.md) folder. The results are presented in the following sections:
|
|
261
257
|
- [MTEB Results](results/README.md#mteb-results)
|
|
258
|
+
- [MMTEB Results](results/README.md#mmteb-results)
|
|
259
|
+
- [Retrieval Results](results/README.md#retrieval-results)
|
|
262
260
|
- [Training Results](results/README.md#training-results)
|
|
263
261
|
- [Ablations](results/README.md#ablations)
|
|
264
262
|
|
|
@@ -269,11 +267,15 @@ MIT
|
|
|
269
267
|
## Citing
|
|
270
268
|
|
|
271
269
|
If you use Model2Vec in your research, please cite the following:
|
|
270
|
+
|
|
272
271
|
```bibtex
|
|
273
|
-
@
|
|
274
|
-
author
|
|
275
|
-
title
|
|
276
|
-
year
|
|
277
|
-
|
|
272
|
+
@software{minishlab2024model2vec,
|
|
273
|
+
author = {Stephan Tulkens and {van Dongen}, Thomas},
|
|
274
|
+
title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
|
|
275
|
+
year = {2024},
|
|
276
|
+
publisher = {Zenodo},
|
|
277
|
+
doi = {10.5281/zenodo.17270888},
|
|
278
|
+
url = {https://github.com/MinishLab/model2vec},
|
|
279
|
+
license = {MIT}
|
|
278
280
|
}
|
|
279
281
|
```
|
|
@@ -9,17 +9,16 @@
|
|
|
9
9
|
<div align="center">
|
|
10
10
|
<h2>
|
|
11
11
|
<a href="https://huggingface.co/minishlab"><strong>🤗 Models</strong></a> |
|
|
12
|
-
<a href="https://
|
|
13
|
-
<a href="https://minishlab.github.io/"><strong>🌐 Blog</strong></a> |
|
|
12
|
+
<a href="https://minish.ai/packages/model2vec/introduction"><strong>📖 Docs</strong></a> |
|
|
14
13
|
<a href="https://github.com/MinishLab/model2vec/blob/main/results/README.md"><strong>🏆 Results</strong></a> |
|
|
15
|
-
<a href="https://github.com/MinishLab/model2vec/
|
|
16
|
-
|
|
14
|
+
<a href="https://github.com/MinishLab/model2vec/tree/main/tutorials"><strong>📚 Tutorials</strong></a> |
|
|
15
|
+
<a href="https://minish.ai/blog"><strong>🌐 Blog</strong></a>
|
|
17
16
|
</div>
|
|
18
17
|
|
|
19
18
|
<div align="center">
|
|
20
19
|
<h2>
|
|
21
20
|
<a href="https://pypi.org/project/model2vec/"><img src="https://img.shields.io/pypi/v/model2vec?color=%23007ec6&label=pypi%20package" alt="Package version"></a>
|
|
22
|
-
<a href="https://
|
|
21
|
+
<a href="https://minish.ai/packages/model2vec/introduction"><img src="https://img.shields.io/badge/docs-minish.ai-blue.svg" alt="Docs"></a>
|
|
23
22
|
<a href="https://pepy.tech/project/model2vec">
|
|
24
23
|
<img src="https://static.pepy.tech/badge/model2vec" alt="Downloads">
|
|
25
24
|
</a>
|
|
@@ -32,6 +31,9 @@
|
|
|
32
31
|
<a href="https://github.com/MinishLab/model2vec/blob/main/LICENSE">
|
|
33
32
|
<img src="https://img.shields.io/badge/license-MIT-green" alt="License - MIT">
|
|
34
33
|
</a>
|
|
34
|
+
<a href="https://github.com/MinishLab/model2vec/stargazers">
|
|
35
|
+
<img src="https://img.shields.io/github/stars/minishlab/model2vec.svg" alt=Stars">
|
|
36
|
+
</a>
|
|
35
37
|
</h2>
|
|
36
38
|
</div>
|
|
37
39
|
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
|
|
40
42
|
|
|
41
43
|
|
|
42
|
-
Model2Vec is a technique to turn any sentence transformer into a
|
|
44
|
+
Model2Vec is a technique to turn any sentence transformer into a small, fast static embedding model. Model2Vec reduces model size by a factor up to 50 and makes models up to 500 times faster, with a small drop in performance. Our [best model](https://huggingface.co/minishlab/potion-base-32M) is the most performant static embedding model in the world. See our [results](results/README.md), read our [docs](https://minish.ai/packages/model2vec/introduction), or dive in to see how it works.
|
|
43
45
|
|
|
44
46
|
<div align="center">
|
|
45
47
|
<h3>
|
|
@@ -60,8 +62,8 @@ You can start using Model2Vec by loading one of our [flagship models from the Hu
|
|
|
60
62
|
```python
|
|
61
63
|
from model2vec import StaticModel
|
|
62
64
|
|
|
63
|
-
# Load a model from the HuggingFace hub (in this case the potion-base-
|
|
64
|
-
model = StaticModel.from_pretrained("minishlab/potion-base-
|
|
65
|
+
# Load a model from the HuggingFace hub (in this case the potion-base-32M model)
|
|
66
|
+
model = StaticModel.from_pretrained("minishlab/potion-base-32M")
|
|
65
67
|
|
|
66
68
|
# Make embeddings
|
|
67
69
|
embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."])
|
|
@@ -69,30 +71,29 @@ embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to ever
|
|
|
69
71
|
# Make sequences of token embeddings
|
|
70
72
|
token_embeddings = model.encode_as_sequence(["It's dangerous to go alone!", "It's a secret to everybody."])
|
|
71
73
|
```
|
|
72
|
-
|
|
73
|
-
Instead of using one of our models, you can also distill your own Model2Vec model from a Sentence Transformer model. First, install the `distillation` extras with:
|
|
74
|
+
For advanced usage, see our [inference docs](https://minish.ai/packages/model2vec/inference). Instead of using one of our models, you can also distill your own Model2Vec model from a Sentence Transformer model. First, install the `distillation` extras with:
|
|
74
75
|
|
|
75
76
|
```bash
|
|
76
77
|
pip install model2vec[distill]
|
|
77
78
|
```
|
|
78
79
|
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
Then, you can distill a model in ~30 seconds on a CPU with the following code snippet:
|
|
81
82
|
|
|
82
83
|
```python
|
|
83
84
|
from model2vec.distill import distill
|
|
84
85
|
|
|
85
86
|
# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
|
|
86
|
-
m2v_model = distill(model_name="BAAI/bge-base-en-v1.5"
|
|
87
|
+
m2v_model = distill(model_name="BAAI/bge-base-en-v1.5")
|
|
87
88
|
|
|
88
89
|
# Save the model
|
|
89
90
|
m2v_model.save_pretrained("m2v_model")
|
|
90
91
|
```
|
|
91
92
|
|
|
92
|
-
After distillation, you can also fine-tune your own classification models on top of the distilled model, or on a pre-trained model. First, make sure you install the `training` extras with:
|
|
93
|
+
For advanced usage, see our [distillation docs](https://minish.ai/packages/model2vec/distillation), which includes some [distillation best practices](https://minish.ai/packages/model2vec/distillation#distillation-best-practices). After distillation, you can also fine-tune your own classification models on top of the distilled model, or on a pre-trained model. First, make sure you install the `training` extras with:
|
|
93
94
|
|
|
94
95
|
```bash
|
|
95
|
-
pip install model2vec[
|
|
96
|
+
pip install model2vec[train]
|
|
96
97
|
```
|
|
97
98
|
|
|
98
99
|
Then, you can fine-tune a model as follows:
|
|
@@ -115,13 +116,13 @@ classifier.fit(ds["train"]["text"], ds["train"]["label"])
|
|
|
115
116
|
classification_report = classifier.evaluate(ds["test"]["text"], ds["test"]["label"])
|
|
116
117
|
```
|
|
117
118
|
|
|
118
|
-
For advanced usage,
|
|
119
|
+
For advanced usage, see our [training docs](https://minish.ai/packages/model2vec/training).
|
|
119
120
|
|
|
120
121
|
## Updates & Announcements
|
|
121
122
|
|
|
122
123
|
- **23/05/2025**: We released [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M), a multilingual model trained on 101 languages. It is the best performing static embedding model for multilingual tasks, and is capable of generating embeddings for any text in any language. The results can be found in our [results](results/README.md#mmteb-results-multilingual) section.
|
|
123
124
|
|
|
124
|
-
- **01/05/2025**: We released backend support for `BPE` and `Unigram` tokenizers, along with quantization and dimensionality reduction. New Model2Vec models are now 50% of the original models, and can be quantized to int8 to be 25% of the size, without loss of performance.
|
|
125
|
+
- **01/05/2025**: We released backend support for `BPE` and `Unigram` tokenizers, along with quantization and dimensionality reduction. New Model2Vec models are now 50% of the original models size, and can be quantized to int8 to be 25% of the size, without loss of performance.
|
|
125
126
|
|
|
126
127
|
- **12/02/2025**: We released **Model2Vec training**, allowing you to fine-tune your own classification models on top of Model2Vec models. Find out more in our [training documentation](https://github.com/MinishLab/model2vec/blob/main/model2vec/train/README.md) and [results](results/README.md#training-results).
|
|
127
128
|
|
|
@@ -137,24 +138,18 @@ For advanced usage, please refer to our [usage documentation](https://github.com
|
|
|
137
138
|
- **Lightning-fast Inference**: up to 500 times faster on CPU than the original model.
|
|
138
139
|
- **Fast, Dataset-free Distillation**: distill your own model in 30 seconds on a CPU, without a dataset.
|
|
139
140
|
- **Fine-tuning**: fine-tune your own classification models on top of Model2Vec models.
|
|
140
|
-
- **Integrated in many popular libraries**: Model2Vec is integrated direclty into popular libraries such as [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) and [LangChain](https://github.com/langchain-ai/langchain). For more information, see our [integrations documentation](https://
|
|
141
|
+
- **Integrated in many popular libraries**: Model2Vec is integrated direclty into popular libraries such as [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) and [LangChain](https://github.com/langchain-ai/langchain). For more information, see our [integrations documentation](https://minish.ai/packages/model2vec/integrations).
|
|
141
142
|
- **Tightly integrated with HuggingFace hub**: easily share and load models from the HuggingFace hub, using the familiar `from_pretrained` and `push_to_hub`. Our own models can be found [here](https://huggingface.co/minishlab).
|
|
142
143
|
|
|
143
144
|
## What is Model2Vec?
|
|
144
145
|
|
|
145
146
|
Model2vec creates a small, fast, and powerful model that outperforms other static embedding models by a large margin on all tasks we could find, while being much faster to create than traditional static embedding models such as GloVe. Like BPEmb, it can create subword embeddings, but with much better performance. Distillation doesn't need _any_ data, just a vocabulary and a model.
|
|
146
147
|
|
|
147
|
-
The core idea is to forward pass a vocabulary through a sentence transformer model, creating static embeddings for the indiviudal tokens. After this, there are a number of post-processing steps we do that results in our best models. For a more extensive deepdive, please refer to
|
|
148
|
-
- Our initial [Model2Vec blog post](https://huggingface.co/blog/Pringled/model2vec). Note that, while this post gives a good overview of the core idea, we've made a number of substantial improvements since then.
|
|
149
|
-
- Our [Tokenlearn blog post](https://minishlab.github.io/tokenlearn_blogpost/). This post describes the Tokenlearn method we used to train our [potion models](https://huggingface.co/collections/minishlab/potion-6721e0abd4ea41881417f062).
|
|
150
|
-
- Our official [documentation](https://github.com/MinishLab/model2vec/blob/main/docs/what_is_model2vec.md). This document provides a high-level overview of how Model2Vec works.
|
|
148
|
+
The core idea is to forward pass a vocabulary through a sentence transformer model, creating static embeddings for the indiviudal tokens. After this, there are a number of post-processing steps we do that results in our best models, as well as an optional pre-training step to further boost performance. For a more extensive deepdive, please refer to our [official documentation on how Model2Vec works](https://minish.ai/packages/model2vec/introduction#how-mode2vec-works).
|
|
151
149
|
|
|
152
150
|
## Documentation
|
|
153
151
|
|
|
154
|
-
Our official documentation can be found [here](https://
|
|
155
|
-
- [Usage documentation](https://github.com/MinishLab/model2vec/blob/main/docs/usage.md): provides a technical overview of how to use Model2Vec.
|
|
156
|
-
- [Integrations documentation](https://github.com/MinishLab/model2vec/blob/main/docs/integrations.md): provides examples of how to use Model2Vec in various downstream libraries.
|
|
157
|
-
- [Model2Vec technical documentation](https://github.com/MinishLab/model2vec/blob/main/docs/what_is_model2vec.md): provides a high-level overview of how Model2Vec works.
|
|
152
|
+
Our official documentation can be found [here](https://minish.ai/packages/model2vec/introduction). This includes in-depth documentation on [inference](https://minish.ai/packages/model2vec/inference), [distillation](https://minish.ai/packages/model2vec/distillation), [training](https://minish.ai/packages/model2vec/training), and [integrations](https://minish.ai/packages/model2vec/integrations).
|
|
158
153
|
|
|
159
154
|
|
|
160
155
|
## Model List
|
|
@@ -179,6 +174,8 @@ We provide a number of models that can be used out of the box. These models are
|
|
|
179
174
|
|
|
180
175
|
We have performed extensive experiments to evaluate the performance of Model2Vec models. The results are documented in the [results](results/README.md) folder. The results are presented in the following sections:
|
|
181
176
|
- [MTEB Results](results/README.md#mteb-results)
|
|
177
|
+
- [MMTEB Results](results/README.md#mmteb-results)
|
|
178
|
+
- [Retrieval Results](results/README.md#retrieval-results)
|
|
182
179
|
- [Training Results](results/README.md#training-results)
|
|
183
180
|
- [Ablations](results/README.md#ablations)
|
|
184
181
|
|
|
@@ -189,11 +186,15 @@ MIT
|
|
|
189
186
|
## Citing
|
|
190
187
|
|
|
191
188
|
If you use Model2Vec in your research, please cite the following:
|
|
189
|
+
|
|
192
190
|
```bibtex
|
|
193
|
-
@
|
|
194
|
-
author
|
|
195
|
-
title
|
|
196
|
-
year
|
|
197
|
-
|
|
191
|
+
@software{minishlab2024model2vec,
|
|
192
|
+
author = {Stephan Tulkens and {van Dongen}, Thomas},
|
|
193
|
+
title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
|
|
194
|
+
year = {2024},
|
|
195
|
+
publisher = {Zenodo},
|
|
196
|
+
doi = {10.5281/zenodo.17270888},
|
|
197
|
+
url = {https://github.com/MinishLab/model2vec},
|
|
198
|
+
license = {MIT}
|
|
198
199
|
}
|
|
199
200
|
```
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Documentation
|
|
2
|
+
|
|
3
|
+
Model2Vec's extensive documentation can be found on [our documentation website](https://minish.ai/packages/model2vec/introduction). This includes in-depth documentation on:
|
|
4
|
+
- [Inference](https://minish.ai/packages/model2vec/inference)
|
|
5
|
+
- [Distillation](https://minish.ai/packages/model2vec/distillation)
|
|
6
|
+
- [Training](https://minish.ai/packages/model2vec/training)
|
|
7
|
+
- [Integrations](https://minish.ai/packages/model2vec/integrations)
|
|
8
|
+
- [How Model2Vec works](https://minish.ai/packages/model2vec/introduction#how-mode2vec-works)
|