CrossEncoder based on BAAI/bge-reranker-v2-m3

This is a Cross Encoder model finetuned from BAAI/bge-reranker-v2-m3 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 Type: Cross Encoder
  • Base model: BAAI/bge-reranker-v2-m3
  • Maximum Sequence Length: 1024 tokens
  • Number of Output Labels: 1 label

Model Sources

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 texts
pairs = [
    ['When did the performer of song That Is All (Song) die?', 'Bill Kaulitz. Bill Kaulitz( born September 1, 1989), also known mononymously as Billy( stylized as BILLY) for his solo act, is a German singer, songwriter, voice actor, designer, and model. He is best known for his work from 2001 to the present as the lead singer of the band Tokio Hotel.'],
    ['Who was born first, Robert Macnish or Gustavo Dávila?', 'Alonso Mudarra. Alonso Mudarra( c. 1510 – April 1, 1580) was a Spanish composer of the Renaissance, and also played the vihuela, a guitar- shaped string instrument. He was an innovative composer of instrumental music as well as songs, and was the composer of the earliest surviving music for the guitar.'],
    ['Where was the place of death of the composer of song Ett Gammalt Fult Och Elakt Troll Det Var En Gång?', 'István Pauli. István Pauli or István Pável( July 13, 1760 – January 29, 1829) was a Hungarian Slovene Roman Catholic priests. Pauli or the teacher of Pertoča György Kousz was the author of a hymnal in Pertoča. He was born in Beltinci. His parents was Márk Pável and Katalin Gyrék. In Bratislava, was studied theology and in 1789 ordained. From 1790- 1797, he was the priest of Pertoča. On October 1, 1822, he retired and died in Szombathely.'],
    ['Are both Tolstoy-Yurt and Ebrahimabad, Jorjafak located in the same country?', 'Ebrahimabad, Jorjafak. Ebrahimabad( also Romanized as Ebrāhīmābād) is a village in Jorjafak Rural District, in the Central District of Zarand County, Kerman Province, Iran. At the 2006 census, its existence was noted, but its population was not reported.'],
    ['Do both directors of films The Outlaw Deputy and W La Foca share the same nationality?', 'Nando Cicero. Fernando Cicero, better known as Nando Cicero( 22 January 1931 – 30 July 1995), was an Italian film director, screenwriter and actor. Born in Asmara, Cicero debuted as an actor, working with directors such as Luchino Visconti(" Senso", 1953), Roberto Rossellini(" Vanina Vanini", 1961), Francesco Rosi(" Salvatore Giuliano", 1962) and Alberto Lattuada(" La steppa", 1962). He starred in eleven films between 1953 and 1962, always in supporting roles. After his directorial debut with" Lo scippo" he directed three Spaghetti Western films(" Professionals for a MassacreLast of the Badmen", and" Twice a Judas"). From 1970 he focused on comedy genre, directing some parody films starred by Franco Franchi and Ciccio Ingrassia. Starting with" The School Teacher" Cicero established himself as one of the most important and successful directors of the commedia sexy all\'italiana film genre. Following the decline of the genre, he retired in 1983; his last film was" Paulo Roberto Cotechino", starring Alvaro Vitali and Carmen Russo. He died in 1995 at age 64.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'When did the performer of song That Is All (Song) die?',
    [
        'Bill Kaulitz. Bill Kaulitz( born September 1, 1989), also known mononymously as Billy( stylized as BILLY) for his solo act, is a German singer, songwriter, voice actor, designer, and model. He is best known for his work from 2001 to the present as the lead singer of the band Tokio Hotel.',
        'Alonso Mudarra. Alonso Mudarra( c. 1510 – April 1, 1580) was a Spanish composer of the Renaissance, and also played the vihuela, a guitar- shaped string instrument. He was an innovative composer of instrumental music as well as songs, and was the composer of the earliest surviving music for the guitar.',
        'István Pauli. István Pauli or István Pável( July 13, 1760 – January 29, 1829) was a Hungarian Slovene Roman Catholic priests. Pauli or the teacher of Pertoča György Kousz was the author of a hymnal in Pertoča. He was born in Beltinci. His parents was Márk Pável and Katalin Gyrék. In Bratislava, was studied theology and in 1789 ordained. From 1790- 1797, he was the priest of Pertoča. On October 1, 1822, he retired and died in Szombathely.',
        'Ebrahimabad, Jorjafak. Ebrahimabad( also Romanized as Ebrāhīmābād) is a village in Jorjafak Rural District, in the Central District of Zarand County, Kerman Province, Iran. At the 2006 census, its existence was noted, but its population was not reported.',
        'Nando Cicero. Fernando Cicero, better known as Nando Cicero( 22 January 1931 – 30 July 1995), was an Italian film director, screenwriter and actor. Born in Asmara, Cicero debuted as an actor, working with directors such as Luchino Visconti(" Senso", 1953), Roberto Rossellini(" Vanina Vanini", 1961), Francesco Rosi(" Salvatore Giuliano", 1962) and Alberto Lattuada(" La steppa", 1962). He starred in eleven films between 1953 and 1962, always in supporting roles. After his directorial debut with" Lo scippo" he directed three Spaghetti Western films(" Professionals for a MassacreLast of the Badmen", and" Twice a Judas"). From 1970 he focused on comedy genre, directing some parody films starred by Franco Franchi and Ciccio Ingrassia. Starting with" The School Teacher" Cicero established himself as one of the most important and successful directors of the commedia sexy all\'italiana film genre. Following the decline of the genre, he retired in 1983; his last film was" Paulo Roberto Cotechino", starring Alvaro Vitali and Carmen Russo. He died in 1995 at age 64.',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Evaluation

Metrics

Cross Encoder Binary Classification

Metric validation train_subset
accuracy 0.7816 0.798
accuracy_threshold 0.0775 0.9966
f1 0.8137 0.7878
f1_threshold 0.0775 0.9962
precision 0.7094 0.7659
recall 0.954 0.8109
average_precision 0.86 0.849

Training Details

Training Dataset

Unnamed Dataset

  • Size: 9,540 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
    • min: 29 characters
    • mean: 75.29 characters
    • max: 156 characters
    • min: 62 characters
    • mean: 572.85 characters
    • max: 3633 characters
    • min: 0.0
    • mean: 0.5
    • max: 1.0
  • Samples:
    sentence_0 sentence_1 label
    When did the performer of song That Is All (Song) die? Bill Kaulitz. Bill Kaulitz( born September 1, 1989), also known mononymously as Billy( stylized as BILLY) for his solo act, is a German singer, songwriter, voice actor, designer, and model. He is best known for his work from 2001 to the present as the lead singer of the band Tokio Hotel. 0.0
    Who was born first, Robert Macnish or Gustavo Dávila? Alonso Mudarra. Alonso Mudarra( c. 1510 – April 1, 1580) was a Spanish composer of the Renaissance, and also played the vihuela, a guitar- shaped string instrument. He was an innovative composer of instrumental music as well as songs, and was the composer of the earliest surviving music for the guitar. 0.0
    Where was the place of death of the composer of song Ett Gammalt Fult Och Elakt Troll Det Var En Gång? István Pauli. István Pauli or István Pável( July 13, 1760 – January 29, 1829) was a Hungarian Slovene Roman Catholic priests. Pauli or the teacher of Pertoča György Kousz was the author of a hymnal in Pertoča. He was born in Beltinci. His parents was Márk Pável and Katalin Gyrék. In Bratislava, was studied theology and in 1789 ordained. From 1790- 1797, he was the priest of Pertoča. On October 1, 1822, he retired and died in Szombathely. 0.0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": null
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 2
  • per_device_eval_batch_size: 2

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 2
  • per_device_eval_batch_size: 2
  • 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
  • num_train_epochs: 3
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • 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: False
  • 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: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': 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: False
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • 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
  • eval_use_gather_object: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss validation_average_precision train_subset_average_precision
0.0210 100 - 0.9492 0.9331
0.0419 200 - 0.9308 0.9430
0.0629 300 - 0.9605 0.9477
0.0839 400 - 0.9349 0.8923
0.1048 500 0.6655 0.9409 0.8862
0.1258 600 - 0.9624 0.9524
0.1468 700 - 0.9480 0.9466
0.1677 800 - 0.9281 0.9424
0.1887 900 - 0.8600 0.8490

Framework Versions

  • Python: 3.11.13
  • Sentence Transformers: 5.2.0
  • Transformers: 4.44.2
  • PyTorch: 2.9.1+cu128
  • Accelerate: 1.12.0
  • Datasets: 4.0.0
  • Tokenizers: 0.19.1

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
2
Safetensors
Model size
0.6B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for OloriBern/2wikimultihopqa-bge-m3-2000

Finetuned
(67)
this model

Paper for OloriBern/2wikimultihopqa-bge-m3-2000

Evaluation results