Preechanon Chatthai
commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -24,11 +24,12 @@ This repository contains the finetuned mT5-base model for Thai sentence summariz
|
|
| 24 |
### Example
|
| 25 |
```python
|
| 26 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
|
| 27 |
|
| 28 |
tokenizer = AutoTokenizer.from_pretrained("preechanon/mt5-base-thaisum-text-summarization")
|
| 29 |
model = AutoModelForSeq2SeqLM.from_pretrained("preechanon/mt5-base-thaisum-text-summarization")
|
| 30 |
-
new_input_string = "
|
| 31 |
-
input_ =tokenizer(new_input_string, truncation=True, max_length=1024, return_tensors="pt")
|
| 32 |
with torch.no_grad():
|
| 33 |
preds = model.generate(
|
| 34 |
input_['input_ids'].to('cpu'),
|
|
@@ -38,6 +39,9 @@ with torch.no_grad():
|
|
| 38 |
remove_invalid_values=True,
|
| 39 |
max_length=140,
|
| 40 |
)
|
|
|
|
|
|
|
|
|
|
| 41 |
```
|
| 42 |
|
| 43 |
### Score
|
|
|
|
| 24 |
### Example
|
| 25 |
```python
|
| 26 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 27 |
+
import torch
|
| 28 |
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained("preechanon/mt5-base-thaisum-text-summarization")
|
| 30 |
model = AutoModelForSeq2SeqLM.from_pretrained("preechanon/mt5-base-thaisum-text-summarization")
|
| 31 |
+
new_input_string = "ข้อความที่ต้องการ"
|
| 32 |
+
input_ = tokenizer(new_input_string, truncation=True, max_length=1024, return_tensors="pt")
|
| 33 |
with torch.no_grad():
|
| 34 |
preds = model.generate(
|
| 35 |
input_['input_ids'].to('cpu'),
|
|
|
|
| 39 |
remove_invalid_values=True,
|
| 40 |
max_length=140,
|
| 41 |
)
|
| 42 |
+
|
| 43 |
+
summary = tokenizer.decode(preds[0], skip_special_tokens=True)
|
| 44 |
+
summary
|
| 45 |
```
|
| 46 |
|
| 47 |
### Score
|