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': 'BertForSequenceClassification'})
)pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("cross_encoder_model_id")
5# Get scores for pairs of inputs
6pairs = [
7 ['How do you control your horniness?', 'How do I control my horny emotions?'],
8 ['What do i do after my MBBS ?', 'What can one do after MBBS?'],
9 ['What is the county of Edgware and how does the lifestyle compare to the London Borough of Enfield?', 'What is the district of Edgware and how does the lifestyle compare to the London Borough of Islington?'],
10 ['What is a qualified SAP ERP key user?', 'What is the responsibility of SAP ERP key user?'],
11 ['Which is the best book for tensor calculus?', 'Which is the best book to study TENSOR for general relativity from basic?'],
12]
13scores = model.predict(pairs)
14print(scores)
15# [ 0.0335 0.6294 -2.3788 -0.096 -0.4309]
16
17# Or rank different texts based on similarity to a single text
18ranks = model.rank(
19 'How do you control your horniness?',
20 [
21 'How do I control my horny emotions?',
22 'What can one do after MBBS?',
23 'What is the district of Edgware and how does the lifestyle compare to the London Borough of Islington?',
24 'What is the responsibility of SAP ERP key user?',
25 'Which is the best book to study TENSOR for general relativity from basic?',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]query, response, and label| query | response | label | |
|---|---|---|---|
| type | string | string | float |
| modality | text | text | |
| details |
|
|
|
| query | response | label |
|---|---|---|
How do you control your horniness? | How do I control my horny emotions? | 1.0 |
What do i do after my MBBS ? | What can one do after MBBS? | 1.0 |
What is the county of Edgware and how does the lifestyle compare to the London Borough of Enfield? | What is the district of Edgware and how does the lifestyle compare to the London Borough of Islington? | 0.0 |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}per_device_train_batch_size: 16num_train_epochs: 1disable_tqdm: Trueper_device_train_batch_size: 16num_train_epochs: 1max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: 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: Falsebf16_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: Trueproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 8prediction_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: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_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: 0dataloader_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 |
|---|---|---|
| 0.0013 | 1 | 2.9614 |
| 0.0134 | 10 | 0.8912 |
| 0.0268 | 20 | 0.8821 |
| 0.0402 | 30 | 0.6854 |
| 0.0536 | 40 | 0.7558 |
| 0.0670 | 50 | 0.6960 |
| 0.0804 | 60 | 0.6753 |
| 0.0938 | 70 | 0.6979 |
| 0.1072 | 80 | 0.6919 |
| 0.1206 | 90 | 0.6373 |
| 0.1340 | 100 | 0.6750 |
| 0.1475 | 110 | 0.7235 |
| 0.1609 | 120 | 0.6508 |
| 0.1743 | 130 | 0.6698 |
| 0.1877 | 140 | 0.6603 |
| 0.2011 | 150 | 0.6601 |
| 0.2145 | 160 | 0.6269 |
| 0.2279 | 170 | 0.6568 |
| 0.2413 | 180 | 0.5662 |
| 0.2547 | 190 | 0.6341 |
| 0.2681 | 200 | 0.6649 |
| 0.2815 | 210 | 0.6582 |
| 0.2949 | 220 | 0.6966 |
| 0.3083 | 230 | 0.5850 |
| 0.3217 | 240 | 0.5919 |
| 0.3351 | 250 | 0.6952 |
| 0.3485 | 260 | 0.6682 |
| 0.3619 | 270 | 0.6402 |
| 0.3753 | 280 | 0.6923 |
| 0.3887 | 290 | 0.5896 |
| 0.4021 | 300 | 0.6448 |
| 0.4155 | 310 | 0.6208 |
| 0.4290 | 320 | 0.6557 |
| 0.4424 | 330 | 0.6780 |
| 0.4558 | 340 | 0.6057 |
| 0.4692 | 350 | 0.6660 |
| 0.4826 | 360 | 0.6834 |
| 0.4960 | 370 | 0.6351 |
| 0.5094 | 380 | 0.6442 |
| 0.5228 | 390 | 0.6002 |
| 0.5362 | 400 | 0.6454 |
| 0.5496 | 410 | 0.6431 |
| 0.5630 | 420 | 0.6146 |
| 0.5764 | 430 | 0.5826 |
| 0.5898 | 440 | 0.6906 |
| 0.6032 | 450 | 0.6260 |
| 0.6166 | 460 | 0.6390 |
| 0.6300 | 470 | 0.6107 |
| 0.6434 | 480 | 0.6381 |
| 0.6568 | 490 | 0.6296 |
| 0.6702 | 500 | 0.6163 |
| 0.6836 | 510 | 0.5750 |
| 0.6971 | 520 | 0.6387 |
| 0.7105 | 530 | 0.6353 |
| 0.7239 | 540 | 0.5639 |
| 0.7373 | 550 | 0.5501 |
| 0.7507 | 560 | 0.6608 |
| 0.7641 | 570 | 0.6868 |
| 0.7775 | 580 | 0.5937 |
| 0.7909 | 590 | 0.6198 |
| 0.8043 | 600 | 0.6683 |
| 0.8177 | 610 | 0.6228 |
| 0.8311 | 620 | 0.5776 |
| 0.8445 | 630 | 0.6115 |
| 0.8579 | 640 | 0.6536 |
| 0.8713 | 650 | 0.6366 |
| 0.8847 | 660 | 0.6278 |
| 0.8981 | 670 | 0.6331 |
| 0.9115 | 680 | 0.5928 |
| 0.9249 | 690 | 0.6246 |
| 0.9383 | 700 | 0.6273 |
| 0.9517 | 710 | 0.6254 |
| 0.9651 | 720 | 0.5991 |
| 0.9786 | 730 | 0.6309 |
| 0.9920 | 740 | 0.5972 |
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}