File size: 1,266 Bytes
1ce9016 |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
---
language: ko
tags:
- bart
license: MIT
---
# Korean News Summarization Model
## How to use
```python
from transformers import PreTrainedTokenizerFast
from transformers import BartForConditionalGeneration
tokenizer = PreTrainedTokenizerFast(
'gogamza/kobart-summarization',
bos_token='<s>', eos_token='</s>', unk_token='<unk>', pad_token='<pad>', mask_token='<mask>')
model = BartForConditionalGeneration.from_pretrained('gogamza/kobart-summarization')
text = "과거를 떠올려보자. 방송을 보던 우리의 모습을..."
raw_input_ids = tokenizer.encode(text)
input_ids = [tokenizer.bos_token_id] + \
raw_input_ids + [tokenizer.eos_token_id]
summary_ids = model.generate(torch.tensor([input_ids]),
max_length=150,
early_stopping=False,
num_beams=5,
repetition_penalty=1.0,
eos_token_id=tokenizer.eos_token_id)
summ_text = tokenizer.batch_decode(summary_ids.tolist(), skip_special_tokens=True)[0]
```
## Demo
- <a href="http://52.231.69.211:8081/" target="_blank">요약 데모</a>
<table><tr><td>
<center><img src="summ.png" width="600"/></center>
</td></tr></table>
|