EmbeddingNandi-450M / README.md
vishesh-t27's picture
Clarify re-normalization after truncation for dot product vs cosine
4fc2dbc verified
|
Raw History Blame Contribute Delete
19.1 kB
metadata
license: apache-2.0
language:
  - en
  - hi
  - mr
  - pa
  - ta
  - te
  - kn
  - ml
  - bn
  - gu
  - as
  - or
  - ur
  - ne
  - ar
  - id
  - ms
library_name: sentence-transformers
pipeline_tag: sentence-similarity
base_model: FrontiersMind/NandiBERT-450M
tags:
  - embeddings
  - sentence-transformers
  - sentence-similarity
  - feature-extraction
  - mteb
  - retrieval
  - multilingual
  - indic
  - long-context
  - frontiersmind
  - nandi
widget:
  - source_sentence: 'task: sentence similarity | query: How do I return a damaged product?'
    sentences:
      - 'task: sentence similarity | query: खराब सामान वापस कैसे करें?'
      - 'task: sentence similarity | query: damaged product wapas kaise kare?'
      - 'task: sentence similarity | query: What is the weather like today?'

EmbeddingNandi-450M

EmbeddingNandi-450M by FrontiersMind

Hugging Face | GitHub | Launch Blog | Website | Technical Report

License: Apache-2.0 | Authors: FrontiersMind

EmbeddingNandi is a family of open, long-context embedding models for English, Indic, Arabic and Southeast Asian languages, built on the NandiBERT bidirectional encoders. They turn text in English, Indic languages and other widely used languages into dense vectors for semantic search, retrieval-augmented generation, clustering and similarity.

Model Parameters Hidden Context Base encoder Description
EmbeddingNandi-150M 150M 768 16K NandiBERT-150M Compact long-context embedding model
EmbeddingNandi-450M (this model) 450M 1,024 32K NandiBERT-450M Long-context embedding model

Description

  • One Model. From English to Indic and Beyond: Built on NandiBERT-450M, which covers English, 13 Indic languages in native script, romanized Indic text such as Hinglish, and Arabic, Indonesian and Malay, so a single embedding model serves queries and documents across these languages.
  • 32K context: A 32,768-token window, so full contracts, reports and papers can be embedded in a single pass without chunking, with the 100K-token multilingual vocabulary shared across the NandiBERT family.
  • Deep, with efficient attention: Inherited from NandiBERT-450M: 28 layers at 1,024 hidden size, with QK-norm and SwiGLU. Grouped-query attention with 8 query heads and 2 key-value heads keeps memory low on long inputs. The 100K-token vocabulary is stored as a rank-512 factorized embedding.
  • Embedding output: 1,024-dimensional vectors. Mean pooling over all tokens (task prompt included), then L2 normalization, compared with cosine similarity. Trained with Matryoshka Representation Learning, so vectors can be cut to 768, 512, 256 or 128 dimensions.
  • Task prompts: Short task prompts in the EmbeddingGemma format (for example task: search result | query: ) steer the embedding for search, code search, classification, clustering and similarity.
  • Built for retrieval: A drop-in encoder for semantic search, retrieval-augmented generation, clustering, deduplication and similarity scoring, loadable with Sentence Transformers and Hugging Face transformers.

Benchmark Results

Mean task scores on MTEB(eng, v2) (41 tasks), MTEB(Code, v1) (12 tasks) and MTEB(Indic, v1) (20 tasks). We re-evaluated every model in this table ourselves with the same code, the open-source MTEB library (version 2.26.19), each with its official mteb loader settings and its documented maximum input length: 32,768 tokens for EmbeddingNandi-450M, Qwen3, harrier and pplx, 8,192 for EmbeddingGemma 2, and 512 for multilingual-e5 and LFM2.5. EmbeddingNandi-450M was evaluated with float32 compute (Touche2020 with bfloat16). Average is the mean of the three benchmark scores. Best score in each column is in bold.

Model MTEB(eng, v2) MTEB(Code, v1) MTEB(Indic, v1) Average (all three)
EmbeddingNandi-450M (445M) 67.61 78.42 76.62 74.22
EmbeddingGemma 2 (271M) 67.53 78.27 68.39 71.40
LFM2.5-Embedding-350M (354M) 60.33 44.27 34.94 46.51
Qwen3-Embedding-0.6B (596M) 70.09 74.88 64.10 69.69
pplx-embed-v1-0.6b (596M) 62.01 75.21 63.83 67.02
harrier-oss-v1-270m (268M) 67.19 62.98 67.99 66.05
multilingual-e5-large-instruct (560M) 65.74 58.49 69.64 64.62
MTEB(Indic, v1) by task type
Model Mean (20) Bitext Mining (2) Classification (12) Clustering (1) Pair Classification (1) Reranking (1) Retrieval (2) STS (1)
EmbeddingNandi-450M (445M) 76.62 88.85 73.66 58.64 85.19 87.03 90.89 58.04
EmbeddingGemma 2 (271M) 68.39 62.88 70.46 31.65 75.14 85.34 83.84 36.81
LFM2.5-Embedding-350M (354M) 34.94 3.73 47.10 3.53 51.84 45.67 16.11 -7.06
Qwen3-Embedding-0.6B (596M) 64.10 67.18 62.71 40.37 75.85 83.86 78.25 38.57
pplx-embed-v1-0.6b (596M) 63.83 68.60 62.91 26.56 64.34 86.30 83.54 40.22
harrier-oss-v1-270m (268M) 67.99 77.84 65.91 47.39 77.54 83.05 76.99 51.19
harrier-oss-v1-0.6b (596M) 70.64 80.32 68.59 51.45 79.50 82.48 81.23 53.26
multilingual-e5-large-instruct (560M) 69.64 80.25 66.62 51.41 74.54 85.89 84.51 51.94
MTEB(eng, v2) by task type
Model Mean (41) Classification (8) Clustering (8) Pair Classification (3) Reranking (2) Retrieval (10) STS (9) Summarization (1)
EmbeddingNandi-450M (445M) 67.61 89.44 53.55 83.48 47.71 52.29 81.44 26.20
EmbeddingGemma 2 (271M) 67.53 88.82 51.73 86.39 45.96 51.35 82.74 35.02
LFM2.5-Embedding-350M (354M) 60.33 69.94 40.93 80.44 45.18 54.42 76.23 24.41
Qwen3-Embedding-0.6B (596M) 70.09 85.60 53.96 85.33 47.33 59.55 86.45 32.89
pplx-embed-v1-0.6b (596M) 62.01 69.22 36.06 82.80 46.93 59.96 80.71 32.00
harrier-oss-v1-270m (268M) 67.19 85.74 53.58 80.89 45.61 53.21 82.91 28.21
multilingual-e5-large-instruct (560M) 65.74 75.28 51.65 86.20 46.53 53.65 84.56 30.59
MTEB(Code, v1) by task
Model Mean (12) AppsRetrieval CodeEditSearchRetrieval CodeFeedbackMT CodeFeedbackST CodeSearchNetCCRetrieval CodeSearchNetRetrieval CodeTransOceanContest CodeTransOceanDL CosQA COIRCodeSearchNetRetrieval StackOverflowQA SyntheticText2SQL
EmbeddingNandi-450M (445M) 78.42 80.97 80.89 94.98 88.72 92.15 89.42 85.87 36.36 43.11 85.84 92.98 69.76
EmbeddingGemma 2 (271M) 78.27 89.27 80.50 88.23 82.15 96.64 90.78 83.67 36.36 51.40 86.89 87.38 65.96
LFM2.5-Embedding-350M (354M) 44.27 6.79 46.43 31.87 69.53 35.26 72.48 56.90 22.33 29.14 37.94 81.60 40.95
Qwen3-Embedding-0.6B (596M) 74.88 75.94 63.37 90.42 86.50 85.07 89.95 86.21 33.23 40.65 84.19 89.23 73.85
pplx-embed-v1-0.6b (596M) 75.21 79.03 76.36 85.58 84.70 88.08 89.80 86.35 36.83 43.60 82.38 90.69 59.12
harrier-oss-v1-270m (268M) 62.98 17.80 53.35 89.13 81.77 49.54 82.75 81.05 36.10 34.92 75.42 89.08 64.79
multilingual-e5-large-instruct (560M) 58.49 29.31 54.81 40.65 75.73 57.86 85.29 74.73 31.09 36.36 62.33 91.11 62.56

Quick Start

Install Sentence Transformers (tested with sentence-transformers 6.1.0 and transformers 5.20.2):

pip install -U "sentence-transformers>=6.1.0" "transformers>=5.20.2"

The model uses custom code, so pass trust_remote_code=True. For search, encode_query and encode_document add the query and document prompts for you. Queries and documents can be in English, an Indic script or romanized text, in any mix:

from sentence_transformers import SentenceTransformer

model = SentenceTransformer("FrontiersMind/EmbeddingNandi-450M", trust_remote_code=True)

queries = [
    "What causes the northern lights?",
    "फ्रांस की राजधानी क्या है?",
    "phone ki battery jaldi khatam kyun hoti hai",
]
documents = [
    "The northern lights are caused by charged particles from the sun hitting the Earth's atmosphere.",
    "पेरिस फ्रांस की राजधानी और सबसे बड़ा शहर है।",
    "Phone batteries drain quickly when many apps run in the background and the screen is very bright.",
    "The Amazon is the largest rainforest in the world.",
]

query_embs = model.encode_query(queries)
doc_embs = model.encode_document(documents)
print(query_embs.shape, doc_embs.shape)
# (3, 1024) (4, 1024)

print(model.similarity(query_embs, doc_embs))
# tensor([[0.7564, 0.0961, 0.1738, 0.1838],
#         [0.1359, 0.8079, 0.0362, 0.2289],
#         [0.1872, 0.0741, 0.5996, 0.0011]])

Best Practices

1. Task Prompts

EmbeddingNandi-450M is trained with short task prompts added in front of the text. The prompts are saved in the model, so you only pass prompt_name and Sentence Transformers adds the prompt text. Using the right prompt gives the best quality.

There are two kinds of tasks:

  • Asymmetric tasks (for example search): use the query prompt for queries and the document prompt for the texts being searched.
  • Symmetric tasks (for example classification, similarity): use the same prompt for all texts being compared.
Use Case Task Type Prompt Name Query Prompt Document Prompt (prompt_name="Document")
Web / document search Asymmetric SearchQuery task: search result | query: {query} title: none | text: {content}
Code search Asymmetric CodeRetrieval task: code retrieval | query: {query} title: none | text: {code}
Text classification Symmetric Classification task: classification | query: {content} N/A
Clustering Symmetric Clustering task: clustering | query: {content} N/A
Sentence similarity Symmetric SentenceSimilarity task: sentence similarity | query: {content} N/A

Pass the prompt name to encode. For code search, encode the queries with CodeRetrieval and the code with Document:

code_queries = ["reverse a string in python"]
code_docs = ["def reverse(s):\n    return s[::-1]", "def add(a, b):\n    return a + b"]

q = model.encode(code_queries, prompt_name="CodeRetrieval")
d = model.encode(code_docs, prompt_name="Document")
print(model.similarity(q, d))
# tensor([[0.5554, 0.2409]])

For a symmetric task, use the same prompt for every text:

texts = ["This phone is really good", "Yeh phone bahut accha hai", "My order was delivered late"]

embs = model.encode(texts, prompt_name="SentenceSimilarity")
print(model.similarity(embs, embs))
# tensor([[1.0000, 0.7536, 0.2031],
#         [0.7536, 1.0000, 0.0294],
#         [0.2031, 0.0294, 1.0000]])

encode_query uses the query prompt (same text as SearchQuery) and encode_document uses the document prompt (same text as Document). The model also holds prompts keyed by MTEB task type (for example Retrieval-query, Retrieval-document, STS, BitextMining), so MTEB picks the right prompt for each task. model.prompts lists all of them.

2. Matryoshka Dimension Truncation

EmbeddingNandi-450M is trained with Matryoshka Representation Learning, so the 1,024-dimensional vector can be shortened by keeping only its first values. The supported sizes are 1024, 768, 512, 256 and 128 (the sizes the model was trained with; use one of these). Shorter vectors use less storage and make search faster, at some cost in quality.

Scores at each size on a 28-task subset of the three benchmarks (13 English, 6 Code and 9 Indic tasks; bfloat16, inputs up to 1,024 tokens, vectors re-normalized after truncation):

Dimension Storage MTEB(eng, v2) MTEB(Code, v1) MTEB(Indic, v1) Average Change vs 1024
1024 100% 67.41 73.73 80.29 73.81 0.00
768 75% 67.23 73.56 80.09 73.63 -0.18
512 50% 66.99 73.20 79.89 73.36 -0.45
256 25% 66.80 72.60 79.33 72.91 -0.90
128 12.5% 65.86 70.89 78.05 71.60 -2.21
  • Re-normalize after truncating when using dot product: truncation changes the vector's norm. Re-normalizing the shortened vectors makes the dot product equivalent to cosine similarity. If you use cosine similarity directly, explicit re-normalization is not necessary.
  • Queries and documents must use the same size.

Pass truncate_dim and normalize_embeddings=True to let Sentence Transformers do both:

query_embs = model.encode_query(queries, truncate_dim=256, normalize_embeddings=True)
doc_embs = model.encode_document(documents, truncate_dim=256, normalize_embeddings=True)
print(query_embs.shape)
# (3, 256)

Or set the size once when loading the model. The vectors are then cut after the model's normalization step, so they are no longer unit length: pass normalize_embeddings=True when you store them or compare them with a dot product (model.similarity uses cosine, so its scores are not affected):

model_256 = SentenceTransformer("FrontiersMind/EmbeddingNandi-450M", trust_remote_code=True, truncate_dim=256)
query_embs = model_256.encode_query(queries, normalize_embeddings=True)
print(query_embs.shape)
# (3, 256)

3. Long Inputs

The model takes inputs of up to 32,768 tokens, and model.max_seq_length is 32768 by default, so long documents are embedded whole. Texts longer than model.max_seq_length tokens are truncated. Longer inputs need more memory and time, so for short texts or limited memory you can lower the limit:

model.max_seq_length = 1024

4. Numerical Precision

Run inference in bfloat16 or float32. The weights are stored in bfloat16. Use float32 on CPU and for very long inputs (16K tokens or more).

import torch

if torch.cuda.is_available():
    dtype = torch.bfloat16 if torch.cuda.is_bf16_supported(including_emulation=False) else torch.float16
else:
    dtype = torch.float32

model = SentenceTransformer(
    "FrontiersMind/EmbeddingNandi-450M",
    trust_remote_code=True,
    model_kwargs={"dtype": dtype},
)

Usage with Transformers

EmbeddingNandi-450M also loads with Hugging Face transformers using trust_remote_code=True for both the tokenizer and the model. Add the task prompt in front of each text, take the mean over all tokens (prompt tokens included) and L2 normalize. This gives the same embeddings as Sentence Transformers, up to tiny bfloat16 rounding differences.

Show the code
import torch
import torch.nn.functional as F
from transformers import AutoModel, AutoTokenizer

model_id = "FrontiersMind/EmbeddingNandi-450M"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModel.from_pretrained(model_id, trust_remote_code=True).to(device).eval()

QUERY_PROMPT = "task: search result | query: "
DOCUMENT_PROMPT = "title: none | text: "


def embed(texts, prompt, max_length=32768, dim=None):
    inputs = tokenizer(
        [prompt + text for text in texts],
        padding=True,
        truncation=True,
        max_length=max_length,
        return_tensors="pt",
    ).to(device)
    with torch.no_grad():
        hidden = model(**inputs).last_hidden_state
    # mean pooling over all tokens, prompt tokens included
    mask = inputs["attention_mask"].unsqueeze(-1).to(hidden.dtype)
    emb = (hidden * mask).sum(dim=1) / mask.sum(dim=1).clamp(min=1e-9)
    if dim is not None:  # Matryoshka: keep the first `dim` values
        emb = emb[:, :dim]
    return F.normalize(emb.float(), dim=-1)


queries = [
    "What causes the northern lights?",
    "फ्रांस की राजधानी क्या है?",
    "phone ki battery jaldi khatam kyun hoti hai",
]
documents = [
    "The northern lights are caused by charged particles from the sun hitting the Earth's atmosphere.",
    "पेरिस फ्रांस की राजधानी और सबसे बड़ा शहर है।",
    "Phone batteries drain quickly when many apps run in the background and the screen is very bright.",
    "The Amazon is the largest rainforest in the world.",
]

scores = embed(queries, QUERY_PROMPT) @ embed(documents, DOCUMENT_PROMPT).T  # cosine similarity
print(scores)
# tensor([[0.7565, 0.0961, 0.1738, 0.1837],
#         [0.1358, 0.8079, 0.0361, 0.2288],
#         [0.1873, 0.0740, 0.5995, 0.0010]])

Model Description

Base model NandiBERT-450M
Parameters 445M
Layers / hidden size 28 / 1,024
Attention Grouped-query, 8 query heads and 2 key-value heads
Embedding dimension 1,024 (Matryoshka: 768, 512, 256, 128)
Pooling Mean over all tokens, task prompt included
Similarity Cosine (L2-normalized output)
Max sequence length 32,768 tokens
Vocabulary 100,352 tokens
Weights bfloat16
Prompt format task: {task} | query: {text} for queries and symmetric tasks, title: none | text: {text} for documents
Languages English; 13 Indic languages in native script (Assamese, Bengali, Gujarati, Hindi, Kannada, Malayalam, Marathi, Nepali, Odia, Punjabi, Tamil, Telugu, Urdu) and romanized Indic text such as Hinglish; Arabic, Indonesian, Malay
License Apache 2.0

Citation

@misc{frontiersmind2026embeddingnandi,
  title        = {EmbeddingNandi: Open Long-Context Embedding Models for English, Indic and Southeast Asian Languages},
  author       = {{FrontiersMind}},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/FrontiersMind/EmbeddingNandi-450M}}
}