CrossEncoder based on answerdotai/ModernBERT-base

This is a Cross Encoder model finetuned from answerdotai/ModernBERT-base 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: answerdotai/ModernBERT-base
  • Maximum Sequence Length: 8192 tokens
  • Number of Output Labels: 1 label
  • Language: en

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("tomaarsen/reranker-ModernBERT-base-nq-bce-static-retriever")
# Get scores for pairs of texts
pairs = [
    ['difference between russian blue and british blue cat', 'Russian Blue The coat is known as a "double coat", with the undercoat being soft, downy and equal in length to the guard hairs, which are an even blue with silver tips. However, the tail may have a few very dull, almost unnoticeable stripes. The coat is described as thick, plush and soft to the touch. The feeling is softer than the softest silk. The silver tips give the coat a shimmering appearance. Its eyes are almost always a dark and vivid green. Any white patches of fur or yellow eyes in adulthood are seen as flaws in show cats.[3] Russian Blues should not be confused with British Blues (which are not a distinct breed, but rather a British Shorthair with a blue coat as the British Shorthair breed itself comes in a wide variety of colors and patterns), nor the Chartreux or Korat which are two other naturally occurring breeds of blue cats, although they have similar traits.'],
    ['who played the little girl on mrs doubtfire', 'Mara Wilson Mara Elizabeth Wilson[2] (born July 24, 1987) is an American writer and former child actress. She is known for playing Natalie Hillard in Mrs. Doubtfire (1993), Susan Walker in Miracle on 34th Street (1994), Matilda Wormwood in Matilda (1996) and Lily Stone in Thomas and the Magic Railroad (2000). Since retiring from film acting, Wilson has focused on writing.'],
    ['what year did the movie the sound of music come out', 'The Sound of Music (film) The film was released on March 2, 1965 in the United States, initially as a limited roadshow theatrical release. Although critical response to the film was widely mixed, the film was a major commercial success, becoming the number one box office movie after four weeks, and the highest-grossing film of 1965. By November 1966, The Sound of Music had become the highest-grossing film of all-time—surpassing Gone with the Wind—and held that distinction for five years. The film was just as popular throughout the world, breaking previous box-office records in twenty-nine countries. Following an initial theatrical release that lasted four and a half years, and two successful re-releases, the film sold 283 million admissions worldwide and earned a total worldwide gross of $286,000,000.'],
    ['where was the movie dawn of the dead filmed', 'Dawn of the Dead (2004 film) The mall scenes and rooftop scenes were shot in the former Thornhill Square Shopping Centre in Thornhill, Ontario, and the other scenes were shot in the Aileen-Willowbrook neighborhood of Thornhill. The set for Ana and Luis\'s bedroom was constructed in a back room of the mall.[7] The mall was defunct, which is the reason the production used it; the movie crew completely renovated the structure, and stocked it with fictitious stores after Starbucks and numerous other corporations refused to let their names be used[7] (two exceptions to this are Roots and Panasonic). Most of the mall was demolished shortly after the film was shot. The fictitious stores include a coffee shop called Hallowed Grounds (a lyric from Johnny Cash\'s song "The Man Comes Around", which was used over the opening credits), and an upscale department store called Gaylen Ross (an in-joke reference to one of the stars of the original 1978 film).'],
    ['where is the 2018 nba draft being held', "2018 NBA draft The 2018 NBA draft was held on June 21, 2018, at Barclays Center in Brooklyn, New York. National Basketball Association (NBA) teams took turns selecting amateur United States college basketball players and other eligible players, including international players. It was televised nationally by ESPN. This draft was the last to use the original weighted lottery system that gives teams near the bottom of the NBA draft better odds at the top three picks of the draft while teams higher up had worse odds in the process; the rule was agreed upon by the NBA on September 28, 2017, but would not be implemented until the 2019 draft.[2] With the last year of what was, at the time, the most recent lottery system (with the NBA draft lottery being held in Chicago instead of in New York), the Phoenix Suns won the first overall pick on May 15, 2018, with the Sacramento Kings at the second overall pick and the Atlanta Hawks at third overall pick.[3] The Suns' selection is their first No. 1 overall selection in franchise history. They would use that selection on the Bahamian center DeAndre Ayton from the nearby University of Arizona."],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'difference between russian blue and british blue cat',
    [
        'Russian Blue The coat is known as a "double coat", with the undercoat being soft, downy and equal in length to the guard hairs, which are an even blue with silver tips. However, the tail may have a few very dull, almost unnoticeable stripes. The coat is described as thick, plush and soft to the touch. The feeling is softer than the softest silk. The silver tips give the coat a shimmering appearance. Its eyes are almost always a dark and vivid green. Any white patches of fur or yellow eyes in adulthood are seen as flaws in show cats.[3] Russian Blues should not be confused with British Blues (which are not a distinct breed, but rather a British Shorthair with a blue coat as the British Shorthair breed itself comes in a wide variety of colors and patterns), nor the Chartreux or Korat which are two other naturally occurring breeds of blue cats, although they have similar traits.',
        'Mara Wilson Mara Elizabeth Wilson[2] (born July 24, 1987) is an American writer and former child actress. She is known for playing Natalie Hillard in Mrs. Doubtfire (1993), Susan Walker in Miracle on 34th Street (1994), Matilda Wormwood in Matilda (1996) and Lily Stone in Thomas and the Magic Railroad (2000). Since retiring from film acting, Wilson has focused on writing.',
        'The Sound of Music (film) The film was released on March 2, 1965 in the United States, initially as a limited roadshow theatrical release. Although critical response to the film was widely mixed, the film was a major commercial success, becoming the number one box office movie after four weeks, and the highest-grossing film of 1965. By November 1966, The Sound of Music had become the highest-grossing film of all-time—surpassing Gone with the Wind—and held that distinction for five years. The film was just as popular throughout the world, breaking previous box-office records in twenty-nine countries. Following an initial theatrical release that lasted four and a half years, and two successful re-releases, the film sold 283 million admissions worldwide and earned a total worldwide gross of $286,000,000.',
        'Dawn of the Dead (2004 film) The mall scenes and rooftop scenes were shot in the former Thornhill Square Shopping Centre in Thornhill, Ontario, and the other scenes were shot in the Aileen-Willowbrook neighborhood of Thornhill. The set for Ana and Luis\'s bedroom was constructed in a back room of the mall.[7] The mall was defunct, which is the reason the production used it; the movie crew completely renovated the structure, and stocked it with fictitious stores after Starbucks and numerous other corporations refused to let their names be used[7] (two exceptions to this are Roots and Panasonic). Most of the mall was demolished shortly after the film was shot. The fictitious stores include a coffee shop called Hallowed Grounds (a lyric from Johnny Cash\'s song "The Man Comes Around", which was used over the opening credits), and an upscale department store called Gaylen Ross (an in-joke reference to one of the stars of the original 1978 film).',
        "2018 NBA draft The 2018 NBA draft was held on June 21, 2018, at Barclays Center in Brooklyn, New York. National Basketball Association (NBA) teams took turns selecting amateur United States college basketball players and other eligible players, including international players. It was televised nationally by ESPN. This draft was the last to use the original weighted lottery system that gives teams near the bottom of the NBA draft better odds at the top three picks of the draft while teams higher up had worse odds in the process; the rule was agreed upon by the NBA on September 28, 2017, but would not be implemented until the 2019 draft.[2] With the last year of what was, at the time, the most recent lottery system (with the NBA draft lottery being held in Chicago instead of in New York), the Phoenix Suns won the first overall pick on May 15, 2018, with the Sacramento Kings at the second overall pick and the Atlanta Hawks at third overall pick.[3] The Suns' selection is their first No. 1 overall selection in franchise history. They would use that selection on the Bahamian center DeAndre Ayton from the nearby University of Arizona.",
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Evaluation

Metrics

Cross Encoder Reranking

Metric nq-dev NanoMSMARCO NanoNFCorpus NanoNQ
map 0.7173 (+0.2201) 0.5918 (+0.1023) 0.3481 (+0.0777) 0.6627 (+0.2420)
mrr@10 0.7152 (+0.2280) 0.5830 (+0.1055) 0.5808 (+0.0810) 0.6765 (+0.2498)
ndcg@10 0.7762 (+0.2164) 0.6454 (+0.1049) 0.4131 (+0.0880) 0.7091 (+0.2084)

Cross Encoder Nano BEIR

Metric Value
map 0.5342 (+0.1407)
mrr@10 0.6135 (+0.1454)
ndcg@10 0.5892 (+0.1338)

Training Details

Training Dataset

Unnamed Dataset

  • Size: 522,240 training samples
  • Columns: query, response, and label
  • Approximate statistics based on the first 1000 samples:
    query response label
    type string string int
    details
    • min: 27 characters
    • mean: 47.59 characters
    • max: 99 characters
    • min: 87 characters
    • mean: 606.97 characters
    • max: 2412 characters
    • 1: 100.00%
  • Samples:
    query response label
    who said my enemy's enemy is my friend The enemy of my enemy is my friend The enemy of my enemy is my friend is an ancient proverb which suggests that two opposing parties can or should work together against a common enemy. The earliest known expression of this concept is found in a Sanskrit treatise on statecraft, the Arthashastra, which dates to around the 4th century BC, while the first recorded use of the current English version came in 1884.[1][2] 1
    when does the nba season start and end 2017–18 NBA season The 2017–18 NBA season is the 72nd season of the National Basketball Association (NBA). The regular season began on October 17, 2017, earlier than previous seasons to reduce the number of "back-to-back" games teams are scheduled to play,[1] with the 2017 Eastern Conference champion (and Finals runner–up) Cleveland Cavaliers hosting a game against the Boston Celtics at Quicken Loans Arena in Cleveland, Ohio[2] Christmas games were played on December 25, 2017. The 2018 NBA All-Star Game was played on February 18, 2018, at the Staples Center in Los Angeles, California. LeBron James of the Cleveland Cavaliers was named the All-Star Game Most Valuable Player. The regular season will end on April 11, 2018 and the playoffs will begin on April 14, 2018.[3] 1
    what is the basis of supreme court decisions Supreme court A supreme court is the highest court within the hierarchy of courts in many legal jurisdictions. Other descriptions for such courts include court of last resort, apex court, and highest (or final) court of appeal. Broadly speaking, the decisions of a supreme court are not subject to further review by any other court. Supreme courts typically function primarily as appellate courts, hearing appeals from decisions of lower trial courts, or from intermediate-level appellate courts.[1] 1
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fct": "torch.nn.modules.linear.Identity",
        "pos_weight": 5
    }
    

Evaluation Dataset

natural-questions

  • Dataset: natural-questions at f9e894e
  • Size: 100,231 evaluation samples
  • Columns: query, response, and label
  • Approximate statistics based on the first 1000 samples:
    query response label
    type string string int
    details
    • min: 27 characters
    • mean: 47.03 characters
    • max: 96 characters
    • min: 26 characters
    • mean: 608.17 characters
    • max: 2639 characters
    • 1: 100.00%
  • Samples:
    query response label
    difference between russian blue and british blue cat Russian Blue The coat is known as a "double coat", with the undercoat being soft, downy and equal in length to the guard hairs, which are an even blue with silver tips. However, the tail may have a few very dull, almost unnoticeable stripes. The coat is described as thick, plush and soft to the touch. The feeling is softer than the softest silk. The silver tips give the coat a shimmering appearance. Its eyes are almost always a dark and vivid green. Any white patches of fur or yellow eyes in adulthood are seen as flaws in show cats.[3] Russian Blues should not be confused with British Blues (which are not a distinct breed, but rather a British Shorthair with a blue coat as the British Shorthair breed itself comes in a wide variety of colors and patterns), nor the Chartreux or Korat which are two other naturally occurring breeds of blue cats, although they have similar traits. 1
    who played the little girl on mrs doubtfire Mara Wilson Mara Elizabeth Wilson[2] (born July 24, 1987) is an American writer and former child actress. She is known for playing Natalie Hillard in Mrs. Doubtfire (1993), Susan Walker in Miracle on 34th Street (1994), Matilda Wormwood in Matilda (1996) and Lily Stone in Thomas and the Magic Railroad (2000). Since retiring from film acting, Wilson has focused on writing. 1
    what year did the movie the sound of music come out The Sound of Music (film) The film was released on March 2, 1965 in the United States, initially as a limited roadshow theatrical release. Although critical response to the film was widely mixed, the film was a major commercial success, becoming the number one box office movie after four weeks, and the highest-grossing film of 1965. By November 1966, The Sound of Music had become the highest-grossing film of all-time—surpassing Gone with the Wind—and held that distinction for five years. The film was just as popular throughout the world, breaking previous box-office records in twenty-nine countries. Following an initial theatrical release that lasted four and a half years, and two successful re-releases, the film sold 283 million admissions worldwide and earned a total worldwide gross of $286,000,000. 1
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fct": "torch.nn.modules.linear.Identity",
        "pos_weight": 5
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • learning_rate: 2e-05
  • num_train_epochs: 1
  • warmup_ratio: 0.1
  • seed: 12
  • bf16: True
  • dataloader_num_workers: 4
  • load_best_model_at_end: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • 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: 2e-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: 12
  • 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: 4
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: True
  • 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: 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: no_duplicates
  • multi_dataset_batch_sampler: proportional

Training Logs

Epoch Step Training Loss Validation Loss nq-dev_ndcg@10 NanoMSMARCO_ndcg@10 NanoNFCorpus_ndcg@10 NanoNQ_ndcg@10 NanoBEIR_mean_ndcg@10
-1 -1 - - 0.1601 (-0.3997) 0.0058 (-0.5346) 0.2751 (-0.0500) 0.0181 (-0.4826) 0.0996 (-0.3557)
0.0001 1 1.4341 - - - - - -
0.0245 200 1.151 - - - - - -
0.0490 400 0.9215 - - - - - -
0.0735 600 0.3631 - - - - - -
0.0980 800 0.2496 - - - - - -
0.1225 1000 0.2019 0.9056 0.7381 (+0.1783) 0.5730 (+0.0326) 0.3626 (+0.0376) 0.6462 (+0.1456) 0.5273 (+0.0719)
0.1471 1200 0.1735 - - - - - -
0.1716 1400 0.1771 - - - - - -
0.1961 1600 0.1619 - - - - - -
0.2206 1800 0.127 - - - - - -
0.2451 2000 0.1351 2.1863 0.7491 (+0.1892) 0.6261 (+0.0856) 0.3637 (+0.0386) 0.6990 (+0.1984) 0.5629 (+0.1076)
0.2696 2200 0.131 - - - - - -
0.2941 2400 0.1382 - - - - - -
0.3186 2600 0.1322 - - - - - -
0.3431 2800 0.1129 - - - - - -
0.3676 3000 0.1297 1.3222 0.7722 (+0.2124) 0.6252 (+0.0847) 0.3888 (+0.0638) 0.6977 (+0.1971) 0.5706 (+0.1152)
0.3922 3200 0.1137 - - - - - -
0.4167 3400 0.115 - - - - - -
0.4412 3600 0.108 - - - - - -
0.4657 3800 0.1066 - - - - - -
0.4902 4000 0.1036 2.0361 0.7707 (+0.2109) 0.6332 (+0.0928) 0.3763 (+0.0513) 0.6758 (+0.1752) 0.5618 (+0.1064)
0.5147 4200 0.0914 - - - - - -
0.5392 4400 0.099 - - - - - -
0.5637 4600 0.1086 - - - - - -
0.5882 4800 0.1055 - - - - - -
0.6127 5000 0.1081 1.8660 0.7736 (+0.2138) 0.6228 (+0.0824) 0.4040 (+0.0790) 0.6995 (+0.1988) 0.5754 (+0.1201)
0.6373 5200 0.0934 - - - - - -
0.6618 5400 0.0972 - - - - - -
0.6863 5600 0.093 - - - - - -
0.7108 5800 0.0859 - - - - - -
0.7353 6000 0.0791 1.4301 0.7762 (+0.2164) 0.6454 (+0.1049) 0.4131 (+0.0880) 0.7091 (+0.2084) 0.5892 (+0.1338)
0.7598 6200 0.0809 - - - - - -
0.7843 6400 0.0775 - - - - - -
0.8088 6600 0.093 - - - - - -
0.8333 6800 0.0812 - - - - - -
0.8578 7000 0.0922 1.8314 0.7868 (+0.2270) 0.6344 (+0.0940) 0.4028 (+0.0777) 0.7228 (+0.2221) 0.5867 (+0.1313)
0.8824 7200 0.0755 - - - - - -
0.9069 7400 0.0743 - - - - - -
0.9314 7600 0.0738 - - - - - -
0.9559 7800 0.0746 - - - - - -
0.9804 8000 0.081 1.5947 0.7891 (+0.2293) 0.6256 (+0.0852) 0.3994 (+0.0743) 0.7256 (+0.2250) 0.5835 (+0.1282)
-1 -1 - - 0.7762 (+0.2164) 0.6454 (+0.1049) 0.4131 (+0.0880) 0.7091 (+0.2084) 0.5892 (+0.1338)
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.11.10
  • Sentence Transformers: 3.5.0.dev0
  • Transformers: 4.49.0.dev0
  • PyTorch: 2.6.0.dev20241112+cu121
  • Accelerate: 1.2.0
  • Datasets: 3.2.0
  • Tokenizers: 0.21.0

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
150M params
Tensor type
F32
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The HF Inference API does not support text-classification models for sentence-transformers library.

Model tree for tomaarsen/reranker-ModernBERT-base-nq-bce-static-retriever

Finetuned
(355)
this model

Dataset used to train tomaarsen/reranker-ModernBERT-base-nq-bce-static-retriever