Spaces:
Sleeping
Sleeping
changing model
Browse files
app.py
CHANGED
|
@@ -3,20 +3,20 @@
|
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
| 5 |
|
| 6 |
-
model_id = "
|
| 7 |
|
| 8 |
-
# Load tokenizer and model
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
| 11 |
|
| 12 |
-
# Create pipeline
|
| 13 |
polisher = pipeline("text2text-generation",
|
| 14 |
model=model,
|
| 15 |
tokenizer=tokenizer)
|
| 16 |
|
| 17 |
def oxford_polish_strict(sentence: str) -> str:
|
| 18 |
prompt = (
|
| 19 |
-
"
|
| 20 |
"Ensure tense matches time expressions (e.g. 'tomorrow' → future, 'yesterday' → past), "
|
| 21 |
"use British spelling, apply the Oxford comma, and correct uncountable nouns naturally. "
|
| 22 |
"Sentence: " + sentence
|
|
@@ -30,7 +30,7 @@ demo = gr.Interface(
|
|
| 30 |
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence to correct..."),
|
| 31 |
outputs=gr.Textbox(label="Oxford-style Correction"),
|
| 32 |
title="Oxford Grammar Polisher",
|
| 33 |
-
description="Rewrite sentences in formal written English using Oxford grammar rules. Powered by
|
| 34 |
)
|
| 35 |
|
| 36 |
demo.launch()
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
| 5 |
|
| 6 |
+
model_id = "deep-learning-analytics/GrammarCorrector"
|
| 7 |
|
| 8 |
+
# Load tokenizer and model
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
| 11 |
|
| 12 |
+
# Create pipeline
|
| 13 |
polisher = pipeline("text2text-generation",
|
| 14 |
model=model,
|
| 15 |
tokenizer=tokenizer)
|
| 16 |
|
| 17 |
def oxford_polish_strict(sentence: str) -> str:
|
| 18 |
prompt = (
|
| 19 |
+
"Correct this sentence into formal written English, following the Oxford University Style Guide. "
|
| 20 |
"Ensure tense matches time expressions (e.g. 'tomorrow' → future, 'yesterday' → past), "
|
| 21 |
"use British spelling, apply the Oxford comma, and correct uncountable nouns naturally. "
|
| 22 |
"Sentence: " + sentence
|
|
|
|
| 30 |
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence to correct..."),
|
| 31 |
outputs=gr.Textbox(label="Oxford-style Correction"),
|
| 32 |
title="Oxford Grammar Polisher",
|
| 33 |
+
description="Rewrite sentences in formal written English using Oxford grammar rules. Powered by GrammarCorrector (T5-base)."
|
| 34 |
)
|
| 35 |
|
| 36 |
demo.launch()
|