Update README.md
Browse files
README.md
CHANGED
|
@@ -12,6 +12,28 @@ model-index:
|
|
| 12 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 13 |
should probably proofread and complete it, then remove this comment. -->
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# correction
|
| 16 |
|
| 17 |
This model is a fine-tuned version of [paust/pko-t5-base](https://huggingface.co/paust/pko-t5-base) on the None dataset.
|
|
|
|
| 12 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 13 |
should probably proofread and complete it, then remove this comment. -->
|
| 14 |
|
| 15 |
+
# Basic Inference
|
| 16 |
+
```python
|
| 17 |
+
from transformers import T5TokenizerFast, T5ForConditionalGeneration
|
| 18 |
+
|
| 19 |
+
tokenizer = T5TokenizerFast.from_pretrained('ij5/whitespace-correction')
|
| 20 |
+
model = T5ForConditionalGeneration.from_pretrained('ij5/whitespace-correction')
|
| 21 |
+
|
| 22 |
+
def fix_whitespace(text):
|
| 23 |
+
inputs = f"띄어쓰기 교정: {text}"
|
| 24 |
+
tokenized = tokenizer(inputs, max_length=128, truncation=True, return_tensors='pt').to('cuda')
|
| 25 |
+
output_ids = model.generate(
|
| 26 |
+
input_ids=tokenized['input_ids'],
|
| 27 |
+
attention_mask=tokenized['attention_mask'],
|
| 28 |
+
max_length=128,
|
| 29 |
+
)
|
| 30 |
+
return tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
print(fix_whitespace("흔들 리는 가지 사이로 불쑥 바람의 형상 이 드 러나기라도 할 것처럼."))
|
| 34 |
+
# result: 흔들리는 가지 사이로 불쑥 바람의 형상이 드러나기라도 할 것처럼.
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
# correction
|
| 38 |
|
| 39 |
This model is a fine-tuned version of [paust/pko-t5-base](https://huggingface.co/paust/pko-t5-base) on the None dataset.
|