CoolFace
Modelpublic

tomaarsen/reranker-distilroberta-base-quora-duplicates

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes13downloads
Model Card

CrossEncoder based on distilbert/distilroberta-base

This is a Cross Encoder model finetuned from distilbert/distilroberta-base on the quora-duplicates dataset using the sentence-transformers 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 <!-- at revision fb53ab8802853c8e4fbdbcd0529f21fc6f459b2b -->
  • —Maximum Sequence Length: 514 tokens
  • —Training Dataset:
  • —quora-duplicates
  • —Language: en <!-- - License: Unknown -->

Model Sources

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': ...}, ...]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Cross Encoder Classification
Metricquora-duplicates-devquora-duplicates-test
accuracy0.89380.8938
accuracy_threshold0.50890.5091
f10.86120.8612
f1_threshold0.38560.3858
precision0.81830.8183
recall0.90890.9089
average_precision0.92030.9203

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

quora-duplicates
  • —Dataset: quora-duplicates at 451a485
  • —Size: 404,290 training samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | label | |:--------|:-----------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------|:------------------------------------------------| | type | string | string | int | | details | <ul><li>min: 1 characters</li><li>mean: 59.15 characters</li><li>max: 354 characters</li></ul> | <ul><li>min: 6 characters</li><li>mean: 60.74 characters</li><li>max: 399 characters</li></ul> | <ul><li>0: ~64.20%</li><li>1: ~35.80%</li></ul> |
  • —Samples: | sentence1 | sentence2 | label | |:-----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------|:---------------| | <code>What are the features of the Indian caste system?</code> | <code>What triggers you the most when you play video games?</code> | <code>0</code> | | <code>What is the best place to learn Mandarin Chinese in Singapore?</code> | <code>What is the best place in Singapore for durian in December?</code> | <code>0</code> | | <code>What will be Hillary Clinton's India policy if she wins the election?</code> | <code>How would the bilateral relationship between India and the USA be under Hillary Clinton's presidency?</code> | <code>1</code> |
  • —Loss: <code>BinaryCrossEntropyLoss</code>

Evaluation Dataset

quora-duplicates
  • —Dataset: quora-duplicates at 451a485
  • —Size: 404,290 evaluation samples
  • —Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>label</code>
  • —Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | label | |:--------|:-----------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:------------------------------------------------| | type | string | string | int | | details | <ul><li>min: 11 characters</li><li>mean: 57.9 characters</li><li>max: 244 characters</li></ul> | <ul><li>min: 12 characters</li><li>mean: 59.33 characters</li><li>max: 221 characters</li></ul> | <ul><li>0: ~62.00%</li><li>1: ~38.00%</li></ul> |
  • —Samples: | sentence1 | sentence2 | label | |:---------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------|:---------------| | <code>What is the step by step guide to invest in share market in india?</code> | <code>What is the step by step guide to invest in share market?</code> | <code>0</code> | | <code>What is the story of Kohinoor (Koh-i-Noor) Diamond?</code> | <code>What would happen if the Indian government stole the Kohinoor (Koh-i-Noor) diamond back?</code> | <code>0</code> | | <code>How can I increase the speed of my internet connection while using a VPN?</code> | <code>How can Internet speed be increased by hacking through DNS?</code> | <code>0</code> |
  • —Loss: <code>BinaryCrossEntropyLoss</code>

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

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: steps
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 64
  • —per_device_eval_batch_size: 64
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 5e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 1
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.1
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: True
  • —fp16: False
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: None
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —dispatch_batches: None
  • —split_batches: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: False
  • —prompts: None
  • —batch_sampler: batch_sampler
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

EpochStepTraining LossValidation Lossquora-duplicates-dev_average_precisionquora-duplicates-test_average_precision
-1-1--0.3711-
0.01671000.6574---
0.03332000.4804---
0.05003000.4406---
0.06664000.4208---
0.08335000.39290.39580.8210-
0.09996000.3986---
0.11667000.3743---
0.13328000.3938---
0.14999000.3602---
0.166510000.37140.34370.8565-
0.183211000.3486---
0.199812000.3479---
0.216513000.3417---
0.233114000.3425---
0.249815000.33530.32640.8742-
0.266416000.3335---
0.283117000.3274---
0.299818000.3284---
0.316419000.3118---
0.333120000.30730.32820.8826-
0.349721000.3233---
0.366422000.3072---
0.383023000.314---
0.399724000.3065---
0.416325000.30460.28770.8930-
0.433026000.2857---
0.449627000.285---
0.466328000.2957---
0.482929000.2965---
0.499630000.28240.28420.8998-
0.516231000.3019---
0.532932000.2841---
0.549533000.2981---
0.566234000.2878---
0.582835000.2780.28030.9061-
0.599536000.2841---
0.616237000.2794---
0.632838000.2808---
0.649539000.27---
0.666140000.27190.26970.9091-
0.682841000.2792---
0.699442000.2669---
0.716143000.2696---
0.732744000.2642---
0.749445000.26840.25910.9140-
0.766046000.2593---
0.782747000.2756---
0.799348000.2584---
0.816049000.2525---
0.832650000.2670.25400.9168-
0.849351000.2612---
0.865952000.2607---
0.882653000.2565---
0.899354000.2432---
0.915955000.25680.24890.9198-
0.932656000.2572---
0.949257000.2658---
0.965958000.2568---
0.982559000.2539---
0.999260000.24580.25030.9203-
-1-1---0.9203

Environmental Impact

Carbon emissions were measured using CodeCarbon.

  • —Energy Consumed: 0.069 kWh
  • —Carbon Emitted: 0.027 kg of CO2
  • —Hours Used: 0.214 hours

Training Hardware

  • —On Cloud: No
  • —GPU Model: 1 x NVIDIA GeForce RTX 3090
  • —CPU Model: 13th Gen Intel(R) Core(TM) i7-13700K
  • —RAM Size: 31.78 GB

Framework Versions

  • —Python: 3.11.6
  • —Sentence Transformers: 3.5.0.dev0
  • —Transformers: 4.49.0.dev0
  • —PyTorch: 2.5.0+cu121
  • —Accelerate: 1.3.0
  • —Datasets: 2.20.0
  • —Tokenizers: 0.21.0

Citation

BibTeX

Sentence Transformers
bibtex
@inproceedings{reimers-2019-sentence-bert,
    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2019",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/1908.10084",
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->