Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 17
How to use Trelis/multi-qa-MiniLM-L6-dot-v1-ft-pairs-4-cst-epoch-s1 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Trelis/multi-qa-MiniLM-L6-dot-v1-ft-pairs-4-cst-epoch-s1")
sentences = [
"What is the penalty awarded to the non-offending team if a player in possession holds or impedes a defending player?",
"15. 5 after effecting the touch, the defending player must retire the required seven ( 7 ) metres or to the defending try line as indicated by the referee without interfering with the attacking team. ruling = a penalty to the attacking team ten ( 10 ) metres forward of the infringement or if on the defensive try line, on the seven ( 7 ) metre line. fit playing rules - 5th edition copyright © touch football australia 2020 13 16 obstruction 16. 1 a player in possession must not run or otherwise move behind other attacking players or the referee in an attempt to avoid an imminent touch. ruling = a penalty to the non - offending team at the point of the infringement. 16. 2 the player in possession is not to hold or otherwise impede a defending player in any way. ruling = a penalty to the non - offending team at the point of the infringement.",
"these rules in no way restrict any nta or their authorised competition providers from having different match conditions to these rules. any adaptation of or alterations to the rules for local competitions should be clearly articulated in relevant competition guidelines and be readily available for players, coaches and referees alike preamble copyright © touch football australia 2020 all rights reserved. these touch football rules are protected by copyright laws. except as permitted under the copyright act, these rules must not be reproduced by any process, electronic or otherwise, without the written permission of touch football australia. fit playing rules - 5th edition copyright © touch football australia 2020 appendix 1 – field of play contents 01 i the field of play 5 02 i player registration 5 03 i the ball 6 04 i playing uniform 6 05 i team composition 6 06 i team coach and team officials 7 07 i commencement and recommencement of play 7 08 i match duration 8 09 i possession 8 10 i the touch 9 11 i passing 10 12 i ball touched in flight 10 13 i the rollball 11 14 i scoring 13 15 i offside 13 16 i obstruction 14 17 i interchange 14 18 i penalty 15 19 i advantage 16 20 i misconduct 16 21 i forced interchange 16 22 i sin bin 16 23 i dismissal 17 24 i drop - off 17 25 i match officials 18 fit playing rules - 5th edition copyright © touch football australia 2020 fit playing rules - 5th edition copyright © touch football australia 2020 definitions and terminology unless the contrary intention appears, the following definitions and terminology apply to the game of touch : term / phrase definition / description advantage the period of time after an infringement in which the non - offending side has the opportunity to gain advantage either territorial, tactical or in the form of a try.",
"fit playing rules - 5th edition copyright © touch football australia 2020 3 sin bin area the area between the dead ball line and the perimeter where players are sent for either a sin bin period or exclusion for repeated seven metre zone infringements. there are four ( 4 ) sin bin areas. see appendix 1. spirit of the game the act of good sportsmanship and fair play. substitute player the player who replaces another player during interchange. there is a maximum of eight ( 8 ) substitute players in any team and except when interchanging, in the sin bin, dismissed or on the field of play, they must remain in the substitution box. tap and tap penalty the method of commencing the match, recommencing the match after half time and after a try has been scored. the tap is also the method of recommencing play when a penalty is awarded. the tap is taken by placing the ball on the ground at or behind the mark, releasing both hands from the ball, tapping the ball gently with either foot or touching the foot on the ball. the ball must not roll or move more than one ( 1 ) metre in any direction and must be retrieved cleanly, without touching the ground again."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from sentence-transformers/multi-qa-MiniLM-L6-dot-v1. 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.
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, '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})
)
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("Trelis/multi-qa-MiniLM-L6-dot-v1-ft-pairs-4-cst-epoch-s1")
# Run inference
sentences = [
'What is the consequence if a defending team is penalized three times in their seven-meter zone during a single possession?',
'18. 5 the mark must be indicated by the referee before a penalty tap is taken. 18. 6 the penalty tap must be performed without delay after the referee indicates the mark. ruling = a penalty to the non - offending team at the point of infringement. 18. 7 a player may perform a rollball instead of a penalty tap and the player who receives the ball does not become the half. 18. 8 if the defending team is penalised three ( 3 ) times upon entering their seven metre zone during a single possession, the last offending player will be given an exclusion until the end of that possession. 18. 9 a penalty try is awarded if any action by a player, team official or spectator, deemed by the referee to be contrary to the rules or spirit of the game clearly prevents the attacking team from scoring a try. fit playing rules - 5th edition copyright © touch football australia 2020 15 19 advantage 19. 1 where a defending team player is offside at a tap or rollball and attempts to interfere with play, the referee will allow advantage or award a penalty, whichever is of greater advantage to the attacking team.',
'5th edition rules touch football tion rules touch football touch football australia ( tfa ) undertook an extensive internal review of their domestic playing rules throughout 2018 and 2019. the review was led by an vastly experienced group of current and past players, coaches, referees and administrators of the sport from community competitions to the elite international game. this group consulted broadly within the australian community to develop a set of playing rules that could be applied across all levels of the sport. the result was the tfa 8th edition playing rules. at the federation of international touch paris convention held in october 2019 touch football australia presented the tfa 8th edition playing rules and subsequently offered fit and all national touch associations ( ntas ) royalty free rights to use the newly developed rules. consequently, the fit board resolved to adopt the tfa 8th edition playing rules as the 5th edition fit playing rules to be used across all levels of the game internationally. fit and its members acknowledge and thank touch football australia for the rights to use these rules. whilst consistency in the application of the rules of the game is important, fit encourages its members to offer features in local competition rules to ensure that all participants enjoy a high quality experience.',
]
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]
eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32learning_rate: 2e-05num_train_epochs: 4lr_scheduler_type: constantwarmup_ratio: 0.3overwrite_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: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 4max_steps: -1lr_scheduler_type: constantlr_scheduler_kwargs: {}warmup_ratio: 0.3warmup_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: 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: Falsebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | loss |
|---|---|---|---|
| 0.3333 | 2 | 1.7279 | - |
| 0.5 | 3 | - | 1.3621 |
| 0.6667 | 4 | 1.4819 | - |
| 1.0 | 6 | 1.5272 | 1.2755 |
| 1.3333 | 8 | 1.2528 | - |
| 1.5 | 9 | - | 1.2600 |
| 1.6667 | 10 | 1.421 | - |
| 2.0 | 12 | 1.1836 | 1.2422 |
| 2.3333 | 14 | 1.2527 | - |
| 2.5 | 15 | - | 1.2317 |
| 2.6667 | 16 | 1.485 | - |
| 3.0 | 18 | 0.8239 | 1.1883 |
| 3.3333 | 20 | 1.1028 | - |
| 3.5 | 21 | - | 1.1533 |
| 3.6667 | 22 | 0.9746 | - |
| 4.0 | 24 | 0.816 | 1.1237 |
@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",
}
@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}
}