ModernBERT-base trained on GooAQ

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 text reranking and semantic search.

Model Details

Model Description

  • Model Type: Cross Encoder
  • Base model: answerdotai/ModernBERT-base
  • Maximum Sequence Length: 8192 tokens
  • Number of Output Labels: 1 label
  • Supported Modality: Text
  • Language: en
  • License: apache-2.0

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

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-ModernBERT-base-gooaq-bce")
# Get scores for pairs of inputs
pairs = [
    ['what to spend my nectar points on?', "There are lots of different places and ways you can spend your points. You can spend straight from your card by swiping it at Sainsbury's, Vue Cinemas and Argos or you can spend them online at nectar.com on great things like holidays, hotels and days out."],
    ['what to spend my nectar points on?', "If you have already registered for Online Services, just log in to see your points balance. For detailed points transactions, go to Membership Rewards page and click on 'Your points Account' and then 'My Points' at the top of the page."],
    ['what to spend my nectar points on?', 'The SDIP authorized insurance rate increase are as follows: 1 point=25%, 2 points=45%, 3 points=65%, 4 points=90%, 5 points=120%, 6 points=150%, 7 points=180%, 8 points=220%, 9 points=260%, 10 points=300%, 11 points=350%, and 12 insurance points equals a 400% increase in your insurance premiums, ouch!'],
    ['what to spend my nectar points on?', 'To redeem your Amex Blue Sky points, log in to your account via the Amex travel portal. At the checkout, there will be an option to pay with points. Points are worth 1 cent each toward flights and 0.7 cents each toward other travel costs.'],
    ['what to spend my nectar points on?', 'Yes, TD rewards points are worth $0.005 each, and must be redeemed in increments of 10,000, at a value of $50 per 10,000 points.'],
]
scores = model.predict(pairs)
print(scores)
# [9.7463e-01 2.7169e-02 1.4214e-03 5.0407e-03 4.4422e-04]

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'what to spend my nectar points on?',
    [
        "There are lots of different places and ways you can spend your points. You can spend straight from your card by swiping it at Sainsbury's, Vue Cinemas and Argos or you can spend them online at nectar.com on great things like holidays, hotels and days out.",
        "If you have already registered for Online Services, just log in to see your points balance. For detailed points transactions, go to Membership Rewards page and click on 'Your points Account' and then 'My Points' at the top of the page.",
        'The SDIP authorized insurance rate increase are as follows: 1 point=25%, 2 points=45%, 3 points=65%, 4 points=90%, 5 points=120%, 6 points=150%, 7 points=180%, 8 points=220%, 9 points=260%, 10 points=300%, 11 points=350%, and 12 insurance points equals a 400% increase in your insurance premiums, ouch!',
        'To redeem your Amex Blue Sky points, log in to your account via the Amex travel portal. At the checkout, there will be an option to pay with points. Points are worth 1 cent each toward flights and 0.7 cents each toward other travel costs.',
        'Yes, TD rewards points are worth $0.005 each, and must be redeemed in increments of 10,000, at a value of $50 per 10,000 points.',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Evaluation

Metrics

Cross Encoder Reranking

Metric Value
map 0.7842 (+0.1739)
mrr@10 0.7827 (+0.1773)
ndcg@10 0.8182 (+0.1499)

Cross Encoder Reranking

  • Datasets: NanoMSMARCO_R100, NanoNFCorpus_R100 and NanoNQ_R100
  • Evaluated with CrossEncoderRerankingEvaluator with these parameters:
    {
        "at_k": 10,
        "always_rerank_positives": true
    }
    
Metric NanoMSMARCO_R100 NanoNFCorpus_R100 NanoNQ_R100
map 0.4839 (-0.0056) 0.3422 (+0.0812) 0.6052 (+0.1856)
mrr@10 0.4753 (-0.0022) 0.5542 (+0.0544) 0.6189 (+0.1922)
ndcg@10 0.5681 (+0.0277) 0.3908 (+0.0658) 0.6657 (+0.1651)

Cross Encoder Nano BEIR

  • Dataset: NanoBEIR_R100_mean
  • Evaluated with CrossEncoderNanoBEIREvaluator with these parameters:
    {
        "dataset_names": [
            "msmarco",
            "nfcorpus",
            "nq"
        ],
        "dataset_id": "sentence-transformers/NanoBEIR-en",
        "rerank_k": 100,
        "at_k": 10,
        "always_rerank_positives": true
    }
    
Metric Value
map 0.4771 (+0.0870)
mrr@10 0.5495 (+0.0814)
ndcg@10 0.5415 (+0.0862)

Training Details

Training Dataset

Unnamed Dataset

  • Size: 292,161 training samples
  • Columns: question, answer, and label
  • Approximate statistics based on the first 100 samples:
    question answer label
    type string string int
    modality text text
    details
    • min: 8 tokens
    • mean: 11.17 tokens
    • max: 14 tokens
    • min: 23 tokens
    • mean: 57.12 tokens
    • max: 115 tokens
    • 0: ~82.69%
    • 1: ~17.31%
  • Samples:
    question answer label
    what to spend my nectar points on? There are lots of different places and ways you can spend your points. You can spend straight from your card by swiping it at Sainsbury's, Vue Cinemas and Argos or you can spend them online at nectar.com on great things like holidays, hotels and days out. 1
    what to spend my nectar points on? If you have already registered for Online Services, just log in to see your points balance. For detailed points transactions, go to Membership Rewards page and click on 'Your points Account' and then 'My Points' at the top of the page. 0
    what to spend my nectar points on? The SDIP authorized insurance rate increase are as follows: 1 point=25%, 2 points=45%, 3 points=65%, 4 points=90%, 5 points=120%, 6 points=150%, 7 points=180%, 8 points=220%, 9 points=260%, 10 points=300%, 11 points=350%, and 12 insurance points equals a 400% increase in your insurance premiums, ouch! 0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": 5
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 64
  • num_train_epochs: 1
  • learning_rate: 2e-05
  • warmup_steps: 0.1
  • fp16: True
  • per_device_eval_batch_size: 64
  • load_best_model_at_end: True
  • seed: 12
  • dataloader_num_workers: 2

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 64
  • num_train_epochs: 1
  • 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: True
  • 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: 12
  • 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: 2
  • 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: None
  • fsdp_config: None
  • 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 gooaq-dev_ndcg@10 NanoMSMARCO_R100_ndcg@10 NanoNFCorpus_R100_ndcg@10 NanoNQ_R100_ndcg@10 NanoBEIR_R100_mean_ndcg@10
-1 -1 - 0.1149 (-0.5534) 0.0212 (-0.5192) 0.2526 (-0.0724) 0.0288 (-0.4719) 0.1009 (-0.3545)
0.0002 1 1.3195 - - - - -
0.0438 200 1.1767 - - - - -
0.0876 400 1.0007 - - - - -
0.1095 500 - 0.7463 (+0.0779) 0.4619 (-0.0785) 0.3117 (-0.0133) 0.5694 (+0.0688) 0.4477 (-0.0077)
0.1314 600 0.6751 - - - - -
0.1752 800 0.6153 - - - - -
0.2190 1000 0.5813 0.7963 (+0.1279) 0.5554 (+0.0150) 0.3518 (+0.0267) 0.6018 (+0.1012) 0.5030 (+0.0476)
0.2628 1200 0.5345 - - - - -
0.3066 1400 0.5544 - - - - -
0.3285 1500 - 0.8035 (+0.1351) 0.5196 (-0.0208) 0.3772 (+0.0522) 0.6118 (+0.1111) 0.5029 (+0.0475)
0.3504 1600 0.5324 - - - - -
0.3942 1800 0.5199 - - - - -
0.4380 2000 0.5015 0.8045 (+0.1362) 0.5731 (+0.0326) 0.3638 (+0.0387) 0.6564 (+0.1558) 0.5311 (+0.0757)
0.4818 2200 0.4899 - - - - -
0.5256 2400 0.4703 - - - - -
0.5475 2500 - 0.8030 (+0.1346) 0.5821 (+0.0417) 0.3820 (+0.0569) 0.6695 (+0.1688) 0.5445 (+0.0892)
0.5694 2600 0.4863 - - - - -
0.6132 2800 0.4823 - - - - -
0.6570 3000 0.4656 0.8066 (+0.1382) 0.5458 (+0.0054) 0.3882 (+0.0632) 0.6386 (+0.1379) 0.5242 (+0.0688)
0.7008 3200 0.4689 - - - - -
0.7446 3400 0.4595 - - - - -
0.7665 3500 - 0.8146 (+0.1462) 0.5861 (+0.0456) 0.3904 (+0.0654) 0.6578 (+0.1572) 0.5448 (+0.0894)
0.7884 3600 0.4484 - - - - -
0.8322 3800 0.4597 - - - - -
0.876 4000 0.4482 0.8182 (+0.1499) 0.5681 (+0.0277) 0.3908 (+0.0658) 0.6657 (+0.1651) 0.5415 (+0.0862)
0.9198 4200 0.4488 - - - - -
0.9636 4400 0.4548 - - - - -
0.9855 4500 - 0.8168 (+0.1484) 0.5612 (+0.0208) 0.4006 (+0.0755) 0.6864 (+0.1858) 0.5494 (+0.0940)
1.0 4566 - 0.8166 (+0.1482) 0.5640 (+0.0236) 0.4006 (+0.0755) 0.6838 (+0.1832) 0.5495 (+0.0941)
-1 -1 - 0.8182 (+0.1499) 0.5681 (+0.0277) 0.3908 (+0.0658) 0.6657 (+0.1651) 0.5415 (+0.0862)
  • The bold row denotes the saved checkpoint.

Training Time

  • Training: 1.5 hours

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 5.6.0
  • Transformers: 5.13.1
  • PyTorch: 2.11.0+cu128
  • Accelerate: 1.14.0
  • Datasets: 4.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
-
Safetensors
Model size
0.1B 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-ModernBERT-base-gooaq-bce

Finetuned
(1404)
this model

Paper for kwondw/reranker-ModernBERT-base-gooaq-bce

Evaluation results