Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, '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
6sentences = [
7 'یک دختر جوان بلوند با پیراهن صورتی به آخوندکی بزرگ در حال نماز روی بازوی خود نگاه می کند.',
8 'دختر جوانی یک آخوندک نمازگزار روی بازوی خود دارد.',
9 'کاخ هنرهای زیبا آثار سوررئالیستی زیادی دارد.',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]premise, hypothesis, and score| premise | hypothesis | score | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| premise | hypothesis | score |
|---|---|---|
موارد پیکربندی پس از استقرار رسمی | آیتم ها پس از ایجاد رسمی پیکربندی می شوند. | 1.0 |
به همان خوبی که در دنیای من انجام شده است. سر پرث، موقتاً از خودش راضی بود، رفت و هانسون ایستاد و به مدل خیره شد. | هانسون از خیره شدن به مدل دست کشید و سر پرث را دنبال کرد. | 0.0 |
به نظر می رسد شما قبلاً رفته اید. | انگار رفتی | 1.0 |
CoSENTLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "pairwise_cos_sim"
4}premise, hypothesis, and score| premise | hypothesis | score | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| premise | hypothesis | score |
|---|---|---|
آنها سوار بر همدیگر شده بودند و کتک خورده بودند تا اینکه اهمیتی ندادند. | مردم مجروح شده بودند. | 1.0 |
در منطقه چمن نگه داشتن چمن در مناطق خاص به نوعی سخت است و من واقعاً هرگز به آن فکر نکرده بودم، اما ما تقریباً در بالای این تپه کوچک هستیم و تمام رواناب های حاصل از بتن، اوه خرید مرکز نزدیک ما و کوچه همه چیزهایی که به سمت همسایههای ما میرود، بنابراین این یک چیز کوچکی بود که من واقعاً هرگز به آن فکر نمیکردم و خوشبختانه به این ترتیب انجام شد. | ما روی تپه ای هستیم و آب در نزدیکی همسایه هایمان جمع می شود. | 1.0 |
زنی با چتر در ایستگاهی نشسته و آگهی تبلیغاتی Aquos روی دیوار دارد. | زنی روی مبل اتاق نشیمنش نشسته است. | 0.0 |
CoSENTLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "pairwise_cos_sim"
4}eval_strategy: stepsper_device_train_batch_size: 48per_device_eval_batch_size: 32learning_rate: 2e-05num_train_epochs: 1warmup_ratio: 0.1fp16: Truepush_to_hub: Truehub_private_repo: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 48per_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: 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: 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}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: Trueresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Truehub_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: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | loss |
|---|---|---|---|
| 0.0271 | 500 | 7.0257 | - |
| 0.0542 | 1000 | 6.3955 | - |
| 0.0813 | 1500 | 6.3502 | - |
| 0.1084 | 2000 | 6.3209 | - |
| 0.1355 | 2500 | 6.292 | - |
| 0.1626 | 3000 | 6.2518 | 5.3943 |
| 0.1897 | 3500 | 6.2469 | - |
| 0.2168 | 4000 | 6.2352 | - |
| 0.2439 | 4500 | 6.2095 | - |
| 0.2710 | 5000 | 6.2006 | - |
| 0.2982 | 5500 | 6.1951 | - |
| 0.3253 | 6000 | 6.1945 | 5.2832 |
| 0.3524 | 6500 | 6.1681 | - |
| 0.3795 | 7000 | 6.167 | - |
| 0.4066 | 7500 | 6.1474 | - |
| 0.4337 | 8000 | 6.1506 | - |
| 0.4608 | 8500 | 6.1506 | - |
| 0.4879 | 9000 | 6.15 | 5.2294 |
| 0.5150 | 9500 | 6.1512 | - |
| 0.5421 | 10000 | 6.149 | - |
| 0.5692 | 10500 | 6.1218 | - |
| 0.5963 | 11000 | 6.1312 | - |
| 0.6234 | 11500 | 6.1233 | - |
| 0.6505 | 12000 | 6.1053 | 5.1807 |
| 0.6776 | 12500 | 6.1209 | - |
| 0.7047 | 13000 | 6.1088 | - |
| 0.7318 | 13500 | 6.0944 | - |
| 0.7589 | 14000 | 6.1089 | - |
| 0.7860 | 14500 | 6.1062 | - |
| 0.8131 | 15000 | 6.0975 | 5.1374 |
| 0.8402 | 15500 | 6.1009 | - |
| 0.8673 | 16000 | 6.086 | - |
| 0.8945 | 16500 | 6.0687 | - |
| 0.9216 | 17000 | 6.0804 | - |
| 0.9487 | 17500 | 6.0981 | - |
| 0.9758 | 18000 | 6.0895 | 5.1153 |
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@online{kexuefm-8847,
2 title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
3 author={Su Jianlin},
4 year={2022},
5 month={Jan},
6 url={https://kexue.fm/archives/8847},
7}