ModernBERT-embed-large
ModernBERT-embed-large is an embedding model trained from ModernBERT-large, bringing the new advances of ModernBERT to embeddings!
Indeed, ModernBERT is a base model trained for Masked Language Modeling and can not directly be used to perform tasks such as retrieval without further fine-tuning.
ModernBERT-embed-large is fine-tuned on the Nomic Embed weakly-supervised and supervised datasets and also supports Matryoshka Representation Learning dimensions of 256 to reduce memory with minimal performance loss.
Performance
Usage
You can use these models directly with the latest transformers release and requires installing transformers>=4.48.0:
Reminder, this model is trained similarly to Nomic Embed and REQUIRES prefixes to be added to the input. For more information, see the instructions in Nomic Embed.
Most use cases, adding search_query: to the query and search_document: to the documents will be sufficient.
Sentence Transformers
Click to see Sentence Transformers usage with Matryoshka Truncation
In Sentence Transformers, you can truncate embeddings to a smaller dimension by using the truncate_dim parameter when loading the SentenceTransformer model.
Note the small differences compared to the full 1024-dimensional similarities.
Transformers
Click to see Transformers usage with Matryoshka Truncation
In transformers, you can truncate embeddings to a smaller dimension by slicing the mean pooled embeddings, prior to normalization.
Note the small differences compared to the full 1024-dimensional similarities.
Transformers.js
If you haven't already, you can install the Transformers.js JavaScript library from NPM using:
Then, you can compute embeddings as follows:
Training
We train ModernBERT-embed-large using a multi-stage training pipeline. Starting from the pretrained ModernBERT-large model,
the first unsupervised contrastive stage trains on a dataset generated from weakly related text pairs, such as question-answer pairs from forums like StackExchange and Quora, title-body pairs from Amazon reviews, and summarizations from news articles.
In the second finetuning stage, higher quality labeled datasets such as search queries and answers from web searches are leveraged. Data curation and hard-example mining is crucial in this stage.
For more details, see the Nomic Embed Technical Report and corresponding blog post.
Training data to train the models is released in its entirety. For more details, see the contrastors repository
Acknowledgment
We wanted to thank Zach Nussbaum from Nomic AI for building and sharing the Nomic Embed recipe and tools and its support during the training of this model!
The training has been run on Orange Business Cloud Avenue infrastructure.
Citation
If you find the model, dataset, or training code useful, please considering citing ModernBERT as well as Nomic Embed:
And if you want to cite this fine-tuning in particular, please use: