yf commited on
Commit
f293f13
·
1 Parent(s): 487dc54

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -0
README.md CHANGED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - fill-mask
4
+ - text2text-generation
5
+ - fill-mask
6
+ - Chinese
7
+ - cpt
8
+ - seq2seq
9
+
10
+ language: zh
11
+ ---
12
+
13
+ # Chinese CPT-Base
14
+
15
+ ## Model description
16
+
17
+ This is an implementation of CPT-Base. To use CPT, please import the file `modeling_cpt.py` (**Download** [Here](https://github.com/fastnlp/CPT/blob/master/finetune/modeling_cpt.py)) that define the architecture of CPT into your project.
18
+
19
+ [**CPT: A Pre-Trained Unbalanced Transformer for Both Chinese Language Understanding and Generation**](https://arxiv.org/pdf/2109.05729.pdf)
20
+
21
+ Yunfan Shao, Zhichao Geng, Yitao Liu, Junqi Dai, Fei Yang, Li Zhe, Hujun Bao, Xipeng Qiu
22
+
23
+ **Github Link:** https://github.com/fastnlp/CPT
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ >>> from modeling_cpt import CPTForConditionalGeneration
29
+ >>> from transformers import BertTokenizer
30
+ >>> tokenizer = BertTokenizer.from_pretrained("fnlp/cpt-base")
31
+ >>> model = CPTForConditionalGeneration.from_pretrained("fnlp/cpt-base")
32
+ >>> inputs = tokenizer.encode("北京是[MASK]的首都", return_tensors='pt')
33
+ >>> pred_ids = model.generate(input_ids, num_beams=4, max_length=20)
34
+ >>> print(tokenizer.convert_ids_to_tokens(pred_ids[i]))
35
+ ['[SEP]', '[CLS]', '北', '京', '是', '中', '国', '的', '首', '都', '[SEP]']
36
+ ```
37
+
38
+ **Note: Please use BertTokenizer for the model vocabulary. DO NOT use original BartTokenizer.**
39
+
40
+ ## Citation
41
+
42
+ ```bibtex
43
+ @article{shao2021cpt,
44
+ title={CPT: A Pre-Trained Unbalanced Transformer for Both Chinese Language Understanding and Generation},
45
+ author={Yunfan Shao and Zhichao Geng and Yitao Liu and Junqi Dai and Fei Yang and Li Zhe and Hujun Bao and Xipeng Qiu},
46
+ journal={arXiv preprint arXiv:2109.05729},
47
+ year={2021}
48
+ }
49
+ ```