HuggingFace镜像/german-gpt2
模型介绍文件和版本分析

German GPT-2 模型

本仓库中,我们发布了(又一个)GPT-2 模型,该模型是在多种德语文本上训练而成的。

此模型旨在作为在其他文本上进行微调的起点,其性能肯定不及英文 GPT-3 模型,也不会像 GPT-3 那样“具有危险性”。我们不打算为此模型进行大规模的公关宣传或分阶段发布 😉

注意:该模型最初是以匿名别名(anonymous-german-nlp/german-gpt2)发布的,因此我们现在对其进行“去匿名化”。

变更日志

2021年8月16日:公开发布重新训练的 German GPT-2 模型版本,结果更优。

2020年11月15日:初始版本。如需使用[此旧版本],请使用标签 v1.0。

训练语料库

我们使用的语料库与训练 DBMDZ BERT 模型时所用的语料库基本相同,该语料库可在此仓库中找到。

感谢出色的 Hugging Face 团队,借助他们强大的 Tokenizers 库,我们得以创建字节级的 BPE。

利用前面提到的强大 Tokenizers 库,我们基于训练语料库创建了一个包含 50K 词表的字节级 BPE。

使用模型

模型本身可按以下方式使用:

from openmind import is_torch_npu_available, AutoTokenizer, AutoModelWithLMHead
import torch

if is_torch_npu_available():
    device = "npu:0"
elif torch.cuda.is_available():
    device = "cuda:0"
else:
    device = "cpu"

tokenizer = AutoTokenizer.from_pretrained("SY_AICC/german-gpt2")

model = AutoModelWithLMHead.from_pretrained("SY_AICC/german-gpt2" , device=device)

不过,文本生成要更有意思一些,所以这里有一个示例,展示如何使用出色的 Transformers Pipelines 来生成文本:

from openmind import is_torch_npu_available, pipeline
import torch

if is_torch_npu_available():
    device = "npu:0"
elif torch.cuda.is_available():
    device = "cuda:0"
else:
    device = "cpu"

pipe = pipeline('text-generation', model="SY_AICC/german-gpt2",
                 tokenizer="SY_AICC/german-gpt2" , device=device)

text = pipe("Der Sinn des Lebens ist es", max_length=100)[0]["generated_text"]

print(text)

许可证

所有模型均根据 MIT 许可证授权。

联系方式(问题反馈、意见建议、贡献等)

如对我们的 BERT 模型有任何疑问,请在此处提交 issue here 🤗

致谢

本研究得到了 Google TensorFlow 研究云(TFRC)提供的 Cloud TPU 支持。 感谢提供 TFRC 访问权限 ❤️

下载使用量0