Downloads · 30 days
328
1% of all-time downloads
jangedoo/all-MiniLM-L6-v2-nepali
all-MiniLM-L6-v2-nepali is a sentence similarity model from jangedoo. Use it when you need a score for how close two texts are. It is set up for sentence-transformers.
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 & p…
Downloads · 30 days
328
1% of all-time downloads
All-time downloads
34.1K
Public
Parameters
22.7M
6.8 GB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors90.9 MB · 99%
From the Hugging Face model README
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]
<!--
### Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details>
-->
<!--
### Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details>
-->
<!--
### Out-of-Scope Use
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->
| 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 |
| anchor | positive | |
|---|---|---|
| type | string | string |
| details | <ul><li>min: 3 tokens</li><li>mean: 49.45 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 17 tokens</li><li>mean: 166.52 tokens</li><li>max: 256 tokens</li></ul> |
| anchor | positive |
|---|---|
| <code>पहिलो पटक फेस वेक्सिङ गर्ने प्रयास गरेपछि मेरो गालामा दागहरू देखा परे। मेरो डाक्टरले clindac A जेल सिफारिस गर्नुभयो। के मेरो छाला निको हुन लामो समय लाग्छ वा केहि दिनमा यो राम्रो हुन सक्छ?</code> | <code>डाक्टरबाट सुझावहरू:<br><br>1. उचित परीक्षणको लागि छाला विशेषज्ञसँग परामर्श गर्नुहोस्।<br>2. वाक्सिङ पछि तपाईंको अनुहारमा दागहरू सम्पर्क डर्मेटाइटिस वा एलर्जी प्रतिक्रियाको कारण हुन सक्छ।<br>3. डाक्टरले एन्टिहिस्टामिन औषधि र कोर्टिकोस्टेरोइड मलम लेख्न सक्छ।<br>4. रातो दागहरू छुन वा चुम्बन नगर्नुहोस्।<br>5. अहिलेको लागि प्रत्यक्ष सूर्यको जोखिम र कस्मेटिक उत्पादनहरूबाट बच्नुहोस्।</code> |
| <code>विश्व व्यापार केन्द्र</code> | <code>वर्ल्ड ट्रेड सेन्टर न्यु योर्क सहरको मैनछटनमा बनेका दुई टावर रूपी भवनहरूको जोडी थियो, जसलाई आतंकवादी सङ्गठन अल कायदासंग सम्बन्धित आतंकवादिहरूले ११ सितंबर, २००१मा नष्ट गरिदिएका थिए। <br><br>मूल वर्ल्ड ट्रेड सेन्टर तल्लो मैनहट्टन, न्यु योर्क सिटी, संयुक्त राज्य अमेरिकामा मीलको पत्थर जुडुवा टावरहरूको विशेषता सात भवनहरुका साथ एक जटिल थियो। जटिल ४ अप्रिल, १९७३लाई खोला, र ११ सेप्टेम्बरका हमलाको समयमा २००१मा नष्ट गरेको थियो।</code> |
| <code>एम्बुलेन्स</code> | <code>एम्बुलेन्स बिरामी वा घाइते मान्छेलाई रोग वा चोट लागि उपचार गर्नको लागि अस्पताल सम्म पुर्याउन प्रयोग हुने सवारी साधन हो। <br><br>यो पनि हेर्नुहोस<br><br>सन्दर्भ सामग्रीहरू<br><br>बाह्य कडीहरू<br><br>आकस्मिक स्वास्थ्य सेवा<br>एम्बुलेन्स</code> |
{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
| anchor | positive | |
|---|---|---|
| type | string | string |
| details | <ul><li>min: 3 tokens</li><li>mean: 50.5 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 22 tokens</li><li>mean: 170.43 tokens</li><li>max: 256 tokens</li></ul> |
| anchor | positive |
|---|---|
| <code>जनसाङ्ख्यिकीय लाभांश</code> | <code>जनसाङ्ख्यिकीय लाभांश (Demographic dividend) अर्थ व्यवस्थामा मानव संसाधनका सकारात्मक र सतत विकासलाई दर्शाउँदछ। यो जनसङ्ख्या ढाँचामा बढदो युवा एवं कार्यशील जनसङ्ख्या (१५ वर्षदेखि ६४ वर्ष आयु वर्ग) तथा घट्तो आश्रितता अनुपातका परिणामस्वरूप उत्पादनमा ठूलो मात्राका सृजनलाई प्रदर्शित गर्दछ। यस स्थितिमा जनसङ्ख्या पिरामिड उल्टा बन्नेछ अर्थात यसमा कम जनसङ्ख्या आधार भन्दा माथि ठूलो जनसङ्ख्यातर्फ बढ्दछन्।</code> |
| <code>साडी गाविस</code> | <code>साडी गाविस नेपालको पश्चिमाञ्चल विकास क्षेत्रको लुम्बिनी अञ्चल, रूपन्देही जिल्लामा अवस्थित गाउँ विकास समिति हो । <br><br>रूपन्देही जिल्लाका ठाउँहरू</code> |
| <code>हेप सी र सिरोसिस भएको मेरो साथीले नाकबाट रगत बग्नेलाई गम्भीरतापूर्वक लिनु पर्छ र जेलमा विशेषज्ञलाई भेट्न माग गर्नु पर्छ?</code> | <code>– लिभर सिरोसिसले नाकबाट रगत बगाउन सक्छ<br>– सिरोसिसमा कलेजोले राम्रोसँग काम गर्दैन<br>- यसले कोगुलेसन कारकहरूको उत्पादनलाई असर गर्छ, जुन रगत जम्मा गर्न जिम्मेवार हुन्छ<br>- फलस्वरूप, क्लोटिंग प्रणाली प्रभावित हुन्छ र नाक रगत हुन सक्छ<br>- तपाईंको साथीले उचित मूल्याङ्कन र उपचारको लागि डाक्टरसँग परामर्श गर्नुपर्छ<br>- केहि अवस्थामा, पोर्टल हाइपरटेन्सन व्यवस्थापन गर्न TIPS जस्ता शल्यक्रियाहरू वा बीटा ब्लकरहरू जस्तै औषधिहरू सिफारिस गर्न सकिन्छ।<br>- सिरोसिसको अन्तिम उपचार कलेजो प्रत्यारोपण हो<br>- यदि varices (अन्ननलीमा असामान्य नसहरू) बाट कुनै पनि रक्तस्राव भएमा, ब्यान्डिङ जस्ता प्रक्रियाहरूको लागि तत्काल चिकित्सा ध्यान आवश्यक छ।<br>- यो तपाईंको साथीसँग कुराकानी जारी राख्न र यस प्रक्रिया मार्फत तिनीहरूलाई समर्थन गर्न महत्त्वपूर्ण छ</code> |
{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepsper_device_train_batch_size: 128per_device_eval_batch_size: 128learning_rate: 2e-05num_train_epochs: 1warmup_ratio: 0.1bf16: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 128per_device_eval_batch_size: 128per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseeval_use_gather_object: Falsebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalIf you use this model, please cite it as:
@misc{subedi2026allminilml6v2nepali,
author = {Subedi, Sanjaya},
title = {all-MiniLM-L6-v2-nepali: A Nepali-English Sentence Transformer for Semantic Search and Similarity},
year = {2026},
publisher = {Hugging Face},
journal = {Hugging Face model repository},
howpublished = {\url{https://huggingface.co/jangedoo/all-MiniLM-L6-v2-nepali}},
note = {Fine-tuned Sentence Transformer model for Nepali and English-Nepali semantic similarity, semantic search, paraphrase mining, clustering, and retrieval}
}