RichardErkhov
commited on
Commit
•
8783d70
1
Parent(s):
35d5fcd
uploaded readme
Browse files
README.md
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
Wenzhong2.0-GPT2-110M-BertTokenizer-chinese - bnb 8bits
|
11 |
+
- Model creator: https://huggingface.co/IDEA-CCNL/
|
12 |
+
- Original model: https://huggingface.co/IDEA-CCNL/Wenzhong2.0-GPT2-110M-BertTokenizer-chinese/
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
Original model description:
|
18 |
+
---
|
19 |
+
language:
|
20 |
+
- zh
|
21 |
+
|
22 |
+
inference:
|
23 |
+
parameters:
|
24 |
+
top_p: 0.9
|
25 |
+
max_new_tokens: 128
|
26 |
+
num_return_sequences: 3
|
27 |
+
do_sample: true
|
28 |
+
repetition_penalty: 1.1
|
29 |
+
|
30 |
+
license: apache-2.0
|
31 |
+
tags:
|
32 |
+
- generate
|
33 |
+
- gpt2
|
34 |
+
|
35 |
+
widget:
|
36 |
+
- 北京是中国的
|
37 |
+
- 西湖的景色
|
38 |
+
|
39 |
+
---
|
40 |
+
|
41 |
+
# Wenzhong2.0-GPT2-110M-BertTokenizer-chinese
|
42 |
+
|
43 |
+
- Main Page:[Fengshenbang](https://fengshenbang-lm.com/)
|
44 |
+
- Github: [Fengshenbang-LM](https://github.com/IDEA-CCNL/Fengshenbang-LM)
|
45 |
+
|
46 |
+
## 简介 Brief Introduction
|
47 |
+
|
48 |
+
善于处理NLG任务,中文版的GPT2-Small。基于BertTokenizer,实现字级别token,更便于受控文本生成。
|
49 |
+
|
50 |
+
Focused on handling NLG tasks, Chinese GPT2-Small.
|
51 |
+
|
52 |
+
## 模型分类 Model Taxonomy
|
53 |
+
|
54 |
+
| 需求 Demand | 任务 Task | 系列 Series | 模型 Model | 参数 Parameter | 额外 Extra |
|
55 |
+
| :----: | :----: | :----: | :----: | :----: | :----: |
|
56 |
+
| 通用 General | 自然语言生成 NLG | 闻仲 Wenzhong | GPT2 | 110M | 中文 Chinese |
|
57 |
+
|
58 |
+
## 模型信息 Model Information
|
59 |
+
|
60 |
+
类似于Wenzhong2.0-GPT2-3.5B-chinese,我们实现了一个small版本的12层的Wenzhong2.0-GPT2-110M-BertTokenizer-chinese,并在悟道(300G版本)上面进行预训练。本次开源别于之前开源的闻仲-GPT2系列,主要在于将BPE的分词换成了BertTokenzier的字级别分词。
|
61 |
+
|
62 |
+
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.
|
63 |
+
|
64 |
+
## 使用 Usage
|
65 |
+
|
66 |
+
### 加载模型 Loading Models
|
67 |
+
|
68 |
+
```python
|
69 |
+
from transformers import BertTokenizer,GPT2LMHeadModel
|
70 |
+
hf_model_path = 'IDEA-CCNL/Wenzhong2.0-GPT2-110M-BertTokenizer-chinese'
|
71 |
+
tokenizer = BertTokenizer.from_pretrained(hf_model_path)
|
72 |
+
model = GPT2LMHeadModel.from_pretrained(hf_model_path)
|
73 |
+
```
|
74 |
+
|
75 |
+
### 使用示例 Usage Examples
|
76 |
+
|
77 |
+
这里需要提一点,GPT在训练的时候是没有添加special_tokens的,BertTokenizer会默认补充special_tokens,所以在tokenzier的时候需要将add_special_tokens设置为false,这样生产效果会更好。
|
78 |
+
|
79 |
+
```python
|
80 |
+
def generate_word_level(input_text,n_return=5,max_length=128,top_p=0.9):
|
81 |
+
inputs = tokenizer(input_text,return_tensors='pt',add_special_tokens=False).to(model.device)
|
82 |
+
gen = model.generate(
|
83 |
+
inputs=inputs['input_ids'],
|
84 |
+
max_length=max_length,
|
85 |
+
do_sample=True,
|
86 |
+
top_p=top_p,
|
87 |
+
eos_token_id=21133,
|
88 |
+
pad_token_id=0,
|
89 |
+
num_return_sequences=n_return)
|
90 |
+
|
91 |
+
sentences = tokenizer.batch_decode(gen)
|
92 |
+
for idx,sentence in enumerate(sentences):
|
93 |
+
print(f'sentence {idx}: {sentence}')
|
94 |
+
print('*'*20)
|
95 |
+
return gen
|
96 |
+
|
97 |
+
outputs = generate_word_level('西湖的景色',n_return=5,max_length=128)
|
98 |
+
```
|
99 |
+
|
100 |
+
## 引用 Citation
|
101 |
+
|
102 |
+
如果您在您的工作中使用了我们的模型,可以引用我们的[论文](https://arxiv.org/abs/2209.02970):
|
103 |
+
|
104 |
+
If you are using the resource for your work, please cite the our [paper](https://arxiv.org/abs/2209.02970):
|
105 |
+
|
106 |
+
```text
|
107 |
+
@article{fengshenbang,
|
108 |
+
author = {Jiaxing Zhang and Ruyi Gan and 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},
|
109 |
+
title = {Fengshenbang 1.0: Being the Foundation of Chinese Cognitive Intelligence},
|
110 |
+
journal = {CoRR},
|
111 |
+
volume = {abs/2209.02970},
|
112 |
+
year = {2022}
|
113 |
+
}
|
114 |
+
```
|
115 |
+
|
116 |
+
也可以引用我们的[网站](https://github.com/IDEA-CCNL/Fengshenbang-LM/):
|
117 |
+
|
118 |
+
You can also cite our [website](https://github.com/IDEA-CCNL/Fengshenbang-LM/):
|
119 |
+
|
120 |
+
```text
|
121 |
+
@misc{Fengshenbang-LM,
|
122 |
+
title={Fengshenbang-LM},
|
123 |
+
author={IDEA-CCNL},
|
124 |
+
year={2021},
|
125 |
+
howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}},
|
126 |
+
}
|
127 |
+
```
|
128 |
+
|
129 |
+
|