Sentence Similarity
sentence-transformers
Safetensors
nandi_encoder
embeddings
feature-extraction
mteb
retrieval
multilingual
indic
long-context
frontiersmind
nandi
custom_code
Instructions to use FrontiersMind/EmbeddingNandi-150M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use FrontiersMind/EmbeddingNandi-150M with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("FrontiersMind/EmbeddingNandi-150M", trust_remote_code=True) sentences = [ "task: sentence similarity | query: How do I return a damaged product?", "task: sentence similarity | query: खराब सामान वापस कैसे करें?", "task: sentence similarity | query: damaged product wapas kaise kare?", "task: sentence similarity | query: What is the weather like today?" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Download configuration_nandi_encoder.py from FrontiersMind/EmbeddingNandi-150M: direct link, hf CLI and curl.
- Browser
- Download file 4.73 kB
-
https://huggingface.co/FrontiersMind/EmbeddingNandi-150M/resolve/main/configuration_nandi_encoder.py
- Command line
-
hf download hf://FrontiersMind/EmbeddingNandi-150M/configuration_nandi_encoder.py
-
curl -L -o configuration_nandi_encoder.py https://huggingface.co/FrontiersMind/EmbeddingNandi-150M/resolve/main/configuration_nandi_encoder.py
4.73 kB
| # Copyright 2026 FrontiersMind. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| """Configuration of the Nandi encoder (the bidirectional Nandi architecture of NandiBERT and EmbeddingNandi).""" | |
| from transformers.configuration_utils import PretrainedConfig | |
| class NandiEncoderConfig(PretrainedConfig): | |
| r""" | |
| Configuration for the Nandi encoder. The architecture is the Nandi decoder's (RMSNorm, SwiGLU, GQA, RoPE, | |
| factorized embeddings, optional layer sharing) with full bidirectional attention. The defaults are the | |
| EmbeddingNandi-150M architecture (28 x 768, 6 query / 2 KV heads, rank-192 factorized embeddings, QK-norm). | |
| ```python | |
| >>> from sentence_transformers import SentenceTransformer | |
| >>> model = SentenceTransformer("FrontiersMind/EmbeddingNandi-150M", trust_remote_code=True) | |
| ``` | |
| Args: | |
| classifier_pooling (`str`, *optional*, defaults to `"mean"`): | |
| Pooling for `NandiForSequenceClassification`: `"mean"` over non-padding tokens, or `"first"` (the | |
| `<|endoftext|>` token every input starts with). | |
| classifier_dropout (`float`, *optional*, defaults to 0.0): | |
| Dropout before the classification heads. | |
| """ | |
| model_type = "nandi_encoder" | |
| def __init__( | |
| self, | |
| vocab_size=100352, | |
| hidden_size=768, | |
| intermediate_size=1280, | |
| num_hidden_layers=28, | |
| num_attention_heads=6, | |
| num_key_value_heads=2, | |
| head_dim=None, | |
| hidden_act="silu", | |
| max_position_embeddings=16384, | |
| initializer_range=0.008, | |
| rms_norm_eps=1e-6, | |
| pad_token_id=3, | |
| bos_token_id=0, | |
| eos_token_id=0, | |
| mask_token_id=4, | |
| tie_word_embeddings=False, | |
| rope_parameters=None, | |
| attention_bias=False, | |
| attention_dropout=0.0, | |
| mlp_bias=False, | |
| factorized_embedding=True, | |
| embedding_rank=192, | |
| layer_sharing=False, | |
| layer_sharing_repeats=1, | |
| classifier_pooling="mean", | |
| classifier_dropout=0.0, | |
| qk_norm=True, | |
| **kwargs, | |
| ): | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.intermediate_size = intermediate_size | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_attention_heads = num_attention_heads | |
| self.num_key_value_heads = num_key_value_heads if num_key_value_heads is not None else num_attention_heads | |
| self.head_dim = head_dim if head_dim is not None else hidden_size // num_attention_heads | |
| self.hidden_act = hidden_act | |
| self.max_position_embeddings = max_position_embeddings | |
| self.initializer_range = initializer_range | |
| self.rms_norm_eps = rms_norm_eps | |
| self.mask_token_id = mask_token_id | |
| self.rope_parameters = rope_parameters if rope_parameters is not None else {"rope_type": "default", "rope_theta": 1000000.0} | |
| self.attention_bias = attention_bias | |
| self.attention_dropout = attention_dropout | |
| self.mlp_bias = mlp_bias | |
| self.factorized_embedding = factorized_embedding | |
| self.embedding_rank = embedding_rank | |
| self.layer_sharing = layer_sharing | |
| self.layer_sharing_repeats = layer_sharing_repeats if layer_sharing else 1 | |
| if classifier_pooling not in ("mean", "first"): | |
| raise ValueError(f"`classifier_pooling` must be 'mean' or 'first', got {classifier_pooling!r}") | |
| self.classifier_pooling = classifier_pooling | |
| self.classifier_dropout = classifier_dropout | |
| self.qk_norm = qk_norm # RMSNorm on Q and K per head (over head_dim) before RoPE | |
| if self.factorized_embedding and self.embedding_rank <= 0: | |
| raise ValueError(f"`embedding_rank` must be positive when `factorized_embedding=True`, got {embedding_rank}.") | |
| if self.layer_sharing_repeats < 1: | |
| raise ValueError(f"`layer_sharing_repeats` must be >= 1, got {self.layer_sharing_repeats}.") | |
| super().__init__( | |
| pad_token_id=pad_token_id, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| tie_word_embeddings=tie_word_embeddings, | |
| **kwargs, | |
| ) | |
| __all__ = ["NandiEncoderConfig"] | |