Understanding DeepSeek R1
Aidan Bedggood đã chỉnh sửa trang này 1 tháng trước cách đây


DeepSeek-R1 is an open-source language design 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 lots of benchmarks, however it likewise includes totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to deliver strong reasoning abilities in an open and available manner.

What makes DeepSeek-R1 particularly interesting is its openness. Unlike the less-open techniques from some industry leaders, DeepSeek has published a detailed training methodology in their paper. The model is also remarkably economical, with input tokens costing simply $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 common knowledge was that better models needed more information and calculate. While that's still legitimate, designs like o1 and R1 show an alternative: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper provided several designs, however main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while intriguing, I won't discuss here.

DeepSeek-R1 utilizes 2 major ideas:

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

  1. Group Relative Policy Optimization (GRPO), a reinforcement learning method that depends on comparing several design outputs per prompt to avoid the requirement for a different critic.

    R1 and R1-Zero are both thinking designs. This basically indicates they do Chain-of-Thought before responding to. For the R1 series of designs, this takes form as believing within a tag, before answering with a final summary.

    R1-Zero vs R1

    R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is utilized to optimize the design's policy to maximize reward. R1-Zero attains outstanding accuracy however often produces confusing outputs, such as mixing several languages in a single action. R1 repairs that by incorporating restricted monitored fine-tuning and multiple RL passes, which enhances both accuracy and readability.

    It is intriguing how some languages may reveal certain ideas much better, which leads the design to pick the most meaningful language for the job.

    Training Pipeline

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

    It's intriguing that their training pipeline differs from the typical:

    The normal training strategy: Pretraining on large dataset (train to predict next word) to get the base modelsupervised fine-tuning → choice tuning via 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 few thousand Chain-of-Thought (CoT) samples to make sure the RL process has a decent starting point. This offers a great model to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and formatting (such as forcing chain-of-thought into believing tags). When they were near merging in the RL process, they transferred to the next step. The outcome of this step is a strong reasoning design however with weak basic abilities, e.g., poor formatting and language blending.
  2. basic information: Create new SFT data through rejection tasting on the RL checkpoint (from action 2), combined with supervised data from the DeepSeek-V3-Base model. They collected around 600k top quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k general tasks) for broader capabilities. This action resulted in a strong reasoning design with basic capabilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to improve the last design, in addition to the thinking rewards. The result is DeepSeek-R1. They also did design distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 models.

    Model distillation is a technique where you use an instructor design to improve a trainee design by creating training data for the trainee model. The teacher is usually a bigger model than the trainee.

    Group Relative Policy Optimization (GRPO)

    The basic idea behind utilizing reinforcement knowing for LLMs is to tweak the design's policy so that it naturally produces more accurate and beneficial answers. They utilized a reward system that checks not only for accuracy but also for appropriate format and language consistency, so the model slowly learns to prefer reactions that satisfy these quality criteria.

    In this paper, wiki.vst.hs-furtwangen.de they motivate the R1 design to generate chain-of-thought reasoning through RL training with GRPO. Rather than including a different module at reasoning time, the training process itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emerging habits of the enhanced policy.

    What makes their technique particularly intriguing is its reliance on straightforward, rule-based benefit functions. Instead of depending on costly external models or human-graded examples as in traditional RLHF, the RL utilized for R1 uses simple criteria: it may give a greater reward if the response is proper, if it follows the anticipated/ format, and if the language of the answer matches that of the timely. Not counting on a reward model also suggests you do not have to invest time 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 timely, the design creates various responses.
  3. Each response gets a scalar reward based upon aspects like precision, format, and language consistency.
  4. Rewards are changed relative to the group's performance, basically measuring how much better each reaction is compared to the others.
  5. The model updates its strategy slightly to prefer responses with higher relative advantages. It just makes slight adjustments-using techniques like clipping and a KL penalty-to guarantee the policy doesn't stray too far from its original habits.

    A cool aspect of GRPO is its flexibility. You can use basic rule-based benefit functions-for circumstances, granting a perk when the design correctly uses the syntax-to guide the training.

    While DeepSeek utilized GRPO, you might utilize alternative techniques instead (PPO or PRIME).

    For those aiming to dive deeper, Will Brown has actually composed quite a nice application of training an LLM with RL using GRPO. GRPO has also currently been included to the Transformer Reinforcement Learning (TRL) library, which is another good resource. Finally, Yannic Kilcher has a fantastic video explaining GRPO by going through the DeepSeekMath paper.

    Is RL on LLMs the path to AGI?

    As a last note on explaining DeepSeek-R1 and the approaches they've provided in their paper, I wish to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

    These findings indicate that RL boosts the design's total efficiency by rendering the output circulation more robust, to put it simply, it appears that the enhancement is attributed to boosting the appropriate reaction from TopK rather than the improvement of fundamental capabilities.

    Simply put, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more most likely to be correct, although the general ability (as measured by the diversity of right responses) is mainly present in the pretrained design.

    This suggests that support knowing on LLMs is more about refining and "forming" the existing distribution of actions instead of enhancing the design with totally new abilities. Consequently, while RL strategies such as PPO and GRPO can produce considerable performance gains, there seems an inherent ceiling determined by the underlying design's pretrained understanding.

    It is uncertain to me how far RL will take us. Perhaps it will be the stepping stone to the next huge turning point. I'm thrilled to see how it unfolds!

    Running DeepSeek-R1

    I've utilized DeepSeek-R1 through the main chat interface for numerous issues, which it seems to solve all right. The extra search functionality makes it even better to use.

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

    I likewise rented a single H100 through 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 design would perform when deployed on a single H100 GPU-not to thoroughly evaluate the model's abilities.

    671B by means of 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 running on the GPU), running through llama.cpp:

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

    Performance:

    A r/localllama user explained that they had the ability to overcome 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 completely 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 bearable for any serious work, however it's fun to run these large models on available hardware.

    What matters most to me is a combination of effectiveness and time-to-usefulness in these models. Since reasoning designs need to think before responding to, their time-to-usefulness is generally higher than other models, but their effectiveness is likewise generally higher. We require to both optimize usefulness and minimize time-to-usefulness.

    70B via Ollama

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

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

    Resources

    DeepSeek-R1: Incentivizing Reasoning Capability in LLMs by means of Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a completely local "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to reproduce o1 and the future of reasoning LMs. The Illustrated DeepSeek-R1 - by Jay Alammar. Explainer: What's R1 & Everything Else? - Tim Kellogg. DeepSeek R1 Explained to your granny - 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 combines multimodal understanding and generation. It can both understand and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking design that equals the efficiency of OpenAI's o1. It presents a detailed method for training such designs utilizing massive reinforcement learning strategies. DeepSeek-V3 Technical Report (December 2024) This report goes over the implementation of an FP8 blended accuracy training structure validated on an incredibly massive design, attaining both accelerated training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper digs into scaling laws and presents findings that facilitate the scaling of large-scale models in open-source setups. It introduces the DeepSeek LLM job, devoted to advancing open-source language designs with a long-lasting point of view. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research presents the DeepSeek-Coder series, a series of open-source code designs trained from scratch on 2 trillion tokens. The designs are pre-trained on a high-quality project-level code corpus and use a fill-in-the-blank task to improve 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 design defined by economical training and efficient inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research study introduces DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language design that attains performance comparable to GPT-4 Turbo in code-specific jobs.

    Interesting events

    - Hong Kong University replicates R1 results (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, totally open source (Jan 25, '25).
  6. OpenAI researcher verifies the DeepSeek group separately found and used some core ideas the OpenAI team used on the way to o1

    Liked this post? Join the newsletter.