---
tags:
- sentence-transformers
- cross-encoder
- reranker
- generated_from_trainer
- dataset_size:9540
- loss:BinaryCrossEntropyLoss
base_model: BAAI/bge-reranker-v2-m3
pipeline_tag: text-ranking
library_name: sentence-transformers
metrics:
- accuracy
- accuracy_threshold
- f1
- f1_threshold
- precision
- recall
- average_precision
model-index:
- name: CrossEncoder based on BAAI/bge-reranker-v2-m3
results:
- task:
type: cross-encoder-binary-classification
name: Cross Encoder Binary Classification
dataset:
name: validation
type: validation
metrics:
- type: accuracy
value: 0.7816091954022989
name: Accuracy
- type: accuracy_threshold
value: 0.0775039941072464
name: Accuracy Threshold
- type: f1
value: 0.8137254901960784
name: F1
- type: f1_threshold
value: 0.0775039941072464
name: F1 Threshold
- type: precision
value: 0.7094017094017094
name: Precision
- type: recall
value: 0.9540229885057471
name: Recall
- type: average_precision
value: 0.8600261622403443
name: Average Precision
- task:
type: cross-encoder-binary-classification
name: Cross Encoder Binary Classification
dataset:
name: train subset
type: train_subset
metrics:
- type: accuracy
value: 0.798
name: Accuracy
- type: accuracy_threshold
value: 0.9965779185295105
name: Accuracy Threshold
- type: f1
value: 0.7877551020408163
name: F1
- type: f1_threshold
value: 0.9961502552032471
name: F1 Threshold
- type: precision
value: 0.7658730158730159
name: Precision
- type: recall
value: 0.8109243697478992
name: Recall
- type: average_precision
value: 0.8489611339196401
name: Average Precision
---
# CrossEncoder based on BAAI/bge-reranker-v2-m3
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [BAAI/bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3) 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:** [BAAI/bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3)
- **Maximum Sequence Length:** 1024 tokens
- **Number of Output Labels:** 1 label
### 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/huggingface/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("cross_encoder_model_id")
# Get scores for pairs of texts
pairs = [
['When did the performer of song That Is All (Song) die?', 'Bill Kaulitz. Bill Kaulitz( born September 1, 1989), also known mononymously as Billy( stylized as BILLY) for his solo act, is a German singer, songwriter, voice actor, designer, and model. He is best known for his work from 2001 to the present as the lead singer of the band Tokio Hotel.'],
['Who was born first, Robert Macnish or Gustavo Dávila?', 'Alonso Mudarra. Alonso Mudarra( c. 1510 – April 1, 1580) was a Spanish composer of the Renaissance, and also played the vihuela, a guitar- shaped string instrument. He was an innovative composer of instrumental music as well as songs, and was the composer of the earliest surviving music for the guitar.'],
['Where was the place of death of the composer of song Ett Gammalt Fult Och Elakt Troll Det Var En Gång?', 'István Pauli. István Pauli or István Pável( July 13, 1760 – January 29, 1829) was a Hungarian Slovene Roman Catholic priests. Pauli or the teacher of Pertoča György Kousz was the author of a hymnal in Pertoča. He was born in Beltinci. His parents was Márk Pável and Katalin Gyrék. In Bratislava, was studied theology and in 1789 ordained. From 1790- 1797, he was the priest of Pertoča. On October 1, 1822, he retired and died in Szombathely.'],
['Are both Tolstoy-Yurt and Ebrahimabad, Jorjafak located in the same country?', 'Ebrahimabad, Jorjafak. Ebrahimabad( also Romanized as Ebrāhīmābād) is a village in Jorjafak Rural District, in the Central District of Zarand County, Kerman Province, Iran. At the 2006 census, its existence was noted, but its population was not reported.'],
['Do both directors of films The Outlaw Deputy and W La Foca share the same nationality?', 'Nando Cicero. Fernando Cicero, better known as Nando Cicero( 22 January 1931 – 30 July 1995), was an Italian film director, screenwriter and actor. Born in Asmara, Cicero debuted as an actor, working with directors such as Luchino Visconti(" Senso", 1953), Roberto Rossellini(" Vanina Vanini", 1961), Francesco Rosi(" Salvatore Giuliano", 1962) and Alberto Lattuada(" La steppa", 1962). He starred in eleven films between 1953 and 1962, always in supporting roles. After his directorial debut with" Lo scippo" he directed three Spaghetti Western films(" Professionals for a MassacreLast of the Badmen", and" Twice a Judas"). From 1970 he focused on comedy genre, directing some parody films starred by Franco Franchi and Ciccio Ingrassia. Starting with" The School Teacher" Cicero established himself as one of the most important and successful directors of the commedia sexy all\'italiana film genre. Following the decline of the genre, he retired in 1983; his last film was" Paulo Roberto Cotechino", starring Alvaro Vitali and Carmen Russo. He died in 1995 at age 64.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'When did the performer of song That Is All (Song) die?',
[
'Bill Kaulitz. Bill Kaulitz( born September 1, 1989), also known mononymously as Billy( stylized as BILLY) for his solo act, is a German singer, songwriter, voice actor, designer, and model. He is best known for his work from 2001 to the present as the lead singer of the band Tokio Hotel.',
'Alonso Mudarra. Alonso Mudarra( c. 1510 – April 1, 1580) was a Spanish composer of the Renaissance, and also played the vihuela, a guitar- shaped string instrument. He was an innovative composer of instrumental music as well as songs, and was the composer of the earliest surviving music for the guitar.',
'István Pauli. István Pauli or István Pável( July 13, 1760 – January 29, 1829) was a Hungarian Slovene Roman Catholic priests. Pauli or the teacher of Pertoča György Kousz was the author of a hymnal in Pertoča. He was born in Beltinci. His parents was Márk Pável and Katalin Gyrék. In Bratislava, was studied theology and in 1789 ordained. From 1790- 1797, he was the priest of Pertoča. On October 1, 1822, he retired and died in Szombathely.',
'Ebrahimabad, Jorjafak. Ebrahimabad( also Romanized as Ebrāhīmābād) is a village in Jorjafak Rural District, in the Central District of Zarand County, Kerman Province, Iran. At the 2006 census, its existence was noted, but its population was not reported.',
'Nando Cicero. Fernando Cicero, better known as Nando Cicero( 22 January 1931 – 30 July 1995), was an Italian film director, screenwriter and actor. Born in Asmara, Cicero debuted as an actor, working with directors such as Luchino Visconti(" Senso", 1953), Roberto Rossellini(" Vanina Vanini", 1961), Francesco Rosi(" Salvatore Giuliano", 1962) and Alberto Lattuada(" La steppa", 1962). He starred in eleven films between 1953 and 1962, always in supporting roles. After his directorial debut with" Lo scippo" he directed three Spaghetti Western films(" Professionals for a MassacreLast of the Badmen", and" Twice a Judas"). From 1970 he focused on comedy genre, directing some parody films starred by Franco Franchi and Ciccio Ingrassia. Starting with" The School Teacher" Cicero established himself as one of the most important and successful directors of the commedia sexy all\'italiana film genre. Following the decline of the genre, he retired in 1983; his last film was" Paulo Roberto Cotechino", starring Alvaro Vitali and Carmen Russo. He died in 1995 at age 64.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Evaluation
### Metrics
#### Cross Encoder Binary Classification
* Datasets: `validation` and `train_subset`
* Evaluated with [CEBinaryClassificationEvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CEBinaryClassificationEvaluator)
| Metric | validation | train_subset |
|:----------------------|:-----------|:-------------|
| accuracy | 0.7816 | 0.798 |
| accuracy_threshold | 0.0775 | 0.9966 |
| f1 | 0.8137 | 0.7878 |
| f1_threshold | 0.0775 | 0.9962 |
| precision | 0.7094 | 0.7659 |
| recall | 0.954 | 0.8109 |
| **average_precision** | **0.86** | **0.849** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 9,540 training samples
* Columns: sentence_0, sentence_1, and label
* Approximate statistics based on the first 1000 samples:
| | sentence_0 | sentence_1 | label |
|:--------|:------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------|:--------------------------------------------------------------|
| type | string | string | float |
| details |
When did the performer of song That Is All (Song) die? | Bill Kaulitz. Bill Kaulitz( born September 1, 1989), also known mononymously as Billy( stylized as BILLY) for his solo act, is a German singer, songwriter, voice actor, designer, and model. He is best known for his work from 2001 to the present as the lead singer of the band Tokio Hotel. | 0.0 |
| Who was born first, Robert Macnish or Gustavo Dávila? | Alonso Mudarra. Alonso Mudarra( c. 1510 – April 1, 1580) was a Spanish composer of the Renaissance, and also played the vihuela, a guitar- shaped string instrument. He was an innovative composer of instrumental music as well as songs, and was the composer of the earliest surviving music for the guitar. | 0.0 |
| Where was the place of death of the composer of song Ett Gammalt Fult Och Elakt Troll Det Var En Gång? | István Pauli. István Pauli or István Pável( July 13, 1760 – January 29, 1829) was a Hungarian Slovene Roman Catholic priests. Pauli or the teacher of Pertoča György Kousz was the author of a hymnal in Pertoča. He was born in Beltinci. His parents was Márk Pável and Katalin Gyrék. In Bratislava, was studied theology and in 1789 ordained. From 1790- 1797, he was the priest of Pertoča. On October 1, 1822, he retired and died in Szombathely. | 0.0 |
* Loss: [BinaryCrossEntropyLoss](https://sbert.net/docs/package_reference/cross_encoder/losses.html#binarycrossentropyloss) with these parameters:
```json
{
"activation_fn": "torch.nn.modules.linear.Identity",
"pos_weight": null
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 2
- `per_device_eval_batch_size`: 2
#### All Hyperparameters