model2vec 0.10.0__tar.gz → 0.12.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.12.0/.github/workflows/ci.yaml +127 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/PKG-INFO +18 -17
- {model2vec-0.10.0 → model2vec-0.12.0}/README.md +13 -14
- model2vec-0.12.0/assets/images/speed_vs_mteb_plot.svg +2430 -0
- model2vec-0.12.0/docs/internals.md +72 -0
- model2vec-0.12.0/model2vec/base.py +184 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/distill/__init__.py +2 -2
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/distill/distillation.py +173 -50
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/distill/inference.py +2 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/inference/README.md +1 -1
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/inference/model.py +24 -57
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/model.py +160 -302
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/modelcards/model_card_template.md +1 -1
- model2vec-0.12.0/model2vec/modelcards/sparse_model_card_template.md +72 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/onnx.py +4 -4
- model2vec-0.12.0/model2vec/persistence/__init__.py +4 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/persistence/persistence.py +105 -28
- model2vec-0.12.0/model2vec/sentence-transformers/sparse_encoder.py +139 -0
- model2vec-0.12.0/model2vec/sparse.py +483 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/tokenizer/tokenizer.py +3 -1
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/README.md +4 -4
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/base.py +61 -24
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/classifier.py +3 -11
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/similarity.py +0 -8
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/trainer.py +3 -14
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/types.py +16 -3
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/utils.py +9 -35
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/version.py +1 -1
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/vocabulary_quantization.py +7 -2
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec.egg-info/PKG-INFO +18 -17
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec.egg-info/SOURCES.txt +8 -1
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec.egg-info/requires.txt +5 -2
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec.egg-info/scm_file_list.json +8 -1
- model2vec-0.12.0/model2vec.egg-info/scm_version.json +8 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/pyproject.toml +5 -3
- {model2vec-0.10.0 → model2vec-0.12.0}/results/README.md +25 -45
- model2vec-0.12.0/results/make_speed_vs_mteb_plot.py +252 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/Alibaba-NLP___gte-modernbert-base_baseline.json +10 -10
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/pretrained_model_metrics.py +2 -2
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/test_onnx_export.py +1 -1
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/test_distillation.py +186 -31
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/test_export_to_onnx.py +23 -4
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/test_inference.py +7 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/test_model.py +198 -34
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/test_quantization.py +36 -0
- model2vec-0.12.0/tests/test_sparse.py +593 -0
- model2vec-0.12.0/tests/test_sparse_encoder.py +203 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/test_trainable.py +88 -32
- {model2vec-0.10.0 → model2vec-0.12.0}/uv.lock +89 -31
- 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/persistence/__init__.py +0 -4
- 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.12.0}/.github/workflows/release.yaml +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/.gitignore +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/.pre-commit-config.yaml +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/CITATION.cff +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/CONTRIBUTING.md +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/LICENSE +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/Makefile +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/assets/images/logo_v2.png +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/assets/images/model2vec_logo.png +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/assets/images/speed_vs_mteb_score_v3.png +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/assets/images/training_speed_vs_score.png +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/assets/images/tutorial_ezlo.png +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/docs/README.md +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/distill/utils.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/inference/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/inference/evaluation.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/inference/mlp.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/modelcards/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/modelcards/classifier_template.md +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/modelcards/modelcards.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/modelcards/onnx_classifier_template.md +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/modelcards/onnx_model_card_template.md +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/persistence/datamodels.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/persistence/hf.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/persistence/utils.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/py.typed +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/quantization.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/tokenizer/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/dataset.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/pairs.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/regression.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec/train/utils.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec.egg-info/dependency_links.txt +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/model2vec.egg-info/top_level.txt +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/setup.cfg +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/conftest.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/data/test_tokenizer/special_tokens_map.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/data/test_tokenizer/tokenizer.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/data/test_tokenizer/tokenizer_config.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/__init__.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/baai___bge-base-en-v1.5_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/google___embeddinggemma-300m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/intfloat___multilingual-e5-base_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/pretrained/minishlab___potion-base-32m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/pretrained/minishlab___potion-base-8m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/pretrained/minishlab___potion-multilingual-128m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/pretrained/minishlab___potion-retrieval-32m_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/data/sentence-transformers___all-MiniLM-L6-v2_baseline.json +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/distill_metrics.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/test_distill_regression.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/test_pretrained_model_regression.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/update_distill_baseline.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/integration/update_pretrained_baseline.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.0}/tests/test_persistence.py +0 -0
- {model2vec-0.10.0 → model2vec-0.12.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.12.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.7.0,>=0.6.0
|
|
52
52
|
Provides-Extra: dev
|
|
53
53
|
Requires-Dist: ipython; extra == "dev"
|
|
54
54
|
Requires-Dist: mypy; extra == "dev"
|
|
@@ -72,6 +72,8 @@ Requires-Dist: torch; extra == "train"
|
|
|
72
72
|
Requires-Dist: datasets>=4.0.0; extra == "train"
|
|
73
73
|
Provides-Extra: quantization
|
|
74
74
|
Requires-Dist: scikit-learn; extra == "quantization"
|
|
75
|
+
Provides-Extra: sparse
|
|
76
|
+
Requires-Dist: scipy; extra == "sparse"
|
|
75
77
|
Provides-Extra: integration
|
|
76
78
|
Requires-Dist: mteb; extra == "integration"
|
|
77
79
|
Provides-Extra: tests
|
|
@@ -111,7 +113,7 @@ Requires-Dist: skops; extra == "tests"
|
|
|
111
113
|
|
|
112
114
|
|
|
113
115
|
|
|
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
|
|
116
|
+
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
117
|
|
|
116
118
|
|
|
117
119
|
## Quickstart
|
|
@@ -122,12 +124,12 @@ Install the lightweight base package with:
|
|
|
122
124
|
pip install model2vec
|
|
123
125
|
```
|
|
124
126
|
|
|
125
|
-
You can start using Model2Vec by loading one of our [flagship models from the HuggingFace hub](https://huggingface.co/collections/minishlab/
|
|
127
|
+
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
128
|
```python
|
|
127
129
|
from model2vec import StaticModel
|
|
128
130
|
|
|
129
|
-
# Load a model from the HuggingFace hub (in this case the
|
|
130
|
-
model = StaticModel.from_pretrained("minishlab/
|
|
131
|
+
# Load a model from the HuggingFace hub (in this case the blink-8M model)
|
|
132
|
+
model = StaticModel.from_pretrained("minishlab/blink-8M")
|
|
131
133
|
|
|
132
134
|
# Make embeddings
|
|
133
135
|
embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."])
|
|
@@ -167,7 +169,7 @@ from datasets import load_dataset
|
|
|
167
169
|
from model2vec.train import StaticModelForClassification
|
|
168
170
|
|
|
169
171
|
# Initialize a classifier from a pre-trained model
|
|
170
|
-
classifier = StaticModelForClassification.from_pretrained(path="minishlab/
|
|
172
|
+
classifier = StaticModelForClassification.from_pretrained(path="minishlab/blink-8M")
|
|
171
173
|
|
|
172
174
|
# Load a dataset. Note: both single and multi-label classification datasets are supported
|
|
173
175
|
ds = load_dataset("setfit/subj")
|
|
@@ -185,9 +187,9 @@ For advanced usage, see our [training docs](https://minish.ai/packages/model2vec
|
|
|
185
187
|
## Main Features
|
|
186
188
|
|
|
187
189
|
- **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/
|
|
190
|
+
- **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
191
|
- **Lightweight Dependencies**: the base package's only major dependency is `numpy`.
|
|
190
|
-
- **Lightning-fast Inference**: up to
|
|
192
|
+
- **Lightning-fast Inference**: up to 30000 times faster on CPU than the original model.
|
|
191
193
|
- **Fast, Dataset-free Distillation**: distill your own model in 30 seconds on a CPU, without a dataset.
|
|
192
194
|
- **Fine-tuning**: fine-tune Model2Vec models for classification, similarity, regression, or pair similarity, and run them without `torch`.
|
|
193
195
|
- **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 +205,20 @@ The core idea is to forward pass a vocabulary through a sentence transformer mod
|
|
|
203
205
|
|
|
204
206
|
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
207
|
|
|
208
|
+
For details on the Rust backend and which dtypes to use, see [internals](docs/internals.md).
|
|
209
|
+
|
|
206
210
|
|
|
207
211
|
## Model List
|
|
208
212
|
|
|
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/
|
|
213
|
+
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
214
|
|
|
211
215
|
|
|
212
216
|
|
|
213
217
|
| Model | Language | Sentence Transformer | Params | Task |
|
|
214
218
|
|-----------------------------------------------------------------------|------------|-----------------------------------------------------------------|---------|-----------|
|
|
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 |
|
|
219
|
+
| [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 |
|
|
220
|
+
| [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | Multilingual | [bge-m3](https://huggingface.co/BAAI/bge-m3) | 64.0M | General |
|
|
221
|
+
| [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.0M | Code |
|
|
220
222
|
|
|
221
223
|
|
|
222
224
|
|
|
@@ -227,7 +229,6 @@ We have performed extensive experiments to evaluate the performance of Model2Vec
|
|
|
227
229
|
- [MMTEB Results](results/README.md#mmteb-results)
|
|
228
230
|
- [Retrieval Results](results/README.md#retrieval-results)
|
|
229
231
|
- [Training Results](results/README.md#training-results)
|
|
230
|
-
- [Ablations](results/README.md#ablations)
|
|
231
232
|
|
|
232
233
|
## Acknowledgements
|
|
233
234
|
|
|
@@ -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
|
|