Update paraphraser.py
Browse files- paraphraser.py +11 -3
paraphraser.py
CHANGED
@@ -27,12 +27,20 @@ def paraphrase_comment(comment):
|
|
27 |
f"Provide the paraphrased comment only, without additional explanation."
|
28 |
)
|
29 |
|
30 |
-
# Tokenize the prompt
|
31 |
-
inputs = tokenizer(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
# Generate the paraphrased comment
|
34 |
outputs = model.generate(
|
35 |
-
inputs["input_ids"],
|
|
|
36 |
max_length=512,
|
37 |
num_beams=5,
|
38 |
no_repeat_ngram_size=2,
|
|
|
27 |
f"Provide the paraphrased comment only, without additional explanation."
|
28 |
)
|
29 |
|
30 |
+
# Tokenize the prompt with attention mask
|
31 |
+
inputs = tokenizer(
|
32 |
+
prompt,
|
33 |
+
return_tensors="pt",
|
34 |
+
truncation=True,
|
35 |
+
padding=True,
|
36 |
+
max_length=512,
|
37 |
+
return_attention_mask=True
|
38 |
+
).to(model.device)
|
39 |
|
40 |
# Generate the paraphrased comment
|
41 |
outputs = model.generate(
|
42 |
+
input_ids=inputs["input_ids"],
|
43 |
+
attention_mask=inputs["attention_mask"],
|
44 |
max_length=512,
|
45 |
num_beams=5,
|
46 |
no_repeat_ngram_size=2,
|