--- language: - en tags: - sentence-transformers - cross-encoder - text-classification - generated_from_trainer - dataset_size:397226027 - loss:BinaryCrossEntropyLoss base_model: microsoft/MiniLM-L12-H384-uncased datasets: - sentence-transformers/msmarco pipeline_tag: text-classification library_name: sentence-transformers metrics: - map - mrr@10 - ndcg@10 model-index: - name: CrossEncoder based on microsoft/MiniLM-L12-H384-uncased results: [] --- # 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-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled) dataset using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more. ## 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-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled) - **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-MiniLM-L12-H384-uncased-msmarco-bce") # Get scores for pairs of texts pairs = [ ['what is a jewel yam', 'Wild Yam can be very beneficial for nervousness, restlessness and other nervous conditions. As a stimulant for increased bile flow, it can help to relieve hepatic congestion, bilious colic and gallstones.'], ['hours of daytona', '24 Hours of Daytona. The 24 Hours of Daytona, currently known as the Rolex 24 At Daytona for sponsorship reasons, is a 24-hour sports car endurance race held annually at Daytona International Speedway in Daytona Beach, Florida. It is run on a 3.56-mile (5.73 km) combined road course, utilizing portions of the NASCAR tri-oval and an infield road course.'], ['how much do autozone workers get paid', 'The typical AutoZone Sales Associate salary is $9. Sales Associate salaries at AutoZone can range from $7-$12. This estimate is based upon 59 AutoZone Sales Associate salary report(s) provided by employees or estimated based upon statistical methods. See all Sales Associate salaries to learn how this stacks up in the market.'], ['what are the special sensory receptors', 'Sensory Neurons. Sensory Neurons: + add to my flashcards cite this term. You have a few different types of neurons in your body including interneurons, motor neurons, and sensory neurons. Sensory neurons (also known as Afferent Neurons) are responsible for bringing information from sensory receptors (like the nerves in your hand) to the central nervous system (spinal cord and brain).'], ['how long to cook salmon on the grill', 'Place the bag with the marinade and salmon fillets in the refrigerator for 30 minutes. 1 Salmon, like all fish, is not as dense as red meats and poultry. 2 As a result, it does not need to be marinaded for long in order to absorb flavor.3 Remove the salmon from the refrigerator at least 10 minutes prior to cooking.lace the broiler pan 5 1/2 inches (14 cm) away from the top heating element and cook the salmon until done. 1 The salmon is done when you can effortlessly flake the fillets with a fork. 2 The center should be opaque.'], ] scores = model.predict(pairs) print(scores.shape) # (5,) # Or rank different texts based on similarity to a single text ranks = model.rank( 'what is a jewel yam', [ 'Wild Yam can be very beneficial for nervousness, restlessness and other nervous conditions. As a stimulant for increased bile flow, it can help to relieve hepatic congestion, bilious colic and gallstones.', '24 Hours of Daytona. The 24 Hours of Daytona, currently known as the Rolex 24 At Daytona for sponsorship reasons, is a 24-hour sports car endurance race held annually at Daytona International Speedway in Daytona Beach, Florida. It is run on a 3.56-mile (5.73 km) combined road course, utilizing portions of the NASCAR tri-oval and an infield road course.', 'The typical AutoZone Sales Associate salary is $9. Sales Associate salaries at AutoZone can range from $7-$12. This estimate is based upon 59 AutoZone Sales Associate salary report(s) provided by employees or estimated based upon statistical methods. See all Sales Associate salaries to learn how this stacks up in the market.', 'Sensory Neurons. Sensory Neurons: + add to my flashcards cite this term. You have a few different types of neurons in your body including interneurons, motor neurons, and sensory neurons. Sensory neurons (also known as Afferent Neurons) are responsible for bringing information from sensory receptors (like the nerves in your hand) to the central nervous system (spinal cord and brain).', 'Place the bag with the marinade and salmon fillets in the refrigerator for 30 minutes. 1 Salmon, like all fish, is not as dense as red meats and poultry. 2 As a result, it does not need to be marinaded for long in order to absorb flavor.3 Remove the salmon from the refrigerator at least 10 minutes prior to cooking.lace the broiler pan 5 1/2 inches (14 cm) away from the top heating element and cook the salmon until done. 1 The salmon is done when you can effortlessly flake the fillets with a fork. 2 The center should be opaque.', ] ) # [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...] ``` ## Evaluation ### Metrics #### Cross Encoder Reranking * Datasets: `NanoMSMARCO`, `NanoNFCorpus` and `NanoNQ` * Evaluated with [CERerankingEvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CERerankingEvaluator) | Metric | NanoMSMARCO | NanoNFCorpus | NanoNQ | |:------------|:---------------------|:---------------------|:---------------------| | map | 0.6127 (+0.1231) | 0.3432 (+0.0728) | 0.6921 (+0.2715) | | mrr@10 | 0.6019 (+0.1244) | 0.5456 (+0.0457) | 0.7062 (+0.2795) | | **ndcg@10** | **0.6648 (+0.1244)** | **0.3769 (+0.0519)** | **0.7462 (+0.2455)** | #### Cross Encoder Nano BEIR * Dataset: `NanoBEIR_mean` * Evaluated with [CENanoBEIREvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CENanoBEIREvaluator) | Metric | Value | |:------------|:---------------------| | map | 0.5493 (+0.1558) | | mrr@10 | 0.6179 (+0.1499) | | **ndcg@10** | **0.5960 (+0.1406)** | ## Training Details ### Training Dataset #### ms-marco-shuffled * Dataset: [ms-marco-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled) at [88847c6](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled/tree/88847c65252168a8c2504664289ef21a9df0ca74) * Size: 397,226,027 training samples * Columns: query, passage, and score * Approximate statistics based on the first 1000 samples: | | query | passage | score | |:--------|:------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|:---------------------------------------------------------------| | type | string | string | float | | details | | | | * Samples: | query | passage | score | |:------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| | when was ron marhofer founded? | What are the birthdays of Ron Shirley Bobby Brantley and Amy Shirley from Lizard Lick Towing? Ron Shirley's birthday is April 13. His wife Amy Shirley celebrates her birthday on May 4, and Bobby Brantley's birthday is September 26. | 0.0 | | what should the average medical assistant make | For example, the Bureau of Labor Statistics reports that as of May 2014, medical assistant jobs located in Offices of Physicians paid about $31,230 a year on average c. These roles (in Offices of Physicians) made up a large portion of medical assistant jobs, totaling 349,370 positions as of May 2014 c. General Medical and Surgical hospitals were another large employer, carrying 85,040 medical assistants c on their payrolls. | 1.0 | | what type of rock form in warm ocean bottoms | Second, sedimentary rocks form on the bottom of the ocean when particles rain down from the surface. These particles can become compressed and cemented to form limestone. Fossilized sea creatures are often found in these rocks. Most of the mountains around Las Vegas are composed of sedimentary rocks. Red Rock Canyon (photo) provides a spectacular example of both types: the gray mountains are limestone, and the red-and-white hills are sandstone. | 1.0 | * Loss: [BinaryCrossEntropyLoss](https://sbert.net/docs/package_reference/cross_encoder/losses.html#binarycrossentropyloss) with these parameters: ```json { "activation_fct": "torch.nn.modules.linear.Identity", "pos_weight": null } ``` ### Evaluation Dataset #### ms-marco-shuffled * Dataset: [ms-marco-shuffled](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled) at [88847c6](https://huggingface.co/datasets/tomaarsen/ms-marco-shuffled/tree/88847c65252168a8c2504664289ef21a9df0ca74) * Size: 397,226,027 evaluation samples * Columns: query, passage, and score * Approximate statistics based on the first 1000 samples: | | query | passage | score | |:--------|:------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|:--------------------------------------------------------------| | type | string | string | float | | details | | | | * Samples: | query | passage | score | |:---------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| | what is a jewel yam | Wild Yam can be very beneficial for nervousness, restlessness and other nervous conditions. As a stimulant for increased bile flow, it can help to relieve hepatic congestion, bilious colic and gallstones. | 0.0 | | hours of daytona | 24 Hours of Daytona. The 24 Hours of Daytona, currently known as the Rolex 24 At Daytona for sponsorship reasons, is a 24-hour sports car endurance race held annually at Daytona International Speedway in Daytona Beach, Florida. It is run on a 3.56-mile (5.73 km) combined road course, utilizing portions of the NASCAR tri-oval and an infield road course. | 1.0 | | how much do autozone workers get paid | The typical AutoZone Sales Associate salary is $9. Sales Associate salaries at AutoZone can range from $7-$12. This estimate is based upon 59 AutoZone Sales Associate salary report(s) provided by employees or estimated based upon statistical methods. See all Sales Associate salaries to learn how this stacks up in the market. | 1.0 | * Loss: [BinaryCrossEntropyLoss](https://sbert.net/docs/package_reference/cross_encoder/losses.html#binarycrossentropyloss) with these parameters: ```json { "activation_fct": "torch.nn.modules.linear.Identity", "pos_weight": null } ``` ### Training Hyperparameters #### Non-Default Hyperparameters - `eval_strategy`: steps - `per_device_train_batch_size`: 64 - `per_device_eval_batch_size`: 64 - `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`: 64 - `per_device_eval_batch_size`: 64 - `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_ndcg@10 | NanoNFCorpus_ndcg@10 | NanoNQ_ndcg@10 | NanoBEIR_mean_ndcg@10 | |:----------:|:---------:|:-------------:|:---------------:|:--------------------:|:--------------------:|:--------------------:|:---------------------:| | -1 | -1 | - | - | 0.0324 (-0.5080) | 0.2439 (-0.0811) | 0.0361 (-0.4646) | 0.1041 (-0.3512) | | 0.0000 | 1 | 0.6941 | - | - | - | - | - | | 0.0322 | 1000 | 0.5117 | - | - | - | - | - | | 0.0643 | 2000 | 0.2604 | - | - | - | - | - | | 0.0965 | 3000 | 0.2258 | - | - | - | - | - | | 0.1286 | 4000 | 0.2115 | - | - | - | - | - | | 0.1608 | 5000 | 0.1995 | 0.1879 | 0.6145 (+0.0741) | 0.4002 (+0.0751) | 0.6970 (+0.1964) | 0.5706 (+0.1152) | | 0.1930 | 6000 | 0.1924 | - | - | - | - | - | | 0.2251 | 7000 | 0.1914 | - | - | - | - | - | | 0.2573 | 8000 | 0.1859 | - | - | - | - | - | | 0.2894 | 9000 | 0.1802 | - | - | - | - | - | | 0.3216 | 10000 | 0.1791 | 0.1628 | 0.6311 (+0.0906) | 0.3795 (+0.0545) | 0.7347 (+0.2341) | 0.5818 (+0.1264) | | 0.3538 | 11000 | 0.1732 | - | - | - | - | - | | 0.3859 | 12000 | 0.1713 | - | - | - | - | - | | 0.4181 | 13000 | 0.1756 | - | - | - | - | - | | 0.4502 | 14000 | 0.1643 | - | - | - | - | - | | 0.4824 | 15000 | 0.166 | 0.1531 | 0.6540 (+0.1136) | 0.3830 (+0.0579) | 0.7315 (+0.2309) | 0.5895 (+0.1341) | | 0.5146 | 16000 | 0.161 | - | - | - | - | - | | 0.5467 | 17000 | 0.1617 | - | - | - | - | - | | 0.5789 | 18000 | 0.1612 | - | - | - | - | - | | 0.6111 | 19000 | 0.1591 | - | - | - | - | - | | **0.6432** | **20000** | **0.1599** | **0.1428** | **0.6648 (+0.1244)** | **0.3769 (+0.0519)** | **0.7462 (+0.2455)** | **0.5960 (+0.1406)** | | 0.6754 | 21000 | 0.1599 | - | - | - | - | - | | 0.7075 | 22000 | 0.1523 | - | - | - | - | - | | 0.7397 | 23000 | 0.1525 | - | - | - | - | - | | 0.7719 | 24000 | 0.1549 | - | - | - | - | - | | 0.8040 | 25000 | 0.1515 | 0.1386 | 0.6682 (+0.1278) | 0.3686 (+0.0436) | 0.7481 (+0.2474) | 0.5950 (+0.1396) | | 0.8362 | 26000 | 0.1556 | - | - | - | - | - | | 0.8683 | 27000 | 0.1501 | - | - | - | - | - | | 0.9005 | 28000 | 0.1522 | - | - | - | - | - | | 0.9327 | 29000 | 0.1493 | - | - | - | - | - | | 0.9648 | 30000 | 0.1509 | 0.1354 | 0.6805 (+0.1400) | 0.3593 (+0.0343) | 0.7439 (+0.2433) | 0.5946 (+0.1392) | | 0.9970 | 31000 | 0.1481 | - | - | - | - | - | | -1 | -1 | - | - | 0.6648 (+0.1244) | 0.3769 (+0.0519) | 0.7462 (+0.2455) | 0.5960 (+0.1406) | * The bold row denotes the saved checkpoint. ### Framework Versions - Python: 3.11.10 - Sentence Transformers: 3.5.0.dev0 - Transformers: 4.49.0.dev0 - PyTorch: 2.6.0.dev20241112+cu121 - Accelerate: 1.2.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", } ```