add readme
Browse files
README.md
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- th
|
4 |
+
pipeline_tag: summarization
|
5 |
+
tags:
|
6 |
+
- summarization
|
7 |
+
- pegasus_x
|
8 |
+
---
|
9 |
+
This repository features a fine-tuned Pegasus X model designed for summarizing Thai text. The architecture of the model is based on the Pegasus X model.
|
10 |
+
|
11 |
+
# Library
|
12 |
+
|
13 |
+
```
|
14 |
+
pip install sentencepiece
|
15 |
+
pip install transformers
|
16 |
+
```
|
17 |
+
|
18 |
+
# Example
|
19 |
+
```python
|
20 |
+
from transformers import PegasusForConditionalGeneration, AutoTokenizer
|
21 |
+
|
22 |
+
model = PegasusForConditionalGeneration.from_pretrained("satjawat/pegasus-x-thai-sum")
|
23 |
+
tokenizer = AutoTokenizer.from_pretrained("satjawat/pegasus-x-thai-sum")
|
24 |
+
|
25 |
+
new_input_string = "ข้อความทดสอบ"
|
26 |
+
new_input_ids = tokenizer(new_input_string.lower(), return_tensors="pt").input_ids
|
27 |
+
summary_ids = model.generate(new_input_ids, max_length=50, num_beams=6, length_penalty=2.0, early_stopping=True)
|
28 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
29 |
+
|
30 |
+
print("Input:", new_input_string)
|
31 |
+
print("Generated Summary:", summary)
|
32 |
+
```
|