CrossEncoder based on cross-encoder/ms-marco-MiniLM-L6-v2

This is a Cross Encoder model finetuned from cross-encoder/ms-marco-MiniLM-L6-v2 using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.

Model Details

Model Description

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': 'BertForSequenceClassification'})
)

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("cross_encoder_model_id")
# Get scores for pairs of inputs
pairs = [
    ['skill: manage health care staff', 'skill: manage healthcare staff'],
    ['skill: manage health care staff', 'skill: manage staff'],
    ['skill: manage health care staff', 'skill: manage physiotherapy staff'],
    ['skill: manage health care staff', 'skill: manage a multidisciplinary team involved in patient care'],
    ['skill: manage health care staff', 'skill: work with nursing staff'],
]
scores = model.predict(pairs)
print(scores)
# [ 4.398  -1.7689 -3.7867 -3.7799 -4.4436]

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'skill: manage health care staff',
    [
        'skill: manage healthcare staff',
        'skill: manage staff',
        'skill: manage physiotherapy staff',
        'skill: manage a multidisciplinary team involved in patient care',
        'skill: work with nursing staff',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Training Details

Training Dataset

Unnamed Dataset

  • Size: 11,010 training samples
  • Columns: sentence_A, sentence_B, and label
  • Approximate statistics based on the first 100 samples:
    sentence_A sentence_B label
    type string string float
    modality text text
    details
    • min: 7 tokens
    • mean: 8.15 tokens
    • max: 11 tokens
    • min: 6 tokens
    • mean: 7.49 tokens
    • max: 9 tokens
    • min: 0.0
    • mean: 0.2
    • max: 1.0
  • Samples:
    sentence_A sentence_B label
    skill: manage security systems skill: manage technical security systems 1.0
    skill: manage security systems skill: manage system security 0.0
    skill: manage security systems skill: manage alarm system 0.0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": null
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 1,505 evaluation samples
  • Columns: sentence_A, sentence_B, and label
  • Approximate statistics based on the first 100 samples:
    sentence_A sentence_B label
    type string string float
    modality text text
    details
    • min: 6 tokens
    • mean: 9.26 tokens
    • max: 14 tokens
    • min: 6 tokens
    • mean: 8.34 tokens
    • max: 16 tokens
    • min: 0.0
    • mean: 0.2
    • max: 1.0
  • Samples:
    sentence_A sentence_B label
    skill: manage health care staff skill: manage healthcare staff 1.0
    skill: manage health care staff skill: manage staff 0.0
    skill: manage health care staff skill: manage physiotherapy staff 0.0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": null
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 32
  • num_train_epochs: 2
  • learning_rate: 2e-05
  • warmup_steps: 0.1
  • per_device_eval_batch_size: 64
  • load_best_model_at_end: True

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 32
  • num_train_epochs: 2
  • max_steps: -1
  • learning_rate: 2e-05
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: None
  • warmup_steps: 0.1
  • optim: adamw_torch_fused
  • optim_args: None
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • optim_target_modules: None
  • gradient_accumulation_steps: 1
  • average_tokens_across_devices: True
  • max_grad_norm: 1.0
  • label_smoothing_factor: 0.0
  • bf16: False
  • fp16: False
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • use_liger_kernel: False
  • liger_kernel_config: None
  • use_cache: False
  • neftune_noise_alpha: None
  • torch_empty_cache_steps: None
  • auto_find_batch_size: False
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • include_num_input_tokens_seen: no
  • log_level: passive
  • log_level_replica: warning
  • disable_tqdm: False
  • project: huggingface
  • trackio_space_id: None
  • trackio_bucket_id: None
  • trackio_static_space_id: None
  • per_device_eval_batch_size: 64
  • prediction_loss_only: True
  • eval_on_start: False
  • eval_do_concat_batches: True
  • eval_use_gather_object: False
  • eval_accumulation_steps: None
  • include_for_metrics: []
  • batch_eval_metrics: False
  • save_only_model: False
  • save_on_each_node: False
  • enable_jit_checkpoint: False
  • push_to_hub: False
  • hub_private_repo: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_always_push: False
  • hub_revision: None
  • load_best_model_at_end: True
  • ignore_data_skip: False
  • restore_callback_states_from_checkpoint: False
  • full_determinism: False
  • seed: 42
  • data_seed: None
  • use_cpu: 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
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • dataloader_prefetch_factor: None
  • remove_unused_columns: True
  • label_names: None
  • train_sampling_strategy: random
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • ddp_static_graph: None
  • ddp_backend: None
  • ddp_timeout: 1800
  • fsdp: []
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • deepspeed: None
  • debug: []
  • skip_memory_metrics: True
  • do_predict: False
  • resume_from_checkpoint: None
  • warmup_ratio: None
  • local_rank: -1
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss Validation Loss
0.0580 20 0.9453 -
0.1159 40 0.5269 -
0.1739 60 0.4222 -
0.2319 80 0.3795 -
0.2899 100 0.3090 -
0.3478 120 0.3580 -
0.4058 140 0.3126 -
0.4638 160 0.2220 -
0.5217 180 0.2884 -
0.5797 200 0.2795 -
0.6377 220 0.2328 -
0.6957 240 0.2573 -
0.7536 260 0.2493 -
0.8116 280 0.2100 -
0.8696 300 0.2548 -
0.9275 320 0.2212 -
0.9855 340 0.2308 -
1.0 345 - 0.257
1.0435 360 0.2258 -
1.1014 380 0.1895 -
1.1594 400 0.1689 -
1.2174 420 0.2283 -
1.2754 440 0.2253 -
1.3333 460 0.2040 -
1.3913 480 0.1850 -
1.4493 500 0.1932 -
1.5072 520 0.1920 -
1.5652 540 0.1964 -
1.6232 560 0.1571 -
1.6812 580 0.2132 -
1.7391 600 0.1823 -
1.7971 620 0.1950 -
1.8551 640 0.1787 -
1.9130 660 0.2028 -
1.9710 680 0.1840 -
2.0 690 - 0.2671
  • The bold row denotes the saved checkpoint.

Training Time

  • Training: 55.0 seconds
  • Evaluation: 1.1 seconds
  • Total: 56.1 seconds

Framework Versions

  • Python: 3.13.13
  • Sentence Transformers: 5.5.0
  • Transformers: 5.8.1
  • PyTorch: 2.12.0
  • Accelerate: 1.14.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
20
Safetensors
Model size
22.7M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for rohit-vt/tink-reranker-minilm

Paper for rohit-vt/tink-reranker-minilm