CrossEncoder based on distilbert/distilroberta-base

This is a Cross Encoder model finetuned from distilbert/distilroberta-base on the all-nli dataset using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text pair classification.

Model Details

Model Description

  • Model Type: Cross Encoder
  • Base model: distilbert/distilroberta-base
  • Maximum Sequence Length: 512 tokens
  • Number of Output Labels: 3 labels
  • Supported Modality: Text
  • Training Dataset:
    • all-nli

Model Sources

Full Model Architecture

CrossEncoder(
  (0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'RobertaForSequenceClassification'})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

pip install -U sentence-transformers

Then you can load this model and run inference.

from sentence_transformers import CrossEncoder

# Download from the 🤗 Hub
model = CrossEncoder("kwondw/reranker-distilroberta-base-nli")
# Get scores for pairs of inputs
pairs = [
    ['Two women are embracing while holding to go packages.', 'The sisters are hugging goodbye while holding to go packages after just eating lunch.'],
    ['Two women are embracing while holding to go packages.', 'Two woman are holding packages.'],
    ['Two women are embracing while holding to go packages.', 'The men are fighting outside a deli.'],
    ['Two young children in blue jerseys, one with the number 9 and one with the number 2 are standing on wooden steps in a bathroom and washing their hands in a sink.', 'Two kids in numbered jerseys wash their hands.'],
    ['Two young children in blue jerseys, one with the number 9 and one with the number 2 are standing on wooden steps in a bathroom and washing their hands in a sink.', 'Two kids at a ballgame wash their hands.'],
]
scores = model.predict(pairs)
print(scores)
# [[-2.6387  3.0625 -1.0605]
#  [ 3.3965 -0.6968 -1.874 ]
#  [-3.2012 -0.9272  3.6855]
#  [ 2.3809 -1.0547 -0.6987]
#  [-2.1973  1.748   0.0408]]

Evaluation

Metrics

Cross Encoder Classification

Metric ALLNLI-dev AllNLI-test
f1_macro 0.8226 0.7575
f1_micro 0.824 0.7576
f1_weighted 0.8226 0.7583

Training Details

Training Dataset

all-nli

  • Dataset: all-nli
  • Size: 100,000 training samples
  • Columns: premise, hypothesis, and label
  • Approximate statistics based on the first 100 samples:
    premise hypothesis label
    type string string int
    modality text text
    details
    • min: 8 tokens
    • mean: 23.12 tokens
    • max: 45 tokens
    • min: 6 tokens
    • mean: 11.24 tokens
    • max: 25 tokens
    • 0: ~32.69%
    • 1: ~34.62%
    • 2: ~32.69%
  • Samples:
    premise hypothesis label
    A person on a horse jumps over a broken down airplane. A person is training his horse for a competition. 1
    A person on a horse jumps over a broken down airplane. A person is at a diner, ordering an omelette. 2
    A person on a horse jumps over a broken down airplane. A person is outdoors, on a horse. 0
  • Loss: CrossEntropyLoss

Evaluation Dataset

all-nli

  • Dataset: all-nli
  • Size: 1,000 evaluation samples
  • Columns: premise, hypothesis, and label
  • Approximate statistics based on the first 100 samples:
    premise hypothesis label
    type string string int
    modality text text
    details
    • min: 9 tokens
    • mean: 19.64 tokens
    • max: 36 tokens
    • min: 5 tokens
    • mean: 10.2 tokens
    • max: 24 tokens
    • 0: ~32.69%
    • 1: ~30.77%
    • 2: ~36.54%
  • Samples:
    premise hypothesis label
    Two women are embracing while holding to go packages. The sisters are hugging goodbye while holding to go packages after just eating lunch. 1
    Two women are embracing while holding to go packages. Two woman are holding packages. 0
    Two women are embracing while holding to go packages. The men are fighting outside a deli. 2
  • Loss: CrossEntropyLoss

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • num_train_epochs: 1
  • warmup_steps: 0.1
  • fp16: True
  • ddp_find_unused_parameters: False

All Hyperparameters

Click to expand
  • do_predict: False
  • prediction_loss_only: True
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • 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: None
  • warmup_ratio: None
  • warmup_steps: 0.1
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • enable_jit_checkpoint: False
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • use_cpu: False
  • seed: 42
  • data_seed: None
  • bf16: False
  • fp16: True
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: -1
  • ddp_backend: None
  • debug: []
  • dataloader_drop_last: True
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • ddp_find_unused_parameters: False
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • hub_revision: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • auto_find_batch_size: False
  • full_determinism: False
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_num_input_tokens_seen: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • use_cache: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss Validation Loss ALLNLI-dev_f1_macro AllNLI-test_f1_macro
-1 -1 - - 0.1658 -
0.1280 100 0.9521 - - -
0.2561 200 0.6069 - - -
0.3841 300 0.5517 - - -
0.5122 400 0.5313 - - -
0.6402 500 0.5126 0.3908 0.8226 -
0.7682 600 0.4918 - - -
0.8963 700 0.4655 - - -
-1 -1 - - - 0.7575

Training Time

  • Training: 2.2 minutes
  • Evaluation: 0.6 seconds
  • Total: 2.2 minutes

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 6.0.1
  • Transformers: 5.0.0
  • PyTorch: 2.10.0+cu128
  • Accelerate: 1.13.0
  • Datasets: 5.0.0
  • Tokenizers: 0.22.2

Additional Resources

Citation

BibTeX

Sentence Transformers

@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",
}
Downloads last month
14
Safetensors
Model size
82.1M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kwondw/reranker-distilroberta-base-nli

Finetuned
(777)
this model

Paper for kwondw/reranker-distilroberta-base-nli

Evaluation results