Mudasir692
commited on
Commit
•
a057b65
1
Parent(s):
8a7f1e1
Update README.md
Browse files
README.md
CHANGED
@@ -56,31 +56,11 @@ tokenizer = PegasusTokenizer.from_pretrained(model_path)
|
|
56 |
model = model.to(device)
|
57 |
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
attention_mask = inputs["attention_mask"].to(device)
|
65 |
-
|
66 |
-
# Generate summary
|
67 |
-
model.eval()
|
68 |
-
with torch.no_grad():
|
69 |
-
outputs = model.generate(
|
70 |
-
input_ids=input_ids,
|
71 |
-
attention_mask=attention_mask,
|
72 |
-
max_new_tokens=150,
|
73 |
-
num_beams=8,
|
74 |
-
early_stopping=True,
|
75 |
-
)
|
76 |
-
|
77 |
-
# Decode the generated text
|
78 |
-
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
79 |
-
return generated_text
|
80 |
-
|
81 |
-
|
82 |
-
# Test with a sample input
|
83 |
-
test_input = """
|
84 |
#Person1#: Hey Alice, congratulations on your promotion!
|
85 |
#Person2#: Thank you so much! It means a lot to me. I’m still processing it, honestly.
|
86 |
#Person1#: You totally deserve it. Your hard work finally paid off. Let’s celebrate this weekend.
|
@@ -90,6 +70,10 @@ test_input = """
|
|
90 |
#Person1#: That’s wonderful! I’ll bring a gift too. It’s such a big milestone for you.
|
91 |
#Person2#: You’re the best. Thanks for always being so supportive.
|
92 |
"""
|
93 |
-
|
|
|
|
|
|
|
|
|
94 |
|
95 |
|
|
|
56 |
model = model.to(device)
|
57 |
|
58 |
|
59 |
+
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
|
60 |
+
|
61 |
+
model = PegasusForConditionalGeneration.from_pretrained("Mudasir692/peguses_chat_sum")
|
62 |
+
tokenizer = PegasusTokenizer.from_pretrained("Mudasir692/peguses_chat_sum")
|
63 |
+
input_text = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
#Person1#: Hey Alice, congratulations on your promotion!
|
65 |
#Person2#: Thank you so much! It means a lot to me. I’m still processing it, honestly.
|
66 |
#Person1#: You totally deserve it. Your hard work finally paid off. Let’s celebrate this weekend.
|
|
|
70 |
#Person1#: That’s wonderful! I’ll bring a gift too. It’s such a big milestone for you.
|
71 |
#Person2#: You’re the best. Thanks for always being so supportive.
|
72 |
"""
|
73 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
74 |
+
model.eval()
|
75 |
+
outputs = model.generate(**inputs, max_new_tokens=100)
|
76 |
+
generated_summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
77 |
+
print("generated summary", generated_summary)
|
78 |
|
79 |
|