🚀 GPT - JT
GPT - JTは、新しい分散型トレーニングアルゴリズムを用いて、GPT - J (6B) を35.3億トークンでファインチューニングしたモデルです。分類ベンチマークにおいて、多くの100B以上のパラメータを持つモデルを上回る性能を発揮します。
🚀 クイックスタート
from transformers import pipeline
pipe = pipeline(model='togethercomputer/GPT-JT-6B-v1')
pipe('''"I love this!" Is it positive? A:''')
または
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/GPT-JT-6B-v1")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/GPT-JT-6B-v1")
✨ 主な機能
- GPT - JTはEleutherAIの[GPT - J (6B)](https://huggingface.co/EleutherAI/gpt - j - 6B)をフォークしたものです。
- [UL2](https://github.com/google - research/google - research/tree/master/ul2)のトレーニング目的を使用し、モデルがプロンプトの双方向コンテキストを見ることができるようにします。
- モデルは、[Chain - of - Thought (CoT)](https://ai.googleblog.com/2022/05/language - models - perform - reasoning - via.html)、Public Pool of Prompts (P3) dataset、[Natural - Instructions (NI) dataset](https://github.com/allenai/natural - instructions)などの多様なデータセットでトレーニングされています。
これらの技術の助けを借りて、GPT - JTは元のGPT - Jに比べて分類タスクの性能を大幅に向上させ、多くの100B以上のパラメータを持つモデルを上回っています。
📦 インストール
このセクションでは、クイックスタートのコードを実行するために必要なライブラリのインストールについて説明します。
pip install transformers
💻 使用例
基本的な使用法
from transformers import pipeline
pipe = pipeline(model='togethercomputer/GPT-JT-6B-v1')
pipe('''"I love this!" Is it positive? A:''')
高度な使用法
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("togethercomputer/GPT-JT-6B-v1")
model = AutoModelForCausalLM.from_pretrained("togethercomputer/GPT-JT-6B-v1")
input_text = "Your custom input text here"
input_ids = tokenizer(input_text, return_tensors='pt').input_ids
output = model.generate(input_ids)
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
print(decoded_output)
📚 詳細ドキュメント
データセット
Property |
Details |
Datasets |
natural_instructions、the_pile、cot、Muennighoff/P3 |
Inference Parameters |
max_new_tokens: 5、temperature: 1.0、top_k: 1 |
License |
apache - 2.0 |
Language |
en |
Pipeline Tag |
text - generation |
ウィジェットの使用例
- Sentiment Analysis
- タスク: 投稿の感情をsadness、joy、love、anger、fear、surpriseのいずれかにラベル付けする。
- 入力: I'm feeling quite sad and sorry for myself but ill snap out of it soon.
- 出力: sadness
- 入力: I am just feeling cranky and blue.
- 出力: anger
- 入力: I can have for a treat or if i am feeling festive.
- 出力:
- Country Currency
- タスク: 与えられた国の通貨を返す。
- 入力: Switzerland
- 出力: Swiss Franc
- 入力: India
- 出力:
- Tweet Eval Hate
- タスク: 以下のツイートが移民または女性に対するヘイトスピーチを含むかどうかをラベル付けする。
- ツイート: HOW REFRESHING! In South Korea, there is no such thing as 'political correctness" when it comes to dealing with Muslim refugee wannabes via @user
- ラベル: hate speech
- ツイート: New to Twitter-- any men on here know what the process is to get #verified?
- ラベル: not hate speech
- ツイート: Dont worry @user you are and will always be the most hysterical woman.
- ラベル:
- Entity Recognition
- タスク: 以下の文章から人、場所、組織の名前をすべて抽出する。
- 文章: Satya Nadella, the CEO of Microsoft, was visiting the Bahamas last May.
- エンティティ: Satya Nadella, Microsoft, Bahamas
- 文章: Pacific Northwest cities include Seattle and Portland, which I have visited with Vikash.
- エンティティ:
- Data Clearning
- タスク: データをCSVファイル形式に整形する。
- 入力: Jane Doe jane.doe@gmail.com (520) 382 2435
- 出力: Jane Doe,jane.doe@gmail.com,520 - 382 - 2435
- 入力: Peter Lee (510) 333 - 2429 email: peter@yahoo.com
- 出力:
🔧 技術詳細
UL2トレーニング目的
GPT - JTはUL2トレーニング目的[1][2]を使用してトレーニングされています。元のGPT - Jは、自己回帰生成のために因果マスク(左下図)を使用しています。つまり、各トークンはその前のコンテキストのみを見ることができます。
コンテキスト情報を最大限に活用するために、GPT - JをUL2トレーニング目的で続けてトレーニングし、プレフィックス付きの因果マスク(右下図)を使用します。つまり、プロンプト/入力には双方向注意を、トークン生成には因果注意を使用します。
直感的には、双方向にコンテキストを見ることができることで、この情報を必要とする下流タスクの性能が向上する可能性があります。
$$
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \
1 & 1 & 0 & 0 & 0 \
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 1 & 0 \
1 & 1 & 1 & 1 & 1
\end{bmatrix}
\begin{bmatrix}
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 0 & 0 \
1 & 1 & 1 & 1 & 0 \
1 & 1 & 1 & 1 & 1
\end{bmatrix}
$$
さらに、[Natural - Instructions](https://github.com/allenai/natural - instructions)、P3、[MMLU - COT](https://github.com/jasonwei20/flan - 2/blob/main/mmlu - cot.json)、the Pileなどの大量のデータセットを活用しています。
具体的には、まずPileデータセットでUL2損失を使用して26.2億トークンのトレーニングを行い、その後、上記のデータセットの混合物で9.2億トークンのトレーニングを行います。この混合物は、COTが5%、P3が20%、NIが20%、the Pileが55%で構成されています。
ハイパーパラメータ
- オプティマイザ: AdamW
- 学習率: 1e - 5
- グローバルバッチサイズ: 64(各データ並列ワーカーにつき16)
- ミックス精度トレーニング: 活性化関数はFP16、オプティマイザの状態はFP32
- 並列化: データ並列とパイプライン並列の両方を使用
- 入力シーケンスのトランケート: 2048トークン
- データ効率向上: 2048トークン未満の入力シーケンスについては、複数のシーケンスを1つの長いシーケンスに連結
インフラストラクチャ
トレーニングにはthe Together Research Computerを使用しました。
📄 ライセンス
GPT - JT - 6B - v1のウェイトは、Apache Licenseのバージョン2.0の下でライセンスされています。
📖 参考文献
[1]: Tay, Yi, Mostafa Dehghani, Vinh Q. Tran, Xavier Garcia, Dara Bahri, Tal Schuster, Huaixiu Steven Zheng, Neil Houlsby, and Donald Metzler. "Unifying Language Learning Paradigms." arXiv preprint arXiv:2205.05131 (2022).
[2]: Tay, Yi, Jason Wei, Hyung Won Chung, Vinh Q. Tran, David R. So, Siamak Shakeri, Xavier Garcia et al. "Transcending scaling laws with 0.1% extra compute." arXiv preprint arXiv:2210.11399 (2022).