🚀 中文BART-Large
中文BART-Large是一个用于文本生成任务的模型,它在中文文本处理方面具有出色的表现。该模型的更新版本在词汇表和位置嵌入等方面进行了改进,提升了模型的性能和适用性。
✨ 主要特性
模型更新
- 词汇表更新:2022年12月30日发布的更新版本中,用从训练数据构建的更大的51271大小的词汇表替换了旧的BERT词汇表。具体操作包括:添加了6800多个缺失的中文字符(大部分为繁体字);移除了冗余的标记(例如带有##前缀的中文字符标记);添加了一些英文标记以减少未登录词(OOV)。
- 位置嵌入扩展:将最大位置嵌入
max_position_embeddings
从512扩展到1024。
模型初始化与训练
- 新版本模型使用旧版本的检查点进行初始化,并进行词汇对齐。旧检查点中找到的标记嵌入被复制,其他新添加的参数随机初始化。
- 进一步对新的CPT和中文BART进行了50K步的训练,批次大小为2048,最大序列长度为1024,峰值学习率为2e - 5,热身比率为0.1。
性能对比
|
AFQMC |
IFLYTEK |
CSL - sum |
LCSTS |
AVG |
Previous |
|
|
|
|
|
bart - base |
73.0 |
60 |
62.1 |
37.8 |
58.23 |
cpt - base |
75.1 |
60.5 |
63.0 |
38.2 |
59.20 |
bart - large |
75.7 |
62.1 |
64.2 |
40.6 |
60.65 |
cpt - large |
75.9 |
61.8 |
63.7 |
42.0 |
60.85 |
Updataed |
|
|
|
|
|
bart - base |
73.03 |
61.25 |
61.51 |
38.78 |
58.64 |
cpt - base |
74.40 |
61.23 |
62.09 |
38.81 |
59.13 |
bart - large |
75.81 |
61.52 |
64.62 |
40.90 |
60.71 |
cpt - large |
75.97 |
61.63 |
63.83 |
42.08 |
60.88 |
结果显示,更新后的模型与之前的检查点相比保持了相当的性能。不过,仍有一些情况下更新后的模型略逊于之前的模型,原因如下:
- 额外的几步训练并未带来显著的性能提升。
- 一些下游任务不受新添加标记和更长编码序列的影响,但对微调超参数敏感。
📚 详细文档
模型描述
这是中文BART-Large的一个实现。相关论文为CPT: A Pre-Trained Unbalanced Transformer for Both Chinese Language Understanding and Generation,作者包括Yunfan Shao、Zhichao Geng、Yitao Liu、Junqi Dai、Fei Yang、Li Zhe、Hujun Bao、Xipeng Qiu。
Github链接:https://github.com/fastnlp/CPT
使用说明
>>> from transformers import BertTokenizer, BartForConditionalGeneration, Text2TextGenerationPipeline
>>> tokenizer = BertTokenizer.from_pretrained("fnlp/bart-large-chinese")
>>> model = BartForConditionalGeneration.from_pretrained("fnlp/bart-large-chinese")
>>> text2text_generator = Text2TextGenerationPipeline(model, tokenizer)
>>> text2text_generator("北京是[MASK]的首都", max_length=50, do_sample=False)
[{'generated_text': '北 京 是 中 华 人 民 共 和 国 的 首 都'}]
⚠️ 重要提示
请使用BertTokenizer
处理模型词汇表,请勿使用原始的BartTokenizer
。
要使用更新后的模型,请更新modeling_cpt.py
(新版本下载点击此处)和词汇表(刷新缓存)。
📄 许可证
引用信息
@article{shao2021cpt,
title={CPT: A Pre-Trained Unbalanced Transformer for Both Chinese Language Understanding and Generation},
author={Yunfan Shao and Zhichao Geng and Yitao Liu and Junqi Dai and Fei Yang and Li Zhe and Hujun Bao and Xipeng Qiu},
journal={arXiv preprint arXiv:2109.05729},
year={2021}
}