9

现代文自动生成器:来试试用GPT2自动写中文

 2 years ago
source link: https://www.52nlp.cn/%e7%8e%b0%e4%bb%a3%e6%96%87%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90%e5%99%a8%ef%bc%9a%e6%9d%a5%e8%af%95%e8%af%95%e8%87%aa%e5%8a%a8%e5%86%99%e6%96%87%e7%ab%a0
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
现代文自动生成器:来试试用GPT2自动写中文 – 我爱自然语言处理
ainlp-qun-r2l.png

周末,继续文本生成的话题。前几天我们基于 Hugging Face 的中文歌词GPT-2预训练模型(Chinese GPT2 Lyric Model)和文言文GPT-2预训练模型(Chinese Ancient GPT2 Model)在AINLP公众号后台添加了中文歌词生成器文言文生成器

今天,我们继续基于 Hugging Face 的通用中文GPT-2预训练模型(Chinese GPT2 Model) ,在 AINLP 公众号后台添加了现代文生成器,感兴趣的朋友可以关注AINLP公众号后对话测试:

回复“写现代文:开头内容”进行测试,例如:

关于这个模型的详细介绍,可以参考Hugging Face的模型主页,这里摘录部分:

Chinese GPT2 Model
Model description
The model is used to generate Chinese texts. You can download the model either from the GPT2-Chinese Github page, or via HuggingFace from the link gpt2-chinese-cluecorpussmall.

How to use
You can use the model directly with a pipeline for text generation:

>>> from transformers import BertTokenizer, GPT2LMHeadModel, TextGenerationPipeline
>>> tokenizer = BertTokenizer.from_pretrained("uer/gpt2-chinese-cluecorpussmall")
>>> model = GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-cluecorpussmall")
>>> text_generator = TextGenerationPipeline(model, tokenizer)   
>>> text_generator("这是很久之前的事情了", max_length=100, do_sample=True)
    [{'generated_text': '这是很久之前的事情了 , 我 曾 经 把 这 个 当 做 一 种 思 想 的 传 承 , 或 者 是 人 生 的 回 顾 , 当 时 我 们 是 一 个 刚 刚 加 入 的 时 候 就 想 要 加 入 他 们 , 于 是 我 们 每 天 看 到 他 们 , 加 上 他 们 的 各 种 不 可 思 议 的 行 为 , 直 到 现 在 , 我 们 的 人 生 才 完 整 起 来 。'}]
Training data
CLUECorpusSmall is used as training data.

特别感谢 GPT2-Chinese 项目的整理和分享的相关模型以及相关模型和数据的贡献者:

以下是AINLP目前支持的自动生成模块,之后将加入更多的领域生成测试模块,欢迎关注测试:

风云三尺剑,花鸟一床书---对联数据集和自动对联机器人
自动对联活动获奖结果以及机器对联赏析
"自动作诗机"上线,代码和数据都是公开的
鼠年春节,用 GPT-2 自动写对联和对对联
用 GPT-2 自动写诗,从五言绝句开始
自动作诗机&藏头诗生成器:五言、七言、绝句、律诗全了
仅供娱乐,藏尾诗生成器来了

中文歌词自动生成器:来试试自动写歌

文言文自动生成器:来试试自动写古文


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK