diff --git a/backend/Generator/main.py b/backend/Generator/main.py index 04aed79f..4223e9e4 100644 --- a/backend/Generator/main.py +++ b/backend/Generator/main.py @@ -160,7 +160,7 @@ def generate_paraphrase(self, payload): sentence = text text_to_paraphrase = "paraphrase: " + sentence + " " - encoding = self.tokenizer.encode_plus(text_to_paraphrase, pad_to_max_length=True, return_tensors="pt") + encoding = self.tokenizer.encode_plus(text_to_paraphrase, padding="max_length", truncation=True, return_tensors="pt") input_ids, attention_masks = encoding["input_ids"].to(self.device), encoding["attention_mask"].to(self.device) beam_outputs = self.model.generate( diff --git a/backend/Generator/mcq.py b/backend/Generator/mcq.py index e2c82954..4db80edd 100644 --- a/backend/Generator/mcq.py +++ b/backend/Generator/mcq.py @@ -177,7 +177,7 @@ def generate_multiple_choice_questions(keyword_sent_mapping, device, tokenizer, text = context + " " + "answer: " + answer + " " batch_text.append(text) - encoding = tokenizer.batch_encode_plus(batch_text, pad_to_max_length=True, return_tensors="pt") + encoding = tokenizer.batch_encode_plus(batch_text, padding="max_length", truncation=True, return_tensors="pt") print("Generating questions using the model...") input_ids, attention_masks = encoding["input_ids"].to(device), encoding["attention_mask"].to(device) @@ -223,7 +223,7 @@ def generate_normal_questions(keyword_sent_mapping, device, tokenizer, model): text = context + " " + "answer: " + answer + " " batch_text.append(text) - encoding = tokenizer.batch_encode_plus(batch_text, pad_to_max_length=True, return_tensors="pt") + encoding = tokenizer.batch_encode_plus(batch_text, padding="max_length", truncation=True, return_tensors="pt") print("Running model for generation...") input_ids, attention_masks = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)