この動画は、Chat GPTを自分のデータセットで微調整する方法について詳細に解説しています。微調整により、モデルの安定性、指示に従う能力、出力のカスタマイズが向上し、APIの呼び出し速度を上げ、コストを削減できます。動画では、微調整のコスト、手順、および注意点についても説明しており、特に、微調整したGPT 3.5 Turboモデルは通常のモデルよりも高価で、その価格上昇がパフォーマンス向上に見合うかは不明であると指摘しています。
公開日:2023年8月23日
※動画を再生してから読むのがオススメです。
これはとても大きなことです。
今日から、自分のデータセットでChatGPTを微調整できる。
それは人々がしばらく待ち望んでいたものです。
このビデオでは、自分のデータセットでChatGPTを微調整することで、どのようなメリットが得られるかを見ていきます。
また、料金体系や、ご自身のデータセットでどのようにモデルを微調整できるのか、コード例を通してご紹介します。
そしてビデオの最後には、ほとんどの人にとって良い選択肢ではない理由も探ります。
では、ファインチューニングによって何が得られるのでしょうか?
モデルを微調整すると、改善された安定性が得られます。これは基本的に、モデルがより良い指示に従うことができることを意味します。
また、信頼性の高い出力フォーマットも得られます。基本的にモデルは、あなたが望む出力フォーマットに忠実です。
また、微調整により、モデルのトーンをカスタマイズすることができる。
まず、モデルを微調整する場合、より良いパフォーマンスを得るために、より短いプロンプトを使用することができる。
また、GPT-3と比較して、GPT-3.5は4000トークンを扱うことができます。彼らのテストによると、モデル自体に命令を微調整することによって、プロンプトのサイズを最大90%削減することができるようです。
ファインチューニングを、プロンプト・エンジニアリング、情報検索、関数呼び出しといった他のアプローチと組み合わせたときこそ、素晴らしいものになる。
それこそが、これらのLLMをより強力なものにしているのだ。
次に、ファインチューニングの例を見る前に、価格設定を見てみよう。
今、価格は2つの異なる部分に分けられています。1つは初期のトレーニングコストであり、2つ目は使用コストです。
つまり、トレーニングには1000トークンあたり0.008ドルかかります。
入力プロンプトには、1,000トークンあたり0.012ドルかかります。
そして、アウトプットの使用には、1,000トークンあたり0.016ドルかかる。
最後に、彼らは非常に単純化した例を提示しています。
例えば、100,000トークン程度のトレーニングが必要な場合、モデルのトレーニングにかかるコストは約2.4ドルです。
今、この価格について再び話を戻します。ここには解説するべきことがたくさんあります。
では、具体的にどのように微調整ができるのかを見てみましょう。
ブログ記事では、このようなスキーマを提供している。
まず、データセットを準備する必要があります。データセットには、システムメッセージ、ユーザーからの入力、アシスタントからの応答があるはずです。
それがデータセットがどのように見えるべきかです。
そして、OpenAIにAPIコールをしてファイルをアップロードし、APIを通じてトレーニングジョブを作成します。
そして、APIを通してモデルを再利用することもできます。
しかし、より具体的なPythonの例を見てみましょう。
OpenAIのウェブサイトには、とても素晴らしい微調整ガイドがあります。
ここでは、なぜ微調整を行いたいのか、その理由を説明しています。
例えば、ファインチューニングを行うことで、プロンプトの能力よりも質の高い結果が得られること、1回のプロンプトで収まるよりも多くの例でトレーニングできること、問題が短くなりレイテンシが減ることでトークンを節約できることなどが挙げられます。
OpenAIモデルのファインチューニングを本当に理解しようとするなら、このガイドに目を通すことをお勧めします。
しかし、自分のデータセットでモデルを微調整したい場合、まずデータを適切なフォーマットにする必要があります。
そのために、データには3つの異なるフィールドやロールが必要です。
最初のフィールドはシステムメッセージです。
それは基本的に、モデルに提供されるシステムメッセージです。
次にユーザー入力です。
ここではロールをユーザーと定義し、内容はユーザーからの入力プロンプトです。
そして、アシスタントからの応答が得られます。
基本的には、すべての例をシンプルなJSONファイルに配置し、そのJSONファイルをモデルがトレーニングに使用します。
データが適切な形式になったら、作成したJSONファイルをOpenAI APIにアップロードする必要があります。
データセットが作成できたら、次はデータセットをOpenAIにアップロードします。
そのためにPythonのコードを使います。
これはOpenAIのAPIパッケージです。
その後、ファイル名を指定します。
データはこのmydata.jsonファイルに保存されているとします。
そして目的を指定します。
このケースでは、モデルを微調整したいのです。
これを行った後、単純に微調整ジョブを開始する必要があります。
そのためには、OpenAIのAPIキーを提供する必要がある。
そして、微調整ジョブを呼び出すだけです。
これでジョブが作成され、微調整が開始されます。
ここで、さらに2つの入力を提供する必要がある。
1つ目はトレーニング・ファイルです。
これはトレーニングされたモデルに使用されるモデル名です。
そしてベースモデルの名前を入力する必要があります。
GPT-3.5ターボを微調整したい場合は、ここにその名前を入力する必要があります。
モデルを微調整して、それを使いたい場合はどうするのですか?
OpenAIのチャット補完APIを使うのと同じくらい簡単だ。
ここでは、微調整モデルに割り当てるモデル名と、システムメッセージを指定するだけです。
そして、ユーザが入力すると、アシスタントの応答やモデルの応答が出力されます。
このように、OpenAI APIを使ったGPT-3.5の微調整はとても簡単です。
自分のデータセットでこれを微調整する方法について、より詳細なビデオを作成するつもりです。
データセットをどのように構成するかを見て、それからAPIコールを行い、微調整されたモデルを取得します。
そのビデオにご期待ください。
さて、このサービスを使うのをためらう人がいるかもしれない、あまり良くない点を見てみよう。
では、最初のものは安全機能です。
あなたのトレーニングデータは、OpenAIの安全基準に抵触する安全でないトレーニングデータを検出するために、GPT4が搭載されたモデレーションシステムとモデレーションAPIを通過します。
つまり、基本的にはデータの基準によって制限されます。
次に考慮するべきことは価格そのものです。微調整されたGPT-3.5ターボモデルは、バニラのGPT-3.5ターボモデルと比べてはるかに高価です。
例として、入力トークンの場合、4Kコンテキスト・ウィンドウGPT-3.5ターボ・モデルを使用する場合と比べて約8倍高くなります。
さて、出力トークンについては、オリジナルの3.5と比較して約5.3倍です。
GPT4と比較すると、まだ安価ですが、おそらく性能はGPT4には及ばないでしょう。
ですから、モデルを微調整する場合は、この大幅な価格上昇を考慮する必要があります。
非常に興味深い開発であり、その上で人々がどんなものを作れるのか興味深い。
とはいえ、あなたのアプリケーションで実際に性能アップが可能かどうか、そしてその性能アップは大幅な価格アップに見合うものなのかどうかは、まだ見極める必要があるだろう。
下のコメント欄で意見を聞かせてほしい。
あなた自身のデータセットでこのモデルを微調整する方法について、より詳細なビデオを作成する予定です。
もしこのコンテンツが役に立ったら、「いいね!」とチャンネル登録をお願いします。
ご視聴いただきありがとうございました。次回をお楽しみに。