Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 58

DeepSeek-R1: Final RL Stage for Alignment

Recommended resources

Introduction

Welcome to the final lesson in our module on GRPO and Emergent Reasoning. In our last session, we dissected the rejection sampling stage of the DeepSeek-R1 pipeline. We saw how the specialized but unpolished R1-Zero model was used as a data factory to generate a large, high-quality Supervised Fine-Tuning (SFT) dataset. By fine-tuning the original base model on this curated data, the developers created an intermediate model that possesses strong reasoning abilities and is also a proficient instruction-follower.

However, the journey isn't over. This model, while capable, has not been explicitly trained to be "helpful" or "safe" in the way humans expect from a top-tier assistant. This lesson focuses on the crucial final step that transforms the model from a powerful reasoning engine into a polished, reliable, and user-friendly product.

Our learning outcome is to explain the purpose of the final general RL stage in the DeepSeek-R1 pipeline for aligning the model toward general helpfulness and safety. We will explore how a final round of Reinforcement Learning (RL), using a more diverse set of rewards, completes the alignment process.



The Need for a Final Alignment Stage

The model entering this final stage is already quite advanced. Thanks to the SFT process, it can produce well-structured, readable reasoning chains. So, why is another RL stage necessary?

The reason lies in the model's objective function up to this point. It has been optimized for two main things:

  1. Correctness on reasoning tasks (math, code, logic).
  2. Following instructions from the SFT dataset.

This leaves some critical gaps. The model might be an "antisocial mathematician"—brilliant at solving problems but unhelpful for general conversation. If you ask it "Hello," it might launch into a complex proof because that's the behavior it has been most rewarded for. Furthermore, it has no explicit guardrails against generating biased, unsafe, or otherwise harmful content.

This final stage is designed to address these gaps, aligning the model with broader human values beyond mere correctness.

DeepSeek-R1 Training Pipeline Overview
This diagram shows the full pipeline. We have covered the Cold Start (1), Reasoning RL (2), and Rejection Sampling SFT (3). We now focus on the final stage, Diverse RL (4), which is designed for general alignment.


The General Reinforcement Learning Stage

This final stage is another round of reinforcement learning, but its goal and methods are different from the "Reasoning RL" stage we studied earlier. The objective here is to make the model a well-rounded assistant.

To get a high-level overview of how this stage fits into the complete pipeline and introduces the key concepts of "helpfulness" and "harmlessness," let's watch the following segment.

How to Train LLMs to "Think" (o1 & DeepSeek-R1)

Shaw Talebi's video 'How to Train LLMs to "Think"' provides an excellent summary of the full DeepSeek R1 pipeline, clearly explaining the motivation for this final alignment step.

Please watch from 23:35 to 29:13. Pay close attention to the description of the final step, which involves 'Reinforcement Learning with Human Feedback,' and the introduction of 'helpfulness' and 'harmlessness' as key training dimensions.

As the video explains, this stage introduces new dimensions to the training process. The model must now learn to balance its reasoning capabilities with the nuanced, and often subjective, goals of being helpful and safe.


From Rules to Preferences: A Hybrid Reward System

The key innovation in this stage is the shift in reward signals. The rule-based rewards used for R1-Zero (e.g., is_answer_correct()) are perfect for objective tasks like math and coding. However, they cannot capture subjective qualities like:

  • Is this summary useful?
  • Is this response polite and respectful?
  • Does this answer avoid harmful stereotypes?

To teach the model these qualities, the DeepSeek team employed reward models trained on human preference data, a technique often called Reinforcement Learning from Human Feedback (RLHF). This leads to a hybrid approach.

Let's read a clear, concise summary of this phase.

The Illustrated DeepSeek-R1

Jay Alammar's blog, 'The Illustrated DeepSeek-R1,' offers a digestible explanation of how this general RL phase works.

Please read section '3.3 General RL training phase'. Note how it highlights the use of helpfulness and safety reward models specifically for non-reasoning applications, which distinguishes this stage from the earlier RL phase.

Now, for the most precise description, we'll turn to the original research paper. It details exactly how different data types were handled during this final alignment.

DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via ...

The DeepSeek-R1 paper provides the definitive account of this final RL stage.

Please read the paragraph following section '2.3.3 Rejection Sampling and Supervised Fine-Tuning.' Focus on how the training process uses different reward signals for 'reasoning data' versus 'general data' and how the paper defines the goals of helpfulness and harmlessness.

Synthesizing the Approach

The readings confirm a sophisticated, two-pronged reward strategy within the same RL loop:

  1. For Reasoning Data: The training continues to use rule-based rewards and the GRPO algorithm. This ensures the model's hard-won mathematical and logical reasoning skills are maintained and even sharpened.
  2. For General Data: For prompts involving creative writing, summarization, or general Q&A, the training uses reward models. These models were trained on human preference datasets to predict whether a given response is "helpful" and "harmless."

By training on a diverse distribution of prompts and applying the appropriate reward signal for each, the model learns to be a polymath: a specialist reasoner when needed and a helpful generalist otherwise.

  • Helpfulness is typically evaluated on the final answer or summary, ensuring the model provides a direct and useful response.
  • Harmlessness is evaluated on the entire output, including the chain-of-thought, to catch any problematic content, biases, or safety risks.

This final alignment is what makes the model suitable for public deployment, leading to the strong performance on general-purpose benchmarks like AlpacaEval noted in the paper.



Conclusion

In this lesson, we have explored the final and crucial alignment stage of the DeepSeek-R1 pipeline. This step is what elevates the model from a powerful but specialized tool into a well-rounded, safe, and user-friendly AI assistant.

Key Takeaways:

  • Purpose: The final RL stage aims to align the model for general helpfulness and harmlessness, addressing gaps left by the reasoning-focused SFT and initial RL stages.
  • Hybrid Rewards: It uses a dual-reward system:
    • Rule-based rewards continue to be used for reasoning tasks to maintain high accuracy.
    • Preference-based reward models (from RLHF) are used for general tasks to teach subjective qualities like politeness, utility, and safety.
  • Outcome: This process produces a final, aligned model (DeepSeek-R1) that excels at both specialized reasoning and general conversation, making it ready for real-world application.

This concludes our deep dive into the training pipeline of a state-of-the-art reasoning model. We have followed the entire journey, from a base model to a fully aligned reasoning specialist.

Preview of the Next Lesson:

Having mastered the architecture and training of a powerful text-based model, we will now broaden our scope. In the next module, we will explore Multimodal Models and Specialist LLMs. We will investigate how models like GPT-4o and Qwen2.5-Omni process not just text, but also images and audio, and how specialized datasets are used to create expert models for domains like advanced coding.