Run this model with HF Jobs

Run minishlab/shimmer on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/minishlab/shimmer. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/minishlab/shimmer on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
shimmer / README.md
Pringled's picture
New document formula (model2vec 0.12.1): k1 0.2, length exponent 0.4; updated results and plot
7b8c1f2 verified
|
Raw History Blame Contribute Delete
12.2 kB
metadata
language:
  - en
library_name: model2vec
license: mit
model_name: shimmer
tags:
  - embeddings
  - static-embeddings
  - sparse
  - retrieval
  - information-retrieval
base_model: minishlab/blink-8M
shimmer logo

shimmer is a sparse retrieval model built from the static embeddings of minishlab/blink-8M, meant to replace BM25. Documents are indexed with a tokenizer and a sparse lookup, which runs at hundreds of thousands of documents per second. Queries are weighted with a per-token constant, which means that querying is encoding-free. All weights are part of the model's own 30,000-token vocabulary, so they can be stored as impacts in any inverted index, but require no corpus or index to function; a document's representation only depends on the document text, nothing else.

The entire model is 76k parameters, and is only 851KB on disk. The whole repo, including the tokenizer and README, is about 1.5MB.

shimmer is a drop-in replacement for BM25. Without using any external corpus statistics, it outperforms BM25 on the majority of benchmarks. This makes it useful in situations where you want good retrieval performance but the corpus distribution changes a lot, or where semantic overlap matters more than exact matches.

Usage

Install model2vec with the sparse extra:

pip install "model2vec[sparse]>=0.12.1"

Load the model with SparseStaticModel:

from model2vec.sparse import SparseStaticModel

model = SparseStaticModel.from_pretrained("minishlab/shimmer")

documents = model.encode_document(["Example document", "Another document"])
queries = model.encode_query(["Example query"])

scores = queries @ documents.T

encode_document and encode_query return scipy.sparse matrices over the 30,000 tokens of the vocabulary.

This model can also be loaded as a Sentence Transformers SparseEncoder, which requires model2vec[sparse] to be installed:

from sentence_transformers import SparseEncoder

model = SparseEncoder("minishlab/shimmer", trust_remote_code=True)

queries = model.encode_query(["Example query"])
documents = model.encode_document(["Example document"])
scores = model.similarity(queries, documents)

Results

RTEB mean against Decontaminated BEIR nDCG@10 for shimmer, BM25 and blink-8M

All scores are ×100.

  • blink-8M is the dense static model shimmer is built from: mean pooling with cosine similarity.
  • BM25 is bm25s Lucene BM25 with k1 = 0.9 and b = 0.4, over stemmed English words without stopwords, which are Pyserini's defaults.

Main results

Dataset Metric blink-8M BM25 shimmer
BEIR-15 nDCG@10 37.7 41.3 43.0
Decon-BEIR nDCG@10 45.0 48.5 50.8
RTEB(eng, beta) nDCG@10 30.8 32.2 39.6

How the suites are built:

  • BEIR-15 is BEIR with CQADupStack (the mean over its 12 subforums) and MS MARCO dev.
  • Decon-BEIR is LightOn's decontaminated BEIR.
  • RTEB is the main RTEB set.

Other benchmarks

Benchmark Metric blink-8M BM25 shimmer
MTEB(eng, v2) retrieval nDCG@10 38.9 43.2 44.7
BRIGHT nDCG@10 10.5 14.2 17.2
BrowseComp-Plus (evidence) nDCG@10 2.1 1.7 8.3
MIRACL-en nDCG@10 25.1 34.6 36.2
MIRACL-en R@100 69.3 81.2 81.4

MIRACL-en (full corpus) is the dev set of 799 queries over all 32.9M English passages.

Compared to learned sparse and dense models

These are the numbers of Table 2 of the SparseUP paper, next to shimmer. Note that those models are 150M-parameter transformers trained on retrieval data, while shimmer runs no model at all during inference.

Dataset Metric DenseOn LateOn SlideOn SparseUP SparseUP-v2 shimmer
BEIR-15 nDCG@10 56.2 57.2 56.7 54.5 57.2 43.0
Decon-BEIR nDCG@10 57.9 59.1 58.4 57.5 59.5 50.8
CURE-en nDCG@10 56.5 61.3 60.8 56.0 62.1 41.6
LegalPinCite-par nDCG@10 46.3 54.7 48.2 55.2 52.3 51.5
Finance nDCG@10 59.8 59.2 62.6 63.4 66.7 64.8
ChemTEB nDCG@10 76.4 75.1 76.8 70.8 72.5 60.9
BRIGHT-Pro nDCG@10 29.6 36.1 47.4 34.5 49.4 39.1
LoTTE Forum S@5 82.7 81.5 78.0 75.5 80.6 52.0
LoTTE Search S@5 83.4 83.9 81.1 78.2 82.1 54.1
FreshStack α-nDCG@10 19.6 24.5 15.6 23.3 22.8 23.2
MIRACL-en nDCG@10 55.4 64.3 60.9 56.7 60.7 36.2
MLDR-en nDCG@10 41.7 71.6 58.7 57.9 61.9 31.1
LIMIT R@2 0.8 74.2 12.2 8.1 28.2 80.8

shimmer scores above DenseOn on LegalPinCite, Finance, BRIGHT-Pro, FreshStack and LIMIT, and above SparseUP on Finance, BRIGHT-Pro and LIMIT.

BEIR-15 (shimmer 43.03)

nDCG@10. The original BeIR datasets, with graded relevance and identical ids dropped.

Dataset blink-8M BM25 shimmer
ArguAna 44.81 40.96 42.30
Climate-FEVER 21.95 16.25 19.71
CQADupStack 27.00 30.04 31.57
DBPedia 26.92 32.04 32.87
FEVER 46.81 63.79 63.64
FiQA-2018 20.89 23.85 25.16
HotpotQA 49.88 62.91 61.06
MS MARCO (dev) 19.87 22.80 25.30
NFCorpus 31.14 31.79 33.74
NQ 30.37 30.47 33.92
Quora 82.11 78.75 80.17
SCIDOCS 15.88 15.05 15.22
SciFact 65.59 67.62 68.84
TREC-COVID 62.43 58.89 68.42
Touché-2020 20.25 44.24 43.53
Mean (15) 37.73 41.30 43.03
Decontaminated BEIR (shimmer 50.84)

nDCG@10 on LightOn's decontaminated BEIR (lightonai/<dataset>-decontaminated): binary relevance, identical ids kept, and MS MARCO as TREC DL19.

Dataset blink-8M BM25 shimmer
ArguAna 33.19 30.65 31.85
Climate-FEVER 22.70 16.74 19.86
DBPedia 25.87 32.62 35.27
FEVER 47.30 64.47 64.01
FiQA-2018 31.58 29.72 30.36
HotpotQA 52.67 64.41 63.45
MS MARCO (DL19) 51.75 59.46 60.32
NFCorpus 21.13 19.06 21.50
NQ 67.40 72.34 80.41
Quora 85.59 81.84 83.02
SCIDOCS 17.66 16.18 16.15
SciFact 83.39 75.36 84.41
TREC-COVID 68.17 65.29 73.52
Touché-2020 22.07 50.51 47.64
Mean (14) 45.03 48.48 50.84
MTEB(eng, v2) retrieval (shimmer 44.72)

nDCG@10.

Task blink-8M BM25 shimmer
ArguAna 44.69 40.80 42.30
CQADupstackGamingRetrieval 44.53 47.95 49.50
CQADupstackUnixRetrieval 25.87 26.99 29.51
ClimateFEVERHardNegatives 23.61 14.28 20.54
FEVERHardNegatives 49.47 65.25 64.06
FiQA2018 20.89 23.85 25.16
HotpotQAHardNegatives 53.01 63.23 61.53
SCIDOCS 15.88 15.05 15.22
TRECCOVID 62.50 58.87 68.42
Touche2020Retrieval.v3 48.27 75.95 70.92
Mean 38.87 43.22 44.72
RTEB (shimmer 39.61)

nDCG@10 on the 15 public English tasks of RTEB(eng, beta).

Task Domain blink-8M BM25 shimmer
AILACasedocs Legal 26.81 21.91 33.75
AILAStatutes Legal 25.10 18.32 21.65
LegalSummarization Legal 58.55 56.27 58.45
FinanceBenchRetrieval Finance 34.76 43.74 55.72
HC3FinanceRetrieval Finance 33.21 25.20 27.04
FinQARetrieval Finance 50.80 72.46 73.90
AppsRetrieval Code 3.58 4.35 5.03
DS1000Retrieval Code 23.93 39.42 39.89
HumanEvalRetrieval Code 45.66 37.83 52.11
MBPPRetrieval Code 37.26 11.65 56.05
WikiSQLRetrieval Code 37.29 51.27 56.48
FreshStackRetrieval Code 22.72 25.62 27.62
SWEbenchCodeRetrieval Code 4.57 7.10 5.67
ChatDoctorRetrieval Healthcare 25.12 29.45 39.32
CUREv1 Healthcare 33.18 39.06 41.45
Mean 30.84 32.24 39.61
BRIGHT (shimmer 17.19)

nDCG@10 with the original queries.

Task blink-8M BM25 shimmer
Biology 14.68 17.73 26.23
Earth Science 25.58 29.24 42.25
Economics 11.29 15.52 15.93
Psychology 11.93 14.38 19.38
Robotics 7.26 12.28 12.99
Stack Overflow 12.94 18.18 19.88
Sustainable Living 7.55 15.80 16.36
LeetCode 15.94 26.06 25.32
Pony 3.52 4.97 6.84
AoPS 5.78 6.13 8.47
TheoremQA (questions) 7.11 8.02 9.09
TheoremQA (theorems) 2.59 1.67 3.49
Mean 10.51 14.16 17.19

Recall@100:

Task blink-8M BM25 shimmer
Biology 50.99 43.61 57.65
Earth Science 58.10 59.79 69.89
Economics 40.14 40.76 42.84
Psychology 40.42 43.29 47.14
Robotics 31.66 42.55 45.86
Stack Overflow 40.20 48.12 53.07
Sustainable Living 45.27 41.57 48.56
LeetCode 38.73 46.84 55.26
Pony 17.03 20.84 14.07
AoPS 20.24 19.12 25.04
TheoremQA (questions) 16.28 15.35 21.54
TheoremQA (theorems) 7.68 9.65 15.02
FreshStack (shimmer 23.15)
Topic blink-8M α-nDCG@10 BM25 α-nDCG@10 shimmer α-nDCG@10 blink-8M C@20 BM25 C@20 shimmer C@20 blink-8M R@50 BM25 R@50 shimmer R@50
Angular 16.88 28.00 21.97 36.59 57.50 53.35 21.45 34.55 32.47
Godot 12.60 14.46 19.17 30.24 32.31 38.11 25.41 23.14 32.27
LangChain 15.47 25.38 23.62 38.87 49.65 52.46 21.15 29.34 28.56
Laravel 21.26 31.21 34.34 49.69 62.25 65.18 36.71 44.19 48.31
YOLO 12.36 16.08 16.66 28.83 39.80 41.61 22.28 32.64 35.71
Mean 15.71 23.03 23.15 36.84 48.30 50.14 25.40 32.77 35.46
BrowseComp-Plus (shimmer 8.30)
Qrels Metric blink-8M BM25 shimmer
Evidence nDCG@10 2.12 1.71 8.30
Recall@5 1.44 1.35 6.07
Recall@100 9.30 4.92 20.32
Recall@1000 32.31 14.02 41.69
Gold nDCG@10 1.77 1.69 7.52
Recall@5 1.77 1.56 7.31
Recall@100 10.16 6.70 22.73
Recall@1000 34.65 17.85 45.34

BrowseComp-Plus documents are long. BM25 with k1 = 16 and b = 1 reaches 10.71 evidence nDCG@10.

Library Authors

Model2Vec was developed by the Minish Lab team consisting of Stephan Tulkens and Thomas van Dongen.

Citation

Please cite the Model2Vec repository if you use this model in your work.

@software{minishlab2024model2vec,
  author       = {Stephan Tulkens and {van Dongen}, Thomas},
  title        = {Model2Vec: Fast State-of-the-Art Static Embeddings},
  year         = {2024},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.17270888},
  url          = {https://github.com/MinishLab/model2vec},
  license      = {MIT}
}