---
language:
- en
tags:
- sentence-transformers
- cross-encoder
- generated_from_trainer
- dataset_size:1990000
- loss:BinaryCrossEntropyLoss
base_model: microsoft/MiniLM-L12-H384-uncased
datasets:
- sentence-transformers/msmarco
pipeline_tag: text-ranking
library_name: sentence-transformers
metrics:
- map
- mrr@10
- ndcg@10
co2_eq_emissions:
emissions: 248.14981796615854
energy_consumed: 0.63840633175584
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: 2.404
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.5585
name: Map
- type: mrr@10
value: 0.5533
name: Mrr@10
- type: ndcg@10
value: 0.6413
name: Ndcg@10
- task:
type: cross-encoder-reranking
name: Cross Encoder Reranking
dataset:
name: NanoNFCorpus R100
type: NanoNFCorpus_R100
metrics:
- type: map
value: 0.3318
name: Map
- type: mrr@10
value: 0.5174
name: Mrr@10
- type: ndcg@10
value: 0.3979
name: Ndcg@10
- task:
type: cross-encoder-reranking
name: Cross Encoder Reranking
dataset:
name: NanoNQ R100
type: NanoNQ_R100
metrics:
- type: map
value: 0.6943
name: Map
- type: mrr@10
value: 0.7187
name: Mrr@10
- type: ndcg@10
value: 0.7395
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.5282
name: Map
- type: mrr@10
value: 0.5964
name: Mrr@10
- type: ndcg@10
value: 0.5929
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 [msmarco](https://huggingface.co/datasets/sentence-transformers/msmarco) 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:**
- [msmarco](https://huggingface.co/datasets/sentence-transformers/msmarco)
- **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 = [
['cost to repair a manifold gasket', 'Parts. The cost of the parts required to repair or replace your intake manifold gasket ranges from $25 to $100 in 2010, according to RepairPal, depending on the year and make of your car. This range applies if you have a 2005 Ford Taurus or a 2011 BMW 750Li.'],
['what county is salisbury missouri in', 'The St. Louis County, Missouri sales tax is 7.11% , consisting of 4.23% Missouri state sales tax and 2.89% St. Louis County local sales taxes.The local sales tax consists of a 1.64% county sales tax and a 1.25% special district sales tax (used to fund transportation districts, local attractions, etc). St. Louis County Missouri Sales Tax Exemptions.'],
['what is life expectancy for someone with lung cancer', 'The two general types of lung cancer include: Small cell lung cancer. Small cell lung cancer occurs almost exclusively in heavy smokers and is less common than non-small cell lung cancer. Non-small cell lung cancer. Non-small cell lung cancer is an umbrella term for several types of lung cancers that behave in a similar way. Non-small cell lung cancers include squamous cell carcinoma, adenocarcinoma and large cell carcinoma.'],
['where does the zambezi river start', 'Where is Zimbabwe? Zimbabwe lies between the Limpopo and Zambezi rivers in south central Africa. It is bounded by Zambia (797km) in the north and northwest, by South Africa (225km) in the south by Mozambique(1 231km) in the east and north-east, and by Botswana (813km)in the south-west. It has no coastline and is totally landlocked.'],
['what is a lichen moth', 'Understanding Oral Lichen Planus. Oral lichen planus can occur anywhere inside the mouth, but is usually seen on the inside of the cheeks and appears as thin white lines, patches, or dots. It is most common between the ages of 30 and 60. While it appears in about one to two percent of the population, women get oral lichen planus twice as often as men.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'cost to repair a manifold gasket',
[
'Parts. The cost of the parts required to repair or replace your intake manifold gasket ranges from $25 to $100 in 2010, according to RepairPal, depending on the year and make of your car. This range applies if you have a 2005 Ford Taurus or a 2011 BMW 750Li.',
'The St. Louis County, Missouri sales tax is 7.11% , consisting of 4.23% Missouri state sales tax and 2.89% St. Louis County local sales taxes.The local sales tax consists of a 1.64% county sales tax and a 1.25% special district sales tax (used to fund transportation districts, local attractions, etc). St. Louis County Missouri Sales Tax Exemptions.',
'The two general types of lung cancer include: Small cell lung cancer. Small cell lung cancer occurs almost exclusively in heavy smokers and is less common than non-small cell lung cancer. Non-small cell lung cancer. Non-small cell lung cancer is an umbrella term for several types of lung cancers that behave in a similar way. Non-small cell lung cancers include squamous cell carcinoma, adenocarcinoma and large cell carcinoma.',
'Where is Zimbabwe? Zimbabwe lies between the Limpopo and Zambezi rivers in south central Africa. It is bounded by Zambia (797km) in the north and northwest, by South Africa (225km) in the south by Mozambique(1 231km) in the east and north-east, and by Botswana (813km)in the south-west. It has no coastline and is totally landlocked.',
'Understanding Oral Lichen Planus. Oral lichen planus can occur anywhere inside the mouth, but is usually seen on the inside of the cheeks and appears as thin white lines, patches, or dots. It is most common between the ages of 30 and 60. While it appears in about one to two percent of the population, women get oral lichen planus twice as often as men.',
]
)
# [{'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.5585 (+0.0689) | 0.3318 (+0.0708) | 0.6943 (+0.2747) |
| mrr@10 | 0.5533 (+0.0758) | 0.5174 (+0.0175) | 0.7187 (+0.2920) |
| **ndcg@10** | **0.6413 (+0.1009)** | **0.3979 (+0.0728)** | **0.7395 (+0.2388)** |
#### 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.5282 (+0.1381) |
| mrr@10 | 0.5964 (+0.1284) |
| **ndcg@10** | **0.5929 (+0.1375)** |
## Training Details
### Training Dataset
#### msmarco
* Dataset: [msmarco](https://huggingface.co/datasets/sentence-transformers/msmarco) at [88847c6](https://huggingface.co/datasets/sentence-transformers/msmarco/tree/88847c65252168a8c2504664289ef21a9df0ca74)
* Size: 1,990,000 training samples
* Columns: query, passage, and score
* Approximate statistics based on the first 1000 samples:
| | query | passage | score |
|:--------|:-----------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details |
who is erin anderson? | Erin Anderson is an actress and writer, known for Kittens in a Cage (2015), The Mysteries of Laura (2014) and Insidious: Chapter 3 (2015). | 1.0 |
| how long is a food handlers permit good for in california | If you would like to get your California Food Handler card you will need to successfully pass an approved Food Safety for Handlers course. For how long is the California Food Handler card valid? The California Food Handler card is valid throughout most of the state and is valid for three years from issuance. Each food establishment or business must have records documenting that each of its employees has a valid California Food Handler card that can be provided to local enforcement officials upon request. | 1.0 |
| matagorda tx is in what county | Matagorda is an unincorporated community in Matagorda County, Texas, United States. It had a population of approximately 710 in 2000. Matagorda is at the end of State Highway 60 and beginning of Farm to Market Road 2031, which runs over the Intracoastal Waterway and south to the Gulf of Mexico. The area is popular for fishing and beach activities. The Matagorda Independent School District serves area students. | 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
#### msmarco
* Dataset: [msmarco](https://huggingface.co/datasets/sentence-transformers/msmarco) at [88847c6](https://huggingface.co/datasets/sentence-transformers/msmarco/tree/88847c65252168a8c2504664289ef21a9df0ca74)
* Size: 10,000 evaluation samples
* Columns: query, passage, and score
* Approximate statistics based on the first 1000 samples:
| | query | passage | score |
|:--------|:-----------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|:--------------------------------------------------------------|
| type | string | string | float |
| details | cost to repair a manifold gasket | Parts. The cost of the parts required to repair or replace your intake manifold gasket ranges from $25 to $100 in 2010, according to RepairPal, depending on the year and make of your car. This range applies if you have a 2005 Ford Taurus or a 2011 BMW 750Li. | 1.0 |
| what county is salisbury missouri in | The St. Louis County, Missouri sales tax is 7.11% , consisting of 4.23% Missouri state sales tax and 2.89% St. Louis County local sales taxes.The local sales tax consists of a 1.64% county sales tax and a 1.25% special district sales tax (used to fund transportation districts, local attractions, etc). St. Louis County Missouri Sales Tax Exemptions. | 0.0 |
| what is life expectancy for someone with lung cancer | The two general types of lung cancer include: Small cell lung cancer. Small cell lung cancer occurs almost exclusively in heavy smokers and is less common than non-small cell lung cancer. Non-small cell lung cancer. Non-small cell lung cancer is an umbrella term for several types of lung cancers that behave in a similar way. Non-small cell lung cancers include squamous cell carcinoma, adenocarcinoma and large cell carcinoma. | 0.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`: 16
- `per_device_eval_batch_size`: 16
- `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