mdbr-leaf-ir is a compact high-performance text embedding model specifically designed for information retrieval (IR) tasks, e.g., the retrieval stage of Retrieval-Augmented Generation (RAG) pipelines.
If you are looking to perform other tasks such as classification, clustering, semantic sentence similarity, summarization, please check out our mdbr-leaf-mt model.
[!Note] Note: this model has been developed by the ML team of MongoDB Research. At the time of writing it is not used in any of MongoDB's commercial product or service offerings.
Technical Report
A technical report detailing our proposed LEAF training procedure is available here.
Highlights
State-of-the-Art Performance: mdbr-leaf-ir achieves state-of-the-art results for compact embedding models, ranking #1 on the public BEIR benchmark leaderboard for models with ≤100M parameters.
Flexible Architecture Support: mdbr-leaf-ir supports asymmetric retrieval architectures enabling even greater retrieval results. See below for more information.
MRL and Quantization Support: embedding vectors generated by mdbr-leaf-ir compress well when truncated (MRL) and can be stored using more efficient types like int8 and binary. See below for more information.
Benchmark Comparison
The table below shows the average BEIR benchmark scores (nDCG@10) for mdbr-leaf-ir compared to other retrieval models.
mdbr-leaf-ir ranks #1 on the BEIR public leaderboard, and when run in asymmetric "(asym.)" mode as described here, the results improve even further.
Model
Size
BEIR Avg. (nDCG@10)
OpenAI text-embedding-3-large
Unknown
55.43
mdbr-leaf-ir (asym.)
23M
54.03
mdbr-leaf-ir
23M
53.55
snowflake-arctic-embed-s
32M
51.98
bge-small-en-v1.5
33M
51.65
OpenAI text-embedding-3-small
Unknown
51.08
granite-embedding-small-english-r2
47M
50.87
snowflake-arctic-embed-xs
23M
50.15
e5-small-v2
33M
49.04
SPLADE++
110M
48.88
MiniLM-L6-v2
23M
41.95
BM25
–
41.14
Quickstart
Sentence Transformers
python
1from sentence_transformers import SentenceTransformer
23# Load the model 4model = SentenceTransformer("MongoDB/mdbr-leaf-ir")56# Example queries and documents 7queries =[8"What is machine learning?",9"How does neural network training work?"10]1112documents =[13"Machine learning is a subset of artificial intelligence that focuses on algorithms that can learn from data.",14"Neural networks are trained through backpropagation, adjusting weights to minimize prediction errors."15]1617# Encode queries and documents 18query_embeddings = model.encode(queries, prompt_name="query")19document_embeddings = model.encode(documents)2021# Compute similarity scores 22scores = model.similarity(query_embeddings, document_embeddings)2324# Print results25for i, query inenumerate(queries):26print(f"Query: {query}")27for j, doc inenumerate(documents):28print(f" Similarity: {scores[i, j]:.4f} | Document {j}: {doc[:80]}...")
See example output
Query: What is machine learning?
Similarity: 0.6857 | Document 0: Machine learning is a subset of ...
Similarity: 0.4598 | Document 1: Neural networks are trained ...
Query: How does neural network training work?
Similarity: 0.4238 | Document 0: Machine learning is a subset of ...
Similarity: 0.5723 | Document 1: Neural networks are trained ...
Transformers.js
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
npm i @huggingface/transformers
You can then use the model to compute embeddings like this:
js
1import{AutoModel,AutoTokenizer, matmul }from"@huggingface/transformers";23// Download from the 🤗 Hub4const model_id ="MongoDB/mdbr-leaf-ir";5const tokenizer =awaitAutoTokenizer.from_pretrained(model_id);6const model =awaitAutoModel.from_pretrained(model_id,{7dtype:"fp32",// Options: "fp32" | "fp16" | "q8" | "q4" | "q4f16"8});910// Prepare queries and documents11const queries =[12"What is machine learning?",13"How does neural network training work?",14];15const documents =[16"Machine learning is a subset of artificial intelligence that focuses on algorithms that can learn from data.",17"Neural networks are trained through backpropagation, adjusting weights to minimize prediction errors.",18];19const inputs =awaittokenizer([20...queries.map((x)=>"Represent this sentence for searching relevant passages: "+ x),21...documents,22],{padding:true});2324// Generate embeddings25const{ sentence_embedding }=awaitmodel(inputs);2627// Compute similarities28const scores =awaitmatmul(29 sentence_embedding.slice([0, queries.length]),30 sentence_embedding.slice([queries.length,null]).transpose(1,0),31);32const scores_list = scores.tolist();3334for(let i =0; i < queries.length;++i){35console.log(`Query: ${queries[i]}`);36for(let j =0; j < documents.length;++j){37console.log(` Similarity: ${scores_list[i][j].toFixed(4)} | Document ${j}: ${documents[j]}`);38}39console.log();40}
See example output
Query: What is machine learning?
Similarity: 0.6857 | Document 0: Machine learning is a subset of artificial intelligence that focuses on algorithms that can learn from data.
Similarity: 0.4598 | Document 1: Neural networks are trained through backpropagation, adjusting weights to minimize prediction errors.
Query: How does neural network training work?
Similarity: 0.4238 | Document 0: Machine learning is a subset of artificial intelligence that focuses on algorithms that can learn from data.
Similarity: 0.5723 | Document 1: Neural networks are trained through backpropagation, adjusting weights to minimize prediction errors.
[!Note] Note: a version of this asymmetric setup, conveniently packaged into a single model, is available here.
mdbr-leaf-ir is aligned to snowflake-arctic-embed-m-v1.5, the model it has been distilled from. This enables flexible architectures in which, for example, documents are encoded using the larger model, while queries can be encoded faster and more efficiently with the compact leaf model:
python
1# Use mdbr-leaf-ir for query encoding (real-time, low latency) 2query_model = SentenceTransformer("MongoDB/mdbr-leaf-ir")3query_embeddings = query_model.encode(queries, prompt_name="query")45# Use a larger model for document encoding (one-time, at index time) 6doc_model = SentenceTransformer("Snowflake/snowflake-arctic-embed-m-v1.5")7document_embeddings = doc_model.encode(documents)89# Compute similarities 10scores = query_model.similarity(query_embeddings, document_embeddings)
Retrieval results in asymmetric mode are often superior to the standard mode above.
MRL Truncation
Embeddings have been trained via MRL and can be truncated for more efficient storage:
Vector quantization, for example to int8 or binary, can be performed as follows:
Note: For vector quantization to types other than binary, we suggest performing a calibration to determine the optimal ranges, see here.
Good initial values, according to the teacher model's documentation, are:
int8: -0.3 and +0.3
int4: -0.18 and +0.18
python
1from sentence_transformers.quantization import quantize_embeddings
2import torch
34query_embeds = model.encode(queries, prompt_name="query")5doc_embeds = model.encode(documents)67# Quantize embeddings to int8 using -0.3 and +0.3 as calibration ranges8ranges = torch.tensor([[-0.3],[+0.3]]).expand(2, query_embeds.shape[1]).cpu().numpy()9query_embeds = quantize_embeddings(query_embeds,"int8", ranges=ranges)10doc_embeds = quantize_embeddings(doc_embeds,"int8", ranges=ranges)1112# Calculate similarities; cast to int64 to avoid under/overflow13similarities = query_embeds.astype(int) @ doc_embeds.astype(int).T
1415print('After quantization:')16print(f"* Embeddings type: {query_embeds.dtype}")17print(f"* Similarities: \n{similarities}")
1@inproceedings{vujanic-ruckstiess-2026-leaf,
2 title = "{LEAF}: Knowledge Distillation of Text Embedding Models with Teacher-Aligned Representations",
3 author = {Vujanic, Robin and
4 R{\"u}ckstie{\ss}, Thomas},
5 editor = "Liakata, Maria and
6 Moreira, Viviane P. and
7 Zhang, Jiajun and
8 Jurgens, David",
9 booktitle = "Proceedings of the 64th Annual Meeting of the {A}ssociation for {C}omputational {L}inguistics (Volume 1: Long Papers)",
10 month = jul,
11 year = "2026",
12 address = "San Diego, California, United States",
13 publisher = "Association for Computational Linguistics",
14 url = "https://aclanthology.org/2026.acl-long.2008/",
15 doi = "10.18653/v1/2026.acl-long.2008",
16 pages = "43362--43383",
17 ISBN = "979-8-89176-390-6",
18 abstract = "We present a knowledge distillation framework for text embedding models. A key distinguishing feature is that our distilled models are compatible with their teacher, enabling flexible asymmetric architectures where documents are encoded with the larger teacher model, while queries use smaller student models. We also show that our models automatically inherit MRL and robustness to output quantization whenever these properties are present in the teacher model, without explicitly training for them. To demonstrate the effectiveness of our framework we publish leaf-ir, a 23M parameters information retrieval oriented model that, besides being teacher-compatibile, sets a new state-of-the-art (SOTA) on BEIR, ranking no.1 on the public leaderboard for models of its size. Asymmetric mode further increases its retrieval performance. Our scheme is however not restricted to information retrieval. We demonstrate its wider applicability by synthesizing the multi-task leaf-mt model. This also sets a new SOTA, achieving no.1 on the public MTEB v2 (English) leaderboard for models of its size. Our technique is applicable to black-box models, requires no judgments nor hard negatives, and training can be conducted using small batch sizes. Thus, dataset and training infrastructure requirements for our framework are modest. We make our models publicly available under a permissive Apache 2.0 license."
19}
License
This model is released under Apache 2.0 License.
Contact
For questions or issues, please open an issue or pull request. You can also contact the MongoDB ML research team at robin.vujanic@mongodb.com.