SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'XLMRobertaModel'})
(1): Pooling({'word_embedding_dimension': 1024, '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})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6queries = [
7 "\u0935\u093e\u0924\u093e\u0924\u092a\u093e\u0927\u094d\u0935-\u092f\u093e\u0928\u093e\u0926\u093f-\u092a\u0930\u093f\u0939\u093e\u0930\u094d\u092f\u0947\u0937\u094d\u0935\u094d \u0905-\u092f\u0928\u094d\u0924\u094d\u0930\u0923\u092e\u094d \u0964 \u092a\u094d\u0930\u092f\u094b\u091c\u094d\u092f\u0902 \u0938\u0941-\u0915\u0941\u092e\u093e\u0930\u093e\u0923\u093e\u092e\u094d \u0908\u0936\u094d\u0935\u0930\u093e\u0923\u093e\u092e\u094d \u0938\u0941\u0916\u093e\u0924\u094d\u092e\u0928\u093e\u092e\u094d \u0965 \u096a\u096b \u0965",
8]
9documents = [
10 '**Ashtanga Hridayam, Chikitsa Sthana, chapter 13, sutra 45**\n\n**Sutra**:\nवातातपाध्व-यानादि-परिहार्येष्व् अ-यन्त्रणम् । प्रयोज्यं सु-कुमाराणाम् ईश्वराणाम् सुखात्मनाम् ॥ ४५ ॥\n\n**English Transliteration**:\nvātātapādhva-yānādi-parihāryeṣv a-yantraṇam | prayojyaṃ su-kumārāṇām īśvarāṇām sukhātmanām || 45 ||\n\n**English Translation**:\nWithout restrictions regarding avoidance of wind, sun, travel, etc., it can be used by delicate, wealthy, and happy individuals.',
11 '**Ashtanga Hridayam, Sutra Sthana, chapter 22, sutra 34**\n\n**Sutra**:\nकच-सदन-सित-त्व-पिञ्जर-त्वं परिफुटनं शिरसः समीर-रोगान् । जयति जनयतीन्द्रिय-प्रसादं स्वर-हनु-मूर्द्ध-बलं च मूर्द्ध-तैलम् ॥ ३४ ॥\n\n**English Transliteration**:\nkaca-sadana-sita-tva-piñjara-tvaṃ parisphuṭanaṃ śirasaḥ samīra-rogān । jayati janayatīndriya-prasādaṃ svara-hanu-mūrddha-balaṃ ca mūrddha-tailam ॥ 34 ॥\n\n**English Translation**:\nHair-falling-white-ness-yellowish-ness splitting of head wind-diseases overcomes generates sense-organ-pleasure voice-jaw-head-strength and head-oil.',
12 '**Ashtanga Hridayam, Sutra Sthana, Sutra Sthana, chapter 6, sutra 129**\n\n**Sutra**:\nगुर्व् आम्रं वात-जित् पक्वं स्वाद्व् अम्लं कफ-शुक्र-कृत् । वृक्षाम्लं ग्राहि रूक्षोष्णं वात-श्लेष्म-हरं लघु ॥ १२९ ॥\n\n**English Transliteration**:\ngurv āmraṃ vāta-jit pakvaṃ svādv amlaṃ kapha-śukra-kṛt । vṛkṣāmlaṃ grāhi rūkṣoṣṇaṃ vāta-śleṣma-haraṃ laghu ॥ 129 ॥\n\n**English Translation**:\nHeavy mango vata-conquering ripe sweet-sour kapha-semen-doing. Garcinia astringent dry-hot vata-phlegm-removing light.',
13]
14query_embeddings = model.encode_query(queries)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# [1, 1024] [3, 1024]
18
19# Get the similarity scores for the embeddings
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[ 0.7478, -0.0367, 0.0590]])Embedding_Dataset_DevTripletEvaluator| Metric | Value |
|---|---|
| cosine_accuracy | 0.9996 |
query, positive_pair, and negative_pair| query | positive_pair | negative_pair | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| query | positive_pair | negative_pair |
|---|---|---|
[object Object] नैते सृती पार्थ जानन्योगी मुह्यति कश्चन। तस्मात्सर्वेषु कालेषु योगयुक्तो भवार्जुन।।8.27।। | [object Object][object Object] नैते सृती पार्थ जानन्योगी मुह्यति कश्चन। तस्मात्सर्वेषु कालेषु योगयुक्तो भवार्जुन।।8.27।।[object Object][object Object][object Object][object Object] naite sṛtī pārtha jānanyogī muhyati kaścana| tasmātsarveṣu kāleṣu yogayukto bhavārjuna||8.27||[object Object][object Object][object Object][object Object]O Arjuna! The saint knowing these paths is not confused. Therefore meditate perpetually.[object Object][object Object][object Object][object Object]O son of Prtha, na kascana yogi, no yogi whosoever; janan, has known; ete srti, these two courses as described-that one leads to worldly life, and the other to Liberation; muhyati, becomes deluded. Tasmat, therefore; O Arjuna, bhava, be you; yoga-yuktah, steadfast in Yoga; sarvesu kalesu, at all times. Here about the greatness of that yoga: | [object Object][object Object] यज्ञार्थात्कर्मणोऽन्यत्र लोकोऽयं कर्मबन्धनः। तदर्थं कर्म कौन्तेय मुक्तसंगः समाचर।।3.9।।[object Object][object Object][object Object][object Object] yajñārthātkarmaṇo'nyatra loko'yaṃ karmabandhanaḥ| tadarthaṃ karma kaunteya muktasaṃgaḥ samācara||3.9||[object Object][object Object][object Object][object Object]In this world people are fettered by action, unless it is performed as a sacrifice. Therefore, O Arjuna, let thy acts be done without attachment, as sacrifice only.[object Object][object Object][object Object][object Object]Ayam, this; lokah, man, the one who is eligible for action; karma-bandhanah, becomes bound by actions- the person who has karma as his bondage (bandhana) is karma-bandhanah-; anyatra, other than; that karmanah, action; yajnarthat, meant for Got not by that meant for God. According to the Vedic text, 'Sacrifice is verily Visnu' (Tai. Sam. 1.7.4), yajnah means God; whatever is done for Him is yajnartham. Therefore, mukta-sangah, without being attached, being free fr... |
Specifically, in the [object Object] type, the physician should create wounds within the tracts. After these have healed, the remaining tracts should be treated. | [object Object][object Object][object Object][object Object]:[object Object]विशेषतस्तु- नाड्यन्तरे व्रणान् कुर्याद्भिषक् तु शतपोनके | ततस्तेषूपरूढेषु शेषा नाडीरुपाचरेत् ||५||[object Object][object Object][object Object]:[object Object]viśeṣatastu- nāḍyantare vraṇān kuryādbhīṣak tu śataponake | tatasteṣūparūḍheṣu śeṣā nāḍīrupācaret ||5||[object Object][object Object][object Object]:[object Object]Specifically, in the [object Object] type, the physician should create wounds within the tracts. After these have healed, the remaining tracts should be treated. | [object Object][object Object][object Object][object Object]:[object Object]चूर्णितैस्त्रिफलाश्यामात्रिवृत्पिप्पलिसंयुतैः | सक्षौद्रः शर्करायुक्तो विरेकस्तु प्रशस्यते ||३०६||[object Object][object Object][object Object]:[object Object]cūrṇitaistriphalāśyāmātrivṛtpippalisaṃyutaiḥ | sakṣaudraḥ śarkarāyukto virekastu praśasyate ||306||[object Object][object Object][object Object]:[object Object]A purgative (vireka) is recommended when prepared with powdered Triphala, Shyama, Trivrit, and Pippali, mixed with honey and sugar. |
अथ पुण्ये ऽह्नि संपूज्य पूज्यांस् तां प्रविशेच् छुचिः । तत्र संशोधनैः शुद्धः सुखी जात-बलः पुनः ॥ ८ ॥ | [object Object][object Object][object Object][object Object]:[object Object]अथ पुण्ये ऽह्नि संपूज्य पूज्यांस् तां प्रविशेच् छुचिः । तत्र संशोधनैः शुद्धः सुखी जात-बलः पुनः ॥ ८ ॥[object Object][object Object][object Object]:[object Object]atha puṇye 'hni saṃpūjya pūjyāṃs tāṃ praviśec chuchiḥ | tatra saṃśodhanaiḥ śuddhaḥ sukhī jāta-balaḥ punaḥ || 8 ||[object Object][object Object][object Object]:[object Object]Then, on an auspicious day, having worshipped the worshipful, the pure one should enter it; there, purified by cleansing therapies, he becomes happy and regains strength. | [object Object][object Object][object Object][object Object]:[object Object]दीर्घ-जीवितम् आरोग्यं धर्मम् अर्थं सुखं यशः । पाठावबोधानुष्ठानैर् अधिगच्छत्य् अतो ध्रुवम् ॥ ८२ ॥[object Object][object Object][object Object]:[object Object]dīrgha-jīvitam ārogyaṁ dharmam arthaṁ sukhaṁ yaśaḥ | pāṭhāvabodhānuṣṭhānair adhigacchaty ato dhruvam || 82 ||[object Object][object Object][object Object]:[object Object]Long life, health, righteousness, wealth, happiness, and fame, one attains surely through reading, understanding, and practicing this. |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "cos_sim",
4 "gather_across_devices": false
5}query, positive_pair, and negative_pair| query | positive_pair | negative_pair | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| query | positive_pair | negative_pair |
|---|---|---|
Marma-destroyed separately not-said their flesh-etc.-depending-on. Generally with-foreign-body but agitating by action with-pain. | [object Object][object Object][object Object][object Object]:[object Object]मर्म-नष्टं पृथङ् नोक्तं तेषां मांसादि-संश्रयात् । सामान्येन स-शल्यं तु क्षोभिण्या क्रियया स-रुक् ॥ १७ ॥[object Object][object Object][object Object]:[object Object]marma-naṣṭaṃ pṛthaṅ noktaṃ teṣāṃ māṃsādi-saṃśrayāt । sāmānyena sa-śalyaṃ tu kṣobhiṇyā kriyayā sa-ruk ॥ 17 ॥[object Object][object Object][object Object]:[object Object]Marma-destroyed separately not-said their flesh-etc.-depending-on. Generally with-foreign-body but agitating by action with-pain. | [object Object][object Object][object Object][object Object]:[object Object]पञ्च-कोल-शठी-पथ्या-गुड-बीजाह्व-पौष्करम् । वारुणी-कल्कितं भृष्टं यमके लवणान्वितम् ॥ ३४ ॥[object Object][object Object][object Object]:[object Object]pañca-kola-śaṭhī-pathyā-guḍa-bījāhva-pauṣkaram । vāruṇī-kalkitaṃ bhṛṣṭaṃ yamake lavaṇānvitam ॥ 34 ॥[object Object][object Object][object Object]:[object Object]Five-kolas, shathi, pathya, jaggery, bija, and pushkara, ground with varuni, fried in clarified butter, and mixed with salt. |
प्राचीनामलकं चैव दोषघ्नं गरहारि च| ऐङ्गुदं तिक्तमधुरं स्निग्धोष्णं कफवातजित्||१४६|| | [object Object][object Object][object Object][object Object]:[object Object]प्राचीनामलकं चैव दोषघ्नं गरहारि च| ऐङ्गुदं तिक्तमधुरं स्निग्धोष्णं कफवातजित्||१४६||[object Object][object Object][object Object]:[object Object]prācīnāmalakaṃ caiva doṣaghnaṃ garahāri ca| aiṅgudaṃ tiktamadhuraṃ snigdhoṣṇaṃ kaphavātajit||146||[object Object][object Object][object Object]:[object Object]Pracinamalaka eliminates the doshas and counteracts poison. Inguda is bitter and sweet, unctuous and hot, and conquers Kapha and Vata. | [object Object][object Object][object Object][object Object]:[object Object]कट्वजीर्णविदाह्यम्लक्षाराद्यैः पित्तमुल्बणम्| अग्निमाप्लावयद्धन्ति जलं तप्तमिवानलम्||६५||[object Object][object Object][object Object]:[object Object]kaṭvajīrṇavidāhyamlākṣārādyaiḥ pittamulbaṇam| agnimāplāvayaddhanti jalaṃ taptamivānalam||65||[object Object][object Object][object Object]:[object Object][object Object] (bile) aggravated by pungent, indigestible, burning, sour, alkaline, and other substances, overwhelms the [object Object] (digestive fire) and destroys it, just as hot water extinguishes a fire. |
[object Object] becomes aggravated by excessive consumption of dry food, overeating, exposure to easterly winds, dew, sexual intercourse, suppression of natural urges, exertion, and exercise. | [object Object][object Object][object Object][object Object]:[object Object]रूक्षात्यध्यशनात् पूर्ववातावश्यायमैथुनैः| वेगसन्धारणायासव्यायामैः कुपितोऽनिलः||७४||[object Object][object Object][object Object]:[object Object]rūkṣātyadhyaśanāt pūrvavātāvaśyāyamaithunaiḥ| vegasaṃdhāraṇāyāsavyāyāmaiḥ kupito'nilaḥ||74||[object Object][object Object][object Object]:[object Object][object Object] becomes aggravated by excessive consumption of dry food, overeating, exposure to easterly winds, dew, sexual intercourse, suppression of natural urges, exertion, and exercise. | [object Object][object Object][object Object][object Object]:[object Object]मातृतः पितृत आत्मतः सात्म्यतो रसतः सत्त्वत इत्येतेभ्यो भावेभ्यः समुदितेभ्यो गर्भः सम्भवति| तस्य ये येऽवयवा यतो यतः सम्भवतः सम्भवन्ति तान् विभज्य मातृजादीनवयवान् पृथक् पृथगुक्तमग्रे||४||[object Object][object Object][object Object]:[object Object]mātṛtaḥ pitṛta ātmatas sāmyato rasataḥ sattvata ityetebhyo bhāvebhyaḥ samuditebhyo garbhaḥ sambhavati| tasya ye ye'vayavā yato yataḥ sambhavataḥ sambhavanti tān vibhajya mātṛjādīnavayavān pṛthak pṛthaguktamagre||4||[object Object][object Object][object Object]:[object Object]The embryo originates from the combined factors of the mother, the father, the self, suitability, nutrition, and the mind. The specific components of it that originate from each of these sources will be described separately in the following sections, distinguishing the maternal and other components. |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "cos_sim",
4 "gather_across_devices": false
5}eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32num_train_epochs: 4warmup_ratio: 0.1fp16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 4max_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: Falsebf16: Falsefp16: Truefp16_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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_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: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_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: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | Embedding_Dataset_Dev_cosine_accuracy |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.9907 |
| 1.2678 | 1600 | 0.0032 | 0.0054 | 0.9998 |
| 1.3471 | 1700 | 0.0017 | 0.0060 | 0.9994 |
| 1.4263 | 1800 | 0.0032 | 0.0059 | 0.9994 |
| 1.5055 | 1900 | 0.0072 | 0.0061 | 0.9996 |
| 1.5848 | 2000 | 0.0077 | 0.0074 | 0.9994 |
| 1.6640 | 2100 | 0.0068 | 0.0879 | 0.9952 |
| 1.7433 | 2200 | 0.0056 | 0.0061 | 0.9996 |
| 1.8225 | 2300 | 0.0087 | 0.0052 | 1.0 |
| 1.9017 | 2400 | 0.0112 | 0.0050 | 0.9998 |
| 1.9810 | 2500 | 0.0036 | 0.0039 | 0.9994 |
| 2.0602 | 2600 | 0.0047 | 0.0047 | 0.9994 |
| 2.1395 | 2700 | 0.0054 | 0.0072 | 0.9998 |
| 2.2187 | 2800 | 0.0052 | 0.0047 | 0.9998 |
| 2.2979 | 2900 | 0.0044 | 0.0059 | 0.9996 |
| 2.3772 | 3000 | 0.0051 | 0.0046 | 0.9996 |
| 2.4564 | 3100 | 0.0068 | 0.0082 | 0.9996 |
| 2.5357 | 3200 | 0.0051 | 0.0046 | 0.9996 |
| 2.6149 | 3300 | 0.0025 | 0.0050 | 0.9998 |
| 2.6941 | 3400 | 0.004 | 0.0052 | 0.9992 |
| 2.7734 | 3500 | 0.0019 | 0.0048 | 0.9996 |
| 2.8526 | 3600 | 0.0039 | 0.0042 | 1.0 |
| 2.9319 | 3700 | 0.0045 | 0.0049 | 0.9998 |
| 3.0111 | 3800 | 0.002 | 0.0046 | 0.9996 |
| 3.0903 | 3900 | 0.0028 | 0.0050 | 0.9996 |
| 3.1696 | 4000 | 0.0033 | 0.0049 | 0.9992 |
| 3.2488 | 4100 | 0.0052 | 0.0048 | 0.9996 |
| 3.3281 | 4200 | 0.0026 | 0.0049 | 0.9994 |
| 3.4073 | 4300 | 0.0043 | 0.0044 | 1.0 |
| 3.4865 | 4400 | 0.0038 | 0.0041 | 0.9998 |
| 3.5658 | 4500 | 0.003 | 0.0043 | 1.0 |
| 3.6450 | 4600 | 0.003 | 0.0045 | 1.0 |
| 3.7242 | 4700 | 0.003 | 0.0045 | 0.9998 |
| 3.8035 | 4800 | 0.0009 | 0.0041 | 0.9998 |
| 3.8827 | 4900 | 0.0048 | 0.0042 | 0.9998 |
| 3.9620 | 5000 | 0.0035 | 0.0042 | 0.9996 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 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},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}