YAML Metadata Warning: The pipeline tag "text-ranking" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, text2text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, other

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

This is a Cross Encoder model finetuned from microsoft/MiniLM-L12-H384-uncased on the msmarco dataset 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("tomaarsen/reranker-MiniLM-L12-H384-uncased-msmarco-bce")
# Get scores for pairs of texts
pairs = [
    ['cost to repair a manifold gasket', 'Parts. The cost of the parts required to repair or replace your intake manifold gasket ranges from $25 to $100 in 2010, according to RepairPal, depending on the year and make of your car. This range applies if you have a 2005 Ford Taurus or a 2011 BMW 750Li.'],
    ['what county is salisbury missouri in', 'The St. Louis County, Missouri sales tax is 7.11% , consisting of 4.23% Missouri state sales tax and 2.89% St. Louis County local sales taxes.The local sales tax consists of a 1.64% county sales tax and a 1.25% special district sales tax (used to fund transportation districts, local attractions, etc). St. Louis County Missouri Sales Tax Exemptions.'],
    ['what is life expectancy for someone with lung cancer', 'The two general types of lung cancer include: Small cell lung cancer. Small cell lung cancer occurs almost exclusively in heavy smokers and is less common than non-small cell lung cancer. Non-small cell lung cancer. Non-small cell lung cancer is an umbrella term for several types of lung cancers that behave in a similar way. Non-small cell lung cancers include squamous cell carcinoma, adenocarcinoma and large cell carcinoma.'],
    ['where does the zambezi river start', 'Where is Zimbabwe? Zimbabwe lies between the Limpopo and Zambezi rivers in south central Africa. It is bounded by Zambia (797km) in the north and northwest, by South Africa (225km) in the south by Mozambique(1 231km) in the east and north-east, and by Botswana (813km)in the south-west. It has no coastline and is totally landlocked.'],
    ['what is a lichen moth', 'Understanding Oral Lichen Planus. Oral lichen planus can occur anywhere inside the mouth, but is usually seen on the inside of the cheeks and appears as thin white lines, patches, or dots. It is most common between the ages of 30 and 60. While it appears in about one to two percent of the population, women get oral lichen planus twice as often as men.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'cost to repair a manifold gasket',
    [
        'Parts. The cost of the parts required to repair or replace your intake manifold gasket ranges from $25 to $100 in 2010, according to RepairPal, depending on the year and make of your car. This range applies if you have a 2005 Ford Taurus or a 2011 BMW 750Li.',
        'The St. Louis County, Missouri sales tax is 7.11% , consisting of 4.23% Missouri state sales tax and 2.89% St. Louis County local sales taxes.The local sales tax consists of a 1.64% county sales tax and a 1.25% special district sales tax (used to fund transportation districts, local attractions, etc). St. Louis County Missouri Sales Tax Exemptions.',
        'The two general types of lung cancer include: Small cell lung cancer. Small cell lung cancer occurs almost exclusively in heavy smokers and is less common than non-small cell lung cancer. Non-small cell lung cancer. Non-small cell lung cancer is an umbrella term for several types of lung cancers that behave in a similar way. Non-small cell lung cancers include squamous cell carcinoma, adenocarcinoma and large cell carcinoma.',
        'Where is Zimbabwe? Zimbabwe lies between the Limpopo and Zambezi rivers in south central Africa. It is bounded by Zambia (797km) in the north and northwest, by South Africa (225km) in the south by Mozambique(1 231km) in the east and north-east, and by Botswana (813km)in the south-west. It has no coastline and is totally landlocked.',
        'Understanding Oral Lichen Planus. Oral lichen planus can occur anywhere inside the mouth, but is usually seen on the inside of the cheeks and appears as thin white lines, patches, or dots. It is most common between the ages of 30 and 60. While it appears in about one to two percent of the population, women get oral lichen planus twice as often as men.',
    ]
)
# [{'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.5585 (+0.0689) 0.3318 (+0.0708) 0.6943 (+0.2747)
mrr@10 0.5533 (+0.0758) 0.5174 (+0.0175) 0.7187 (+0.2920)
ndcg@10 0.6413 (+0.1009) 0.3979 (+0.0728) 0.7395 (+0.2388)

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.5282 (+0.1381)
mrr@10 0.5964 (+0.1284)
ndcg@10 0.5929 (+0.1375)

Training Details

Training Dataset

msmarco

  • Dataset: msmarco at 88847c6
  • Size: 1,990,000 training samples
  • Columns: query, passage, and score
  • Approximate statistics based on the first 1000 samples:
    query passage score
    type string string float
    details
    • min: 10 characters
    • mean: 34.4 characters
    • max: 200 characters
    • min: 88 characters
    • mean: 344.88 characters
    • max: 935 characters
    • min: 0.0
    • mean: 0.48
    • max: 1.0
  • Samples:
    query passage score
    who is erin anderson? Erin Anderson is an actress and writer, known for Kittens in a Cage (2015), The Mysteries of Laura (2014) and Insidious: Chapter 3 (2015). 1.0
    how long is a food handlers permit good for in california If you would like to get your California Food Handler card you will need to successfully pass an approved Food Safety for Handlers course. For how long is the California Food Handler card valid? The California Food Handler card is valid throughout most of the state and is valid for three years from issuance. Each food establishment or business must have records documenting that each of its employees has a valid California Food Handler card that can be provided to local enforcement officials upon request. 1.0
    matagorda tx is in what county Matagorda is an unincorporated community in Matagorda County, Texas, United States. It had a population of approximately 710 in 2000. Matagorda is at the end of State Highway 60 and beginning of Farm to Market Road 2031, which runs over the Intracoastal Waterway and south to the Gulf of Mexico. The area is popular for fishing and beach activities. The Matagorda Independent School District serves area students. 1.0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fct": "torch.nn.modules.linear.Identity",
        "pos_weight": null
    }
    

Evaluation Dataset

msmarco

  • Dataset: msmarco at 88847c6
  • Size: 10,000 evaluation samples
  • Columns: query, passage, and score
  • Approximate statistics based on the first 1000 samples:
    query passage score
    type string string float
    details
    • min: 7 characters
    • mean: 33.41 characters
    • max: 114 characters
    • min: 52 characters
    • mean: 346.04 characters
    • max: 892 characters
    • min: 0.0
    • mean: 0.5
    • max: 1.0
  • Samples:
    query passage score
    cost to repair a manifold gasket Parts. The cost of the parts required to repair or replace your intake manifold gasket ranges from $25 to $100 in 2010, according to RepairPal, depending on the year and make of your car. This range applies if you have a 2005 Ford Taurus or a 2011 BMW 750Li. 1.0
    what county is salisbury missouri in The St. Louis County, Missouri sales tax is 7.11% , consisting of 4.23% Missouri state sales tax and 2.89% St. Louis County local sales taxes.The local sales tax consists of a 1.64% county sales tax and a 1.25% special district sales tax (used to fund transportation districts, local attractions, etc). St. Louis County Missouri Sales Tax Exemptions. 0.0
    what is life expectancy for someone with lung cancer The two general types of lung cancer include: Small cell lung cancer. Small cell lung cancer occurs almost exclusively in heavy smokers and is less common than non-small cell lung cancer. Non-small cell lung cancer. Non-small cell lung cancer is an umbrella term for several types of lung cancers that behave in a similar way. Non-small cell lung cancers include squamous cell carcinoma, adenocarcinoma and large cell carcinoma. 0.0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fct": "torch.nn.modules.linear.Identity",
        "pos_weight": null
    }
    

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
  • 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: 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: 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_R100_ndcg@10 NanoNFCorpus_R100_ndcg@10 NanoNQ_R100_ndcg@10 NanoBEIR_R100_mean_ndcg@10
-1 -1 - - 0.0463 (-0.4941) 0.2098 (-0.1153) 0.0229 (-0.4777) 0.0930 (-0.3624)
0.0000 1 0.6924 - - - - -
0.0322 4000 0.4573 - - - - -
0.0643 8000 0.2515 - - - - -
0.0804 10000 - 0.2219 0.6264 (+0.0860) 0.3713 (+0.0463) 0.7032 (+0.2026) 0.5670 (+0.1116)
0.0965 12000 0.2335 - - - - -
0.1286 16000 0.2294 - - - - -
0.1608 20000 0.2172 0.2071 0.5972 (+0.0568) 0.3913 (+0.0662) 0.6825 (+0.1818) 0.5570 (+0.1016)
0.1930 24000 0.2086 - - - - -
0.2251 28000 0.2075 - - - - -
0.2412 30000 - 0.1947 0.6298 (+0.0893) 0.3858 (+0.0608) 0.7129 (+0.2123) 0.5762 (+0.1208)
0.2573 32000 0.2015 - - - - -
0.2894 36000 0.2003 - - - - -
0.3216 40000 0.1976 0.1759 0.6333 (+0.0929) 0.3757 (+0.0506) 0.7058 (+0.2052) 0.5716 (+0.1162)
0.3538 44000 0.1945 - - - - -
0.3859 48000 0.1881 - - - - -
0.4020 50000 - 0.1735 0.6267 (+0.0862) 0.3752 (+0.0502) 0.7417 (+0.2410) 0.5812 (+0.1258)
0.4181 52000 0.1875 - - - - -
0.4503 56000 0.1875 - - - - -
0.4824 60000 0.1836 0.1726 0.5941 (+0.0537) 0.3915 (+0.0665) 0.7071 (+0.2064) 0.5642 (+0.1089)
0.5146 64000 0.179 - - - - -
0.5467 68000 0.178 - - - - -
0.5628 70000 - 0.1622 0.6245 (+0.0841) 0.3920 (+0.0669) 0.7220 (+0.2213) 0.5795 (+0.1241)
0.5789 72000 0.1791 - - - - -
0.6111 76000 0.1759 - - - - -
0.6432 80000 0.1775 0.1661 0.6413 (+0.1009) 0.3979 (+0.0728) 0.7395 (+0.2388) 0.5929 (+0.1375)
0.6754 84000 0.1724 - - - - -
0.7075 88000 0.1714 - - - - -
0.7236 90000 - 0.1684 0.6535 (+0.1131) 0.3780 (+0.0529) 0.7460 (+0.2454) 0.5925 (+0.1371)
0.7397 92000 0.165 - - - - -
0.7719 96000 0.1678 - - - - -
0.8040 100000 0.1673 0.1497 0.6461 (+0.1056) 0.3637 (+0.0387) 0.7306 (+0.2300) 0.5801 (+0.1248)
0.8362 104000 0.1644 - - - - -
0.8683 108000 0.1617 - - - - -
0.8844 110000 - 0.1513 0.6767 (+0.1363) 0.3674 (+0.0424) 0.7340 (+0.2334) 0.5927 (+0.1373)
0.9005 112000 0.1605 - - - - -
0.9327 116000 0.1667 - - - - -
0.9648 120000 0.1624 0.1474 0.6530 (+0.1126) 0.3671 (+0.0420) 0.7412 (+0.2406) 0.5871 (+0.1317)
0.9970 124000 0.1608 - - - - -
-1 -1 - - 0.6413 (+0.1009) 0.3979 (+0.0728) 0.7395 (+0.2388) 0.5929 (+0.1375)
  • The bold row denotes the saved checkpoint.

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • Energy Consumed: 0.638 kWh
  • Carbon Emitted: 0.248 kg of CO2
  • Hours Used: 2.404 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.49.0
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.4.0
  • Datasets: 3.3.2
  • 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
5
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 model has no pipeline_tag.

Model tree for tomaarsen/reranker-MiniLM-L12-H384-uncased-msmarco-bce

Finetuned
(54)
this model

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

Evaluation results