---
language:
- en
tags:
- sentence-transformers
- cross-encoder
- text-classification
- generated_from_trainer
- dataset_size:404290
- loss:BinaryCrossEntropyLoss
base_model: distilbert/distilroberta-base
datasets:
- sentence-transformers/quora-duplicates
pipeline_tag: text-classification
library_name: sentence-transformers
metrics:
- accuracy
- accuracy_threshold
- f1
- f1_threshold
- precision
- recall
- average_precision
co2_eq_emissions:
emissions: 26.889480385249758
energy_consumed: 0.06917762292257246
source: codecarbon
training_type: fine-tuning
on_cloud: false
cpu_model: 13th Gen Intel(R) Core(TM) i7-13700K
ram_total_size: 31.777088165283203
hours_used: 0.214
hardware_used: 1 x NVIDIA GeForce RTX 3090
model-index:
- name: CrossEncoder based on distilbert/distilroberta-base
results:
- task:
type: cross-encoder-classification
name: Cross Encoder Classification
dataset:
name: quora duplicates dev
type: quora-duplicates-dev
metrics:
- type: accuracy
value: 0.8938
name: Accuracy
- type: accuracy_threshold
value: 0.5088549852371216
name: Accuracy Threshold
- type: f1
value: 0.8612281373675477
name: F1
- type: f1_threshold
value: 0.3856155276298523
name: F1 Threshold
- type: precision
value: 0.8182920912178554
name: Precision
- type: recall
value: 0.908919428725411
name: Recall
- type: average_precision
value: 0.920292628179356
name: Average Precision
- task:
type: cross-encoder-classification
name: Cross Encoder Classification
dataset:
name: quora duplicates test
type: quora-duplicates-test
metrics:
- type: accuracy
value: 0.8938
name: Accuracy
- type: accuracy_threshold
value: 0.5091445446014404
name: Accuracy Threshold
- type: f1
value: 0.8612281373675477
name: F1
- type: f1_threshold
value: 0.38580775260925293
name: F1 Threshold
- type: precision
value: 0.8182920912178554
name: Precision
- type: recall
value: 0.908919428725411
name: Recall
- type: average_precision
value: 0.92029239602284
name: Average Precision
---
# CrossEncoder based on distilbert/distilroberta-base
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [distilbert/distilroberta-base](https://huggingface.co/distilbert/distilroberta-base) on the [quora-duplicates](https://huggingface.co/datasets/sentence-transformers/quora-duplicates) dataset using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
## Model Details
### Model Description
- **Model Type:** Cross Encoder
- **Base model:** [distilbert/distilroberta-base](https://huggingface.co/distilbert/distilroberta-base)
- **Maximum Sequence Length:** 514 tokens
- **Training Dataset:**
- [quora-duplicates](https://huggingface.co/datasets/sentence-transformers/quora-duplicates)
- **Language:** en
### 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/UKPLab/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("sentence_transformers_model_id")
# Get scores for pairs...
pairs = [
['What is the step by step guide to invest in share market in india?', 'What is the step by step guide to invest in share market?'],
['What is the story of Kohinoor (Koh-i-Noor) Diamond?', 'What would happen if the Indian government stole the Kohinoor (Koh-i-Noor) diamond back?'],
['How can I increase the speed of my internet connection while using a VPN?', 'How can Internet speed be increased by hacking through DNS?'],
['Why am I mentally very lonely? How can I solve it?', 'Find the remainder when [math]23^{24}[/math] is divided by 24,23?'],
['Which one dissolve in water quikly sugar, salt, methane and carbon di oxide?', 'Which fish would survive in salt water?'],
]
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 step by step guide to invest in share market in india?',
[
'What is the step by step guide to invest in share market?',
'What would happen if the Indian government stole the Kohinoor (Koh-i-Noor) diamond back?',
'How can Internet speed be increased by hacking through DNS?',
'Find the remainder when [math]23^{24}[/math] is divided by 24,23?',
'Which fish would survive in salt water?',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Evaluation
### Metrics
#### Cross Encoder Classification
* Datasets: `quora-duplicates-dev` and `quora-duplicates-test`
* Evaluated with [CEClassificationEvaluator
](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CEClassificationEvaluator)
| Metric | quora-duplicates-dev | quora-duplicates-test |
|:----------------------|:---------------------|:----------------------|
| accuracy | 0.8938 | 0.8938 |
| accuracy_threshold | 0.5089 | 0.5091 |
| f1 | 0.8612 | 0.8612 |
| f1_threshold | 0.3856 | 0.3858 |
| precision | 0.8183 | 0.8183 |
| recall | 0.9089 | 0.9089 |
| **average_precision** | **0.9203** | **0.9203** |
## Training Details
### Training Dataset
#### quora-duplicates
* Dataset: [quora-duplicates](https://huggingface.co/datasets/sentence-transformers/quora-duplicates) at [451a485](https://huggingface.co/datasets/sentence-transformers/quora-duplicates/tree/451a4850bd141edb44ade1b5828c259abd762cdb)
* Size: 404,290 training samples
* Columns: sentence1
, sentence2
, and label
* Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | label |
|:--------|:-----------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------|:------------------------------------------------|
| type | string | string | int |
| details |
What are the features of the Indian caste system?
| What triggers you the most when you play video games?
| 0
|
| What is the best place to learn Mandarin Chinese in Singapore?
| What is the best place in Singapore for durian in December?
| 0
|
| What will be Hillary Clinton's India policy if she wins the election?
| How would the bilateral relationship between India and the USA be under Hillary Clinton's presidency?
| 1
|
* Loss: [BinaryCrossEntropyLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#binarycrossentropyloss)
### Evaluation Dataset
#### quora-duplicates
* Dataset: [quora-duplicates](https://huggingface.co/datasets/sentence-transformers/quora-duplicates) at [451a485](https://huggingface.co/datasets/sentence-transformers/quora-duplicates/tree/451a4850bd141edb44ade1b5828c259abd762cdb)
* Size: 404,290 evaluation samples
* Columns: sentence1
, sentence2
, and label
* Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | label |
|:--------|:-----------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:------------------------------------------------|
| type | string | string | int |
| details | What is the step by step guide to invest in share market in india?
| What is the step by step guide to invest in share market?
| 0
|
| What is the story of Kohinoor (Koh-i-Noor) Diamond?
| What would happen if the Indian government stole the Kohinoor (Koh-i-Noor) diamond back?
| 0
|
| How can I increase the speed of my internet connection while using a VPN?
| How can Internet speed be increased by hacking through DNS?
| 0
|
* Loss: [BinaryCrossEntropyLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#binarycrossentropyloss)
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 64
- `per_device_eval_batch_size`: 64
- `num_train_epochs`: 1
- `warmup_ratio`: 0.1
- `bf16`: True
#### All Hyperparameters