CoolFace
Modelpublic

milistu/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-lambdaloss-hard-neg

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes8downloads
Model Card

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 <!-- at revision 44acabbec0ef496f6dbc93adadea57f376b7c0ec -->
  • —Maximum Sequence Length: 512 tokens
  • —Number of Output Labels: 1 label <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
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': ...}, ...]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Cross Encoder Reranking
json
  {
      "at_k": 10,
      "always_rerank_positives": true
  }
MetricNanoMSMARCO_R100NanoNFCorpus_R100NanoNQ_R100
map0.5356 (+0.0460)0.3376 (+0.0767)0.6074 (+0.1878)
mrr@100.5286 (+0.0511)0.5410 (+0.0411)0.6151 (+0.1884)
ndcg@100.6078 (+0.0674)0.3887 (+0.0636)0.6535 (+0.1529)
Cross Encoder Nano BEIR
json
  {
      "dataset_names": [
          "msmarco",
          "nfcorpus",
          "nq"
      ],
      "rerank_k": 100,
      "at_k": 10,
      "always_rerank_positives": true
  }
MetricValue
map0.4935 (+0.1035)
mrr@100.5615 (+0.0935)
ndcg@100.5500 (+0.0946)

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • —Size: 167,227 training samples
  • —Columns: <code>query</code>, <code>docs</code>, and <code>labels</code>
  • —Approximate statistics based on the first 1000 samples: | | query | docs | labels | |:--------|:-----------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------| | type | string | list | list | | details | <ul><li>min: 11 characters</li><li>mean: 33.92 characters</li><li>max: 97 characters</li></ul> | <ul><li>min: 3 elements</li><li>mean: 6.50 elements</li><li>max: 10 elements</li></ul> | <ul><li>min: 3 elements</li><li>mean: 6.50 elements</li><li>max: 10 elements</li></ul> |
  • —Samples: | query | docs | labels | |:---------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------| | <code>what is a natural hormone replacement</code> | <code>['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...</code> | <code>[1, 0, 0, 0, 0, ...]</code> | | <code>what is ras</code> | <code>["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...</code> | <code>[1, 0, 0, 0, 0, ...]</code> | | <code>does laila engaged to meera's brother</code> | <code>['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 ...</code> | <code>[1, 0, 0, 0, 0, ...]</code> |
  • —Loss: <code>LambdaLoss</code> with these parameters:
json
  {
      "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: <code>query</code>, <code>docs</code>, and <code>labels</code>
  • —Approximate statistics based on the first 1000 samples: | | query | docs | labels | |:--------|:------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------| | type | string | list | list | | details | <ul><li>min: 11 characters</li><li>mean: 34.41 characters</li><li>max: 102 characters</li></ul> | <ul><li>min: 3 elements</li><li>mean: 6.50 elements</li><li>max: 10 elements</li></ul> | <ul><li>min: 3 elements</li><li>mean: 6.50 elements</li><li>max: 10 elements</li></ul> |
  • —Samples: | query | docs | labels | |:---------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------| | <code>what is the medicine called for tonsillitis</code> | <code>['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...</code> | <code>[1, 0, 0, 0, 0, ...]</code> | | <code>is candida contagious</code> | <code>['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...</code> | <code>[1, 0, 0, 0, 0, ...]</code> | | <code>what helps runny nose from allergies</code> | <code>['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...</code> | <code>[1, 0, 0, 0, 0, ...]</code> |
  • —Loss: <code>LambdaLoss</code> with these parameters:
json
  {
      "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: 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

<details><summary>Click to expand</summary>

  • —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: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': 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

</details>

Training Logs

EpochStepTraining LossValidation LossNanoMSMARCO_R100_ndcg@10NanoNFCorpus_R100_ndcg@10NanoNQ_R100_ndcg@10NanoBEIR_R100_mean_ndcg@10
-1-1--0.0186 (-0.5218)0.2310 (-0.0940)0.0644 (-0.4363)0.1047 (-0.3507)
0.000111.4366-----
0.02392501.4817-----
0.04785001.40321.27540.4899 (-0.0505)0.3961 (+0.0711)0.5825 (+0.0818)0.4895 (+0.0341)
0.07187501.2631-----
0.095710001.20331.15340.5655 (+0.0251)0.3973 (+0.0723)0.6528 (+0.1521)0.5385 (+0.0832)
0.119612501.17-----
0.143515001.14251.09540.5939 (+0.0535)0.4027 (+0.0776)0.6343 (+0.1337)0.5436 (+0.0883)
0.167417501.1379-----
0.191420001.11881.08210.5835 (+0.0431)0.4002 (+0.0751)0.6518 (+0.1511)0.5452 (+0.0898)
0.215322501.1084-----
0.239225001.10151.06530.6078 (+0.0674)0.3887 (+0.0636)0.6535 (+0.1529)0.5500 (+0.0946)
0.263127501.0938-----
0.287030001.09031.05610.5836 (+0.0432)0.3776 (+0.0525)0.6557 (+0.1550)0.5389 (+0.0836)
0.310932501.1009-----
0.334935001.06381.04530.5974 (+0.0570)0.3795 (+0.0545)0.6468 (+0.1462)0.5412 (+0.0859)
0.358837501.0846-----
0.382740001.07961.04850.5971 (+0.0567)0.3734 (+0.0484)0.6326 (+0.1320)0.5344 (+0.0790)
0.406642501.076-----
0.430545001.06611.03830.5912 (+0.0507)0.3748 (+0.0498)0.6223 (+0.1217)0.5294 (+0.0741)
0.454547501.0429-----
0.478450001.04981.03610.5990 (+0.0586)0.3829 (+0.0579)0.6378 (+0.1372)0.5399 (+0.0845)
0.502352501.0663-----
0.526255001.03761.02880.6045 (+0.0640)0.3786 (+0.0535)0.6437 (+0.1431)0.5423 (+0.0869)
0.550157501.0347-----
0.574160001.02991.03170.5914 (+0.0510)0.3797 (+0.0547)0.6447 (+0.1441)0.5386 (+0.0833)
0.598062501.0448-----
0.621965001.04431.02810.5860 (+0.0456)0.3623 (+0.0372)0.6291 (+0.1285)0.5258 (+0.0704)
0.645867501.0129-----
0.669770001.03881.02080.5857 (+0.0453)0.3625 (+0.0375)0.6233 (+0.1226)0.5238 (+0.0685)
0.693672501.0402-----
0.717675001.03521.01580.5777 (+0.0372)0.3725 (+0.0475)0.6476 (+0.1469)0.5326 (+0.0772)
0.741577501.0328-----
0.765480001.00221.01560.5817 (+0.0413)0.3537 (+0.0287)0.6358 (+0.1351)0.5237 (+0.0684)
0.789382501.0175-----
0.813285001.02560.99950.5830 (+0.0426)0.3647 (+0.0397)0.6531 (+0.1524)0.5336 (+0.0782)
0.837287501.0209-----
0.861190001.02331.01040.5830 (+0.0426)0.3798 (+0.0548)0.6592 (+0.1585)0.5407 (+0.0853)
0.885092501.0247-----
0.908995001.00571.00890.5887 (+0.0483)0.3705 (+0.0455)0.6387 (+0.1381)0.5327 (+0.0773)
0.932897501.0124-----
0.9568100001.02091.01000.5837 (+0.0432)0.3765 (+0.0514)0.6377 (+0.1371)0.5326 (+0.0772)
0.9807102501.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
bibtex
@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
bibtex
@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}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->