Understanding DeepSeek R1
lukastietjen91 于 3 月之前 修改了此页面


DeepSeek-R1 is an open-source language design built on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not only does it match-or even surpass-OpenAI's o1 model in lots of standards, but it likewise includes totally MIT-licensed weights. This marks it as the first non-OpenAI/Google model to deliver strong reasoning abilities 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 actually released a detailed training method in their paper. The model is also incredibly 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 common wisdom was that much better designs required more data and calculate. While that's still legitimate, models like o1 and R1 demonstrate an alternative: inference-time scaling through reasoning.

The Essentials

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

DeepSeek-R1 utilizes two significant concepts:

1. A multi-stage pipeline where a small set of cold-start information kickstarts the design, followed by massive RL.

  1. Group Relative Policy Optimization (GRPO), a reinforcement learning approach that depends on comparing multiple design outputs per timely to prevent the requirement for a different critic.

    R1 and fishtanklive.wiki R1-Zero are both thinking designs. This basically suggests they do Chain-of-Thought before addressing. For the R1 series of designs, this takes kind as believing within a tag, before addressing with a final summary.

    R1-Zero vs R1

    R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any supervised fine-tuning (SFT). RL is utilized to enhance the model's policy to maximize reward. R1-Zero attains outstanding accuracy however often produces confusing outputs, such as blending several languages in a single response. R1 repairs that by integrating minimal supervised fine-tuning and numerous RL passes, which improves both accuracy and readability.

    It is fascinating how some languages might express certain concepts much better, which leads the model to pick the most expressive language for the job.

    Training Pipeline

    The training pipeline that DeepSeek released in the R1 paper is profoundly intriguing. It showcases how they developed such strong reasoning models, and what you can anticipate from each phase. This includes the issues that the resulting designs from each stage have, and how they solved it in the next stage.

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

    The normal training strategy: Pretraining on large dataset (train to forecast next word) to get the base model → supervised fine-tuning → preference tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with multiple SFT and RL stages

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to make sure the RL process has a good starting point. This provides a great design to start RL. First RL Stage: Apply GRPO with rule-based rewards to enhance thinking accuracy and format (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 result of this action is a strong reasoning model however with weak general capabilities, e.g., bad formatting and language blending. Rejection Sampling + general information: Create new SFT information through rejection sampling on the RL checkpoint (from step 2), combined with monitored information from the DeepSeek-V3-Base model. They gathered around 600k premium reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic jobs) for broader capabilities. This action led to a strong reasoning design with basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the last design, in addition to the reasoning rewards. The result is DeepSeek-R1. They likewise did design distillation for numerous Qwen and Llama designs on the reasoning traces to get distilled-R1 models.

    Model distillation is a technique where you use a teacher design to improve a trainee design by producing training information for the trainee design. The teacher is generally a larger design than the trainee.

    Group Relative Policy Optimization (GRPO)

    The standard idea behind using reinforcement knowing for LLMs is to fine-tune the model's policy so that it naturally produces more precise and useful responses. They utilized a benefit system that examines not only for accuracy however likewise for proper format and language consistency, so the model slowly finds out to prefer reactions that satisfy these quality requirements.

    In this paper, they encourage the R1 design to create chain-of-thought reasoning through RL training with GRPO. Instead of including a different module at inference time, the training process itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the optimized policy.

    What makes their technique particularly fascinating is its reliance on straightforward, rule-based reward functions. Instead of depending upon pricey external designs or human-graded examples as in standard RLHF, the RL utilized for R1 uses easy criteria: it might provide a higher reward if the answer is proper, if it follows the expected/ formatting, morphomics.science and if the language of the response matches that of the timely. Not depending on a reward model likewise indicates you do not have to invest time and effort training it, and it does not take memory and calculate away from your main model.

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

    1. For each input prompt, the model produces different reactions.
  2. Each action receives a scalar benefit based upon factors like precision, format, and language consistency.
  3. Rewards are changed relative to the group's efficiency, essentially determining how much better each response is compared to the others.
  4. The design updates its strategy a little to prefer reactions with higher relative advantages. It just makes minor adjustments-using strategies like clipping and a KL penalty-to make sure the policy does not stray too far from its initial habits.

    A cool element of GRPO is its flexibility. You can use simple rule-based benefit functions-for instance, awarding a benefit when the design properly utilizes the syntax-to guide the training.

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

    For those aiming to dive much deeper, Will Brown has composed rather a nice execution of training an LLM with RL using GRPO. GRPO has also currently been contributed to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 final note on explaining DeepSeek-R1 and the methodologies they've presented in their paper, I wish to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

    These findings indicate that RL boosts the model's total performance by rendering the output circulation more robust, to put it simply, it appears that the improvement is attributed to improving the proper response from TopK instead of the enhancement of fundamental capabilities.

    To put it simply, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be proper, even though the overall capability (as measured by the variety of right responses) is mainly present in the pretrained design.

    This suggests that reinforcement learning on LLMs is more about refining and "forming" the existing circulation of actions instead of enhancing the design with completely new abilities. Consequently, while RL techniques such as PPO and GRPO can produce significant efficiency gains, there appears to be an intrinsic ceiling figured out by the underlying design's pretrained knowledge.

    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 delighted to see how it unfolds!

    Running DeepSeek-R1

    I've utilized DeepSeek-R1 through the main chat user interface for numerous problems, which it seems to resolve well enough. The additional search functionality makes it even nicer to use.

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

    I likewise leased 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 model would perform when deployed on a single H100 GPU-not to extensively test 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 via llama.cpp:

    29 layers seemed to be the sweet spot given this setup.

    Performance:

    A r/localllama user explained that they had the ability to get over 2 tok/sec with DeepSeek R1 671B, without using their GPU on their regional video 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 manageable for menwiki.men any serious work, however it's fun to run these large models on available hardware.

    What matters most to me is a combination of usefulness and time-to-usefulness in these models. Since reasoning models require to think before answering, their time-to-usefulness is usually higher than other models, akropolistravel.com however their usefulness is likewise generally greater. We need to both make the most of usefulness and lessen time-to-usefulness.

    70B by means of Ollama

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

    GPU usage 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 regional "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe to replicate 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 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 a novel autoregressive structure that combines multimodal understanding and generation. It can both comprehend and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that matches the performance of OpenAI's o1. It presents a detailed method for training such designs utilizing massive support learning techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 blended accuracy training framework confirmed on an exceptionally massive model, attaining both accelerated training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and presents findings that help with the scaling of massive models in open-source setups. It introduces the DeepSeek LLM job, committed to advancing open-source language designs with a long-term 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 variety of open-source code models trained from scratch on 2 trillion tokens. The models are pre-trained on a top quality project-level and use a fill-in-the-blank job to enhance code generation and infilling. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model (May 2024) This paper presents DeepSeek-V2, asteroidsathome.net a Mixture-of-Experts (MoE) language model defined by economical training and effective reasoning. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains performance similar to GPT-4 Turbo in code-specific jobs.

    Interesting occasions

    - Hong Kong University reproduces R1 results (Jan 25, '25).
  5. Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
  6. OpenAI scientist confirms the DeepSeek team individually discovered and utilized some core concepts the OpenAI group used en route to o1

    Liked this post? Join the newsletter.