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:
- 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
model = CrossEncoder("Hyperakan/minilm-msmarco-distilled")
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)
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.",
]
)
Evaluation
Metrics
Cross Encoder Reranking
| 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
Evaluation Dataset
msmarco
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}
}