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 Type: Cross Encoder
- Base model: microsoft/MiniLM-L12-H384-uncased
- Maximum Sequence Length: 512 tokens
- Number of Output Labels: 1 label
- Training Dataset:
- Language: en
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
model = CrossEncoder("tomaarsen/reranker-MiniLM-L12-H384-uncased-msmarco-bce")
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)
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.',
]
)
Evaluation
Metrics
Cross Encoder Reranking
| 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
Evaluation Dataset
msmarco
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",
}