分享

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

 520jefferson 2021-08-04

前两天,我们基于 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 项目的整理和分享的相关模型以及相关模型和数据的贡献者:

图片

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多