CoolFace
Modelpublic

sanganaka/LaBSE-sanskritFT

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes223downloads
Model Card

SentenceTransformer based on sentence-transformers/LaBSE

This is a sentence-transformers model finetuned from sentence-transformers/LaBSE on the mitrasamgraha dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: sentence-transformers/LaBSE <!-- at revision b7f947194ceae0ddf90bafe213722569e274ad28 -->
  • —Maximum Sequence Length: 256 tokens
  • —Output Dimensionality: 768 tokens
  • —Similarity Function: Cosine Similarity
  • —Training Dataset:
  • —mitrasamgraha <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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): Dense({'in_features': 768, 'out_features': 768, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'})
  (3): Normalize()
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("sanganaka/LaBSE-sanskritFT")
# Run inference
sentences = [
    'O Śākyamuni, conquering the powerful host of Māra, You found peace, immortality, and the happiness of that supreme enlightenment',
    'मारस् त्वयास्तु विजितस् सबलो मुनीन्द्रः प्राप्ता शिवा अमृतशान्तवराग्रबोधिः ।',
    'न हि तथता द्वयप्रभाविता नानात्वप्रभाविता ।',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# 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. -->

Evaluation

Metrics

Translation
MetricValue
src2trg_accuracy0.9095
trg2src_accuracy0.9005
mean_accuracy0.905
Translation
MetricValue
src2trg_accuracy0.8901
trg2src_accuracy0.8822
mean_accuracy0.8861

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

mitrasamgraha
  • —Dataset: mitrasamgraha
  • —Size: 477,170 training samples
  • —Columns: <code>english</code> and <code>sanskrit_Deva</code>
  • —Approximate statistics based on the first 1000 samples: | | english | sanskrit_Deva | |:--------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 18 tokens</li><li>mean: 39.31 tokens</li><li>max: 80 tokens</li></ul> | <ul><li>min: 20 tokens</li><li>mean: 38.51 tokens</li><li>max: 94 tokens</li></ul> |
  • —Samples: | english | sanskrit_Deva | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------| | <code>My patience is almost worn out, like that of a creeper under the winter frost. It is decayed, and neither lives nor perishes at once.</code> | <code>जर्जरीकृत्य वस्तूनि त्यजन्ती विभ्रती तथा । मार्गशीर्षान्तवल्लीव धृतिर्विधुरतां गता ॥</code> | | <code>Our minds are partly settled in worldly things, and partly fixed in their giver (the Supreme soul). This divided state of the mind is termed its half waking condition.</code> | <code>अपहस्तितसर्वार्थमनवस्थितिरास्थिता । गृहीत्वोत्सृज्य चात्मानं भवस्थितिरवस्थिता ॥</code> | | <code>My mind is in a state of suspense, being unable to ascertain the real nature of my soul. I am like one in the dark, who is deceived by the stump of a fallen tree at a distance, to think it a human figure.</code> | <code>चलिताचलितेनान्तरवष्टम्भेन मे मतिः । दरिद्रा छिन्नवृक्षस्य मूलेनेव विडम्ब्यते ॥</code> |
  • —Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Evaluation Dataset

mitrasamgraha
  • —Dataset: mitrasamgraha
  • —Size: 5,560 evaluation samples
  • —Columns: <code>english</code> and <code>sanskrit_Deva</code>
  • —Approximate statistics based on the first 1000 samples: | | english | sanskrit_Deva | |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 5 tokens</li><li>mean: 53.41 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 51.2 tokens</li><li>max: 256 tokens</li></ul> |
  • —Samples: | english | sanskrit_Deva | |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Thereupon he takes the winnowing basket and the Agnihotra ladle , with the text : 'For the work (I take) you, for pervasion (or accomplishment) you two! ' For the sacrifice is a work: hence, in saying 'for the work you two, ' he says, 'for the sacrifice. ' And 'for pervasion you two, ' he says, because he, as it were, pervades (goes through, accomplishes) the sacrifice. He then restrains his speech; for (restrained) speech means undisturbed sacrifice; so that (in so doing) he thinks: 'May I accomplish the sacrifice! ' He now heats (the two objects on the Grhapatya), with the formula : 'Scorched is the Rakshas, scorched are the enemies! ' or : 'Burnt out is the Rakshas, burnt out are the enemies! '</code> | <code>अग्ने व्रतपते व्रतं चरिष्यामि तचकेयं तन्मे राध्यतामित्यग्निर्वै देवानां व्रतपतिस्तस्मा एवैतत्प्राह व्रतं चरिष्यामि तच्चकेयं तन्मे राध्यतामिति नात्र तिरोहितमिवास्ति ॥ अथ संस्थिते विसृजते । अग्ने व्रतपते व्रतमचारिषं तादशकम् तन्मे राधीत्यशकद्येतद्यो यज्ञस्य संस्थामगन्नराधि ह्यस्मै यो यज्ञस्य संस्थामगन्नेतेन न्वेव भूयिष्ठा इव व्रतमुपयन्त्यनेन त्वेवोपेयात् ॥ द्वयं वा इदं न तृतीयमस्ति ।</code> | | <code>For the gods, when they were performing the sacrifice, were afraid of a disturbance on the part of the Asuras and Rakshas: hence by this means he expels from here, at the very opening of the sacrifice, the evil spirits, the Rakshas.</code> | <code>एतद्धवै देवा व्रतं चरन्ति यत्सत्यं तस्मात्ते यशो यशो ह भवति य एवं विद्वांत्सत्यंवदति ॥ अथ संस्थिते विसृजते ।</code> | | <code>He now steps forward (to the cart ), with the text : 'I move along the wide arial realm. ' For the Rakshas roams about in the air, rootless and unfettered in both directions (below and above); and in order that this man (the Adhvaryu) may move about the air, rootless and unfettered in both directions, he by this very prayer renders the atmosphere free from danger and evil spirits.</code> | <code>स वा आरण्यमेवाश्नीयात् । या वारण्या ओषधयो यद्वा वृक्ष्यं तदु ह स्माहापि बर्कुर्वार्ष्णो मासान्मे पचत न वा एतेसां हविर्गृह्णन्तीति तदु तथा न कुर्याद्व्रीहियवयोर्वा एतदुपजं यचमीधान्यं तद्व्रीहियवावेवैतेन भूयांसौ करोति तस्मादारण्यमेवाश्नीयात् ॥</code> |
  • —Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: epoch
  • —per_device_train_batch_size: 32
  • —per_device_eval_batch_size: 128
  • —learning_rate: 2e-05
  • —num_train_epochs: 5
  • —warmup_ratio: 0.1
  • —bf16: True
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: epoch
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 32
  • —per_device_eval_batch_size: 128
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —learning_rate: 2e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 5
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.1
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: True
  • —fp16: False
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: False
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —dispatch_batches: None
  • —split_batches: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

<details><summary>Click to expand</summary>

EpochStepTraining LossValidation Losstranslate-val_mean_accuracytranslate-test_mean_accuracy
00--0.1176-
0.03355002.1597---
0.067110001.2431---
0.100615000.5749---
0.134120000.3824---
0.167725000.2748---
0.201230000.4789---
0.234735000.69---
0.268240000.5577---
0.301845000.7105---
0.335350000.8834---
0.368855000.5629---
0.402460000.4356---
0.435965000.379---
0.469470000.4488---
0.503075000.3444---
0.536580000.277---
0.570085000.2805---
0.603590000.4728---
0.637195000.4786---
0.6706100000.6838---
0.7041105000.1776---
0.7377110000.3796---
0.7712115000.2974---
0.8047120000.5517---
0.8383125000.6688---
0.8718130000.1289---
0.9053135000.097---
0.9388140000.2965---
0.9724145000.4222---
1.014912-0.45750.8076-
1.0059150000.3351---
1.0394155000.7294---
1.0730160000.3553---
1.1065165000.1192---
1.1400170000.1004---
1.1736175000.0474---
1.2071180000.2542---
1.2406185000.3749---
1.2741190000.2676---
1.3077195000.5731---
1.3412200000.6647---
1.3747205000.1805---
1.4083210000.2676---
1.4418215000.1849---
1.4753220000.2452---
1.5089225000.163---
1.5424230000.1426---
1.5759235000.178---
1.6094240000.2998---
1.6430245000.3723---
1.6765250000.4025---
1.7100255000.0436---
1.7436260000.2142---
1.7771265000.1912---
1.8106270000.5035---
1.8442275000.369---
1.8777280000.0524---
1.9112285000.0459---
1.9447290000.2484---
1.9783295000.2117---
2.029824-0.31250.8622-
2.0118300000.2879---
2.0453305000.4875---
2.0789310000.1512---
2.1124315000.066---
2.1459320000.0367---
2.1795325000.0218---
2.2130330000.1896---
2.2465335000.2711---
2.2800340000.1561---
2.3136345000.5086---
2.3471350000.4496---
2.3806355000.0925---
2.4142360000.1692---
2.4477365000.1324---
2.4812370000.1545---
2.5148375000.1051---
2.5483380000.0887---
2.5818385000.1367---
2.6153390000.2141---
2.6489395000.3103---
2.6824400000.2494---
2.7159405000.06---
2.7495410000.1096---
2.7830415000.1414---
2.8165420000.5108---
2.8501425000.1763---
2.8836430000.0303---
2.9171435000.024---
2.9506440000.2311---
2.9842445000.1018---
3.044736-0.25460.8862-
3.0177450000.2786---
3.0512455000.3404---
3.0848460000.0584---
3.1183465000.0383---
3.1518470000.0207---
3.1854475000.0144---
3.2189480000.1432---
3.2524485000.2068---
3.2859490000.1111---
3.3195495000.4326---
3.3530500000.3313---
3.3865505000.0622---
3.4201510000.1225---
3.4536515000.1156---
3.4871520000.0909---
3.5207525000.0693---
3.5542530000.0619---
3.5877535000.1109---
3.6212540000.1956---
3.6548545000.2483---
3.6883550000.1522---
3.7218555000.067---
3.7554560000.062---
3.7889565000.1123---
3.8224570000.4497---
3.8560575000.1193---
3.8895580000.018---
3.9230585000.0436---
3.9565590000.1814---
3.9901595000.0472---
4.059648-0.23050.8944-
4.0236600000.2647---
4.0571605000.2341---
4.0907610000.0323---
4.1242615000.0253---
4.1577620000.0129---
4.1913625000.0362---
4.2248630000.1049---
4.2583635000.1626---
4.2918640000.1179---
4.3254645000.3493---
4.3589650000.2709---
4.3924655000.0653---
4.4260660000.0962---
4.4595665000.0921---
4.4930670000.06---
4.5266675000.0571---
4.5601680000.0448---
4.5936685000.0969---
4.6271690000.1652---
4.6607695000.2514---
4.6942700000.0886---
4.7277705000.0673---
4.7613710000.0681---
4.7948715000.098---
4.8283720000.4446---
4.8619725000.0748---
4.8954730000.016---
4.9289735000.0631---
4.9624740000.1845---
4.9960745000.0453---
5.074560-0.21810.90500.8861

</details>

Framework Versions

  • —Python: 3.12.4
  • —Sentence Transformers: 3.2.1
  • —Transformers: 4.42.4
  • —PyTorch: 2.3.1
  • —Accelerate: 0.31.0
  • —Datasets: 2.20.0
  • —Tokenizers: 0.19.1

Citation

BibTeX

Sentence Transformers
bibtex
@inproceedings{reimers-2019-sentence-bert,
    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2019",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/1908.10084",
}
MultipleNegativesRankingLoss
bibtex
@misc{henderson2017efficient,
    title={Efficient Natural Language Response Suggestion for Smart Reply},
    author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
    year={2017},
    eprint={1705.00652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->