前两天,我们基于 Hugging Face 的中文歌词模型(Chinese GPT2 Lyric Model)在AINLP公众号后台添加了中文歌词生成器:

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

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

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

Chinese Ancient GPT2 Model

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

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-ancient")
>>> model = GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-ancient")
>>> text_generator = TextGenerationPipeline(model, tokenizer)   
>>> text_generator("当是时", max_length=100, do_sample=True)
    [{'generated_text': '[CLS]当是时 所 议 者 不 为 无 据 , 况 亦 在 之 列 乎 ? 然 则 今 日 之 事 , 所 当 思 者 在 何 ? 欲 求 国 是 于 天 下 , 莫 在 于 得 人 。 臣 以 为 求 人 之 法 , 不 在 多 用 官 一 途 。 诚 使 得 才 者 众 , 人 才 者 优 , 则 治 所 当 得 , 而 不 事 于 官 者 , 人 才 乃 其 常 也 。 所 当 讲 者'}]

Training data
Training data contains 3,000,000 ancient Chinese which are collected by daizhigev20. Since part of ancient corpus has no punctuation, we used the ancient Chinese punctuation system developed by BNU ICIP lab. 

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

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

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

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

作者 52nlp

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注