--- language: - en tags: - sentence-transformers - cross-encoder - generated_from_trainer - dataset_size:78704 - loss:PListMLELoss base_model: microsoft/MiniLM-L12-H384-uncased datasets: - microsoft/ms_marco pipeline_tag: text-ranking library_name: sentence-transformers metrics: - map - mrr@10 - ndcg@10 co2_eq_emissions: emissions: 91.35802448505943 energy_consumed: 0.23503358481577002 source: codecarbon training_type: fine-tuning on_cloud: false cpu_model: 13th Gen Intel(R) Core(TM) i7-13700K ram_total_size: 31.777088165283203 hours_used: 0.881 hardware_used: 1 x NVIDIA GeForce RTX 3090 model-index: - name: CrossEncoder based on microsoft/MiniLM-L12-H384-uncased results: - task: type: cross-encoder-reranking name: Cross Encoder Reranking dataset: name: NanoMSMARCO R100 type: NanoMSMARCO_R100 metrics: - type: map value: 0.4779 name: Map - type: mrr@10 value: 0.4676 name: Mrr@10 - type: ndcg@10 value: 0.5461 name: Ndcg@10 - task: type: cross-encoder-reranking name: Cross Encoder Reranking dataset: name: NanoNFCorpus R100 type: NanoNFCorpus_R100 metrics: - type: map value: 0.3322 name: Map - type: mrr@10 value: 0.5765 name: Mrr@10 - type: ndcg@10 value: 0.3701 name: Ndcg@10 - task: type: cross-encoder-reranking name: Cross Encoder Reranking dataset: name: NanoNQ R100 type: NanoNQ_R100 metrics: - type: map value: 0.5906 name: Map - type: mrr@10 value: 0.5981 name: Mrr@10 - type: ndcg@10 value: 0.6559 name: Ndcg@10 - task: type: cross-encoder-nano-beir name: Cross Encoder Nano BEIR dataset: name: NanoBEIR R100 mean type: NanoBEIR_R100_mean metrics: - type: map value: 0.4669 name: Map - type: mrr@10 value: 0.5474 name: Mrr@10 - type: ndcg@10 value: 0.524 name: Ndcg@10 --- # CrossEncoder based on microsoft/MiniLM-L12-H384-uncased This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [microsoft/MiniLM-L12-H384-uncased](https://huggingface.co/microsoft/MiniLM-L12-H384-uncased) on the [ms_marco](https://huggingface.co/datasets/microsoft/ms_marco) dataset using the [sentence-transformers](https://www.SBERT.net) 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](https://huggingface.co/microsoft/MiniLM-L12-H384-uncased) - **Maximum Sequence Length:** 512 tokens - **Number of Output Labels:** 1 label - **Training Dataset:** - [ms_marco](https://huggingface.co/datasets/microsoft/ms_marco) - **Language:** en ### Model Sources - **Documentation:** [Sentence Transformers Documentation](https://sbert.net) - **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html) - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers) - **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder) ## 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("tomaarsen/reranker-msmarco-v1.1-MiniLM-L12-H384-uncased-plistmle-sum-to-1") # 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` and `NanoNQ_R100` * Evaluated with [CrossEncoderRerankingEvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderRerankingEvaluator) with these parameters: ```json { "at_k": 10, "always_rerank_positives": true } ``` | Metric | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 | |:------------|:---------------------|:---------------------|:---------------------| | map | 0.4779 (-0.0116) | 0.3322 (+0.0712) | 0.5906 (+0.1710) | | mrr@10 | 0.4676 (-0.0099) | 0.5765 (+0.0767) | 0.5981 (+0.1714) | | **ndcg@10** | **0.5461 (+0.0057)** | **0.3701 (+0.0450)** | **0.6559 (+0.1552)** | #### Cross Encoder Nano BEIR * Dataset: `NanoBEIR_R100_mean` * Evaluated with [CrossEncoderNanoBEIREvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderNanoBEIREvaluator) with these parameters: ```json { "dataset_names": [ "msmarco", "nfcorpus", "nq" ], "rerank_k": 100, "at_k": 10, "always_rerank_positives": true } ``` | Metric | Value | |:------------|:---------------------| | map | 0.4669 (+0.0768) | | mrr@10 | 0.5474 (+0.0794) | | **ndcg@10** | **0.5240 (+0.0686)** | ## Training Details ### Training Dataset #### ms_marco * Dataset: [ms_marco](https://huggingface.co/datasets/microsoft/ms_marco) at [a47ee7a](https://huggingface.co/datasets/microsoft/ms_marco/tree/a47ee7aae8d7d466ba15f9f0bfac3b3681087b3a) * Size: 78,704 training samples * Columns: query, docs, and labels * Approximate statistics based on the first 1000 samples: | | query | docs | labels | |:--------|:-----------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------| | type | string | list | list | | details | | | | * Samples: | query | docs | labels | |:-------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------| | what does it cost to remove a tree stump | ['Stump removal costs will vary depending on a variety of things, most notably whether you do it yourself or hire a professional. By learning about the costs and prices associated with removing a tree stump, you will avoid unpleasant surprises. Learn more about stump removal prices with our cost guide below. The average cost to remove a tree stump ranges from $60 to $350 per stump, depending on various factors like size. The average removal cost breaks down to approximately $2 to $3 per diameter of the stump. If you do it yourself, it may only cost you about $75 to $150.', 'Get an INSTANT estimate of the cost to Grind a Large Tree Stump! Our free calculator uses recent, trusted data to estimate costs for your Large Stump Grinding project. For a basic 1 stump project in zip code 47474, the benchmark cost to Grind a Large Tree Stump ranges between $87.22 - $150.54 per stump.', 'Tree limb removal costs vary, but it is usually between $50 and $75. Additional services that may be added on f... | [1, 0, 0, 0, 0, ...] | | what is the currency used in tenerife | ['Language: The language spoken in Tenerife is Spanish. Currency: The currency used in Tenerife is Euro (€). Local time: Tenerife is 1 hour ahead of GMT/UK time. Fly to: Tenerife has two airports. Tenerife South, near the island’s most popular resorts, is larger and busier than Tenerife North, which is about 11km west of the capital. Tenerife is the largest and most developed Canary Island. Attractive beaches, watersports and exciting adventures to Loro Parque, Siam Park and the cliffs of Los Gigantes make holidays to Tenerife popular year after year, offering activities for everyone to enjoy.', 'Due to Tenerife being a part of Spain, the currency is the Euro. 1 The Pegged Exchange Rate and Modern Money Markets A pegged exchange rate is used when a government fixes the exchange rate of its currency for other currencies, and is also called a fixed exchange rate.', 'Santa Cruz The capital of Tenerife is Santa Cruz de Tenerife which is also, together with Las Palmas on Gran Canaria, the c... | [1, 0, 0, 0, 0, ...] | | what is the average salary for a tax consultant | ['According to a salary survey, a tax consultant earns almost $325,000 per year on an average. This is applicable for the period 2008 to 2012. And at present, the average salary for a tax consultant in UK is £38,500. In this nation, working 250 days a year and 8 hours a day fetches an hourly rate of £20.18. Overall, the hourly rate actually depends on how much messy the work is and how highly qualified a tax consultant is! The factors that affect the hourly pay rate for tax consultant are the area in which the consultant is operating, experience level, complexity of tax return, and the type of company for whom the service is provided. A CPA candidate or a staff bookkeeper would get almost $65-$85 per hour for sorting out the receipts.', 'With regard to age and impact on salary for a Tax Consultant, a statistical average weighting (that is based on how salary varies by age and not for a specific job which may vary considerably) suggests these figures: £30,560 for a worker in their 20s, ... | [1, 0, 0, 0, 0, ...] | * Loss: [PListMLELoss](https://sbert.net/docs/package_reference/cross_encoder/losses.html#plistmleloss) with these parameters: ```json { "lambda_weight": "sentence_transformers.cross_encoder.losses.PListMLELoss.PListMLELambdaWeight", "activation_fct": "torch.nn.modules.linear.Identity", "mini_batch_size": 16, "respect_input_order": true } ``` ### Evaluation Dataset #### ms_marco * Dataset: [ms_marco](https://huggingface.co/datasets/microsoft/ms_marco) at [a47ee7a](https://huggingface.co/datasets/microsoft/ms_marco/tree/a47ee7aae8d7d466ba15f9f0bfac3b3681087b3a) * Size: 1,000 evaluation samples * Columns: query, docs, and labels * Approximate statistics based on the first 1000 samples: | | query | docs | labels | |:--------|:-----------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------| | type | string | list | list | | details | | | | * Samples: | query | docs | labels | |:----------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------| | what is mosfet transistor | ['Mosfet Transistor. A MOSFET transistor is a semiconductor device which is widely used to switch the amplification signals in the electronic devices. MOSFET can be expanded metal-oxide-semiconductor field-effect transistor that is used to influence the flow of electric charges by influencing the flow of the charges to greater extent. The major advantage of the MOSFET transistor is that it uses low power for accomplishing its purpose and the dissipation of power in terms of loss is very llittle, which makes it a major component in the modern computers and electronic devices like the cell phones, digital watches, small robotic toys and calculators.', 'A transistor is used to amplify and switch electronic signals and electrical power. They are used in a variety of circuits and they come in many different shapes. You can use a transistor as a switch or you can use a transistor as an amplifier. Metal-oxide-semiconductor field-effect transistor is a type of transistor commonly found in digi... | [1, 0, 0, 0, 0, ...] | | what was the most famous native american massacres | ["The Massacre at Bear River took place in 1863 when heightened tensions between the Native Americans and federal troops from the California reserves reached a tipping point. Remembering those passed: Patty Timbimboo-Madsen is a descendant of one of the few survivors from the Bear River Massacre which took place in 1863. Native Americans remember 'forgotten' massacre that left 450 dead in vicious attack during the Civil War. By Daily Mail Reporter. Published: 00:47 EST, 30 January 2013 | Updated: 01:00 EST, 30 January 2013.", "While the Native Americans had collected a few firearms from various raids on other villages, their weapons were nothing compared to the guns used by the soldiers. Because this battle took place in the midst of the Civil War, Colonel Connor's men from the California Volunteers were armed with federally-issued guns. Native Americans remember 'forgotten' massacre that left 450 dead in vicious attack during the Civil War. By Daily Mail Reporter. Published: 00:47 EST... | [1, 0, 0, 0, 0, ...] | | where is canberra located | ["168 pages on this wiki. Canberra is the capital city of Australia and with a population of over 332,000, is Australia's largest inland city. The city is located at the northern end of the Australian Capital Territory, 300 kilometres (190 mi) southwest of Sydney, and 650 kilometres (400 mi) north-east of Melbourne. ", "it looks as though the author of this plan ... had been carefully reading books upon town planning without having much more theoretical knowledge to go upon. Canberra, in the Australian Capital Territory, is Australia's capital city. ", 'Canberra is a city/town with a medium population in the state/region of Australian Capital Territory, Australia which is located in the continent/region of Oceania. Cities, towns and places near Canberra include City, Reid, Braddon and Turner. ', 'History [edit]. Canberra was established in 1913 as the capital for the newly federated Australian nation. The ACT was excised from New South Wales and put under the control of the federal gov... | [1, 0, 0, 0, 0, ...] | * Loss: [PListMLELoss](https://sbert.net/docs/package_reference/cross_encoder/losses.html#plistmleloss) with these parameters: ```json { "lambda_weight": "sentence_transformers.cross_encoder.losses.PListMLELoss.PListMLELambdaWeight", "activation_fct": "torch.nn.modules.linear.Identity", "mini_batch_size": 16, "respect_input_order": true } ``` ### 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} - `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.0293 (-0.5111) | 0.2379 (-0.0872) | 0.0249 (-0.4757) | 0.0974 (-0.3580) | | 0.0002 | 1 | 2.1926 | - | - | - | - | - | | 0.0508 | 250 | 2.1 | - | - | - | - | - | | 0.1016 | 500 | 1.9636 | 1.9124 | 0.2430 (-0.2975) | 0.2494 (-0.0756) | 0.3521 (-0.1486) | 0.2815 (-0.1739) | | 0.1525 | 750 | 1.9151 | - | - | - | - | - | | 0.2033 | 1000 | 1.8844 | 1.8574 | 0.4329 (-0.1076) | 0.3198 (-0.0053) | 0.6016 (+0.1009) | 0.4514 (-0.0040) | | 0.2541 | 1250 | 1.8748 | - | - | - | - | - | | 0.3049 | 1500 | 1.8636 | 1.8745 | 0.5198 (-0.0206) | 0.3698 (+0.0447) | 0.6365 (+0.1358) | 0.5087 (+0.0533) | | 0.3558 | 1750 | 1.854 | - | - | - | - | - | | 0.4066 | 2000 | 1.8437 | 1.8239 | 0.4936 (-0.0469) | 0.3820 (+0.0570) | 0.6065 (+0.1059) | 0.4940 (+0.0387) | | 0.4574 | 2250 | 1.843 | - | - | - | - | - | | 0.5082 | 2500 | 1.8509 | 1.8222 | 0.5435 (+0.0031) | 0.3720 (+0.0469) | 0.6201 (+0.1195) | 0.5119 (+0.0565) | | 0.5591 | 2750 | 1.842 | - | - | - | - | - | | 0.6099 | 3000 | 1.83 | 1.8252 | 0.5303 (-0.0101) | 0.3629 (+0.0379) | 0.6177 (+0.1171) | 0.5037 (+0.0483) | | 0.6607 | 3250 | 1.8293 | - | - | - | - | - | | **0.7115** | **3500** | **1.8254** | **1.8177** | **0.5461 (+0.0057)** | **0.3701 (+0.0450)** | **0.6559 (+0.1552)** | **0.5240 (+0.0686)** | | 0.7624 | 3750 | 1.8163 | - | - | - | - | - | | 0.8132 | 4000 | 1.8338 | 1.8092 | 0.5555 (+0.0151) | 0.3650 (+0.0400) | 0.6347 (+0.1340) | 0.5184 (+0.0630) | | 0.8640 | 4250 | 1.8233 | - | - | - | - | - | | 0.9148 | 4500 | 1.8127 | 1.8116 | 0.5512 (+0.0108) | 0.3737 (+0.0487) | 0.6424 (+0.1417) | 0.5224 (+0.0671) | | 0.9656 | 4750 | 1.8255 | - | - | - | - | - | | -1 | -1 | - | - | 0.5461 (+0.0057) | 0.3701 (+0.0450) | 0.6559 (+0.1552) | 0.5240 (+0.0686) | * The bold row denotes the saved checkpoint. ### Environmental Impact Carbon emissions were measured using [CodeCarbon](https://github.com/mlco2/codecarbon). - **Energy Consumed**: 0.235 kWh - **Carbon Emitted**: 0.091 kg of CO2 - **Hours Used**: 0.881 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.5.1 - Datasets: 3.3.2 - 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", } ``` #### PListMLELoss ```bibtex @inproceedings{lan2014position, title={Position-Aware ListMLE: A Sequential Learning Process for Ranking.}, author={Lan, Yanyan and Zhu, Yadong and Guo, Jiafeng and Niu, Shuzi and Cheng, Xueqi}, booktitle={UAI}, volume={14}, pages={449--458}, year={2014} } ```