NLP Cloudでは、GPT-Jを、自然言語による人間の指示を適切に理解するための指示モデルとして、数発の学習を使わずに微調整できるかどうかを確かめたいと思いました。オープンソースコミュニティでは、Flan-T5、BloomZ、Stanford Alpacaなど、他の試みが面白い結果を出しているので、Alpacaのデータセットを使ってGPT-Jで同じことをやってみようと思いました。結果は、とても良いものでした
生成AIモデルは、デフォルトでは人間の要望を理解することが苦手です。
このようなテキスト生成モデルに、あなたが望むものを理解させるために、最適な解決策は、少数点学習を使うことです。少数点学習について、特別なガイドを作りました。 こちらでご覧いただけます。. GPT-Jは、非常に高性能なモデルでありながら、数撃ちゃ当たるの学習でしか正しく機能しない良い例だと思います。
このような例題を作るのは、通常、それほど時間がかからないとしても、これらのAIモデルを正しく使おうとする新参者には非常に分かりにくい。人間と同じように自然に質問する方がずっと簡単です。
例えば、GPT-Jでスペルミスを修正したいとします。ここで、使用しなければならないプロンプトの例を挙げます。
I love goin to the beach.
Correction: I love going to the beach.
###
Let me hav it!
Correction: Let me have it!
###
It have too many drawbacks.
Correction: It has too many drawbacks.
###
I do not wan to go
Correction:
このように、複雑ではありませんが、簡単でもありません。GPT-Jをきちんと微調整すれば、「指示」型にすることができますので、次のように問うことができるようになりました。
Correct spelling and grammar from the following text.
I do not wan to go
そして、次のように返されるのである。
I do not want to go.
ずっといいんじゃないですか?どうすれば実現できるのか?
Stanford Alpacaが数日前にリリースされました。これは、Facebookが開発した「Llama」というモデルの微調整版です。 このプロジェクトについては、こちらで詳しくご紹介しています。
基本的に、スタンフォードのアルパカチームは、人間の命令からなるかなり小さなデータセット(52k例)でLlamaを微調整することで、最先端の命令モデルを作り上げることに成功しました。興味深いのは、このデータセットを、より大きな言語モデル(GPT-3)を使ってプログラム的に生成したことです。 データセットはこちらからダウンロードできます。
NLPクラウドでは、このデータセットを使ってGPT-Jの微調整を試みましたが、驚くほど良い結果が得られました。
新たに作成したInstruct GPT-Jモデルは、Hugging Face Hubに掲載されているので、気軽に利用することができます。 モデルを見るにはここをクリック.
ここでは、ハギングフェイストランスフォーマーを使った、モデルの使い方をご紹介します。
from transformers import pipeline
import torch
generator = pipeline(model="nlpcloud/instruct-gpt-j-fp16", torch_dtype=torch.float16, device=0)
prompt = "Correct spelling and grammar from the following text.\nI do not wan to go\n"
print(generator(prompt))
試してみたいプロンプトを紹介します。
Write a short story about space.\n
Generate a C++ program that sorts a list of integers in ascending order.\n
Paraphrase the following text.\nAfter a war lasting 20 years, following the decision taken first by President Trump and then by President Biden to withdraw American troops, Kabul, the capital of Afghanistan, fell within a few hours to the Taliban, without resistance.\n
Summarize the following text.\nFor all its whizz-bang caper-gone-wrong energy, and for all its subsequent emotional troughs, this week’s Succession finale might have been the most important in its entire run. Because, unless I am very much wrong, Succession – a show about people trying to forcefully mount a succession – just had its succession. And now everything has to change. The episode ended with Logan Roy defying his children by selling Waystar Royco to idiosyncratic Swedish tech bro Lukas Matsson. It’s an unexpected twist, like if King Lear contained a weird new beat where Lear hands the British crown to Jack Dorsey for a laugh, but it sets up a bold new future for the show. What will happen in season four? Here are some theories. Season three of Succession picked up seconds after season two ended. It was a smart move, showing the immediate swirl of confusion that followed Kendall Roy’s decision to undo his father, and something similar could happen here. This week’s episode ended with three of the Roy siblings heartbroken and angry at their father’s grand betrayal. Perhaps season four could pick up at that precise moment, and show their efforts to reorganise their rebellion against him. This is something that Succession undoubtedly does very well – for the most part, its greatest moments have been those heart-thumping scenes where Kendall scraps for support to unseat his dad – and Jesse Armstrong has more than enough dramatic clout to centre the entire season around the battle to stop the Matsson deal dead in its tracks.\n
なお、このモデルの微調整の仕方から、説明書の最後には必ず改行が必要です。
このモデルは、NVIDIA Tesla T4のような16GBのVRAMを搭載したGPUで非常によく動作する、微調整されたモデルのfp16版です。
fp32版とfp16版では、品質面での差は感じられませんでした。
GPT-Jは以前から非常に優れたモデルでしたが、インストラクターモデルとして使用するとさらに良くなります。
この技術により、誰でも自分のAI生成モデルをインストラクターモデルにすることができるようになったのです。
上記について、ご質問やご意見がありましたら、遠慮なくご連絡ください.
François
NLPクラウドのデータサイエンティスト