---
tags:
- sentence-transformers
- cross-encoder
- reranker
- generated_from_trainer
- dataset_size:68056
- 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: eval
type: eval
metrics:
- type: accuracy
value: 0.8962388216728038
name: Accuracy
- type: accuracy_threshold
value: 0.2969196140766144
name: Accuracy Threshold
- type: f1
value: 0.7976337194971654
name: F1
- type: f1_threshold
value: 0.20159849524497986
name: F1 Threshold
- type: precision
value: 0.7504638218923934
name: Precision
- type: recall
value: 0.8511309836927933
name: Recall
- type: average_precision
value: 0.8668698311259357
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:** 512 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 = [
['A Hydro Flask in a light brown color with a small hand logo.', 'A large, light-brown Hydro Flask water bottle with a darker tan cap and black accents, appears to be made of metal, and seems to be in new condition with tags still attached.'],
['A black smartphone.', 'The image shows four used smartphones, including a white and black Samsung smartphone, a black and silver phone of unknown brand, a white and black Nokia phone, and a white Apple iPhone, all appearing to be between 4 and 5 inches in screen size.'],
['A purple pencil case with a unicorn design.', 'A new, mint green hard-shell pencil case with a ribbed texture and a central circular illustration of a unicorn with a rainbow mane.'],
['A folded, dark blue umbrella has a slightly crinkled matching fabric case and its handle is still wrapped in clear plastic.', 'There are two blue umbrellas.'],
['a black messenger bag with purple stitching.', 'A gray-green backpack with black mesh padding and an orange "NANEU PRO" tag on the side.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'A Hydro Flask in a light brown color with a small hand logo.',
[
'A large, light-brown Hydro Flask water bottle with a darker tan cap and black accents, appears to be made of metal, and seems to be in new condition with tags still attached.',
'The image shows four used smartphones, including a white and black Samsung smartphone, a black and silver phone of unknown brand, a white and black Nokia phone, and a white Apple iPhone, all appearing to be between 4 and 5 inches in screen size.',
'A new, mint green hard-shell pencil case with a ribbed texture and a central circular illustration of a unicorn with a rainbow mane.',
'There are two blue umbrellas.',
'A gray-green backpack with black mesh padding and an orange "NANEU PRO" tag on the side.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Evaluation
### Metrics
#### Cross Encoder Binary Classification
* Dataset: `eval`
* Evaluated with [CEBinaryClassificationEvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CEBinaryClassificationEvaluator)
| Metric | Value |
|:----------------------|:-----------|
| accuracy | 0.8962 |
| accuracy_threshold | 0.2969 |
| f1 | 0.7976 |
| f1_threshold | 0.2016 |
| precision | 0.7505 |
| recall | 0.8511 |
| **average_precision** | **0.8669** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 68,056 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 |
A Hydro Flask in a light brown color with a small hand logo. | A large, light-brown Hydro Flask water bottle with a darker tan cap and black accents, appears to be made of metal, and seems to be in new condition with tags still attached. | 1.0 |
| A black smartphone. | The image shows four used smartphones, including a white and black Samsung smartphone, a black and silver phone of unknown brand, a white and black Nokia phone, and a white Apple iPhone, all appearing to be between 4 and 5 inches in screen size. | 0.0 |
| A purple pencil case with a unicorn design. | A new, mint green hard-shell pencil case with a ribbed texture and a central circular illustration of a unicorn with a rainbow mane. | 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`: 16
- `per_device_eval_batch_size`: 16
#### All Hyperparameters