|
--- |
|
language: zh |
|
tags: |
|
- summarization |
|
inference: False |
|
--- |
|
|
|
|
|
Randeng_Pegasus_523M_Summary model (Chinese),which codes has merged into [Fengshenbang-LM](https://github.com/IDEA-CCNL/Fengshenbang-LM) |
|
|
|
The 523M million parameter randeng_pegasus_large model, training with sampled gap sentence ratios on 180G Chinese data, and stochastically sample important sentences. The pretraining task just same as the paper [PEGASUS: Pre-training with Extracted Gap-sentences for |
|
Abstractive Summarization](https://arxiv.org/pdf/1912.08777.pdf) mentioned. |
|
|
|
Different from the English version of pegasus, considering that the Chinese sentence piece is unstable, we use jieba and Bertokenizer as the tokenizer in chinese pegasus model. |
|
|
|
This model we provided in hugging face hub is only the pretrained model, has not finetuned with downstream data yet. |
|
|
|
We also pretained a base model, available with [Randeng_Pegasus_238M_Summary](https://huggingface.co/IDEA-CCNL/Randeng_Pegasus_238M_Summary) |
|
|
|
|
|
Task: Summarization |
|
|
|
## Usage |
|
```python |
|
from transformers import PegasusForConditionalGeneration |
|
# Need to download tokenizers_pegasus.py and other Python script from Fengshenbang-LM github repo in advance, |
|
# or you can mv download in tokenizers_pegasus.py and data_utils.py in https://huggingface.co/IDEA-CCNL/Randeng_Pegasus_523M_Summary/tree/main |
|
# Strongly recommend you git clone the Fengshenbang-LM repo: |
|
# 1. git clone https://github.com/IDEA-CCNL/Fengshenbang-LM |
|
# 2. cd Fengshenbang-LM/fengshen/examples/pegasus/ |
|
# and then you will see the tokenizers_pegasus.py and data_utils.py which are needed by pegasus model |
|
from tokenizers_pegasus import PegasusTokenizer |
|
|
|
model = PegasusForConditionalGeneration.from_pretrained("IDEA-CCNL/Randeng_Pegasus_523M_Summary") |
|
# You can find the vocab.txt in hugging face cache file. |
|
# Or, you can download the vocab.txt manually |
|
tokenizer = PegasusTokenizer.from_pretrained("/path/to/vocab.txt") |
|
|
|
text = "在北京冬奥会自由式滑雪女子坡面障碍技巧决赛中,中国选手谷爱凌夺得银牌。祝贺谷爱凌!今天上午,自由式滑雪女子坡面障碍技巧决赛举行。决赛分三轮进行,取选手最佳成绩排名决出奖牌。第一跳,中国选手谷爱凌获得69.90分。在12位选手中排名第三。完成动作后,谷爱凌又扮了个鬼脸,甚是可爱。第二轮中,谷爱凌在道具区第三个障碍处失误,落地时摔倒。获得16.98分。网友:摔倒了也没关系,继续加油!在第二跳失误摔倒的情况下,谷爱凌顶住压力,第三跳稳稳发挥,流畅落地!获得86.23分!此轮比赛,共12位选手参赛,谷爱凌第10位出场。网友:看比赛时我比谷爱凌紧张,加油!" |
|
inputs = tokenizer(text, max_length=1024, return_tensors="pt") |
|
|
|
# Generate Summary |
|
summary_ids = model.generate(inputs["input_ids"]) |
|
tokenizer.batch_decode(summary_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0] |
|
``` |
|
|
|
## Citation |
|
If you find the resource is useful, please cite the following website in your paper. |
|
``` |
|
@misc{Fengshenbang-LM, |
|
title={Fengshenbang-LM}, |
|
author={IDEA-CCNL}, |
|
year={2022}, |
|
howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}}, |
|
} |
|
``` |