Train a Bert Classifier with more than 2 Input Text Columns
Hi Guys, I am trying to train a bert based classifier for a problem that contains 2 text Columns.The data looks like this:Text 1 | Text 2 | LabelIt is a multi-class problem. I have tried following thisnotebook. But I am having a hard time on using 2 columns together. If someone can point me to the correct resource that would be really helpful.
2023-10-25T19:41:05Z
Is your problem with the tokenizer? You can pass in two input columns in your custom tokenize function, like:def tokenize_function(examples):
    return tokenizer(examples["text1"], examples["text2"])I’m not sure what aspect of the classification you are struggling with. I’m somewhat of a beginner myself, so more details and code examples would be helpful to help you better.
2023-10-26T03:57:32Z
Any end to end solution would be helpful because I want to understand the entire process.
2023-10-26T11:30:10Z
It would be better if you post the code you’ve tried so far and specify the specific problem that you’re having.These forums are usually not for tutorial-type solutions but more for getting help with specific problems.
2023-10-27T08:20:12Z
I tried your way it worked.tokenizer = AutoTokenizer.from_pretrained(model_str)
def tokenize_function(examples):
    return tokenizer(examples["ques_resp"], padding="max_length", truncation=True)
tokenized_datasets2 = dataset2.map(tokenize_function, batched=True)
tokenized_dataset_test = dataset_test.map(tokenize_function, batched=True)
small_train_dataset2 = tokenized_datasets2.shuffle(seed=42).select(range(0,3600))
small_eval_dataset2 = tokenized_datasets2.shuffle(seed=42).select(range(3600,3976))
display(small_train_dataset2)
display(small_eval_dataset2)```