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.
See training_gooaq_bce.py for the training script. This script is also described in the Cross Encoder > Training Overview documentation and the Training and Finetuning Reranker Models with Sentence Transformers v4 blogpost.
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
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Documentation: Cross Encoder Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Cross Encoders on Hugging Face
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-gooaq-bce")
# Get scores for pairs of texts
pairs = [
['why are rye chips so good?', "It makes them taste that much better! The rye chips are tasty because they stand out--they're the saltiest thing in the bag. It's not because rye bread is inherently awesome. ... You could just buy a bag of rye chips."],
['why are rye chips so good?', 'There are no substantial technical, nutritional or performance issues associated with rye that would limit its use for pets. Rye is a fairly common ingredient in human foods and beverages. The most prevalent occurrence is in crackers and breads.'],
['why are rye chips so good?', 'Bread made wholly from rye flour is made in Germany and called pumpernickel. Rye is unique among grains for having a high level of fibre in its endosperm – not just in its bran. As such, the glycemic index (GI) of rye products is generally lower than products made from wheat and most other grains.'],
['why are rye chips so good?', 'KFC Chips – The salt mix on the seasoned chips and the actual chips do not contain any animal products. Our supplier/s of chips and seasoning have confirmed they are suitable for vegans.'],
['why are rye chips so good?', 'A study in the American Journal of Clinical Nutrition found that eating rye leads to better blood-sugar control compared to wheat. Rye bread is packed with magnesium, which helps control blood pressure and optimize heart health. Its high levels of soluble fibre can also reduce cholesterol.'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'why are rye chips so good?',
[
"It makes them taste that much better! The rye chips are tasty because they stand out--they're the saltiest thing in the bag. It's not because rye bread is inherently awesome. ... You could just buy a bag of rye chips.",
'There are no substantial technical, nutritional or performance issues associated with rye that would limit its use for pets. Rye is a fairly common ingredient in human foods and beverages. The most prevalent occurrence is in crackers and breads.',
'Bread made wholly from rye flour is made in Germany and called pumpernickel. Rye is unique among grains for having a high level of fibre in its endosperm – not just in its bran. As such, the glycemic index (GI) of rye products is generally lower than products made from wheat and most other grains.',
'KFC Chips – The salt mix on the seasoned chips and the actual chips do not contain any animal products. Our supplier/s of chips and seasoning have confirmed they are suitable for vegans.',
'A study in the American Journal of Clinical Nutrition found that eating rye leads to better blood-sugar control compared to wheat. Rye bread is packed with magnesium, which helps control blood pressure and optimize heart health. Its high levels of soluble fibre can also reduce cholesterol.',
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
Evaluation
Metrics
Cross Encoder Reranking
- Dataset:
gooaq-dev
- Evaluated with
CrossEncoderRerankingEvaluator
with these parameters:{ "at_k": 10, "always_rerank_positives": false }
Metric | Value |
---|---|
map | 0.7308 (+0.1997) |
mrr@10 | 0.7292 (+0.2052) |
ndcg@10 | 0.7713 (+0.1801) |
Cross Encoder Reranking
- Dataset:
gooaq-dev
- Evaluated with
CrossEncoderRerankingEvaluator
with these parameters:{ "at_k": 10, "always_rerank_positives": true }
Metric | Value |
---|---|
map | 0.7908 (+0.2597) |
mrr@10 | 0.7890 (+0.2650) |
ndcg@10 | 0.8351 (+0.2439) |
Cross Encoder Reranking
- Datasets:
NanoMSMARCO_R100
,NanoNFCorpus_R100
andNanoNQ_R100
- Evaluated with
CrossEncoderRerankingEvaluator
with these parameters:{ "at_k": 10, "always_rerank_positives": true }
Metric | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
---|---|---|---|
map | 0.4579 (-0.0317) | 0.3414 (+0.0804) | 0.3932 (-0.0264) |
mrr@10 | 0.4479 (-0.0296) | 0.5340 (+0.0342) | 0.3918 (-0.0349) |
ndcg@10 | 0.5275 (-0.0130) | 0.3821 (+0.0571) | 0.4630 (-0.0377) |
Cross Encoder Nano BEIR
- Dataset:
NanoBEIR_R100_mean
- Evaluated with
CrossEncoderNanoBEIREvaluator
with these parameters:{ "dataset_names": [ "msmarco", "nfcorpus", "nq" ], "rerank_k": 100, "at_k": 10, "always_rerank_positives": true }
Metric | Value |
---|---|
map | 0.3975 (+0.0074) |
mrr@10 | 0.4579 (-0.0101) |
ndcg@10 | 0.4575 (+0.0022) |
Training Details
Training Dataset
Unnamed Dataset
- Size: 578,402 training samples
- Columns:
question
,answer
, andlabel
- Approximate statistics based on the first 1000 samples:
question answer label type string string int details - min: 19 characters
- mean: 45.14 characters
- max: 85 characters
- min: 65 characters
- mean: 254.8 characters
- max: 379 characters
- 0: ~82.90%
- 1: ~17.10%
- Samples:
question answer label why are rye chips so good?
It makes them taste that much better! The rye chips are tasty because they stand out--they're the saltiest thing in the bag. It's not because rye bread is inherently awesome. ... You could just buy a bag of rye chips.
1
why are rye chips so good?
There are no substantial technical, nutritional or performance issues associated with rye that would limit its use for pets. Rye is a fairly common ingredient in human foods and beverages. The most prevalent occurrence is in crackers and breads.
0
why are rye chips so good?
Bread made wholly from rye flour is made in Germany and called pumpernickel. Rye is unique among grains for having a high level of fibre in its endosperm – not just in its bran. As such, the glycemic index (GI) of rye products is generally lower than products made from wheat and most other grains.
0
- Loss:
BinaryCrossEntropyLoss
with these parameters:{ "activation_fct": "torch.nn.modules.linear.Identity", "pos_weight": 5 }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 64per_device_eval_batch_size
: 64learning_rate
: 2e-05num_train_epochs
: 1warmup_ratio
: 0.1seed
: 12bf16
: Truedataloader_num_workers
: 4load_best_model_at_end
: True
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 64per_device_eval_batch_size
: 64per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 1eval_accumulation_steps
: Nonetorch_empty_cache_steps
: Nonelearning_rate
: 2e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 1max_steps
: -1lr_scheduler_type
: linearlr_scheduler_kwargs
: {}warmup_ratio
: 0.1warmup_steps
: 0log_level
: passivelog_level_replica
: warninglog_on_each_node
: Truelogging_nan_inf_filter
: Truesave_safetensors
: Truesave_on_each_node
: Falsesave_only_model
: Falserestore_callback_states_from_checkpoint
: Falseno_cuda
: Falseuse_cpu
: Falseuse_mps_device
: Falseseed
: 12data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Truefp16
: Falsefp16_opt_level
: O1half_precision_backend
: autobf16_full_eval
: Falsefp16_full_eval
: Falsetf32
: Nonelocal_rank
: 0ddp_backend
: Nonetpu_num_cores
: Nonetpu_metrics_debug
: Falsedebug
: []dataloader_drop_last
: Falsedataloader_num_workers
: 4dataloader_prefetch_factor
: Nonepast_index
: -1disable_tqdm
: Falseremove_unused_columns
: Truelabel_names
: Noneload_best_model_at_end
: Trueignore_data_skip
: Falsefsdp
: []fsdp_min_num_params
: 0fsdp_config
: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap
: Noneaccelerator_config
: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torchoptim_args
: Noneadafactor
: Falsegroup_by_length
: Falselength_column_name
: lengthddp_find_unused_parameters
: Noneddp_bucket_cap_mb
: Noneddp_broadcast_buffers
: Falsedataloader_pin_memory
: Truedataloader_persistent_workers
: Falseskip_memory_metrics
: Trueuse_legacy_prediction_loop
: Falsepush_to_hub
: Falseresume_from_checkpoint
: Nonehub_model_id
: Nonehub_strategy
: every_savehub_private_repo
: Nonehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseinclude_for_metrics
: []eval_do_concat_batches
: Truefp16_backend
: autopush_to_hub_model_id
: Nonepush_to_hub_organization
: Nonemp_parameters
:auto_find_batch_size
: Falsefull_determinism
: Falsetorchdynamo
: Noneray_scope
: lastddp_timeout
: 1800torch_compile
: Falsetorch_compile_backend
: Nonetorch_compile_mode
: Nonedispatch_batches
: Nonesplit_batches
: Noneinclude_tokens_per_second
: Falseinclude_num_input_tokens_seen
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falseeval_on_start
: Falseuse_liger_kernel
: Falseeval_use_gather_object
: Falseaverage_tokens_across_devices
: Falseprompts
: Nonebatch_sampler
: batch_samplermulti_dataset_batch_sampler
: proportional
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.1288 (-0.4624) | 0.0149 (-0.5255) | 0.2278 (-0.0972) | 0.0229 (-0.4777) | 0.0885 (-0.3668) |
0.0001 | 1 | 1.0435 | - | - | - | - | - |
0.0221 | 200 | 1.1924 | - | - | - | - | - |
0.0443 | 400 | 1.1531 | - | - | - | - | - |
0.0664 | 600 | 0.9371 | - | - | - | - | - |
0.0885 | 800 | 0.6993 | - | - | - | - | - |
0.1106 | 1000 | 0.669 | 0.7042 (+0.1130) | 0.4353 (-0.1051) | 0.3289 (+0.0039) | 0.4250 (-0.0757) | 0.3964 (-0.0590) |
0.1328 | 1200 | 0.6257 | - | - | - | - | - |
0.1549 | 1400 | 0.6283 | - | - | - | - | - |
0.1770 | 1600 | 0.6014 | - | - | - | - | - |
0.1992 | 1800 | 0.5888 | - | - | - | - | - |
0.2213 | 2000 | 0.5493 | 0.7425 (+0.1513) | 0.4947 (-0.0457) | 0.3568 (+0.0318) | 0.4634 (-0.0373) | 0.4383 (-0.0171) |
0.2434 | 2200 | 0.5479 | - | - | - | - | - |
0.2655 | 2400 | 0.5329 | - | - | - | - | - |
0.2877 | 2600 | 0.5208 | - | - | - | - | - |
0.3098 | 2800 | 0.5259 | - | - | - | - | - |
0.3319 | 3000 | 0.5221 | 0.7479 (+0.1567) | 0.5146 (-0.0258) | 0.3710 (+0.0460) | 0.4846 (-0.0160) | 0.4568 (+0.0014) |
0.3541 | 3200 | 0.4977 | - | - | - | - | - |
0.3762 | 3400 | 0.4965 | - | - | - | - | - |
0.3983 | 3600 | 0.4985 | - | - | - | - | - |
0.4204 | 3800 | 0.4907 | - | - | - | - | - |
0.4426 | 4000 | 0.5058 | 0.7624 (+0.1712) | 0.5166 (-0.0238) | 0.3665 (+0.0415) | 0.4868 (-0.0138) | 0.4567 (+0.0013) |
0.4647 | 4200 | 0.4885 | - | - | - | - | - |
0.4868 | 4400 | 0.495 | - | - | - | - | - |
0.5090 | 4600 | 0.4839 | - | - | - | - | - |
0.5311 | 4800 | 0.4983 | - | - | - | - | - |
0.5532 | 5000 | 0.4778 | 0.7603 (+0.1691) | 0.5110 (-0.0294) | 0.3540 (+0.0290) | 0.4809 (-0.0197) | 0.4487 (-0.0067) |
0.5753 | 5200 | 0.4726 | - | - | - | - | - |
0.5975 | 5400 | 0.477 | - | - | - | - | - |
0.6196 | 5600 | 0.4613 | - | - | - | - | - |
0.6417 | 5800 | 0.4492 | - | - | - | - | - |
0.6639 | 6000 | 0.4506 | 0.7643 (+0.1731) | 0.5275 (-0.0129) | 0.3639 (+0.0389) | 0.4913 (-0.0094) | 0.4609 (+0.0055) |
0.6860 | 6200 | 0.4618 | - | - | - | - | - |
0.7081 | 6400 | 0.463 | - | - | - | - | - |
0.7303 | 6600 | 0.4585 | - | - | - | - | - |
0.7524 | 6800 | 0.4612 | - | - | - | - | - |
0.7745 | 7000 | 0.4621 | 0.7649 (+0.1736) | 0.5105 (-0.0299) | 0.3688 (+0.0437) | 0.4552 (-0.0454) | 0.4448 (-0.0105) |
0.7966 | 7200 | 0.4536 | - | - | - | - | - |
0.8188 | 7400 | 0.4515 | - | - | - | - | - |
0.8409 | 7600 | 0.4396 | - | - | - | - | - |
0.8630 | 7800 | 0.4542 | - | - | - | - | - |
0.8852 | 8000 | 0.4332 | 0.7669 (+0.1757) | 0.5247 (-0.0157) | 0.3794 (+0.0544) | 0.4370 (-0.0637) | 0.4470 (-0.0083) |
0.9073 | 8200 | 0.447 | - | - | - | - | - |
0.9294 | 8400 | 0.4335 | - | - | - | - | - |
0.9515 | 8600 | 0.4179 | - | - | - | - | - |
0.9737 | 8800 | 0.4459 | - | - | - | - | - |
0.9958 | 9000 | 0.4196 | 0.7713 (+0.1801) | 0.5275 (-0.0130) | 0.3821 (+0.0571) | 0.4630 (-0.0377) | 0.4575 (+0.0022) |
-1 | -1 | - | 0.7713 (+0.1801) | 0.5275 (-0.0130) | 0.3821 (+0.0571) | 0.4630 (-0.0377) | 0.4575 (+0.0022) |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.11.10
- Sentence Transformers: 3.5.0.dev0
- Transformers: 4.49.0
- PyTorch: 2.5.1+cu124
- Accelerate: 1.5.2
- Datasets: 2.21.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
- 29
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-ranking models for sentence-transformers library.
Model tree for tomaarsen/reranker-ModernBERT-base-gooaq-bce
Base model
answerdotai/ModernBERT-baseEvaluation results
- Map on gooaq devself-reported0.731
- Mrr@10 on gooaq devself-reported0.729
- Ndcg@10 on gooaq devself-reported0.771
- Map on NanoMSMARCO R100self-reported0.458
- Mrr@10 on NanoMSMARCO R100self-reported0.448
- Ndcg@10 on NanoMSMARCO R100self-reported0.527
- Map on NanoNFCorpus R100self-reported0.341
- Mrr@10 on NanoNFCorpus R100self-reported0.534
- Ndcg@10 on NanoNFCorpus R100self-reported0.382
- Map on NanoNQ R100self-reported0.393