CrossEncoder based on microsoft/MiniLM-L12-H384-uncased
This is a Cross Encoder model finetuned from microsoft/MiniLM-L12-H384-uncased 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
Model Sources
- Documentation: Sentence Transformers Documentation
- Documentation: Cross Encoder Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Cross Encoders on Hugging Face
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("Studeni/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-lambdaloss-hard-neg")
# Get scores for pairs of texts
pairs = [
['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (3,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'How many calories in an egg',
[
'There are on average between 55 and 80 calories in an egg depending on its size.',
'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
'Most of the calories in an egg come from the yellow yolk in the center.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
Evaluation
Metrics
Cross Encoder Reranking
- Datasets:
NanoMSMARCO_R100
,NanoNFCorpus_R100
andNanoNQ_R100
- Evaluated with
CrossEncoderRerankingEvaluator
with these parameters:{ "at_k": 10, "always_rerank_positives": true }
Metric | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
---|---|---|---|
map | 0.5356 (+0.0460) | 0.3376 (+0.0767) | 0.6074 (+0.1878) |
mrr@10 | 0.5286 (+0.0511) | 0.5410 (+0.0411) | 0.6151 (+0.1884) |
ndcg@10 | 0.6078 (+0.0674) | 0.3887 (+0.0636) | 0.6535 (+0.1529) |
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.4935 (+0.1035) |
mrr@10 | 0.5615 (+0.0935) |
ndcg@10 | 0.5500 (+0.0946) |
Training Details
Training Dataset
Unnamed Dataset
- Size: 167,227 training samples
- Columns:
query
,docs
, andlabels
- Approximate statistics based on the first 1000 samples:
query docs labels type string list list details - min: 11 characters
- mean: 33.92 characters
- max: 97 characters
- min: 3 elements
- mean: 6.50 elements
- max: 10 elements
- min: 3 elements
- mean: 6.50 elements
- max: 10 elements
- Samples:
query docs labels what is a natural hormone replacement
['Natural Hormone Replacement Therapy (“BHRT”) is common term for the treatment of conditions caused by the effects of hormone deficiencies resulting from menopause. BHRT uses hormones that are identical in their mollecular structure to the hormones produced naturally within the human body.', 'Natural hormone replacement therapy (HRT) is also known as bioidentical hormone therapy. It utilizes estradiol, progesterone or testosterone that are identical in structure to hormones found in a woman’s body.', 'NATURAL HORMONE REPLACEMENT. Natural hormone replacement therapy is a safer, sensible, effective, and free from most of the side effects of synthetic hormones. Every day in the United States 3,500 women enter menopause.', 'Natural or bio-identical hormone replacement therapy in the form of administering estrogen from estrogenic foods or taking progesterone creams has not been clinically tested. Much of the information is anecdotal only.', 'Bioidentical hormone therapy is often called nat...
[1, 0, 0, 0, 0, ...]
what is ras
["Ras is a family of related proteins which is ubiquitously expressed in all cell lineages and organs. All Ras protein family members belong to a class of protein called small GTPase, and are involved in transmitting signals within cells (cellular signal transduction). Ras is the prototypical member of the Ras superfamily of proteins, which are all related in 3D structure and regulate diverse cell behaviours. When Ras is 'switched on' by incoming signals, it subsequently switches on other proteins, which ultimately turn on genes involved in cell growth, differentiation and survival. Ras is a G protein, or a guanosine-nucleotide-binding protein. Specifically, it is a single-subunit small GTPase, which is related in structure to the G α subunit of heterotrimeric G proteins (large GTPases). G proteins function as binary signaling switches with on and off states.", "Ras is the prototypical member of the Ras superfamily of proteins, which are all related in 3D structure and regulate diverse...
[1, 0, 0, 0, 0, ...]
does laila engaged to meera's brother
['Laila Got Engaged To Meera Brother Ahsan. admin April 9, 2015 Laila Got Engaged To Meera Brother Ahsan 2015-04-10T03:50:40+00:00 Latest Happning No Comment. After the late buildup on media about Laila discovering her life accomplice through a network show, Laila has at long last discovered her “To-Be” Ahson. Kaun Bane Ga Laila Ka Dulha was a quite discussed fragment where youthful men contended to be Laila’s husband to be on APlus Morning Show, facilitated by Noor', 'Kaun Bane Ga Laila Ka Dulha was a much talked about segment where young men competed to be Laila’s groom on APlus Morning Show, hosted by Noor. Ahson, surprisingly happens to be the brother of film actress Meera and it has been revealed by sources that Laila and Ahson have been in a relationship for some time.', 'As we all be acquainted with that Laila was in look for of her life colleague. The beat show Kaun Banega “ Laila Ka Dulha ” was aired on A plus. In this part, men from special places take part and compete every ...
[1, 0, 0, 0, 0, ...]
- Loss:
LambdaLoss
with these parameters:{ "weighing_scheme": "sentence_transformers.cross_encoder.losses.LambdaLoss.NDCGLoss2PPScheme", "k": null, "sigma": 1.0, "eps": 1e-10, "reduction": "mean", "reduction_log": "binary", "activation_fct": "torch.nn.modules.linear.Identity", "mini_batch_size": 16 }
Evaluation Dataset
Unnamed Dataset
- Size: 1,000 evaluation samples
- Columns:
query
,docs
, andlabels
- Approximate statistics based on the first 1000 samples:
query docs labels type string list list details - min: 11 characters
- mean: 34.41 characters
- max: 102 characters
- min: 3 elements
- mean: 6.50 elements
- max: 10 elements
- min: 3 elements
- mean: 6.50 elements
- max: 10 elements
- Samples:
query docs labels what is the medicine called for tonsillitis
['Tonsillitis is usually caused by a virus and does not require prescription medicine. For information on over-the-counter pain medicine and other self-care options, see Home Treatment. An antibiotic, usually amoxicillin or penicillin, is used to treat tonsillitis caused by strep bacteria. Although tonsillitis caused by strep bacteria usually will go away on its own, antibiotics are used to prevent the complications, such as rheumatic fever, that can result from untreated strep throat. ', 'You have two tonsils, one on either side at the back of the mouth. The picture below shows large non-infected tonsils (no redness or pus). Tonsillitis is an infection of the tonsils. A sore throat is the most common of all tonsillitis symptoms. In addition, you may also have a cough, high temperature (fever), headache, feel sick, feel tired, find swallowing painful, and have swollen neck glands. ', 'Tonsillitis (/ˌtɒnsɪˈlaɪtɪs/ TON-si-LEYE-tis) is inflammation of the tonsils most commonly caused by v...
[1, 0, 0, 0, 0, ...]
is candida contagious
['Candida Related Complex is not a contagious condition. However the genital yeast can be contagious for some. east does not become a problem for us just because someone else who is having a problem keeping their yeast population under control kisses us or makes love to us. It is a disease that I do not see as contagious. ', 'Thrush, whether affecting the mouth or genitals, is not contagious in the way a cold or flu is, but it can still be passed on in some circumstances. The candida yeast occurs naturally in our bodies and, in healthy circumstances, it is harmless. ', 'Thrush, whether affecting the mouth or genitals, is not contagious in the way a cold or flu is, but it can still be passed on in some circumstances. The candida yeast occurs naturally in our bodies and, in healthy circumstances, it is harmless.', 'Candida is a type of yeast (fungus). Small numbers of candida normally live on your skin and do no harm. Sometimes, under certain conditions, they can multiply and cause infec...
[1, 0, 0, 0, 0, ...]
what helps runny nose from allergies
['Coughing also helps clear your airways of mucus produced due to a cold, allergies, or other diseases, such as the flu. Cold and allergies have many similar symptoms, such as coughing, runny nose, and sneezing. If you have asthma, both conditions can also cause wheezing and shortness of breath. However, colds and allergies are different conditions with distinct causes. Allergies:', 'You’ll want a decongestant, like pseudoephedrine or phenylephrine. A decongestant will help reduce nasal tissue swelling. If you’re dealing with allergies or a runny nose, you should look for an antihistamine, like diphenhydramine for nighttime use or non-drowsy fexofenadine. Products containing pseudoephedrine can be found behind your pharmacist’s counter. Rhinitis just means that the mucus membranes inside your nose are inflamed. Your runny nose could be caused by an infection (like a cold or the flu) or by cold weather, allergies, crying, irritating smells, or particles in the air. Before your nose star...
[1, 0, 0, 0, 0, ...]
- Loss:
LambdaLoss
with these parameters:{ "weighing_scheme": "sentence_transformers.cross_encoder.losses.LambdaLoss.NDCGLoss2PPScheme", "k": null, "sigma": 1.0, "eps": 1e-10, "reduction": "mean", "reduction_log": "binary", "activation_fct": "torch.nn.modules.linear.Identity", "mini_batch_size": 16 }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 16per_device_eval_batch_size
: 16learning_rate
: 2e-05num_train_epochs
: 1warmup_ratio
: 0.1seed
: 12bf16
: Trueload_best_model_at_end
: True
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 16per_device_eval_batch_size
: 16per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 1eval_accumulation_steps
: Nonetorch_empty_cache_steps
: Nonelearning_rate
: 2e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 1max_steps
: -1lr_scheduler_type
: linearlr_scheduler_kwargs
: {}warmup_ratio
: 0.1warmup_steps
: 0log_level
: passivelog_level_replica
: warninglog_on_each_node
: Truelogging_nan_inf_filter
: Truesave_safetensors
: Truesave_on_each_node
: Falsesave_only_model
: Falserestore_callback_states_from_checkpoint
: Falseno_cuda
: Falseuse_cpu
: Falseuse_mps_device
: Falseseed
: 12data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Truefp16
: Falsefp16_opt_level
: O1half_precision_backend
: autobf16_full_eval
: Falsefp16_full_eval
: Falsetf32
: Nonelocal_rank
: 0ddp_backend
: Nonetpu_num_cores
: Nonetpu_metrics_debug
: Falsedebug
: []dataloader_drop_last
: Falsedataloader_num_workers
: 0dataloader_prefetch_factor
: Nonepast_index
: -1disable_tqdm
: Falseremove_unused_columns
: Truelabel_names
: Noneload_best_model_at_end
: Trueignore_data_skip
: Falsefsdp
: []fsdp_min_num_params
: 0fsdp_config
: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap
: Noneaccelerator_config
: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torchoptim_args
: Noneadafactor
: Falsegroup_by_length
: Falselength_column_name
: lengthddp_find_unused_parameters
: Noneddp_bucket_cap_mb
: Noneddp_broadcast_buffers
: Falsedataloader_pin_memory
: Truedataloader_persistent_workers
: Falseskip_memory_metrics
: Trueuse_legacy_prediction_loop
: Falsepush_to_hub
: Falseresume_from_checkpoint
: Nonehub_model_id
: Nonehub_strategy
: every_savehub_private_repo
: Nonehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseinclude_for_metrics
: []eval_do_concat_batches
: Truefp16_backend
: autopush_to_hub_model_id
: Nonepush_to_hub_organization
: Nonemp_parameters
:auto_find_batch_size
: Falsefull_determinism
: Falsetorchdynamo
: Noneray_scope
: lastddp_timeout
: 1800torch_compile
: Falsetorch_compile_backend
: Nonetorch_compile_mode
: Nonedispatch_batches
: Nonesplit_batches
: Noneinclude_tokens_per_second
: Falseinclude_num_input_tokens_seen
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falseeval_on_start
: Falseuse_liger_kernel
: Falseeval_use_gather_object
: Falseaverage_tokens_across_devices
: Falseprompts
: Nonebatch_sampler
: batch_samplermulti_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.0186 (-0.5218) | 0.2310 (-0.0940) | 0.0644 (-0.4363) | 0.1047 (-0.3507) |
0.0001 | 1 | 1.4366 | - | - | - | - | - |
0.0239 | 250 | 1.4817 | - | - | - | - | - |
0.0478 | 500 | 1.4032 | 1.2754 | 0.4899 (-0.0505) | 0.3961 (+0.0711) | 0.5825 (+0.0818) | 0.4895 (+0.0341) |
0.0718 | 750 | 1.2631 | - | - | - | - | - |
0.0957 | 1000 | 1.2033 | 1.1534 | 0.5655 (+0.0251) | 0.3973 (+0.0723) | 0.6528 (+0.1521) | 0.5385 (+0.0832) |
0.1196 | 1250 | 1.17 | - | - | - | - | - |
0.1435 | 1500 | 1.1425 | 1.0954 | 0.5939 (+0.0535) | 0.4027 (+0.0776) | 0.6343 (+0.1337) | 0.5436 (+0.0883) |
0.1674 | 1750 | 1.1379 | - | - | - | - | - |
0.1914 | 2000 | 1.1188 | 1.0821 | 0.5835 (+0.0431) | 0.4002 (+0.0751) | 0.6518 (+0.1511) | 0.5452 (+0.0898) |
0.2153 | 2250 | 1.1084 | - | - | - | - | - |
0.2392 | 2500 | 1.1015 | 1.0653 | 0.6078 (+0.0674) | 0.3887 (+0.0636) | 0.6535 (+0.1529) | 0.5500 (+0.0946) |
0.2631 | 2750 | 1.0938 | - | - | - | - | - |
0.2870 | 3000 | 1.0903 | 1.0561 | 0.5836 (+0.0432) | 0.3776 (+0.0525) | 0.6557 (+0.1550) | 0.5389 (+0.0836) |
0.3109 | 3250 | 1.1009 | - | - | - | - | - |
0.3349 | 3500 | 1.0638 | 1.0453 | 0.5974 (+0.0570) | 0.3795 (+0.0545) | 0.6468 (+0.1462) | 0.5412 (+0.0859) |
0.3588 | 3750 | 1.0846 | - | - | - | - | - |
0.3827 | 4000 | 1.0796 | 1.0485 | 0.5971 (+0.0567) | 0.3734 (+0.0484) | 0.6326 (+0.1320) | 0.5344 (+0.0790) |
0.4066 | 4250 | 1.076 | - | - | - | - | - |
0.4305 | 4500 | 1.0661 | 1.0383 | 0.5912 (+0.0507) | 0.3748 (+0.0498) | 0.6223 (+0.1217) | 0.5294 (+0.0741) |
0.4545 | 4750 | 1.0429 | - | - | - | - | - |
0.4784 | 5000 | 1.0498 | 1.0361 | 0.5990 (+0.0586) | 0.3829 (+0.0579) | 0.6378 (+0.1372) | 0.5399 (+0.0845) |
0.5023 | 5250 | 1.0663 | - | - | - | - | - |
0.5262 | 5500 | 1.0376 | 1.0288 | 0.6045 (+0.0640) | 0.3786 (+0.0535) | 0.6437 (+0.1431) | 0.5423 (+0.0869) |
0.5501 | 5750 | 1.0347 | - | - | - | - | - |
0.5741 | 6000 | 1.0299 | 1.0317 | 0.5914 (+0.0510) | 0.3797 (+0.0547) | 0.6447 (+0.1441) | 0.5386 (+0.0833) |
0.5980 | 6250 | 1.0448 | - | - | - | - | - |
0.6219 | 6500 | 1.0443 | 1.0281 | 0.5860 (+0.0456) | 0.3623 (+0.0372) | 0.6291 (+0.1285) | 0.5258 (+0.0704) |
0.6458 | 6750 | 1.0129 | - | - | - | - | - |
0.6697 | 7000 | 1.0388 | 1.0208 | 0.5857 (+0.0453) | 0.3625 (+0.0375) | 0.6233 (+0.1226) | 0.5238 (+0.0685) |
0.6936 | 7250 | 1.0402 | - | - | - | - | - |
0.7176 | 7500 | 1.0352 | 1.0158 | 0.5777 (+0.0372) | 0.3725 (+0.0475) | 0.6476 (+0.1469) | 0.5326 (+0.0772) |
0.7415 | 7750 | 1.0328 | - | - | - | - | - |
0.7654 | 8000 | 1.0022 | 1.0156 | 0.5817 (+0.0413) | 0.3537 (+0.0287) | 0.6358 (+0.1351) | 0.5237 (+0.0684) |
0.7893 | 8250 | 1.0175 | - | - | - | - | - |
0.8132 | 8500 | 1.0256 | 0.9995 | 0.5830 (+0.0426) | 0.3647 (+0.0397) | 0.6531 (+0.1524) | 0.5336 (+0.0782) |
0.8372 | 8750 | 1.0209 | - | - | - | - | - |
0.8611 | 9000 | 1.0233 | 1.0104 | 0.5830 (+0.0426) | 0.3798 (+0.0548) | 0.6592 (+0.1585) | 0.5407 (+0.0853) |
0.8850 | 9250 | 1.0247 | - | - | - | - | - |
0.9089 | 9500 | 1.0057 | 1.0089 | 0.5887 (+0.0483) | 0.3705 (+0.0455) | 0.6387 (+0.1381) | 0.5327 (+0.0773) |
0.9328 | 9750 | 1.0124 | - | - | - | - | - |
0.9568 | 10000 | 1.0209 | 1.0100 | 0.5837 (+0.0432) | 0.3765 (+0.0514) | 0.6377 (+0.1371) | 0.5326 (+0.0772) |
0.9807 | 10250 | 1.0199 | - | - | - | - | - |
-1 | -1 | - | - | 0.6078 (+0.0674) | 0.3887 (+0.0636) | 0.6535 (+0.1529) | 0.5500 (+0.0946) |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.10.13
- Sentence Transformers: 3.5.0.dev0
- Transformers: 4.48.1
- PyTorch: 2.5.1+cu124
- Accelerate: 1.3.0
- Datasets: 3.2.0
- 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",
}
LambdaLoss
@inproceedings{wang2018lambdaloss,
title={The lambdaloss framework for ranking metric optimization},
author={Wang, Xuanhui and Li, Cheng and Golbandi, Nadav and Bendersky, Michael and Najork, Marc},
booktitle={Proceedings of the 27th ACM international conference on information and knowledge management},
pages={1313--1322},
year={2018}
}
- Downloads last month
- 15
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 HF Inference API does not support text-classification models for sentence-transformers library.
Model tree for milistu/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-lambdaloss-hard-neg
Base model
microsoft/MiniLM-L12-H384-uncasedEvaluation results
- Map on NanoMSMARCO R100self-reported0.536
- Mrr@10 on NanoMSMARCO R100self-reported0.529
- Ndcg@10 on NanoMSMARCO R100self-reported0.608
- Map on NanoNFCorpus R100self-reported0.338
- Mrr@10 on NanoNFCorpus R100self-reported0.541
- Ndcg@10 on NanoNFCorpus R100self-reported0.389
- Map on NanoNQ R100self-reported0.607
- Mrr@10 on NanoNQ R100self-reported0.615
- Ndcg@10 on NanoNQ R100self-reported0.653
- Map on NanoBEIR R100 meanself-reported0.493