🚀 中文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}
}