File size: 795 Bytes
e6b6507 b9f9195 e6b6507 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
```python
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
GED_TOKENIZER = AutoTokenizer.from_pretrained("zuu/grammar-error-correcter")
GED_MODEL = AutoModelForSeq2SeqLM.from_pretrained("zuu/grammar-error-correcter")
# Incorrect text
incorrect_text = 'young children should avoid exposure to contageous disease'
# Tokenize text
tokens= GED_TOKENIZER(
[incorrect_text],
padding=True,
return_tensors='pt'
)
corrections = GED_MODEL.generate(**tokens)
corrections = GED_TOKENIZER.batch_decode(
corrections,
skip_special_tokens=True
)
``` |