Understanding DeepSeek R1
Amelie Crume upravil túto stránku 5 mesiacov pred


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

What makes DeepSeek-R1 especially exciting is its transparency. Unlike the less-open methods from some market leaders, DeepSeek has actually released a detailed training method in their paper. The design is also incredibly affordable, 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 knowledge was that much better models needed more information and compute. While that's still valid, designs like o1 and R1 show an alternative: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented multiple designs, however main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I won't discuss here.

DeepSeek-R1 uses 2 significant ideas:

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

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

    R1 and R1-Zero are both thinking models. This essentially means they do Chain-of-Thought before responding to. For the R1 series of models, this takes form as believing within a tag, before addressing with a last summary.

    R1-Zero vs R1

    R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is used to optimize the design's policy to take full advantage of benefit. R1-Zero attains excellent precision but sometimes produces complicated outputs, such as mixing multiple languages in a single reaction. R1 repairs that by including restricted supervised fine-tuning and numerous RL passes, which enhances both accuracy and readability.

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

    Training Pipeline

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

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

    The typical training strategy: Pretraining on big dataset (train to forecast next word) to get the base design → supervised fine-tuning → preference tuning by means of 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 few thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a good beginning point. This provides a great design 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 convergence in the RL process, they relocated to the next step. The result of this step is a strong reasoning model but with weak basic capabilities, e.g., poor format and language blending. Rejection Sampling + general information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), combined with monitored information from the DeepSeek-V3-Base design. They collected around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k general jobs) for more comprehensive abilities. This action resulted in a strong reasoning model with general capabilities. Second RL Stage: Add more reward signals (helpfulness, pipewiki.org harmlessness) to improve the last model, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They also did design distillation for a number of Qwen and Llama models on the thinking traces to get distilled-R1 designs.

    Model distillation is a method where you use an instructor design to enhance a trainee design by creating training information for the trainee model. The instructor is usually a bigger design than the trainee.

    Group Relative Policy Optimization (GRPO)

    The standard concept behind using reinforcement knowing for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and beneficial responses. They used a benefit system that inspects not only for accuracy but also for proper formatting and language consistency, so the design gradually discovers to favor responses that satisfy these quality criteria.

    In this paper, they motivate the R1 design to produce chain-of-thought reasoning through RL training with GRPO. Rather than including a different module at inference time, the training process itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the enhanced policy.

    What makes their method particularly interesting is its dependence on straightforward, rule-based benefit functions. Instead of depending on costly external designs or human-graded examples as in standard RLHF, the RL utilized for R1 uses easy criteria: it may provide a higher benefit if the answer is proper, accc.rcec.sinica.edu.tw if it follows the anticipated/ format, and if the language of the response matches that of the prompt. Not relying on a benefit design also suggests you do not need to invest time and effort training it, and it doesn't take memory and compute away from your main design.

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

    1. For each input timely, the design creates different responses.
  2. Each response gets a scalar benefit based upon factors like precision, format, and language consistency.
  3. Rewards are changed relative to the group's performance, essentially measuring how much better each action is compared to the others.
  4. The model updates its technique a little to prefer responses with greater relative benefits. It only makes slight 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 flexibility. You can utilize basic rule-based reward functions-for instance, granting a bonus offer when the model correctly uses the syntax-to guide the training.

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

    For those aiming to dive much deeper, Will Brown has written rather a nice execution of training an LLM with RL utilizing GRPO. GRPO has actually 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 final 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 general performance by rendering the output circulation more robust, simply put, it appears that the enhancement is credited to improving the proper reaction from TopK rather than the enhancement of basic capabilities.

    In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more most likely to be appropriate, despite the fact that the general ability (as measured by the variety of correct responses) is mainly present in the pretrained design.

    This recommends that support learning on LLMs is more about refining and "forming" the existing circulation of reactions rather than enhancing the design with completely brand-new capabilities. Consequently, while RL techniques such as PPO and GRPO can produce significant efficiency gains, ura.cc there seems an inherent 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 big turning point. I'm excited to see how it unfolds!

    Running DeepSeek-R1

    I've used DeepSeek-R1 via the main chat interface for numerous problems, which it appears to solve all right. The additional search functionality makes it even better to utilize.

    Interestingly, o3-mini(-high) was released as I was writing this post. From my preliminary screening, R1 appears more powerful at math 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 goal was to see how the design would carry out when deployed on a single H100 GPU-not to extensively check the model's capabilities.

    671B through Llama.cpp

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

    29 layers seemed to be the sweet area provided this configuration.

    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 composed a full guide on how to run Deepseek R1 671b totally 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 quite manageable for any serious work, however it's fun to run these large designs on available hardware.

    What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since thinking designs need to think before answering, their time-to-usefulness is usually greater than other models, however their effectiveness is likewise normally higher. We require to both take full advantage of effectiveness and decrease time-to-usefulness.

    70B through Ollama

    70.6 b params, 4-bit KM quantized DeepSeek-R1 running through 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 fully regional "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe to duplicate 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 grandma - 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 comprehend 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 model that rivals the performance of OpenAI's o1. It presents a detailed methodology for training such designs using large-scale reinforcement knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the implementation of an FP8 combined precision training structure validated on a very 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 assist in the scaling of large-scale designs in open-source setups. It introduces the DeepSeek LLM task, devoted to advancing open-source language designs with a long-lasting viewpoint. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research presents the DeepSeek-Coder series, a range 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 utilize a fill-in-the-blank task 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, a Mixture-of-Experts (MoE) language model identified by cost-effective 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 efficiency similar to GPT-4 Turbo in code-specific tasks.

    Interesting occasions

    - Hong Kong University reproduces R1 outcomes (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, completely open source (Jan 25, '25).
  5. OpenAI researcher verifies the DeepSeek group independently found and used some core concepts the OpenAI group utilized en route to o1

    Liked this post? Join the newsletter.