Sentence Similarity
sentence-transformers
ONNX
Safetensors
Transformers.js
modernbert
feature-extraction
embeddings
romanized
transliteration
hinglish
code-mixing
indic
india
cross-lingual
distillation
text-embeddings-inference
Instructions to use altslate/indic-embed-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use altslate/indic-embed-small with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("altslate/indic-embed-small") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers.js
How to use altslate/indic-embed-small with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('feature-extraction', 'altslate/indic-embed-small'); - Notebooks
- Google Colab
- Kaggle
|
Download README.md from altslate/indic-embed-small: direct link, hf CLI and curl.
- Browser
- Download file 12.4 kB
-
https://huggingface.co/altslate/indic-embed-small/resolve/main/README.md
- Command line
-
hf download hf://altslate/indic-embed-small/README.md
-
curl -L -o README.md https://huggingface.co/altslate/indic-embed-small/resolve/main/README.md
12.4 kB
| license: apache-2.0 | |
| base_model: jhu-clsp/mmBERT-small | |
| language: | |
| - en | |
| - hi | |
| - bn | |
| - ta | |
| - te | |
| - mr | |
| - gu | |
| - kn | |
| - ml | |
| - pa | |
| - ur | |
| pipeline_tag: sentence-similarity | |
| library_name: sentence-transformers | |
| tags: | |
| - sentence-transformers | |
| - sentence-similarity | |
| - feature-extraction | |
| - embeddings | |
| - romanized | |
| - transliteration | |
| - hinglish | |
| - code-mixing | |
| - indic | |
| - india | |
| - cross-lingual | |
| - distillation | |
| - transformers.js | |
| # indic-embed-small | |
| > **v2 (2026-11-26):** better at graded similarity: English STS 80.0 → 83.9 (test), after adding everyday English sentences | |
| > (SNLI) to training. The other results moved by 0.001 at most. The previous version is the `v1` tag (`revision="v1"`). | |
| A 140M-parameter sentence embedding model for Indian languages **as people actually type them**: native script, | |
| romanized ("kal meeting cancel ho gayi"), and code-mixed, plus English. A romanized message, its native-script | |
| original and its English translation land close together, so you can search native-script documents with romanized | |
| queries (or the reverse) without transliterating first. | |
| Languages: Hindi, Bengali, Tamil, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Urdu, English. | |
| Output: 1024-dimensional, L2-normalized vectors (cosine = dot product). Max input length used in training: 128 tokens. | |
| Try it in your browser: **[romanized search demo](https://huggingface.co/spaces/altslate/indic-romanized-search)**. | |
| It is a distillation of [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3) (568M) into | |
| [jhu-clsp/mmBERT-small](https://huggingface.co/jhu-clsp/mmBERT-small), trained so that romanized and native inputs map to | |
| the teacher's embedding of the native sentence, and Indic inputs map to the teacher's embedding of the English translation. | |
| ``` | |
| kal meeting कल मीटिंग The meeting நாளை கூட்டம் aaj bahut | |
| cancel ho कैंसल हो गई tomorrow was ரத்து garmi hai | |
| gayi cancelled. செய்யப்பட்டது yaar | |
| kal meeting cancel ho gayi 1.00 0.89 0.97 0.98 0.52 | |
| कल मीटिंग कैंसल हो गई 0.89 1.00 0.87 0.89 0.59 | |
| The meeting tomorrow was cancelled. 0.97 0.87 1.00 0.96 0.50 | |
| ``` | |
| ## Usage | |
| ### sentence-transformers | |
| ```python | |
| from sentence_transformers import SentenceTransformer | |
| model = SentenceTransformer("altslate/indic-embed-small") | |
| docs = ["कल मीटिंग कैंसल हो गई", "আজ খুব গরম পড়েছে", "நாளை கூட்டம் ரத்து செய்யப்பட்டது"] | |
| query = "kal meeting cancel ho gayi" | |
| scores = model.encode([query]) @ model.encode(docs).T | |
| print(scores) # [[0.89 0.55 0.98]]: the Hindi original and the Tamil translation score high, the unrelated Bengali sentence low | |
| ``` | |
| No prefix or instruction is needed. Tested with sentence-transformers 5.1.2 (transformers 4.57.6) and 6.3.0 | |
| (transformers 5.24.0); both give the same vectors. | |
| ### transformers.js (browser or Node) | |
| `onnx/model.onnx` (fp32, 564 MB) and `onnx/model_fp16.onnx` (282 MB) contain the whole sentence encoder, including pooling | |
| and the projection head. Read the `sentence_embedding` output (already normalized): | |
| ```js | |
| import { AutoTokenizer, AutoModel } from "@huggingface/transformers"; | |
| const tok = await AutoTokenizer.from_pretrained("altslate/indic-embed-small"); | |
| const model = await AutoModel.from_pretrained("altslate/indic-embed-small", { dtype: "fp16" }); // or "fp32" | |
| const { sentence_embedding } = await model(tok(["kal meeting cancel ho gayi", "कल मीटिंग कैंसल हो गई"], { padding: true, truncation: true, max_length: 128 })); | |
| const [a, b] = sentence_embedding.tolist(); | |
| console.log(a.reduce((s, x, i) => s + x * b[i], 0)); // ~0.89 | |
| ``` | |
| Tested with `@huggingface/transformers` 4.3.2 in Node 22: fp32 matches PyTorch (cosine 1.0000 on every test sentence), fp16 min | |
| cosine 0.9996. Dynamic int8 quantization lost too much on this model (mean cosine 0.94 against fp32), so there is | |
| no int8 file. Don't use the `feature-extraction` pipeline: it would mean-pool the 384-d token states and skip the projection head. | |
| ## Results | |
| All test sets are held out: no sentence from any of them (or from their dev splits) was used in training. Model choices | |
| (four training rounds, which checkpoint to ship) were made on the dev splits, with one exception noted under STS. | |
| Recall@1 is averaged over both directions and over the 10 languages; STS is Spearman × 100. | |
| | Model | Params | Romanized ↔ native (Dakshina) | English ↔ Indic (FLORES) | English ↔ romanized Indic (FLORES, our romanizer) | English ↔ Indic STS | English STS | | |
| |---|---|---|---|---|---|---| | |
| | **altslate/indic-embed-small** (v2) | 140M | **0.992** | 0.999 | **0.996** | 53.0 | 83.9 | | |
| | previous revision (v1) | 140M | 0.993 | 0.999 | 0.996 | 53.0 | 80.0 | | |
| | [l3cube-pune/indic-sentence-similarity-sbert](https://huggingface.co/l3cube-pune/indic-sentence-similarity-sbert) | 237M | 0.824 | 0.996 | 0.652 | 56.3 | **85.3** | | |
| | [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3) (teacher) | 568M | 0.608 | 0.999 | 0.413 | 53.2 | 84.8 | | |
| | [sentence-transformers/LaBSE](https://huggingface.co/sentence-transformers/LaBSE) | 471M | 0.507 | **1.000** | 0.423 | **56.5** | 72.2 | | |
| | [intfloat/multilingual-e5-small](https://huggingface.co/intfloat/multilingual-e5-small) | 118M | 0.479 | 0.996 | 0.286 | 42.4 | 83.4 | | |
| | [paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) | 118M | 0.076 | 0.474 | 0.112 | 22.5 | 84.3 | | |
| Per language, romanized ↔ native recall@1 (Dakshina test, 1000 sentences each): | |
| | | hi | bn | ta | te | mr | gu | kn | ml | pa | ur | | |
| |---|---|---|---|---|---|---|---|---|---|---| | |
| | **this model** | **1.00** | **0.99** | **0.99** | **0.98** | **0.99** | **1.00** | **1.00** | **0.99** | **0.99** | **0.99** | | |
| | l3cube indic sbert | 0.97 | 0.69 | 0.62 | 0.83 | 0.90 | 0.87 | 0.78 | 0.85 | 0.89 | 0.85 | | |
| | bge-m3 | 0.69 | 0.65 | 0.47 | 0.59 | 0.63 | 0.58 | 0.52 | 0.56 | 0.65 | 0.74 | | |
| The tasks: | |
| - **Romanized ↔ native (main task):** [Dakshina](https://github.com/google-research-datasets/dakshina) test split, sentences | |
| romanized **by people**, 1000 per language (native side over 20 characters, deduplicated). Each romanized sentence must find | |
| its native-script original among 1000 candidates, and the reverse. | |
| - **English ↔ Indic:** [IndicGenBench FLORES](https://huggingface.co/datasets/mteb/IndicGenBenchFloresBitextMining) bitext, | |
| test split. Every model here except MiniLM is near the ceiling; it mostly shows the model has not lost its cross-lingual | |
| alignment. | |
| - **English ↔ romanized Indic:** the same FLORES pairs, with the Indic side romanized by the dictionary + rule romanizer used to | |
| build our training data. **This favours our model** (it was trained on that romanizer's output, though never on these | |
| sentences); read the Dakshina column for human romanization. | |
| - **English ↔ Indic STS:** [IndicCrosslingualSTS](https://huggingface.co/datasets/mteb/IndicCrosslingualSTS) (en–xx, 10 | |
| languages). It has only a test split, and we compared training rounds on it, so this number was used for model selection | |
| and is optimistic for our model by an unknown amount. Urdu is low for every model (24 at most). | |
| - **English STS:** [STS Benchmark](https://huggingface.co/datasets/mteb/stsbenchmark-sts) test (validation split used for | |
| choices). The v2 English training sentences (SNLI) were filtered so that none matches an STS Benchmark sentence even after | |
| lower-casing and removing punctuation and the articles a/an/the; we checked that no test sentence has such a near-duplicate. | |
| ## Known limitations | |
| - **Graded similarity is still its weakest area.** It is excellent at finding *the* matching sentence, but only on par with | |
| the other models at scoring *how* similar two sentences are: English STS 83.9 (e5-small 83.4, MiniLM 84.3, bge-m3 84.8, l3cube | |
| 85.3); English ↔ Indic STS 53.0, against 56.3 for l3cube and 56.5 for LaBSE. If you rank by fine similarity differences (deduplication | |
| thresholds, semantic similarity scores), test it on your data first. | |
| - **English-only search:** use an English model (e5, bge). This model is for mixed Indic / romanized / English text. | |
| - **Telugu and Urdu STS** are its lowest (42.6 and 21.5). | |
| - Romanized training data was made by a dictionary + rule romanizer, not collected from chat, so unusual spellings, heavy | |
| abbreviations ("kl mtng cncl") and mixed-language slang are less covered. Romanized Urdu, Punjabi and Marathi have the | |
| smallest romanization dictionaries. | |
| - Inputs were at most 128 tokens in training; long documents should be split into sentences or short passages. | |
| - Not evaluated on retrieval of long passages, classification or clustering benchmarks. | |
| ## Training | |
| Teacher: BAAI/bge-m3 dense embeddings (CLS, normalized). Student: mmBERT-small encoder → mean pooling → linear 384 → 1024 → | |
| L2 normalization. Loss: MSE to the teacher vector of the target sentence + in-batch contrastive loss (temperature 0.05; rows that | |
| share a target are not negatives). Four rounds, each fine-tuning the previous one (batch 128, AdamW, linear warm-up and decay): | |
| 1. 17.7k steps, lr 5e-5: native sentences → teacher(native); the same sentences romanized and half-romanized → teacher(native); | |
| English Wikipedia sentences → teacher(English); Hinglish → teacher(English translation). | |
| 2. 14.9k steps, lr 3e-5: 1.41M more native sentences (up to 150k per language) + 500k replayed round-1 rows. | |
| 3. 28.1k steps, lr 3e-5: 1.2M English–Indic sentence pairs (120k per language): Indic → teacher(English), romanized Indic (half | |
| of them) → teacher(English), English → teacher(English) + 600k replayed round-2 rows. (This was v1.) | |
| 4. 11.7k steps, lr 2e-5 (v2): 500k English sentences from SNLI premises and hypotheses (everyday, caption-style text) → | |
| teacher(English) + 1.0M replayed round-3 rows. | |
| About 9.5 GPU hours in total on one NVIDIA DGX Spark (GB10), plus about an hour of teacher encoding. No text was generated by a | |
| language model. | |
| **Data (all used under their licenses; none of it is redistributed here):** | |
| | Data | Used for | License | | |
| |---|---|---| | |
| | [Dakshina](https://github.com/google-research-datasets/dakshina) native Wikipedia sentences (TRAIN split) and romanization lexicons (TRAIN) | native sentences; word romanizations | CC BY-SA 4.0 | | |
| | [Aksharantar](https://huggingface.co/datasets/ai4bharat/Aksharantar) word pairs (TRAIN) | word romanizations | CC0 / CC-BY 4.0 (per source) | | |
| | English Wikipedia (one shard of the 20231101 dump) | English sentences | CC BY-SA 4.0 | | |
| | [findnitai/english-to-hinglish](https://huggingface.co/datasets/findnitai/english-to-hinglish) | Hinglish → English pairs | Apache-2.0 | | |
| | [stanfordnlp/snli](https://huggingface.co/datasets/stanfordnlp/snli) premises and hypotheses (train split, 10–300 characters) | English sentences (v2) | CC BY-SA 4.0 | | |
| | [allenai/nllb](https://huggingface.co/datasets/allenai/nllb) mined English–Indic bitext (highest-scoring part, filtered, ≤2% from any one website) | English–Indic pairs | ODC-BY 1.0 (CommonCrawl-derived; upstream terms apply) | | |
| Every sentence that appears in any evaluation set above (Dakshina dev/test, all FLORES splits, IndicCrosslingualSTS) was removed | |
| from the training data before training (exact match after whitespace normalization; for the SNLI sentences also near-duplicates | |
| of these and of STS Benchmark, as described above). | |
| Code: [github.com/AltSlate-Labs/indic-chat-toolkit](https://github.com/AltSlate-Labs/indic-chat-toolkit). | |
| ## License | |
| Apache-2.0. The base model (mmBERT-small) and the teacher (bge-m3) are MIT-licensed. | |
| ## Citation | |
| If you use this model, please cite the teacher, the base model and the datasets above (Dakshina: Roark et al., 2020; | |
| Aksharantar: Madhani et al., 2022; NLLB: NLLB Team, 2022), and the multilingual distillation method (Reimers & Gurevych, 2020). | |