Spaces:
Runtime error
Runtime error
deep-learning-analytics
commited on
Commit
•
d0f63c1
1
Parent(s):
02a0fc5
Update app.py
Browse files
app.py
CHANGED
@@ -8,9 +8,9 @@ model = T5ForConditionalGeneration.from_pretrained('deep-learning-analytics/Gram
|
|
8 |
|
9 |
def correct_grammar(input_text,num_return_sequences=1):
|
10 |
batch = tokenizer([input_text],truncation=True,padding='max_length',max_length=64, return_tensors="pt").to(torch_device)
|
11 |
-
|
12 |
-
|
13 |
-
return
|
14 |
|
15 |
-
iface = gr.Interface(fn=correct_grammar, inputs=[gr.inputs.Textbox(lines=5)],outputs=["text"])
|
16 |
iface.launch(inline=False, share=True)
|
|
|
8 |
|
9 |
def correct_grammar(input_text,num_return_sequences=1):
|
10 |
batch = tokenizer([input_text],truncation=True,padding='max_length',max_length=64, return_tensors="pt").to(torch_device)
|
11 |
+
results = model.generate(**batch,max_length=64,num_beams=2, num_return_sequences=num_return_sequences, temperature=1.5)
|
12 |
+
answer = tokenizer.batch_decode(results[0], skip_special_tokens=True)
|
13 |
+
return answer
|
14 |
|
15 |
+
iface = gr.Interface(fn=correct_grammar, inputs=[gr.inputs.Textbox(lines=5)], outputs=["text"])
|
16 |
iface.launch(inline=False, share=True)
|