---
tags:
- sentence-transformers
- cross-encoder
- reranker
- generated_from_trainer
- dataset_size:24588
- loss:BinaryCrossEntropyLoss
base_model: Alibaba-NLP/gte-multilingual-reranker-base
pipeline_tag: text-ranking
library_name: sentence-transformers
metrics:
- pearson
- spearman
model-index:
- name: CrossEncoder based on Alibaba-NLP/gte-multilingual-reranker-base
results:
- task:
type: cross-encoder-correlation
name: Cross Encoder Correlation
dataset:
name: validation
type: validation
metrics:
- type: pearson
value: 0.875500492479389
name: Pearson
- type: spearman
value: 0.8709281334702662
name: Spearman
---
# CrossEncoder based on Alibaba-NLP/gte-multilingual-reranker-base
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [Alibaba-NLP/gte-multilingual-reranker-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-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:** [Alibaba-NLP/gte-multilingual-reranker-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-reranker-base)
- **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 = [
['What is the average rent price in Canada?', 'Title: "How many hours do Americans sleep at night (United States)"\nCollections: YouGov Trackers\nDatasets: YouGovTrackerValueV2\nChart Type: survey:timeseries\nSources: YouGov'],
['for the topic digital foortprint and identity use "\t " to give a description on if there was an provided teaching materials for this activity.', 'Title: "Different ways Americans define gender for someone who says they are transgender (United States)"\nCollections: YouGov Trackers\nDatasets: YouGovTrackerValueV2\nChart Type: survey:timeseries\nSources: YouGov'],
['Which U.S. cities or counties have the highest rates of aggravated assault involving a deadly weapon per 100,000 residents?', 'Title: "U.S. Bank Overview, CITY Overview"\nCollections: Companies\nDatasets: InstrumentClosePrice1Day\nChart Type: timeseries:eav_v3\nCanonical forms: "U.S. Bancorp"="closing_price", "Club De Futbol Intercity Sad"="closing_price"'],
['Black identity topics', 'Title: "Different ways Americans define gender for someone who says they are transgender (United States)"\nCollections: YouGov Trackers\nDatasets: YouGovTrackerValueV2\nChart Type: survey:timeseries\nSources: YouGov'],
['Which company in the Interactive Media and Services category has the highest market capitalization?', 'Title: "DigiPlus Interactive. Capital Expenditure (Quarterly)"\nCollections: Companies\nDatasets: StandardIncomeStatement\nChart Type: timeseries:eav_v3\nCanonical forms: "Capital Expenditure"="capital_expenditure"\nSources: S&P Global'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'What is the average rent price in Canada?',
[
'Title: "How many hours do Americans sleep at night (United States)"\nCollections: YouGov Trackers\nDatasets: YouGovTrackerValueV2\nChart Type: survey:timeseries\nSources: YouGov',
'Title: "Different ways Americans define gender for someone who says they are transgender (United States)"\nCollections: YouGov Trackers\nDatasets: YouGovTrackerValueV2\nChart Type: survey:timeseries\nSources: YouGov',
'Title: "U.S. Bank Overview, CITY Overview"\nCollections: Companies\nDatasets: InstrumentClosePrice1Day\nChart Type: timeseries:eav_v3\nCanonical forms: "U.S. Bancorp"="closing_price", "Club De Futbol Intercity Sad"="closing_price"',
'Title: "Different ways Americans define gender for someone who says they are transgender (United States)"\nCollections: YouGov Trackers\nDatasets: YouGovTrackerValueV2\nChart Type: survey:timeseries\nSources: YouGov',
'Title: "DigiPlus Interactive. Capital Expenditure (Quarterly)"\nCollections: Companies\nDatasets: StandardIncomeStatement\nChart Type: timeseries:eav_v3\nCanonical forms: "Capital Expenditure"="capital_expenditure"\nSources: S&P Global',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Evaluation
### Metrics
#### Cross Encoder Correlation
* Dataset: `validation`
* Evaluated with [CrossEncoderCorrelationEvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderCorrelationEvaluator)
| Metric | Value |
|:-------------|:-----------|
| pearson | 0.8755 |
| **spearman** | **0.8709** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 24,588 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 |
What is the average rent price in Canada? | Title: "How many hours do Americans sleep at night (United States)"
Collections: YouGov Trackers
Datasets: YouGovTrackerValueV2
Chart Type: survey:timeseries
Sources: YouGov | 0.0 |
| for the topic digital foortprint and identity use " " to give a description on if there was an provided teaching materials for this activity. | Title: "Different ways Americans define gender for someone who says they are transgender (United States)"
Collections: YouGov Trackers
Datasets: YouGovTrackerValueV2
Chart Type: survey:timeseries
Sources: YouGov | 0.25 |
| Which U.S. cities or counties have the highest rates of aggravated assault involving a deadly weapon per 100,000 residents? | Title: "U.S. Bank Overview, CITY Overview"
Collections: Companies
Datasets: InstrumentClosePrice1Day
Chart Type: timeseries:eav_v3
Canonical forms: "U.S. Bancorp"="closing_price", "Club De Futbol Intercity Sad"="closing_price" | 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`: 32
- `per_device_eval_batch_size`: 32
- `num_train_epochs`: 5
- `fp16`: True
#### All Hyperparameters