gpt 2 Pytorch
1.0.0
更好的语言模型及其含义
我们的模型称为GPT-2(GPT的继承人),受过训练,只是为了预测40GB的Internet文本中的下一个单词。由于我们对该技术的恶意应用的担忧,我们没有发布训练有素的模型。作为负责任披露的实验,我们正在释放一个较小的模型,以供研究人员和技术论文进行实验。来自Openai博客
该存储库是带有压缩代码的Pytorch中有关文本生成器的简单实现GPT-2
原始曲目是OpenAI/GPT-2。您也可以阅读有关GPT-2的论文,“语言模型是无监督的多任务学习者”。为了了解更多详细的概念,我建议有关变压器模型的论文。
我提到的pytorch中的良好实现GPT-2,huggingface/pytorch-pretretain-bert,您可以在HuggingFace Repository中看到更多详细的实现。
变形金刚(自我注意)论文:您需要注意的全部(2017年)
第一张OpenAi-GPT论文:通过生成预培训提高语言理解(2018年)
请参阅有关GPT-2和纸张的OpenAI博客
$ git clone https://github.com/graykode/gpt-2-Pytorch && cd gpt-2-Pytorch
# download huggingface's pytorch model
$ curl --output gpt2-pytorch_model.bin https://s3.amazonaws.com/models.huggingface.co/bert/gpt2-pytorch_model.bin
# setup requirements, if using mac os, then run additional setup as descibed below
$ pip install -r requirements.txt$ python main.py --text " It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind, slipped quickly through the glass doors of Victory Mansions, though not quickly enough to prevent a swirl of gritty dust from entering along with him. "--text :句子开始。--quiet :不要打印所有其他物品,例如“ =================”--nsamples :使用多项式功能时在批处理中采样的样品数量--unconditional :如果是真的,无条件的生成。--batch_size :批量大小的数量--length :句子长度(<上下文数)--temperature :分布的热力学温度(default 0.7)--top_k :沿给定的尺寸返回给定输入张量的最大元素。 (default 40)在此处查看有关temperature和top_k更多详细选项
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install torch tqdm
$ brew install libomp
$ export LC_ALL=en_US.UTF-8
$ export LANG=en_US.UTF-8
$ pip install -r requirements.txtJeff Wu(@wuthefwasthat),托马斯·沃尔夫(@thomwolf)允许参考代码。