tomaarsen's picture
tomaarsen HF staff
Update README.md
94273b1 verified
---
tags:
- sentence-transformers
- cross-encoder
- text-classification
- generated_from_trainer
- dataset_size:1990000
- loss:MSELoss
base_model: microsoft/MiniLM-L12-H384-uncased
datasets:
- tomaarsen/ms-marco-shuffled
pipeline_tag: text-classification
library_name: sentence-transformers
metrics:
- map
- mrr@10
- ndcg@10
model-index:
- name: CrossEncoder based on microsoft/MiniLM-L12-H384-uncased
results: []
---
# CrossEncoder based on microsoft/MiniLM-L12-H384-uncased
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [microsoft/MiniLM-L12-H384-uncased](https://huggingface.co/microsoft/MiniLM-L12-H384-uncased) on the [ms-marco-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled) dataset using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
## Model Details
### Model Description
- **Model Type:** Cross Encoder
- **Base model:** [microsoft/MiniLM-L12-H384-uncased](https://huggingface.co/microsoft/MiniLM-L12-H384-uncased) <!-- at revision 44acabbec0ef496f6dbc93adadea57f376b7c0ec -->
- **Maximum Sequence Length:** 512 tokens
- **Number of Output Labels:** 1 label
- **Training Dataset:**
- [ms-marco-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled)
<!-- - **Language:** Unknown -->
<!-- - **License:** Unknown -->
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
- **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder)
## Usage
### Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
```bash
pip install -U sentence-transformers
```
Then you can load this model and run inference.
```python
from sentence_transformers import CrossEncoder
# Download from the 🤗 Hub
model = CrossEncoder("tomaarsen/reranker-modernbert-base-msmarco-mse")
# Get scores for pairs of texts
pairs = [
['what is a electrophoresis apparatus', 'Gel electrophoresis is a method for separation and analysis of macromolecules (DNA, RNA and proteins) and their fragments, based on their size and charge.el electrophoresis of large DNA or RNA is usually done by agarose gel electrophoresis. See the Chain termination method page for an example of a polyacrylamide DNA sequencing gel. Characterization through ligand interaction of nucleic acids or fragments may be performed by mobility shift affinity electrophoresis.'],
['does creatine elevate creatinine levels', "Creatinine is produced from creatine, a molecule of major importance for energy production in muscles. Approximately 2% of the body's creatine is converted to creatinine every day. Creatinine is transported through the bloodstream to the kidneys."],
['how to get rid of caffeine in the body', 'In addition to quickly curing caffeine withdrawal headaches, caffeine may help cure regular headaches and even migraines. Some studies have shown that small doses of caffeine taken in conjunction with pain killers may help the body absorb the medication more quickly and cure the headache in a shorter period of time.'],
['define splanchnopleure', 'delineated, represented, delineate(verb) represented accurately or precisely. define, delineate(verb) show the form or outline of. The tree was clearly defined by the light; The camera could define the smallest object. specify, define, delineate, delimit, delimitate(verb) determine the essential quality of.'],
['how many calories does a glass of wine', 'A large glass of wine contains as many calories as an ice cream. We often drink wine with a meal. But did you know that a large glass of wine (250ml) with 13% ABV can add 228 calories to your dinner? Thatâ\x80\x99s similar to an ice cream or two fish fingers. A standard glass of red or white wine (175ml) with 13% ABV could also contain up to 160 calories, similar to a slice of Madeira cake.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'what is a electrophoresis apparatus',
[
'Gel electrophoresis is a method for separation and analysis of macromolecules (DNA, RNA and proteins) and their fragments, based on their size and charge.el electrophoresis of large DNA or RNA is usually done by agarose gel electrophoresis. See the Chain termination method page for an example of a polyacrylamide DNA sequencing gel. Characterization through ligand interaction of nucleic acids or fragments may be performed by mobility shift affinity electrophoresis.',
"Creatinine is produced from creatine, a molecule of major importance for energy production in muscles. Approximately 2% of the body's creatine is converted to creatinine every day. Creatinine is transported through the bloodstream to the kidneys.",
'In addition to quickly curing caffeine withdrawal headaches, caffeine may help cure regular headaches and even migraines. Some studies have shown that small doses of caffeine taken in conjunction with pain killers may help the body absorb the medication more quickly and cure the headache in a shorter period of time.',
'delineated, represented, delineate(verb) represented accurately or precisely. define, delineate(verb) show the form or outline of. The tree was clearly defined by the light; The camera could define the smallest object. specify, define, delineate, delimit, delimitate(verb) determine the essential quality of.',
'A large glass of wine contains as many calories as an ice cream. We often drink wine with a meal. But did you know that a large glass of wine (250ml) with 13% ABV can add 228 calories to your dinner? Thatâ\x80\x99s similar to an ice cream or two fish fingers. A standard glass of red or white wine (175ml) with 13% ABV could also contain up to 160 calories, similar to a slice of Madeira cake.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
<!--
### Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details>
-->
<!--
### Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details>
-->
<!--
### Out-of-Scope Use
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->
## Evaluation
### Metrics
#### Cross Encoder Reranking
* Datasets: `NanoMSMARCO`, `NanoNFCorpus` and `NanoNQ`
* Evaluated with [<code>CERerankingEvaluator</code>](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CERerankingEvaluator)
| Metric | NanoMSMARCO | NanoNFCorpus | NanoNQ |
|:------------|:---------------------|:---------------------|:---------------------|
| map | 0.5979 (+0.1083) | 0.3464 (+0.0760) | 0.6886 (+0.2679) |
| mrr@10 | 0.5893 (+0.1118) | 0.6264 (+0.1266) | 0.6962 (+0.2695) |
| **ndcg@10** | **0.6585 (+0.1181)** | **0.3864 (+0.0613)** | **0.7366 (+0.2359)** |
#### Cross Encoder Nano BEIR
* Dataset: `NanoBEIR_mean`
* Evaluated with [<code>CENanoBEIREvaluator</code>](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CENanoBEIREvaluator)
| Metric | Value |
|:------------|:---------------------|
| map | 0.5443 (+0.1507) |
| mrr@10 | 0.6373 (+0.1693) |
| **ndcg@10** | **0.5938 (+0.1385)** |
<!--
## Bias, Risks and Limitations
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
-->
<!--
### Recommendations
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
-->
## Training Details
### Training Dataset
#### ms-marco-shuffled
* Dataset: [ms-marco-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled) at [0e80192](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled/tree/0e8019214fbbb17845d8fa1e4594882944716633)
* Size: 1,990,000 training samples
* Columns: <code>score</code>, <code>query</code>, and <code>passage</code>
* Approximate statistics based on the first 1000 samples:
| | score | query | passage |
|:--------|:-------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|
| type | float | string | string |
| details | <ul><li>min: -11.8</li><li>mean: 0.75</li><li>max: 11.16</li></ul> | <ul><li>min: 9 characters</li><li>mean: 33.33 characters</li><li>max: 123 characters</li></ul> | <ul><li>min: 53 characters</li><li>mean: 348.8 characters</li><li>max: 1016 characters</li></ul> |
* Samples:
| score | query | passage |
|:--------------------------------|:----------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <code>6.732539335886638</code> | <code>what is shielding in welding</code> | <code>A benefit in using a shielding gas when welding is that there is no slag left on the weld that requires chipping and cleaning like that which is found on an arc weld. When a new wire welding machine is purchased, it does not come with a shielding gas tank. This must be purchased or rented from a gas supplier. Most welding supply stores also sell welding gasses and will be able to assist the buyer in a tank purchase.</code> |
| <code>-5.769245758652687</code> | <code>what degree do you need for physical therapy</code> | <code>E. Medicaid covers occupational therapy, physical therapy and speech therapy services when provided to eligible Medicaid beneficiaries under age 21 in the Child Health Services (EPSDT) Program by qualified occupational, physical or speech therapy providers.</code> |
| <code>9.033631960550943</code> | <code>cascade effect definition</code> | <code>In medicine, cascade effect may also refer to a chain of events initiated by an unnecessary test, an unexpected result, or patient or physician anxiety, which results in ill-advised tests or treatments that may cause harm to patients as the results are pursued.</code> |
* Loss: [<code>MSELoss</code>](https://sbert.net/docs/package_reference/cross_encoder/losses.html#mseloss)
### Evaluation Dataset
#### ms-marco-shuffled
* Dataset: [ms-marco-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled) at [0e80192](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled/tree/0e8019214fbbb17845d8fa1e4594882944716633)
* Size: 10,000 evaluation samples
* Columns: <code>score</code>, <code>query</code>, and <code>passage</code>
* Approximate statistics based on the first 1000 samples:
| | score | query | passage |
|:--------|:--------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|
| type | float | string | string |
| details | <ul><li>min: -11.86</li><li>mean: 0.72</li><li>max: 11.07</li></ul> | <ul><li>min: 10 characters</li><li>mean: 33.83 characters</li><li>max: 101 characters</li></ul> | <ul><li>min: 50 characters</li><li>mean: 343.73 characters</li><li>max: 929 characters</li></ul> |
* Samples:
| score | query | passage |
|:---------------------------------|:-----------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <code>4.691008905569713</code> | <code>what is a electrophoresis apparatus</code> | <code>Gel electrophoresis is a method for separation and analysis of macromolecules (DNA, RNA and proteins) and their fragments, based on their size and charge.el electrophoresis of large DNA or RNA is usually done by agarose gel electrophoresis. See the Chain termination method page for an example of a polyacrylamide DNA sequencing gel. Characterization through ligand interaction of nucleic acids or fragments may be performed by mobility shift affinity electrophoresis.</code> |
| <code>0.7860534191131592</code> | <code>does creatine elevate creatinine levels</code> | <code>Creatinine is produced from creatine, a molecule of major importance for energy production in muscles. Approximately 2% of the body's creatine is converted to creatinine every day. Creatinine is transported through the bloodstream to the kidneys.</code> |
| <code>-1.2669222354888916</code> | <code>how to get rid of caffeine in the body</code> | <code>In addition to quickly curing caffeine withdrawal headaches, caffeine may help cure regular headaches and even migraines. Some studies have shown that small doses of caffeine taken in conjunction with pain killers may help the body absorb the medication more quickly and cure the headache in a shorter period of time.</code> |
* Loss: [<code>MSELoss</code>](https://sbert.net/docs/package_reference/cross_encoder/losses.html#mseloss)
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 64
- `per_device_eval_batch_size`: 64
- `learning_rate`: 8e-06
- `num_train_epochs`: 1
- `warmup_ratio`: 0.1
- `seed`: 12
- `bf16`: True
- `dataloader_num_workers`: 4
- `load_best_model_at_end`: True
#### All Hyperparameters
<details><summary>Click to expand</summary>
- `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`: 8e-06
- `weight_decay`: 0.0
- `adam_beta1`: 0.9
- `adam_beta2`: 0.999
- `adam_epsilon`: 1e-08
- `max_grad_norm`: 1.0
- `num_train_epochs`: 1
- `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`: 12
- `data_seed`: None
- `jit_mode_eval`: False
- `use_ipex`: False
- `bf16`: True
- `fp16`: False
- `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`: False
- `dataloader_num_workers`: 4
- `dataloader_prefetch_factor`: None
- `past_index`: -1
- `disable_tqdm`: False
- `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}
- `deepspeed`: None
- `label_smoothing_factor`: 0.0
- `optim`: adamw_torch
- `optim_args`: None
- `adafactor`: False
- `group_by_length`: False
- `length_column_name`: length
- `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
- `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
- `dispatch_batches`: None
- `split_batches`: None
- `include_tokens_per_second`: False
- `include_num_input_tokens_seen`: False
- `neftune_noise_alpha`: None
- `optim_target_modules`: None
- `batch_eval_metrics`: False
- `eval_on_start`: False
- `use_liger_kernel`: False
- `eval_use_gather_object`: False
- `average_tokens_across_devices`: False
- `prompts`: None
- `batch_sampler`: batch_sampler
- `multi_dataset_batch_sampler`: proportional
</details>
### Training Logs
| Epoch | Step | Training Loss | Validation Loss | NanoMSMARCO_ndcg@10 | NanoNFCorpus_ndcg@10 | NanoNQ_ndcg@10 | NanoBEIR_mean_ndcg@10 |
|:----------:|:---------:|:-------------:|:---------------:|:--------------------:|:--------------------:|:--------------------:|:---------------------:|
| -1 | -1 | - | - | 0.0219 (-0.5185) | 0.2538 (-0.0712) | 0.0498 (-0.4509) | 0.1085 (-0.3469) |
| 0.0000 | 1 | 64.054 | - | - | - | - | - |
| 0.0322 | 1000 | 55.8586 | - | - | - | - | - |
| 0.0643 | 2000 | 31.6183 | - | - | - | - | - |
| 0.0965 | 3000 | 13.1762 | - | - | - | - | - |
| 0.1286 | 4000 | 6.1773 | - | - | - | - | - |
| 0.1608 | 5000 | 4.2945 | 3.4889 | 0.6180 (+0.0776) | 0.3893 (+0.0643) | 0.7144 (+0.2137) | 0.5739 (+0.1185) |
| 0.1930 | 6000 | 3.6451 | - | - | - | - | - |
| 0.2251 | 7000 | 3.3041 | - | - | - | - | - |
| 0.2573 | 8000 | 2.9813 | - | - | - | - | - |
| 0.2894 | 9000 | 2.8473 | - | - | - | - | - |
| 0.3216 | 10000 | 2.6852 | 2.6960 | 0.6124 (+0.0720) | 0.3992 (+0.0742) | 0.7315 (+0.2309) | 0.5811 (+0.1257) |
| 0.3538 | 11000 | 2.6128 | - | - | - | - | - |
| 0.3859 | 12000 | 2.5252 | - | - | - | - | - |
| 0.4181 | 13000 | 2.461 | - | - | - | - | - |
| 0.4502 | 14000 | 2.3625 | - | - | - | - | - |
| 0.4824 | 15000 | 2.2746 | 2.0279 | 0.6397 (+0.0993) | 0.3963 (+0.0713) | 0.7369 (+0.2363) | 0.5910 (+0.1356) |
| 0.5146 | 16000 | 2.2551 | - | - | - | - | - |
| 0.5467 | 17000 | 2.2193 | - | - | - | - | - |
| 0.5789 | 18000 | 2.2099 | - | - | - | - | - |
| 0.6111 | 19000 | 2.1277 | - | - | - | - | - |
| 0.6432 | 20000 | 2.0969 | 1.9564 | 0.6468 (+0.1063) | 0.3936 (+0.0685) | 0.7391 (+0.2385) | 0.5932 (+0.1378) |
| 0.6754 | 21000 | 2.0624 | - | - | - | - | - |
| 0.7075 | 22000 | 2.0565 | - | - | - | - | - |
| 0.7397 | 23000 | 2.0226 | - | - | - | - | - |
| 0.7719 | 24000 | 1.9583 | - | - | - | - | - |
| 0.8040 | 25000 | 2.0048 | 1.8239 | 0.6575 (+0.1171) | 0.3884 (+0.0634) | 0.7339 (+0.2333) | 0.5933 (+0.1379) |
| 0.8362 | 26000 | 1.9861 | - | - | - | - | - |
| 0.8683 | 27000 | 1.9675 | - | - | - | - | - |
| 0.9005 | 28000 | 1.9531 | - | - | - | - | - |
| 0.9327 | 29000 | 1.9139 | - | - | - | - | - |
| **0.9648** | **30000** | **1.9224** | **1.7848** | **0.6585 (+0.1181)** | **0.3864 (+0.0613)** | **0.7366 (+0.2359)** | **0.5938 (+0.1385)** |
| 0.9970 | 31000 | 1.9059 | - | - | - | - | - |
| -1 | -1 | - | - | 0.6585 (+0.1181) | 0.3864 (+0.0613) | 0.7366 (+0.2359) | 0.5938 (+0.1385) |
* The bold row denotes the saved checkpoint.
### Framework Versions
- Python: 3.11.10
- Sentence Transformers: 3.5.0.dev0
- Transformers: 4.49.0.dev0
- PyTorch: 2.6.0.dev20241112+cu121
- Accelerate: 1.2.0
- Datasets: 3.2.0
- Tokenizers: 0.21.0
## Citation
### BibTeX
#### Sentence Transformers
```bibtex
@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",
}
```
<!--
## Glossary
*Clearly define terms in order to be accessible across audiences.*
-->
<!--
## Model Card Authors
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->
<!--
## Model Card Contact
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->