あなたはopenai / gpt-2を見てきました。
あなたはカルパシー/ minGPTを見てきました。
あなたはカルパシー/ナノGPTを見たことさえあります!
しかし、あなたはpicoGPTを見たことがありますか??!?
picoGPTは、プレーンなNumPyでのGPT-2の不必要に小さく最小限の実装です。フォワードパスコード全体は40行のコードです。私はpicoGPTの関連するブログ記事を書きました。
ピコGPTの特徴:
gpt2.py
gpt2_pico.py
各ファイルの簡単な内訳:
encoder.pyには、GPT-2リポジトリから直接取得したOpenAIのBPEトークナイザーのコードが含まれています。
utils.pyGPT-2 モデルの重み、トークナイザー、およびハイパーパラメーターをダウンロードして読み込むコードが含まれています。
gpt2.pyPython スクリプトとして実行できる実際の GPT モデルと生成コードが含まれています。
gpt2_pico.pyは と同じですが、コードの行数はさらに少なくなります。なぜでしょうか。なぜだめですか
gpt2.py
pip install -r requirements.txt
でテスト済み。
Python 3.9.10
python gpt2.py "Alan Turing theorized that computers would one day become"
これは生成します
the most powerful machines on the planet. The computer is a machine that can perform complex calculations, and it can perform these calculations in a way that is very similar to the human brain.
また、生成するトークンの数、モデル サイズ ( の 1 つ)、およびモデルを保存するディレクトリを制御することもできます。
["124M", "355M", "774M", "1558M"]
python gpt2.py \
"Alan Turing theorized that computers would one day become" \
--n_tokens_to_generate 40 \
--model_size "124M" \
--models_dir "models"