From 7d988c1f2d485871788cdf3a2555dc4ac83dff16 Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 10:57:27 +0100 Subject: [PATCH 1/8] docs: rewrite README with sparse support --- README.md | 92 ++++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 26e8a21a..4ab56200 100644 --- a/README.md +++ b/README.md @@ -23,64 +23,66 @@ License - MIT - - - -[Quickstart](#quickstart) • [Main Features](#main-features) • [Model List](#model-list) • [Results](#results) -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. +Model2Vec is a library for static models: dense embeddings, sparse retrieval and classifiers that look up a vector per token instead of running a transformer. They're small enough to ship anywhere and fast enough to encode large corpora on a CPU. Our [best dense model](https://huggingface.co/minishlab/blink-8M) is the strongest static embedding model we know of, and our sparse model is a drop-in replacement for BM25. See our [results](results/README.md) or read our [docs](https://minish.ai/packages/model2vec/introduction). ## Quickstart -Install the lightweight base package with: +Install the base package with: ```bash pip install model2vec ``` -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: +Load one of our [pre-trained models from the HuggingFace hub](https://huggingface.co/collections/minishlab/blink) and make embeddings, which you can use for retrieval, classification, clustering or RAG: + ```python from model2vec import StaticModel -# Load a model from the HuggingFace hub (in this case the blink-8M model) model = StaticModel.from_pretrained("minishlab/blink-8M") -# Make embeddings embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."]) - -# Make sequences of token embeddings -token_embeddings = model.encode_as_sequence(["It's dangerous to go alone!", "It's a secret to everybody."]) ``` -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 `distill` extra with: + +For advanced usage, see our [inference docs](https://minish.ai/packages/model2vec/inference). + +### Sparse retrieval + +Sparse models give each text a weight per token of the vocabulary, so you can store them in any inverted index, just like BM25. Unlike BM25, they need no corpus statistics: a document's representation depends only on its own text. Queries aren't encoded by a model at all, just weighted per token. Install the `sparse` extra with: ```bash -pip install model2vec[distill] +pip install model2vec[sparse] ``` +Then encode documents and queries, and score them with a dot product: -Then, you can distill a model in ~30 seconds on a CPU with the following code snippet: - + ```python -from model2vec.distill import distill +from model2vec.sparse import SparseStaticModel -# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model -m2v_model = distill(model_name="BAAI/bge-base-en-v1.5") +model = SparseStaticModel.from_pretrained("minishlab/") -# Save the model -m2v_model.save_pretrained("m2v_model") +documents = model.encode_document(["It's dangerous to go alone!", "It's a secret to everybody."]) +queries = model.encode_query(["Is it safe to go alone?"]) + +scores = queries @ documents.T ``` -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 the distilled model, or a pre-trained model, for classification, similarity, regression, or pair similarity (e.g. query-document retrieval). First, make sure you install the `train` extras with: +`encode_document` and `encode_query` return `scipy.sparse` matrices with one column per token of the vocabulary. Sparse models can also be loaded as a [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) `SparseEncoder` with `trust_remote_code=True`. + +### Training a classifier + +You can fine-tune a pre-trained model for classification, similarity, regression or pair similarity (for example query-document retrieval). Install the `train` extra with: ```bash pip install model2vec[train] ``` -Then, you can fine-tune a model as follows: +Then train a classifier as follows: ```python from datasets import load_dataset @@ -89,7 +91,7 @@ from model2vec.train import StaticModelForClassification # Initialize a classifier from a pre-trained model classifier = StaticModelForClassification.from_pretrained(path="minishlab/blink-8M") -# Load a dataset. Note: both single and multi-label classification datasets are supported +# Load a dataset. Both single and multi-label classification datasets are supported ds = load_dataset("setfit/subj") # Train the classifier on text (X) and labels (y) @@ -99,50 +101,42 @@ classifier.fit(ds["train"]["text"], ds["train"]["label"]) classification_report = classifier.evaluate(ds["test"]["text"], ds["test"]["label"]) ``` -For advanced usage, see our [training docs](https://minish.ai/packages/model2vec/training). +Trained models run without `torch`. For advanced usage, see our [training docs](https://minish.ai/packages/model2vec/training). You can also distill your own static model from any Sentence Transformer, see our [distillation docs](https://minish.ai/packages/model2vec/distillation). ## Main Features -- **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). -- **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)!). -- **Lightweight Dependencies**: the base package's only major dependency is `numpy`. -- **Lightning-fast Inference**: up to 30000 times faster on CPU than the original model. -- **Fast, Dataset-free Distillation**: distill your own model in 30 seconds on a CPU, without a dataset. -- **Fine-tuning**: fine-tune Model2Vec models for classification, similarity, regression, or pair similarity, and run them without `torch`. -- **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). -- **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). - -## What is Model2Vec? - -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. - -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). +- **Dense and sparse models**: dense embeddings for semantic search, classification and clustering, and sparse models for inverted-index retrieval as a replacement for BM25. +- **Small**: our [best dense model](https://huggingface.co/minishlab/blink-8M) has 7.7M parameters and is ~30 MB on disk. Our sparse model has 76k parameters and is under 1 MB. +- **Fast on CPU**: encoding is a token lookup and a sum, done in Rust by [model2vec-rs](https://github.com/MinishLab/model2vec-rs). +- **Lightweight dependencies**: the base package needs no `torch` or `transformers`, just `numpy`, `tokenizers` and the Rust backend. +- **Fine-tuning**: fine-tune models for classification, similarity, regression or pair similarity, and run them without `torch`. +- **Integrations**: load models directly in [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) and [LangChain](https://github.com/langchain-ai/langchain), and share them on the HuggingFace hub with `from_pretrained` and `push_to_hub`. See our [integrations docs](https://minish.ai/packages/model2vec/integrations). ## Documentation -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). +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), [training](https://minish.ai/packages/model2vec/training), [distillation](https://minish.ai/packages/model2vec/distillation) and [integrations](https://minish.ai/packages/model2vec/integrations). For details on the Rust backend and which dtypes to use, see [internals](docs/internals.md). ## Model List -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. - - +These models are available on the [HuggingFace hub](https://huggingface.co/minishlab) and can be loaded with `from_pretrained`. -| Model | Language | Sentence Transformer | Params | Task | -|-----------------------------------------------------------------------|------------|-----------------------------------------------------------------|---------|-----------| -| [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 | -| [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | Multilingual | [bge-m3](https://huggingface.co/BAAI/bge-m3) | 64.0M | General | -| [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.0M | Code | + +| Model | Language | Base model | Params | Task | +|-----------------------------------------------------------------------|--------------|------------------------------------------------------------------|---------|------------------| +| [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 | +| [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | Multilingual | [bge-m3](https://huggingface.co/BAAI/bge-m3) | 64.0M | General | +| [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.0M | Code | +| `` | English | [blink-8M](https://huggingface.co/minishlab/blink-8M) | 76k | Sparse retrieval | ## Results -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: +We have performed extensive experiments to evaluate the performance of Model2Vec models. The results are documented in the [results](results/README.md) folder: - [MTEB Results](results/README.md#mteb-results) - [MMTEB Results](results/README.md#mmteb-results) - [Retrieval Results](results/README.md#retrieval-results) From 78dd9f6b0fcd3439ad068fcd5d43544564eb59ca Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 11:13:39 +0100 Subject: [PATCH 2/8] docs: update results and README highlights --- README.md | 11 +- assets/images/speed_vs_mteb_plot.svg | 231 +++++++++++++-------------- results/README.md | 85 +++++----- results/make_speed_vs_mteb_plot.py | 10 +- 4 files changed, 172 insertions(+), 165 deletions(-) diff --git a/README.md b/README.md index 4ab56200..fdacb3dc 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ -Model2Vec is a library for static models: dense embeddings, sparse retrieval and classifiers that look up a vector per token instead of running a transformer. They're small enough to ship anywhere and fast enough to encode large corpora on a CPU. Our [best dense model](https://huggingface.co/minishlab/blink-8M) is the strongest static embedding model we know of, and our sparse model is a drop-in replacement for BM25. See our [results](results/README.md) or read our [docs](https://minish.ai/packages/model2vec/introduction). +Model2Vec is a library for static models: dense embeddings, sparse retrieval and classifiers that look up a vector per token instead of running a transformer. They're up to 30,000 times faster than transformer-based embeddings on a CPU, and small enough to ship anywhere. Our [best dense model](https://huggingface.co/minishlab/blink-8M) is the strongest static embedding model in the world, and our sparse model is a drop-in replacement for BM25 that outperforms it on most retrieval benchmarks. See our [results](results/README.md) or read our [docs](https://minish.ai/packages/model2vec/introduction). ## Quickstart @@ -107,10 +107,11 @@ Trained models run without `torch`. For advanced usage, see our [training docs]( ## Main Features - **Dense and sparse models**: dense embeddings for semantic search, classification and clustering, and sparse models for inverted-index retrieval as a replacement for BM25. +- **Multilingual and code**: [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) reaches 99% of the performance of [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) on MMTEB, and [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) outperforms BM25 on code retrieval (CoIR). See our [results](results/README.md). - **Small**: our [best dense model](https://huggingface.co/minishlab/blink-8M) has 7.7M parameters and is ~30 MB on disk. Our sparse model has 76k parameters and is under 1 MB. - **Fast on CPU**: encoding is a token lookup and a sum, done in Rust by [model2vec-rs](https://github.com/MinishLab/model2vec-rs). - **Lightweight dependencies**: the base package needs no `torch` or `transformers`, just `numpy`, `tokenizers` and the Rust backend. -- **Fine-tuning**: fine-tune models for classification, similarity, regression or pair similarity, and run them without `torch`. +- **Fine-tuning**: fine-tune models for classification, similarity, regression or pair similarity, and run them without `torch`. A fine-tuned classifier scores within 1 point of a fully fine-tuned [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) over 26 datasets, while running about 300 times faster (see our [training results](results/README.md#training-results)). - **Integrations**: load models directly in [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) and [LangChain](https://github.com/langchain-ai/langchain), and share them on the HuggingFace hub with `from_pretrained` and `push_to_hub`. See our [integrations docs](https://minish.ai/packages/model2vec/integrations). ## Documentation @@ -137,9 +138,9 @@ These models are available on the [HuggingFace hub](https://huggingface.co/minis ## Results We have performed extensive experiments to evaluate the performance of Model2Vec models. The results are documented in the [results](results/README.md) folder: -- [MTEB Results](results/README.md#mteb-results) -- [MMTEB Results](results/README.md#mmteb-results) -- [Retrieval Results](results/README.md#retrieval-results) +- [MTEB Results](results/README.md#mteb-results-english) +- [MMTEB Results](results/README.md#mmteb-results-multilingual) +- [CoIR Results](results/README.md#coir-results-code) - [Training Results](results/README.md#training-results) ## Acknowledgements diff --git a/assets/images/speed_vs_mteb_plot.svg b/assets/images/speed_vs_mteb_plot.svg index 2ed1a858..984d12af 100644 --- a/assets/images/speed_vs_mteb_plot.svg +++ b/assets/images/speed_vs_mteb_plot.svg @@ -6,7 +6,7 @@ - 2026-11-25T14:47:08.005787 + 2026-12-04T11:09:48.386498 image/svg+xml @@ -42,7 +42,7 @@ z +" clip-path="url(#p3806fe7a48)" style="fill: none; stroke: #e8e7e3; stroke-linecap: square"/> @@ -121,7 +121,7 @@ z +" clip-path="url(#p3806fe7a48)" style="fill: none; stroke: #e8e7e3; stroke-linecap: square"/> @@ -137,7 +137,7 @@ L 183.500637 60.48 +" clip-path="url(#p3806fe7a48)" style="fill: none; stroke: #e8e7e3; stroke-linecap: square"/> @@ -169,7 +169,7 @@ z +" clip-path="url(#p3806fe7a48)" style="fill: none; stroke: #e8e7e3; stroke-linecap: square"/> @@ -185,7 +185,7 @@ L 385.895104 60.48 +" clip-path="url(#p3806fe7a48)" style="fill: none; stroke: #e8e7e3; stroke-linecap: square"/> @@ -202,7 +202,7 @@ L 487.092338 60.48 +" clip-path="url(#p3806fe7a48)" style="fill: none; stroke: #e8e7e3; stroke-linecap: square"/> @@ -790,14 +790,14 @@ z - + - + - + - + @@ -881,14 +881,14 @@ L 628.56 264.626526 - + - + @@ -896,14 +896,14 @@ L 628.56 186.108632 - + - + - - + + - - + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1090,7 +1108,7 @@ L 628.56 358.848 - - - + + - - - + + - - - + + - - - + + - + - + - + - + - - + @@ -1552,7 +1570,7 @@ z - - + @@ -1611,7 +1629,7 @@ z - - + @@ -2234,31 +2252,6 @@ Q 1242 -301 1242 64 L 1242 710 L 531 710 z -" transform="scale(0.015625)"/> - + diff --git a/results/README.md b/results/README.md index eb23421a..eee97bd2 100644 --- a/results/README.md +++ b/results/README.md @@ -3,24 +3,28 @@ This document contains the results of the Model2Vec project. The results are presented in the following sections: - [MTEB Results (English)](#mteb-results-english) - [MMTEB Results (Multilingual)](#mmteb-results-multilingual) -- [Retrieval Results](#retrieval-results) +- [CoIR Results (Code)](#coir-results-code) - [Training Results](#training-results) ## MTEB Results (English) -Model2Vec is evaluated on MTEB. The results are shown in the table below. +Model2Vec is evaluated on [MTEB(eng, v2)](https://github.com/embeddings-benchmark/mteb) (41 tasks). Models are ranked by the mean over tasks. The results are shown in the table below. -Note: The `blink`, `potion` and `M2V` models are our static models. +Every static model is evaluated at 256 dimensions. Models with more dimensions are truncated to their first 256 dimensions and use L2 normalized embeddings, even if the original model did not have normalization. all-MiniLM-L6-v2 (384 dimensions) and GloVe (300 dimensions) are shown at their native size as references. -| Model | Avg (MTEB) | Class | Clust | PairClass | Rank | Ret | STS | Sum | -|:-----------------------|-------------:|--------:|--------:|------------:|-------:|-------:|-------:|-------:| -| [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | 55.93 | 69.25 | 44.90 | 82.37 | 47.14 | 42.92 | 78.95 | 25.96 | -| [blink-8M](https://huggingface.co/minishlab/blink-8m) | 55.35 | 67.88 | 41.49 | 78.42 | 43.12 | 38.86 | 73.56 | 22.48 | -| [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) | 52.13 | 71.70 | 41.25 | 78.17 | 42.45 | 32.67 | 73.93 | 24.74 | -| [potion-base-8M](https://huggingface.co/minishlab/potion-base-8M) | 51.08 | 70.34 | 39.74 | 76.62 | 41.79 | 31.11 | 72.91 | 25.06 | -| [M2V_base_output](https://huggingface.co/minishlab/M2V_base_output) | 47.96 | 66.84 | 33.96 | 74.90 | 39.31 | 25.36 | 68.76 | 26.61 | -| [GloVe_300d](https://huggingface.co/sentence-transformers/average_word_embeddings_glove.6B.300d) | 45.82 | 62.73 | 37.10 | 72.48 | 38.28 | 21.80 | 61.52 | 26.81 | -| [BPEmb_50k_300d](https://github.com/bheinzerling/bpemb) | 41.74 | 61.72 | 35.17 | 57.86 | 37.26 | 15.36 | 55.30 | 29.49 | +Note: The `blink` and `potion` models are our static models. + +| Model | Mean (Task) | Mean (TaskType) | Class | Clust | PairClass | Rank | Ret | STS | Sum | +|:--|--:|--:|--:|--:|--:|--:|--:|--:|--:| +| [all-MiniLM-L6-v2 (384d)](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | 59.03 | 55.93 | 69.25 | 44.90 | 82.37 | 47.14 | 42.92 | 78.95 | 25.96 | +| [blink-8M](https://huggingface.co/minishlab/blink-8M) | 55.35 | 52.26 | 67.88 | 41.49 | 78.42 | 43.12 | 38.86 | 73.56 | 22.48 | +| [lattice-retrieval](https://huggingface.co/erikkaum/lattice-retrieval) | 55.24 | 52.12 | 68.25 | 42.11 | 77.51 | 42.96 | 38.01 | 73.41 | 22.56 | +| [bekko-static-embedding-v1](https://huggingface.co/hotchpotch/bekko-static-embedding-v1) | 55.21 | 52.07 | 68.42 | 40.77 | 78.32 | 42.54 | 37.62 | 74.60 | 22.24 | +| [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) | 54.02 | 51.58 | 70.48 | 41.49 | 77.33 | 42.52 | 31.94 | 73.17 | 24.14 | +| [potion-retrieval-32M](https://huggingface.co/minishlab/potion-retrieval-32M) | 53.70 | 50.54 | 66.67 | 41.76 | 75.94 | 41.95 | 34.64 | 72.89 | 19.95 | +| [potion-base-8M](https://huggingface.co/minishlab/potion-base-8M) | 53.30 | 51.07 | 70.41 | 39.88 | 76.62 | 41.79 | 31.22 | 72.45 | 25.14 | +| [static-retrieval-mrl-en-v1](https://huggingface.co/sentence-transformers/static-retrieval-mrl-en-v1) | 52.00 | 49.08 | 63.16 | 39.98 | 74.68 | 41.57 | 33.87 | 71.35 | 18.95 | +| [GloVe_300d](https://huggingface.co/sentence-transformers/average_word_embeddings_glove.6B.300d) | 46.13 | 45.82 | 62.73 | 37.16 | 72.48 | 38.28 | 21.80 | 61.52 | 26.78 |
@@ -36,33 +40,31 @@ For readability, the MTEB task names are abbreviated as follows: - Sum: Summarization
-The results show that [blink-8M](https://huggingface.co/minishlab/blink-8m) is the most performant static embedding model. It reaches 98.96% of the performance of [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) with an average MTEB score of 55.35 while being orders of magnitude faster. +The results show that [blink-8M](https://huggingface.co/minishlab/blink-8M) is the most performant static embedding model, ahead of the larger [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) with about a quarter of the parameters. It reaches 93.77% of the performance of [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) with a mean task score of 55.35, while being orders of magnitude faster. -The figure below shows the relationship between the number of sentences per second and the average MTEB score. The circle sizes correspond to the number of parameters in the models (larger = more parameters). +The figure below shows the relationship between the number of sentences per second and the mean MTEB score over tasks. The circle sizes correspond to the number of parameters in the models (larger = more parameters). This plot shows that [blink-8M](https://huggingface.co/minishlab/blink-8m) is much faster than the other models, while still being competitive in terms of performance with the [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) model. NOTE: all models encode the same 1,000 Wikipedia articles on CPU. Model2Vec models are truncated to 512 tokens, like [bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5). All sentence-transformers models are run with the [sentence-transformers](https://github.com/UKPLab/sentence-transformers) library's default settings for `encode`. The script is [make_speed_vs_mteb_plot.py](make_speed_vs_mteb_plot.py). | ![Average MTEB score plotted against samples per second](../assets/images/speed_vs_mteb_plot.svg) | |:--:| -|*Figure: The average MTEB score plotted against sentences per second. The circle size indicates model size.*| +|*Figure: The mean MTEB score plotted against sentences per second. The circle size indicates model size.*| ## MMTEB Results (Multilingual) -The results for the multilingual models are shown in the table below. We compare against the [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) model, as well as other multilingual static embedding models. +The results for the multilingual models are shown in the table below. We compare against the [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) model, as well as other multilingual static embedding models, on [MTEB(Multilingual, v2)](https://github.com/embeddings-benchmark/mteb) (131 tasks). As for English, every static model is evaluated at 256 dimensions. LaBSE is shown at its native 768 dimensions. Note: the MMTEB leaderboard ranks models using a [Borda count](https://en.wikipedia.org/wiki/Borda_count) over per-task ranks rather than a simple average. This rewards models that perform consistently well across all tasks, rather than those that excel on one task type while performing poorly on others. -| Model | Mean (Task) | Mean (TaskType) | BitMining | Class | Clust | InstRet | MultiClass | PairClass | Rank | Ret | STS | -| :---------------------------------------- | :---------- | :-------------- | :------------ | :------------- | :--------- | :-------------------- | :------------------------ | :------------------ | :-------- | :-------- | :-------- | -| [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) | 52.07 | 45.65 | 76.35 | 54.60 | 38.08 | −3.00 | 20.12 | 75.97 | 50.20 | 33.17 | 65.35 | -| [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | 51.60 | 45.11 | 57.03 | 52.11 | 39.67 | −1.33 | 17.47 | 73.47 | 52.61 | 47.52 | 67.47 | -| [static-similarity-mrl-multilingual-v1](https://huggingface.co/sentence-transformers/static-similarity-mrl-multilingual-v1) | 47.21 | 41.28 | 50.62 | 48.60 | 30.67 | −1.24 | 13.83 | 74.34 | 49.45 | 41.21 | 64.02 | -| [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M) | 47.20 | 40.18 | 40.72 | 52.36 | 37.63 | −2.08 | 15.11 | 71.39 | 47.39 | 37.86 | 61.23 | -| [M2V_multilingual_output](https://huggingface.co/minishlab/M2V_multilingual_output) | 42.13 | 35.89 | 36.88 | 49.75 | 30.09 | −0.07 | 14.34 | 69.74 | 41.51 | 25.42 | 55.33 | - -As can be seen, [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) is the most performant static multilingual model, reaching 99.10% of the performance of [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) with half the parameters of [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M). It outperforms [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) on clustering, reranking, retrieval and STS, and outperforms the other static models on every task type except classification, pair classification and instruction retrieval. +| Model | Mean (Task) | Mean (TaskType) | BitMining | Class | Clust | InstRet | MultiClass | PairClass | Rank | Ret | STS | +|:--|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:| +| [LaBSE (768d)](https://huggingface.co/sentence-transformers/LaBSE) | 52.06 | 45.65 | 76.35 | 54.60 | 38.08 | −3.00 | 20.12 | 75.94 | 50.20 | 33.17 | 65.35 | +| [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | 51.60 | 45.11 | 57.03 | 52.11 | 39.67 | −1.33 | 17.47 | 73.47 | 52.61 | 47.52 | 67.47 | +| [bekko-static-embedding-v1](https://huggingface.co/hotchpotch/bekko-static-embedding-v1) | 48.37 | 41.64 | 37.30 | 50.41 | 39.84 | −1.79 | 14.32 | 72.60 | 50.78 | 47.62 | 63.72 | +| [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M) | 47.67 | 40.59 | 40.72 | 52.34 | 37.88 | −1.65 | 15.15 | 71.38 | 47.08 | 41.22 | 61.15 | +| [static-similarity-mrl-multilingual-v1](https://huggingface.co/sentence-transformers/static-similarity-mrl-multilingual-v1) | 46.88 | 41.06 | 48.50 | 47.98 | 34.46 | −0.86 | 14.29 | 73.16 | 48.83 | 39.49 | 63.67 | -Among the older static models, [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M) reaches 90.65% of the performance of [LaBSE](https://huggingface.co/sentence-transformers/LaBSE). There are differences per task. The [static-similarity-mrl-multilingual-v1](https://huggingface.co/sentence-transformers/static-similarity-mrl-multilingual-v1) model is better for retrieval and STS tasks (which can be explained by the fact that it's trained for STS), while the [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M) model is better for classification and clustering tasks. It is important to note that the [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M) model supports a total of 101 languages, while [static-similarity-mrl-multilingual-v1](https://huggingface.co/sentence-transformers/static-similarity-mrl-multilingual-v1) supports only 50 languages. It is also important to note that MMTEB does not include tasks for every language, and there may be a bias towards larger languages. +As can be seen, [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) is the most performant static multilingual model, reaching 99.12% of the performance of [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) with a mean task score of 51.60, while being much smaller. LaBSE is still far ahead on bitext mining, while blink-multilingual-64M is better on retrieval, reranking, STS and clustering. Note that MMTEB does not include tasks for every language, and there may be a bias towards larger languages.
@@ -82,19 +84,30 @@ For readability, the MMTEB task names are abbreviated as follows:
-## Retrieval Results +## CoIR Results (Code) -We used to release models specifically designed for retrieval, such as [potion-retrieval-32M](https://huggingface.co/minishlab/potion-retrieval-32M). Our newer general-purpose model, [blink-8M](https://huggingface.co/minishlab/blink-8m), now outperforms them on retrieval, so there is no longer a need for a separate retrieval model. The results are shown in the table below, with [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) included as a transformer baseline and [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) as a general-purpose static baseline. +[blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) is evaluated on [CoIR](https://github.com/CoIR-team/coir), the standard code retrieval benchmark: 10 tasks covering text-to-code, code-to-code, code-to-text and code Q&A. All scores are nDCG@10. We compare against BM25 and our older code models. -| Model | Retrieval Score | -|:-----------------------|------------------:| -| [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | 42.92 | -| [blink-8M](https://huggingface.co/minishlab/blink-8m) | 38.86 | -| [potion-retrieval-32M](https://huggingface.co/minishlab/potion-retrieval-32M) | 35.06 | -| [static-retrieval-mrl-en-v1](https://huggingface.co/sentence-transformers/static-retrieval-mrl-en-v1) | 34.95 | -| [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) | 32.67 | +| Model | Mean | Apps | CSN | CFMT | CFST | CSNCC | CTContest | CTDL | CosQA | SO | Text2SQL | +|:--|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:| +| [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) | 46.82 | 6.08 | 53.59 | 51.72 | 65.87 | 51.42 | 57.31 | 38.34 | 24.34 | 64.03 | 55.45 | +| BM25 | 42.31 | 4.76 | 40.86 | 59.19 | 68.15 | 53.97 | 47.78 | 34.42 | 18.75 | 70.26 | 24.94 | +| [potion-code-16M-v2](https://huggingface.co/minishlab/potion-code-16M-v2) | 40.67 | 5.05 | 46.34 | 46.50 | 54.40 | 43.70 | 48.55 | 33.48 | 24.39 | 60.13 | 44.12 | +| [potion-code-16M](https://huggingface.co/minishlab/potion-code-16M) | 38.78 | 4.11 | 43.10 | 45.09 | 52.24 | 43.09 | 45.40 | 32.81 | 22.19 | 58.10 | 41.66 | + +
+ Task Abbreviations + +- CSN: CodeSearchNet +- CFMT: CodeFeedbackMT +- CFST: CodeFeedbackST +- CSNCC: CodeSearchNetCC +- CTContest: CodeTransContest +- CTDL: CodeTransDL +- SO: StackOverflow +
-As can be seen, [blink-8M](https://huggingface.co/minishlab/blink-8m) is the most performant static retrieval model, reaching 90.54% of the performance of [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) with a retrieval score of 38.86. Even though it is a general-purpose model, it outperforms the retrieval-specific [potion-retrieval-32M](https://huggingface.co/minishlab/potion-retrieval-32M) by 3.8 points, with a quarter of the parameters. +[blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) scores 4.51 points above BM25 and 6.15 above potion-code-16M-v2. It is best on 5 of 10 tasks, while BM25 is still ahead on CodeFeedback, CodeSearchNetCC and StackOverflow. Combining it with BM25 in a hybrid search raises the mean to 49.36. For more code benchmarks, see the [model card](https://huggingface.co/minishlab/blink-code-16M). ## Training Results diff --git a/results/make_speed_vs_mteb_plot.py b/results/make_speed_vs_mteb_plot.py index 4ecb77ac..1eedc79d 100644 --- a/results/make_speed_vs_mteb_plot.py +++ b/results/make_speed_vs_mteb_plot.py @@ -41,14 +41,14 @@ class Result: RESULTS: list[Result] = [ - Result("bge-base-en-v1.5", "BAAI/bge-base-en-v1.5", "ST", "Transformer", 60.77, 109.0), - Result("all-MiniLM-L6-v2", "sentence-transformers/all-MiniLM-L6-v2", "ST", "Transformer", 55.93, 23.0), + Result("bge-base-en-v1.5", "BAAI/bge-base-en-v1.5", "ST", "Transformer", 65.14, 109.0), + Result("all-MiniLM-L6-v2", "sentence-transformers/all-MiniLM-L6-v2", "ST", "Transformer", 59.03, 23.0), Result( "GloVe 6B 300d", "sentence-transformers/average_word_embeddings_glove.6B.300d", "ST", "Word embeddings", - 45.82, + 46.13, 120.0, ), Result("blink-8M", "minishlab/blink-8m", "M2V", "Model2Vec", 55.35, 7.68), @@ -128,7 +128,7 @@ def make_plot(speeds: dict[str, float]) -> plt.Figure: ax.xaxis.set_major_locator(FixedLocator([10**exponent for exponent in range(1, 7)])) ax.xaxis.set_minor_locator(NullLocator()) ax.xaxis.set_major_formatter(FuncFormatter(_format_speed)) - ax.set_ylim(44, 63) + ax.set_ylim(44, 68) ax.set_yticks(range(45, 65, 5)) ax.grid(True, color=GRID, linewidth=1) @@ -139,7 +139,7 @@ def make_plot(speeds: dict[str, float]) -> plt.Figure: ax.tick_params(colors=TEXT_SECONDARY, labelsize=9, length=0, pad=6) ax.set_xlabel("Samples per second (log scale)", color=TEXT_SECONDARY, fontsize=10, labelpad=8) - ax.set_ylabel("Average MTEB score", color=TEXT_SECONDARY, fontsize=10, labelpad=8) + ax.set_ylabel("MTEB score (mean over tasks)", color=TEXT_SECONDARY, fontsize=10, labelpad=8) fig.text(0.06, 0.95, "MTEB score vs. encoding speed", fontsize=14, weight="bold", color=TEXT_PRIMARY) fig.text( From 37eb68bb751f2acca9401f2fa7488d9e9866701d Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 11:18:57 +0100 Subject: [PATCH 3/8] docs: trim sparse quickstart and add sparse results --- README.md | 9 ++++----- results/README.md | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fdacb3dc..4b54fd8c 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,9 @@ model = StaticModel.from_pretrained("minishlab/blink-8M") embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."]) ``` -For advanced usage, see our [inference docs](https://minish.ai/packages/model2vec/inference). - ### Sparse retrieval -Sparse models give each text a weight per token of the vocabulary, so you can store them in any inverted index, just like BM25. Unlike BM25, they need no corpus statistics: a document's representation depends only on its own text. Queries aren't encoded by a model at all, just weighted per token. Install the `sparse` extra with: +Sparse models can be stored in any inverted index, just like BM25, but need no corpus statistics. Install the `sparse` extra with: ```bash pip install model2vec[sparse] @@ -72,7 +70,7 @@ queries = model.encode_query(["Is it safe to go alone?"]) scores = queries @ documents.T ``` -`encode_document` and `encode_query` return `scipy.sparse` matrices with one column per token of the vocabulary. Sparse models can also be loaded as a [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) `SparseEncoder` with `trust_remote_code=True`. +Sparse models can also be loaded as a [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) `SparseEncoder`. ### Training a classifier @@ -101,7 +99,7 @@ classifier.fit(ds["train"]["text"], ds["train"]["label"]) classification_report = classifier.evaluate(ds["test"]["text"], ds["test"]["label"]) ``` -Trained models run without `torch`. For advanced usage, see our [training docs](https://minish.ai/packages/model2vec/training). You can also distill your own static model from any Sentence Transformer, see our [distillation docs](https://minish.ai/packages/model2vec/distillation). +Trained models run without `torch`. You can also distill your own static model from any Sentence Transformer, see our [distillation docs](https://minish.ai/packages/model2vec/distillation). ## Main Features @@ -140,6 +138,7 @@ These models are available on the [HuggingFace hub](https://huggingface.co/minis We have performed extensive experiments to evaluate the performance of Model2Vec models. The results are documented in the [results](results/README.md) folder: - [MTEB Results](results/README.md#mteb-results-english) - [MMTEB Results](results/README.md#mmteb-results-multilingual) +- [Sparse Retrieval Results](results/README.md#sparse-retrieval-results) - [CoIR Results](results/README.md#coir-results-code) - [Training Results](results/README.md#training-results) diff --git a/results/README.md b/results/README.md index eee97bd2..0cef52c4 100644 --- a/results/README.md +++ b/results/README.md @@ -3,6 +3,7 @@ This document contains the results of the Model2Vec project. The results are presented in the following sections: - [MTEB Results (English)](#mteb-results-english) - [MMTEB Results (Multilingual)](#mmteb-results-multilingual) +- [Sparse Retrieval Results](#sparse-retrieval-results) - [CoIR Results (Code)](#coir-results-code) - [Training Results](#training-results) @@ -84,6 +85,24 @@ For readability, the MMTEB task names are abbreviated as follows: +## Sparse Retrieval Results + + +Our sparse model is a drop-in replacement for BM25, so we compare it against BM25 and against [blink-8M](https://huggingface.co/minishlab/blink-8M), the dense static model it is built from. All scores are nDCG@10. + +| Benchmark | blink-8M | BM25 | `` | +|:--|--:|--:|--:| +| BEIR-15 | 37.7 | 41.3 | 42.3 | +| Decon-BEIR (12) | 46.7 | 49.8 | 51.6 | +| RTEB(eng, beta) | 30.8 | 32.2 | 39.4 | + +- **BEIR-15** is BEIR with CQADupStack (the mean over its 12 subforums) and MS MARCO dev. +- **Decon-BEIR** is LightOn's decontaminated BEIR: 12 datasets, excluding Climate-FEVER and FEVER. +- **RTEB** is the main RTEB English set. +- **BM25** is bm25s Lucene BM25 with k1 = 0.9 and b = 0.4, over stemmed English words without stopwords (Pyserini's defaults). + +The sparse model outperforms BM25 on all three benchmarks without using any corpus statistics, and outperforms blink-8M by a wide margin. For per-dataset results, see the model card. + ## CoIR Results (Code) [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) is evaluated on [CoIR](https://github.com/CoIR-team/coir), the standard code retrieval benchmark: 10 tasks covering text-to-code, code-to-code, code-to-text and code Q&A. All scores are nDCG@10. We compare against BM25 and our older code models. From 4d54757b7482e97801767e4133215b25c7c7bef7 Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 11:27:20 +0100 Subject: [PATCH 4/8] docs: move baseline dimensions to table notes --- results/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/results/README.md b/results/README.md index 0cef52c4..8637f960 100644 --- a/results/README.md +++ b/results/README.md @@ -11,13 +11,13 @@ This document contains the results of the Model2Vec project. The results are pre Model2Vec is evaluated on [MTEB(eng, v2)](https://github.com/embeddings-benchmark/mteb) (41 tasks). Models are ranked by the mean over tasks. The results are shown in the table below. -Every static model is evaluated at 256 dimensions. Models with more dimensions are truncated to their first 256 dimensions and use L2 normalized embeddings, even if the original model did not have normalization. all-MiniLM-L6-v2 (384 dimensions) and GloVe (300 dimensions) are shown at their native size as references. +Every static model is evaluated at 256 dimensions. Models with more dimensions are truncated to their first 256 dimensions and use L2 normalized embeddings, even if the original model did not have normalization. all-MiniLM-L6-v2 (384 dimensions) and GloVe (300 dimensions) cannot be truncated, so they are evaluated at their native size. Note: The `blink` and `potion` models are our static models. | Model | Mean (Task) | Mean (TaskType) | Class | Clust | PairClass | Rank | Ret | STS | Sum | |:--|--:|--:|--:|--:|--:|--:|--:|--:|--:| -| [all-MiniLM-L6-v2 (384d)](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | 59.03 | 55.93 | 69.25 | 44.90 | 82.37 | 47.14 | 42.92 | 78.95 | 25.96 | +| [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | 59.03 | 55.93 | 69.25 | 44.90 | 82.37 | 47.14 | 42.92 | 78.95 | 25.96 | | [blink-8M](https://huggingface.co/minishlab/blink-8M) | 55.35 | 52.26 | 67.88 | 41.49 | 78.42 | 43.12 | 38.86 | 73.56 | 22.48 | | [lattice-retrieval](https://huggingface.co/erikkaum/lattice-retrieval) | 55.24 | 52.12 | 68.25 | 42.11 | 77.51 | 42.96 | 38.01 | 73.41 | 22.56 | | [bekko-static-embedding-v1](https://huggingface.co/hotchpotch/bekko-static-embedding-v1) | 55.21 | 52.07 | 68.42 | 40.77 | 78.32 | 42.54 | 37.62 | 74.60 | 22.24 | @@ -53,13 +53,13 @@ NOTE: all models encode the same 1,000 Wikipedia articles on CPU. Model2Vec mode ## MMTEB Results (Multilingual) -The results for the multilingual models are shown in the table below. We compare against the [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) model, as well as other multilingual static embedding models, on [MTEB(Multilingual, v2)](https://github.com/embeddings-benchmark/mteb) (131 tasks). As for English, every static model is evaluated at 256 dimensions. LaBSE is shown at its native 768 dimensions. +The results for the multilingual models are shown in the table below. We compare against the [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) model, as well as other multilingual static embedding models, on [MTEB(Multilingual, v2)](https://github.com/embeddings-benchmark/mteb) (131 tasks). As for English, every static model is evaluated at 256 dimensions. LaBSE cannot be truncated, so it is evaluated at its native 768 dimensions. Note: the MMTEB leaderboard ranks models using a [Borda count](https://en.wikipedia.org/wiki/Borda_count) over per-task ranks rather than a simple average. This rewards models that perform consistently well across all tasks, rather than those that excel on one task type while performing poorly on others. | Model | Mean (Task) | Mean (TaskType) | BitMining | Class | Clust | InstRet | MultiClass | PairClass | Rank | Ret | STS | |:--|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:| -| [LaBSE (768d)](https://huggingface.co/sentence-transformers/LaBSE) | 52.06 | 45.65 | 76.35 | 54.60 | 38.08 | −3.00 | 20.12 | 75.94 | 50.20 | 33.17 | 65.35 | +| [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) | 52.06 | 45.65 | 76.35 | 54.60 | 38.08 | −3.00 | 20.12 | 75.94 | 50.20 | 33.17 | 65.35 | | [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | 51.60 | 45.11 | 57.03 | 52.11 | 39.67 | −1.33 | 17.47 | 73.47 | 52.61 | 47.52 | 67.47 | | [bekko-static-embedding-v1](https://huggingface.co/hotchpotch/bekko-static-embedding-v1) | 48.37 | 41.64 | 37.30 | 50.41 | 39.84 | −1.79 | 14.32 | 72.60 | 50.78 | 47.62 | 63.72 | | [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M) | 47.67 | 40.59 | 40.72 | 52.34 | 37.88 | −1.65 | 15.15 | 71.38 | 47.08 | 41.22 | 61.15 | From 69729c16c19488b384dfd3fd6e85f9102743359f Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 11:36:29 +0100 Subject: [PATCH 5/8] docs: use placeholders for unreleased sparse results --- results/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/results/README.md b/results/README.md index 8637f960..3d5789e2 100644 --- a/results/README.md +++ b/results/README.md @@ -92,16 +92,16 @@ Our sparse model is a drop-in replacement for BM25, so we compare it against BM2 | Benchmark | blink-8M | BM25 | `` | |:--|--:|--:|--:| -| BEIR-15 | 37.7 | 41.3 | 42.3 | -| Decon-BEIR (12) | 46.7 | 49.8 | 51.6 | -| RTEB(eng, beta) | 30.8 | 32.2 | 39.4 | +| BEIR-15 | 37.7 | 41.3 | TBD | +| Decon-BEIR (12) | 46.7 | 49.8 | TBD | +| RTEB(eng, beta) | 30.8 | 32.2 | TBD | - **BEIR-15** is BEIR with CQADupStack (the mean over its 12 subforums) and MS MARCO dev. - **Decon-BEIR** is LightOn's decontaminated BEIR: 12 datasets, excluding Climate-FEVER and FEVER. - **RTEB** is the main RTEB English set. - **BM25** is bm25s Lucene BM25 with k1 = 0.9 and b = 0.4, over stemmed English words without stopwords (Pyserini's defaults). -The sparse model outperforms BM25 on all three benchmarks without using any corpus statistics, and outperforms blink-8M by a wide margin. For per-dataset results, see the model card. + ## CoIR Results (Code) From b7ef2161fcdebdcceecefb7ce9b7fb08641c5339 Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 11:41:50 +0100 Subject: [PATCH 6/8] docs: drop Sentence Transformers note from sparse quickstart --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 4b54fd8c..9fa2edde 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,6 @@ queries = model.encode_query(["Is it safe to go alone?"]) scores = queries @ documents.T ``` -Sparse models can also be loaded as a [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) `SparseEncoder`. - ### Training a classifier You can fine-tune a pre-trained model for classification, similarity, regression or pair similarity (for example query-document retrieval). Install the `train` extra with: From 7ae201451eb8356a69ea98f6cd6009e8c36d936e Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 11:48:21 +0100 Subject: [PATCH 7/8] chore: relock --- uv.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/uv.lock b/uv.lock index e6cc27e9..c018ffc4 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 5 +revision = 3 requires-python = ">=3.10" resolution-markers = [ "python_full_version >= '3.14' and sys_platform == 'win32'", @@ -19,7 +19,7 @@ resolution-markers = [ [options] exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values. -exclude-newer-span = "P3D" +exclude-newer-span = "P1W" [options.exclude-newer-package] model2vec-rs = false @@ -1323,7 +1323,7 @@ requires-dist = [ { name = "huggingface-hub", specifier = ">=1.0.0" }, { name = "ipython", marker = "extra == 'dev'" }, { name = "jinja2" }, - { name = "model2vec-rs", specifier = ">=0.5.1,<0.6.0" }, + { name = "model2vec-rs", specifier = ">=0.6.0,<0.7.0" }, { name = "mteb", marker = "extra == 'integration'" }, { name = "mypy", marker = "extra == 'dev'" }, { name = "numpy" }, @@ -1353,22 +1353,22 @@ provides-extras = ["dev", "distill", "onnx", "train", "quantization", "sparse", [[package]] name = "model2vec-rs" -version = "0.5.1" +version = "0.6.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, { name = "numpy", version = "2.4.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/f4/90/a1b1320c93e169f052ff579102915806aa589d75d551add9b80a2d7e7212/model2vec_rs-0.5.1.tar.gz", hash = "sha256:db1ab1a79f06f5e6b0dc024704ab3be656f71bac80a79298ef71458384cd06da", size = 153596, upload-time = "2026-11-24T06:28:09.687Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f3/c4/5a8e36dfd66872ad461568fc85c5586657b568e73cb0fa74d0dde37571f0/model2vec_rs-0.6.0.tar.gz", hash = "sha256:f1353fcafb3ed388aa709f917df839d319e3eb272d01ae862dafa0bd27480b77", size = 157069, upload-time = "2026-12-04T09:15:49.652Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/43/cf/5eeb55291d1d365419a6ff1f8529be7be9408d690a43f28112de17bc2f86/model2vec_rs-0.5.1-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:19cbb19555229d5232cbd246ae11b7c1941def84048bf3871826db73e71cc8c2", size = 3422771, upload-time = "2026-11-24T06:27:56.665Z" }, - { url = "https://files.pythonhosted.org/packages/53/0e/7c63cd068a92dbfa7f41930460a8ff7a5f30ffb60d49458c76e3018fa994/model2vec_rs-0.5.1-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:aa394460f15edd38cee31951d56bbf1d226ada2dea7baaaed373e3e9eb46c25a", size = 3320494, upload-time = "2026-11-24T06:27:58.298Z" }, - { url = "https://files.pythonhosted.org/packages/35/ad/a2e1f6576599918f731e93687607d30fe0af89c336d738bc5f090765ffe6/model2vec_rs-0.5.1-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:8814f1a9aa24d291b07f4a934b0fa57ddf72376552f1db4e7f61a99923de6cdf", size = 3785520, upload-time = "2026-11-24T06:27:59.659Z" }, - { url = "https://files.pythonhosted.org/packages/0c/77/7634b609591c3f957a09b289acfde2b5f86488d952fc640438dc2db5df0c/model2vec_rs-0.5.1-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:4e71f701a1d389d5f7e7c021cd940b97bfc466f4bd64d5e0dd76f4ef81e59ab8", size = 3731888, upload-time = "2026-11-24T06:28:01.104Z" }, - { url = "https://files.pythonhosted.org/packages/53/93/e881640e7e94bda8278f1996ecb7e9755105bc2b34f1477d3b0aa68942d9/model2vec_rs-0.5.1-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:e8271caa08343948d3d7459e065e1f2d27dfed664063247057c11604b54058f7", size = 10227143, upload-time = "2026-11-24T06:28:02.824Z" }, - { url = "https://files.pythonhosted.org/packages/81/ae/dc39169e6f3a38aa1063776b3e596e28e3a811c12771e46c37c8b4dc2b86/model2vec_rs-0.5.1-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:92f0c0ee68920847ca51d4b42bd17d2b2637326fbde22947f9b40f50efef1d17", size = 10553805, upload-time = "2026-11-24T06:28:04.999Z" }, - { url = "https://files.pythonhosted.org/packages/35/4c/4f75e995ce8f480dd6f3cbbc1103f452700422931b92f6d35382a04d4835/model2vec_rs-0.5.1-cp310-abi3-win_amd64.whl", hash = "sha256:34273ad17774ed90baa16c04313a805de5be08621966b45f0eca2a1df4b5b794", size = 3142384, upload-time = "2026-11-24T06:28:06.764Z" }, - { url = "https://files.pythonhosted.org/packages/fd/c6/ba5d52cffd746a0ec160f001d0595baecdd7d5a7be9c4862ced809f5d9e8/model2vec_rs-0.5.1-cp310-abi3-win_arm64.whl", hash = "sha256:aa89947cd02ec2f6b0ffe60504b3efd2d77e8e32205ebbae846f5da234c77a09", size = 2992357, upload-time = "2026-11-24T06:28:08.33Z" }, + { url = "https://files.pythonhosted.org/packages/8a/b0/c83f8cc51b4035a93018398578589280b24c25808adfe6cbce88a70291ea/model2vec_rs-0.6.0-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:78dbdc90ccc2bbeb910119318a8843c32c1b8ae2006c3bf2789d14da8e27a461", size = 3445704, upload-time = "2026-12-04T09:15:36.484Z" }, + { url = "https://files.pythonhosted.org/packages/ad/e0/12e50e0d3242d55239fcc106b1bdcb4b8f41a461cfb2d5874dc49a36c389/model2vec_rs-0.6.0-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:31a505dd1dbf024025302f1e2fcd0c641443541e30159640eabcce75b22e6011", size = 3352945, upload-time = "2026-12-04T09:15:37.895Z" }, + { url = "https://files.pythonhosted.org/packages/f0/5f/0dcc2ea5bb3da2ad4a68ecd85fbbdff5be57aafb209fc2a73f5a6b8f8f47/model2vec_rs-0.6.0-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:5fd84491455b2ca7774aa3168ad787b3742355553e019b3601dbb06b67a7c51e", size = 3818899, upload-time = "2026-12-04T09:15:39.535Z" }, + { url = "https://files.pythonhosted.org/packages/0f/fe/143ecccc1f6db5cec89685e841f601fd1a51f7032fa731aa33d06e34f5cd/model2vec_rs-0.6.0-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:c4724a0dac196be16a5351af56fe46ef9c64c03ed6c7495c8d7cc140f7cee9b7", size = 3754050, upload-time = "2026-12-04T09:15:41.024Z" }, + { url = "https://files.pythonhosted.org/packages/32/f8/43ae3d3ac642849e6060d5aca2138a3eca599df0c7a0dbe90661947ce57a/model2vec_rs-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:61ae9dd1391da382f43ce72590c9e4158209f015290bd04367e44d9dadb2c979", size = 10260797, upload-time = "2026-12-04T09:15:43.265Z" }, + { url = "https://files.pythonhosted.org/packages/fb/c3/4e99e6adb96ebb417e5d09f7325b07e6313d6fbcf03f0878a94d5af9e488/model2vec_rs-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:91573c0140e90a0cd0279968aef8c15d9960b16a317a5e1811ac4a4aea9dcebd", size = 10579214, upload-time = "2026-12-04T09:15:45.295Z" }, + { url = "https://files.pythonhosted.org/packages/4a/26/eba6b6a0127eec1894119868b135287ef45de3bcca68c655c84cbe55f9fc/model2vec_rs-0.6.0-cp310-abi3-win_amd64.whl", hash = "sha256:506bfa9a8b60583f8632b08f5cf793a5dd89c4afc0ddb01e2f16f9f3761136b9", size = 3160865, upload-time = "2026-12-04T09:15:47.168Z" }, + { url = "https://files.pythonhosted.org/packages/f2/fa/48600b2f7dba7c8e30d31ef2edb932dac4cec83114cb588b5e9ad0948773/model2vec_rs-0.6.0-cp310-abi3-win_arm64.whl", hash = "sha256:d3a61e70abbfbfa01c9032f6db6e82498a329696ca4a631f8f78fb22c5819de8", size = 3009568, upload-time = "2026-12-04T09:15:48.415Z" }, ] [[package]] From 3450db6c0ad0d2950b2e8dad9a4ecde07688c54c Mon Sep 17 00:00:00 2001 From: Pringled Date: Fri, 4 Dec 2026 15:00:28 +0100 Subject: [PATCH 8/8] docs: name the sparse model shimmer --- README.md | 8 +++----- results/README.md | 15 +++++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9fa2edde..0cfe06fe 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,10 @@ pip install model2vec[sparse] Then encode documents and queries, and score them with a dot product: - ```python from model2vec.sparse import SparseStaticModel -model = SparseStaticModel.from_pretrained("minishlab/") +model = SparseStaticModel.from_pretrained("minishlab/shimmer") documents = model.encode_document(["It's dangerous to go alone!", "It's a secret to everybody."]) queries = model.encode_query(["Is it safe to go alone?"]) @@ -104,7 +103,7 @@ Trained models run without `torch`. You can also distill your own static model f - **Dense and sparse models**: dense embeddings for semantic search, classification and clustering, and sparse models for inverted-index retrieval as a replacement for BM25. - **Multilingual and code**: [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) reaches 99% of the performance of [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) on MMTEB, and [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) outperforms BM25 on code retrieval (CoIR). See our [results](results/README.md). -- **Small**: our [best dense model](https://huggingface.co/minishlab/blink-8M) has 7.7M parameters and is ~30 MB on disk. Our sparse model has 76k parameters and is under 1 MB. +- **Small**: our [best dense model](https://huggingface.co/minishlab/blink-8M) has 7.7M parameters and is ~30 MB on disk. Our sparse model, [shimmer](https://huggingface.co/minishlab/shimmer), has 76k parameters and is under 1 MB. - **Fast on CPU**: encoding is a token lookup and a sum, done in Rust by [model2vec-rs](https://github.com/MinishLab/model2vec-rs). - **Lightweight dependencies**: the base package needs no `torch` or `transformers`, just `numpy`, `tokenizers` and the Rust backend. - **Fine-tuning**: fine-tune models for classification, similarity, regression or pair similarity, and run them without `torch`. A fine-tuned classifier scores within 1 point of a fully fine-tuned [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) over 26 datasets, while running about 300 times faster (see our [training results](results/README.md#training-results)). @@ -121,13 +120,12 @@ For details on the Rust backend and which dtypes to use, see [internals](docs/in These models are available on the [HuggingFace hub](https://huggingface.co/minishlab) and can be loaded with `from_pretrained`. - | Model | Language | Base model | Params | Task | |-----------------------------------------------------------------------|--------------|------------------------------------------------------------------|---------|------------------| | [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 | | [blink-multilingual-64M](https://huggingface.co/minishlab/blink-multilingual-64M) | Multilingual | [bge-m3](https://huggingface.co/BAAI/bge-m3) | 64.0M | General | | [blink-code-16M](https://huggingface.co/minishlab/blink-code-16M) | Code | [CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed) | 16.0M | Code | -| `` | English | [blink-8M](https://huggingface.co/minishlab/blink-8M) | 76k | Sparse retrieval | +| [shimmer](https://huggingface.co/minishlab/shimmer) | English | [blink-8M](https://huggingface.co/minishlab/blink-8M) | 76k | Sparse retrieval | diff --git a/results/README.md b/results/README.md index 3d5789e2..2f003e0c 100644 --- a/results/README.md +++ b/results/README.md @@ -87,21 +87,20 @@ For readability, the MMTEB task names are abbreviated as follows: ## Sparse Retrieval Results - -Our sparse model is a drop-in replacement for BM25, so we compare it against BM25 and against [blink-8M](https://huggingface.co/minishlab/blink-8M), the dense static model it is built from. All scores are nDCG@10. +Our sparse model, [shimmer](https://huggingface.co/minishlab/shimmer), is a drop-in replacement for BM25, so we compare it against BM25 and against [blink-8M](https://huggingface.co/minishlab/blink-8M), the dense static model it is built from. All scores are nDCG@10. -| Benchmark | blink-8M | BM25 | `` | +| Benchmark | blink-8M | BM25 | shimmer | |:--|--:|--:|--:| -| BEIR-15 | 37.7 | 41.3 | TBD | -| Decon-BEIR (12) | 46.7 | 49.8 | TBD | -| RTEB(eng, beta) | 30.8 | 32.2 | TBD | +| BEIR-15 | 37.7 | 41.3 | 42.3 | +| Decon-BEIR | 46.7 | 49.8 | 50.0 | +| RTEB(eng, beta) | 30.8 | 32.2 | 39.4 | - **BEIR-15** is BEIR with CQADupStack (the mean over its 12 subforums) and MS MARCO dev. -- **Decon-BEIR** is LightOn's decontaminated BEIR: 12 datasets, excluding Climate-FEVER and FEVER. +- **Decon-BEIR** is LightOn's decontaminated BEIR. - **RTEB** is the main RTEB English set. - **BM25** is bm25s Lucene BM25 with k1 = 0.9 and b = 0.4, over stemmed English words without stopwords (Pyserini's defaults). - +[shimmer](https://huggingface.co/minishlab/shimmer) outperforms BM25 on all three benchmarks without using any corpus statistics, and outperforms blink-8M by a wide margin. For per-dataset results, see the [model card](https://huggingface.co/minishlab/shimmer). ## CoIR Results (Code)