Spaces:
Sleeping
Sleeping
armandstrickernlp
commited on
Commit
·
3ef14f8
1
Parent(s):
a5971a0
Add application file
Browse files
app.py
CHANGED
@@ -1,7 +1,20 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
2 |
+
|
3 |
+
model_name = 'gpt2-TOD_finetuned_SGD'
|
4 |
+
tokenizer_TOD = AutoTokenizer.from_pretrained(model_name)
|
5 |
+
model_TOD = AutoModelForCausalLM.from_pretrained(model_name)
|
6 |
+
|
7 |
+
def generate_response(message):
|
8 |
+
input_ids = tokenizer_TOD(prompt, return_tensors="pt").input_ids
|
9 |
+
outputs = model_TOD.generate(input_ids,
|
10 |
+
do_sample=False,
|
11 |
+
max_length=1024,
|
12 |
+
eos_token_id=50262)
|
13 |
+
return tokenizer_TOD.batch_decode(outputs)[0]
|
14 |
|
|
|
|
|
15 |
|
16 |
+
|
17 |
+
import gradio as gr
|
18 |
+
|
19 |
+
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
20 |
iface.launch()
|