Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 16
How to use OmmWankhedee369/bge-base-medical-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("OmmWankhedee369/bge-base-medical-v1")
sentences = [
"Represent this sentence for searching relevant passages: Does sixteen-slice multi-detector computed tomographic angiography improve the accuracy of screening for blunt cerebrovascular injury?",
"This paper sets out to analyse the use of the Six Sigma methodology to improve quality in healthcare. It looks at how Six Sigma grew out of the concept of Total Quality Management (TQM). Six Sigma is a quality improvement methodology that has been widely adopted by companies since the early 1990s and has grown exponentially in the healthcare industry during the past five years. Some of the main tenets of Six Sigma have emerged from the principles of TQM, including the notion that the entire organization must support the quality effort; that there should be a vigorous education effort; and that a quality improvement process should emphasize root cause analysis. In spite of its early success, TQM \"crashed and burned\" for several reasons including the fact that financial benefits were difficult to assign to TQM efforts, root cause was not always determined resulting in recurring errors, there was no common metric to measure the level of quality attained, and quality efforts were sometimes aimed at processes or operations that were not critical to the customer. Six Sigma filled the vacuums created by these TQM failures in several ways. Under the Six Sigma methodology, quality improvement projects are carefully defined so that they can be successfully completed within a relatively short time frame. Financials are applied to each completed project so that management knows how much the project saves the institution.",
"Mandible. (D) Mandible # FRACTURES OF MAXILLA: They are classified into 3 types.> Le Fort I (transverse) fracture runs ab and parallel to the palate. It cross lower part of nasal septum, maxillary antra and the pterygoid plates.> Le Fort II (pyramidal) fracture through the root of nose, lacrimal bone, floor of orbit, upper part of maxillary sinus and pterygoid plates.> This fracture has some features common with the zygomatic fractures.> Le Fort III (craniofacial dysfunction): There is complete separation of facial bones from the cranial bones. The fracture line passes through root of nose, ethmofrontal junction, superior orbital fissure, lateral wall of orbit, frontozygomatic and temporozygomatic sutures and the upper part of pterygoid plates.> Mandibular fractures are not a part of Le Fort classification.",
"Blunt cerebrovascular injuries (BCVI) are rare but potentially devastating injuries, particularly if the diagnosis is delayed. Only four-vessel cerebral angiography (FVCA) has been shown to be adequately sensitive and specific as a screening tool for BCVI but is resource-intensive and invasive. Computed tomography (CT) angiography has emerged as a possible alternative, but its accuracy has been poor, particularly for low-grade injuries. Recent advances in CT technology, particularly the use of a multi-detector array for image acquisition should improve the accuracy of this technique. This study is the first reported experience of the role of the 16-slice multi- detector CT scanner in screening for BCVI. From January 2, 2003 to October 31, 2004, all patients who met predefined screening criteria were screened for blunt injury to the carotid (BCI) and vertebral (BVI) arteries with a 16-slice multi-detector CT scanner with angiographic reconstruction (CTA). If CTA was positive or equivocal for BCVI, FVCA was performed as a confirmatory test. If CTA was negative, no further diagnostic studies were performed. There were 435 patients who met criteria and were screened with CTA. Of these, 25 injuries were identified in 24 patients for an incidence of BCVI of 1.2% (24/2023) among all blunt admissions (BTA) and 5.5% (24/435) among screened patients (SP). This was increased compared with the four-slice era (0.38% BTA, 2.4% SP, p<0.01). No patient with a negative CTA was subsequently identified as having, or developed neurologic symptoms attributable to a missed BCVI."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'cls', '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("OmmWankhedee369/bge-base-medical-v1")
# Run inference
sentences = [
'Represent this sentence for searching relevant passages: Adoptive immunity is by:',
"Injection of lymphocytes. Ans. is 'c' i.e., Injection of lymphocytes(Ref: Jawetz, 27th/e, p. 130)* An extract of immunologically competent T - lymphocytes, known as transfer factor can be used in the treatment of lepromatous leprosy when CMI is low.",
'Nonalcoholic fatty liver disease (NAFLD) is likely to replace Hepatitis C as the leading cause of cirrhosis resulting in liver transplantation (LT) within a few years. Unfortunately, due to the lack of established guidelines for the screening of NAFLD in high-risk populations, many patients present with portal hypertension complications as their first manifestation of NAFLD require a LT evaluation. We aimed to investigate what proportion of patients who underwent LT for NAFLD-cirrhosis had knowledge of their liver disease prior to presenting with portal hypertension complications and to identify differences in clinical parameters between those with and without knowledge of preexisting NAFLD. Consecutive patients who underwent LT for NAFLD-cirrhosis at a tertiary referral center were included in the study. Demographic and clinical data at the time of the first LT evaluation visit were collected, and patient knowledge of previous NAFLD was documented. Ascites, variceal bleeding, hepatic encephalopathy, and thrombocytopenia leading to diagnosis of underlying cirrhosis were considered as the presenting symptoms of portal hypertension. A p < 0.05 was considered statistically significant. A total of 124 subjects who received LT for NAFLD-cirrhosis were included, 58 % (n = 72) were male. At the time of the first LT evaluation visit, 60 % had diabetes, the mean body mass index was 33.2 [28.6, 37.6] kg/m(2), and the mean Model for End-Stage Liver Disease (MELD) score was 14.0 [11.0, 19.0]. More importantly, 85/124 patients (68.5 %) had no knowledge of preexisting NAFLD prior to presentation with symptoms of portal hypertension. The presenting symptoms were new-onset ascites in 61 %, hepatic encephalopathy in 25 %, variceal bleeding in 18 %, thrombocytopenia in 9 %, and other in 9 % (non-exclusive). Patients with no prior knowledge of NAFLD were less likely to have a diagnosis of hypercholesterolemia (30 vs. 50 %, p = 0.035) and had a trend toward having higher MELD scores at the time of the first LT evaluation visit (15 vs. 13.5, p = 0.05) and presenting with encephalopathy (25 vs. 10 %, p = 0.06) compared to those with previous knowledge of NAFLD diagnosis.',
]
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.2966, -0.1118],
# [ 0.2966, 1.0000, -0.0079],
# [-0.1118, -0.0079, 1.0000]])
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| anchor | positive |
|---|---|
Represent this sentence for searching relevant passages: Is the Thr92Ala 5 ' type 2 deiodinase gene polymorphism associated with a delayed triiodothyronine secretion in response to the thyrotropin-releasing hormone-stimulation test : a pharmacogenomic study? |
The common Thr92Ala D2 polymorphism has been associated with changes in pituitary-thyroid axis homeostasis, but published results are conflicting. To investigate the effects of the Thr92Ala polymorphism on intrathyroidal thyroxine (T4) to triiodothyronine (T3) conversion, we designed prospective pharmacogenomic intervention aimed to detect differences in T3 levels after thyrotropin (TSH)-releasing hormone (TRH)-mediated TSH stimulation of the thyroid gland. Eighty-three healthy volunteers were screened and genotyped for the Thr92Ala polymorphism. Fifteen volunteers of each genotype (Thr/Thr, Thr/Ala, and Ala/Ala) underwent a 500 mcg intravenous TRH stimulation test with serial measurements of serum total T3 (TT3), free T4, and TSH over 180 minutes. No differences in baseline thyroid hormone levels were seen among the study groups. Compared to the Thr/Thr group, the Ala/Ala group showed a significantly lower TRH-stimulated increase in serum TT3 at 60 minutes (12.07 ± 2.67 vs. 21.07 ± 2.... |
Represent this sentence for searching relevant passages: Do neuroticism and low educational level predict the risk of posttraumatic stress disorder in women after miscarriage or stillbirth? |
This study aimed to determine whether neuroticism and educational level predict posttraumatic stress disorder (PTSD) in women following an unsuccessful pregnancy. Via advertisements, pregnant women with a gestational period shorter than 12 weeks were asked to participate in a study regarding their perception of pregnancy. After they had agreed, they were sent questionnaires, including a scale for neuroticism and their highest attained educational level. Every other month during the pregnancy and 1 month after the expected date of birth, they were sent brief questionnaires about the pregnancy. Participants for whom the pregnancy had ended unsuccessfully were contacted by phone and asked to participate in a follow-up study with a PTSD scale. Of the 1339 women studied, 126 (9%) experienced an unsuccessful pregnancy; 8 of these dropped out of the study (response rate, 94%); 1 had not indicated her educational level. The remaining 117 women filled out the PTSD scale after about 1 month. Thi... |
Represent this sentence for searching relevant passages: Does transfection of promyelocytic leukemia in retrovirus vector inhibit growth of human bladder cancer cells? |
To construct a recombinant retrovirus vector carrying human promyelocytic leukemia (PML) cDNA and identify its expression and biology role in bladder cancer UM-UC-2 cells for future gene therapy. PML full-length cDNA was inserted into the EcoR I and BamH I site of pLXSN vector containing the long terminal repeat (LTR) promoter. The vector was identified by restriction enzyme digestion and then transfected into PA317 packaging cell line by calcium phosphate coprecipitation. PML cDNA was detected by polymerase chain reaction (PCR) and the protein was identified by laser confocal microscopy and Western blot in bladder cancer cells, respectively. The morphology was observed by inverted phase contrast microscope, and MTT assay determined growth curve of the bladder cancer cells. Restriction enzyme digestion proved that a 2.1 kb PML cDNA was inserted into the pLXSN vector. PCR assay demonstrated that 304 bp fragments were found in UM-UC-2/pLPMLSN transfects. Laser confocal microscopy showed ... |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| anchor | positive |
|---|---|
Represent this sentence for searching relevant passages: Are baseline comorbidities and treatment strategy in elderly patients associated with outcome of cardiogenic shock in a community-based population? |
Cardiogenic shock (CGS) historically results in high inhospital mortality, particularly in elderly patients. Factors that contribute to increased mortality and treatment strategies that improve short- and long-term outcomes in patients with CGS remain to be established. The study consisted of 1263 consecutive patients with acute myocardial infarction admitted from Olmsted County, Minn, during the period 1988 to 2000; of these, 73 (6%) developed cardiogenic shock. Short- and long-term mortality was compared between the elderly and younger populations in both shock and nonshock groups. In patients with acute myocardial infarction, age of > or =65 years was associated with increased long-term mortality for nonshock patients (unadjusted relative risk [RR] 5.23, 95% CI 4.10-6.67, P <.001) and to a lesser degree in patients with cardiogenic shock (unadjusted RR 2.02, 95% CI 1.12-3.65, P =.02). Among cardiogenic shock patients, estimated survival at 1 and 5 years for elderly patients was 38% ... |
Represent this sentence for searching relevant passages: Irvin Moore sign is positive in |
Chronic tonsillitis. Irwin-Moore sign:- Expression of cheesy material from the tonsil, on pressing anterior pillar seen in case of chronic tonsillitis. Ref:- Textbook of ENT, Hazarika; pg num:- 480 |
Represent this sentence for searching relevant passages: Do three-dimensional echo-planar MR spectroscopic imaging at short echo times in the human brain? |
To demonstrate the feasibility of three-dimensional echo-planar spectroscopic imaging (EPSI) at short echo time (13 msec) with a conventional clinical imager in the human brain. Periodic inversions of a readout gradient were used during data acquisition to simultaneously encode chemical shift and one spatial dimension in one excitation. Aliasing artifacts were avoided with a modified acquisition-and-processing method based on oversampling. A double outer-volume suppression technique that adapts to the ovoid brain shape was used to strongly reduce extracranial lipid resonances. Three-dimensional spatial encoding in vivo of eight sections with 32 x 32 voxels each (0.75 cm3) was performed in 34 minutes with four signal averages. The spectral resolution and signal-to-noise ratio (S/N) of resonances of inositol, choline, creatine, glutamate and glutamine, and N-acetyl aspartate were consistent with those previously recorded with conventional phase encoding. |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 16num_train_epochs: 1learning_rate: 2e-05warmup_steps: 0.1fp16: Trueper_device_eval_batch_size: 16batch_sampler: no_duplicatesper_device_train_batch_size: 16num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 16prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Truedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.0085 | 100 | 0.2854 | - |
| 0.0171 | 200 | 0.1561 | - |
| 0.0256 | 300 | 0.1099 | - |
| 0.0342 | 400 | 0.0774 | - |
| 0.0427 | 500 | 0.0777 | - |
| 0.0513 | 600 | 0.0587 | - |
| 0.0598 | 700 | 0.0632 | - |
| 0.0684 | 800 | 0.0605 | - |
| 0.0769 | 900 | 0.0666 | - |
| 0.0855 | 1000 | 0.0651 | - |
| 0.0940 | 1100 | 0.0758 | - |
| 0.1026 | 1200 | 0.0610 | - |
| 0.1111 | 1300 | 0.0499 | - |
| 0.1197 | 1400 | 0.0509 | - |
| 0.1282 | 1500 | 0.0611 | - |
| 0.1368 | 1600 | 0.0487 | - |
| 0.1453 | 1700 | 0.0503 | - |
| 0.1539 | 1800 | 0.0508 | - |
| 0.1624 | 1900 | 0.0556 | - |
| 0.1710 | 2000 | 0.0454 | 0.0327 |
| 0.1795 | 2100 | 0.0443 | - |
| 0.1881 | 2200 | 0.0505 | - |
| 0.1966 | 2300 | 0.0454 | - |
| 0.2052 | 2400 | 0.0433 | - |
| 0.2137 | 2500 | 0.0417 | - |
| 0.2223 | 2600 | 0.0441 | - |
| 0.2308 | 2700 | 0.0373 | - |
| 0.2394 | 2800 | 0.0481 | - |
| 0.2479 | 2900 | 0.0405 | - |
| 0.2565 | 3000 | 0.0473 | - |
| 0.2650 | 3100 | 0.0374 | - |
| 0.2736 | 3200 | 0.0254 | - |
| 0.2821 | 3300 | 0.0408 | - |
| 0.2906 | 3400 | 0.0359 | - |
| 0.2992 | 3500 | 0.0382 | - |
| 0.3077 | 3600 | 0.0297 | - |
| 0.3163 | 3700 | 0.0407 | - |
| 0.3248 | 3800 | 0.0343 | - |
| 0.3334 | 3900 | 0.0373 | - |
| 0.3419 | 4000 | 0.0452 | 0.0210 |
| 0.3505 | 4100 | 0.0485 | - |
| 0.3590 | 4200 | 0.0393 | - |
| 0.3676 | 4300 | 0.0375 | - |
| 0.3761 | 4400 | 0.0356 | - |
| 0.3847 | 4500 | 0.0407 | - |
| 0.3932 | 4600 | 0.0343 | - |
| 0.4018 | 4700 | 0.0401 | - |
| 0.4103 | 4800 | 0.0381 | - |
| 0.4189 | 4900 | 0.0317 | - |
| 0.4274 | 5000 | 0.0277 | - |
| 0.4360 | 5100 | 0.0307 | - |
| 0.4445 | 5200 | 0.0289 | - |
| 0.4531 | 5300 | 0.0334 | - |
| 0.4616 | 5400 | 0.0348 | - |
| 0.4702 | 5500 | 0.0319 | - |
| 0.4787 | 5600 | 0.0382 | - |
| 0.4873 | 5700 | 0.0255 | - |
| 0.4958 | 5800 | 0.0298 | - |
| 0.5044 | 5900 | 0.0335 | - |
| 0.5129 | 6000 | 0.0302 | 0.0233 |
| 0.5215 | 6100 | 0.0308 | - |
| 0.5300 | 6200 | 0.0313 | - |
| 0.5386 | 6300 | 0.0298 | - |
| 0.5471 | 6400 | 0.0318 | - |
| 0.5557 | 6500 | 0.0314 | - |
| 0.5642 | 6600 | 0.0385 | - |
| 0.5727 | 6700 | 0.0304 | - |
| 0.5813 | 6800 | 0.0293 | - |
| 0.5898 | 6900 | 0.0232 | - |
| 0.5984 | 7000 | 0.0291 | - |
| 0.6069 | 7100 | 0.0348 | - |
| 0.6155 | 7200 | 0.0256 | - |
| 0.6240 | 7300 | 0.0314 | - |
| 0.6326 | 7400 | 0.0290 | - |
| 0.6411 | 7500 | 0.0294 | - |
| 0.6497 | 7600 | 0.0298 | - |
| 0.6582 | 7700 | 0.0271 | - |
| 0.6668 | 7800 | 0.0338 | - |
| 0.6753 | 7900 | 0.0259 | - |
| 0.6839 | 8000 | 0.0294 | 0.0194 |
| 0.6924 | 8100 | 0.0250 | - |
| 0.7010 | 8200 | 0.0282 | - |
| 0.7095 | 8300 | 0.0295 | - |
| 0.7181 | 8400 | 0.0302 | - |
| 0.7266 | 8500 | 0.0254 | - |
| 0.7352 | 8600 | 0.0229 | - |
| 0.7437 | 8700 | 0.0240 | - |
| 0.7523 | 8800 | 0.0274 | - |
| 0.7608 | 8900 | 0.0230 | - |
| 0.7694 | 9000 | 0.0247 | - |
| 0.7779 | 9100 | 0.0262 | - |
| 0.7865 | 9200 | 0.0269 | - |
| 0.7950 | 9300 | 0.0337 | - |
| 0.8036 | 9400 | 0.0283 | - |
| 0.8121 | 9500 | 0.0270 | - |
| 0.8207 | 9600 | 0.0193 | - |
| 0.8292 | 9700 | 0.0215 | - |
| 0.8378 | 9800 | 0.0283 | - |
| 0.8463 | 9900 | 0.0226 | - |
| 0.8548 | 10000 | 0.0224 | 0.0175 |
| 0.8634 | 10100 | 0.0267 | - |
| 0.8719 | 10200 | 0.0341 | - |
| 0.8805 | 10300 | 0.0250 | - |
| 0.8890 | 10400 | 0.0222 | - |
| 0.8976 | 10500 | 0.0218 | - |
| 0.9061 | 10600 | 0.0230 | - |
| 0.9147 | 10700 | 0.0235 | - |
| 0.9232 | 10800 | 0.0293 | - |
| 0.9318 | 10900 | 0.0292 | - |
| 0.9403 | 11000 | 0.0223 | - |
| 0.9489 | 11100 | 0.0259 | - |
| 0.9574 | 11200 | 0.0352 | - |
| 0.9660 | 11300 | 0.0243 | - |
| 0.9745 | 11400 | 0.0237 | - |
| 0.9831 | 11500 | 0.0281 | - |
| 0.9916 | 11600 | 0.0271 | - |
| 1.0 | 11698 | - | 0.0160 |
@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{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}
Base model
BAAI/bge-base-en-v1.5