--- 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-150M 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-150M
EmbeddingNandi-150M by FrontiersMind

Hugging Face | GitHub | Launch Blog | Website

License: Apache-2.0 | Authors: FrontiersMind

EmbeddingNandi is a family of open, long-context embedding models for English, Indic and Southeast Asian languages, built on the [NandiBERT](https://huggingface.co/FrontiersMind/NandiBERT-150M) 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** *(this model)* | 150M | 768 | 16K | [NandiBERT-150M](https://huggingface.co/FrontiersMind/NandiBERT-150M) | Compact long-context embedding model | | [EmbeddingNandi-450M](https://huggingface.co/FrontiersMind/EmbeddingNandi-450M) | 450M | 1,024 | 32K | [NandiBERT-450M](https://huggingface.co/FrontiersMind/NandiBERT-450M) | Long-context embedding model | ## Description - **One Model. From English to Indic and Beyond:** Built on NandiBERT-150M, 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. - **16K context:** A 16,384-token window, so long documents can be embedded in a single pass without chunking, with the 100K-token multilingual vocabulary shared across the NandiBERT family. - **Deep and efficient:** Inherited from NandiBERT-150M: 28 layers at 768 hidden size, with grouped-query attention (6 query heads, 2 key-value heads), QK-norm and SwiGLU, sized for fast inference and low-cost serving. The 100K-token vocabulary is stored as a rank-192 factorized embedding. - **Embedding output:** 768-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 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), for models up to about 270M parameters. EmbeddingNandi-150M was evaluated with the open-source [MTEB library](https://github.com/embeddings-benchmark/mteb) (version 2.26.19), at its maximum input length of 16,384 tokens and with float32 compute. Scores for the other models are MTEB results, except the MTEB(Indic, v1) scores of granite-embedding-125m-english, granite-embedding-english-r2 and UltraBERT-Embed-150M, which we evaluated ourselves with the same MTEB version (float32, at 512, 8,192 and 32,768 tokens respectively); "-" means the model has no score for that benchmark. Average is the mean of the three benchmark scores, for models that have all three. Best score in each column is in bold. | Model | MTEB(eng, v2) | MTEB(Code, v1) | MTEB(Indic, v1) | Average (all three) | |---|---|---|---|---| | **EmbeddingNandi-150M (146M)** | 65.85 | **75.80** | **74.33** | **71.99** | | UltraBERT-Embed-150M (151M) | **67.24** | 73.30 | 42.16 | 60.90 | | granite-embedding-english-r2 (149M) | 62.84 | 57.22 | 32.85 | 50.97 | | granite-embedding-125m-english (125M) | 62.10 | 53.30 | 34.46 | 49.95 | | bekko-embedding-v1-a25m (123M) | 62.25 | 60.27 | 65.43 | 62.65 | | multilingual-e5-small (118M) | 59.69 | 53.53 | 62.15 | 58.46 | | harrier-oss-v1-270m (268M) | 67.19 | 62.98 | 69.81 | 66.66 |
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-150M (146M)** | **74.33** | **84.36** | **72.19** | **54.32** | **82.57** | **86.07** | **87.40** | 53.95 | | UltraBERT-Embed-150M (151M) | 42.16 | 16.91 | 49.62 | 3.41 | 56.44 | 65.18 | 43.81 | 1.32 | | granite-embedding-english-r2 (149M) | 32.85 | 3.27 | 42.77 | 2.53 | 51.89 | 49.27 | 17.21 | -0.86 | | granite-embedding-125m-english (125M) | 34.46 | 5.54 | 44.68 | 3.04 | 51.75 | 49.23 | 17.94 | 2.07 | | bekko-embedding-v1-a25m (123M) | 65.43 | 75.25 | 64.45 | 27.83 | 69.64 | 83.66 | 76.96 | 49.63 | | multilingual-e5-small (118M) | 62.15 | 73.38 | 67.00 | 26.39 | 73.32 | 72.20 | 76.82 | 45.93 | | harrier-oss-v1-270m (268M) | 69.81 | 81.54 | 70.84 | 52.51 | 80.12 | 61.90 | 66.38 | **75.35** |
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-150M (146M)** | 65.85 | **87.78** | 50.54 | 82.43 | 46.52 | 49.75 | 81.15 | 24.95 | | UltraBERT-Embed-150M (151M) | **67.24** | 81.74 | 49.70 | **85.33** | 47.50 | **57.20** | **83.03** | **34.89** | | granite-embedding-english-r2 (149M) | 62.84 | 70.71 | 47.20 | 79.34 | 49.10 | 56.43 | 78.12 | 29.31 | | granite-embedding-125m-english (125M) | 62.10 | 68.30 | 47.30 | 79.60 | **49.40** | 55.70 | 77.60 | 29.30 | | bekko-embedding-v1-a25m (123M) | 62.25 | 74.70 | 44.64 | 83.57 | 45.60 | 49.74 | 80.68 | 32.34 | | multilingual-e5-small (118M) | 59.69 | 70.69 | 41.36 | 84.09 | 43.19 | 46.43 | 79.84 | 29.22 | | harrier-oss-v1-270m (268M) | 67.19 | 85.74 | **53.58** | 80.89 | 45.61 | 53.21 | 82.91 | 28.21 |
MTEB(Code, v1) by task | Model | Mean (12) | AppsRetrieval | CodeEditSearchRetrieval | CodeFeedbackMT | CodeFeedbackST | CodeSearchNetCCRetrieval | CodeSearchNetRetrieval | CodeTransOceanContest | CodeTransOceanDL | CosQA | COIRCodeSearchNetRetrieval | StackOverflowQA | SyntheticText2SQL | |---|---|---|---|---|---|---|---|---|---|---|---|---|---| | **EmbeddingNandi-150M (146M)** | **75.80** | **70.65** | **77.57** | **93.84** | **87.51** | 88.40 | 88.54 | 83.10 | 35.69 | **40.13** | **84.44** | 91.51 | **68.20** | | UltraBERT-Embed-150M (151M) | 73.30 | 68.50 | 62.21 | 84.37 | 86.40 | **93.73** | **90.03** | **88.08** | **37.23** | 36.29 | 82.23 | **92.43** | 58.05 | | granite-embedding-english-r2 (149M) | 57.22 | 13.96 | 59.35 | 52.54 | 77.18 | 47.67 | 80.79 | 77.07 | 35.03 | 37.01 | 64.65 | 91.80 | 49.55 | | granite-embedding-125m-english (125M) | 53.30 | 11.80 | 58.80 | 42.10 | 75.30 | 47.60 | 76.90 | 66.70 | 29.60 | 36.60 | 55.10 | 89.80 | 48.70 | | bekko-embedding-v1-a25m (123M) | 60.27 | - | - | - | - | - | - | - | - | - | - | - | - | | multilingual-e5-small (118M) | 53.53 | - | - | - | - | - | - | - | - | - | - | - | - | | 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 |
## Quick Start Install Sentence Transformers (tested with sentence-transformers 6.1.0 and transformers 5.20.2): ```bash 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: ```python from sentence_transformers import SentenceTransformer model = SentenceTransformer("FrontiersMind/EmbeddingNandi-150M", 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, 768) (4, 768) print(model.similarity(query_embs, doc_embs)) # tensor([[0.7959, 0.0706, 0.2876, 0.1923], # [0.1152, 0.7974, 0.0967, 0.2378], # [0.1909, 0.1029, 0.6422, 0.0747]]) ``` ## Best Practices ### 1. Task Prompts EmbeddingNandi-150M 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`: ```python 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.6099, 0.1002]]) ``` For a symmetric task, use the same prompt for every text: ```python 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.7178, 0.2270], # [0.7178, 1.0000, 0.0413], # [0.2270, 0.0413, 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-150M is trained with Matryoshka Representation Learning, so the 768-dimensional vector can be shortened by keeping only its first values. The supported sizes are 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 | |---|---| | 768 | 100% | | 512 | 66.7% | | 256 | 33.3% | | 128 | 16.7% | * **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: ```python 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): ```python model_256 = SentenceTransformer("FrontiersMind/EmbeddingNandi-150M", 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 16,384 tokens, and `model.max_seq_length` is 16384 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: ```python model.max_seq_length = 1024 ``` ### 4. Numerical Precision Run inference in `bfloat16` or `float32`. The weights are stored in `bfloat16`. Use `float32` on CPU, where it runs faster, and for long inputs (4K tokens or more). On GPU, `bfloat16` uses much less memory. ```python 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-150M", trust_remote_code=True, model_kwargs={"dtype": dtype}, ) ``` ## Usage with Transformers EmbeddingNandi-150M 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 ```python import torch import torch.nn.functional as F from transformers import AutoModel, AutoTokenizer model_id = "FrontiersMind/EmbeddingNandi-150M" 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=16384, 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.7959, 0.0707, 0.2877, 0.1923], # [0.1152, 0.7974, 0.0968, 0.2380], # [0.1910, 0.1030, 0.6422, 0.0747]]) ```
## Model Description | | | |---|---| | Base model | [NandiBERT-150M](https://huggingface.co/FrontiersMind/NandiBERT-150M) | | Parameters | 146M | | Layers / hidden size | 28 / 768 | | Attention | Grouped-query, 6 query heads and 2 key-value heads | | Embedding dimension | 768 (Matryoshka: 512, 256, 128) | | Pooling | Mean over all tokens, task prompt included | | Similarity | Cosine (L2-normalized output) | | Max sequence length | 16,384 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 ```bibtex @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-150M}} } ```