<jupyter_start><jupyter_text>[![GitHub stars](https://img.shields.io/github/stars/rdp-studio/EssayKiller_V2?style=social)](https://github.com/imcaspar/gpt2-ml)[![GitHub](https://img.shields.io/github/license/rdp-studio/EssayKiller_V2)](https://github.com/imcaspar/gpt2-ml)[![Twitter URL](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fimcaspar%2Fgpt2-ml)](https://twitter.com/intent/tweet?text=Wow:&url=https://github.com/imcaspar/gpt2-ml) 高考作文生成指南:* 点击代码框左上角的▶️，选择RUN ANYWAY* 等待对应代码文件、模型文件下载* 输入参数，代表长度* 输入作文题目（摘要模块没有部署，请自己提炼作文题中的主旨句）之后就会生成对应文章，效果如下:<jupyter_code>#@title #参数与开源框架预加载
!pip install pandas==0.24.2 &> tmp.log
!pip install regex==2019.4.14 &> tmp.log
!pip install h5py==2.10.0 &> tmp.log
!pip install numpy==1.18.4 &> tmp.log
!pip install tensorboard==1.15.0 &> tmp.log
!pip install tensorflow-gpu>=1.15.4 &> tmp.log
!pip install tensorflow-estimator==1.15.1 &> tmp.log
!pip install tqdm==4.31.1 &> tmp.log
!pip install requests==2.22.0 &> tmp.log
!pip install ujson==2.0.3 &> tmp.log
!echo '预加载模块结束，请继续点击下方的▶️'
#@title #Prerequisites
#@title #模型框架加载模块
%cd /home
!git clone -b master https://github.com/EssayKillerBrain/EssayKiller_V2.git 

#%tensorflow_version 1.5.2-GPU/TPU
!mkdir -p /home/EssayKiller_V2/LanguageNetwork/GPT2/finetune/trained_models

%cd /home/EssayKiller_V2/LanguageNetwork/GPT2/finetune/
#!perl /home/EssayKiller_V2/LanguageNetwork/GPT2/scripts/gdown.pl https://drive.google.com/open?id=1ujWYTOvRLGJX0raH-f-lPZa3-RN58ZQx trained_models/model.ckpt-220000.data-00000-of-00001
!perl /home/EssayKiller_V2/LanguageNetwork/GPT2/scripts/gdown.pl https://drive.google.com/open?id=1mT_qCQg4AWnAXTwKfsyyRWCRpgPrBJS3 trained_models/model.ckpt-280000.data-00000-of-00001
#!python3 scripts/down_gdrive_file.py -file_id='1ujWYTOvRLGJX0raH-f-lPZa3-RN58ZQx' -file_path='trained_models/model.ckpt-280000.data-00000-of-00001'　&> predict.log
!wget -q --show-progress https://github.com/EssayKillerBrain/EssayKiller/releases/download/v1.0/model.ckpt-280000.index -P /home/EssayKiller_V2/LanguageNetwork/GPT2/finetune/models/mega
!wget -q --show-progress https://github.com/EssayKillerBrain/EssayKiller/releases/download/v1.0/model.ckpt-280000.meta -P /home/EssayKiller_V2/LanguageNetwork/GPT2/finetune/models/mega

!echo '模型下载完成，Git项目已构建，请继续点击下方的▶️'
# If gdown.pl failed, please uncomment following code & exec<jupyter_output><empty_output><jupyter_text>模型参数设置:* 1.作文最小篇幅：生成对应字数的高考作文，可自己调节长度，最长为1024个汉字。一般来说越短的文章AI表现越好。* 2.生成作文篇数：默认会生成1篇议论文，生成时间取决于服务器状态一般不超过60秒。受限于线上GPU内存，篇数最多为100。<jupyter_code>#!cat /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/tpu/tpu_feed.py
#@title #文章生成模块
作文最小篇幅 = 1024 #@param {type:"number", min:800, max:1024, step:1}
生成作文篇数 = 1 #@param {type:"number", min:1, max:100, step:1}
%mv /home/EssayKiller_V2/LanguageNetwork/GPT2/finetune/models/mega/* /home/EssayKiller_V2/LanguageNetwork/GPT2/finetune/trained_models/
%cd /home/EssayKiller_V2/LanguageNetwork/GPT2/
!export TF_CPP_MIN_LOG_LEVEL=2
!echo '模型加载中，请稍后......'
!PYTHONPATH=$(pwd) python scripts/demo.py -ckpt_fn finetune/trained_models/model.ckpt-280000 -min_len $作文最小篇幅 -samples $生成作文篇数
!PYTHONPATH=$(pwd) python scripts/formatter.py -org_text result.txt<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.161350263239393, 'fraction_numerical': 0.05977082688138743, 'mean_word_length': 6.476851851851852, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '275011', 'license': 'MIT', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1626, 'n_words': 147, 'path': 'colab_online.ipynb', 'repo_name': 'rdp-studio/EssayKiller_V2', 'size': '3229'}