File size: 924 Bytes
88b0b43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd1c3d4
88b0b43
dd1c3d4
88b0b43
 
dd1c3d4
88b0b43
 
 
 
 
 
 
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
---
language:
- th
pipeline_tag: summarization
tags:
- summarization
- pegasus_x
---
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.

# Library 

```
pip install transformers
```

# Example
```python
from transformers import PegasusXForConditionalGeneration, AutoTokenizer

model = PegasusXForConditionalGeneration.from_pretrained("satjawat/pegasus-x-thai-sum")
tokenizer = AutoTokenizer.from_pretrained("satjawat/pegasus-x-thai-sum")

new_input_string = "ข้อความ"
new_input_ids = tokenizer(new_input_string.lower(), return_tensors="pt").input_ids
summary_ids = model.generate(new_input_ids, max_length=50, num_beams=6, length_penalty=2.0, early_stopping=True)
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)

print("Input:", new_input_string)
print("Generated Summary:", summary)
```