Fine tuned sentence transformers for document retrieval • 4 items • Updated
Static Embeddings with ModernBERT tokenizer finetuned on various datasets
This is a static embedding sentence-transformers model trained on various english text retrieval datasets (see below for details). It maps sentences & paragraphs to a 1024-dimensional dense vector space with an intended use of english based semantic search. Notably, this model has 0 active parameters and was trained with Matryoshka Representation Learning, allowing for efficient and fast CPU/GPU based embedding operations.
This is based on prior work from Tom Aarsen, see blog post here.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: answerdotai/ModernBERT-base Tokenizer
- Maximum Sequence Length: inf tokens
- Output Dimensionality: 1024 dimensions
- Similarity Function: Cosine Similarity
- Training Datasets:
- Languages: en
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): StaticEmbedding(
(embedding): EmbeddingBag(50368, 1024, mode='mean')
)
)
Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("AdamLucek/static-retrieval-mrl-MBERT-base-en-v1")
# Run inference
sentences = [
"What is the name of Nan's primary teacher?",
"While still young, Nan left his military career so that he could commit himself fully to his study of Buddhism and to meditation. In 1942 at age 24, he went on a three-year meditation retreat in the Emei Mountains. It is said that it was there that he verified his experiences against the Chinese Buddhist canon. During this time, Nan's primary teacher was Yuan Huanxian (袁煥仙; 1887\xa0– 1966).",
'Among other schemes that have been considered is a rapid transport link between Heathrow and Gatwick Airports, known as "Heathwick", which would allow the airports to operate jointly as an airline hub; In 2018, the Department for Transport began to invite proposals for privately funded rail links to Heathrow Airport. Projects being considered under this initiative include:The Mayor of London\'s office and Transport for London commissioned plans in the event of Heathrow\'s closure—to replace it by a large built-up area. Some of the plans seem to show terminal 5, or part of it, kept as a shopping centre.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Evaluation
Metrics
Information Retrieval
- Datasets:
NanoClimateFEVER,NanoDBPedia,NanoFEVER,NanoFiQA2018,NanoHotpotQA,NanoMSMARCO,NanoNFCorpus,NanoNQ,NanoQuoraRetrieval,NanoSCIDOCS,NanoArguAna,NanoSciFactandNanoTouche2020 - Evaluated with
InformationRetrievalEvaluator
| Metric | NanoClimateFEVER | NanoDBPedia | NanoFEVER | NanoFiQA2018 | NanoHotpotQA | NanoMSMARCO | NanoNFCorpus | NanoNQ | NanoQuoraRetrieval | NanoSCIDOCS | NanoArguAna | NanoSciFact | NanoTouche2020 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cosine_accuracy@1 | 0.3 | 0.62 | 0.4 | 0.3 | 0.62 | 0.28 | 0.4 | 0.28 | 0.76 | 0.38 | 0.08 | 0.48 | 0.5102 |
| cosine_accuracy@3 | 0.54 | 0.84 | 0.7 | 0.46 | 0.74 | 0.54 | 0.52 | 0.48 | 0.9 | 0.58 | 0.38 | 0.64 | 0.7959 |
| cosine_accuracy@5 | 0.68 | 0.9 | 0.76 | 0.54 | 0.76 | 0.6 | 0.58 | 0.58 | 0.94 | 0.66 | 0.52 | 0.72 | 0.9184 |
| cosine_accuracy@10 | 0.8 | 0.94 | 0.84 | 0.58 | 0.86 | 0.68 | 0.66 | 0.72 | 0.98 | 0.8 | 0.64 | 0.8 | 0.9796 |
| cosine_precision@1 | 0.3 | 0.62 | 0.4 | 0.3 | 0.62 | 0.28 | 0.4 | 0.28 | 0.76 | 0.38 | 0.08 | 0.48 | 0.5102 |
| cosine_precision@3 | 0.1933 | 0.5467 | 0.2333 | 0.2067 | 0.36 | 0.18 | 0.3067 | 0.16 | 0.3667 | 0.2667 | 0.1267 | 0.22 | 0.5102 |
| cosine_precision@5 | 0.164 | 0.52 | 0.16 | 0.156 | 0.236 | 0.12 | 0.268 | 0.12 | 0.228 | 0.2 | 0.104 | 0.152 | 0.502 |
| cosine_precision@10 | 0.11 | 0.434 | 0.088 | 0.088 | 0.138 | 0.068 | 0.2 | 0.076 | 0.118 | 0.14 | 0.064 | 0.086 | 0.4755 |
| cosine_recall@1 | 0.1333 | 0.0543 | 0.3767 | 0.1472 | 0.31 | 0.28 | 0.0418 | 0.26 | 0.674 | 0.0787 | 0.08 | 0.445 | 0.0302 |
| cosine_recall@3 | 0.2507 | 0.1505 | 0.6567 | 0.2854 | 0.54 | 0.54 | 0.0708 | 0.46 | 0.8653 | 0.1657 | 0.38 | 0.61 | 0.0914 |
| cosine_recall@5 | 0.3457 | 0.2128 | 0.7233 | 0.3813 | 0.59 | 0.6 | 0.1041 | 0.56 | 0.9053 | 0.2057 | 0.52 | 0.685 | 0.1517 |
| cosine_recall@10 | 0.438 | 0.2982 | 0.8033 | 0.414 | 0.69 | 0.68 | 0.1291 | 0.68 | 0.932 | 0.2867 | 0.64 | 0.775 | 0.2889 |
| cosine_ndcg@10 | 0.3391 | 0.5263 | 0.605 | 0.3312 | 0.616 | 0.4783 | 0.2741 | 0.463 | 0.8487 | 0.2856 | 0.3549 | 0.6105 | 0.4953 |
| cosine_mrr@10 | 0.4425 | 0.7382 | 0.556 | 0.3897 | 0.6933 | 0.4138 | 0.4761 | 0.4059 | 0.8425 | 0.4979 | 0.2644 | 0.5762 | 0.6754 |
| cosine_map@100 | 0.2558 | 0.396 | 0.545 | 0.2785 | 0.5571 | 0.4275 | 0.1127 | 0.4016 | 0.8181 | 0.2127 | 0.2796 | 0.5597 | 0.3778 |
Nano BEIR
- Dataset:
NanoBEIR_mean - Evaluated with
NanoBEIREvaluatorwith these parameters:{ "dataset_names": [ "climatefever", "dbpedia", "fever", "fiqa2018", "hotpotqa", "msmarco", "nfcorpus", "nq", "quoraretrieval", "scidocs", "arguana", "scifact", "touche2020" ] }
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.4162 |
| cosine_accuracy@3 | 0.6243 |
| cosine_accuracy@5 | 0.7045 |
| cosine_accuracy@10 | 0.7907 |
| cosine_precision@1 | 0.4162 |
| cosine_precision@3 | 0.2828 |
| cosine_precision@5 | 0.2254 |
| cosine_precision@10 | 0.1604 |
| cosine_recall@1 | 0.2239 |
| cosine_recall@3 | 0.3897 |
| cosine_recall@5 | 0.4604 |
| cosine_recall@10 | 0.5427 |
| cosine_ndcg@10 | 0.4791 |
| cosine_mrr@10 | 0.5363 |
| cosine_map@100 | 0.4017 |
Training Details
Training Datasets
Evaluation Datasets
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsper_device_train_batch_size: 2048per_device_eval_batch_size: 2048learning_rate: 0.2num_train_epochs: 1warmup_ratio: 0.1bf16: Truebatch_sampler: no_duplicates
All Hyperparameters
Training Logs
Framework Versions
- Python: 3.11.11
- Sentence Transformers: 4.1.0
- Transformers: 4.51.3
- PyTorch: 2.8.0.dev20250319+cu128
- Accelerate: 1.6.0
- Datasets: 3.6.0
- Tokenizers: 0.21.1
Citation
BibTeX
Sentence Transformers
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
MatryoshkaLoss
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
- Downloads last month
- 7
Datasets used to train AdamLucek/static-retrieval-mrl-MBERT-base-en-v1
Collection including AdamLucek/static-retrieval-mrl-MBERT-base-en-v1
Papers for AdamLucek/static-retrieval-mrl-MBERT-base-en-v1
Paper • 2205.13147 • Published • 27
Paper • 1908.10084 • Published • 15
Paper • 1705.00652 • Published
Evaluation results
- Cosine Accuracy@1 on NanoClimateFEVERself-reported0.300
- Cosine Accuracy@3 on NanoClimateFEVERself-reported0.540
- Cosine Accuracy@5 on NanoClimateFEVERself-reported0.680
- Cosine Accuracy@10 on NanoClimateFEVERself-reported0.800
- Cosine Precision@1 on NanoClimateFEVERself-reported0.300
- Cosine Precision@3 on NanoClimateFEVERself-reported0.193
- Cosine Precision@5 on NanoClimateFEVERself-reported0.164
- Cosine Precision@10 on NanoClimateFEVERself-reported0.110
