---
tags:
- sentence-transformers
- cross-encoder
- reranker
- generated_from_trainer
- dataset_size:31340
- loss:BinaryCrossEntropyLoss
base_model: BAAI/bge-reranker-base
pipeline_tag: text-ranking
library_name: sentence-transformers
---
# CrossEncoder based on BAAI/bge-reranker-base
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [BAAI/bge-reranker-base](https://huggingface.co/BAAI/bge-reranker-base) 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-base](https://huggingface.co/BAAI/bge-reranker-base)
- **Maximum Sequence Length:** 128 tokens
- **Number of Output Labels:** 1 label
- **Supported Modality:** Text
### 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)
### Full Model Architecture
```
CrossEncoder(
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'XLMRobertaForSequenceClassification'})
)
```
## 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 inputs
pairs = [
['حقيبة تشانك لوكس', "Globus Women's Textured Vegan Leather Sling Bag Tan | Globus Women Tan Vegan Leather Textured Sling Bag With Detachable Strap | globus | Crossbody Bags | Tan"],
['حريمية ماسكات كورية', 'Kappa 3-Pack Crew Socks Multicolour | Kappa Pack of 3 Crew Length Socks | Kappa | Socks | Multicolour'],
['شسي غير مبطنة', 'Fall In Love Unlined Bodysuit | فول إن لوف بودي سوت غير مبطن | DeFacto | Body Suits | Deep Magenta'],
['كندرة رموش مريحة للستات', 'Lift N Snatch Brow Tint Pen Black | قلم تحديد الحواجب ليفت أند سناتش رمادي أسود | NYX PROFESSIONAL MAKEUP | All Products | Black'],
['white blouse', '2Xtremz Schiffli Ruffle Cotton Top White | 2Xtremz Regular Fit Cotton Top with Schiffli and Ruffle Detail | 2Xtremz | Blouses | White'],
]
scores = model.predict(pairs)
print(scores)
# [0.9418 0.0044 0.978 0.2881 0.9463]
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'حقيبة تشانك لوكس',
[
"Globus Women's Textured Vegan Leather Sling Bag Tan | Globus Women Tan Vegan Leather Textured Sling Bag With Detachable Strap | globus | Crossbody Bags | Tan",
'Kappa 3-Pack Crew Socks Multicolour | Kappa Pack of 3 Crew Length Socks | Kappa | Socks | Multicolour',
'Fall In Love Unlined Bodysuit | فول إن لوف بودي سوت غير مبطن | DeFacto | Body Suits | Deep Magenta',
'Lift N Snatch Brow Tint Pen Black | قلم تحديد الحواجب ليفت أند سناتش رمادي أسود | NYX PROFESSIONAL MAKEUP | All Products | Black',
'2Xtremz Schiffli Ruffle Cotton Top White | 2Xtremz Regular Fit Cotton Top with Schiffli and Ruffle Detail | 2Xtremz | Blouses | White',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 31,340 training samples
* Columns: sentence_0, sentence_1, and label
* Approximate statistics based on the first 100 samples:
| | sentence_0 | sentence_1 | label |
|:---------|:---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| modality | text | text | |
| details |
حقيبة تشانك لوكس | Globus Women's Textured Vegan Leather Sling Bag Tan \| Globus Women Tan Vegan Leather Textured Sling Bag With Detachable Strap \| globus \| Crossbody Bags \| Tan | 1.0 |
| حريمية ماسكات كورية | Kappa 3-Pack Crew Socks Multicolour \| Kappa Pack of 3 Crew Length Socks \| Kappa \| Socks \| Multicolour | 0.0 |
| شسي غير مبطنة | Fall In Love Unlined Bodysuit \| فول إن لوف بودي سوت غير مبطن \| DeFacto \| Body Suits \| Deep Magenta | 1.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
- `per_device_train_batch_size`: 32
- `per_device_eval_batch_size`: 32
- `fp16`: True
- `disable_tqdm`: True
#### All Hyperparameters