Views
No views yet
pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("kallilikhitha123/finetuned-bge-reranker-2403")
5# Get scores for pairs of texts
6pairs = [
7 ['bhargavi madhavi', 'bhargavi srinidhi'],
8 ['navya kiara', 'navya tanvi'],
9 ['manish', 'manisha'],
10 ['anantha padmanabha', 'ananthpadmanabha'],
11 ['nitin singh', 'n singh'],
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 'bhargavi madhavi',
20 [
21 'bhargavi srinidhi',
22 'navya tanvi',
23 'manisha',
24 'ananthpadmanabha',
25 'n singh',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]entity-matching-evalCrossEncoderClassificationEvaluator| Metric | Value |
|---|---|
| accuracy | 0.9716 |
| accuracy_threshold | 0.9984 |
| f1 | 0.9762 |
| f1_threshold | 0.9965 |
| precision | 0.988 |
| recall | 0.9647 |
| average_precision | 0.9915 |
sentence1, sentence2, and label| sentence1 | sentence2 | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| sentence1 | sentence2 | label |
|---|---|---|
whitefield bangalore | whitefield chennai | 0 |
shastri nagar narangpura ahmedabad | l-5-135 block shastri nagar ahmedabad gujarat | 0 |
plot 45 kukatpally hyderabad | plot 45 kukatpally bangalore | 0 |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}sentence1, sentence2, and label| sentence1 | sentence2 | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
| sentence1 | sentence2 | label |
|---|---|---|
bhargavi madhavi | bhargavi srinidhi | 0 |
navya kiara | navya tanvi | 0 |
manish | manisha | 0 |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}eval_strategy: stepsper_device_eval_batch_size: 16learning_rate: 2e-05weight_decay: 0.01warmup_steps: 73remove_unused_columns: Falseload_best_model_at_end: Truedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 16gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 73log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Falselabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': 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: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Nonegroup_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: Truepush_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_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_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: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | entity-matching-eval_average_precision |
|---|---|---|---|---|
| 0.1463 | 36 | 0.3950 | - | - |
| 0.2927 | 72 | 0.3475 | - | - |
| 0.2967 | 73 | - | 0.3461 | 0.9648 |
| 0.1463 | 36 | 0.0637 | - | - |
| 0.2927 | 72 | 0.1365 | - | - |
| 0.2967 | 73 | - | 0.4392 | 0.9630 |
| 0.4390 | 108 | 0.4193 | - | - |
| 0.5854 | 144 | 0.2634 | - | - |
| 0.5935 | 146 | - | 0.3738 | 0.9602 |
| 0.7317 | 180 | 0.3739 | - | - |
| 0.8780 | 216 | 0.1583 | - | - |
| 0.8902 | 219 | - | 0.1850 | 0.9893 |
| 1.0244 | 252 | 0.1806 | - | - |
| 1.1707 | 288 | 0.1287 | - | - |
| 1.1870 | 292 | - | 0.4037 | 0.9836 |
| 1.3171 | 324 | 0.1883 | - | - |
| 1.4634 | 360 | 0.1562 | - | - |
| 1.4837 | 365 | - | 0.3427 | 0.9868 |
| 1.6098 | 396 | 0.0619 | - | - |
| 1.7561 | 432 | 0.0854 | - | - |
| 1.7805 | 438 | - | 0.2923 | 0.9887 |
| 1.9024 | 468 | 0.1240 | - | - |
| 2.0488 | 504 | 0.1076 | - | - |
| 2.0772 | 511 | - | 0.2441 | 0.9915 |
| 2.1951 | 540 | 0.1289 | - | - |
| 2.3415 | 576 | 0.0311 | - | - |
| 2.3740 | 584 | - | 0.2151 | 0.9923 |
| 2.4878 | 612 | 0.0181 | - | - |
| 2.6341 | 648 | 0.0982 | - | - |
| 2.6707 | 657 | - | 0.2268 | 0.9915 |
| 2.7805 | 684 | 0.0010 | - | - |
| 2.9268 | 720 | 0.0321 | - | - |
| 2.9675 | 730 | - | 0.2393 | 0.9915 |
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}