MPNet base trained on GooAQ triplets using CachedMultipleNegativesBidirectionalRankingLoss (refactored)
This is a sentence-transformers model finetuned from microsoft/mpnet-base on the gooaq dataset. 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.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: microsoft/mpnet-base
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- Language: en
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, '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})
)
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
# Download from the 🤗 Hub
model = SentenceTransformer("tomaarsen/mpnet-base-gooaq-cmnbrl-1024bs-0qidi")
# Run inference
queries = [
"is duchenne muscular dystrophy a dominant or recessive trait?",
]
documents = [
'Duchenne muscular dystrophy is inherited in an X-linked recessive pattern. Males have only one copy of the X chromosome from their mother and one copy of the Y chromosome from their father. If their X chromosome has a DMD gene mutation, they will have Duchenne muscular dystrophy.',
'The dream suggests captivity and it refers to your fear of punishment. Another interpretation of this dream refers to a need to do what you feel is right in waking life. Being in jail suggests that your feelings may be trapped by a limited mind and body. ... Jail also suggests repressed feelings.',
"An automatic transmission will downshift for you when you drive uphill. However, for moderately steep slopes, it's wise to shift to the gear range marked D2, 2, or L to ascend and descend the hill. For steep slopes that you can't ascend at a speed faster than 10 mph (about 15 kph), shift to D1 or 1.",
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 768] [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.9205, 0.1686, 0.1144]])
Evaluation
Metrics
Information Retrieval
- Dataset:
gooaq-dev - Evaluated with
InformationRetrievalEvaluator
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7112 |
| cosine_accuracy@3 | 0.8499 |
| cosine_accuracy@5 | 0.8903 |
| cosine_accuracy@10 | 0.9296 |
| cosine_precision@1 | 0.7112 |
| cosine_precision@3 | 0.2833 |
| cosine_precision@5 | 0.1781 |
| cosine_precision@10 | 0.093 |
| cosine_recall@1 | 0.7112 |
| cosine_recall@3 | 0.8499 |
| cosine_recall@5 | 0.8903 |
| cosine_recall@10 | 0.9296 |
| cosine_ndcg@10 | 0.8226 |
| cosine_mrr@10 | 0.7881 |
| cosine_map@100 | 0.7907 |
Training Details
Training Dataset
gooaq
- Dataset: gooaq at b089f72
- Size: 90,000 training samples
- Columns:
questionandanswer - Approximate statistics based on the first 1000 samples:
question answer type string string details - min: 8 tokens
- mean: 11.83 tokens
- max: 20 tokens
- min: 15 tokens
- mean: 60.45 tokens
- max: 180 tokens
- Samples:
question answer how long does halifax take to transfer mortgage funds?Bear in mind that the speed of application will vary depending on your own personal circumstances and the lender's present day-to-day performance. In some cases, applications can be approved by the lender within 24 hours, while some can take weeks or even months.can you get a false pregnancy test?In very rare cases, you can have a false-positive result. This means you're not pregnant but the test says you are. You could have a false-positive result if you have blood or protein in your pee. Certain drugs, such as tranquilizers, anticonvulsants, hypnotics, and fertility drugs, could cause false-positive results.are ahead of its time?Definition of ahead of one's/its time : too advanced or modern to be understood or appreciated during the time when one lives or works As a director, he was ahead of his time. - Loss:
CachedMultipleNegativesBidirectionalRankingLosswith these parameters:{ "temperature": 0.01, "similarity_fct": "cos_sim", "mini_batch_size": 64, "gather_across_devices": false }
Evaluation Dataset
gooaq
- Dataset: gooaq at b089f72
- Size: 10,000 evaluation samples
- Columns:
questionandanswer - Approximate statistics based on the first 1000 samples:
question answer type string string details - min: 8 tokens
- mean: 11.93 tokens
- max: 25 tokens
- min: 14 tokens
- mean: 60.84 tokens
- max: 127 tokens
- Samples:
question answer should you take ibuprofen with high blood pressure?In general, people with high blood pressure should use acetaminophen or possibly aspirin for over-the-counter pain relief. Unless your health care provider has said it's OK, you should not use ibuprofen, ketoprofen, or naproxen sodium. If aspirin or acetaminophen doesn't help with your pain, call your doctor.how old do you have to be to work in sc?The general minimum age of employment for South Carolina youth is 14, although the state allows younger children who are performers to work in show business. If their families are agricultural workers, children younger than age 14 may also participate in farm labor.how to write a topic proposal for a research paper?['Write down the main topic of your paper. ... ', 'Write two or three short sentences under the main topic that explain why you chose that topic. ... ', 'Write a thesis sentence that states the angle and purpose of your research paper. ... ', 'List the items you will cover in the body of the paper that support your thesis statement.'] - Loss:
CachedMultipleNegativesBidirectionalRankingLosswith these parameters:{ "temperature": 0.01, "similarity_fct": "cos_sim", "mini_batch_size": 64, "gather_across_devices": false }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsper_device_train_batch_size: 1024per_device_eval_batch_size: 1024learning_rate: 8e-05num_train_epochs: 1warmup_ratio: 0.1bf16: Truebatch_sampler: no_duplicates
All Hyperparameters
Click to expandoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 1024per_device_eval_batch_size: 1024per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 8e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_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: Nonejit_mode_eval: Falsebf16: Truefp16: 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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_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: noneftune_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: Trueprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
Training Logs
| Epoch | Step | Training Loss | Validation Loss | gooaq-dev_cosine_ndcg@10 |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.2155 |
| 0.0114 | 1 | 11.1628 | - | - |
| 0.0568 | 5 | 8.8119 | - | - |
| 0.1023 | 9 | - | 0.7685 | 0.6378 |
| 0.1136 | 10 | 3.7605 | - | - |
| 0.1705 | 15 | -0.9796 | - | - |
| 0.2045 | 18 | - | -12.1621 | 0.7460 |
| 0.2273 | 20 | -5.6782 | - | - |
| 0.2841 | 25 | -9.8067 | - | - |
| 0.3068 | 27 | - | -18.0439 | 0.7799 |
| 0.3409 | 30 | -12.3723 | - | - |
| 0.3977 | 35 | -13.438 | - | - |
| 0.4091 | 36 | - | -20.6125 | 0.7982 |
| 0.4545 | 40 | -15.1852 | - | - |
| 0.5114 | 45 | -15.8425 | -22.4894 | 0.8090 |
| 0.5682 | 50 | -16.0841 | - | - |
| 0.6136 | 54 | - | -23.7313 | 0.8134 |
| 0.625 | 55 | -16.742 | - | - |
| 0.6818 | 60 | -17.4537 | - | - |
| 0.7159 | 63 | - | -24.3035 | 0.8178 |
| 0.7386 | 65 | -18.1724 | - | - |
| 0.7955 | 70 | -17.9468 | - | - |
| 0.8182 | 72 | - | -25.1142 | 0.8174 |
| 0.8523 | 75 | -18.1677 | - | - |
| 0.9091 | 80 | -18.3673 | - | - |
| 0.9205 | 81 | - | -25.3134 | 0.8247 |
| 0.9659 | 85 | -18.4905 | - | - |
| -1 | -1 | - | - | 0.8226 |
Environmental Impact
Carbon emissions were measured using CodeCarbon.
- Energy Consumed: 0.088 kWh
- Carbon Emitted: 0.023 kg of CO2
- Hours Used: 0.244 hours
Training Hardware
- On Cloud: No
- GPU Model: 1 x NVIDIA GeForce RTX 3090
- CPU Model: 13th Gen Intel(R) Core(TM) i7-13700K
- RAM Size: 31.78 GB
Framework Versions
- Python: 3.11.14
- Sentence Transformers: 5.3.0.dev0
- Transformers: 4.57.3
- PyTorch: 2.9.1+cu130
- Accelerate: 1.12.0
- Datasets: 4.4.2
- Tokenizers: 0.22.2
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",
}