MiniLM-L12-H384-uncased reranker distilled from MS MARCO ensemble

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 Type: Cross Encoder
  • Base model: microsoft/MiniLM-L12-H384-uncased
  • Maximum Sequence Length: 512 tokens
  • Number of Output Labels: 1 label
  • Supported Modality: Text
  • Training Dataset:
    • msmarco
  • Language: en
  • License: apache-2.0

Model Sources

Full Model Architecture

CrossEncoder(
  (0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'BertForSequenceClassification'})
)

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("Hyperakan/minilm-msmarco-distilled")
# Get scores for pairs of inputs
pairs = [
    ['what are roof rats', 'Rattus rattus redirects here. For the album by Merzbow, see Rattus Rattus (album). The black rat (Rattus rattus), also known as the ship rat, roof rat, house rat, is a common long-tailed rodent of the genus Rattus (rats) in the subfamily Murinae. The species originated in tropical Asia and spread through the Near East in Roman times before reaching Europe by the 1st century and spreading with Europeans across the world.'],
    ['is overeating an eating disorder?', 'Compulsive overeating disorder is frequently called a â\x80\x9cfood addictionâ\x80\x9d because eating can cause biological changes in your body that are similar to those caused by addictive substances. Studies have found that foods, particularly high-fat foods, affect the areas of your brain associated with pleasure.'],
    ['can polycythemia cause stroke', 'Polycythemia Vera Complications. If you have PV, the thickness of your blood and the slowed blood flow can cause serious health problems. Blood clots are the most serious complication of PV. Blood clots can cause a heart attack or stroke. They also can cause your liver and spleen to enlarge.'],
    ['how many years of college does it take to be a pediatrician', 'Training to become a pediatrician requires a four-year undergraduate degree, four years of medical school, and three or more years of hands-on residency training.'],
    ['using commas correctly in sentences', "Commas and periods are the most frequently used punctuation marks. Commas customarily indicate a brief pause; they're not as final as periods. Rule 1. Use commas to separate words and word groups in a simple series of three or more items. Example: My estate goes to my husband, son, daughter-in-law, and nephew. Note: When the last comma in a series comes before and or or (after daughter-in-law in the above example), it is known as the Oxford comma. Most newspapers and magazines drop the Oxford comma in a simple series, apparently feeling it's unnecessary."],
]
scores = model.predict(pairs)
print(scores)
# [-0.0032 -0.0024 -0.0019  0.0005 -0.0017]

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'what are roof rats',
    [
        'Rattus rattus redirects here. For the album by Merzbow, see Rattus Rattus (album). The black rat (Rattus rattus), also known as the ship rat, roof rat, house rat, is a common long-tailed rodent of the genus Rattus (rats) in the subfamily Murinae. The species originated in tropical Asia and spread through the Near East in Roman times before reaching Europe by the 1st century and spreading with Europeans across the world.',
        'Compulsive overeating disorder is frequently called a â\x80\x9cfood addictionâ\x80\x9d because eating can cause biological changes in your body that are similar to those caused by addictive substances. Studies have found that foods, particularly high-fat foods, affect the areas of your brain associated with pleasure.',
        'Polycythemia Vera Complications. If you have PV, the thickness of your blood and the slowed blood flow can cause serious health problems. Blood clots are the most serious complication of PV. Blood clots can cause a heart attack or stroke. They also can cause your liver and spleen to enlarge.',
        'Training to become a pediatrician requires a four-year undergraduate degree, four years of medical school, and three or more years of hands-on residency training.',
        "Commas and periods are the most frequently used punctuation marks. Commas customarily indicate a brief pause; they're not as final as periods. Rule 1. Use commas to separate words and word groups in a simple series of three or more items. Example: My estate goes to my husband, son, daughter-in-law, and nephew. Note: When the last comma in a series comes before and or or (after daughter-in-law in the above example), it is known as the Oxford comma. Most newspapers and magazines drop the Oxford comma in a simple series, apparently feeling it's unnecessary.",
    ]
)
# [{'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.0300 (-0.4596) 0.2709 (+0.0099) 0.0230 (-0.3966)
mrr@10 0.0069 (-0.4706) 0.3974 (-0.1025) 0.0025 (-0.4242)
ndcg@10 0.0148 (-0.5256) 0.2428 (-0.0822) 0.0039 (-0.4968)

Cross Encoder Nano BEIR

  • Dataset: NanoBEIR_R100_mean
  • Evaluated with CrossEncoderNanoBEIREvaluator with these parameters:
    {
        "dataset_names": [
            "msmarco",
            "nfcorpus",
            "nq"
        ],
        "dataset_id": "sentence-transformers/NanoBEIR-en",
        "rerank_k": 100,
        "at_k": 10,
        "always_rerank_positives": true
    }
    
Metric Value
map 0.1080 (-0.2821)
mrr@10 0.1356 (-0.3324)
ndcg@10 0.0872 (-0.3682)

Training Details

Training Dataset

msmarco

  • Dataset: msmarco
  • Size: 100 training samples
  • Columns: score, query, positive, and negative
  • Approximate statistics based on the first 100 samples:
    score query positive negative
    type float string string string
    modality text text text
    details
    • min: 0.6
    • mean: 12.6
    • max: 20.57
    • min: 4 tokens
    • mean: 9.43 tokens
    • max: 16 tokens
    • min: 13 tokens
    • mean: 78.46 tokens
    • max: 197 tokens
    • min: 32 tokens
    • mean: 77.94 tokens
    • max: 161 tokens
  • Samples:
    score query positive negative
    12.03586260477702 obesity synonyms Synonyms: embonpoint; stoutness; corpulency; exogenous obesity; overweight; avoirdupois; plumpness; fat; fatness; roundness; adiposis; corpulence; blubber; fleshiness; Antonyms: leanness Make an effort synonyms. Top make an effort synonyms (idioms only) are have a crack, chip away at and give a go.
    8.629784286022186 minecraft 1.9.2 how to make fences Once you have these you can then put them back into the Crafting Box and make them into Sticks. Place all items like how it is displayed below into the table: Now that you have learned how to make a fence in Minecraft, they are 1.5 blocks tall so nothing is able to jump over them.You are able to place blocks on top of the fence that will sit on the fence like it is one block. Fences can be used as a Fuel Source in Furnaces.A Fence Gate is commonly used with fences so a player easily go through a wall of fences.ow To Make A Fence In Minecraft. Crafting is the way to make a cake in Minecraft. The player will first need one crafting table. It can be made by opening your inventory box and placing 4 Wooden Planks into the 2×2 grid. If you just made the crafting table then you will need to equip it and place it on the ground. 1.9, the first release of the Combat Update, is an upcoming major update to Minecraft with no set release date.Dinnerbone has stated in May that many of the features he has shown for 1.9 are not “100% final”, so things may change later.or other editions, see Version history (disambiguation) . 1.9, the first release of the Combat Update, is an upcoming major update to Minecraft with no set release date. Dinnerbone has stated in May that many of the features he has shown for 1.9 are not “100% final”, so things may change later.
    8.286005536715189 what is trap it term Trap (computing) In computing and operating systems, a trap, also known as an exception or a fault, is typically[NB 1][1] a type of synchronous interrupt typically caused by an exceptional condition (e.g., breakpoint, division by zero, invalid memory access). 1 A cage trap baited with peanut butter or a sticky trap that is of a size designed to catch rats will get them while in the car. 2 Then drown the rats or suffocate them in a plastic bag (trap and rat go in the bag) and then trash them. A cage trap baited with peanut butter or a sticky trap that is of a size designed to catch rats will get them while in the car. 2 Then drown the rats or suffocate them in a plastic bag (trap and rat go in the bag) and then trash them.
  • Loss: MarginMSELoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity"
    }
    

Evaluation Dataset

msmarco

  • Dataset: msmarco
  • Size: 20 evaluation samples
  • Columns: score, query, positive, and negative
  • Approximate statistics based on the first 20 samples:
    score query positive negative
    type float string string string
    modality text text text
    details
    • min: -1.83
    • mean: 12.68
    • max: 20.24
    • min: 4 tokens
    • mean: 8.4 tokens
    • max: 15 tokens
    • min: 34 tokens
    • mean: 89.75 tokens
    • max: 147 tokens
    • min: 32 tokens
    • mean: 78.8 tokens
    • max: 161 tokens
  • Samples:
    score query positive negative
    16.17283757527669 what are roof rats Rattus rattus redirects here. For the album by Merzbow, see Rattus Rattus (album). The black rat (Rattus rattus), also known as the ship rat, roof rat, house rat, is a common long-tailed rodent of the genus Rattus (rats) in the subfamily Murinae. The species originated in tropical Asia and spread through the Near East in Roman times before reaching Europe by the 1st century and spreading with Europeans across the world. 1 A cage trap baited with peanut butter or a sticky trap that is of a size designed to catch rats will get them while in the car. 2 Then drown the rats or suffocate them in a plastic bag (trap and rat go in the bag) and then trash them. A cage trap baited with peanut butter or a sticky trap that is of a size designed to catch rats will get them while in the car. 2 Then drown the rats or suffocate them in a plastic bag (trap and rat go in the bag) and then trash them.
    12.888915936152141 is overeating an eating disorder? Compulsive overeating disorder is frequently called a “food addiction” because eating can cause biological changes in your body that are similar to those caused by addictive substances. Studies have found that foods, particularly high-fat foods, affect the areas of your brain associated with pleasure. Emetrol is an oral solution designed to soothe the stomach when nausea and vomiting are caused by a viral or bacterial infection or overeating. Emetrol contains sugar and phosphoric acid. Diabetics should not use Emetrol without medical supervision because of the concentrated sugar.
    18.19395383199056 can polycythemia cause stroke Polycythemia Vera Complications. If you have PV, the thickness of your blood and the slowed blood flow can cause serious health problems. Blood clots are the most serious complication of PV. Blood clots can cause a heart attack or stroke. They also can cause your liver and spleen to enlarge. Stroke Recovery. Stroke affects everybody differently. Many stroke survivors continue to improve over a long time, sometimes over a number of years. Recovery from stroke involves making changes in the physical, social and, emotional aspects of your life. You will make changes to prevent additional strokes as well as to facilitate your life-long recovery.
  • Loss: MarginMSELoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 32
  • per_device_eval_batch_size: 32
  • learning_rate: 8e-06
  • weight_decay: 0.01
  • 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
  • prediction_loss_only: True
  • per_device_train_batch_size: 32
  • per_device_eval_batch_size: 32
  • 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.01
  • 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: None
  • 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
  • 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}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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
  • hub_revision: None
  • 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
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

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.0177 (-0.5227) 0.2189 (-0.1061) 0.0059 (-0.4948) 0.0808 (-0.3745)
0.25 1 218.674 191.3648 0.0177 (-0.5227) 0.2189 (-0.1061) 0.0059 (-0.4948) 0.0808 (-0.3745)
0.5 2 163.1853 191.3569 0.0167 (-0.5238) 0.2342 (-0.0908) 0.0039 (-0.4968) 0.0849 (-0.3705)
0.75 3 171.4948 191.3564 0.0148 (-0.5256) 0.2428 (-0.0822) 0.0039 (-0.4968) 0.0872 (-0.3682)
1.0 4 120.6957 191.3561 0.0146 (-0.5258) 0.2347 (-0.0903) 0.0047 (-0.4959) 0.0847 (-0.3707)
-1 -1 - - 0.0148 (-0.5256) 0.2428 (-0.0822) 0.0039 (-0.4968) 0.0872 (-0.3682)
  • The bold row denotes the saved checkpoint.

Training Time

  • Training: 1.0 minutes
  • Evaluation: 3.1 minutes
  • Total: 4.1 minutes

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 5.6.0
  • Transformers: 4.57.6
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.14.0
  • Datasets: 5.0.0
  • Tokenizers: 0.22.2

Additional Resources

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",
}

MarginMSELoss

@misc{hofstätter2021improving,
    title={Improving Efficient Neural Ranking Models with Cross-Architecture Knowledge Distillation},
    author={Sebastian Hofstätter and Sophia Althammer and Michael Schröder and Mete Sertkan and Allan Hanbury},
    year={2021},
    eprint={2010.02666},
    archivePrefix={arXiv},
    primaryClass={cs.IR}
}
Downloads last month
23
Safetensors
Model size
33.4M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Hyperakan/minilm-msmarco-distilled

Finetuned
(133)
this model

Papers for Hyperakan/minilm-msmarco-distilled

Evaluation results