CrossEncoder based on google-bert/bert-base-uncased

This is a Cross Encoder model finetuned from google-bert/bert-base-uncased 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: google-bert/bert-base-uncased
  • Maximum Sequence Length: 512 tokens
  • Number of Output Labels: 1 label
  • Supported Modality: Text

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

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("reranker-finetuned")
# Get scores for pairs of inputs
pairs = [
    ['\n  QuestionText: Solve this equation, giving all solutions:\n\\(\n3 p^{2}+9=39\n\\)\n\n  ConstructName: Solve quadratic equations using balancing\n\n  SubjectName: Quadratic Equations\n\n  CorrectAnswer: \np=sqrt10\n\np=\\sqrt{10}\n\nor\n\\(\np=-\\sqrt{10}\n\\)\n\n  WrongAnswer: \\[\np=2\n\\]\nor\n\\[\np=-2\n\\]\n  ', 'When solving an equation, uses the same operation rather than the inverse.'],
    ['\n  QuestionText: Dave has recorded the number of pets his classmates have in the frequency table on the right. \\begin{tabular}{|c|c|}\n\\hline Number of pets & Frequency \\\\\n\\hline 0 0  & 4 4  \\\\\n\\hline 1 1  & 6 6  \\\\\n\\hline 2 2  & 3 3  \\\\\n\\hline 3 3  & 2 2  \\\\\n\\hline 4 4  & 5 5  \\\\\n\\hline\n\\end{tabular} How many people did Dave record the results of?\n\n  ConstructName: Interpret numbers in a frequency table\n\n  SubjectName: Frequency tables\n\n  CorrectAnswer: 20 20 \n\n  WrongAnswer: 5 5 \n  ', 'Adds up the variable column when asked for total frequency'],
    ['\n  QuestionText: Which of the following is a correct way to describe the marked angle? ![Trapezium PQRS with angle QPS highlighted in red]()\n\n  ConstructName: Label angles using correct 3-letter notation (e.g. angle ADB)\n\n  SubjectName: Types, Naming and Estimating\n\n  CorrectAnswer: QPS Q P S \n\n  WrongAnswer: QPRS\n  ', 'Gives the vertex instead of the 3-letter angle notation'],
    ['\n  QuestionText: A coach takes 3 3  hours 50 50  minutes to complete a journey from Manchester to London.\n\nIf the coach leaves Manchester at 09:25, what time does it arrive in London?\n\n  ConstructName: Solve problems involving adding a period of time on to a given start time\n\n  SubjectName: Time\n\n  CorrectAnswer: 13:15 13: 15 \n\n  WrongAnswer: 01:15\n  ', 'Writes times in the afternoon as if they are morning on a 24 hour clock'],
    ['\n  QuestionText: 6โˆ’(โˆ’8)= 6-(-8)= \n\n  ConstructName: Carry out subtraction problems involving one negative integer\n\n  SubjectName: Adding and Subtracting Negative Numbers\n\n  CorrectAnswer: 14 14 \n\n  WrongAnswer: โˆ’14 -14 \n  ', "Does not realise that subtracting a negative is the same as adding it's additive inverse"],
]
scores = model.predict(pairs)
print(scores)
# [0.8266 0.9364 0.9766 0.9578 0.9748]

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    '\n  QuestionText: Solve this equation, giving all solutions:\n\\(\n3 p^{2}+9=39\n\\)\n\n  ConstructName: Solve quadratic equations using balancing\n\n  SubjectName: Quadratic Equations\n\n  CorrectAnswer: \np=sqrt10\n\np=\\sqrt{10}\n\nor\n\\(\np=-\\sqrt{10}\n\\)\n\n  WrongAnswer: \\[\np=2\n\\]\nor\n\\[\np=-2\n\\]\n  ',
    [
        'When solving an equation, uses the same operation rather than the inverse.',
        'Adds up the variable column when asked for total frequency',
        'Gives the vertex instead of the 3-letter angle notation',
        'Writes times in the afternoon as if they are morning on a 24 hour clock',
        "Does not realise that subtracting a negative is the same as adding it's additive inverse",
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Training Details

Training Dataset

Unnamed Dataset

  • Size: 9,000 training samples
  • Columns: text, missconception, and label
  • Approximate statistics based on the first 100 samples:
    text missconception label
    type string string int
    modality text text
    details
    • min: 47 tokens
    • mean: 121.94 tokens
    • max: 419 tokens
    • min: 7 tokens
    • mean: 15.26 tokens
    • max: 38 tokens
    • 0: ~42.31%
    • 1: ~57.69%
  • Samples:
    text missconception label

    QuestionText: What temperature does the thermometer show? A thermometer showing the temperature in degrees Celsius. There are five steps on the scale between 10 and 0, and five steps between 0 and -10. The temperature is shown at 4 steps below 0.

    ConstructName: Read a negative integer temperature from a thermometer

    SubjectName: Temperature units

    CorrectAnswer: ( -8^{\circ} \mathrm{C} )

    WrongAnswer: ( -4^{\circ} \mathrm{C} )
    When reading integers on a number line, assumes each dash is 1 1

    QuestionText: What is the size of angle ( q ) ? A long straight line with two shorter lines joining it, but not crossing it. Where the line on the left joins it forms two angles, q on the left, 126 degrees on the right. Where the line on the right joins it forms two angles, the left is unmarked, 37 degrees on the right.

    ConstructName: Find missing angles using angles on a straight line

    SubjectName: Basic Angle Facts (straight line, opposite, around a point, etc)

    CorrectAnswer: ( 54^{\circ} )

    WrongAnswer: ( 64^{\circ} )
    Misinterprets the meaning of angles on a straight line angle fact 0

    QuestionText: What is the value of:

    [
    485+78-9
    ]

    ConstructName: Complete multi-step mental calculations

    SubjectName: Mental Addition and Subtraction

    CorrectAnswer: ( 554 )

    WrongAnswer: ( 398 )
    When two digits sum to 10 or more during an addition problem, does not add one to the preceding digit 0
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 10.0,
        "num_negatives": 4,
        "activation_fn": "torch.nn.modules.activation.Sigmoid"
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 2,250 evaluation samples
  • Columns: text, missconception, and label
  • Approximate statistics based on the first 100 samples:
    text missconception label
    type string string int
    modality text text
    details
    • min: 46 tokens
    • mean: 108.51 tokens
    • max: 399 tokens
    • min: 6 tokens
    • mean: 15.18 tokens
    • max: 35 tokens
    • 0: ~43.27%
    • 1: ~56.73%
  • Samples:
    text missconception label

    QuestionText: Solve this equation, giving all solutions:
    (
    3 p^{2}+9=39
    )

    ConstructName: Solve quadratic equations using balancing

    SubjectName: Quadratic Equations

    CorrectAnswer: (
    p=\sqrt{10}
    )
    or
    (
    p=-\sqrt{10}
    )

    WrongAnswer: [
    p=2
    ]
    or
    [
    p=-2
    ]
    When solving an equation, uses the same operation rather than the inverse. 0

    QuestionText: Dave has recorded the number of pets his classmates have in the frequency table on the right. \begin{tabular}{|c|c|}
    \hline Number of pets & Frequency \
    \hline ( 0 ) & ( 4 ) \
    \hline ( 1 ) & ( 6 ) \
    \hline ( 2 ) & ( 3 ) \
    \hline ( 3 ) & ( 2 ) \
    \hline ( 4 ) & ( 5 ) \
    \hline
    \end{tabular} How many people did Dave record the results of?

    ConstructName: Interpret numbers in a frequency table

    SubjectName: Frequency tables

    CorrectAnswer: ( 20 )

    WrongAnswer: ( 5 )
    Adds up the variable column when asked for total frequency 0

    QuestionText: Which of the following is a correct way to describe the marked angle? Trapezium PQRS with angle QPS highlighted in red

    ConstructName: Label angles using correct 3-letter notation (e.g. angle ADB)

    SubjectName: Types, Naming and Estimating

    CorrectAnswer: ( Q P S )

    WrongAnswer: QPRS
    Gives the vertex instead of the 3-letter angle notation 0
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 10.0,
        "num_negatives": 4,
        "activation_fn": "torch.nn.modules.activation.Sigmoid"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 16
  • num_train_epochs: 2
  • learning_rate: 0.0001
  • warmup_steps: 0.1
  • gradient_accumulation_steps: 2
  • fp16: True
  • per_device_eval_batch_size: 16

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 16
  • num_train_epochs: 2
  • max_steps: -1
  • learning_rate: 0.0001
  • 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: 2
  • 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: 16
  • 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: False
  • ignore_data_skip: False
  • restore_callback_states_from_checkpoint: False
  • full_determinism: False
  • seed: 42
  • 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: 0
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • dataloader_prefetch_factor: None
  • dataloader_multiprocessing_context: None
  • dataloader_in_order: True
  • 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
  • local_rank: -1
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}
  • warmup_ratio: None

Training Logs

Epoch Step Training Loss Validation Loss
0.0213 6 1.9288 -
0.0426 12 1.5921 -
0.0639 18 1.1075 -
0.0853 24 0.7169 -
0.1066 30 0.5473 -
0.1279 36 0.4761 -
0.1492 42 0.3948 -
0.1705 48 0.4800 -
0.1918 54 0.5520 -
0.2131 60 0.5596 -
0.2345 66 0.3587 -
0.2558 72 0.4442 -
0.2771 78 0.3607 -
0.2984 84 0.3622 -
0.3197 90 0.3339 -
0.3410 96 0.4211 -
0.3623 102 0.3275 -
0.3837 108 0.2806 -
0.4050 114 0.4830 -
0.4263 120 0.3304 -
0.4476 126 0.3471 -
0.4689 132 0.2266 -
0.4902 138 0.2479 -
0.5115 144 0.2506 -
0.5329 150 0.2103 -
0.5542 156 0.2699 -
0.5755 162 0.2931 -
0.5968 168 0.4029 -
0.6181 174 0.1841 -
0.6394 180 0.2195 -
0.6607 186 0.2391 -
0.6821 192 0.2131 -
0.7034 198 0.2103 -
0.7247 204 0.2687 -
0.7460 210 0.3169 -
0.7673 216 0.2280 -
0.7886 222 0.2084 -
0.8099 228 0.2113 -
0.8313 234 0.2049 -
0.8526 240 0.2736 -
0.8739 246 0.1631 -
0.8952 252 0.1771 -
0.9165 258 0.2031 -
0.9378 264 0.2642 -
0.9591 270 0.2185 -
0.9805 276 0.1537 -
1.0 282 0.1927 0.1680
1.0213 288 0.0810 -
1.0426 294 0.1010 -
1.0639 300 0.1640 -
1.0853 306 0.1220 -
1.1066 312 0.2518 -
1.1279 318 0.1932 -
1.1492 324 0.1435 -
1.1705 330 0.1295 -
1.1918 336 0.2066 -
1.2131 342 0.1823 -
1.2345 348 0.1687 -
1.2558 354 0.1663 -
1.2771 360 0.1192 -
1.2984 366 0.1610 -
1.3197 372 0.2017 -
1.3410 378 0.0877 -
1.3623 384 0.1714 -
1.3837 390 0.1482 -
1.4050 396 0.1481 -
1.4263 402 0.1413 -
1.4476 408 0.1010 -
1.4689 414 0.2108 -
1.4902 420 0.0982 -
1.5115 426 0.1551 -
1.5329 432 0.1501 -
1.5542 438 0.1301 -
1.5755 444 0.1083 -
1.5968 450 0.1894 -
1.6181 456 0.1167 -
1.6394 462 0.1397 -
1.6607 468 0.0776 -
1.6821 474 0.1218 -
1.7034 480 0.1077 -
1.7247 486 0.1507 -
1.7460 492 0.0702 -
1.7673 498 0.1216 -
1.7886 504 0.0844 -
1.8099 510 0.1513 -
1.8313 516 0.0762 -
1.8526 522 0.1426 -
1.8739 528 0.0782 -
1.8952 534 0.1015 -
1.9165 540 0.0699 -
1.9378 546 0.1085 -
1.9591 552 0.1081 -
1.9805 558 0.0689 -
2.0 564 0.0705 0.1055

Training Time

  • Training: 49.0 minutes

Framework Versions

  • Python: 3.13.16
  • Sentence Transformers: 5.7.0
  • Transformers: 5.22.1
  • PyTorch: 2.14.1+cu130
  • Accelerate: 1.15.0
  • Datasets: 4.8.5
  • Tokenizers: 0.23.3

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 Luca207/reranker-finetuned

Finetuned
(7,260)
this model

Paper for Luca207/reranker-finetuned