model2vec 0.10.0__tar.gz → 0.11.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.11.0/.github/workflows/ci.yaml +127 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/PKG-INFO +16 -17
- {model2vec-0.10.0 → model2vec-0.11.0}/README.md +13 -14
- model2vec-0.11.0/assets/images/speed_vs_mteb_plot.svg +2430 -0
- model2vec-0.11.0/docs/internals.md +72 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/distill/__init__.py +2 -2
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/distill/distillation.py +173 -50
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/distill/inference.py +2 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/inference/README.md +1 -1
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/inference/model.py +23 -56
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/model.py +157 -186
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/modelcards/model_card_template.md +1 -1
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/onnx.py +4 -4
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/tokenizer/tokenizer.py +3 -1
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/README.md +4 -4
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/base.py +27 -9
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/classifier.py +3 -11
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/similarity.py +0 -8
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/trainer.py +3 -14
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/utils.py +1 -35
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/version.py +1 -1
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/vocabulary_quantization.py +7 -2
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec.egg-info/PKG-INFO +16 -17
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec.egg-info/SOURCES.txt +2 -1
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec.egg-info/requires.txt +2 -2
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec.egg-info/scm_file_list.json +2 -1
- model2vec-0.11.0/model2vec.egg-info/scm_version.json +8 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/pyproject.toml +3 -3
- {model2vec-0.10.0 → model2vec-0.11.0}/results/README.md +25 -45
- model2vec-0.11.0/results/make_speed_vs_mteb_plot.py +252 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/Alibaba-NLP___gte-modernbert-base_baseline.json +10 -10
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/pretrained_model_metrics.py +2 -2
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/test_onnx_export.py +1 -1
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_distillation.py +186 -31
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_export_to_onnx.py +23 -4
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_inference.py +7 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_model.py +136 -22
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_quantization.py +36 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_trainable.py +51 -20
- {model2vec-0.10.0 → model2vec-0.11.0}/uv.lock +83 -30
- model2vec-0.10.0/.github/workflows/ci.yaml +0 -59
- model2vec-0.10.0/assets/images/speed_vs_mteb_plot.png +0 -0
- model2vec-0.10.0/model2vec.egg-info/scm_version.json +0 -8
- model2vec-0.10.0/results/make_speed_vs_mteb_plot.py +0 -186
- {model2vec-0.10.0 → model2vec-0.11.0}/.github/workflows/release.yaml +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/.gitignore +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/.pre-commit-config.yaml +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/CITATION.cff +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/CONTRIBUTING.md +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/LICENSE +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/Makefile +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/assets/images/logo_v2.png +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/assets/images/model2vec_logo.png +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/assets/images/speed_vs_mteb_score_v3.png +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/assets/images/training_speed_vs_score.png +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/assets/images/tutorial_ezlo.png +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/docs/README.md +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/distill/utils.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/inference/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/inference/evaluation.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/inference/mlp.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/modelcards/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/modelcards/classifier_template.md +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/modelcards/modelcards.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/modelcards/onnx_classifier_template.md +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/modelcards/onnx_model_card_template.md +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/persistence/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/persistence/datamodels.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/persistence/hf.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/persistence/persistence.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/persistence/utils.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/py.typed +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/quantization.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/tokenizer/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/dataset.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/pairs.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/regression.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/train/utils.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec/types.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec.egg-info/dependency_links.txt +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/model2vec.egg-info/top_level.txt +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/setup.cfg +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/conftest.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/data/test_tokenizer/special_tokens_map.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/data/test_tokenizer/tokenizer.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/data/test_tokenizer/tokenizer_config.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/baai___bge-base-en-v1.5_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/google___embeddinggemma-300m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/intfloat___multilingual-e5-base_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/pretrained/minishlab___potion-base-32m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/pretrained/minishlab___potion-base-8m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/pretrained/minishlab___potion-multilingual-128m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/pretrained/minishlab___potion-retrieval-32m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/data/sentence-transformers___all-MiniLM-L6-v2_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/distill_metrics.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/test_distill_regression.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/test_pretrained_model_regression.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/update_distill_baseline.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/integration/update_pretrained_baseline.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_persistence.py +0 -0
- {model2vec-0.10.0 → model2vec-0.11.0}/tests/test_utils.py +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
name: Run tests and upload coverage
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
changes:
|
|
11
|
+
name: Detect code changes
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
outputs:
|
|
14
|
+
code: ${{ steps.filter.outputs.code }}
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0
|
|
19
|
+
|
|
20
|
+
- name: Check for changes outside non-code files
|
|
21
|
+
id: filter
|
|
22
|
+
shell: bash
|
|
23
|
+
env:
|
|
24
|
+
EVENT_NAME: ${{ github.event_name }}
|
|
25
|
+
PR_BASE: ${{ github.event.pull_request.base.sha }}
|
|
26
|
+
PR_HEAD: ${{ github.event.pull_request.head.sha }}
|
|
27
|
+
PUSH_BEFORE: ${{ github.event.before }}
|
|
28
|
+
PUSH_AFTER: ${{ github.event.after }}
|
|
29
|
+
run: |
|
|
30
|
+
if [[ "$EVENT_NAME" == "pull_request" ]]; then
|
|
31
|
+
range="$PR_BASE...$PR_HEAD"
|
|
32
|
+
elif [[ -z "$PUSH_BEFORE" || "$PUSH_BEFORE" =~ ^0+$ ]]; then
|
|
33
|
+
echo "code=true" >> "$GITHUB_OUTPUT"
|
|
34
|
+
exit 0
|
|
35
|
+
else
|
|
36
|
+
range="$PUSH_BEFORE..$PUSH_AFTER"
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
if ! files=$(git diff --no-renames --name-only "$range"); then
|
|
40
|
+
echo "code=true" >> "$GITHUB_OUTPUT"
|
|
41
|
+
exit 0
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
code=false
|
|
45
|
+
while IFS= read -r file; do
|
|
46
|
+
case "$file" in
|
|
47
|
+
"") ;;
|
|
48
|
+
model2vec/modelcards/*) code=true ;;
|
|
49
|
+
*.md|assets/*|docs/*|results/*|LICENSE|CITATION.cff) ;;
|
|
50
|
+
*) code=true ;;
|
|
51
|
+
esac
|
|
52
|
+
done <<< "$files"
|
|
53
|
+
|
|
54
|
+
echo "code=$code" >> "$GITHUB_OUTPUT"
|
|
55
|
+
|
|
56
|
+
test:
|
|
57
|
+
name: Run tests with pytest
|
|
58
|
+
needs: changes
|
|
59
|
+
if: needs.changes.outputs.code == 'true'
|
|
60
|
+
runs-on: ${{ matrix.os }}
|
|
61
|
+
strategy:
|
|
62
|
+
fail-fast: false
|
|
63
|
+
matrix:
|
|
64
|
+
os: ["ubuntu-latest", "windows-latest"]
|
|
65
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
66
|
+
|
|
67
|
+
steps:
|
|
68
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
|
|
69
|
+
|
|
70
|
+
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
|
|
71
|
+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
|
|
72
|
+
with:
|
|
73
|
+
python-version: ${{ matrix.python-version }}
|
|
74
|
+
allow-prereleases: true
|
|
75
|
+
|
|
76
|
+
- name: Install uv
|
|
77
|
+
uses: astral-sh/setup-uv@d0d8abe699bfb85fec6de9f7adb5ae17292296ff
|
|
78
|
+
|
|
79
|
+
- name: Create virtual environment
|
|
80
|
+
run: uv venv .venv
|
|
81
|
+
|
|
82
|
+
- name: Add venv to PATH (Linux/macOS)
|
|
83
|
+
if: runner.os != 'Windows'
|
|
84
|
+
run: |
|
|
85
|
+
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
|
|
86
|
+
echo "$PWD/.venv/bin" >> $GITHUB_PATH
|
|
87
|
+
|
|
88
|
+
- name: Add venv to PATH (Windows)
|
|
89
|
+
if: runner.os == 'Windows'
|
|
90
|
+
shell: pwsh
|
|
91
|
+
run: |
|
|
92
|
+
"VIRTUAL_ENV=.venv" >> $env:GITHUB_ENV
|
|
93
|
+
"$pwd\.venv\Scripts" >> $env:GITHUB_PATH
|
|
94
|
+
|
|
95
|
+
- name: Install dependencies
|
|
96
|
+
run: make install-no-pre-commit
|
|
97
|
+
|
|
98
|
+
- name: Run tests under coverage
|
|
99
|
+
shell: bash
|
|
100
|
+
run: |
|
|
101
|
+
coverage run --source=model2vec -m pytest --ignore=tests/integration
|
|
102
|
+
coverage report
|
|
103
|
+
|
|
104
|
+
- name: Upload results to Codecov
|
|
105
|
+
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238
|
|
106
|
+
with:
|
|
107
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
108
|
+
|
|
109
|
+
tests-passed:
|
|
110
|
+
name: Tests passed
|
|
111
|
+
needs: [changes, test]
|
|
112
|
+
if: always()
|
|
113
|
+
runs-on: ubuntu-latest
|
|
114
|
+
steps:
|
|
115
|
+
- name: Check test results
|
|
116
|
+
shell: bash
|
|
117
|
+
env:
|
|
118
|
+
CHANGES_RESULT: ${{ needs.changes.result }}
|
|
119
|
+
TEST_RESULT: ${{ needs.test.result }}
|
|
120
|
+
run: |
|
|
121
|
+
echo "changes: $CHANGES_RESULT, test: $TEST_RESULT"
|
|
122
|
+
if [[ "$CHANGES_RESULT" != "success" ]]; then
|
|
123
|
+
exit 1
|
|
124
|
+
fi
|
|
125
|
+
if [[ "$TEST_RESULT" != "success" && "$TEST_RESULT" != "skipped" ]]; then
|
|
126
|
+
exit 1
|
|
127
|
+
fi
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: model2vec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Fast State-of-the-Art Static Embeddings
|
|
5
5
|
Author-email: Stéphan Tulkens <stephantul@gmail.com>, Thomas van Dongen <thomasvdongen@proton.me>
|
|
6
6
|
License: MIT License
|
|
@@ -43,12 +43,12 @@ Classifier: Natural Language :: English
|
|
|
43
43
|
Requires-Python: >=3.10
|
|
44
44
|
Description-Content-Type: text/markdown
|
|
45
45
|
Requires-Dist: jinja2
|
|
46
|
-
Requires-Dist: joblib
|
|
47
46
|
Requires-Dist: numpy
|
|
48
47
|
Requires-Dist: safetensors
|
|
49
|
-
Requires-Dist: tokenizers
|
|
48
|
+
Requires-Dist: tokenizers<1.0.0,>=0.22
|
|
50
49
|
Requires-Dist: tqdm
|
|
51
50
|
Requires-Dist: huggingface-hub>=1.0.0
|
|
51
|
+
Requires-Dist: model2vec-rs<0.6.0,>=0.5.1
|
|
52
52
|
Provides-Extra: dev
|
|
53
53
|
Requires-Dist: ipython; extra == "dev"
|
|
54
54
|
Requires-Dist: mypy; extra == "dev"
|
|
@@ -111,7 +111,7 @@ Requires-Dist: skops; extra == "tests"
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
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
|
|
114
|
+
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 30000 times faster, with a small drop in performance. Our [best model](https://huggingface.co/minishlab/blink-8M) 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.
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
## Quickstart
|
|
@@ -122,12 +122,12 @@ Install the lightweight base package with:
|
|
|
122
122
|
pip install model2vec
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
You can start using Model2Vec by loading one of our [flagship models from the HuggingFace hub](https://huggingface.co/collections/minishlab/
|
|
125
|
+
You can start using Model2Vec by loading one of our [flagship models from the HuggingFace hub](https://huggingface.co/collections/minishlab/blink). These models are pre-trained and ready to use. The following code snippet shows how to load a model and make embeddings, which you can use for any task, such as text classification, retrieval, clustering, or building a RAG system:
|
|
126
126
|
```python
|
|
127
127
|
from model2vec import StaticModel
|
|
128
128
|
|
|
129
|
-
# Load a model from the HuggingFace hub (in this case the
|
|
130
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
129
|
+
# Load a model from the HuggingFace hub (in this case the blink-8M model)
|
|
130
|
+
model = StaticModel.from_pretrained("minishlab/blink-8M")
|
|
131
131
|
|
|
132
132
|
# Make embeddings
|
|
133
133
|
embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."])
|
|
@@ -167,7 +167,7 @@ from datasets import load_dataset
|
|
|
167
167
|
from model2vec.train import StaticModelForClassification
|
|
168
168
|
|
|
169
169
|
# Initialize a classifier from a pre-trained model
|
|
170
|
-
classifier = StaticModelForClassification.from_pretrained(path="minishlab/
|
|
170
|
+
classifier = StaticModelForClassification.from_pretrained(path="minishlab/blink-8M")
|
|
171
171
|
|
|
172
172
|
# Load a dataset. Note: both single and multi-label classification datasets are supported
|
|
173
173
|
ds = load_dataset("setfit/subj")
|
|
@@ -185,9 +185,9 @@ For advanced usage, see our [training docs](https://minish.ai/packages/model2vec
|
|
|
185
185
|
## Main Features
|
|
186
186
|
|
|
187
187
|
- **State-of-the-Art Performance**: Model2Vec models outperform any other static embeddings (such as GLoVe and BPEmb) by a large margin, as can be seen in our [results](results/README.md).
|
|
188
|
-
- **Small**: Model2Vec reduces the size of a Sentence Transformer model by a factor of up to 50. Our [best model](https://huggingface.co/minishlab/
|
|
188
|
+
- **Small**: Model2Vec reduces the size of a Sentence Transformer model by a factor of up to 50. Our [best model](https://huggingface.co/minishlab/blink-8M) is just ~30 MB on disk, and our smallest model just ~8 MB (making it the smallest model on [MTEB](https://huggingface.co/spaces/mteb/leaderboard)!).
|
|
189
189
|
- **Lightweight Dependencies**: the base package's only major dependency is `numpy`.
|
|
190
|
-
- **Lightning-fast Inference**: up to
|
|
190
|
+
- **Lightning-fast Inference**: up to 30000 times faster on CPU than the original model.
|
|
191
191
|
- **Fast, Dataset-free Distillation**: distill your own model in 30 seconds on a CPU, without a dataset.
|
|
192
192
|
- **Fine-tuning**: fine-tune Model2Vec models for classification, similarity, regression, or pair similarity, and run them without `torch`.
|
|
193
193
|
- **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).
|
|
@@ -203,20 +203,20 @@ The core idea is to forward pass a vocabulary through a sentence transformer mod
|
|
|
203
203
|
|
|
204
204
|
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).
|
|
205
205
|
|
|
206
|
+
For details on the Rust backend and which dtypes to use, see [internals](docs/internals.md).
|
|
207
|
+
|
|
206
208
|
|
|
207
209
|
## Model List
|
|
208
210
|
|
|
209
|
-
We provide a number of models that can be used out of the box. These models are available on the [HuggingFace hub](https://huggingface.co/collections/minishlab/
|
|
211
|
+
We provide a number of models that can be used out of the box. These models are available on the [HuggingFace hub](https://huggingface.co/collections/minishlab/blink) and can be loaded using the `from_pretrained` method. The models are listed below.
|
|
210
212
|
|
|
211
213
|
|
|
212
214
|
|
|
213
215
|
| Model | Language | Sentence Transformer | Params | Task |
|
|
214
216
|
|-----------------------------------------------------------------------|------------|-----------------------------------------------------------------|---------|-----------|
|
|
215
|
-
| [
|
|
216
|
-
| [
|
|
217
|
-
| [
|
|
218
|
-
| [potion-base-8M](https://huggingface.co/minishlab/potion-base-8M) | English | [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) | 7.5M | General |
|
|
219
|
-
| [potion-code-16M-v2](https://huggingface.co/minishlab/potion-code-16M-v2) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.2M | Code |
|
|
217
|
+
| [blink-8M](https://huggingface.co/minishlab/blink-8M) | English | [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) | 7.7M | General |
|
|
218
|
+
| [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | Multilingual | [bge-m3](https://huggingface.co/BAAI/bge-m3) | 64.0M | General |
|
|
219
|
+
| [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.0M | Code |
|
|
220
220
|
|
|
221
221
|
|
|
222
222
|
|
|
@@ -227,7 +227,6 @@ We have performed extensive experiments to evaluate the performance of Model2Vec
|
|
|
227
227
|
- [MMTEB Results](results/README.md#mmteb-results)
|
|
228
228
|
- [Retrieval Results](results/README.md#retrieval-results)
|
|
229
229
|
- [Training Results](results/README.md#training-results)
|
|
230
|
-
- [Ablations](results/README.md#ablations)
|
|
231
230
|
|
|
232
231
|
## Acknowledgements
|
|
233
232
|
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
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
|
|
34
|
+
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 30000 times faster, with a small drop in performance. Our [best model](https://huggingface.co/minishlab/blink-8M) 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.
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
## Quickstart
|
|
@@ -42,12 +42,12 @@ Install the lightweight base package with:
|
|
|
42
42
|
pip install model2vec
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
You can start using Model2Vec by loading one of our [flagship models from the HuggingFace hub](https://huggingface.co/collections/minishlab/
|
|
45
|
+
You can start using Model2Vec by loading one of our [flagship models from the HuggingFace hub](https://huggingface.co/collections/minishlab/blink). These models are pre-trained and ready to use. The following code snippet shows how to load a model and make embeddings, which you can use for any task, such as text classification, retrieval, clustering, or building a RAG system:
|
|
46
46
|
```python
|
|
47
47
|
from model2vec import StaticModel
|
|
48
48
|
|
|
49
|
-
# Load a model from the HuggingFace hub (in this case the
|
|
50
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
49
|
+
# Load a model from the HuggingFace hub (in this case the blink-8M model)
|
|
50
|
+
model = StaticModel.from_pretrained("minishlab/blink-8M")
|
|
51
51
|
|
|
52
52
|
# Make embeddings
|
|
53
53
|
embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."])
|
|
@@ -87,7 +87,7 @@ from datasets import load_dataset
|
|
|
87
87
|
from model2vec.train import StaticModelForClassification
|
|
88
88
|
|
|
89
89
|
# Initialize a classifier from a pre-trained model
|
|
90
|
-
classifier = StaticModelForClassification.from_pretrained(path="minishlab/
|
|
90
|
+
classifier = StaticModelForClassification.from_pretrained(path="minishlab/blink-8M")
|
|
91
91
|
|
|
92
92
|
# Load a dataset. Note: both single and multi-label classification datasets are supported
|
|
93
93
|
ds = load_dataset("setfit/subj")
|
|
@@ -105,9 +105,9 @@ For advanced usage, see our [training docs](https://minish.ai/packages/model2vec
|
|
|
105
105
|
## Main Features
|
|
106
106
|
|
|
107
107
|
- **State-of-the-Art Performance**: Model2Vec models outperform any other static embeddings (such as GLoVe and BPEmb) by a large margin, as can be seen in our [results](results/README.md).
|
|
108
|
-
- **Small**: Model2Vec reduces the size of a Sentence Transformer model by a factor of up to 50. Our [best model](https://huggingface.co/minishlab/
|
|
108
|
+
- **Small**: Model2Vec reduces the size of a Sentence Transformer model by a factor of up to 50. Our [best model](https://huggingface.co/minishlab/blink-8M) is just ~30 MB on disk, and our smallest model just ~8 MB (making it the smallest model on [MTEB](https://huggingface.co/spaces/mteb/leaderboard)!).
|
|
109
109
|
- **Lightweight Dependencies**: the base package's only major dependency is `numpy`.
|
|
110
|
-
- **Lightning-fast Inference**: up to
|
|
110
|
+
- **Lightning-fast Inference**: up to 30000 times faster on CPU than the original model.
|
|
111
111
|
- **Fast, Dataset-free Distillation**: distill your own model in 30 seconds on a CPU, without a dataset.
|
|
112
112
|
- **Fine-tuning**: fine-tune Model2Vec models for classification, similarity, regression, or pair similarity, and run them without `torch`.
|
|
113
113
|
- **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).
|
|
@@ -123,20 +123,20 @@ The core idea is to forward pass a vocabulary through a sentence transformer mod
|
|
|
123
123
|
|
|
124
124
|
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).
|
|
125
125
|
|
|
126
|
+
For details on the Rust backend and which dtypes to use, see [internals](docs/internals.md).
|
|
127
|
+
|
|
126
128
|
|
|
127
129
|
## Model List
|
|
128
130
|
|
|
129
|
-
We provide a number of models that can be used out of the box. These models are available on the [HuggingFace hub](https://huggingface.co/collections/minishlab/
|
|
131
|
+
We provide a number of models that can be used out of the box. These models are available on the [HuggingFace hub](https://huggingface.co/collections/minishlab/blink) and can be loaded using the `from_pretrained` method. The models are listed below.
|
|
130
132
|
|
|
131
133
|
|
|
132
134
|
|
|
133
135
|
| Model | Language | Sentence Transformer | Params | Task |
|
|
134
136
|
|-----------------------------------------------------------------------|------------|-----------------------------------------------------------------|---------|-----------|
|
|
135
|
-
| [
|
|
136
|
-
| [
|
|
137
|
-
| [
|
|
138
|
-
| [potion-base-8M](https://huggingface.co/minishlab/potion-base-8M) | English | [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) | 7.5M | General |
|
|
139
|
-
| [potion-code-16M-v2](https://huggingface.co/minishlab/potion-code-16M-v2) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.2M | Code |
|
|
137
|
+
| [blink-8M](https://huggingface.co/minishlab/blink-8M) | English | [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5) | 7.7M | General |
|
|
138
|
+
| [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | Multilingual | [bge-m3](https://huggingface.co/BAAI/bge-m3) | 64.0M | General |
|
|
139
|
+
| [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.0M | Code |
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|
|
@@ -147,7 +147,6 @@ We have performed extensive experiments to evaluate the performance of Model2Vec
|
|
|
147
147
|
- [MMTEB Results](results/README.md#mmteb-results)
|
|
148
148
|
- [Retrieval Results](results/README.md#retrieval-results)
|
|
149
149
|
- [Training Results](results/README.md#training-results)
|
|
150
|
-
- [Ablations](results/README.md#ablations)
|
|
151
150
|
|
|
152
151
|
## Acknowledgements
|
|
153
152
|
|