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)允許參考代碼。