Model reference · open weights
all-MiniLM-L6-nepali is an open-weight embedding model from jangedoo. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | jangedoo |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Parameters (lead) | 23M |
| Context | 512 tokens |
| Runs with | sentence-transformers |
| Based on | jangedoo/all-MiniLM-L6-v2-nepali |
| Released | 2024-08-18 |
| Popularity | 9k downloads / month |
| Licence | Unknown |
About
This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2 on the momo22/eng2nep, NepaliAI/Nepali-Health-Fact, wikimedia/wikipedia, wisewizer/nepali-news dataset. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
Two step approach was taken to fine-tune this model.
First I took sentence-transformers/all-MiniLM-L6-v2 model and then made it multi-lingual (English and Nepali). The approach is describe here Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation.
The basic idea is that we need a parallel corpus. In this case I took momo22/eng2nep which contains English to Nepali sentence pairs.
Then the sentence-transformers/all-MiniLM-L6-v2 was used to generate embeddings for English sentences.
While training, the model was fine-tuned in a way that it produces embeddings for Nepali sentences to be similar to the corresponding English embeddings. The loss function used was MSELoss.
Next, this new multi-lingual model was further fine tuned on datasets like Nepali Wikipedia articles, Nepali News, Nepali Health Q&A.
I took the title and body from those datasets and treat them as anchor and positive for computing pair-wise similarity. Specifically, the MultipleNegativesSymmetricRankingLoss was used.
Basically this will force the embeddings of anchor to be similar to positive and vice-versa. The negative samples are automatically mined from a batch and the objective is to make sure similarity between anchor and positive is higher than anchor and negative.
The rest of the content was generated automatically by sentence-transformers library.
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
(2): Normalize()
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("jangedoo/all-MiniLM-L6-v2-nepali")
# Run inference
sentences = [
'अर्थवेद',
'अर्थवेद\nचार वेदका चार उपवेद मानिन्छ-\nधनुर्वेद, \nगान्धर्ववेद, \nआयुर्वेद, र \nअर्थवेद \nपं. धनराज शास्त्रीले अर्थवेदका चार ठूला र दुइ ाना ग्रन्थको उल्लेख गरेका छन्\n\nठूला ग्रन्थ\nचार ठूला ग्रन्थ यस प्रकार छन् \n १. अर्थोपवेद– यसको श्लोक संख्या एक लाख बताइएको छ । \n २.अर्थवेद– यसको श्लोक संख्या ३० हजार बताइएको छ । \n ३. अर्थ चन्द्रोदय– यसको श्लोक संख्या २० हजार बताइएको छ ।',
'डा. फेल, डिटेक्टिभ, एन्ड अदर स्टोरिज अमेरिकन उपन्यासकार तथा लेखक जोन डिक्सन कारद्वारा लिखित लघुकथा सङ्ग्रह हो । \n\nसन्दर्भ सूची\n\nलघुकथा संग्रहहरू\nपुस्तकहरू\nजोन डिक्सन कारका लघुकथा संग्रहहरू',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.5404 |
| cosine_accuracy@3 | 0.6196 |
| cosine_accuracy@5 | 0.654 |
| cosine_accuracy@10 | 0.6962 |
| cosine_precision@1 | 0.5404 |
| cosine_precision@3 | 0.2065 |
| cosine_precision@5 | 0.1308 |
| cosine_precision@10 | 0.0696 |
| cosine_recall@1 | 0.5404 |
| cosine_recall@3 | 0.6196 |
| cosine_recall@5 | 0.654 |
| cosine_recall@10 | 0.6962 |
| cosine_ndcg@10 | 0.6146 |
| cosine_mrr@10 | 0.5889 |
| cosine_mrr@20 | 0.5918 |
| cosine_mrr@50 | 0.5937 |
| cosine_map@100 | 0.5944 |
From the published model card. Full card on the HuggingFace links in the sidebar.
Benchmarks
As published on the model card — the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| Information Retrieval | Unknown | Cosine Accuracy@1 | 0.540 |
| Information Retrieval | Unknown | Cosine Accuracy@3 | 0.620 |
| Information Retrieval | Unknown | Cosine Accuracy@5 | 0.654 |
| Information Retrieval | Unknown | Cosine Accuracy@10 | 0.696 |
| Information Retrieval | Unknown | Cosine Precision@1 | 0.540 |
| Information Retrieval | Unknown | Cosine Precision@3 | 0.207 |
| Information Retrieval | Unknown | Cosine Precision@5 | 0.131 |
| Information Retrieval | Unknown | Cosine Precision@10 | 0.070 |
| Information Retrieval | Unknown | Cosine Recall@1 | 0.540 |
| Information Retrieval | Unknown | Cosine Recall@3 | 0.620 |
| Information Retrieval | Unknown | Cosine Recall@5 | 0.654 |
| Information Retrieval | Unknown | Cosine Recall@10 | 0.696 |
| Information Retrieval | Unknown | Cosine Ndcg@10 | 0.615 |
| Information Retrieval | Unknown | Cosine Mrr@10 | 0.589 |
| Information Retrieval | Unknown | Cosine Mrr@20 | 0.592 |
| Information Retrieval | Unknown | Cosine Mrr@50 | 0.594 |
| Information Retrieval | Unknown | Cosine Map@100 | 0.594 |
Using it via the API
Once AxForge deploys all-minilm-l6-nepali for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (all-minilm-l6-nepali below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/embeddings \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"all-minilm-l6-nepali","input":"text to embed"}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.