Redis semantic caching CrossEncoder model fine-tuned on Quora Question Pairs

This is a Cross Encoder model finetuned from cross-encoder/ms-marco-MiniLM-L12-v2 on the Quora Question Pairs LangCache Train Set dataset using the sentence-transformers library. It computes scores for pairs of texts, which can be used for sentence pair classification.

Model Details

Model Description

  • Model Type: Cross Encoder
  • Base model: cross-encoder/ms-marco-MiniLM-L12-v2
  • Maximum Sequence Length: 512 tokens
  • Number of Output Labels: 1 label
  • Training Dataset:
    • Quora Question Pairs LangCache Train Set
  • Language: en
  • License: apache-2.0

Model Sources

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("aditeyabaral-redis/langcache-crossencoder-v1-ms-marco-MiniLM-L12-v2")
# Get scores for pairs of texts
pairs = [
    ['How can I get a list of my Gmail accounts?', 'How can I find all my old Gmail accounts?'],
    ['How can I stop Quora from modifying and editing other peopleโ€™s questions on Quora?', 'Can I prevent a Quora user from editing my question on Quora?'],
    ['How much does it cost to design a logo in india?', 'How much does it cost to design a logo?'],
    ['What is screenedrenters.com?', 'What is allmyapps.com?'],
    ['What are the best colleges for an MBA in Australia?', 'What are the top MBA schools in Australia?'],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)

# Or rank different texts based on similarity to a single text
ranks = model.rank(
    'How can I get a list of my Gmail accounts?',
    [
        'How can I find all my old Gmail accounts?',
        'Can I prevent a Quora user from editing my question on Quora?',
        'How much does it cost to design a logo?',
        'What is allmyapps.com?',
        'What are the top MBA schools in Australia?',
    ]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]

Evaluation

Metrics

Cross Encoder Classification

Metric Value
accuracy 0.6801
accuracy_threshold 3.2522
f1 0.5699
f1_threshold 2.8498
precision 0.4213
recall 0.8806
average_precision 0.5877

Training Details

Training Dataset

Quora Question Pairs LangCache Train Set

  • Dataset: Quora Question Pairs LangCache Train Set
  • Size: 363,861 training samples
  • Columns: sentence1, sentence2, and label
  • Approximate statistics based on the first 1000 samples:
    sentence1 sentence2 label
    type string string int
    details
    • min: 15 characters
    • mean: 60.22 characters
    • max: 229 characters
    • min: 14 characters
    • mean: 60.0 characters
    • max: 274 characters
    • 0: ~63.50%
    • 1: ~36.50%
  • Samples:
    sentence1 sentence2 label
    Why do people believe in God and how can they say he/she exists? Why do we kill each other in the name of God? 0
    What are the chances of a bee sting when a bee buzzes around you? How can I tell if my bees are agitated/likely to sting? 0
    If a man from Syro Malankara church marries a Syro-Malabar girl, can they join a Syro-Malabar parish? Is Malabar Hills of Mumbai anyhow related to Malabar of Kerala? 0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": null
    }
    

Evaluation Dataset

Quora Question Pairs LangCache Validation Set

  • Dataset: Quora Question Pairs LangCache Validation Set
  • Size: 40,429 evaluation samples
  • Columns: sentence1, sentence2, and label
  • Approximate statistics based on the first 1000 samples:
    sentence1 sentence2 label
    type string string int
    details
    • min: 13 characters
    • mean: 59.91 characters
    • max: 266 characters
    • min: 13 characters
    • mean: 59.51 characters
    • max: 293 characters
    • 0: ~63.80%
    • 1: ~36.20%
  • Samples:
    sentence1 sentence2 label
    How can I get a list of my Gmail accounts? How can I find all my old Gmail accounts? 1
    How can I stop Quora from modifying and editing other peopleโ€™s questions on Quora? Can I prevent a Quora user from editing my question on Quora? 1
    How much does it cost to design a logo in india? How much does it cost to design a logo? 0
  • Loss: BinaryCrossEntropyLoss with these parameters:
    {
        "activation_fn": "torch.nn.modules.linear.Identity",
        "pos_weight": null
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • learning_rate: 0.0002
  • num_train_epochs: 15
  • load_best_model_at_end: True
  • push_to_hub: True
  • hub_model_id: aditeyabaral-redis/langcache-crossencoder-v1-ms-marco-MiniLM-L12-v2

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 64
  • per_device_eval_batch_size: 64
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 0.0002
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 15
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: False
  • fp16: False
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: True
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: True
  • resume_from_checkpoint: None
  • hub_model_id: aditeyabaral-redis/langcache-crossencoder-v1-ms-marco-MiniLM-L12-v2
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional

Training Logs

Click to expand
Epoch Step Training Loss Validation Loss quora-eval_average_precision
0.0879 500 0.3912 0.3494 0.5710
0.1759 1000 0.3467 0.3193 0.5648
0.2638 1500 0.3403 0.3179 0.5698
0.3517 2000 0.3348 0.3045 0.6115
0.4397 2500 0.3275 0.3143 0.6306
0.5276 3000 0.3153 0.3034 0.5772
0.6155 3500 0.3196 0.2990 0.5759
0.7035 4000 0.3165 0.2924 0.5700
0.7914 4500 0.3052 0.2987 0.6343
0.8794 5000 0.3131 0.3184 0.5388
0.9673 5500 0.3053 0.2936 0.6038
1.0552 6000 0.2782 0.3003 0.6315
1.1432 6500 0.2599 0.2922 0.6226
1.2311 7000 0.2661 0.3477 0.6244
1.3190 7500 0.2578 0.3150 0.6438
1.4070 8000 0.2644 0.2915 0.6168
1.4949 8500 0.2635 0.2835 0.6427
1.5828 9000 0.266 0.2880 0.6556
1.6708 9500 0.2618 0.3050 0.6258
1.7587 10000 0.2651 0.2815 0.6488
1.8466 10500 0.2703 0.2803 0.5877
1.9346 11000 0.2601 0.2925 0.5998
2.0225 11500 0.2527 0.3401 0.6626
2.1104 12000 0.2173 0.2813 0.6109
2.1984 12500 0.2124 0.3034 0.6207
2.2863 13000 0.2221 0.3097 0.6164
2.3743 13500 0.2231 0.2929 0.5904
2.4622 14000 0.2247 0.3355 0.5872
2.5501 14500 0.226 0.3286 0.6354
2.6381 15000 0.2312 0.3024 0.5988
2.7260 15500 0.2382 0.2854 0.5627
2.8139 16000 0.2347 0.2991 0.5965
2.9019 16500 0.2283 0.2949 0.6256
2.9898 17000 0.2399 0.2849 0.6317
3.0777 17500 0.2024 0.3391 0.5659
3.1657 18000 0.1963 0.3010 0.6274
3.2536 18500 0.1932 0.3469 0.6255
3.3415 19000 0.2038 0.3331 0.6052
3.4295 19500 0.2005 0.3421 0.5648
3.5174 20000 0.2078 0.3266 0.6189
3.6053 20500 0.2033 0.3398 0.6279
3.6933 21000 0.2101 0.3149 0.6106
3.7812 21500 0.2255 0.3352 0.6362
3.8692 22000 0.2107 0.3216 0.6295
3.9571 22500 0.2269 0.2968 0.6251
4.0450 23000 0.2063 0.3329 0.5968
4.1330 23500 0.1872 0.3457 0.5843
4.2209 24000 0.1902 0.4201 0.5722
4.3088 24500 0.2043 0.3506 0.5670
4.3968 25000 0.1991 0.3146 0.5807
4.4847 25500 0.2061 0.3409 0.3265
4.5726 26000 0.2104 0.3690 0.5509
4.6606 26500 0.2122 0.3400 0.5678
4.7485 27000 0.213 0.3283 0.3679
4.8364 27500 0.2181 0.3373 0.6225
4.9244 28000 0.2312 0.3397 0.5945
5.0123 28500 0.2227 0.3401 0.5783
5.1002 29000 0.1954 0.3705 0.5907
5.1882 29500 0.2084 0.3293 0.5770
5.2761 30000 0.2046 0.3847 0.5815
5.3641 30500 0.2093 0.3407 0.6050
5.4520 31000 0.2066 0.3582 0.5621
5.5399 31500 0.2038 0.3495 0.5632
5.6279 32000 0.2037 0.3237 0.5434
5.7158 32500 0.1993 0.3480 0.5230
5.8037 33000 0.1999 0.3315 0.5572
5.8917 33500 0.1936 0.3271 0.5538
5.9796 34000 0.2022 0.3507 0.5232
6.0675 34500 0.2014 0.3734 0.4539
6.1555 35000 0.1931 0.3790 0.5118
6.2434 35500 0.1989 0.3970 0.4461
6.3313 36000 0.1953 0.3696 0.4504
6.4193 36500 0.1977 0.3440 0.4783
6.5072 37000 0.1946 0.3790 0.5619
6.5951 37500 0.2212 0.3734 0.5811
6.6831 38000 0.2221 0.3885 0.4700
6.7710 38500 0.2048 0.3547 0.4436
6.8590 39000 0.1965 0.3643 0.3691
6.9469 39500 0.1955 0.3554 0.6121
7.0348 40000 0.1886 0.3495 0.5667
7.1228 40500 0.1796 0.4076 0.5291
7.2107 41000 0.1744 0.3378 0.5866
7.2986 41500 0.1688 0.3813 0.5942
7.3866 42000 0.1659 0.3278 0.5806
7.4745 42500 0.1646 0.3609 0.5678
7.5624 43000 0.1617 0.3852 0.5917
7.6504 43500 0.1588 0.3618 0.5789
7.7383 44000 0.1566 0.3409 0.5286
7.8262 44500 0.1614 0.3410 0.5767
7.9142 45000 0.1625 0.3402 0.5505
8.0021 45500 0.1652 0.3426 0.6049
8.0900 46000 0.1351 0.3754 0.5681
8.1780 46500 0.1363 0.3737 0.5688
8.2659 47000 0.1319 0.3651 0.5704
8.3539 47500 0.1343 0.3406 0.4727
8.4418 48000 0.1385 0.3728 0.5917
8.5297 48500 0.1335 0.3730 0.4597
8.6177 49000 0.1327 0.3436 0.5480
8.7056 49500 0.1319 0.3748 0.5610
8.7935 50000 0.1379 0.3314 0.6036
8.8815 50500 0.1386 0.3368 0.5501
8.9694 51000 0.1373 0.3441 0.5672
9.0573 51500 0.119 0.3909 0.5266
9.1453 52000 0.1195 0.4138 0.5029
9.2332 52500 0.1114 0.4174 0.5001
9.3211 53000 0.1154 0.3623 0.5219
9.4091 53500 0.1142 0.4175 0.5235
9.4970 54000 0.1146 0.3877 0.5652
9.5849 54500 0.1145 0.4052 0.3716
9.6729 55000 0.1159 0.3755 0.5593
9.7608 55500 0.1102 0.3821 0.4637
9.8488 56000 0.1073 0.3785 0.5502
9.9367 56500 0.112 0.3908 0.4852
10.0246 57000 0.1105 0.4008 0.5485
10.1126 57500 0.0919 0.4266 0.5240
10.2005 58000 0.0942 0.4328 0.5125
10.2884 58500 0.0945 0.4304 0.4780
10.3764 59000 0.0933 0.4200 0.5214
10.4643 59500 0.0976 0.3932 0.4576
10.5522 60000 0.0965 0.3963 0.4754
10.6402 60500 0.0937 0.4558 0.5249
10.7281 61000 0.0956 0.4494 0.5159
10.8160 61500 0.101 0.4063 0.5204
10.9040 62000 0.0956 0.4243 0.4250
10.9919 62500 0.0933 0.3847 0.5222
11.0798 63000 0.0776 0.4363 0.5281
11.1678 63500 0.0765 0.4253 0.5159
11.2557 64000 0.0767 0.4306 0.5223
11.3437 64500 0.0805 0.4185 0.5205
11.4316 65000 0.0817 0.4297 0.5152
11.5195 65500 0.0791 0.4323 0.5041
11.6075 66000 0.0771 0.4147 0.5180
11.6954 66500 0.081 0.4077 0.5577
11.7833 67000 0.0832 0.4268 0.5382
11.8713 67500 0.0784 0.4461 0.5259
11.9592 68000 0.0801 0.4401 0.3307
12.0471 68500 0.0749 0.4472 0.5192
12.1351 69000 0.0632 0.4932 0.5295
12.2230 69500 0.0651 0.4877 0.4111
12.3109 70000 0.0653 0.4903 0.3651
12.3989 70500 0.0641 0.4918 0.4986
12.4868 71000 0.0635 0.4564 0.5429
12.5747 71500 0.0659 0.4626 0.5470
12.6627 72000 0.0675 0.4363 0.5449
12.7506 72500 0.0664 0.3980 0.5171
12.8386 73000 0.0669 0.4566 0.3894
12.9265 73500 0.065 0.4781 0.5442
13.0144 74000 0.0672 0.4782 0.5255
13.1024 74500 0.0546 0.4897 0.5167
13.1903 75000 0.0535 0.5131 0.5216
13.2782 75500 0.0575 0.4811 0.5258
13.3662 76000 0.0562 0.4530 0.5227
13.4541 76500 0.057 0.4338 0.5115
13.5420 77000 0.0553 0.4658 0.5136
13.6300 77500 0.0519 0.5106 0.5071
13.7179 78000 0.0541 0.4508 0.5262
13.8058 78500 0.0564 0.4491 0.5368
13.8938 79000 0.0546 0.4809 0.5121
13.9817 79500 0.0506 0.4874 0.5183
14.0696 80000 0.0484 0.4755 0.5129
14.1576 80500 0.0473 0.4932 0.5104
14.2455 81000 0.0472 0.4776 0.5009
14.3335 81500 0.0446 0.5355 0.4464
14.4214 82000 0.0465 0.5294 0.4414
14.5093 82500 0.0499 0.5268 0.4909
14.5973 83000 0.0467 0.4991 0.5019
14.6852 83500 0.0438 0.5074 0.4968
14.7731 84000 0.0455 0.5112 0.4827
14.8611 84500 0.0466 0.4864 0.5007
14.9490 85000 0.0457 0.4898 0.5019
-1 -1 - - 0.5877
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.11.11
  • Sentence Transformers: 4.1.0
  • Transformers: 4.52.4
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.8.0
  • Datasets: 3.6.0
  • Tokenizers: 0.21.1

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
288
Safetensors
Model size
33.4M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for aditeyabaral-redis/langcache-crossencoder-v1-ms-marco-MiniLM-L12-v2

Finetuned
(7)
this model

Evaluation results