1import requests
23defdot(va, vb):4returnsum(a * b for a, b inzip(va, vb))56defembed(texts):7 resp = requests.post('http://localhost:8080/v1/embeddings', json={'input': texts}).json()8return[d['embedding']for d in resp['data']]910docs =['嵌入很酷','骆驼很酷']# 'embeddings are cool', 'llamas are cool'11docs_embed = embed(['search_document: '+ d for d in docs])1213query ='跟我讲讲嵌入'# 'tell me about embeddings'14query_embed = embed(['search_query: '+ query])[0]15print(f'query: {query!r}')16for d, e inzip(docs, docs_embed):17print(f'similarity {dot(query_embed, e):.2f}: {d!r}')
nomic-embed-text-v2-moe is a SoTA multilingual MoE text embedding model that excels at multilingual retrieval:
High Performance: SoTA Multilingual performance compared to ~300M parameter models, competitive with models 2x in size
Multilinguality: Supports ~100 languages and trained on over 1.6B pairs
Flexible Embedding Dimension: Trained with Matryoshka Embeddings with 3x reductions in storage cost with minimal performance degradations
Fully Open-Source: Model weights, code, and training data (see code repo) released
Model
Params (M)
Emb Dim
BEIR
MIRACL
Pretrain Data
Finetune Data
Code
Nomic Embed v2
305
768
52.86
65.80
✅
✅
✅
mE5 Base
278
768
48.88
62.30
❌
❌
❌
mGTE Base
305
768
51.10
63.40
❌
❌
❌
Arctic Embed v2 Base
305
768
55.40
59.90
❌
❌
❌
BGE M3
568
1024
48.80
69.20
❌
✅
❌
Arctic Embed v2 Large
568
1024
55.65
66.00
❌
❌
❌
mE5 Large
560
1024
51.40
66.50
❌
❌
❌
Model Architecture
Total Parameters: 475M
Active Parameters During Inference: 305M
Architecture Type: Mixture of Experts (MoE)
MoE Configuration: 8 experts with top-2 routing
Embedding Dimensions: Supports flexible dimension from 768 to 256 through Matryoshka representation learning
Maximum Sequence Length: 512 tokens
Languages: Supports dozens of languages (see Performance section)
Paper Abstract
Transformer-based text embedding models have improved their performance on benchmarks like MIRACL and BEIR by increasing their parameter counts. However, this scaling approach introduces significant deployment challenges, including increased inference latency and memory usage. These challenges are particularly severe in retrieval-augmented generation (RAG) applications, where large models' increased memory requirements constrain dataset ingestion capacity, and their higher latency directly impacts query-time performance. While causal language models have addressed similar efficiency challenges using Mixture of Experts (MoE) architectures, this approach hasn't been successfully adapted to the general text embedding setting. In this paper, we introduce Nomic Embed v2, the first general purpose MoE text embedding model. Our model outperforms models in the same parameter class on both monolingual and multilingual benchmarks while also maintaining competitive performance with models twice its size. We open-source all code, models, and evaluation data to ensure full reproducibility of our training pipeline at https://github.com/nomic-ai/contrastors.
Performance
nomic-embed-text-v2-moe performance on BEIR and MIRACL compared to other open-weights embedding models:
nomic-embed-text-v2-moe performance on BEIR at 768 dimension and truncated to 256 dimensions:
Best Practices
Add appropriate prefixes to your text:
For queries: "search_query: "
For documents: "search_document: "
Maximum input length is 512 tokens
For optimal efficiency, consider using the 256-dimension embeddings if storage/compute is a concern
Limitations
Performance may vary across different languages
Resource requirements may be higher than traditional dense models due to MoE architecture
Must use trust_remote_code=True when loading the model to use our custom architecture implementation
Training Details
Trained on 1.6 billion high-quality pairs across multiple languages
Uses consistency filtering to ensure high-quality training data
Incorporates Matryoshka representation learning for dimension flexibility
Training includes both weakly-supervised contrastive pretraining and supervised finetuning