Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,109 @@
|
|
1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
|
5 |
+
inference:
|
6 |
+
parameters:
|
7 |
+
temperature: 0.7
|
8 |
+
top_p: 0.6
|
9 |
+
repetition_penalty: 1.1
|
10 |
+
max_new_tokens: 128
|
11 |
+
num_return_sequences: 3
|
12 |
+
do_sample: true
|
13 |
+
|
14 |
license: apache-2.0
|
15 |
+
tags:
|
16 |
+
- generate
|
17 |
+
- gpt2
|
18 |
+
|
19 |
+
widget:
|
20 |
+
- 北京是中国的
|
21 |
+
- 西湖的景色
|
22 |
+
|
23 |
---
|
24 |
+
|
25 |
+
# Wenzhong2.0-GPT2-110M-BertTokenizer-chinese
|
26 |
+
|
27 |
+
- Github: [Fengshenbang-LM](https://github.com/IDEA-CCNL/Fengshenbang-LM)
|
28 |
+
- Docs: [Fengshenbang-Docs](https://fengshenbang-doc.readthedocs.io/)
|
29 |
+
|
30 |
+
## 简介 Brief Introduction
|
31 |
+
|
32 |
+
善于处理NLG任务,中文版的GPT2-Small。基于BertTokenizer,实现字级别token,更便于受控文本生成。
|
33 |
+
|
34 |
+
Focused on handling NLG tasks, Chinese GPT2-Small.
|
35 |
+
|
36 |
+
## 模型分类 Model Taxonomy
|
37 |
+
|
38 |
+
| 需求 Demand | 任务 Task | 系列 Series | 模型 Model | 参数 Parameter | 额外 Extra |
|
39 |
+
| :----: | :----: | :----: | :----: | :----: | :----: |
|
40 |
+
| 通用 General | 自然语言生成 NLG | 闻仲 Wenzhong | GPT2 | 110M | 中文 Chinese |
|
41 |
+
|
42 |
+
## 模型信息 Model Information
|
43 |
+
|
44 |
+
类似于Wenzhong2.0-GPT2-3.5B-chinese,我们实现了一个small版本的12层的Wenzhong2.0-GPT2-110M-BertTokenizer-chinese,并在悟道(300G版本)上面进行预训练。本次开源别于之前开源的闻仲-GPT2系列,主要在于将BPE的分词换成了BertTokenzier的字级别分词。
|
45 |
+
|
46 |
+
Similar to Wenzhong2.0-GPT2-3.5B-chinese, we implement a small size Wenzhong2.0-GPT2-110M-BertTokenizer-chinese with 12 layers, which is pre-trained on Wudao Corpus (300G version).This open source version is different from the previous open source Wenzhong-GPT2 series, mainly because the word segmentation of BPE is replaced by the word level word segmentation of BertTokenzier.
|
47 |
+
|
48 |
+
## 使用 Usage
|
49 |
+
|
50 |
+
### 加载模型 Loading Models
|
51 |
+
|
52 |
+
```python
|
53 |
+
from transformers import BertTokenizer,GPT2LMHeadModel
|
54 |
+
hf_model_path = 'IDEA-CCNL/Wenzhong-GPT2-110M'
|
55 |
+
tokenizer = BertTokenizer.from_pretrained(hf_model_path)
|
56 |
+
model = GPT2LMHeadModel.from_pretrained(hf_model_path)
|
57 |
+
```
|
58 |
+
|
59 |
+
### 使用示例 Usage Examples
|
60 |
+
|
61 |
+
```python
|
62 |
+
def generate_word_level(input_text,n_return=5,max_length=128,top_p=0.9):
|
63 |
+
inputs = tokenizer(input_text,return_tensors='pt',add_special_tokens=False).to(model.device)
|
64 |
+
gen = model.generate(
|
65 |
+
inputs=inputs['input_ids'],
|
66 |
+
max_length=max_length,
|
67 |
+
do_sample=True,
|
68 |
+
top_p=top_p,
|
69 |
+
eos_token_id=21133,
|
70 |
+
pad_token_id=0,
|
71 |
+
num_return_sequences=n_return)
|
72 |
+
|
73 |
+
sentences = tokenizer.batch_decode(gen)
|
74 |
+
for idx,sentence in enumerate(sentences):
|
75 |
+
print(f'sentence {idx}: {sentence}')
|
76 |
+
print('*'*20)
|
77 |
+
return gen
|
78 |
+
|
79 |
+
outputs = generate_word_level('西湖的景色',n_return=5,max_length=128)
|
80 |
+
```
|
81 |
+
|
82 |
+
## 引用 Citation
|
83 |
+
|
84 |
+
如果您在您的工作中使用了我们的模型,可以引用我们的[论文](https://arxiv.org/abs/2209.02970):
|
85 |
+
|
86 |
+
If you are using the resource for your work, please cite the our [paper](https://arxiv.org/abs/2209.02970):
|
87 |
+
|
88 |
+
```text
|
89 |
+
@article{fengshenbang,
|
90 |
+
author = {Junjie Wang and Yuxiang Zhang and Lin Zhang and Ping Yang and Xinyu Gao and Ziwei Wu and Xiaoqun Dong and Junqing He and Jianheng Zhuo and Qi Yang and Yongfeng Huang and Xiayu Li and Yanghan Wu and Junyu Lu and Xinyu Zhu and Weifeng Chen and Ting Han and Kunhao Pan and Rui Wang and Hao Wang and Xiaojun Wu and Zhongshen Zeng and Chongpei Chen and Ruyi Gan and Jiaxing Zhang},
|
91 |
+
title = {Fengshenbang 1.0: Being the Foundation of Chinese Cognitive Intelligence},
|
92 |
+
journal = {CoRR},
|
93 |
+
volume = {abs/2209.02970},
|
94 |
+
year = {2022}
|
95 |
+
}
|
96 |
+
```
|
97 |
+
|
98 |
+
也可以引用我们的[网站](https://github.com/IDEA-CCNL/Fengshenbang-LM/):
|
99 |
+
|
100 |
+
You can also cite our [website](https://github.com/IDEA-CCNL/Fengshenbang-LM/):
|
101 |
+
|
102 |
+
```text
|
103 |
+
@misc{Fengshenbang-LM,
|
104 |
+
title={Fengshenbang-LM},
|
105 |
+
author={IDEA-CCNL},
|
106 |
+
year={2021},
|
107 |
+
howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}},
|
108 |
+
}
|
109 |
+
```
|