1
1
2
- # EssayKiller
2
+ # WriteGPT
3
3
4
4
![ image] ( https://img.shields.io/badge/License-Apache--2.0-green ) ![ image] ( https://img.shields.io/badge/License-MIT-orange ) ![ image] ( https://img.shields.io/badge/License-Anti--996-red ) ![ image] ( https://img.shields.io/badge/pypi-v0.0.1a4-yellowgreen ) ![ image] ( https://img.shields.io/badge/stars-%3C%205k-blue ) ![ image] ( https://img.shields.io/badge/issues-30%20open-brightgreen )
5
5
6
6
通用型议论文创作人工智能框架,仅限交流与科普。
7
7
8
8
9
9
## 项目简介
10
- EssayKiller是基于OCR 、NLP领域的最新模型所构建的生成式文本创作AI框架,目前第一版finetune模型针对高考作文(主要是议论文),可以有效生成符合人类认知的文章,多数文章经过测试可以达到正常高中生及格作文水平。
10
+ writeGPT是基于OCR 、NLP领域的最新模型所构建的生成式文本创作AI框架,目前第一版finetune模型针对高考作文(主要是议论文),可以有效生成符合人类认知的文章,多数文章经过测试可以达到正常高中生及格作文水平。
11
11
12
12
| 项目作者 | 主页1 | 主页2 |
13
13
| ------------- | :------:| :----:|
@@ -24,27 +24,27 @@ EssayKiller是基于OCR、NLP领域的最新模型所构建的生成式文本创
24
24
- [x] 基于EAST、CRNN、Bert和GPT-2语言模型的高考作文生成AI
25
25
- [x] 支持bert tokenizer,当前版本基于clue chinese vocab
26
26
- [x] 17亿参数多模块异构深度神经网络,超2亿条预训练数据
27
- - [x] 线上点击即用的文本生成效果demo:[ 17亿参数作文杀手] ( https://colab.research.google.com/github/EssayKillerBrain/EssayKiller_V2 /blob/master/colab_online.ipynb )
27
+ - [x] 线上点击即用的文本生成效果demo:[ 17亿参数作文杀手] ( https://colab.research.google.com/github/EssayKillerBrain/writeGPT /blob/master/colab_online.ipynb )
28
28
- [x] 端到端生成,从试卷识别到答题卡输出一条龙服务
29
29
30
30
31
31
32
32
### Colab线上作文生成功能
33
33
国内没有足够显存的免费GPU平台,所以配合Google Drive将训练好的AI核心功能Language Network写作模块迁移到Colab。
34
34
35
- 当前线上仅开放文本生成功能,输入对应句子,AI返回生成文章。同一个句子可以输入多次,每一次输出都不同。也可以选择同时生成多篇文章。具体见:[ 17亿参数作文杀手] ( https://colab.research.google.com/github/EssayKillerBrain/EssayKiller_V2 /blob/master/colab_online.ipynb )
35
+ 当前线上仅开放文本生成功能,输入对应句子,AI返回生成文章。同一个句子可以输入多次,每一次输出都不同。也可以选择同时生成多篇文章。具体见:[ 17亿参数作文杀手] ( https://colab.research.google.com/github/EssayKillerBrain/writeGPT /blob/master/colab_online.ipynb )
36
36
37
37
* 第一步:安装环境
38
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-15-22-13.png )
38
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-15-22-13.png )
39
39
40
40
* 第二部:加载模型
41
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-15-27-38.png )
41
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-15-27-38.png )
42
42
43
43
* 第三步:文章生成
44
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-15-27-14.png )
44
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-15-27-14.png )
45
45
46
46
* 写作效果
47
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-15-23-27.png )
47
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-15-23-27.png )
48
48
49
49
50
50
## 本地环境
@@ -75,7 +75,7 @@ EssayKiller是基于OCR、NLP领域的最新模型所构建的生成式文本创
75
75
76
76
## 模型结构
77
77
整个框架分为EAST、CRNN、Bert、GPT-2、DNN 5个模块,每个模块的网络单独训练,参数相互独立。infer过程使用pipeline串联,通过外接装置直接输出到答题卡。
78
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-15-35-00.png )
78
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-15-35-00.png )
79
79
80
80
81
81
### 1. 输入
@@ -86,7 +86,7 @@ EssayKiller是基于OCR、NLP领域的最新模型所构建的生成式文本创
86
86
### 2. 识别网络
87
87
#### 2.1 EAST文本检测
88
88
OpenCV 的EAST文本检测器是一个深度学习模型,它能够在 720p 的图像上以13帧/秒的速度实时检测任意方向的文本,并可以获得很好的文本检测精度。
89
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-15-45-54.png )
89
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-15-45-54.png )
90
90
91
91
<br >
92
92
@@ -114,7 +114,7 @@ python multigpu_train.py --gpu_list=0 --input_size=512 --batch_size_per_gpu=14 -
114
114
<br >
115
115
116
116
* 检测结果*
117
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-16-25-01.png )
117
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-16-25-01.png )
118
118
119
119
除了EAST,也可以把识别网络替换为传统的CTPN等模型,github上有已经成熟的项目:https://github.com/Walleclipse/ChineseAddress_OCR
120
120
@@ -162,7 +162,7 @@ Epoch 8/100
162
162
BERT的全称是Bidirectional Encoder Representation from Transformers,即双向Transformer的Encoder。模型的主要创新点在pre-train方法上,用了Masked LM和Next Sentence Prediction两种方法分别捕捉词语和句子级别的representation。
163
163
164
164
模型的构成元素Transformer可以参考Google的 [ Attention is all you need] ( https://arxiv.org/abs/1706.03762 ) ,BERT模型的结构如下图最左:
165
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-16-44-54.png )
165
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-16-44-54.png )
166
166
167
167
对比OpenAI GPT(Generative pre-trained transformer),BERT是双向的Transformer block连接;就像单向RNN和双向RNN的区别,直觉上来讲效果会好一些。
168
168
<br >
@@ -203,12 +203,12 @@ python run.py --model bert
203
203
```
204
204
<br >
205
205
206
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-16-40-19.png )
206
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-16-40-19.png )
207
207
208
208
测试时,需要用正则表达式过滤考试专用词,包括“阅读下面的材料,根据要求写作”,“要求:xxx”,“请完成/请结合/请综合xx”。
209
209
210
210
比如
211
- > ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-17-17-30.png )
211
+ > ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-17-17-30.png )
212
212
213
213
214
214
人们用眼睛看他人、看世界,却无法直接看到完整的自己。所以,在人生的旅程中,我们需要寻找各种“镜子”、不断绘制“自画像”来审视自我,尝试回答“我是怎样的人”“我想过怎样的生活”“我能做些什么”“如何生活得更有意义”等重要的问题。
@@ -227,7 +227,7 @@ python run.py --model bert
227
227
** 预训练**
228
228
参考 [ GPT2-ML] ( https://github.com/imcaspar/gpt2-ml/ ) 预训练模型,使用 [ Quadro RTX 8000] ( https://www.nvidia.com/en-us/design-visualization/quadro/rtx-8000/ ) 训练 28w 步
229
229
230
- > ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/2233.PNG )
230
+ > ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/2233.PNG )
231
231
232
232
233
233
<br >
@@ -252,11 +252,11 @@ CUDA_VISIBLE_DEVICES=0 python train/train_wc.py --input_file=/data/EssayKiller/
252
252
### 3.判分网络
253
253
254
254
#### 3.1 DNN判分模型
255
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-18-59-12.png )
255
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-18-59-12.png )
256
256
257
257
这部分直接调用百度API。有现成的模型就不重复造轮子了,具体实现方式百度没有开源,这里简单描述一下语言模型的概念:
258
258
语言模型是通过计算给定词组成的句子的概率,从而判断所组成的句子是否符合客观语言表达习惯。通常用于机器翻译、拼写纠错、语音识别、问答系统、词性标注、句法分析和信息检索等。
259
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-18-59-57.png )
259
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-18-59-57.png )
260
260
261
261
这里使用通顺度打分作为判断依据。
262
262
@@ -273,20 +273,20 @@ CUDA_VISIBLE_DEVICES=0 python train/train_wc.py --input_file=/data/EssayKiller/
273
273
4 . 字数不能过长或过短
274
274
275
275
由于模型输出的文章不保证换行和分段,通过统计高考作文的常见段数、每段句数,编写脚本对输出进行划分。大多数情况下分段排版的结果都比较合理。
276
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-19-04-24.png )
276
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-19-04-24.png )
277
277
278
278
<br >
279
279
280
280
## 输出
281
281
** 答题卡**
282
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-19-07-53.png )
282
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-19-07-53.png )
283
283
284
284
** 外接装置**
285
285
286
286
基于aedraw,一款开源的CNC(Computer Numerical Control数控机床)画图机器人,具有绘制图案、写字等功能,它也可以升级为激光雕刻等用途。
287
287
详细教程见 http://aelab.net/ ,不仅能自己制作一台写字绘画机器人,而且能够掌握其工作原理拓展更多的应用。
288
288
289
- ![ ] ( https://github.com/EssayKillerBrain/EssayKiller_V2 /blob/master/References/attachments/Clipboard_2020-09-29-19-12-07.png )
289
+ ![ ] ( https://github.com/EssayKillerBrain/writeGPT /blob/master/References/attachments/Clipboard_2020-09-29-19-12-07.png )
290
290
291
291
原版的输出临摹装置存在速度慢和格式不准的问题,通过改装和修改源代码得以优化
292
292
@@ -344,7 +344,7 @@ CUDA_VISIBLE_DEVICES=0 python train/train_wc.py --input_file=/data/EssayKiller/
344
344
year = {2020},
345
345
publisher = {GitHub},
346
346
journal = {GitHub repository},
347
- howpublished = {\url{https://github.com/EssayKillerBrain/EssayKiller }},
347
+ howpublished = {\url{https://github.com/EssayKillerBrain/writeGPT }},
348
348
}
349
349
```
350
350
@@ -372,7 +372,7 @@ CUDA_VISIBLE_DEVICES=0 python train/train_wc.py --input_file=/data/EssayKiller/
372
372
[ 18] https://github.com/YCG09/chinese_ocr
373
373
[ 19] https://github.com/xiaomaxiao/keras_ocr
374
374
[ 20] https://github.com/nghuyong/ERNIE-Pytorch
375
- [ 21] https://zhuanlan.zhihu.com/p/43534801
375
+ [ 21] https://zhuanlan.zhihu.com/p/43534801
376
376
[ 22] https://blog.csdn.net/xuxunjie147/article/details/87178774/
377
377
[ 23] https://github.com/JiangYanting/Pre-modern_Chinese_corpus_dataset
378
378
[ 24] https://github.com/brightmart/nlp_chinese_corpus
0 commit comments