AItool commited on
Commit
b9591bd
·
verified ·
1 Parent(s): a5d507b

changing model

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -3,20 +3,20 @@
3
  import gradio as gr
4
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
5
 
6
- model_id = "google/flan-t5-base" # ~250MB, loads fast
7
 
8
- # Load tokenizer and model correctly for FLAN-T5
9
  tokenizer = AutoTokenizer.from_pretrained(model_id)
10
  model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
11
 
12
- # Create pipeline for text2text generation
13
  polisher = pipeline("text2text-generation",
14
  model=model,
15
  tokenizer=tokenizer)
16
 
17
  def oxford_polish_strict(sentence: str) -> str:
18
  prompt = (
19
- "Rewrite this sentence in 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,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 FLAN-T5."
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()