---
tags:
- sentence-transformers
- cross-encoder
- reranker
- generated_from_trainer
- dataset_size:1122
- loss:BinaryCrossEntropyLoss
base_model: cross-encoder/stsb-roberta-large
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 cross-encoder/stsb-roberta-large
results:
- task:
type: cross-encoder-classification
name: Cross Encoder Classification
dataset:
name: validation
type: validation
metrics:
- type: accuracy
value: 0.95
name: Accuracy
- type: accuracy_threshold
value: 0.4996068775653839
name: Accuracy Threshold
- type: f1
value: 0.9517241379310345
name: F1
- type: f1_threshold
value: 0.3665258288383484
name: F1 Threshold
- type: precision
value: 0.9452054794520548
name: Precision
- type: recall
value: 0.9583333333333334
name: Recall
- type: average_precision
value: 0.9752684979366919
name: Average Precision
---
# CrossEncoder based on cross-encoder/stsb-roberta-large
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [cross-encoder/stsb-roberta-large](https://huggingface.co/cross-encoder/stsb-roberta-large) 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:** [cross-encoder/stsb-roberta-large](https://huggingface.co/cross-encoder/stsb-roberta-large)
- **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("pujithapsx/address-crossencoder-stsb-roberta-large-finetuned")
# Get scores for pairs of texts
pairs = [
['C/O Rakesh Tower C Sector 137 Gurgaon', 'C Tower Sec-137 Gurugram'],
['Tellapur Hyderabad', 'Telapur Hyderabad'],
['Flat 703 Electronic City Bangalore', 'Flat 703 Electronic City Mumbai'],
['B-12 Malviya Nagar Delhi', 'B-22 Malviya Nagar Delhi'],
['Flat 1203 Lower Parel Mumbai', 'Flat 1203 Lower Parel Chennai'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'C/O Rakesh Tower C Sector 137 Gurgaon',
[
'C Tower Sec-137 Gurugram',
'Telapur Hyderabad',
'Flat 703 Electronic City Mumbai',
'B-22 Malviya Nagar Delhi',
'Flat 1203 Lower Parel Chennai',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Evaluation
### Metrics
#### Cross Encoder Classification
* Dataset: `validation`
* Evaluated with [CrossEncoderClassificationEvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderClassificationEvaluator)
| Metric | Value |
|:----------------------|:-----------|
| accuracy | 0.95 |
| accuracy_threshold | 0.4996 |
| f1 | 0.9517 |
| f1_threshold | 0.3665 |
| precision | 0.9452 |
| recall | 0.9583 |
| **average_precision** | **0.9753** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 1,122 training samples
* Columns: sentence1, sentence2, and label
* Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | label |
|:--------|:----------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details |
Eighty Eight 8th Cross HSR Layout Bengaluru | 52 Fifty Two D Second Lane Marathahalli Bengaluru | 0.0 |
| Flat 301 C/O Sharma Kondapur Near Hitech City Hyderabad | Flat 301 C/O Sharma Kondapoor Near Hi Tech City Hyd | 1.0 |
| Anna Nagar 12B Chennai 600040 | 12B Anna Nagar Chennai | 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
}
```
### Evaluation Dataset
#### Unnamed Dataset
* Size: 140 evaluation samples
* Columns: sentence1, sentence2, and label
* Approximate statistics based on the first 140 samples:
| | sentence1 | sentence2 | label |
|:--------|:-----------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details | C/O Rakesh Tower C Sector 137 Gurgaon | C Tower Sec-137 Gurugram | 1.0 |
| Tellapur Hyderabad | Telapur Hyderabad | 1.0 |
| Flat 703 Electronic City Bangalore | Flat 703 Electronic City Mumbai | 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
- `num_train_epochs`: 6
- `learning_rate`: 1.5e-05
- `warmup_steps`: 0.1
- `weight_decay`: 0.01
- `gradient_accumulation_steps`: 4
- `disable_tqdm`: True
- `eval_strategy`: epoch
- `per_device_eval_batch_size`: 16
- `load_best_model_at_end`: True
#### All Hyperparameters