---
language:
- en
license: apache-2.0
tags:
- sentence-transformers
- cross-encoder
- generated_from_trainer
- dataset_size:578402
- loss:BinaryCrossEntropyLoss
base_model: answerdotai/ModernBERT-large
pipeline_tag: text-ranking
library_name: sentence-transformers
metrics:
- map
- mrr@10
- ndcg@10
model-index:
- name: ModernBERT-large trained on GooAQ
results:
- task:
type: cross-encoder-reranking
name: Cross Encoder Reranking
dataset:
name: gooaq dev
type: gooaq-dev
metrics:
- type: map
value: 0.7586
name: Map
- type: mrr@10
value: 0.7576
name: Mrr@10
- type: ndcg@10
value: 0.7946
name: Ndcg@10
- task:
type: cross-encoder-reranking
name: Cross Encoder Reranking
dataset:
name: NanoMSMARCO R100
type: NanoMSMARCO_R100
metrics:
- type: map
value: 0.5488
name: Map
- type: mrr@10
value: 0.5443
name: Mrr@10
- type: ndcg@10
value: 0.6323
name: Ndcg@10
- task:
type: cross-encoder-reranking
name: Cross Encoder Reranking
dataset:
name: NanoNFCorpus R100
type: NanoNFCorpus_R100
metrics:
- type: map
value: 0.3682
name: Map
- type: mrr@10
value: 0.5677
name: Mrr@10
- type: ndcg@10
value: 0.4136
name: Ndcg@10
- task:
type: cross-encoder-reranking
name: Cross Encoder Reranking
dataset:
name: NanoNQ R100
type: NanoNQ_R100
metrics:
- type: map
value: 0.6103
name: Map
- type: mrr@10
value: 0.6108
name: Mrr@10
- type: ndcg@10
value: 0.657
name: Ndcg@10
- task:
type: cross-encoder-nano-beir
name: Cross Encoder Nano BEIR
dataset:
name: NanoBEIR R100 mean
type: NanoBEIR_R100_mean
metrics:
- type: map
value: 0.5091
name: Map
- type: mrr@10
value: 0.5743
name: Mrr@10
- type: ndcg@10
value: 0.5676
name: Ndcg@10
---
# ModernBERT-large trained on GooAQ
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model finetuned from [answerdotai/ModernBERT-large](https://huggingface.co/answerdotai/ModernBERT-large) using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.
See [training_gooaq_bce.py](https://github.com/UKPLab/sentence-transformers/blob/feat/cross_encoder_trainer/examples/cross_encoder/training/rerankers/training_gooaq_bce.py) for the training script - only the base model was updated from [answerdotai/ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) to [answerdotai/ModernBERT-large](https://huggingface.co/answerdotai/ModernBERT-large). This script is also described in the [Cross Encoder > Training Overview](https://sbert.net/docs/cross_encoder/training_overview.html) documentation and the [Training and Finetuning Reranker Models with Sentence Transformers v4](https://huggingface.co/blog/train-reranker) blogpost.

## Model Details
### Model Description
- **Model Type:** Cross Encoder
- **Base model:** [answerdotai/ModernBERT-large](https://huggingface.co/answerdotai/ModernBERT-large)
- **Maximum Sequence Length:** 8192 tokens
- **Number of Output Labels:** 1 label
- **Language:** en
- **License:** apache-2.0
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
- **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder)
## Usage
### Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
```bash
pip install -U sentence-transformers
```
Then you can load this model and run inference.
```python
from sentence_transformers import CrossEncoder
# Download from the 🤗 Hub
model = CrossEncoder("tomaarsen/reranker-ModernBERT-large-gooaq-bce")
# Get scores for pairs of texts
pairs = [
['what are the characteristics and elements of poetry?', 'The elements of poetry include meter, rhyme, form, sound, and rhythm (timing). Different poets use these elements in many different ways.'],
['what are the characteristics and elements of poetry?', "What's the first rule of writing poetry? That there are no rules — it's all up to you! Of course there are different poetic forms and devices, and free verse poems are one of the many poetic styles; they have no structure when it comes to format or even rhyming."],
['what are the characteristics and elements of poetry?', "['Blank verse. Blank verse is poetry written with a precise meter—almost always iambic pentameter—that does not rhyme. ... ', 'Rhymed poetry. In contrast to blank verse, rhymed poems rhyme by definition, although their scheme varies. ... ', 'Free verse. ... ', 'Epics. ... ', 'Narrative poetry. ... ', 'Haiku. ... ', 'Pastoral poetry. ... ', 'Sonnet.']"],
['what are the characteristics and elements of poetry?', 'The main component of poetry is its meter (the regular pattern of strong and weak stress). When a poem has a recognizable but varying pattern of stressed and unstressed syllables, the poetry is written in verse. ... There are many possible patterns of verse, and the basic pattern of each unit is called a foot.'],
['what are the characteristics and elements of poetry?', "Some poetry may not make sense to you. But that's because poets don't write to be understood by others. They write because they must. The feelings and emotions that reside within them need to be expressed."],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
'what are the characteristics and elements of poetry?',
[
'The elements of poetry include meter, rhyme, form, sound, and rhythm (timing). Different poets use these elements in many different ways.',
"What's the first rule of writing poetry? That there are no rules — it's all up to you! Of course there are different poetic forms and devices, and free verse poems are one of the many poetic styles; they have no structure when it comes to format or even rhyming.",
"['Blank verse. Blank verse is poetry written with a precise meter—almost always iambic pentameter—that does not rhyme. ... ', 'Rhymed poetry. In contrast to blank verse, rhymed poems rhyme by definition, although their scheme varies. ... ', 'Free verse. ... ', 'Epics. ... ', 'Narrative poetry. ... ', 'Haiku. ... ', 'Pastoral poetry. ... ', 'Sonnet.']",
'The main component of poetry is its meter (the regular pattern of strong and weak stress). When a poem has a recognizable but varying pattern of stressed and unstressed syllables, the poetry is written in verse. ... There are many possible patterns of verse, and the basic pattern of each unit is called a foot.',
"Some poetry may not make sense to you. But that's because poets don't write to be understood by others. They write because they must. The feelings and emotions that reside within them need to be expressed.",
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
```
## Evaluation
### Metrics
#### Cross Encoder Reranking
* Dataset: `gooaq-dev`
* Evaluated with [CrossEncoderRerankingEvaluator
](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderRerankingEvaluator) with these parameters:
```json
{
"at_k": 10,
"always_rerank_positives": false
}
```
| Metric | Value |
|:------------|:---------------------|
| map | 0.7586 (+0.2275) |
| mrr@10 | 0.7576 (+0.2336) |
| **ndcg@10** | **0.7946 (+0.2034)** |
#### Cross Encoder Reranking
* Dataset: `gooaq-dev`
* Evaluated with [CrossEncoderRerankingEvaluator
](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderRerankingEvaluator) with these parameters:
```json
{
"at_k": 10,
"always_rerank_positives": true
}
```
| Metric | Value |
|:------------|:---------------------|
| map | 0.8176 (+0.2865) |
| mrr@10 | 0.8166 (+0.2926) |
| **ndcg@10** | **0.8581 (+0.2669)** |
#### Cross Encoder Reranking
* Datasets: `NanoMSMARCO_R100`, `NanoNFCorpus_R100` and `NanoNQ_R100`
* Evaluated with [CrossEncoderRerankingEvaluator
](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderRerankingEvaluator) with these parameters:
```json
{
"at_k": 10,
"always_rerank_positives": true
}
```
| Metric | NanoMSMARCO_R100 | NanoNFCorpus_R100 | NanoNQ_R100 |
|:------------|:---------------------|:---------------------|:---------------------|
| map | 0.5488 (+0.0592) | 0.3682 (+0.1072) | 0.6103 (+0.1907) |
| mrr@10 | 0.5443 (+0.0668) | 0.5677 (+0.0678) | 0.6108 (+0.1841) |
| **ndcg@10** | **0.6323 (+0.0918)** | **0.4136 (+0.0886)** | **0.6570 (+0.1564)** |
#### Cross Encoder Nano BEIR
* Dataset: `NanoBEIR_R100_mean`
* Evaluated with [CrossEncoderNanoBEIREvaluator
](https://sbert.net/docs/package_reference/cross_encoder/evaluation.html#sentence_transformers.cross_encoder.evaluation.CrossEncoderNanoBEIREvaluator) with these parameters:
```json
{
"dataset_names": [
"msmarco",
"nfcorpus",
"nq"
],
"rerank_k": 100,
"at_k": 10,
"always_rerank_positives": true
}
```
| Metric | Value |
|:------------|:---------------------|
| map | 0.5091 (+0.1190) |
| mrr@10 | 0.5743 (+0.1063) |
| **ndcg@10** | **0.5676 (+0.1123)** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 578,402 training samples
* Columns: question
, answer
, and label
* Approximate statistics based on the first 1000 samples:
| | question | answer | label |
|:--------|:-----------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|:------------------------------------------------|
| type | string | string | int |
| details |
what are the characteristics and elements of poetry?
| The elements of poetry include meter, rhyme, form, sound, and rhythm (timing). Different poets use these elements in many different ways.
| 1
|
| what are the characteristics and elements of poetry?
| What's the first rule of writing poetry? That there are no rules — it's all up to you! Of course there are different poetic forms and devices, and free verse poems are one of the many poetic styles; they have no structure when it comes to format or even rhyming.
| 0
|
| what are the characteristics and elements of poetry?
| ['Blank verse. Blank verse is poetry written with a precise meter—almost always iambic pentameter—that does not rhyme. ... ', 'Rhymed poetry. In contrast to blank verse, rhymed poems rhyme by definition, although their scheme varies. ... ', 'Free verse. ... ', 'Epics. ... ', 'Narrative poetry. ... ', 'Haiku. ... ', 'Pastoral poetry. ... ', 'Sonnet.']
| 0
|
* Loss: [BinaryCrossEntropyLoss
](https://sbert.net/docs/package_reference/cross_encoder/losses.html#binarycrossentropyloss) with these parameters:
```json
{
"activation_fn": "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
#### All Hyperparameters