Understanding DeepSeek R1
Alanna Burris đã chỉnh sửa trang này 7 tháng trước cách đây


DeepSeek-R1 is an open-source language model constructed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not only does it match-or even surpass-OpenAI's o1 design in numerous criteria, but it also features fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong thinking capabilities in an open and available way.

What makes DeepSeek-R1 particularly interesting is its transparency. Unlike the less-open methods from some industry leaders, DeepSeek has published a detailed training methodology in their paper. The design is also remarkably cost-effective, with input tokens costing just $0.14-0.55 per million (vs o1's $15) and output tokens at $2.19 per million (vs o1's $60).

Until ~ GPT-4, the typical knowledge was that much better models needed more data and calculate. While that's still valid, models like o1 and R1 demonstrate an option: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper presented numerous designs, however main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I will not discuss here.

DeepSeek-R1 utilizes 2 major concepts:

1. A multi-stage pipeline where a little set of cold-start information kickstarts the model, followed by large-scale RL.

  1. Group Relative Policy Optimization (GRPO), a support learning technique that depends on comparing multiple model outputs per timely to avoid the requirement for a separate critic.

    R1 and R1-Zero are both thinking models. This essentially indicates they do Chain-of-Thought before answering. For the R1 series of models, this takes kind as thinking within a tag, before answering with a last summary.

    R1-Zero vs R1

    R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is used to optimize the model's policy to optimize benefit. R1-Zero attains excellent precision but sometimes produces confusing outputs, such as mixing multiple languages in a single reaction. R1 repairs that by including limited monitored fine-tuning and larsaluarna.se multiple RL passes, which improves both accuracy and readability.

    It is interesting how some languages might reveal certain concepts much better, which leads the design to pick the most meaningful language for the task.

    Training Pipeline

    The training pipeline that DeepSeek published in the R1 paper is exceptionally fascinating. It showcases how they produced such strong thinking designs, and what you can expect from each phase. This consists of the problems that the resulting models from each phase have, and how they fixed it in the next stage.

    It's interesting that their training pipeline varies from the normal:

    The usual training strategy: Pretraining on big dataset (train to anticipate next word) to get the base model → monitored fine-tuning → preference tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL phases

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a good starting point. This gives a great model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and formatting (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL process, annunciogratis.net they moved to the next step. The outcome of this action is a strong reasoning model however with weak basic capabilities, e.g., bad format and language mixing. Rejection Sampling + basic data: Create new SFT information through rejection sampling on the RL checkpoint (from action 2), integrated with monitored data from the DeepSeek-V3-Base model. They gathered around 600k high-quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k basic tasks) for more comprehensive abilities. This action led to a strong thinking model with basic abilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the reasoning rewards. The result is DeepSeek-R1. They likewise did model distillation for several Qwen and Llama models on the thinking traces to get distilled-R1 models.

    Model distillation is a strategy where you utilize an instructor model to improve a trainee model by creating training information for the trainee design. The teacher is generally a bigger design than the trainee.

    Group Relative Policy Optimization (GRPO)

    The basic concept behind using knowing for LLMs is to tweak the design's policy so that it naturally produces more precise and useful answers. They used a benefit system that checks not just for correctness but likewise for proper formatting and language consistency, so the design slowly learns to prefer reactions that satisfy these quality requirements.

    In this paper, they motivate the R1 model to create chain-of-thought reasoning through RL training with GRPO. Instead of adding a separate module at reasoning time, the training procedure itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emerging habits of the optimized policy.

    What makes their method especially fascinating is its reliance on straightforward, rule-based benefit functions. Instead of depending on costly external models or human-graded examples as in standard RLHF, the RL used for archmageriseswiki.com R1 utilizes simple criteria: it may give a greater reward if the response is proper, if it follows the anticipated/ formatting, and if the language of the answer matches that of the prompt. Not relying on a reward model likewise implies you do not have to hang around and effort training it, and it does not take memory and compute far from your main model.

    GRPO was introduced in the DeepSeekMath paper. Here's how GRPO works:

    1. For each input prompt, the design produces various reactions.
  2. Each action receives a scalar reward based on factors like precision, format, and language consistency.
  3. Rewards are changed relative to the group's efficiency, essentially measuring how much better each reaction is compared to the others.
  4. The design updates its technique a little to favor actions with higher relative advantages. It just makes minor adjustments-using strategies like clipping and a KL penalty-to make sure the policy doesn't wander off too far from its initial behavior.

    A cool element of GRPO is its versatility. You can use easy rule-based benefit functions-for circumstances, awarding a benefit when the model correctly utilizes the syntax-to guide the training.

    While DeepSeek used GRPO, you might use alternative approaches instead (PPO or PRIME).

    For those aiming to dive much deeper, Will Brown has written rather a nice implementation of training an LLM with RL utilizing GRPO. GRPO has actually also currently been added to the Transformer Reinforcement Learning (TRL) library, which is another good resource. Finally, Yannic Kilcher has an excellent video explaining GRPO by going through the DeepSeekMath paper.

    Is RL on LLMs the path to AGI?

    As a final note on explaining DeepSeek-R1 and the methods they have actually presented in their paper, I want to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

    These findings show that RL improves the model's overall efficiency by rendering the output distribution more robust, simply put, it seems that the improvement is associated to increasing the right action from TopK instead of the improvement of essential abilities.

    In other words, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are most likely to be correct, despite the fact that the total ability (as measured by the variety of correct answers) is mainly present in the pretrained model.

    This suggests that support learning on LLMs is more about refining and "shaping" the existing distribution of responses rather than enhancing the design with entirely brand-new abilities. Consequently, while RL techniques such as PPO and GRPO can produce substantial efficiency gains, there appears to be an inherent ceiling figured out by the underlying model's pretrained knowledge.

    It is uncertain to me how far RL will take us. Perhaps it will be the stepping stone to the next big milestone. I'm delighted to see how it unfolds!

    Running DeepSeek-R1

    I've used DeepSeek-R1 by means of the main chat interface for numerous issues, which it seems to fix all right. The additional search performance makes it even nicer to use.

    Interestingly, o3-mini(-high) was released as I was writing this post. From my preliminary screening, R1 seems stronger at math than o3-mini.

    I also rented a single H100 via Lambda Labs for $2/h (26 CPU cores, 214.7 GB RAM, 1.1 TB SSD) to run some experiments. The main objective was to see how the model would carry out when released on a single H100 GPU-not to extensively check the design's capabilities.

    671B via Llama.cpp

    DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized design by Unsloth, with a 4-bit quantized KV-cache and partial GPU offloading (29 layers working on the GPU), running via llama.cpp:

    29 layers appeared to be the sweet spot offered this configuration.

    Performance:

    A r/localllama user explained that they had the ability to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their local gaming setup. Digital Spaceport wrote a complete guide on how to run Deepseek R1 671b fully in your area on a $2000 EPYC server, on which you can get ~ 4.25 to 3.5 tokens per second.

    As you can see, the tokens/s isn't rather manageable for any serious work, but it's enjoyable to run these large designs on available hardware.

    What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since thinking models need to believe before addressing, their time-to-usefulness is generally greater than other designs, but their usefulness is also generally higher. We need to both take full advantage of effectiveness and reduce time-to-usefulness.

    70B through Ollama

    70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of Ollama:

    GPU utilization soars here, as anticipated when compared to the mainly CPU-powered run of 671B that I showcased above.

    Resources

    DeepSeek-R1: Incentivizing Reasoning Capability in LLMs through Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a completely regional "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe to reproduce o1 and the future of thinking LMs. The Illustrated DeepSeek-R1 - by Jay Alammar. Explainer: What's R1 & Everything Else? - Tim Kellogg. DeepSeek R1 Explained to your grandmother - YouTube

    DeepSeek

    - Try R1 at chat.deepseek.com. GitHub - deepseek-ai/DeepSeek-R 1. deepseek-ai/Janus-Pro -7 B · Hugging Face (January 2025): Janus-Pro is an unique autoregressive structure that unifies multimodal understanding and generation. It can both understand and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking design that rivals the efficiency of OpenAI's o1. It presents a detailed approach for training such designs utilizing massive support learning techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 combined precision training structure validated on an exceptionally massive model, attaining both accelerated training and decreased GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that facilitate the scaling of large-scale designs in open-source configurations. It presents the DeepSeek LLM job, committed to advancing open-source language models with a long-term perspective. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study presents the DeepSeek-Coder series, a series of open-source code models trained from scratch on 2 trillion tokens. The models are pre-trained on a high-quality project-level code corpus and utilize a fill-in-the-blank task to boost code generation and infilling. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model (May 2024) This paper presents DeepSeek-V2, a Mixture-of-Experts (MoE) language model identified by economical training and effective reasoning. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research study presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains efficiency comparable to GPT-4 Turbo in code-specific tasks.

    Interesting occasions

    - Hong Kong University replicates R1 results (Jan 25, '25).
  5. Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to duplicate R1, fully open source (Jan 25, '25). - OpenAI researcher validates the DeepSeek team separately found and utilized some core concepts the OpenAI team utilized en route to o1

    Liked this post? Join the newsletter.