Views
No views yet
pip install -U linktransformer1import linktransformer as lt
2import pandas as pd
3
4##Load the two dataframes that you want to link. For example, 2 dataframes with company names that are written differently
5df1=pd.read_csv("data/df1.csv") ###This is the left dataframe with key CompanyName for instance
6df2=pd.read_csv("data/df2.csv") ###This is the right dataframe with key CompanyName for instance
7
8###Merge the two dataframes on the key column!
9df_merged = lt.merge(df1, df2, on="CompanyName", how="inner")
10
11##Done! The merged dataframe has a column called "score" that contains the similarity score between the two company names
121
2##Consider the example in the paper that has a dataset of Mexican products and their tariff codes from 1947 and 1948 and we want train a model to link the two tariff codes.
3saved_model_path = train_model(
4 model_path="hiiamsid/sentence_similarity_spanish_es",
5 dataset_path=dataset_path,
6 left_col_names=["description47"],
7 right_col_names=['description48'],
8 left_id_name=['tariffcode47'],
9 right_id_name=['tariffcode48'],
10 log_wandb=False,
11 config_path=LINKAGE_CONFIG_PATH,
12 training_args={"num_epochs": 1}
13 )
14torch.utils.data.dataloader.DataLoader of length 281 with parameters:{'batch_size': 64, 'sampler': 'torch.utils.data.dataloader._InfiniteConstantSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}linktransformer.modified_sbert.losses.SupConLoss_wandb{
"epochs": 100,
"evaluation_steps": 141,
"evaluator": "sentence_transformers.evaluation.SequentialEvaluator.SequentialEvaluator",
"max_grad_norm": 1,
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
"optimizer_params": {
"lr": 2e-05
},
"scheduler": "WarmupLinear",
"steps_per_epoch": null,
"warmup_steps": 28100,
"weight_decay": 0.01
}
## Citing & Authors