Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 14
How to use MinhPhuc0804/qwen3-embedding-docling-checkthat-task1-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("MinhPhuc0804/qwen3-embedding-docling-checkthat-task1-v1")
sentences = [
"query: @joerogan The libs are just peeved that Rogan beat Covid with FDA approved meds and not their unapproved, untried, emergency‑use‑only vaccines. And yes, the Ivermectin for human use is FDA approved.",
"passage: rates of treatment discontinuation were similar in both arms (19% vs 16%; P = .81).\n\ntitle: Efficacy and Safety of Hydroxychloroquine vs Placebo for Pre-exposure SARS-CoV-2 Prophylaxis Among Health Care Workers\nThe median change in QTc (baseline to 4-week evaluation) did not differ between arms (hydroxychloroquine: 4 milliseconds; 95% CI, -9 to 17; vs placebo: 3 milliseconds; 95% CI, -5 to 11; P = .98). Of the 8 participants with positive results for SARS-CoV-2 (6.4%), 6 developed viral symptoms; none required hospitalization, and all clinically recovered.In this randomized clinical trial, although limited by early termination, there was no clinical benefit of hydroxychloroquine administered daily for 8 weeks as pre-exposure prophylaxis in hospital-based HCWs exposed to patients with COVID-19.ClinicalTrials.gov Identifier: NCT04329923.",
"passage: ARS-CoV-2, including higher IL-1/IL-6 release and decreased production of IFN-α.\n\ntitle: The impact of BNT162b2 mRNA vaccine on adaptive and innate immune responses\nAltogether, these data expand our knowledge regarding the overall immunological effects of this new class of vaccines and underline the need of additional studies to elucidate their effects on both innate and adaptive immune responses.",
"passage: title: The FDA-approved drug ivermectin inhibits the replication of SARS-CoV-2 in vitro\nabstract: Although several clinical trials are now underway to test possible therapies, the worldwide response to the COVID-19 outbreak has been largely limited to monitoring/containment. We report here that Ivermectin, an FDA-approved anti-parasitic previously shown to have broad-spectrum anti-viral activity in vitro, is an inhibitor of the causative virus (SARS-CoV-2), with a single addition to Vero-hSLAM cells 2 h post infection with SARS-CoV-2 able to effect ~5000-fold reduction in viral RNA at 48 h. Ivermectin therefore warrants further investigation for possible benefits in humans."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from Qwen/Qwen3-Embedding-0.6B. It maps sentences & paragraphs to a 1024-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': 'Qwen3Model'})
(1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'lasttoken', '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("MinhPhuc0804/qwen3-embedding-docling-checkthat-task1-v1")
# Run inference
queries = [
'query: Myocarditis-triggered Unexpected Demise following BNT162b2 mRNA COVID-19 Immunization in Korea: Case Study Concentrating on Tissue-level Findings Sangjoon Choi et al.',
]
documents = [
'passage: title: Myocarditis-induced Sudden Death after BNT162b2 mRNA COVID-19 Vaccination in Korea: Case Report Focusing on Histopathological Findings\nabstract: We present autopsy findings of a 22-year-old man who developed chest pain 5 days after the first dose of the BNT162b2 mRNA vaccine and died 7 hours later. Histological examination of the heart revealed isolated atrial myocarditis, with neutrophil and histiocyte predominance. Immunohistochemical C4d staining revealed scattered single-cell necrosis of myocytes which was not accompanied by inflammatory infiltrates. Extensive contraction band necrosis was observed in the atria and ventricles. There was no evidence of microthrombosis or infection in the heart and other organs. The primary cause of death was determined to be myocarditis, causally-associated with the BNT162b2 vaccine.',
'passage: atase (DUSP) expression in neurons in the disease process.\n\ntitle: Mitogen Activated Protein Kinase (MAPK) Activation, p53, and Autophagy Inhibition Characterize the Severe Acute Respiratory Syndrome Coronavirus 2 (SARS-CoV-2) Spike Protein Induced Neurotoxicity\nThe pathways induced by the spike protein via toll-like receptor activation induce both the upregulation of PrPC (the normal isoform of the prion protein, PrP) and the expression of β amyloid. Through the spike-protein-dependent elevation of p53 levels via β amyloid metabolism, increased PrPC expression can lead to PrP misfolding and impaired autophagy, generating prion disease. We conclude that, according to the age of the spike protein-exposed patient and the state of their cellular autophagy activity, excess sustained activity of p53 in neurons may be a catalytic factor in neurodegeneration. An autoimmune reaction via molecular mimicry likely also contributes to neurological symptoms. Overall results suggest that neurodegeneration is in part due to the intensity and duration of spike protein exposure, patient advanced age, cellular autophagy activity, and activation, function and regulation of p53.',
'passage: more contacts (22.8%; 95% CI, 13.6%-33.5%).\n\ntitle: Household Transmission of SARS-CoV-2\n<h3>Conclusions and Relevance</h3> The findings of this study suggest that given that individuals with suspected or confirmed infections are being referred to isolate at home, households will continue to be a significant venue for transmission of SARS-CoV-2.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 1024] [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.8458, 0.1361, 0.0091]])
10-percent-dev-splitInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.5595 |
| cosine_accuracy@3 | 0.7668 |
| cosine_accuracy@5 | 0.8234 |
| cosine_accuracy@10 | 0.8712 |
| cosine_precision@1 | 0.5595 |
| cosine_precision@3 | 0.2556 |
| cosine_precision@5 | 0.1647 |
| cosine_precision@10 | 0.0871 |
| cosine_recall@1 | 0.5595 |
| cosine_recall@3 | 0.7668 |
| cosine_recall@5 | 0.8234 |
| cosine_recall@10 | 0.8712 |
| cosine_ndcg@10 | 0.721 |
| cosine_mrr@10 | 0.6723 |
| cosine_map@100 | 0.676 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
query: 10) Sure enough, a slew of reports in numerous nations showing a rise in infections in children in the fresh surge in 2021, probably because of #B117 variant. |
passage: otherapy at Israel's Bar-Ilan University and member of the country's national covid-19 vaccine clinical trial advisory committee, |
query: CDC: Monkeypox isn’t airborne. And CDC: Wear a snug mask. Me: snug mask might only imply aerosols. Which are in the air. If not, you could wear a face shield for just droplets. Research on fomites- reveals that #MonkeypoxIsAirborne |
passage: " or ulcerated, to characteristically well-circumscribed and centrally umbilicated. Both patients had mild illness. |
query: The extra advantage of vaccination combined with Omicron infection for neutralizing antibodies versus infection alone: far reduced expected protection throughout all variants, Omicron itself included. |
passage: title: Neutralization profile of Omicron variant convalescent individuals |
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: 32per_device_eval_batch_size: 32num_train_epochs: 10fp16: Truemulti_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseprediction_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: 1num_train_epochs: 10max_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: 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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_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: Nonehub_always_push: Falsehub_revision: Nonegradient_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: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | 10-percent-dev-split_cosine_ndcg@10 |
|---|---|---|---|
| 0.9225 | 500 | 0.3566 | - |
| 1.0 | 542 | - | 0.7010 |
| 1.8450 | 1000 | 0.194 | - |
| 2.0 | 1084 | - | 0.7106 |
| 2.7675 | 1500 | 0.0851 | - |
| 3.0 | 1626 | - | 0.7200 |
| 3.6900 | 2000 | 0.0447 | - |
| 4.0 | 2168 | - | 0.7184 |
| 4.6125 | 2500 | 0.0342 | - |
| 5.0 | 2710 | - | 0.7151 |
| 5.5351 | 3000 | 0.0254 | - |
| 6.0 | 3252 | - | 0.7113 |
| 6.4576 | 3500 | 0.0216 | - |
| 7.0 | 3794 | - | 0.7171 |
| 7.3801 | 4000 | 0.0189 | - |
| 8.0 | 4336 | - | 0.7221 |
| 8.3026 | 4500 | 0.0169 | - |
| 9.0 | 4878 | - | 0.7179 |
| 9.2251 | 5000 | 0.0167 | - |
| 10.0 | 5420 | - | 0.7210 |
@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},
}