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 text reranking and semantic search.

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("Studeni/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-lambdaloss-hard-neg")
# Get scores for pairs of texts
pairs = [
    ['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
    ['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
    ['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (3,)

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'How many calories in an egg',
    [
        'There are on average between 55 and 80 calories in an egg depending on its size.',
        'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
        'Most of the calories in an egg come from the yellow yolk in the center.',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Evaluation

Metrics

Cross Encoder Reranking

  • Datasets: NanoMSMARCO_R100, NanoNFCorpus_R100 and NanoNQ_R100
  • Evaluated with CrossEncoderRerankingEvaluator with these parameters:
    {
        "at_k": 10,
        "always_rerank_positives": true
    }
    
Metric NanoMSMARCO_R100 NanoNFCorpus_R100 NanoNQ_R100
map 0.5356 (+0.0460) 0.3376 (+0.0767) 0.6074 (+0.1878)
mrr@10 0.5286 (+0.0511) 0.5410 (+0.0411) 0.6151 (+0.1884)
ndcg@10 0.6078 (+0.0674) 0.3887 (+0.0636) 0.6535 (+0.1529)

Cross Encoder Nano BEIR

  • Dataset: NanoBEIR_R100_mean
  • Evaluated with CrossEncoderNanoBEIREvaluator with these parameters:
    {
        "dataset_names": [
            "msmarco",
            "nfcorpus",
            "nq"
        ],
        "rerank_k": 100,
        "at_k": 10,
        "always_rerank_positives": true
    }
    
Metric Value
map 0.4935 (+0.1035)
mrr@10 0.5615 (+0.0935)
ndcg@10 0.5500 (+0.0946)

Training Details

Training Dataset

Unnamed Dataset

  • Size: 167,227 training samples
  • Columns: query, docs, and labels
  • Approximate statistics based on the first 1000 samples:
    query docs labels
    type string list list
    details
    • min: 11 characters
    • mean: 33.92 characters
    • max: 97 characters
    • min: 3 elements
    • mean: 6.50 elements
    • max: 10 elements
    • min: 3 elements
    • mean: 6.50 elements
    • max: 10 elements
  • Samples:
    query docs labels
    what is a natural hormone replacement ['Natural Hormone Replacement Therapy (“BHRT”) is common term for the treatment of conditions caused by the effects of hormone deficiencies resulting from menopause. BHRT uses hormones that are identical in their mollecular structure to the hormones produced naturally within the human body.', 'Natural hormone replacement therapy (HRT) is also known as bioidentical hormone therapy. It utilizes estradiol, progesterone or testosterone that are identical in structure to hormones found in a woman’s body.', 'NATURAL HORMONE REPLACEMENT. Natural hormone replacement therapy is a safer, sensible, effective, and free from most of the side effects of synthetic hormones. Every day in the United States 3,500 women enter menopause.', 'Natural or bio-identical hormone replacement therapy in the form of administering estrogen from estrogenic foods or taking progesterone creams has not been clinically tested. Much of the information is anecdotal only.', 'Bioidentical hormone therapy is often called nat... [1, 0, 0, 0, 0, ...]
    what is ras ["Ras is a family of related proteins which is ubiquitously expressed in all cell lineages and organs. All Ras protein family members belong to a class of protein called small GTPase, and are involved in transmitting signals within cells (cellular signal transduction). Ras is the prototypical member of the Ras superfamily of proteins, which are all related in 3D structure and regulate diverse cell behaviours. When Ras is 'switched on' by incoming signals, it subsequently switches on other proteins, which ultimately turn on genes involved in cell growth, differentiation and survival. Ras is a G protein, or a guanosine-nucleotide-binding protein. Specifically, it is a single-subunit small GTPase, which is related in structure to the G α subunit of heterotrimeric G proteins (large GTPases). G proteins function as binary signaling switches with on and off states.", "Ras is the prototypical member of the Ras superfamily of proteins, which are all related in 3D structure and regulate diverse... [1, 0, 0, 0, 0, ...]
    does laila engaged to meera's brother ['Laila Got Engaged To Meera Brother Ahsan. admin April 9, 2015 Laila Got Engaged To Meera Brother Ahsan 2015-04-10T03:50:40+00:00 Latest Happning No Comment. After the late buildup on media about Laila discovering her life accomplice through a network show, Laila has at long last discovered her “To-Be” Ahson. Kaun Bane Ga Laila Ka Dulha was a quite discussed fragment where youthful men contended to be Laila’s husband to be on APlus Morning Show, facilitated by Noor', 'Kaun Bane Ga Laila Ka Dulha was a much talked about segment where young men competed to be Laila’s groom on APlus Morning Show, hosted by Noor. Ahson, surprisingly happens to be the brother of film actress Meera and it has been revealed by sources that Laila and Ahson have been in a relationship for some time.', 'As we all be acquainted with that Laila was in look for of her life colleague. The beat show Kaun Banega “ Laila Ka Dulha ” was aired on A plus. In this part, men from special places take part and compete every ... [1, 0, 0, 0, 0, ...]
  • Loss: LambdaLoss with these parameters:
    {
        "weighing_scheme": "sentence_transformers.cross_encoder.losses.LambdaLoss.NDCGLoss2PPScheme",
        "k": null,
        "sigma": 1.0,
        "eps": 1e-10,
        "reduction": "mean",
        "reduction_log": "binary",
        "activation_fct": "torch.nn.modules.linear.Identity",
        "mini_batch_size": 16
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 1,000 evaluation samples
  • Columns: query, docs, and labels
  • Approximate statistics based on the first 1000 samples:
    query docs labels
    type string list list
    details
    • min: 11 characters
    • mean: 34.41 characters
    • max: 102 characters
    • min: 3 elements
    • mean: 6.50 elements
    • max: 10 elements
    • min: 3 elements
    • mean: 6.50 elements
    • max: 10 elements
  • Samples:
    query docs labels
    what is the medicine called for tonsillitis ['Tonsillitis is usually caused by a virus and does not require prescription medicine. For information on over-the-counter pain medicine and other self-care options, see Home Treatment. An antibiotic, usually amoxicillin or penicillin, is used to treat tonsillitis caused by strep bacteria. Although tonsillitis caused by strep bacteria usually will go away on its own, antibiotics are used to prevent the complications, such as rheumatic fever, that can result from untreated strep throat. ', 'You have two tonsils, one on either side at the back of the mouth. The picture below shows large non-infected tonsils (no redness or pus). Tonsillitis is an infection of the tonsils. A sore throat is the most common of all tonsillitis symptoms. In addition, you may also have a cough, high temperature (fever), headache, feel sick, feel tired, find swallowing painful, and have swollen neck glands. ', 'Tonsillitis (/ˌtɒnsɪˈlaɪtɪs/ TON-si-LEYE-tis) is inflammation of the tonsils most commonly caused by v... [1, 0, 0, 0, 0, ...]
    is candida contagious ['Candida Related Complex is not a contagious condition. However the genital yeast can be contagious for some. east does not become a problem for us just because someone else who is having a problem keeping their yeast population under control kisses us or makes love to us. It is a disease that I do not see as contagious. ', 'Thrush, whether affecting the mouth or genitals, is not contagious in the way a cold or flu is, but it can still be passed on in some circumstances. The candida yeast occurs naturally in our bodies and, in healthy circumstances, it is harmless. ', 'Thrush, whether affecting the mouth or genitals, is not contagious in the way a cold or flu is, but it can still be passed on in some circumstances. The candida yeast occurs naturally in our bodies and, in healthy circumstances, it is harmless.', 'Candida is a type of yeast (fungus). Small numbers of candida normally live on your skin and do no harm. Sometimes, under certain conditions, they can multiply and cause infec... [1, 0, 0, 0, 0, ...]
    what helps runny nose from allergies ['Coughing also helps clear your airways of mucus produced due to a cold, allergies, or other diseases, such as the flu. Cold and allergies have many similar symptoms, such as coughing, runny nose, and sneezing. If you have asthma, both conditions can also cause wheezing and shortness of breath. However, colds and allergies are different conditions with distinct causes. Allergies:', 'You’ll want a decongestant, like pseudoephedrine or phenylephrine. A decongestant will help reduce nasal tissue swelling. If you’re dealing with allergies or a runny nose, you should look for an antihistamine, like diphenhydramine for nighttime use or non-drowsy fexofenadine. Products containing pseudoephedrine can be found behind your pharmacist’s counter. Rhinitis just means that the mucus membranes inside your nose are inflamed. Your runny nose could be caused by an infection (like a cold or the flu) or by cold weather, allergies, crying, irritating smells, or particles in the air. Before your nose star... [1, 0, 0, 0, 0, ...]
  • Loss: LambdaLoss with these parameters:
    {
        "weighing_scheme": "sentence_transformers.cross_encoder.losses.LambdaLoss.NDCGLoss2PPScheme",
        "k": null,
        "sigma": 1.0,
        "eps": 1e-10,
        "reduction": "mean",
        "reduction_log": "binary",
        "activation_fct": "torch.nn.modules.linear.Identity",
        "mini_batch_size": 16
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • learning_rate: 2e-05
  • num_train_epochs: 1
  • warmup_ratio: 0.1
  • seed: 12
  • bf16: 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: 16
  • per_device_eval_batch_size: 16
  • 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: 2e-05
  • 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: 0
  • 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_R100_ndcg@10 NanoNFCorpus_R100_ndcg@10 NanoNQ_R100_ndcg@10 NanoBEIR_R100_mean_ndcg@10
-1 -1 - - 0.0186 (-0.5218) 0.2310 (-0.0940) 0.0644 (-0.4363) 0.1047 (-0.3507)
0.0001 1 1.4366 - - - - -
0.0239 250 1.4817 - - - - -
0.0478 500 1.4032 1.2754 0.4899 (-0.0505) 0.3961 (+0.0711) 0.5825 (+0.0818) 0.4895 (+0.0341)
0.0718 750 1.2631 - - - - -
0.0957 1000 1.2033 1.1534 0.5655 (+0.0251) 0.3973 (+0.0723) 0.6528 (+0.1521) 0.5385 (+0.0832)
0.1196 1250 1.17 - - - - -
0.1435 1500 1.1425 1.0954 0.5939 (+0.0535) 0.4027 (+0.0776) 0.6343 (+0.1337) 0.5436 (+0.0883)
0.1674 1750 1.1379 - - - - -
0.1914 2000 1.1188 1.0821 0.5835 (+0.0431) 0.4002 (+0.0751) 0.6518 (+0.1511) 0.5452 (+0.0898)
0.2153 2250 1.1084 - - - - -
0.2392 2500 1.1015 1.0653 0.6078 (+0.0674) 0.3887 (+0.0636) 0.6535 (+0.1529) 0.5500 (+0.0946)
0.2631 2750 1.0938 - - - - -
0.2870 3000 1.0903 1.0561 0.5836 (+0.0432) 0.3776 (+0.0525) 0.6557 (+0.1550) 0.5389 (+0.0836)
0.3109 3250 1.1009 - - - - -
0.3349 3500 1.0638 1.0453 0.5974 (+0.0570) 0.3795 (+0.0545) 0.6468 (+0.1462) 0.5412 (+0.0859)
0.3588 3750 1.0846 - - - - -
0.3827 4000 1.0796 1.0485 0.5971 (+0.0567) 0.3734 (+0.0484) 0.6326 (+0.1320) 0.5344 (+0.0790)
0.4066 4250 1.076 - - - - -
0.4305 4500 1.0661 1.0383 0.5912 (+0.0507) 0.3748 (+0.0498) 0.6223 (+0.1217) 0.5294 (+0.0741)
0.4545 4750 1.0429 - - - - -
0.4784 5000 1.0498 1.0361 0.5990 (+0.0586) 0.3829 (+0.0579) 0.6378 (+0.1372) 0.5399 (+0.0845)
0.5023 5250 1.0663 - - - - -
0.5262 5500 1.0376 1.0288 0.6045 (+0.0640) 0.3786 (+0.0535) 0.6437 (+0.1431) 0.5423 (+0.0869)
0.5501 5750 1.0347 - - - - -
0.5741 6000 1.0299 1.0317 0.5914 (+0.0510) 0.3797 (+0.0547) 0.6447 (+0.1441) 0.5386 (+0.0833)
0.5980 6250 1.0448 - - - - -
0.6219 6500 1.0443 1.0281 0.5860 (+0.0456) 0.3623 (+0.0372) 0.6291 (+0.1285) 0.5258 (+0.0704)
0.6458 6750 1.0129 - - - - -
0.6697 7000 1.0388 1.0208 0.5857 (+0.0453) 0.3625 (+0.0375) 0.6233 (+0.1226) 0.5238 (+0.0685)
0.6936 7250 1.0402 - - - - -
0.7176 7500 1.0352 1.0158 0.5777 (+0.0372) 0.3725 (+0.0475) 0.6476 (+0.1469) 0.5326 (+0.0772)
0.7415 7750 1.0328 - - - - -
0.7654 8000 1.0022 1.0156 0.5817 (+0.0413) 0.3537 (+0.0287) 0.6358 (+0.1351) 0.5237 (+0.0684)
0.7893 8250 1.0175 - - - - -
0.8132 8500 1.0256 0.9995 0.5830 (+0.0426) 0.3647 (+0.0397) 0.6531 (+0.1524) 0.5336 (+0.0782)
0.8372 8750 1.0209 - - - - -
0.8611 9000 1.0233 1.0104 0.5830 (+0.0426) 0.3798 (+0.0548) 0.6592 (+0.1585) 0.5407 (+0.0853)
0.8850 9250 1.0247 - - - - -
0.9089 9500 1.0057 1.0089 0.5887 (+0.0483) 0.3705 (+0.0455) 0.6387 (+0.1381) 0.5327 (+0.0773)
0.9328 9750 1.0124 - - - - -
0.9568 10000 1.0209 1.0100 0.5837 (+0.0432) 0.3765 (+0.0514) 0.6377 (+0.1371) 0.5326 (+0.0772)
0.9807 10250 1.0199 - - - - -
-1 -1 - - 0.6078 (+0.0674) 0.3887 (+0.0636) 0.6535 (+0.1529) 0.5500 (+0.0946)
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.10.13
  • Sentence Transformers: 3.5.0.dev0
  • Transformers: 4.48.1
  • PyTorch: 2.5.1+cu124
  • Accelerate: 1.3.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",
}

LambdaLoss

@inproceedings{wang2018lambdaloss,
  title={The lambdaloss framework for ranking metric optimization},
  author={Wang, Xuanhui and Li, Cheng and Golbandi, Nadav and Bendersky, Michael and Najork, Marc},
  booktitle={Proceedings of the 27th ACM international conference on information and knowledge management},
  pages={1313--1322},
  year={2018}
}
Downloads last month
15
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 milistu/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-lambdaloss-hard-neg

Finetuned
(81)
this model

Evaluation results