Spaces:
Sleeping
Sleeping
Ahmed
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,34 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
|
|
1 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
2 |
+
|
3 |
+
tokenizerModelName = 'google/flan-t5-base'
|
4 |
+
instruct_model_name='truocpham/flan-dialogue-summary-checkpoint'
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(tokenizerModelName)
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(instruct_model_name)
|
8 |
+
|
9 |
+
def SummarizeThis(dialogue):
|
10 |
+
prompt = f"""
|
11 |
+
Summarize the following conversation.
|
12 |
+
|
13 |
+
{dialogue}
|
14 |
|
15 |
+
Summary:
|
16 |
+
"""
|
17 |
|
18 |
+
inputs = tokenizer(prompt, return_tensors='pt')
|
19 |
+
output = tokenizer.decode(
|
20 |
+
model.generate(
|
21 |
+
inputs["input_ids"],
|
22 |
+
max_new_tokens=200,
|
23 |
+
)[0],
|
24 |
+
skip_special_tokens=True
|
25 |
+
)
|
26 |
+
|
27 |
+
return output
|
28 |
+
|
29 |
+
|
30 |
+
# Making the gradio application
|
31 |
+
import gradio as gr
|
32 |
+
iface = gr.Interface(fn=SummarizeThis, inputs="text", outputs=["text"], title="Summarization")
|
33 |
|
34 |
+
iface.launch()
|