Views
No views yet
pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("jayshah5696/er2-ce-bge-reranker-m3-ft")
5# Get scores for pairs of texts
6pairs = [
7 ["{'entity_id': 'E2-013271', 'first_name': 'Ramswaroop', 'last_name': 'Kakoti', 'company': 'KDS APPLIANCES RBS', 'title': 'Highway Painter Helper', 'email': 'ramswaroop_kakoti@kdsappliancesrbs.com', 'country': 'GB', 'ethnicity_group': 'indian', 'name_script': 'latin'}", "{'entity_id': 'E2-013271', 'first_name': 'Ramsaroop', 'last_name': 'Kakoti', 'company': 'KDS APPLIANCES RBS', 'title': 'Highway Painter Helper', 'email': 'ramswaroop_kakoti@kdsappliancesrbs.com', 'country': 'GB', 'ethnicity_group': 'indian', 'name_script': 'latin'}"],
8 ["{'entity_id': 'E2-036160', 'first_name': 'Lole', 'last_name': 'Camaney', 'company': 'Monroe Capital CFO I Ltd.', 'title': 'Computer Technology Trainer', 'email': 'lole@monroecapitalcfoi.com', 'country': 'KY', 'ethnicity_group': 'hispanic', 'name_script': 'latin'}", "{'entity_id': 'E2-045966', 'first_name': 'Lali', 'last_name': 'Roig', 'company': 'AQUA AEREM (DBH) PTY LTD', 'title': 'Clamp Operator', 'email': 'laliroig@aquaaeremdbh.com', 'country': 'AU', 'ethnicity_group': 'other', 'name_script': 'latin'}"],
9 ["{'entity_id': 'E2-045272', 'first_name': 'Rim', 'last_name': 'Hue', 'company': 'Edizioni ZYX Music SRL', 'title': 'Radiologic Technology Teacher', 'email': 'rim_hue@edizionizyxmusic.com', 'country': 'IT', 'ethnicity_group': 'other', 'name_script': 'latin'}", "{'entity_id': 'E2-043277', 'first_name': 'Less', 'last_name': 'Hue', 'company': 'EXERGY S.P.A. - IN LIQUIDAZIONE', 'title': 'Personnel Quality Assurance Auditor', 'email': 'less_hue@exergyspainliquidazione.com', 'country': 'IT', 'ethnicity_group': 'other', 'name_script': 'latin'}"],
10 ["{'entity_id': 'E2-010159', 'first_name': 'Brianna', 'last_name': 'Cruzmartinez', 'company': 'S PARIKH AND CO', 'title': 'General Manager (GM)', 'email': 'bcruzmartinez@sparikhand.com', 'country': 'IN', 'ethnicity_group': 'us_uk_english', 'name_script': 'latin'}", "{'entity_id': 'E2-010442', 'first_name': 'Brian', 'last_name': 'Alves', 'company': '中州國際證券有限公司', 'title': 'Soaking Pits Supervisor', 'email': 'brian.alves@example.com', 'country': 'HK', 'ethnicity_group': 'us_uk_english', 'name_script': 'latin'}"],
11 ["{'entity_id': 'E2-015732', 'first_name': 'Ikka', 'last_name': 'Dhurve', 'company': 'Tiburon Unternehmensaufbau GmbH', 'title': 'Freight Elevator Operator', 'email': 'idhurve@tiburonunternehmensaufbau.com', 'country': 'DE', 'ethnicity_group': 'indian', 'name_script': 'latin'}", "{'entity_id': 'E2-015732', 'first_name': 'Ikka', 'last_name': 'Dhurve', 'company': 'Tiburon Unternehmensaufbau', 'title': 'Freight Elevator Operator', 'email': 'idhurve@tiburonunternehmensaufbau.com', 'country': 'DE', 'ethnicity_group': 'indian', 'name_script': 'latin'}"],
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 "{'entity_id': 'E2-013271', 'first_name': 'Ramswaroop', 'last_name': 'Kakoti', 'company': 'KDS APPLIANCES RBS', 'title': 'Highway Painter Helper', 'email': 'ramswaroop_kakoti@kdsappliancesrbs.com', 'country': 'GB', 'ethnicity_group': 'indian', 'name_script': 'latin'}",
20 [
21 "{'entity_id': 'E2-013271', 'first_name': 'Ramsaroop', 'last_name': 'Kakoti', 'company': 'KDS APPLIANCES RBS', 'title': 'Highway Painter Helper', 'email': 'ramswaroop_kakoti@kdsappliancesrbs.com', 'country': 'GB', 'ethnicity_group': 'indian', 'name_script': 'latin'}",
22 "{'entity_id': 'E2-045966', 'first_name': 'Lali', 'last_name': 'Roig', 'company': 'AQUA AEREM (DBH) PTY LTD', 'title': 'Clamp Operator', 'email': 'laliroig@aquaaeremdbh.com', 'country': 'AU', 'ethnicity_group': 'other', 'name_script': 'latin'}",
23 "{'entity_id': 'E2-043277', 'first_name': 'Less', 'last_name': 'Hue', 'company': 'EXERGY S.P.A. - IN LIQUIDAZIONE', 'title': 'Personnel Quality Assurance Auditor', 'email': 'less_hue@exergyspainliquidazione.com', 'country': 'IT', 'ethnicity_group': 'other', 'name_script': 'latin'}",
24 "{'entity_id': 'E2-010442', 'first_name': 'Brian', 'last_name': 'Alves', 'company': '中州國際證券有限公司', 'title': 'Soaking Pits Supervisor', 'email': 'brian.alves@example.com', 'country': 'HK', 'ethnicity_group': 'us_uk_english', 'name_script': 'latin'}",
25 "{'entity_id': 'E2-015732', 'first_name': 'Ikka', 'last_name': 'Dhurve', 'company': 'Tiburon Unternehmensaufbau', 'title': 'Freight Elevator Operator', 'email': 'idhurve@tiburonunternehmensaufbau.com', 'country': 'DE', 'ethnicity_group': 'indian', 'name_script': 'latin'}",
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]bge_reranker_m3CEBinaryClassificationEvaluator| Metric | Value |
|---|---|
| accuracy | 0.9992 |
| accuracy_threshold | 0.9999 |
| f1 | 0.9992 |
| f1_threshold | 0.9999 |
| precision | 1.0 |
| recall | 0.9984 |
| average_precision | 0.9994 |
label, text_a, and text_b| label | text_a | text_b | |
|---|---|---|---|
| type | int | string | string |
| details |
|
|
|
| label | text_a | text_b |
|---|---|---|
0 | {'entity_id': 'E2-011894', 'first_name': 'Noel', 'last_name': 'Muldowney', 'company': 'HIPP UK LIMITED', 'title': 'Flight Teacher', 'email': '[object Object]', 'country': 'GB', 'ethnicity_group': 'us_uk_english', 'name_script': 'latin'} | {'entity_id': 'E2-003538', 'first_name': 'Neal', 'last_name': 'Ellenberger', 'company': 'Hawthorns Park Ltd', 'title': 'Rip Sawyer', 'email': '[object Object]', 'country': 'GB', 'ethnicity_group': 'us_uk_english', 'name_script': 'latin'} |
1 | {'entity_id': 'E2-024730', 'first_name': '正平', 'last_name': 'Yan', 'company': 'TRUSTEE OF M I L WADLEY DECEASED WILL TRUST', 'title': 'Radial Drill Press Operator', 'email': '正平[object Object]', 'country': 'GB', 'ethnicity_group': 'chinese', 'name_script': 'cjk'} | {'entity_id': 'E2-024730', 'first_name': '正平', 'last_name': 'Yan', 'company': 'TRUSTEE OF M I L WADLEY DECEASED WILL TRUST Inc', 'title': 'Radial Drill Press Operator', 'email': '正平[object Object]', 'country': 'GB', 'ethnicity_group': 'chinese', 'name_script': 'cjk'} |
0 | {'entity_id': 'E2-044064', 'first_name': 'Gîte', 'last_name': 'Gi', 'company': 'VECMEDICAL SPAIN SL', 'title': 'Shellfish Bed Worker', 'email': 'gî[object Object]', 'country': 'ES', 'ethnicity_group': 'other', 'name_script': 'latin'} | {'entity_id': 'E2-030776', 'first_name': 'Anyelo', 'last_name': 'Dela Cruz', 'company': 'AVURNAVE S.L', 'title': 'Nail Assembly Machine Operator', 'email': 'adela [object Object]', 'country': 'ES', 'ethnicity_group': 'hispanic', 'name_script': 'latin'} |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}label, text_a, and text_b| label | text_a | text_b | |
|---|---|---|---|
| type | int | string | string |
| details |
|
|
|
| label | text_a | text_b |
|---|---|---|
1 | {'entity_id': 'E2-013271', 'first_name': 'Ramswaroop', 'last_name': 'Kakoti', 'company': 'KDS APPLIANCES RBS', 'title': 'Highway Painter Helper', 'email': '[object Object]', 'country': 'GB', 'ethnicity_group': 'indian', 'name_script': 'latin'} | {'entity_id': 'E2-013271', 'first_name': 'Ramsaroop', 'last_name': 'Kakoti', 'company': 'KDS APPLIANCES RBS', 'title': 'Highway Painter Helper', 'email': '[object Object]', 'country': 'GB', 'ethnicity_group': 'indian', 'name_script': 'latin'} |
0 | {'entity_id': 'E2-036160', 'first_name': 'Lole', 'last_name': 'Camaney', 'company': 'Monroe Capital CFO I Ltd.', 'title': 'Computer Technology Trainer', 'email': '[object Object]', 'country': 'KY', 'ethnicity_group': 'hispanic', 'name_script': 'latin'} | {'entity_id': 'E2-045966', 'first_name': 'Lali', 'last_name': 'Roig', 'company': 'AQUA AEREM (DBH) PTY LTD', 'title': 'Clamp Operator', 'email': '[object Object]', 'country': 'AU', 'ethnicity_group': 'other', 'name_script': 'latin'} |
0 | {'entity_id': 'E2-045272', 'first_name': 'Rim', 'last_name': 'Hue', 'company': 'Edizioni ZYX Music SRL', 'title': 'Radiologic Technology Teacher', 'email': '[object Object]', 'country': 'IT', 'ethnicity_group': 'other', 'name_script': 'latin'} | {'entity_id': 'E2-043277', 'first_name': 'Less', 'last_name': 'Hue', 'company': 'EXERGY S.P.A. - IN LIQUIDAZIONE', 'title': 'Personnel Quality Assurance Auditor', 'email': '[object Object]', 'country': 'IT', 'ethnicity_group': 'other', 'name_script': 'latin'} |
BinaryCrossEntropyLoss with these parameters:
1{
2 "activation_fn": "torch.nn.modules.linear.Identity",
3 "pos_weight": null
4}eval_strategy: epochper_device_train_batch_size: 32per_device_eval_batch_size: 64learning_rate: 2e-05num_train_epochs: 5warmup_ratio: 0.1fp16: Trueload_best_model_at_end: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 64per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 5max_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: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Truefp16_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: 0dataloader_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}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_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: Falsegradient_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: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | bge_reranker_m3_average_precision |
|---|---|---|---|---|
| 0.0961 | 100 | 0.0224 | - | - |
| 0.1921 | 200 | 0.0057 | - | - |
| 0.2882 | 300 | 0.0182 | - | - |
| 0.3842 | 400 | 0.0167 | - | - |
| 0.4803 | 500 | 0.0097 | - | - |
| 0.5764 | 600 | 0.0095 | - | - |
| 0.6724 | 700 | 0.0093 | - | - |
| 0.7685 | 800 | 0.0049 | - | - |
| 0.8646 | 900 | 0.0091 | - | - |
| 0.9606 | 1000 | 0.0144 | - | - |
| 1.0 | 1041 | - | 0.0059 | 0.9999 |
| 1.0567 | 1100 | 0.007 | - | - |
| 1.1527 | 1200 | 0.0188 | - | - |
| 1.2488 | 1300 | 0.0071 | - | - |
| 1.3449 | 1400 | 0.0144 | - | - |
| 1.4409 | 1500 | 0.01 | - | - |
| 1.5370 | 1600 | 0.0064 | - | - |
| 1.6330 | 1700 | 0.0094 | - | - |
| 1.7291 | 1800 | 0.0183 | - | - |
| 1.8252 | 1900 | 0.0069 | - | - |
| 1.9212 | 2000 | 0.0136 | - | - |
| 2.0 | 2082 | - | 0.0054 | 0.9999 |
| 2.0173 | 2100 | 0.0087 | - | - |
| 2.1134 | 2200 | 0.0074 | - | - |
| 2.2094 | 2300 | 0.0094 | - | - |
| 2.3055 | 2400 | 0.0028 | - | - |
| 2.4015 | 2500 | 0.0142 | - | - |
| 2.4976 | 2600 | 0.0178 | - | - |
| 2.5937 | 2700 | 0.0129 | - | - |
| 2.6897 | 2800 | 0.0135 | - | - |
| 2.7858 | 2900 | 0.007 | - | - |
| 2.8818 | 3000 | 0.0048 | - | - |
| 2.9779 | 3100 | 0.0115 | - | - |
| 3.0 | 3123 | - | 0.0060 | 0.9998 |
| 3.0740 | 3200 | 0.0122 | - | - |
| 3.1700 | 3300 | 0.0063 | - | - |
| 3.2661 | 3400 | 0.0105 | - | - |
| 3.3622 | 3500 | 0.0088 | - | - |
| 3.4582 | 3600 | 0.0165 | - | - |
| 3.5543 | 3700 | 0.0028 | - | - |
| 3.6503 | 3800 | 0.0129 | - | - |
| 3.7464 | 3900 | 0.0017 | - | - |
| 3.8425 | 4000 | 0.0047 | - | - |
| 3.9385 | 4100 | 0.0053 | - | - |
| 4.0 | 4164 | - | 0.0093 | 0.9995 |
| 4.0346 | 4200 | 0.0033 | - | - |
| 4.1306 | 4300 | 0.0034 | - | - |
| 4.2267 | 4400 | 0.0002 | - | - |
| 4.3228 | 4500 | 0.0025 | - | - |
| 4.4188 | 4600 | 0.0045 | - | - |
| 4.5149 | 4700 | 0.0132 | - | - |
| 4.6110 | 4800 | 0.0004 | - | - |
| 4.7070 | 4900 | 0.0043 | - | - |
| 4.8031 | 5000 | 0.0031 | - | - |
| 4.8991 | 5100 | 0.0001 | - | - |
| 4.9952 | 5200 | 0.001 | - | - |
| 5.0 | 5205 | - | 0.0108 | 0.9994 |
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}