jayshah5696/entity-resolution-ce-pairs-v2
Viewer • Updated • 37.1k • 21
How to use jayshah5696/er2-ce-granite-reranker-ft with sentence-transformers:
from sentence_transformers import CrossEncoder
model = CrossEncoder("jayshah5696/er2-ce-granite-reranker-ft")
query = "Which planet is known as the Red Planet?"
passages = [
"Venus is often called Earth's twin because of its similar size and proximity.",
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet."
]
scores = model.predict([(query, passage) for passage in passages])
print(scores)This is a Cross Encoder model finetuned from ibm-granite/granite-embedding-reranker-english-r2 on the entity-resolution-ce-pairs-v2 dataset using the sentence-transformers library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.
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("jayshah5696/er2-ce-granite-reranker-ft")
# Get scores for pairs of texts
pairs = [
["{'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'}"],
["{'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'}"],
["{'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'}"],
["{'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'}"],
["{'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'}"],
]
scores = model.predict(pairs)
print(scores.shape)
# (5,)
# Or rank different texts based on similarity to a single text
ranks = model.rank(
"{'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'}",
"{'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'}",
"{'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'}",
"{'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'}",
"{'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'}",
]
)
# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
granite_rerankerCEBinaryClassificationEvaluator| Metric | Value |
|---|---|
| accuracy | 0.9992 |
| accuracy_threshold | 0.5001 |
| f1 | 0.9992 |
| f1_threshold | 0.5001 |
| precision | 1.0 |
| recall | 0.9984 |
| average_precision | 0.9995 |
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': 'nmuldowney@hipp.com', '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': 'nealellenberger@hawthornspark.com', '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': '正平yan@trusteeofmilwadleydeceasedwilltrust.com', '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': '正平yan@trusteeofmilwadleydeceasedwilltrust.com', '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îte.gi@vecmedicalspain.com', '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 cruz@avurnave.com', 'country': 'ES', 'ethnicity_group': 'hispanic', 'name_script': 'latin'} |
BinaryCrossEntropyLoss with these parameters:{
"activation_fn": "torch.nn.modules.linear.Identity",
"pos_weight": null
}
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': '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'} |
0 |
{'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'} |
0 |
{'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'} |
BinaryCrossEntropyLoss with these parameters:{
"activation_fn": "torch.nn.modules.linear.Identity",
"pos_weight": null
}
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 | granite_reranker_average_precision |
|---|---|---|---|---|
| 0.0961 | 100 | 0.6102 | - | - |
| 0.1921 | 200 | 0.0099 | - | - |
| 0.2882 | 300 | 0.0183 | - | - |
| 0.3842 | 400 | 0.015 | - | - |
| 0.4803 | 500 | 0.0099 | - | - |
| 0.5764 | 600 | 0.0097 | - | - |
| 0.6724 | 700 | 0.0095 | - | - |
| 0.7685 | 800 | 0.005 | - | - |
| 0.8646 | 900 | 0.009 | - | - |
| 0.9606 | 1000 | 0.0132 | - | - |
| 1.0 | 1041 | - | 0.005 | 0.9999 |
| 1.0567 | 1100 | 0.0068 | - | - |
| 1.1527 | 1200 | 0.0159 | - | - |
| 1.2488 | 1300 | 0.0061 | - | - |
| 1.3449 | 1400 | 0.0123 | - | - |
| 1.4409 | 1500 | 0.0093 | - | - |
| 1.5370 | 1600 | 0.0044 | - | - |
| 1.6330 | 1700 | 0.0041 | - | - |
| 1.7291 | 1800 | 0.0132 | - | - |
| 1.8252 | 1900 | 0.0074 | - | - |
| 1.9212 | 2000 | 0.0104 | - | - |
| 2.0 | 2082 | - | 0.0078 | 0.9998 |
| 2.0173 | 2100 | 0.0073 | - | - |
| 2.1134 | 2200 | 0.0064 | - | - |
| 2.2094 | 2300 | 0.0054 | - | - |
| 2.3055 | 2400 | 0.0017 | - | - |
| 2.4015 | 2500 | 0.0063 | - | - |
| 2.4976 | 2600 | 0.0134 | - | - |
| 2.5937 | 2700 | 0.0051 | - | - |
| 2.6897 | 2800 | 0.009 | - | - |
| 2.7858 | 2900 | 0.0037 | - | - |
| 2.8818 | 3000 | 0.0014 | - | - |
| 2.9779 | 3100 | 0.0084 | - | - |
| 3.0 | 3123 | - | 0.0054 | 0.9999 |
| 3.0740 | 3200 | 0.0044 | - | - |
| 3.1700 | 3300 | 0.0014 | - | - |
| 3.2661 | 3400 | 0.0008 | - | - |
| 3.3622 | 3500 | 0.0014 | - | - |
| 3.4582 | 3600 | 0.0007 | - | - |
| 3.5543 | 3700 | 0.0001 | - | - |
| 3.6503 | 3800 | 0.0015 | - | - |
| 3.7464 | 3900 | 0.0009 | - | - |
| 3.8425 | 4000 | 0.0003 | - | - |
| 3.9385 | 4100 | 0.0002 | - | - |
| 4.0 | 4164 | - | 0.0103 | 0.9998 |
| 4.0346 | 4200 | 0.0009 | - | - |
| 4.1306 | 4300 | 0.0002 | - | - |
| 4.2267 | 4400 | 0.0002 | - | - |
| 4.3228 | 4500 | 0.0003 | - | - |
| 4.4188 | 4600 | 0.0001 | - | - |
| 4.5149 | 4700 | 0.0005 | - | - |
| 4.6110 | 4800 | 0.0001 | - | - |
| 4.7070 | 4900 | 0.0002 | - | - |
| 4.8031 | 5000 | 0.0002 | - | - |
| 4.8991 | 5100 | 0.0 | - | - |
| 4.9952 | 5200 | 0.0001 | - | - |
| 5.0 | 5205 | - | 0.0111 | 0.9995 |
@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",
}
Base model
ibm-granite/granite-embedding-english-r2