Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 13
How to use Gurveer05/paraphrase-mpnet-eedi-2024 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Gurveer05/paraphrase-mpnet-eedi-2024")
sentences = [
"Question:\nAssign probabilities to single events using fractions. There are 4 red balls and 3 yellow balls in a ∪. The image shows the ∪ with the 4 red balls and 3 yellow balls. What is the probability of picking a red ball?.\nAnswer: (4 / 3)",
"Does not recognise difference of two squares",
"Gives the probability out of the number of non-successes rather than the total",
"Shares equally instead of in given ratio"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from sentence-transformers/paraphrase-mpnet-base-v2 on the csv 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.
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: MPNetModel
(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})
)
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("Gurveer05/paraphrase-mpnet-eedi-2024")
# Run inference
sentences = [
'Question:\nUnderstand key loci terms like equidistant and perpendicular. A set of axes: x-axis from -4 to 4, y-axis from -4 to 4. A red line is drawn from (-2,2) to (2,2). The red line is _________ to the y axis..\nAnswer: Equidistant',
'Does not know the meaning of perpendicular',
'Believes squaring a negative number just changes the sign',
]
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]
sentence1 and sentence2| sentence1 | sentence2 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence1 | sentence2 |
|---|---|
Question: |
Does not know that angles in a triangle sum to 180 degrees |
Question: |
Believes the inverse of square rooting is halving |
Question: |
Does not know that angles around a point sum to 360 |
MultipleNegativesSymmetricRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32num_train_epochs: 20fp16: Trueload_best_model_at_end: 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: 20max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_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: Trueignore_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: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss |
|---|---|---|
| 0.25 | 23 | 1.4213 |
| 0.5 | 46 | 1.0924 |
| 0.75 | 69 | 0.9586 |
| 1.0 | 92 | 0.8914 |
| 1.25 | 115 | 0.579 |
| 1.5 | 138 | 0.5327 |
| 1.75 | 161 | 0.4746 |
| 2.0 | 184 | 0.4323 |
| 2.25 | 207 | 0.3155 |
| 2.5 | 230 | 0.2763 |
| 2.75 | 253 | 0.2408 |
| 3.0 | 276 | 0.2677 |
| 3.25 | 299 | 0.1763 |
| 3.5 | 322 | 0.1815 |
| 3.75 | 345 | 0.1536 |
| 4.0 | 368 | 0.1789 |
| 4.25 | 391 | 0.1331 |
| 4.5 | 414 | 0.119 |
| 4.75 | 437 | 0.1183 |
| 5.0 | 460 | 0.1423 |
| 5.25 | 483 | 0.0979 |
| 5.5 | 506 | 0.0894 |
| 5.75 | 529 | 0.0816 |
| 6.0 | 552 | 0.0853 |
| 6.25 | 575 | 0.0779 |
| 6.5 | 598 | 0.0632 |
| 6.75 | 621 | 0.0618 |
| 7.0 | 644 | 0.0798 |
| 7.25 | 667 | 0.0536 |
| 7.5 | 690 | 0.0615 |
| 7.75 | 713 | 0.0473 |
| 8.0 | 736 | 0.0536 |
| 8.25 | 759 | 0.0392 |
| 8.5 | 782 | 0.0551 |
| 8.75 | 805 | 0.0405 |
| 9.0 | 828 | 0.0519 |
| 9.25 | 851 | 0.0299 |
| 9.5 | 874 | 0.0355 |
| 9.75 | 897 | 0.0337 |
| 10.0 | 920 | 0.0324 |
| 10.25 | 943 | 0.0283 |
| 10.5 | 966 | 0.0293 |
| 10.75 | 989 | 0.0248 |
| 11.0 | 1012 | 0.0281 |
| 11.25 | 1035 | 0.0142 |
| 11.5 | 1058 | 0.022 |
| 11.75 | 1081 | 0.0159 |
| 12.0 | 1104 | 0.0188 |
| 12.25 | 1127 | 0.0078 |
| 12.5 | 1150 | 0.0142 |
| 12.75 | 1173 | 0.0148 |
| 13.0 | 1196 | 0.0126 |
| 13.25 | 1219 | 0.0077 |
| 13.5 | 1242 | 0.0115 |
| 13.75 | 1265 | 0.0119 |
| 14.0 | 1288 | 0.0086 |
@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",
}