CrossEncoder based on microsoft/MiniLM-L12-H384-uncased

This is a Cross Encoder model finetuned from microsoft/MiniLM-L12-H384-uncased on the ms-marco-shuffled dataset using the sentence-transformers 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 Sources

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 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': ...}, ...]

Evaluation

Metrics

Cross Encoder Reranking

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

Metric Value
map 0.5443 (+0.1507)
mrr@10 0.6373 (+0.1693)
ndcg@10 0.5938 (+0.1385)

Training Details

Training Dataset

ms-marco-shuffled

  • Dataset: ms-marco-shuffled at 0e80192
  • Size: 1,990,000 training samples
  • Columns: score, query, and passage
  • Approximate statistics based on the first 1000 samples:
    score query passage
    type float string string
    details
    • min: -11.8
    • mean: 0.75
    • max: 11.16
    • min: 9 characters
    • mean: 33.33 characters
    • max: 123 characters
    • min: 53 characters
    • mean: 348.8 characters
    • max: 1016 characters
  • Samples:
    score query passage
    6.732539335886638 what is shielding in welding 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.
    -5.769245758652687 what degree do you need for physical therapy 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.
    9.033631960550943 cascade effect definition 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.
  • Loss: MSELoss

Evaluation Dataset

ms-marco-shuffled

  • Dataset: ms-marco-shuffled at 0e80192
  • Size: 10,000 evaluation samples
  • Columns: score, query, and passage
  • Approximate statistics based on the first 1000 samples:
    score query passage
    type float string string
    details
    • min: -11.86
    • mean: 0.72
    • max: 11.07
    • min: 10 characters
    • mean: 33.83 characters
    • max: 101 characters
    • min: 50 characters
    • mean: 343.73 characters
    • max: 929 characters
  • Samples:
    score query passage
    4.691008905569713 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.
    0.7860534191131592 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.
    -1.2669222354888916 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.
  • Loss: 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

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: 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

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

@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",
}
Downloads last month
16
Safetensors
Model size
33.4M params
Tensor type
F32
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The HF Inference API does not support text-classification models for sentence-transformers library.

Model tree for tomaarsen/reranker-MiniLM-L12-H384-msmarco-mse

Finetuned
(40)
this model

Dataset used to train tomaarsen/reranker-MiniLM-L12-H384-msmarco-mse