Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Stability AI Japanにおける大規模言語モデルの研究開発

Avatar for Takuya Akiba Takuya Akiba
September 20, 2023
12k

Stability AI Japanにおける大規模言語モデルの研究開発

Avatar for Takuya Akiba

Takuya Akiba

September 20, 2023
Tweet

More Decks by Takuya Akiba

Transcript

  1. 自己紹介: 秋葉 拓哉 • ~2015 東京大学 コンピュータ科学専攻 博士 • ~2023

    Preferred Networks リサーチャー → ML基盤担当VP • 2023~ Stability AI シニアリサーチサイエンティスト https://takiba.net https://x.com/iwiwi
  2. 20 Apr 2023 22 Aug 2022 24 Nov 2022 Jan

    2023 28 July 2023 10 Aug 2023 17 Aug 2023 Stable Diffusion テキストから画像を生成する Text-to-imageモデル。 Japan office設立 日本のクリエイター・会社・組織の想像 力・創造力を拡張。 StableLM Stability AIから初となる言語モデ ルをリリース。 Stable Diffusion XL これまでのStable Diffusionの中で 最も高性能なモデル。 Stable Diffusion V2.1 V1リリースモデルからさらなる改善がされたモデル。 基盤のText-to-imageモデルを拡張したモデルも公 開。 • Super-Resolution Upscaler Diffusion Models • Depth-to-Image Diffusion Model • Updated Inpainting Diffusion Model Japanese InstructBLIP Japanese StableLM Stability AI Japan初となる日本語 特化言語モデル。 日本特化の画像言語モデル。 キャプション生成・質問応答。 Stability AI 沿革
  3. 目次 1. Japanese StableLM の紹介 • 日本語LLM作りの雰囲気 2. より強力な日本語LLMを作るために •

    日本語LLMの今後について、考えてること・疑問に思っていること • ご意見・アドバイス歓迎
  4. 🦜 Japanese StableLM (JSLM) Alpha • Japanese-StableLM-Base-Alpha-7B ◦ 7B pretrained

    autoregressive model using GPT-NeoX ◦ Trained w/ 750B tokens (Japanese/English) ▪ Japanese/English Wikipedia ▪ Japanese CC-100, mC4 ▪ extended Japanese OSCAR • Japanese-StableLM-Instruct-Alpha-7B ◦ SFT the above base model with Japanese instruction ▪ Stanford Alpaca ▪ Dolly-15k ▪ Japanese translation of Anthropic HH ◦ Trained with 3 epoch
  5. 🦜 Japanese StableLM (JSLM) Alpha • Japanese-StableLM-Base-Alpha-7B ◦ 7B pretrained

    autoregressive model using GPT-NeoX ◦ Trained w/ 750B tokens (Japanese/English) ▪ Japanese/English Wikipedia ▪ Japanese CC-100, mC4 ▪ extended Japanese OSCAR • Japanese-StableLM-Instruct-Alpha-7B ◦ SFT the above base model with Japanese instruction ▪ Stanford Alpaca ▪ Dolly-15k ▪ Japanese translation of Anthropic HH ◦ Trained with 3 epoch
  6. 🦜 Pretraining - Model architecture (Diff from standard NeoX setup)

    • Working on our own fork of EleutherAI/gpt-neox • Gated MLP (MLP with Gated Linear Unit) ◦ Becoming common op since SwiGLU and the other variants have been shown to improve perf. ◦ from BTLM-3B-8K: “We also found … SwiGLU further improved training efficiency.” • xPos (Extrapolatable Position Embedding) ◦ Our JSLM has seqlen=2048 ◦ xPos is a upgraded version of RoPE from Roformer ◦ more stable for long-term context modeling • Advice: consider the cost to introduce new model arch and make sure to properly implement your own NeoX->HF conversion to be user friendly 🤗
  7. 󰳐 Pretraining - Curriculum learning (CL) • There are many

    kinds of CL. The core idea of CL is to presents easier/simpler examples earlier during training and gradually increases the sample difficulties. • Aim to improve NN’s training stability or training efficiency, but usually not both. • We used Sequence Length Warmup (SLW) which define the difficulty as seqlen. In our 1B runs, SLW improved both training stability and efficiency which is great! 😎 • Start w/ SL=64, use 20k steps to reach SL=2048 (make sure to count #tokens right!) Li+, The Stability-Efficiency Dilemma: Investigating Sequence Length Warmup for Training GPT Models, NeurIPS’22 https://arxiv.org/abs/2108.06084
  8. 🍸 Pretraining - Data mixtures • We included both Japanese

    and English corpus during pretraining (check list of corpus in our model page) and simply set the language ratio as 50:50. • For different domains (web/wiki/books etc), we eventually set the domain weight based on their quantity (#tokens) so large portion of final corpus is web-based text (~85%). • We tried DoReMi to find the optimal domain weights w/ our own implementation but had no success. Recently, the paper author released their official code so we might revisit this later. Xie+,DoReMi: Optimizing Data Mixtures Speeds Up Language Model Pretraining, 2023. https://arxiv.org/abs/2108.06084
  9. 👍 Pretraining - Rule of thumb to allow you to

    sleep well at night • Use BF16 for mixed precision. FP16 might work if seqlen is short (e.g, 256-512), but OPT-175B and Bloom showed us for longer seqlen probably better to use BF16. • If loss spikes happen still, try setting gradient clipping to 1 and use lower LR (for 7B model, 1.2e-4 should work) • Try curriculum learning like SWL, or skip some batches right before spikes to bypass the spike.
  10. 🦜 Japanese StableLM (JSLM) Alpha • Japanese-StableLM-Base-Alpha-7B ◦ 7B pretrained

    autoregressive model using GPT-NeoX ◦ Trained w/ 750B tokens (Japanese/English) ▪ Japanese/English Wikipedia ▪ Japanese CC-100, mC4 ▪ extended Japanese OSCAR • Japanese-StableLM-Instruct-Alpha-7B ◦ SFT the above base model with Japanese instruction ▪ Stanford Alpaca ▪ Dolly-15k ▪ Japanese translation of Anthropic HH ◦ Trained with 3 epoch
  11. 🦜 Japanese StableLM (JSLM) Alpha • Japanese-StableLM-Base-Alpha-7B ◦ 7B pretrained

    autoregressive model using GPT-NeoX ◦ Trained w/ 750B tokens (Japanese/English) ▪ Japanese/English Wikipedia ▪ Japanese CC-100, mC4 ▪ extended Japanese OSCAR • Japanese-StableLM-Instruct-Alpha-7B ◦ SFT the above base model with Japanese instruction ▪ Stanford Alpaca ▪ Dolly-15k ▪ Japanese translation of Anthropic HH ◦ Trained with 3 epoch
  12. ⚖ Evaluation - lm-evaluation-harness for Japanese LLMs • When we

    started to build Japanese LLM months ago, we were surprised that there is not easy way to evaluate these models’ Japanese ability. • We extended lm-evaluation-harness with the community to allow everyone to evaluate Japanese LLMs easily. • Useful for evaluating general Japanese NLU ability but hard to evaluate NLG ability esp. for autoregressive models like GPT.
  13. ⚖ Evaluation - Japanese MT-Bench for Japanese LLMs • Inspired

    by LLM-as-a-judge approach, we also extended their work for Japanese LLMs evaluation recently. • Japanese MT-Bench includes: ◦ 160 2-turn Japan/Japanese-relevant questions across 8 domains (writing, roleplay, math etc) ◦ auto-graded by GPT-4, serve as a proxy measure to enable fast iteration ◦ used with lm-evaluation-harness together to get a better understanding of how these Japanese LLMs perform. • Feel free to send PRs and collaborate!
  14. ① Scaling Law を正しく理解していますか? 「モデルサイズを大きくすれば、性能が上がる」 誤りではないが…… 「性能を上げるには、モデルサイズと学習トークン数を一緒に大きくすると良い」 • Chinchilla Scaling

    Law ◦ 学習コストを固定する場合、およそ1:1で大きくしていくとよい ◦ その場合の性能向上は予測可能である • 実用的には、Chinchillaより学習トークン数をもっと大きくするのが普通 (モデルサイズを大きくすると、推論コストが上がってしまうため) とりあえず一旦、学習トークン数を増やしたい気持ちになってください(この後の話のために) Hoffmann+,Training Compute-Optimal Large Language Models, 2022. https://arxiv.org/abs/2203.15556
  15. ① Scaling Law を正しく理解していますか? Chinchilla Scaling関連の計算のためのnotebook https://gist.github.com/iwiwi/2528e4121bd339ffa71a18b6b47ac868 Hoffmann+,Training Compute-Optimal Large

    Language Models, 2022. https://arxiv.org/abs/2203.15556 H100の枚数 × 学習日数 → モデルサイズ Llama2の実際の学習トークン数と Chinchilla Optimalの比較
  16. ③ 英語データを併用するアプローチ アプローチ1: Multilingual Training 日本語と英語のデータを混合して学習を行う 例:stabilityai/stablelm-ja-base-alpha-7b, rinna/bilingual-gpt-neox-4b, matsuo-lab/weblab-10b アプローチ2:

    Cross-Lingual Transfer 英語で学習したモデルに、日本語で追加の学習を行う 例:elyza/ELYZA-japanese-Llama-2-7b, BLOOM+1, x-LLAMA Yong+, BLOOM+1: Adding Language Support to BLOOM for Zero-Shot Prompting, ACL 2023. https://arxiv.org/abs/2212.09535 Zhu+, Extrapolating Large Language Models to Non-English by Aligning Language, 2023. https://arxiv.org/abs/2308.04948 Japanese StableLM StableLM
  17. ③ 英語データを併用するアプローチ Multilingual Training vs Cross-Lingual Transfer この2つはどう違う? • どのようなトレードオフの関係にあるか?どう使い分ければ良いのか?

    • できるモデルに定性的な違いはあるのか? Curriculum Learning 2つのアプローチを組み合わせる。例えば、少しずつ日本語の割合を増やす。 例:PolyLM Wei+, PolyLM: An Open Source Polyglot Large Language Model, 2023. https://arxiv.org/abs/2307.06018 🤔
  18. ④ 学習データの割合はどのように決めればよい? Multilingual Trainingの場合は、さらに複雑 • 言語 × データ種別、という2つの軸が出てくる • 日本語と英語でデータサイズが大きく異なる

    • 最終的には日本語での性能が高まることが目標 DoReMi (Google) • GroupDROに基づくアルゴリズムでデータの混合割合を決定 • ヒューリスティクスではなく体系だった決め方 👍 • 最終的な性能に関する希望を反映させる介入が一切不可能 👎 • 極端なデータ内容やグループの分け方に対し不安定? 👎 Xie+,DoReMi: Optimizing Data Mixtures Speeds Up Language Model Pretraining, 2023. https://arxiv.org/abs/2108.06084 🤔
  19. ⑤ トークナイザの影響 日本語に向けて学習されたトークナイザを使った方がモデルの性能も良くなるのか? Cross-Lingual Transferをする場合、更にトレードオフは複雑になる。 学習済みモデルのトークナイザを変更すると? • 生成が速くなる👍 • Transfer

    Learningの効率が悪くなる 👎 • 他の影響は? 🤔 Artexe+, On the Cross-lingual Transferability of Monolingual Representations. ACL 2020. https://arxiv.org/abs/1910.11856 Vries+, As Good as New. How to Successfully Recycle English GPT-2 to Make Models for Other Languages, ACL 2021. https://arxiv.org/abs/2012.05628 Minixhofer+, WECHSEL: Effective initialization of subword embeddings for cross-lingual transfer of monolingual language models, NAACL 2022. https://arxiv.org/abs/2112.06598 Ostendorff+, Efficient Language Model Training through Cross-Lingual and Progressive Transfer Learning, 2023. https://arxiv.org/abs/2301.09626
  20. ⑤ トークナイザの影響 Char-Level LM, Byte-Level LM トークナイザについて思考実験する場合、極端なケースとして、これらも考えた方が面白い。 (例えば、これらについて考えた際に成り立たない仮説は、仮説として良くないはず。) • Char-Level:1文字

    = 1トークン • Byte-Level:1バイト = 1トークン Yu+, MEGABYTE: Predicting Million-byte Sequences with Multiscale Transformers, 2023. https://arxiv.org/abs/2305.07185 Horton+, Bytes Are All You Need: Transformers Operating Directly On File Bytes, 2023. https://arxiv.org/abs/2306.00238
  21. 目次 1. Japanese StableLM の紹介 • 日本語LLM作りの雰囲気 2. より強力な日本語LLMを作るために •

    Scaling Law、日本語のデータの量、英語データ併用の必要性 • 学習データの割合はどのように決めれば良いのか • トークナイザがモデルに与える影響