---
tags:
- sentence-transformers
- cross-encoder
- reranker
- generated_from_trainer
- dataset_size:43188
- loss:BinaryCrossEntropyLoss
base_model: cross-encoder/nli-deberta-v3-base
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/nli-deberta-v3-base
results:
- task:
type: cross-encoder-binary-classification
name: Cross Encoder Binary Classification
dataset:
name: paws val judge
type: paws-val-judge
metrics:
- type: accuracy
value: 0.9645748987854251
name: Accuracy
- type: accuracy_threshold
value: 0.08707074075937271
name: Accuracy Threshold
- type: f1
value: 0.9604876947392187
name: F1
- type: f1_threshold
value: 0.08707074075937271
name: F1 Threshold
- type: precision
value: 0.9470169189670525
name: Precision
- type: recall
value: 0.9743472285845167
name: Recall
- type: average_precision
value: 0.9870268561433264
name: Average Precision
---
# CrossEncoder based on cross-encoder/nli-deberta-v3-base
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [cross-encoder/nli-deberta-v3-base](https://huggingface.co/cross-encoder/nli-deberta-v3-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:** [cross-encoder/nli-deberta-v3-base](https://huggingface.co/cross-encoder/nli-deberta-v3-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 = [
['Route 309 is a Connecticut State Highway in the northwestern Hartford suburbs from Canton to Simsbury .', 'Route 309 runs a Canton State Highway in the northwestern Connecticut suburbs from Hartford to Simsbury .'],
['During the competition she lost 50-25 to Zimbabwe , 84-16 to Tanzania , 58-24 to South Africa .', 'During the competition , they lost 50-25 to Zimbabwe , 84-16 to Tanzania , 58-24 to South Africa .'],
['The latter study is one of the few prospective demonstrations that environmental stress with high blood pressure and LVH remains associated .', 'The latter study remains one of the few prospective demonstrations that environmental stress with high blood pressure and LVH is associated .'],
['The Marignane is located at Marseille Airport in Provence .', 'The Marignane is located in Marseille Provence Airport .'],
['Birleffi was of Italian descent and Roman - Catholic in a predominantly Protestant state .', 'Birleffi was of Italian ethnicity and Roman Catholic in a predominantly Protestant state .'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'Route 309 is a Connecticut State Highway in the northwestern Hartford suburbs from Canton to Simsbury .',
[
'Route 309 runs a Canton State Highway in the northwestern Connecticut suburbs from Hartford to Simsbury .',
'During the competition , they lost 50-25 to Zimbabwe , 84-16 to Tanzania , 58-24 to South Africa .',
'The latter study remains one of the few prospective demonstrations that environmental stress with high blood pressure and LVH is associated .',
'The Marignane is located in Marseille Provence Airport .',
'Birleffi was of Italian ethnicity and Roman Catholic in a predominantly Protestant state .',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Evaluation
### Metrics
#### Cross Encoder Binary Classification
* Dataset: `paws-val-judge`
* Evaluated with [CEBinaryClassificationEvaluator](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CEBinaryClassificationEvaluator)
| Metric | Value |
|:----------------------|:----------|
| accuracy | 0.9646 |
| accuracy_threshold | 0.0871 |
| f1 | 0.9605 |
| f1_threshold | 0.0871 |
| precision | 0.947 |
| recall | 0.9743 |
| **average_precision** | **0.987** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 43,188 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 |
Route 309 is a Connecticut State Highway in the northwestern Hartford suburbs from Canton to Simsbury . | Route 309 runs a Canton State Highway in the northwestern Connecticut suburbs from Hartford to Simsbury . | 0.0 |
| During the competition she lost 50-25 to Zimbabwe , 84-16 to Tanzania , 58-24 to South Africa . | During the competition , they lost 50-25 to Zimbabwe , 84-16 to Tanzania , 58-24 to South Africa . | 1.0 |
| The latter study is one of the few prospective demonstrations that environmental stress with high blood pressure and LVH remains associated . | The latter study remains one of the few prospective demonstrations that environmental stress with high blood pressure and LVH is associated . | 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`: 16
- `per_device_eval_batch_size`: 16
#### All Hyperparameters