Upgrade to Pro — share decks privately, control downloads, hide ads and more …

論文解説 DeepSeek-R1: Incentivizing Reasoning Capab...

koharite
February 14, 2025

論文解説 DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning

Presentation for explaining the paper "DeepSeek-R1".
DeepSeek R1 is a Chinese-developed LLM that has demonstrated performance comparable to top LLMs such as ChatGPT, Gemini, and Claude.
Its computational costs of train and inference are said to be one-tenth to one-hundredth of those of the top LLMs.

koharite

February 14, 2025
Tweet

More Decks by koharite

Other Decks in Research

Transcript

  1. 2 論文情報 タイトル: DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via

    Reinforcement Learning • 論文: https://github.com/deepseek-ai/DeepSeek-R1/blob/main/DeepSeek_R1.pdf • モデル: https://huggingface.co/deepseek-ai/DeepSeek-R1 • 著者: Daya Guo, Dejian Yang, Haowei Zhang, Junxiao Song, Ruoyu Zhang, Runxin Xu, Qihao Zhu, Shirong Ma, PeiyiWang, Xiao Bi, Xiaokang Zhang, Xingkai Yu, Yu Wu, Z.F.Wu, Zhibin Gou, Zhihong Shao, Zhuoshu Li, Ziyi Gao, and many more • 所属:DeepSeek-AI 選んだ理由: 一般のニュースでも話題になっている中国で開発された世界トップレベルのLLMについて読み 解きたいと思った。
  2. 3 What’s innovative about DeepSeek? ➢ 高性能 ChatGPT-4o, Gemini-2.0-Flash-Thinkingなど深い思考力があるとされるモデルと同等レベルの性能 Webサービスやスマホアプリがリリースされ一般でも使いやすく、ChatGPTなどと比べて遜色ない回答

    ➢ 低価格 ➢ オープンソース 学習コスト DeepSeek-V3 558万ドル、一方 GPT-4o 数十億ドル、Llama 2 数億ドルと言われる Hugging Faceでモデル公開 論文で技術特徴を公開 API料金
  3. 4 How to achieve it? ➢ 強化学習による思考力の獲得 大規模LLMで高性能を発揮するには、そのネットワーク規模に見合う教師データが必要とされるが RLHF(Reinforcement Learning

    via Human Feedback)等のデータ作成も大きな負荷。 RLAIF(Reinforcement Learning via AI Feedback)でも評価モデルの実現などが難しい。 数学などの正解が明確なタスクのデータを与え、GRPOという方法を採用し学習させる ことで思考力(問題の理解、解決方法の探索、回答の提示方法など)を獲得する。 ➢ 効率的なアーキテクチャ Mixture-of-Expert, Multi head Latent Attentionなどを採用し、実行効率の良いLLMを 実現している。 ➢ 高品質データによるSupervised Finetuning 高品質なデータセットによるSupervised Finetuningを実施して、 Chatなどで人にとってわかりやすい回答を得られるようにした。
  4. 5 DeepSeek related technologies DeepSeek-R1-Zero DeepSeek-V3 DeepSeek-R1 DeepSeek-V2 DeepSeek-MoE DeepSeekMath

    Sorry for the rough diagram. There must be more details. high quality data for reasoning capabilities Mixture of Expert Multi Head Latent Attention Auxiliary-Loss- Free Load Balancing Reinforcement Learning on Group Relative Policy Optimization Supervised fine-tuning with small amount Chain of Thought data they were published in 2024
  5. 8 Feature of DeepSeek-V3 DeepSeek-v3 Technical Report https://arxiv.org/html/2412.19437v1 ◆ Multi-head

    Latent Attention (MLA) ◆ Mixture-of-Experts (MoE) ◆ Auxiliary-loss-free strategy 実行効率が高いネットワーク構造を採用し、学習時の工夫を行う。 計算機を最大限に活用できるようなpipeline, アーキテクチャ設計なども記載されている。
  6. 9 DeepSeek-V3 Architecture MLA(Multi-head Latent Attention)とDeepSeekMoE(Mixture of Experts)を備えたTransformer total parameters:

    671Bだが、 activated parameters for each token : 37B となる。 Mixture of Expertsによりデータにより有効なネット ワークを選択的に活用できるため、 実行効率が良い Multi-head Latent AttentionによりAttention によるメモリ要求を低減させる
  7. 10 Multi-Head Latent Attention inference時のKey-Value cacheを減らせるようにlow-rank joint compressionを行う。 down-projection matrix

    up-projection matrix up-projection matrix cacheする必要があるのはこの2つ during inference, since WUK can be absorbed into WQ, and WUV can be absorbed into WO, we even do not need to compute keys and values out for attention.
  8. 12 DeepSeekMoE DeepSeekMoEは細かい粒度のexpertsを用意し、一部をshared expertsとする。 shared expert routed expert number of

    activated routed experts gating value for i-th expert • expertsの専門性を高め、より正確な知識獲 得を実現 • shared expertsによりrouted expertsの知識 の冗長性の軽減
  9. 13 Auxiliary-Loss-Free Load Balancing Mixture of Expertsでは、どのデータでも特定の同じexpertsが呼び出されてしまう問題が起こりやすく、 これまでauxiliary lossを導入することでそのunbalanced loadの問題を改善する事が多かった。

    しかし、あまりに大きなauxiliary lossはmodel性能を損なってしまう。 load balanceとmodel performanceのトレードオフを解決するload balancing strategyを提案する。 bias項の導入 トレーニング中の各ステップで各expertsの負荷を監視し、 各ステップの終了時に、呼び出しが多いexpertの場合はバイアスをγ減らし、 呼び出しが少ないexpertの場合はバイアスをγ増やす。 γはbias update speedのハイパーパラメータ。 わりと手動調整の項目となっているように思われ、熟知している人でないとうまく調整できないのでは ないかという気がする。
  10. 15 DeepSeek-R1-Zero DeepSeek-R1-Zero demonstrates capabilities such as self-verification, reflection, and

    generating long CoTs, marking a significant milestone for the research community. Notably, it is the first open research to validate that reasoning capabilities of LLMs can be incentivized purely through RL, without the need for SFT. This breakthrough paves the way for future advancements in this area. まず、Supervised dataなしの強化学習のみでReasoning capabilitiesを獲得する試み 引用
  11. 16 Group Relative Policy Optimization Input Problem LLM Output 1

    Output 2 ・ ・ ・ Output G Reward 1 Reward 2 Reward G 複数の出力に対してRewardをつけ、policyを更新する。 望ましい出力に近いものが出力さ れるように最適化されていく。
  12. 17 Group Relative Policy Optimization 各出力ごとのreward Value modelが必要でない。 複数出力について、Reward modelに沿っ

    てスコア付けされ、平均スコアとの差分と Reference modelとのKullback-Leibler(KL) Divergence距離制約に基づき更新される。
  13. 18 Reward Modeling Accuracy rewards 正しい答えを得たか(数学の問題など) 指定のフォーマットに沿ったか(ボックス内に記載など) コンパイラを通してテストケースで正しい動作をしたか(LeetCode problemsのようなもの) ルールベースで評価できるようにする

    Format rewards thinking processを ‘<think>’ and ‘</think>’ tags.の間に記載するのような指定の指示に 従っているか。 prompt will be replaced with the specific reasoning question during training. training template example
  14. 20 DeepSeekMath data collection OpenWebMathをinitial seed corpusとし、fastText modelを学習させ、似たような数学問題の Web pageを探索する。

    500,000ページのpositive training examplesとnegative training examplesを設定する。 4回の繰り返しで35.5Mの数学のweb pagesを集め、120Bのtokensを得た。 4回目では98%近くは3回目ですでに得られていたデータであり、そこで終了した。
  15. 26 Cold Start まず、DeepSeek-V3-Baseを少量(数千個)の長いCoT dataによりinitial RL actorとして fine-tuneする。 DeepSeek-R1-Zeroのoutputからよさそうな出力をみつけ、人手での修正を行う。 CoT

    (Chain of Thought) data コールドスタート問題はレコメンドシステムなどでユーザーの十分なデータがないときに、 適切な推薦ができないことなどを指します。
  16. 28 Rejection Sampling and Supervised Fine-Tuning その他のタスクでの性能を上げるためのSFT(Supervised Fine-Tuning) 600kのreasoning related

    training samples. Reasoning data Non-Reasoning data writing, factual AQ, self-cognition, translationなどのnon-reasoning dataについて DeepSeek-V3のdatasetを使う。 200kのtraining samples writing, role-playing, other general-purpose tasksの能力を上げるために 他のドメインのデータを学習する。
  17. 31 Distillation Open-source modelのQwen, LlamaをDeepSeek-R1の800k samples(Reasoning data :600k, Non-Reasoning data:200k)を使ってfine-tuneする。

    Open Sourceの他の比較的小規模のモデルに対してDeepSeek-R1を使ったDistillationで reasoning capabilitiesの向上が図れないか実験する。 かなり性能向上が見られた。 小規模モデルでもGPTや Claudeの一昔前のモデルや 廉価版より高いスコアを示す。
  18. 32 Distillation v.s. Reinforcement Learning 他の小規模モデルにDistillationでなく、DeepSeek-R1のように直接大規模なReinforcement Learningをしたらどうなのか? Qwen-32B-Baseで実験する。 math, code,

    STEM dataで10K steps以上のトレーニングを実施した DeepSeek-R1-Zero-Qwen-32B 大規模Reinforcement LearningしたQwen-32Bはベースからあまり性能を改善できていないが、 Distillationのほうはかなりの性能向上が見られる。 計算資源の効率でもDistillationが有効と言える。
  19. 33 所感 DeepSeekには優秀なリサーチャー、エンジニアが多くおり、様々な論文のリサーチなどもよくした うえで、DNNの挙動などをよく観察し、様々な試行をしたうえで生み出されたのではないかという 印象を受ける。 データセット作成や学習時の調整などの勘所が色々ありそう。(簡単に再現できない) ニュースでは莫大なGPUやデータセンターがいらなくなるのではという論調もあるが、 Scaling則については否定していない。 効率的なネットワーク構造や学習方法を探索しているが、Scalingを大きくするともっと賢くな る可能性も?

    人間不在で高度で新規なデータ(問と思考・解答)が生み出されたらシンギュラリティが本当に なるかも。 ChatGPTが出た当時、巧妙な受け答えに驚いたが、簡単な算数の問題で間違うことなど指摘され たりもした。 逆に数学の問題をしっかり考えて解けるようになると(他の問題にも通じる)思考力のあるLLMが 実現したということもAha momentとして面白い。 DeepSeek LLM( https://arxiv.org/abs/2401.02954)ではScaling則についても研究している。
  20. 34 参考情報 DeepSeek-V3 Technical Report https://arxiv.org/html/2412.19437v1 DeepSeek-V2 V2: A Strong,

    Economical, and Efficient Mixture-of-Experts Language Model https://arxiv.org/abs/2405.04434 DeepSeekMoE: Towards Ultimate Expert Specialization in Mixture-of-Experts Language Models https://arxiv.org/abs/2401.06066 DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models https://arxiv.org/abs/2402.03300 DeepSeek LLM: Scaling Open-Source Language Models with Longtermism https://arxiv.org/abs/2401.02954
  21. 35 参考情報 DeepSeek-R1の論文読んだ?【勉強になるよ】 https://zenn.dev/asap/articles/34237ad87f8511 DeepSeek-R1 Paper Explained — A New

    RL LLMs Era in AI? https://medium.com/@aipapers/deepseek-r1-paper-explained-a-new-rl-llms-era-in-ai-6d3271401270 How to distill Deepseek-R1: A Comprehensive Guide https://medium.com/@prabhudev.guntur/how-to-distill-deepseek-r1-a-comprehensive-guide-c8ba04e2c28c LLMチューニングのための強化学習:GRPO(Group Relative Policy Optimization)(どこから見てもメンダコ) https://horomary.hatenablog.com/entry/2025/01/26/204545