Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 16
How to use ozgur-celik/all-mpnet-base-v2-qaitrain500-500 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("ozgur-celik/all-mpnet-base-v2-qaitrain500-500")
sentences = [
"Which type of doctor should a patient visit if there is doubt about the health of their maxillary sinus before undergoing surgery?",
"# Postoperative sinusitis\n\nResolution of\nResolution of\nall symptoms\n all symptoms\nand signs after\nResolution of\nand signs\nGraft\nall symptoms\nMaxillary\n contained\nSecond regimen\n 3 weeks\nNo\nand signs\nsinus\nunder\nof antibiotics\nPartial graft/\nresolution of\nMonitor the\nthe sinus\nelevation\nimplants\n symptoms\n patient\nNo resolution of\n symptoms and\nmembrane\nNo\nremoval\nGrafit/implants\nand signs\nTotal graft\n removal\nCBCT\nresolution of\nremoval via\nsigns after 3\nsymptoms\nGraft not\nintraoral approach\nweeks\nand signs\n contained\nwith or without\nunder\ninteranasal\nthe sinus\napproach (FESS)\nmembrane",
"# Evaluation of paranasal sinuses\n\nThe crux of sinus diagnosis rests on a thorough, focused history\nand physical examination. In patients who are planned to\nundergo maxillary sinus floor augmentation, it is critical to elicit\na proper history and to perform a focused physical examination\non the paranasal sinuses and associated structures. Patients\nwho are afflicted with at least one major sinus infection every\nyear merit consideration of full CT evaluation. Box 2-1 summa-\nrizes the most common signs and symptoms associated with\nrhinosinusitis. In addition, findings such as pain with palpa-\ntion or percussion over the paranasal sinuses, hearing changes,\nmaxillary dental pain, periorbital discomfort, sinus headache,\nor turbinate hyperemia may indicate sinusitis.\nCT imaging-most often CBCT-is of utmost importance in\nevaluating both the maxillary edentulous ridge and the health",
"# References\n\n8. Ogle OE, Weinstock RJ, Friedman E. Surgical anatomy of the\nnasal cavity and paranasal sinuses. Oral Maxillofac Surg Clin\nNorth Am 2012;24:155-166.\n9. Haghnegahdar A, Khojastepour L, Naderi A. Evaluation of",
"FIG 10-33 Healthy maxillary sinuses.",
"hysiologic changes that occur in the maxilla following\nthe loss of teeth often do not allow for the placement of\ndental implants in the posterior maxilla. Loss of alveolar\nheight due to periodontal disease and tooth extractions\ncombined with the possibility of secondary sinus pneumatization \nlimit the available bone height for implant placement.\nMaxillary sinus augmentation has evolved as a predictable\nsolution to correct this deficiency. It has been part of the authors'\nsurgical armamentarium for more than 30 years1 and has under-\ngone many changes in surgical protocol over this time as a result\nf ongoing clinical and scientific research, the development of\nnew products and technologies, the desire for higher proce-\nural success rates and reduced complication rates, and the\ndemand for minimally invasive surgical approaches. There have\nbeen numerous transcrestal sinus elevation techniques devel-\noped that have proven to be the equal to the lateral window\napproach in outcome; however, when less than 4 mm of resid-\nual crestal bone is available, the lateral window remains the\nprocedure of choice.\nThis chapter will begin with a discussion of indications and\ncontraindications, followed by basic sinus anatomy. Preopera-\ntive treatment planning will be presented in a manner that will\nprovide the clinician with a means of determining whether an\ninterdisciplinary consultation with an ear, nose, and throat (ENT)\nphysician is indicated and to determine the difficulty level of\nthe case in question."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [6, 6]This is a sentence-transformers model finetuned from sentence-transformers/all-mpnet-base-v2. 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': 384, 'do_lower_case': False, 'architecture': '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})
(2): Normalize()
)
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("ozgur-celik/all-mpnet-base-v2-qaitrain500-500")
# Run inference
sentences = [
'How long should a patient wait for soft tissue to heal after a tooth extraction before undergoing regenerative surgery for ridge augmentation?',
'# Vertical periodontal regeneration\nin combination with ridge\naugmentation\n\ninterproximal bone loss, the smile line, and esthetic\nexpectations should be considered. In cases where\nthe decision is difficult to make, even after the clin-\nician has evaluated these criteria, it can also be de-\ncided during the regenerative surgery. In some cas-\nes, the clinician should consider whether there will\nbe a soft tissue defect when the extraction is per-\nformed during the regenerative surgery, and then\nthe flap design has to be at least one tooth larger. In\ncases where the extraction is performed before the\nidge augmentation, a complete soft tissue healing\ntime of about 2 months should be allowed before\nthe regenerative surgery.\nIn this chapter, technical details of interproximal\nbone and soft tissue regeneration are reviewed\nthrough a representative case of vertical periodon-\ntal regeneration in combination with ridge augmen-\ntation. The 55-year-old, healthy, male patient was\ntreated with an immediate implant at site 12 a dec-\nade previously at another clinic. The patient experi-\nenced bleeding and purulent exudate around the\nimplant and sensitivity of the neighboring lateral\nincisor shortly after implant placement. He sought\ntreatment due to an abscess around the implant.',
'Fig 9 Ridge preservation via placement of a biomaterial to reduce shrink-\nage following tooth extraction.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.6634, 0.3224],
# [0.6634, 1.0000, 0.3342],
# [0.3224, 0.3342, 1.0000]])
anchor, positive, negative_1, negative_2, negative_3, and negative_4| anchor | positive | negative_1 | negative_2 | negative_3 | negative_4 | |
|---|---|---|---|---|---|---|
| type | string | string | string | string | string | string |
| details |
|
|
|
|
|
|
| anchor | positive | negative_1 | negative_2 | negative_3 | negative_4 |
|---|---|---|---|---|---|
What specific term does Larsson use to describe the personality-dependent, additional sucking urge observed in children who engage in non-nutritive sucking behaviors? |
# B) Abbau schädlicher Gewohnheiten (Habits) |
# ugar and childhood obesity |
# 8.5.1 Gingival recessions |
# WHEN BRUSHING IS A STRUGGLE |
# REFERENCES |
What type of implant is recommended for a narrow-diameter implant case according to the Esthetic Risk Assessment? |
# Table 1 Esthetic Risk Assessment (ERA) |
# Single-tooth gap |
# 2.3.1 |
# The Relationship Between Peri-implant |
# Treatment guidelines |
Which specific shade of composite material was utilized to simulate the incisal halo effect on the left central incisor during the restorative procedure described in the Manauta case? |
Q: You invented the centripetal technique in the year 1994. Is it only for posteriors? |
# The incisal hook |
Fig 4-33h Left lateral incisor. Folded protective |
# LITERATUR |
# References |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false
}
eval_strategy: stepslearning_rate: 2e-05num_train_epochs: 2warmup_ratio: 0.1data_seed: 42dataloader_pin_memory: Falsehub_model_id: ozgur-celik/all-mpnet-base-v2-qaitrain500-500hub_private_repo: Trueeval_on_start: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8per_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: 2max_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: 42jit_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}tp_size: 0fsdp_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: Falsedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: ozgur-celik/all-mpnet-base-v2-qaitrain500-500hub_strategy: every_savehub_private_repo: Truehub_always_push: Falsegradient_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: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Trueuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0 | 0 | - |
| 0.5 | 50 | 1.7984 |
| 1.0 | 100 | 1.3651 |
| 1.5 | 150 | 0.704 |
| 2.0 | 200 | 0.6485 |
@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}
}
Base model
sentence-transformers/all-mpnet-base-v2