File size: 1,051 Bytes
00ef7ec 24a5736 00ef7ec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
---
datasets:
- grammarly/coedit
- Owishiboo/grammar-correction
language:
- en
base_model:
- google-t5/t5-base
pipeline_tag: text-generation
---
# English Grammar Correction model
# Quick Start (Python)
### Installation
```bash
pip install transformers torch
```
### Basic Usage
```python
from transformers import T5Tokenizer, T5ForConditionalGeneration
import torch
# Load model and tokenizer
model_name = "yoon-eunbin/t5-gec-model"
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)
# Set device
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = model.to(device)
# Prepare input
text = "He has left the room when I came into the room."
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=64).to(device)
# Generate correction
outputs = model.generate(**inputs, max_length=64)
# Decode output
corrected_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"Original: {text}")
print(f"Corrected: {corrected_text}") |