Spaces:
Runtime error
Runtime error
Commit
·
a7247a1
1
Parent(s):
2b0b89d
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
from transformers import AutoModelWithLMHead, AutoTokenizer
|
6 |
+
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
|
8 |
+
model = AutoModelWithLMHead.from_pretrained("microsoft/DialoGPT-medium")
|
9 |
+
|
10 |
+
def chatbot(input_text):
|
11 |
+
input_ids = tokenizer.encode(input_text, return_tensors='pt')
|
12 |
+
output = model.generate(input_ids, max_length=50, do_sample=True, top_k=50, top_p=0.95, num_return_sequences=3)
|
13 |
+
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
14 |
+
return output_text
|
15 |
+
|
16 |
+
iface = gr.Interface(fn=chatbot, inputs="text", outputs="text", description="ChatGPT")
|
17 |
+
iface.launch()
|