CrossEncoder based on microsoft/MiniLM-L12-H384-uncased
This is a Cross Encoder model finetuned from microsoft/MiniLM-L12-H384-uncased on the ms_marco 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("Wi-Fi/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-listmle")
pairs = [
['what schooling is required to become a nephrologist', 'Educational Requirements. Necessary education to become a nephrologist includes a medical doctoral degree, completion of an Accreditation Council for Graduate Medical Education (ACGME) internal medicine residency program and at least two years of professional experience working with patients. '],
['what schooling is required to become a nephrologist', 'How to Become a Nephrologist. Nephrology is a discipline of internal medicine that focuses on the kidney and related conditions and diseases. Nephrologists are specially trained medical doctors that are experts on treating patients with conditions related to the kidneys and other related areas. Nephrologists diagnose and treat a variety of conditions such as kidney disease, electrolyte disorders, high blood pressure, and kidney stones. They perform many different types of tests to assist in diagnosis and treatments such as blood tests, urine tests, biopsies, ultrasounds, and placement of catheters.'],
['what schooling is required to become a nephrologist', '10. While in your residency period, try to make contacts with other nephrologists. Having good contacts in the field of nephrology, as well as urology, is a very good step while in your residency and if you are sure of becoming a nephrologist. Since nephrology is a branch of internal medicine, you will have to do your residency in internal medicine first. During your residency period, you will work in a hospital. You are responsible for patients, and supervised by senior residents as well as professional doctors'],
['what schooling is required to become a nephrologist', "Residency and Fellowships. Graduation from medical school is just the beginning of the nephrologist's medical education. After graduation, newly minted doctors do their medical residency at a hospital. Would-be nephrologists complete an internal medicine residency, which lasts for three years. Medical School. Budding nephrologists must graduate from a medical school. The road just to get into medical school after graduation from an accredited four-year college or university is arduous."],
['what schooling is required to become a nephrologist', 'Formal education and training requirements for physicians are among the most demanding of any occupation-4 years of undergraduate school, 4 years of medical school, and 3 to 8 years of internship and residency, depending on the specialty selected. Physicians specializing in anesthesiology must spend a substantial number of years completing education and training requirements, including 4 years of undergraduate school, 4 … years of medical school, and 3 to 8 years of residency.'],
]
scores = model.predict(pairs)
print(scores.shape)
ranks = model.rank(
'what schooling is required to become a nephrologist',
[
'Educational Requirements. Necessary education to become a nephrologist includes a medical doctoral degree, completion of an Accreditation Council for Graduate Medical Education (ACGME) internal medicine residency program and at least two years of professional experience working with patients. ',
'How to Become a Nephrologist. Nephrology is a discipline of internal medicine that focuses on the kidney and related conditions and diseases. Nephrologists are specially trained medical doctors that are experts on treating patients with conditions related to the kidneys and other related areas. Nephrologists diagnose and treat a variety of conditions such as kidney disease, electrolyte disorders, high blood pressure, and kidney stones. They perform many different types of tests to assist in diagnosis and treatments such as blood tests, urine tests, biopsies, ultrasounds, and placement of catheters.',
'10. While in your residency period, try to make contacts with other nephrologists. Having good contacts in the field of nephrology, as well as urology, is a very good step while in your residency and if you are sure of becoming a nephrologist. Since nephrology is a branch of internal medicine, you will have to do your residency in internal medicine first. During your residency period, you will work in a hospital. You are responsible for patients, and supervised by senior residents as well as professional doctors',
"Residency and Fellowships. Graduation from medical school is just the beginning of the nephrologist's medical education. After graduation, newly minted doctors do their medical residency at a hospital. Would-be nephrologists complete an internal medicine residency, which lasts for three years. Medical School. Budding nephrologists must graduate from a medical school. The road just to get into medical school after graduation from an accredited four-year college or university is arduous.",
'Formal education and training requirements for physicians are among the most demanding of any occupation-4 years of undergraduate school, 4 years of medical school, and 3 to 8 years of internship and residency, depending on the specialty selected. Physicians specializing in anesthesiology must spend a substantial number of years completing education and training requirements, including 4 years of undergraduate school, 4 … years of medical school, and 3 to 8 years of residency.',
]
)
Evaluation
Metrics
Cross Encoder Reranking
| Metric |
NanoMSMARCO_R100 |
NanoNFCorpus_R100 |
NanoNQ_R100 |
| map |
0.3407 (-0.1489) |
0.2803 (+0.0193) |
0.2448 (-0.1748) |
| mrr@10 |
0.3234 (-0.1541) |
0.3818 (-0.1180) |
0.2333 (-0.1934) |
| ndcg@10 |
0.3834 (-0.1570) |
0.2520 (-0.0730) |
0.2953 (-0.2053) |
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.2886 (-0.1015) |
| mrr@10 |
0.3128 (-0.1552) |
| ndcg@10 |
0.3103 (-0.1451) |
Training Details
Training Dataset
ms_marco
Evaluation Dataset
ms_marco
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}
tp_size: 0
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
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.0300 (-0.5104) |
0.2528 (-0.0723) |
0.0168 (-0.4839) |
0.0999 (-0.3555) |
| 0.0008 |
1 |
14.1367 |
- |
- |
- |
- |
- |
| 0.2033 |
250 |
12.2769 |
- |
- |
- |
- |
- |
| 0.4065 |
500 |
11.248 |
11.2104 |
0.1129 (-0.4275) |
0.2002 (-0.1248) |
0.1527 (-0.3480) |
0.1553 (-0.3001) |
| 0.6098 |
750 |
11.2506 |
- |
- |
- |
- |
- |
| 0.813 |
1000 |
11.1721 |
11.1729 |
0.3834 (-0.1570) |
0.2520 (-0.0730) |
0.2953 (-0.2053) |
0.3103 (-0.1451) |
| -1 |
-1 |
- |
- |
0.3834 (-0.1570) |
0.2520 (-0.0730) |
0.2953 (-0.2053) |
0.3103 (-0.1451) |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.11.11
- Sentence Transformers: 4.1.0
- Transformers: 4.51.3
- PyTorch: 2.6.0+cu124
- Accelerate: 1.6.0
- Datasets: 3.5.0
- Tokenizers: 0.21.1
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",
}
ListMLELoss
@inproceedings{10.1145/1390156.1390306,
title = {Listwise Approach to Learning to Rank - Theory and Algorithm},
author = {Xia, Fen and Liu, Tie-Yan and Wang, Jue and Zhang, Wensheng and Li, Hang},
booktitle = {Proceedings of the 25th International Conference on Machine Learning},
pages = {1192-1199},
year = {2008},
url = {https://doi.org/10.1145/1390156.1390306},
}