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

This is a Cross Encoder model finetuned from microsoft/MiniLM-L12-H384-uncased 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("sentence_transformers_model_id")
# Get scores for pairs of texts
pairs = [
    ['how much should i pay for breast implants', 'Implant Fees. The cost of buying the implants themselves will influence the overall costs of the procedure. Silicone implants cost between $1,800 and $2,500 though this may go up to slightly over $3,000.Saline implants will cost anywhere between $1,200 and $1,600.The cost of implants varies due to size and manufacturer though there is usually not much of a difference.Anesthesia Fees. There are various options for your anesthesia and this will have a direct impact on the fee you will be charged.otal Costs of Brest Implants. With all the above factors taken into consideration, the total cost of breast implants generally are somewhere in the range of $5,000 and $15,000. However, it is best for your safety and peace of mind to avoid the lowest-charging surgeons and the ones charging very high fees.'],
    ['are merrell shoes lifetime warranty', "Best Answer: Regular shoes. If your horse doesn't have bad feet, don't put shoes on him. Shoes actually weaken the hooves due to a lack of circulation and the nail holes (they just make the hooves stronger while the shoes are on, once you take them off the hooves are weaker than they were at first).f your horse doesn't have bad feet, don't put shoes on him. Shoes actually weaken the hooves due to a lack of circulation and the nail holes (they just make the hooves stronger while the shoes are on, once you take them off the hooves are weaker than they were at first)."],
    ['what is the largest capacity dvd disc available', 'Insert a disc that contains files into the drive that is having the problem. Use a type of disc that is not being recognized in the drive. Good discs to use are game or software discs that were purchased from a store. Do not use music CDs. If the DVD drive can read CDs but not DVDs, insert a DVD movie.nsert a software CD (like a game or business software) into the CD/DVD drive and note what happens. If an AutoPlay window opens, the drive is able to read the disc. The data stored on the disc may still be bad, but an AutoPlay window proves that the drive can read data on the disc.'],
    ['weather in dead sea', "The higher above sea level you go, (for example, the tops of mountains,) the more separated and spaced out the molecules become, which causes cold weather. This is the ACCURATE answer to how elevation affects temperature. learned the answer to this in science this year, so don't worry, it is accurate: The higher above sea level/elevation you are, the colder the temperature becomes. The reas â\x80¦ on for this is because there are air molecules in the air bump closer together when you are lower above sea level-that creates warm weather."],
    ['who should not contribute to roth ira', 'You can contribute to a Roth at any age, even past retirement age, as long as youâ\x80\x99re still earning taxable income. A working spouse can also contribute to a Roth IRA on behalf of a nonworking spouse. For a 401(k), the 2014 contribution limit is $17,500, unless youâ\x80\x99re 50 or older, in which case the limit is $23,000.hen you can strategize your distributions to minimize your tax liability. You can also contribute to a traditional IRA even if you participate in an employer-sponsored retirement plan, but in some cases not all of your traditional IRA contributions will be tax deductible.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'how much should i pay for breast implants',
    [
        'Implant Fees. The cost of buying the implants themselves will influence the overall costs of the procedure. Silicone implants cost between $1,800 and $2,500 though this may go up to slightly over $3,000.Saline implants will cost anywhere between $1,200 and $1,600.The cost of implants varies due to size and manufacturer though there is usually not much of a difference.Anesthesia Fees. There are various options for your anesthesia and this will have a direct impact on the fee you will be charged.otal Costs of Brest Implants. With all the above factors taken into consideration, the total cost of breast implants generally are somewhere in the range of $5,000 and $15,000. However, it is best for your safety and peace of mind to avoid the lowest-charging surgeons and the ones charging very high fees.',
        "Best Answer: Regular shoes. If your horse doesn't have bad feet, don't put shoes on him. Shoes actually weaken the hooves due to a lack of circulation and the nail holes (they just make the hooves stronger while the shoes are on, once you take them off the hooves are weaker than they were at first).f your horse doesn't have bad feet, don't put shoes on him. Shoes actually weaken the hooves due to a lack of circulation and the nail holes (they just make the hooves stronger while the shoes are on, once you take them off the hooves are weaker than they were at first).",
        'Insert a disc that contains files into the drive that is having the problem. Use a type of disc that is not being recognized in the drive. Good discs to use are game or software discs that were purchased from a store. Do not use music CDs. If the DVD drive can read CDs but not DVDs, insert a DVD movie.nsert a software CD (like a game or business software) into the CD/DVD drive and note what happens. If an AutoPlay window opens, the drive is able to read the disc. The data stored on the disc may still be bad, but an AutoPlay window proves that the drive can read data on the disc.',
        "The higher above sea level you go, (for example, the tops of mountains,) the more separated and spaced out the molecules become, which causes cold weather. This is the ACCURATE answer to how elevation affects temperature. learned the answer to this in science this year, so don't worry, it is accurate: The higher above sea level/elevation you are, the colder the temperature becomes. The reas â\x80¦ on for this is because there are air molecules in the air bump closer together when you are lower above sea level-that creates warm weather.",
        'You can contribute to a Roth at any age, even past retirement age, as long as youâ\x80\x99re still earning taxable income. A working spouse can also contribute to a Roth IRA on behalf of a nonworking spouse. For a 401(k), the 2014 contribution limit is $17,500, unless youâ\x80\x99re 50 or older, in which case the limit is $23,000.hen you can strategize your distributions to minimize your tax liability. You can also contribute to a traditional IRA even if you participate in an employer-sponsored retirement plan, but in some cases not all of your traditional IRA contributions will be tax deductible.',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Evaluation

Metrics

Cross Encoder Reranking

Metric train-eval NanoMSMARCO NanoNFCorpus NanoNQ
map 0.6511 0.5909 (+0.1013) 0.3364 (+0.0660) 0.6673 (+0.2466)
mrr@10 0.6494 0.5862 (+0.1087) 0.5282 (+0.0284) 0.6862 (+0.2595)
ndcg@10 0.7082 0.6658 (+0.1254) 0.3656 (+0.0405) 0.7191 (+0.2185)

Cross Encoder Nano BEIR

Metric Value
map 0.5315 (+0.1380)
mrr@10 0.6002 (+0.1322)
ndcg@10 0.5835 (+0.1281)

Training Details

Training Dataset

Unnamed Dataset

  • Size: 2,000,000 training samples
  • Columns: sentence_0, sentence_1, and label
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1 label
    type string string int
    details
    • min: 7 characters
    • mean: 34.08 characters
    • max: 118 characters
    • min: 83 characters
    • mean: 342.99 characters
    • max: 1018 characters
    • 0: ~81.70%
    • 1: ~18.30%
  • Samples:
    sentence_0 sentence_1 label
    how much should i pay for breast implants Implant Fees. The cost of buying the implants themselves will influence the overall costs of the procedure. Silicone implants cost between $1,800 and $2,500 though this may go up to slightly over $3,000.Saline implants will cost anywhere between $1,200 and $1,600.The cost of implants varies due to size and manufacturer though there is usually not much of a difference.Anesthesia Fees. There are various options for your anesthesia and this will have a direct impact on the fee you will be charged.otal Costs of Brest Implants. With all the above factors taken into consideration, the total cost of breast implants generally are somewhere in the range of $5,000 and $15,000. However, it is best for your safety and peace of mind to avoid the lowest-charging surgeons and the ones charging very high fees. 1
    are merrell shoes lifetime warranty Best Answer: Regular shoes. If your horse doesn't have bad feet, don't put shoes on him. Shoes actually weaken the hooves due to a lack of circulation and the nail holes (they just make the hooves stronger while the shoes are on, once you take them off the hooves are weaker than they were at first).f your horse doesn't have bad feet, don't put shoes on him. Shoes actually weaken the hooves due to a lack of circulation and the nail holes (they just make the hooves stronger while the shoes are on, once you take them off the hooves are weaker than they were at first). 0
    what is the largest capacity dvd disc available Insert a disc that contains files into the drive that is having the problem. Use a type of disc that is not being recognized in the drive. Good discs to use are game or software discs that were purchased from a store. Do not use music CDs. If the DVD drive can read CDs but not DVDs, insert a DVD movie.nsert a software CD (like a game or business software) into the CD/DVD drive and note what happens. If an AutoPlay window opens, the drive is able to read the disc. The data stored on the disc may still be bad, but an AutoPlay window proves that the drive can read data on the disc. 0
  • Loss: BinaryCrossEntropyLoss

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • num_train_epochs: 1
  • fp16: 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: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • 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
  • use_ipex: 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: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • 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 train-eval_ndcg@10 NanoMSMARCO_ndcg@10 NanoNFCorpus_ndcg@10 NanoNQ_ndcg@10 NanoBEIR_mean_ndcg@10
-1 -1 - 0.0312 0.0280 (-0.5124) 0.2260 (-0.0991) 0.0315 (-0.4691) 0.0952 (-0.3602)
0.016 500 0.6271 - - - - -
0.032 1000 0.4867 - - - - -
0.048 1500 0.3551 - - - - -
0.064 2000 0.2768 - - - - -
0.08 2500 0.2455 - - - - -
0.096 3000 0.2186 - - - - -
0.112 3500 0.2151 - - - - -
0.128 4000 0.2002 - - - - -
0.144 4500 0.1973 - - - - -
0.16 5000 0.1928 0.6389 0.6178 (+0.0774) 0.3541 (+0.0291) 0.6869 (+0.1862) 0.5529 (+0.0976)
0.176 5500 0.1841 - - - - -
0.192 6000 0.1835 - - - - -
0.208 6500 0.1828 - - - - -
0.224 7000 0.1777 - - - - -
0.24 7500 0.1674 - - - - -
0.256 8000 0.1655 - - - - -
0.272 8500 0.1706 - - - - -
0.288 9000 0.1629 - - - - -
0.304 9500 0.1641 - - - - -
0.32 10000 0.1631 0.6859 0.6220 (+0.0815) 0.3849 (+0.0598) 0.6951 (+0.1944) 0.5673 (+0.1119)
0.336 10500 0.1616 - - - - -
0.352 11000 0.1575 - - - - -
0.368 11500 0.1565 - - - - -
0.384 12000 0.1523 - - - - -
0.4 12500 0.1628 - - - - -
0.416 13000 0.1569 - - - - -
0.432 13500 0.1581 - - - - -
0.448 14000 0.1527 - - - - -
0.464 14500 0.1484 - - - - -
0.48 15000 0.1531 0.6939 0.6455 (+0.1051) 0.3663 (+0.0413) 0.6977 (+0.1970) 0.5698 (+0.1145)
0.496 15500 0.1482 - - - - -
0.512 16000 0.1523 - - - - -
0.528 16500 0.1532 - - - - -
0.544 17000 0.1513 - - - - -
0.56 17500 0.1486 - - - - -
0.576 18000 0.1438 - - - - -
0.592 18500 0.1496 - - - - -
0.608 19000 0.1455 - - - - -
0.624 19500 0.1474 - - - - -
0.64 20000 0.1484 0.7025 0.6423 (+0.1019) 0.3637 (+0.0387) 0.7162 (+0.2156) 0.5741 (+0.1187)
0.656 20500 0.1436 - - - - -
0.672 21000 0.1427 - - - - -
0.688 21500 0.1463 - - - - -
0.704 22000 0.1475 - - - - -
0.72 22500 0.1446 - - - - -
0.736 23000 0.1424 - - - - -
0.752 23500 0.1397 - - - - -
0.768 24000 0.1405 - - - - -
0.784 24500 0.1405 - - - - -
0.8 25000 0.1397 0.7014 0.6492 (+0.1088) 0.3672 (+0.0422) 0.7229 (+0.2222) 0.5798 (+0.1244)
0.816 25500 0.1378 - - - - -
0.832 26000 0.1409 - - - - -
0.848 26500 0.1368 - - - - -
0.864 27000 0.1389 - - - - -
0.88 27500 0.1354 - - - - -
0.896 28000 0.1412 - - - - -
0.912 28500 0.138 - - - - -
0.928 29000 0.1369 - - - - -
0.944 29500 0.1321 - - - - -
0.96 30000 0.137 0.7150 0.6576 (+0.1172) 0.3655 (+0.0405) 0.7211 (+0.2204) 0.5814 (+0.1260)
0.976 30500 0.1342 - - - - -
0.992 31000 0.137 - - - - -
1.0 31250 - 0.7082 0.6658 (+0.1254) 0.3656 (+0.0405) 0.7191 (+0.2185) 0.5835 (+0.1281)

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • Energy Consumed: 0.501 kWh
  • Carbon Emitted: 0.195 kg of CO2
  • Hours Used: 1.403 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.6
  • Sentence Transformers: 3.5.0.dev0
  • Transformers: 4.48.3
  • PyTorch: 2.5.0+cu121
  • Accelerate: 1.3.0
  • Datasets: 2.20.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
22
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-msmarco-scratch

Finetuned
(41)
this model

Evaluation results