MordernBERT-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-50k")
# Get scores for pairs of inputs
pairs = [
['is corpse bride on hulu?', ". Watch Corpse Bride on Hulu either streaming online or on your favorite device. It's easy to watch Corpse Bride streaming online if you have either the Hulu basic or the Hulu Premium. ... HBO Max now has Corpse Bride streaming with a subscription."],
['is corpse bride on hulu?', 'When you put your day-of timeline together, try to keep these guidelines in mind: Makeup: 30–45 minutes per bridesmaid and mother of the bride, 60–90 minutes for the bride. Hair: 30–45 minutes per bridesmaid and mother of the bride, 60–90 minutes for the bride.'],
['is corpse bride on hulu?', "A dowry is a transfer of parental property, gifts, or money at the marriage of a daughter (bride). ... While bride price or bride service is a payment by the groom or his family to the bride's parents, dowry is the wealth transferred from the bride's family to the groom or his family, ostensibly for the bride."],
['is corpse bride on hulu?', 'The traditional wedding speech order goes father of the bride, groom, best man and other toasts. However, lots of brides now choose to give a speech, as do the bridesmaids or maid of honour. If you are including these, the order should go: father of the bride, groom, bride, bridesmaids/maid of honour, best man.'],
['is corpse bride on hulu?', "If the bride can afford to, it's a very thoughtful gesture for her to pay for the dress or a portion of the cost for each of her bridesmaids. ... Generally speaking, bridesmaids are expected to pay for their own dresses and accessories, as well as potentially hair and makeup appointments and transportation to the wedding."],
]
scores = model.predict(pairs)
print(scores)
# [9.9504e-01 4.7737e-03 1.2148e-04 1.8603e-03 2.1824e-04]
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'is corpse bride on hulu?',
[
". Watch Corpse Bride on Hulu either streaming online or on your favorite device. It's easy to watch Corpse Bride streaming online if you have either the Hulu basic or the Hulu Premium. ... HBO Max now has Corpse Bride streaming with a subscription.",
'When you put your day-of timeline together, try to keep these guidelines in mind: Makeup: 30–45 minutes per bridesmaid and mother of the bride, 60–90 minutes for the bride. Hair: 30–45 minutes per bridesmaid and mother of the bride, 60–90 minutes for the bride.',
"A dowry is a transfer of parental property, gifts, or money at the marriage of a daughter (bride). ... While bride price or bride service is a payment by the groom or his family to the bride's parents, dowry is the wealth transferred from the bride's family to the groom or his family, ostensibly for the bride.",
'The traditional wedding speech order goes father of the bride, groom, best man and other toasts. However, lots of brides now choose to give a speech, as do the bridesmaids or maid of honour. If you are including these, the order should go: father of the bride, groom, bride, bridesmaids/maid of honour, best man.',
"If the bride can afford to, it's a very thoughtful gesture for her to pay for the dress or a portion of the cost for each of her bridesmaids. ... Generally speaking, bridesmaids are expected to pay for their own dresses and accessories, as well as potentially hair and makeup appointments and transportation to the wedding.",
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
Evaluation
Metrics
Cross Encoder Reranking
| Metric | Value |
|---|
| map | 0.5969 (+0.2482) |
| mrr@10 | 0.5964 (+0.2582) |
| ndcg@10 | 0.6408 (+0.2404) |
Cross Encoder Reranking
| Metric | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
|---|
| map | 0.4076 (-0.0820) | 0.3461 (+0.0851) | 0.4223 (+0.0027) |
| mrr@10 | 0.3912 (-0.0863) | 0.4815 (-0.0183) | 0.4446 (+0.0179) |
| ndcg@10 | 0.4703 (-0.0702) | 0.3600 (+0.0349) | 0.4739 (-0.0267) |
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.3920 (+0.0019) |
| mrr@10 | 0.4391 (-0.0289) |
| ndcg@10 | 0.4347 (-0.0207) |
Training Details
Training Dataset
Unnamed Dataset
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 64
per_device_eval_batch_size: 64
learning_rate: 2e-05
num_train_epochs: 1
warmup_steps: 0.1
seed: 12
fp16: True
dataloader_num_workers: 2
load_best_model_at_end: True
ddp_find_unused_parameters: False
dataloader_persistent_workers: True
All Hyperparameters
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: 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: 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: 12
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: 2
dataloader_prefetch_factor: None
disable_tqdm: False
remove_unused_columns: True
label_names: None
load_best_model_at_end: True
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: True
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 | gooaq-dev_ndcg@10 | NanoMSMARCO_R100_ndcg@10 | NanoNFCorpus_R100_ndcg@10 | NanoNQ_R100_ndcg@10 | NanoBEIR_R100_mean_ndcg@10 |
|---|
| 0.0000 | 1 | 1.1154 | - | - | - | - | - |
| 0.0093 | 200 | 1.2221 | - | - | - | - | - |
| 0.0186 | 400 | 1.2006 | - | - | - | - | - |
| 0.0278 | 600 | 1.1757 | - | - | - | - | - |
| 0.0371 | 800 | 1.0125 | - | - | - | - | - |
| 0.0464 | 1000 | 0.8074 | - | - | - | - | - |
| 0.0557 | 1200 | 0.7453 | - | - | - | - | - |
| 0.0650 | 1400 | 0.7043 | - | - | - | - | - |
| 0.0742 | 1600 | 0.6840 | - | - | - | - | - |
| 0.0835 | 1800 | 0.6631 | - | - | - | - | - |
| 0.0928 | 2000 | 0.6615 | - | - | - | - | - |
| 0.1000 | 2156 | - | 0.5889 (+0.1884) | 0.4139 (-0.1265) | 0.3892 (+0.0642) | 0.5487 (+0.0481) | 0.4506 (-0.0048) |
| 0.1021 | 2200 | 0.6360 | - | - | - | - | - |
| 0.1114 | 2400 | 0.6156 | - | - | - | - | - |
| 0.1206 | 2600 | 0.6007 | - | - | - | - | - |
| 0.1299 | 2800 | 0.5962 | - | - | - | - | - |
| 0.1392 | 3000 | 0.6028 | - | - | - | - | - |
| 0.1485 | 3200 | 0.5925 | - | - | - | - | - |
| 0.1578 | 3400 | 0.5591 | - | - | - | - | - |
| 0.1670 | 3600 | 0.5705 | - | - | - | - | - |
| 0.1763 | 3800 | 0.5607 | - | - | - | - | - |
| 0.1856 | 4000 | 0.5744 | - | - | - | - | - |
| 0.1949 | 4200 | 0.5625 | - | - | - | - | - |
| 0.2001 | 4312 | - | 0.6086 (+0.2081) | 0.4460 (-0.0944) | 0.4204 (+0.0953) | 0.4800 (-0.0207) | 0.4488 (-0.0066) |
| 0.2042 | 4400 | 0.5490 | - | - | - | - | - |
| 0.2134 | 4600 | 0.5529 | - | - | - | - | - |
| 0.2227 | 4800 | 0.5494 | - | - | - | - | - |
| 0.2320 | 5000 | 0.5420 | - | - | - | - | - |
| 0.2413 | 5200 | 0.5184 | - | - | - | - | - |
| 0.2506 | 5400 | 0.5416 | - | - | - | - | - |
| 0.2598 | 5600 | 0.5144 | - | - | - | - | - |
| 0.2691 | 5800 | 0.5260 | - | - | - | - | - |
| 0.2784 | 6000 | 0.5048 | - | - | - | - | - |
| 0.2877 | 6200 | 0.5353 | - | - | - | - | - |
| 0.2970 | 6400 | 0.5199 | - | - | - | - | - |
| 0.3001 | 6468 | - | 0.6113 (+0.2109) | 0.4895 (-0.0509) | 0.3925 (+0.0675) | 0.4662 (-0.0345) | 0.4494 (-0.0060) |
| 0.3063 | 6600 | 0.5116 | - | - | - | - | - |
| 0.3155 | 6800 | 0.5180 | - | - | - | - | - |
| 0.3248 | 7000 | 0.5109 | - | - | - | - | - |
| 0.3341 | 7200 | 0.5095 | - | - | - | - | - |
| 0.3434 | 7400 | 0.5009 | - | - | - | - | - |
| 0.3527 | 7600 | 0.5016 | - | - | - | - | - |
| 0.3619 | 7800 | 0.4985 | - | - | - | - | - |
| 0.3712 | 8000 | 0.5046 | - | - | - | - | - |
| 0.3805 | 8200 | 0.4984 | - | - | - | - | - |
| 0.3898 | 8400 | 0.4969 | - | - | - | - | - |
| 0.3991 | 8600 | 0.5002 | - | - | - | - | - |
| 0.4002 | 8624 | - | 0.6300 (+0.2296) | 0.4809 (-0.0595) | 0.3848 (+0.0597) | 0.4699 (-0.0308) | 0.4452 (-0.0102) |
| 0.4083 | 8800 | 0.4910 | - | - | - | - | - |
| 0.4176 | 9000 | 0.5025 | - | - | - | - | - |
| 0.4269 | 9200 | 0.4854 | - | - | - | - | - |
| 0.4362 | 9400 | 0.4911 | - | - | - | - | - |
| 0.4455 | 9600 | 0.4874 | - | - | - | - | - |
| 0.4547 | 9800 | 0.4895 | - | - | - | - | - |
| 0.4640 | 10000 | 0.4803 | - | - | - | - | - |
| 0.4733 | 10200 | 0.4876 | - | - | - | - | - |
| 0.4826 | 10400 | 0.4893 | - | - | - | - | - |
| 0.4919 | 10600 | 0.4774 | - | - | - | - | - |
| 0.5002 | 10780 | - | 0.6352 (+0.2347) | 0.5559 (+0.0154) | 0.3819 (+0.0568) | 0.5335 (+0.0329) | 0.4904 (+0.0351) |
| 0.5011 | 10800 | 0.4688 | - | - | - | - | - |
| 0.5104 | 11000 | 0.4723 | - | - | - | - | - |
| 0.5197 | 11200 | 0.4752 | - | - | - | - | - |
| 0.5290 | 11400 | 0.4711 | - | - | - | - | - |
| 0.5383 | 11600 | 0.4702 | - | - | - | - | - |
| 0.5475 | 11800 | 0.4680 | - | - | - | - | - |
| 0.5568 | 12000 | 0.4739 | - | - | - | - | - |
| 0.5661 | 12200 | 0.4529 | - | - | - | - | - |
| 0.5754 | 12400 | 0.4709 | - | - | - | - | - |
| 0.5847 | 12600 | 0.4518 | - | - | - | - | - |
| 0.5939 | 12800 | 0.4726 | - | - | - | - | - |
| 0.6003 | 12936 | - | 0.6405 (+0.2400) | 0.5069 (-0.0335) | 0.3581 (+0.0331) | 0.5042 (+0.0036) | 0.4564 (+0.0010) |
| 0.6032 | 13000 | 0.4698 | - | - | - | - | - |
| 0.6125 | 13200 | 0.4627 | - | - | - | - | - |
| 0.6218 | 13400 | 0.4562 | - | - | - | - | - |
| 0.6311 | 13600 | 0.4566 | - | - | - | - | - |
| 0.6403 | 13800 | 0.4775 | - | - | - | - | - |
| 0.6496 | 14000 | 0.4532 | - | - | - | - | - |
| 0.6589 | 14200 | 0.4660 | - | - | - | - | - |
| 0.6682 | 14400 | 0.4488 | - | - | - | - | - |
| 0.6775 | 14600 | 0.4482 | - | - | - | - | - |
| 0.6867 | 14800 | 0.4515 | - | - | - | - | - |
| 0.6960 | 15000 | 0.4596 | - | - | - | - | - |
| 0.7003 | 15092 | - | 0.6413 (+0.2409) | 0.4668 (-0.0736) | 0.3518 (+0.0268) | 0.4538 (-0.0469) | 0.4241 (-0.0312) |
| 0.7053 | 15200 | 0.4418 | - | - | - | - | - |
| 0.7146 | 15400 | 0.4499 | - | - | - | - | - |
| 0.7239 | 15600 | 0.4542 | - | - | - | - | - |
| 0.7331 | 15800 | 0.4636 | - | - | - | - | - |
| 0.7424 | 16000 | 0.4371 | - | - | - | - | - |
| 0.7517 | 16200 | 0.4344 | - | - | - | - | - |
| 0.7610 | 16400 | 0.4535 | - | - | - | - | - |
| 0.7703 | 16600 | 0.4429 | - | - | - | - | - |
| 0.7795 | 16800 | 0.4435 | - | - | - | - | - |
| 0.7888 | 17000 | 0.4398 | - | - | - | - | - |
| 0.7981 | 17200 | 0.4441 | - | - | - | - | - |
| 0.8003 | 17248 | - | 0.6410 (+0.2406) | 0.5221 (-0.0183) | 0.3324 (+0.0074) | 0.4941 (-0.0065) | 0.4496 (-0.0058) |
| 0.8074 | 17400 | 0.4501 | - | - | - | - | - |
| 0.8167 | 17600 | 0.4501 | - | - | - | - | - |
| 0.8259 | 17800 | 0.4228 | - | - | - | - | - |
| 0.8352 | 18000 | 0.4395 | - | - | - | - | - |
| 0.8445 | 18200 | 0.4383 | - | - | - | - | - |
| 0.8538 | 18400 | 0.4414 | - | - | - | - | - |
| 0.8631 | 18600 | 0.4315 | - | - | - | - | - |
| 0.8723 | 18800 | 0.4306 | - | - | - | - | - |
| 0.8816 | 19000 | 0.4249 | - | - | - | - | - |
| 0.8909 | 19200 | 0.4356 | - | - | - | - | - |
| 0.9002 | 19400 | 0.4326 | - | - | - | - | - |
| 0.9004 | 19404 | - | 0.6408 (+0.2404) | 0.4703 (-0.0702) | 0.3600 (+0.0349) | 0.4739 (-0.0267) | 0.4347 (-0.0207) |
| 0.9095 | 19600 | 0.4431 | - | - | - | - | - |
| 0.9188 | 19800 | 0.4199 | - | - | - | - | - |
| 0.9280 | 20000 | 0.4409 | - | - | - | - | - |
| 0.9373 | 20200 | 0.4351 | - | - | - | - | - |
| 0.9466 | 20400 | 0.4261 | - | - | - | - | - |
| 0.9559 | 20600 | 0.4245 | - | - | - | - | - |
| 0.9652 | 20800 | 0.4292 | - | - | - | - | - |
| 0.9744 | 21000 | 0.4300 | - | - | - | - | - |
| 0.9837 | 21200 | 0.4298 | - | - | - | - | - |
| 0.9930 | 21400 | 0.4263 | - | - | - | - | - |
- The bold row denotes the saved checkpoint.
Training Time
- Training: 3.8 hours
- Evaluation: 26.3 minutes
- Total: 4.2 hours
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",
}