Spaces:
Running
Running
grammar model changed
Browse files- app/services/grammar.py +5 -5
- requirements.txt +1 -2
app/services/grammar.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
import
|
2 |
|
3 |
-
|
4 |
|
5 |
def correct_grammar(text: str) -> str:
|
6 |
-
|
7 |
-
|
8 |
-
return
|
|
|
1 |
+
from transformers import pipeline
|
2 |
|
3 |
+
grammar_corrector = pipeline("text2text-generation", model="pszemraj/flan-t5-large-grammar-synthesis")
|
4 |
|
5 |
def correct_grammar(text: str) -> str:
|
6 |
+
prompt = "grammar: " + text
|
7 |
+
result = grammar_corrector(prompt, max_length=min(len(prompt.split()) + 50, 128), do_sample=False)
|
8 |
+
return result[0]["generated_text"]
|
requirements.txt
CHANGED
@@ -4,5 +4,4 @@ transformers
|
|
4 |
torch
|
5 |
pydantic
|
6 |
protobuf
|
7 |
-
huggingface-hub
|
8 |
-
language_tool_python
|
|
|
4 |
torch
|
5 |
pydantic
|
6 |
protobuf
|
7 |
+
huggingface-hub
|
|