Views
No views yet
CrossEncoder(
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'ModernBertForSequenceClassification'})
)pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("kwondw/reranker-ModernBERT-base-gooaq-bce")
5# Get scores for pairs of inputs
6pairs = [
7 ['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."],
8 ['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."],
9 ['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!'],
10 ['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.'],
11 ['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.'],
12]
13scores = model.predict(pairs)
14print(scores)
15# [9.7463e-01 2.7169e-02 1.4214e-03 5.0407e-03 4.4422e-04]
16
17# Or rank different texts based on similarity to a single text
18ranks = model.rank(
19 'what to spend my nectar points on?',
20 [
21 "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.",
22 "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.",
23 '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!',
24 '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.',
25 '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.',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]gooaq-devCrossEncoderRerankingEvaluator with these parameters:
1{
2 "at_k": 10,
3 "always_rerank_positives": false
4}| Metric | Value |
|---|---|
| map | 0.7842 (+0.1739) |
| mrr@10 | 0.7827 (+0.1773) |
| ndcg@10 | 0.8182 (+0.1499) |
NanoMSMARCO_R100, NanoNFCorpus_R100 and NanoNQ_R100CrossEncoderRerankingEvaluator with these parameters:
1{
2 "at_k": 10,
3 "always_rerank_positives": true
4}| 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) |
NanoBEIR_R100_meanCrossEncoderNanoBEIREvaluator with these parameters:
1{
2 "dataset_names": [
3 "msmarco",
4 "nfcorpus",
5 "nq"
6 ],
7 "dataset_id": "sentence-transformers/NanoBEIR-en",
8 "rerank_k": 100,
9 "at_k": 10,
10 "always_rerank_positives": true
11}| Metric | Value |
|---|---|
| map | 0.4771 (+0.0870) |
| mrr@10 | 0.5495 (+0.0814) |
| ndcg@10 | 0.5415 (+0.0862) |
question, answer, and label| question | answer | label | |
|---|---|---|---|
| type | string | string | int |
| modality | text | text | |
| details |
|
|
|
| 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 |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity",
3 "pos_weight": 5
4}per_device_train_batch_size: 64num_train_epochs: 1learning_rate: 2e-05warmup_steps: 0.1fp16: Trueper_device_eval_batch_size: 64load_best_model_at_end: Trueseed: 12dataloader_num_workers: 2per_device_train_batch_size: 64num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 64prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Trueignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 12data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 2dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| 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) |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}