Add example Usage
#1
by
Nekochu
- opened
README.md
CHANGED
|
@@ -5,9 +5,21 @@ tags: []
|
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
|
|
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
+
## Usage
|
| 9 |
+
```python
|
| 10 |
+
from transformers import AutoTokenizer, T5ForConditionalGeneration, BitsAndBytesConfig
|
| 11 |
+
import torch
|
| 12 |
+
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained("wisdominanutshell/coedit-xxl-8bit")
|
| 14 |
+
model = T5ForConditionalGeneration.from_pretrained("wisdominanutshell/coedit-xxl-8bit", quantization_config=BitsAndBytesConfig(load_in_8bit=True))
|
| 15 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 16 |
+
input_text = 'Fix grammatical errors in this sentence: When I graw up, I start to understand what he said is quite right.'
|
| 17 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
|
| 18 |
+
outputs = model.generate(input_ids, max_length=256)
|
| 19 |
+
edited_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 20 |
+
|
| 21 |
+
print(edited_text)
|
| 22 |
+
```
|
| 23 |
|
| 24 |
## Model Details
|
| 25 |
|