SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
This is a sentence-transformers model finetuned on NFCorpus from sentence-transformers/all-MiniLM-L6-v2.
It is specialised for Information retrieval (IR). Here is the relative improvement compared to the original model:
| Metric |
Value |
Value after finetuning |
| cosine_accuracy@1 |
0.34 |
0.49 |
| cosine_accuracy@3 |
0.57 |
0.68 |
| cosine_accuracy@5 |
0.64 |
0.76 |
| cosine_accuracy@10 |
0.72 |
0.83 |
| cosine_ndcg@10 |
0.26 |
0.39 |
| cosine_mrr@10 |
0.47 |
0.58 |
| cosine_map@100 |
0.12 |
0.26 |
More information on training and dev can be found below.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: sentence-transformers/all-MiniLM-L6-v2
- Maximum Sequence Length: 256 tokens
- Output Dimensionality: 384 dimensions
- Similarity Function: Cosine Similarity
Model Sources
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 384, '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()
)
Usage
Direct Usage (Sentence Transformers)
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
model = SentenceTransformer("dboyker-code/all-MiniLM-L6-v2-nfcorpus")
queries = [
"wart cancer viruses in food last year , i talked about butcher \u2019 s warts , a condition that afflicts those who handle fresh meat for a living because of the viruses in meat , but it \u2019 s more than just a cosmetic issue . earlier this year , a landmark study of cancer mortality in poultry workers was released . we \u2019 ve known that people who handle a lot of fresh chicken get a lot of warts on their hands , but the concern is that some of the wart viruses are oncogenic , or cancer-causing . workers in poultry slaughtering and processing are exposed to these cancer-causing viruses , some of which are the most potent cancer-causing agents known in animals , but what does that mean for people ? well , compared to the general population , poultry workers appear to have an excess of cancers of the mouth , nasal cavities , throat . cancer of the tongue , the tonsils , the inner ear , then down the esophagus , rectal / anal cancer , and liver , bone marrow , and blood cancers as well . the reason it \u2019 s so important to study this group is because it \u2019 s possible that the cancer-causing viruses present in poultry and poultry products could be transmitted to anyone handing raw poultry . proper cooking will kill any and all chicken wart and cancer viruses , but the problem is that meat may come into our homes fresh or frozen and contaminate our hands or kitchen surfaces before it gets into the pot . same concern with other meat . there was a fascinating case report about pork intake and human papillomavirus , hpv , which can cause cancerous anal and genital warts . oh , the poor guy . 19 years old . giant warty tumor nearly an inch in diameter protruding from the tip of his penis . they cut it off , but it grew right back and so they asked for a dietary history . he was eating more than a pound of pork a day . they told him to stop the pork , and the tumor completely regressed on its own \u2014 totally disappeared . the doctors were so blown away , they even went as far as to suggest that the low cervical cancer rates in israel could be because they eat so little pork . so why do i have warts on my fingers ? i have been vegan for four and a half years . how can i get rid of them ? the animal you most likely got your wart virus infection from was homo sapiens . wart viruses are thought to be typically transmitted when using a towel or something someone else with a wart has used . salicylic acid is probably the most effective treatment ( 75 % success rate compared to about 50 % for placebo ) . thanks for your question , heidi ! hi dr i love your videos , keep up the good work . i have been trying to find information about the prevention of sore throats on your website . i am a vegetarian and do no have milk but i seem to constantly getting a sore throat can you help ? hi andrew , there are a number of reasons why someone might get a sore throat . if you \u2019 re getting them often , you might want to look at possible lifestyle factors . things like pollution , not washing your hands , or even dehydration could contribute to the frequency and severity of the symptoms you \u2019 re feeling . preventative dietary strategy ? drink lots of fluids ( hot or room temperature ) when you \u2019 re feeling a sore throat come on . you might want to try a warm bowl of miso soup to get the pro-biotic benefits ( just don \u2019 t over-heat and kill the health promoting enzymes ) . avoid alcohol . and make sure you \u2019 re getting vitamins and minerals such as zinc , vitamin e and vitamin c. oh , and make sure you \u2019 re getting enough sleep : http : / / nutritionfacts.org / videos / sleep-immunity / also , please check out my associated blog post : http : / / nutritionfacts.org / blog / 2012 / 05 / 17 / poultry-and-penis-cancer / ! please also check out my associated blog post , poultry and penis cancer ! butcher \u0027s warts , cancer , carcinogens , chicken , colon health , ear health , esophageal cancer , esophagus health , inner ear cancer , mortality , mouth cancer , nasal cavity cancer , oral health , pork , poultry , poultry workers , skin health , throat cancer , throat health , tongue cancer , tonsil cancer , viral infections , wart viruses , warts the wart-causing viruses in animals may present more than just a cosmetic issue for consumers . other videos on cancer viruses and meat include : chicken dioxins , viruses , or antibiotics ? carcinogenic retrovirus found in eggs poultry exposure tied to liver and pancreatic cancer poultry exposure and neurological diseaseplease feel free to post any ask-the-doctor type questions here in the comments section and i \u2019 d be happy to try to answer them . and check out the other videos on poultry . also , there are 1,686 other subjects covered in the rest of my videos--please feel free to explore them as well ! for more context , check out my associated blog post , poultry and penis cancer .",
]
documents = [
'Abstract Background In October 2007, a cluster of patients experiencing a novel polyradiculoneuropathy was identified at a pork abattoir (Plant A). Patients worked in the primary carcass processing area (warm room); the majority processed severed heads (head-table). An investigation was initiated to determine risk factors for illness. Methods and Results Symptoms of the reported patients were unlike previously described occupational associated illnesses. A case-control study was conducted at Plant A. A case was defined as evidence of symptoms of peripheral neuropathy and compatible electrodiagnostic testing in a pork abattoir worker. Two control groups were used - randomly selected non-ill warm-room workers (n\u200a=\u200a49), and all non-ill head-table workers (n\u200a=\u200a56). Consenting cases and controls were interviewed and blood and throat swabs were collected. The 26 largest U.S. pork abattoirs were surveyed to identify additional cases. Fifteen cases were identified at Plant A; illness onsets occurred during May 2004–November 2007. Median age was 32 years (range, 21–55 years). Cases were more likely than warm-room controls to have ever worked at the head-table (adjusted odds ratio [AOR], 6.6; 95% confidence interval [CI], 1.6–26.7), removed brains or removed muscle from the backs of heads (AOR, 10.3; 95% CI, 1.5–68.5), and worked within 0–10 feet of the brain removal operation (AOR, 9.9; 95% CI, 1.2–80.0). Associations remained when comparing head-table cases and head-table controls. Workers removed brains by using compressed air that liquefied brain and generated aerosolized droplets, exposing themselves and nearby workers. Eight additional cases were identified in the only two other abattoirs using this technique. The three abattoirs that used this technique have stopped brain removal, and no new cases have been reported after 24 months of follow up. Cases compared to controls had higher median interferon-gamma (IFNγ) levels (21.7 pg/ml; vs 14.8 pg/ml, P<0.001). Discussion This novel polyradiculoneuropathy was associated with removing porcine brains with compressed air. An autoimmune mechanism is supported by higher levels of IFNγ in cases than in controls consistent with other immune mediated illnesses occurring in association with neural tissue exposure. Abattoirs should not use compressed air to remove brains and should avoid procedures that aerosolize CNS tissue. This outbreak highlights the potential for respiratory or mucosal exposure to cause an immune-mediated illness in an occupational setting.',
'Abstract Purpose The effect of brewers’ yeast (1,3)-(1,6)-beta-d-glucan consumption on the number of common cold episodes in healthy subject was investigated. Methods In a placebo-controlled, double-blind, randomized, multicentric clinical trial, 162 healthy participants with recurring infections received 900\xa0mg of either placebo (n\xa0=\xa081) or an insoluble yeast (1,3)-(1,6)-beta-d-glucan preparation (n\xa0=\xa081) per day over a course of 16\xa0weeks. Subjects were instructed to document each occurring common cold episode in a diary and to rate ten predefined infection symptoms during an infections period, resulting in a symptom score. The subjects were examined by the investigator during the episode visit on the 5th day of each cold episode. Results In the per protocol population, supplementation with insoluble yeast (1,3)-(1,6)-beta-glucan reduced the number of symptomatic common cold infections by 25\xa0% as compared to placebo (p\xa0=\xa00.041). The mean symptom score was 15\xa0% lower in the beta-glucan as opposed to the placebo group (p\xa0=\xa00.125). Beta-glucan significantly reduced sleep difficulties caused by cold episode as compared to placebo (p\xa0=\xa00.028). Efficacy of yeast beta-glucan was rated better than the placebo both by physicians (p\xa0=\xa00.004) participants (p\xa0=\xa00.012). Conclusion The present study demonstrated that yeast beta-glucan preparation increased the body’s potential to defend against invading pathogens.',
'Abstract AIMS: In animals, intracerebroventricular glucose and fructose have opposing effects on appetite and weight regulation. In humans, functional brain magnetic resonance imaging (fMRI) studies during glucose ingestion or infusion have demonstrated suppression of hypothalamic signalling, but no studies have compared the effects of glucose and fructose. We therefore sought to determine if the brain response differed to glucose vs. fructose in humans independently of the ingestive process. METHODS: Nine healthy, normal weight subjects underwent blood oxygenation level dependent (BOLD) fMRI measurements during either intravenous (IV) glucose (0.3 mg/kg), fructose (0.3 mg/kg) or saline, administered over 2 min in a randomized, double-blind, crossover study. Blood was sampled every 5 min during a baseline period and following infusion for 60 min in total for glucose, fructose, lactate and insulin levels. RESULTS: No significant brain BOLD signal changes were detected in response to IV saline. BOLD signal in the cortical control areas increased during glucose infusion (p = 0.002), corresponding with increased plasma glucose and insulin levels. In contrast, BOLD signal decreased in the cortical control areas during fructose infusion (p = 0.006), corresponding with increases of plasma fructose and lactate. Neither glucose nor fructose infusions significantly altered BOLD signal in the hypothalamus. CONCLUSION: In normal weight humans, cortical responses as assessed by BOLD fMRI to infused glucose are opposite to those of fructose. Differential brain responses to these sugars and their metabolites may provide insight into the neurologic basis for dysregulation of food intake during high dietary fructose intake. © 2011 Blackwell Publishing Ltd.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
Evaluation
Metrics
Information Retrieval
| Metric |
Value |
| cosine_accuracy@1 |
0.4383 |
| cosine_accuracy@3 |
0.6821 |
| cosine_accuracy@5 |
0.7593 |
| cosine_accuracy@10 |
0.8333 |
| cosine_ndcg@10 |
0.3885 |
| cosine_mrr@10 |
0.5802 |
| cosine_map@100 |
0.2538 |
Training Details
Training Dataset
Unnamed Dataset
Evaluation Dataset
Unnamed Dataset
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: steps
per_device_train_batch_size: 64
per_device_eval_batch_size: 64
learning_rate: 3e-05
weight_decay: 0.01
num_train_epochs: 5
warmup_ratio: 0.1
fp16: True
disable_tqdm: True
load_best_model_at_end: True
All Hyperparameters
Click to expand
overwrite_output_dir: False
do_predict: False
eval_strategy: steps
prediction_loss_only: True
per_device_train_batch_size: 64
per_device_eval_batch_size: 64
per_gpu_train_batch_size: None
per_gpu_eval_batch_size: None
gradient_accumulation_steps: 1
eval_accumulation_steps: None
torch_empty_cache_steps: None
learning_rate: 3e-05
weight_decay: 0.01
adam_beta1: 0.9
adam_beta2: 0.999
adam_epsilon: 1e-08
max_grad_norm: 1.0
num_train_epochs: 5
max_steps: -1
lr_scheduler_type: linear
lr_scheduler_kwargs: {}
warmup_ratio: 0.1
warmup_steps: 0
log_level: passive
log_level_replica: warning
log_on_each_node: True
logging_nan_inf_filter: True
save_safetensors: True
save_on_each_node: False
save_only_model: False
restore_callback_states_from_checkpoint: False
no_cuda: False
use_cpu: False
use_mps_device: False
seed: 42
data_seed: None
jit_mode_eval: False
bf16: False
fp16: True
fp16_opt_level: O1
half_precision_backend: auto
bf16_full_eval: False
fp16_full_eval: False
tf32: None
local_rank: 0
ddp_backend: None
tpu_num_cores: None
tpu_metrics_debug: False
debug: []
dataloader_drop_last: True
dataloader_num_workers: 0
dataloader_prefetch_factor: None
past_index: -1
disable_tqdm: True
remove_unused_columns: True
label_names: None
load_best_model_at_end: True
ignore_data_skip: False
fsdp: []
fsdp_min_num_params: 0
fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
fsdp_transformer_layer_cls_to_wrap: None
accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
parallelism_config: None
deepspeed: None
label_smoothing_factor: 0.0
optim: adamw_torch
optim_args: None
adafactor: False
group_by_length: False
length_column_name: length
project: huggingface
trackio_space_id: trackio
ddp_find_unused_parameters: None
ddp_bucket_cap_mb: None
ddp_broadcast_buffers: False
dataloader_pin_memory: True
dataloader_persistent_workers: False
skip_memory_metrics: True
use_legacy_prediction_loop: False
push_to_hub: False
resume_from_checkpoint: None
hub_model_id: None
hub_strategy: every_save
hub_private_repo: None
hub_always_push: False
hub_revision: None
gradient_checkpointing: False
gradient_checkpointing_kwargs: None
include_inputs_for_metrics: False
include_for_metrics: []
eval_do_concat_batches: True
fp16_backend: auto
push_to_hub_model_id: None
push_to_hub_organization: None
mp_parameters:
auto_find_batch_size: False
full_determinism: False
torchdynamo: None
ray_scope: last
ddp_timeout: 1800
torch_compile: False
torch_compile_backend: None
torch_compile_mode: None
include_tokens_per_second: False
include_num_input_tokens_seen: no
neftune_noise_alpha: None
optim_target_modules: None
batch_eval_metrics: False
eval_on_start: False
use_liger_kernel: False
liger_kernel_config: None
eval_use_gather_object: False
average_tokens_across_devices: True
prompts: None
multi_dataset_batch_sampler: proportional
router_mapping: {}
learning_rate_mapping: {}
Training Logs
| Epoch |
Step |
Training Loss |
Validation Loss |
dev_cosine_ndcg@10 |
| 0.0579 |
100 |
4.5784 |
3.6899 |
0.2575 |
| 0.1158 |
200 |
3.7454 |
3.4444 |
0.2943 |
| 0.1737 |
300 |
3.6286 |
3.3864 |
0.2997 |
| 0.2316 |
400 |
3.5706 |
3.3173 |
0.3167 |
| 0.2895 |
500 |
3.4935 |
3.2910 |
0.3183 |
| 0.3474 |
600 |
3.4682 |
3.2391 |
0.3230 |
| 0.4053 |
700 |
3.4361 |
3.2089 |
0.3250 |
| 0.4632 |
800 |
3.3731 |
3.1708 |
0.3300 |
| 0.5211 |
900 |
3.3421 |
3.1532 |
0.3424 |
| 0.5790 |
1000 |
3.2904 |
3.1223 |
0.3422 |
| 0.6369 |
1100 |
3.2709 |
3.0798 |
0.3400 |
| 0.6948 |
1200 |
3.2191 |
3.0619 |
0.3503 |
| 0.7528 |
1300 |
3.1983 |
3.0471 |
0.3470 |
| 0.8107 |
1400 |
3.1622 |
3.0461 |
0.3424 |
| 0.8686 |
1500 |
3.1495 |
3.0081 |
0.3518 |
| 0.9265 |
1600 |
3.1218 |
2.9875 |
0.3544 |
| 0.9844 |
1700 |
3.0686 |
2.9786 |
0.3585 |
| 1.0423 |
1800 |
3.0237 |
2.9984 |
0.3579 |
| 1.1002 |
1900 |
2.9812 |
2.9910 |
0.3611 |
| 1.1581 |
2000 |
2.9644 |
2.9669 |
0.3622 |
| 1.2160 |
2100 |
2.9052 |
3.0249 |
0.3611 |
| 1.2739 |
2200 |
2.9233 |
2.9563 |
0.3690 |
| 1.3318 |
2300 |
2.9177 |
2.9564 |
0.3692 |
| 1.3897 |
2400 |
2.8904 |
2.9492 |
0.3709 |
| 1.4476 |
2500 |
2.9017 |
2.9441 |
0.3699 |
| 1.5055 |
2600 |
2.8931 |
2.9119 |
0.3677 |
| 1.5634 |
2700 |
2.8529 |
2.9349 |
0.3741 |
| 1.6213 |
2800 |
2.8649 |
2.9082 |
0.3740 |
| 1.6792 |
2900 |
2.8951 |
2.8919 |
0.3682 |
| 1.7371 |
3000 |
2.8254 |
2.9023 |
0.3784 |
| 1.7950 |
3100 |
2.8014 |
2.8863 |
0.3803 |
| 1.8529 |
3200 |
2.8144 |
2.9305 |
0.3875 |
| 1.9108 |
3300 |
2.8314 |
2.8928 |
0.3836 |
| 1.9687 |
3400 |
2.7778 |
2.8889 |
0.3885 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.12.3
- Sentence Transformers: 5.2.0
- Transformers: 4.57.3
- PyTorch: 2.6.0+cu124
- Accelerate: 1.5.2
- Datasets: 4.4.2
- Tokenizers: 0.22.1
Citation
BibTeX
Sentence Transformers
@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",
}
MultipleNegativesRankingLoss
@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}
}