Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
|
|
3 |
|
4 |
def check_grammar(sentence):
|
5 |
-
tokenizer = AutoTokenizer.from_pretrained("leslyarun/grammatical-error-correction")
|
6 |
-
model =
|
7 |
|
8 |
-
inputs = tokenizer("grammar: " + sentence,
|
9 |
|
10 |
output = model.generate(inputs['input_ids'], num_beams=5, max_length=512, early_stopping=True)
|
11 |
correction = tokenizer.batch_decode(output, skip_special_tokens=True)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
+
from optimum.onnxruntime import ORTModelForSeq2SeqLM
|
4 |
+
|
5 |
|
6 |
def check_grammar(sentence):
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("leslyarun/grammatical-error-correction-quantized")
|
8 |
+
model = ORTModelForSeq2SeqLM.from_pretrained("leslyarun/grammatical-error-correction-quantized")
|
9 |
|
10 |
+
inputs = tokenizer("grammar: " + sentence, return_tensors='pt')
|
11 |
|
12 |
output = model.generate(inputs['input_ids'], num_beams=5, max_length=512, early_stopping=True)
|
13 |
correction = tokenizer.batch_decode(output, skip_special_tokens=True)
|