Views
No views yet
pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("hasankursun/reranker-Multilingual-MiniLM-L12-H384-msmarco-mse")
5# Get scores for pairs of texts
6pairs = [
7 ['what who did dr nassar molest', 'Dr. Larry Nassar, who is 54 years old, has been in prison while awaiting sentencing. During that time, McKayla Maroney and Aly Raisman revealed that Dr. Nassar had molested them, sharing their heartbreaking #MeToo stories with the world. Like so many others, these Olympic superstars describe Dr. Nassar, at the time their team doctor, administering treatments to them under the guise of medical practice.'],
8 ['average monthly temperature in vancouver', 'Vancouver: Annual Weather Averages. August is the hottest month in Vancouver with an average temperature of 18°C (64°F) and the coldest is January at 4°C (38°F) with the most daily sunshine hours at 13 in July.The wettest month is November with an average of 200mm of rain.The best month to swim in the sea is in July when the average sea temperature is 14°C (57°F).he wettest month is November with an average of 200mm of rain. The best month to swim in the sea is in July when the average sea temperature is 14°C (57°F).'],
9 ['do i have to file a tax return for my business if i dont have any income', 'The responsibility for filing your childâ\x80\x99s tax return rests with your child if he is capable of doing so. If he is not old enough to understand how to prepare a tax return, then it becomes your responsibility to file it for him or to include his income on your return.he responsibility for filing your childâ\x80\x99s tax return rests with your child if he is capable of doing so. If he is not old enough to understand how to prepare a tax return, then it becomes your responsibility to file it for him or to include his income on your return.'],
10 ['what happens to your growth plate when you finish growing', 'Over the past 70 million years, the combined processes of magma formation, volcano eruption and growth, and continued movement of the Pacific Plate over the stationary Hawaiian hot-spot have left a long trail of volcanoes across the Pacific Ocean floor.s the Pacific Plate continues to move west-northwest, the Island of Hawaii will be carried beyond the hotspot by plate motion, setting the stage for the formation of a new volcanic island in its place.'],
11 ['average cost of holiday to new zealand', 'Definition: Average total cost is the sum of all the production costs divided by the number of units produced. Terms related to Average Total Cost: 1 The Cost Curve. 2 Average Propensity to Consume.'],
12]
13scores = model.predict(pairs)
14print(scores.shape)
15# (5,)
16
17# Or rank different texts based on similarity to a single text
18ranks = model.rank(
19 'what who did dr nassar molest',
20 [
21 'Dr. Larry Nassar, who is 54 years old, has been in prison while awaiting sentencing. During that time, McKayla Maroney and Aly Raisman revealed that Dr. Nassar had molested them, sharing their heartbreaking #MeToo stories with the world. Like so many others, these Olympic superstars describe Dr. Nassar, at the time their team doctor, administering treatments to them under the guise of medical practice.',
22 'Vancouver: Annual Weather Averages. August is the hottest month in Vancouver with an average temperature of 18°C (64°F) and the coldest is January at 4°C (38°F) with the most daily sunshine hours at 13 in July.The wettest month is November with an average of 200mm of rain.The best month to swim in the sea is in July when the average sea temperature is 14°C (57°F).he wettest month is November with an average of 200mm of rain. The best month to swim in the sea is in July when the average sea temperature is 14°C (57°F).',
23 'The responsibility for filing your childâ\x80\x99s tax return rests with your child if he is capable of doing so. If he is not old enough to understand how to prepare a tax return, then it becomes your responsibility to file it for him or to include his income on your return.he responsibility for filing your childâ\x80\x99s tax return rests with your child if he is capable of doing so. If he is not old enough to understand how to prepare a tax return, then it becomes your responsibility to file it for him or to include his income on your return.',
24 'Over the past 70 million years, the combined processes of magma formation, volcano eruption and growth, and continued movement of the Pacific Plate over the stationary Hawaiian hot-spot have left a long trail of volcanoes across the Pacific Ocean floor.s the Pacific Plate continues to move west-northwest, the Island of Hawaii will be carried beyond the hotspot by plate motion, setting the stage for the formation of a new volcanic island in its place.',
25 'Definition: Average total cost is the sum of all the production costs divided by the number of units produced. Terms related to Average Total Cost: 1 The Cost Curve. 2 Average Propensity to Consume.',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]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.5969 (+0.1073) | 0.3452 (+0.0842) | 0.6475 (+0.2279) |
| mrr@10 | 0.5916 (+0.1141) | 0.5892 (+0.0893) | 0.6618 (+0.2351) |
| ndcg@10 | 0.6640 (+0.1236) | 0.3925 (+0.0674) | 0.7035 (+0.2028) |
NanoBEIR_R100_meanCrossEncoderNanoBEIREvaluator with these parameters:
1{
2 "dataset_names": [
3 "msmarco",
4 "nfcorpus",
5 "nq"
6 ],
7 "rerank_k": 100,
8 "at_k": 10,
9 "always_rerank_positives": true
10}| Metric | Value |
|---|---|
| map | 0.5299 (+0.1398) |
| mrr@10 | 0.6142 (+0.1462) |
| ndcg@10 | 0.5867 (+0.1313) |
score, query, and passage| score | query | passage | |
|---|---|---|---|
| type | float | string | string |
| details |
|
|
|
| score | query | passage |
|---|---|---|
-1.2796382506688435 | what hormone is released after a meal | This conduction of bile is the main function of the common bile duct. The hormone cholecystokinin, when stimulated by a fatty meal, promotes bile secretion by increased production of hepatic bile, contraction of the gall bladder, and relaxation of the Sphincter of Oddi. |
5.993939399719238 | what can cause fluid around the heart and in the lungs | But in certain circumstances, the alveoli fill with fluid instead of air, preventing oxygen from being absorbed into your bloodstream. A number of things can cause fluid to accumulate in your lungs, but most have to do with your heart (cardiogenic pulmonary edema). |
-3.6289062102635703 | which war did augustus underwood serve in? | Quick Answer. Caesar Augustus, also known as Octavian, was the first Roman emperor after the assassination of Julius Caesar in 43 B.C. Augustus was Caesar's grand nephew who shrewdly combined lawmaking, military might and institutional building to create the foundations of the 200-year Pax Romana, explains Biography.com. |
MSELoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity"
3}score, query, and passage| score | query | passage | |
|---|---|---|---|
| type | float | string | string |
| details |
|
|
|
| score | query | passage |
|---|---|---|
7.531805515289307 | what who did dr nassar molest | Dr. Larry Nassar, who is 54 years old, has been in prison while awaiting sentencing. During that time, McKayla Maroney and Aly Raisman revealed that Dr. Nassar had molested them, sharing their heartbreaking #MeToo stories with the world. Like so many others, these Olympic superstars describe Dr. Nassar, at the time their team doctor, administering treatments to them under the guise of medical practice. |
8.721138636271158 | average monthly temperature in vancouver | Vancouver: Annual Weather Averages. August is the hottest month in Vancouver with an average temperature of 18°C (64°F) and the coldest is January at 4°C (38°F) with the most daily sunshine hours at 13 in July.The wettest month is November with an average of 200mm of rain.The best month to swim in the sea is in July when the average sea temperature is 14°C (57°F).he wettest month is November with an average of 200mm of rain. The best month to swim in the sea is in July when the average sea temperature is 14°C (57°F). |
-2.6914831002553306 | do i have to file a tax return for my business if i dont have any income | The responsibility for filing your childâs tax return rests with your child if he is capable of doing so. If he is not old enough to understand how to prepare a tax return, then it becomes your responsibility to file it for him or to include his income on your return.he responsibility for filing your childâs tax return rests with your child if he is capable of doing so. If he is not old enough to understand how to prepare a tax return, then it becomes your responsibility to file it for him or to include his income on your return. |
MSELoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity"
3}eval_strategy: stepsper_device_train_batch_size: 16per_device_eval_batch_size: 16learning_rate: 8e-06num_train_epochs: 1warmup_ratio: 0.1seed: 12bf16: Truedataloader_num_workers: 4load_best_model_at_end: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 8e-06weight_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: 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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_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: Falsehub_revision: Nonegradient_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: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | NanoMSMARCO_R100_ndcg@10 | NanoNFCorpus_R100_ndcg@10 | NanoNQ_R100_ndcg@10 | NanoBEIR_R100_mean_ndcg@10 |
|---|---|---|---|---|---|---|---|
| -1 | -1 | - | - | 0.0412 (-0.4992) | 0.2383 (-0.0867) | 0.0468 (-0.4538) | 0.1088 (-0.3466) |
| 0.0000 | 1 | 66.3043 | - | - | - | - | - |
| 0.0322 | 4000 | 51.8043 | - | - | - | - | - |
| 0.0643 | 8000 | 19.8202 | - | - | - | - | - |
| 0.0965 | 12000 | 8.3776 | - | - | - | - | - |
| 0.1286 | 16000 | 5.8256 | - | - | - | - | - |
| 0.1608 | 20000 | 4.9058 | 4.1738 | 0.6666 (+0.1262) | 0.3713 (+0.0463) | 0.6888 (+0.1882) | 0.5756 (+0.1202) |
| 0.1930 | 24000 | 4.4046 | - | - | - | - | - |
| 0.2251 | 28000 | 4.0191 | - | - | - | - | - |
| 0.2573 | 32000 | 3.8165 | - | - | - | - | - |
| 0.2894 | 36000 | 3.5786 | - | - | - | - | - |
| 0.3216 | 40000 | 3.484 | 3.3411 | 0.6856 (+0.1451) | 0.3848 (+0.0597) | 0.6858 (+0.1852) | 0.5854 (+0.1300) |
| 0.3538 | 44000 | 3.3467 | - | - | - | - | - |
| 0.3859 | 48000 | 3.1952 | - | - | - | - | - |
| 0.4181 | 52000 | 3.1518 | - | - | - | - | - |
| 0.4503 | 56000 | 3.0006 | - | - | - | - | - |
| 0.4824 | 60000 | 3.0028 | 2.9331 | 0.6609 (+0.1204) | 0.3894 (+0.0643) | 0.7033 (+0.2027) | 0.5845 (+0.1292) |
| 0.5146 | 64000 | 2.8912 | - | - | - | - | - |
| 0.5467 | 68000 | 2.8112 | - | - | - | - | - |
| 0.5789 | 72000 | 2.7707 | - | - | - | - | - |
| 0.6111 | 76000 | 2.7566 | - | - | - | - | - |
| 0.6432 | 80000 | 2.667 | 2.6270 | 0.6603 (+0.1199) | 0.3967 (+0.0717) | 0.6790 (+0.1784) | 0.5787 (+0.1233) |
| 0.6754 | 84000 | 2.6895 | - | - | - | - | - |
| 0.7075 | 88000 | 2.6151 | - | - | - | - | - |
| 0.7397 | 92000 | 2.558 | - | - | - | - | - |
| 0.7719 | 96000 | 2.5346 | - | - | - | - | - |
| 0.804 | 100000 | 2.5255 | 2.3877 | 0.6640 (+0.1236) | 0.3925 (+0.0674) | 0.7035 (+0.2028) | 0.5867 (+0.1313) |
| 0.8362 | 104000 | 2.488 | - | - | - | - | - |
| 0.8683 | 108000 | 2.5009 | - | - | - | - | - |
| 0.9005 | 112000 | 2.4195 | - | - | - | - | - |
| 0.9327 | 116000 | 2.4237 | - | - | - | - | - |
| 0.9648 | 120000 | 2.4671 | 2.3669 | 0.6640 (+0.1236) | 0.3955 (+0.0705) | 0.6877 (+0.1871) | 0.5824 (+0.1270) |
| 0.9970 | 124000 | 2.3769 | - | - | - | - | - |
| -1 | -1 | - | - | 0.6640 (+0.1236) | 0.3925 (+0.0674) | 0.7035 (+0.2028) | 0.5867 (+0.1313) |
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}