Sentence Similarity
sentence-transformers
ONNX
Safetensors
bert
embeddings
indic
romanized
transliteration
code-mixing
hinglish
tanglish
text-embeddings-inference
Instructions to use cidcodes/indic-e5-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use cidcodes/indic-e5-small with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("cidcodes/indic-e5-small") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
|
Download README.md from cidcodes/indic-e5-small: direct link, hf CLI and curl.
- Browser
- Download file 7.75 kB
-
https://huggingface.co/cidcodes/indic-e5-small/resolve/main/README.md
- Command line
-
hf download hf://cidcodes/indic-e5-small/README.md
-
curl -L -o README.md https://huggingface.co/cidcodes/indic-e5-small/resolve/main/README.md
7.75 kB
| license: mit | |
| base_model: intfloat/multilingual-e5-small | |
| library_name: sentence-transformers | |
| pipeline_tag: sentence-similarity | |
| language: [hi, bn, ta, te, ml, mr, gu, kn, pa, or, as, ur, ne, en] | |
| tags: [sentence-transformers, embeddings, indic, romanized, transliteration, code-mixing, hinglish, tanglish] | |
| datasets: [ai4bharat/sangraha, ai4bharat/BPCC] | |
| # indic-e5-small | |
| A 47M-parameter sentence-embedding model for 13 Indian languages and English that understands Indic text **in its | |
| native script and typed in the Latin alphabet** ("mujhe kal office jaana hai", "naan nalaikku varuven"). | |
| It is [multilingual-e5-small](https://huggingface.co/intfloat/multilingual-e5-small) with the vocabulary trimmed | |
| to the scripts that matter here (250K → 64K tokens, 118M → 47M parameters), then distilled twice: first so that | |
| romanized, casually spelled and code-mixed text lands where e5 puts the native-script text, then from | |
| [bge-m3](https://huggingface.co/BAAI/bge-m3) (568M), a 12x larger teacher. | |
| | model | params | MTEB(Indic) | retrieval | Dakshina roman→native R@1 | native→roman R@1 | TanglishSTS | | |
| |---|---|---|---|---|---|---| | |
| | **indic-e5-small v2** | **47M** | **0.673** | **0.835** | **0.931** | **0.926** | **0.760** | | |
| | indic-e5-small v1 | 47M | 0.651 | 0.780 | 0.827 | 0.905 | 0.699 | | |
| | multilingual-e5-small | 118M | 0.648 | 0.768 | 0.396 | 0.498 | 0.729 | | |
| | multilingual-e5-large | 560M | 0.680 | 0.826 | 0.435 | 0.556 | 0.721 | | |
| | bge-m3 | 568M | 0.686 | 0.824 | 0.534 | 0.586 | 0.758 | | |
| | Qwen3-Embedding-0.6B | 596M | 0.653 | 0.787 | – | – | – | | |
| | LaBSE | 471M | 0.617 | 0.643 | 0.478 | 0.436 | 0.750 | | |
| | L3Cube indic-sentence-similarity-sbert | 238M | 0.592 | 0.676 | 0.772 | 0.819 | 0.692 | | |
| MTEB(Indic, v1): mean over its 20 tasks; retrieval: mean of its two retrieval tasks (Belebele 0.748, up from 0.611 | |
| in v1; XQuAD 0.921), above the 12x larger multilingual-e5-large and bge-m3. Dakshina: 2,000 human-romanized sentences per language, 10 | |
| languages, retrieval of the native sentence among 2,000. TanglishSTS: Spearman on 325 Tamil–English code-mixed | |
| pairs. Neither Dakshina nor TanglishSTS was used for training or for choosing checkpoints. TanglishSTS is small: | |
| the difference to multilingual-e5-small is +0.031, 95% paired-bootstrap CI [-0.012, +0.074], i.e. not significant. | |
| English: STSB 0.808 (multilingual-e5-small 0.841), SICK-R 0.766 (0.775). | |
| v1 is still available as revision `08d044b8` (`SentenceTransformer("cidcodes/indic-e5-small", revision="08d044b8")`). | |
| ## Usage | |
| Same prefixes as e5: `query: ` for queries and symmetric tasks, `passage: ` for documents. | |
| `encode_query` / `encode_document` add them for you (sentence-transformers 5+); with older versions, or with | |
| plain `encode`, add them yourself. | |
| ```python | |
| from sentence_transformers import SentenceTransformer | |
| model = SentenceTransformer("cidcodes/indic-e5-small") | |
| q = model.encode_query(["mujhe kal office jana hai"]) | |
| d = model.encode_document(["मुझे कल ऑफिस जाना है", "আজ খুব বৃষ্টি হচ্ছে", "I have to go to the office tomorrow"]) | |
| print(model.similarity(q, d)) | |
| ``` | |
| In the browser or Node with [transformers.js](https://github.com/huggingface/transformers.js) (`onnx/model_quantized.onnx`, | |
| 53 MB: int8, with the three FFN projections that have activation outliers kept in fp32; mean cosine 0.994 to the | |
| full model). Try it in the | |
| [demo Space](https://huggingface.co/spaces/cidcodes/indic-e5-small-demo). | |
| ```js | |
| import { pipeline } from "@huggingface/transformers"; | |
| const embed = await pipeline("feature-extraction", "cidcodes/indic-e5-small", { dtype: "q8" }); | |
| const out = await embed(["query: mujhe kal office jana hai", "passage: मुझे कल ऑफिस जाना है"], | |
| { pooling: "mean", normalize: true }); | |
| ``` | |
| ## How it was made | |
| Code: [github.com/codewithcid/indic-embed](https://github.com/codewithcid/indic-embed). MTEB: | |
| [embeddings-benchmark/mteb#6014](https://github.com/embeddings-benchmark/mteb/pull/6014). | |
| 1. **Vocabulary trimming.** Token frequencies from Wikipedia and Sangraha in 13 languages plus romanized text, | |
| balanced per language; the 64K most useful pieces (and every single character of the target scripts) are kept | |
| and the embedding rows gathered. MTEB(Indic) 0.6471 vs 0.6484 for the full model. | |
| 2. **Romanization distillation** ([Reimers & Gurevych, 2020](https://arxiv.org/abs/2004.09813)) = v1. Teacher: | |
| the original multilingual-e5-small, frozen. On 256K aligned native/romanized paragraphs from Sangraha's | |
| synthetic split, S(native), S(romanized), S(casually spelled romanized) and S(code-mixed romanized) are trained | |
| to match T(native), and S(English) to match T(English). Code-mixing swaps words for English using a lexicon | |
| induced from the teacher's own embeddings (margin-based mutual nearest neighbours). Short, query-like inputs | |
| come from the same 2-8 word window of each word-aligned pair. | |
| 3. **Distillation from bge-m3** (v2). bge-m3's embeddings are 1024-d, the student's 384-d, so two losses that do | |
| not need the same space: a linear head (384→1024, least-squares initialized, discarded after training) maps the | |
| student onto the teacher's embedding of the native text, and within each batch every row of the student's | |
| cosine similarities must correlate with the teacher's (Pearson per row, so only relative similarities matter). | |
| The same romanized/casual/code-mixed views and windows as in step 2, plus English paragraphs (targets: an equal | |
| blend of bge-m3's and e5-small's similarities, which keeps English quality) and 870K English↔Indic sentence | |
| pairs, where both sides go to the teacher's embedding of the English: PMIndia, and the human-translated Wiki | |
| and Daily (conversational) sets of BPCC. Checkpoints were chosen on held-out training-distribution data only | |
| (agreement with bge-m3, parallel-sentence retrieval), with romanized retrieval as a floor. Two epochs on one | |
| L4 GPU, about 4 hours. | |
| **Decontamination.** Every text in all 20 MTEB(Indic) tasks was normalized (Unicode NFC, lower case, punctuation | |
| removed), and any training pair whose English or Indic side equals a benchmark text or shares a run of 8 words with | |
| one was dropped: 507 BPCC pairs and 4,692 PMIndia pairs. PMIndia shares sentences with IndicCrosslingualSTS: an | |
| otherwise similar model trained before this filter scored 0.517 on it, this one 0.513. | |
| ## Limitations | |
| - Romanization in the training data is synthetic; very informal spellings and heavy code-mixing are only | |
| approximated by rules and an induced lexicon. | |
| - Tamil is the weakest language for romanized input (Dakshina R@1 0.845; Hindi 0.982). | |
| - Bitext mining (0.717) is below multilingual-e5-small (0.734), mostly on conversational sentences | |
| (IN22-Conv 0.586 vs 0.631); XQuAD retrieval is a little lower than v1 (0.921 vs 0.950). | |
| - Training text is mostly written language (news, Wikipedia-style, government releases). Very colloquial spoken | |
| forms (e.g. spoken Tamil "enakku pasikkudhu" for written "enakku pasikkiradhu") and short chat messages are weaker. | |
| - Max sequence length 512 as in e5-small, but training used 128 tokens. | |
| ## Data and licenses | |
| Base model: multilingual-e5-small (MIT). Teacher: bge-m3 (MIT). Training text: | |
| [Sangraha](https://huggingface.co/datasets/ai4bharat/sangraha) (AI4Bharat, CC BY 4.0) and | |
| [PMIndia](https://arxiv.org/abs/2001.09907) v1 (CC BY 4.0) and | |
| [BPCC-Human](https://huggingface.co/datasets/ai4bharat/BPCC) Wiki and Daily (AI4Bharat, IndicTrans2; CC BY 4.0). | |
| Evaluation only: Dakshina (CC BY-SA 4.0), | |
| TanglishSTS (CC BY 4.0), MTEB. | |