Understanding DeepSeek R1
Alda Chastain laboja lapu 4 mēneši atpakaļ


DeepSeek-R1 is an open-source language model developed 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 also features fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to provide strong reasoning abilities in an open and available manner.

What makes DeepSeek-R1 especially exciting is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has actually published a detailed training method in their paper. The model is likewise incredibly economical, 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 better models needed more information and calculate. While that's still legitimate, designs like o1 and R1 show an option: inference-time scaling through reasoning.

The Essentials

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

DeepSeek-R1 uses 2 major ideas:

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

  1. Group Relative Policy Optimization (GRPO), a support knowing technique that relies on comparing numerous model outputs per prompt to avoid the need for a different critic.

    R1 and R1-Zero are both thinking models. This basically suggests they do Chain-of-Thought before responding to. For the R1 series of models, this takes form 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 without any monitored fine-tuning (SFT). RL is used to optimize the model's policy to optimize reward. R1-Zero attains excellent precision however often produces complicated 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 correctness and readability.

    It is fascinating how some languages might reveal certain concepts much better, which leads the model to select the most meaningful language for the task.

    Training Pipeline

    The training pipeline that DeepSeek published in the R1 paper is profoundly interesting. It showcases how they created such strong thinking models, and what you can anticipate from each stage. This includes the issues that the resulting designs from each stage have, and how they fixed it in the next stage.

    It's intriguing that their training pipeline varies from the usual:

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

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to guarantee the RL process has a decent starting point. This offers an excellent design to begin RL. First RL Stage: Apply GRPO with rule-based benefits to improve reasoning correctness and formatting (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL procedure, they transferred to the next action. The outcome of this step is a strong reasoning model but with weak basic abilities, e.g., poor formatting and language mixing. Rejection Sampling + general information: Create brand-new SFT information through rejection sampling on the RL checkpoint (from step 2), combined with supervised data from the DeepSeek-V3-Base model. They collected around 600k premium thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k general jobs) for broader abilities. This step resulted in a strong thinking model with basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the last design, in addition to the thinking benefits. The outcome is DeepSeek-R1. They also did model distillation for several Qwen and Llama models on the reasoning traces to get distilled-R1 models.

    Model distillation is a technique where you utilize an instructor model to enhance a trainee model by creating training information for the trainee model. The instructor is normally a larger design than the trainee.

    Group Relative Policy Optimization (GRPO)

    The standard idea behind using support learning for LLMs is to tweak the design's policy so that it naturally produces more accurate and helpful answers. They utilized a benefit system that inspects not only for correctness but also for appropriate formatting and language consistency, so the design slowly discovers to favor responses that satisfy these quality criteria.

    In this paper, they motivate the R1 model to generate chain-of-thought thinking through RL training with GRPO. Instead of including 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 approach especially interesting is its dependence on straightforward, rule-based reward functions. Instead of depending on costly external designs or human-graded examples as in conventional RLHF, the RL utilized for R1 uses basic criteria: it might offer a higher reward if the response is right, if it follows the anticipated/ formatting, and if the language of the answer matches that of the prompt. Not relying on a benefit design also indicates you do not have to hang out and effort training it, and it doesn't take memory and calculate away from your main design.

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

    1. For each input timely, the model generates different actions.
  2. Each response receives a scalar benefit based upon factors like precision, formatting, and language consistency.
  3. Rewards are changed relative to the group's efficiency, essentially measuring how much better each response is compared to the others.
  4. The design updates its strategy slightly to favor actions with higher relative advantages. It only makes small adjustments-using methods like clipping and a KL penalty-to make sure the policy does not wander off too far from its initial habits.

    A cool aspect of GRPO is its flexibility. You can use simple rule-based reward functions-for circumstances, awarding a perk when the design properly uses the syntax-to guide the training.

    While DeepSeek utilized GRPO, parentingliteracy.com you could utilize alternative approaches instead (PPO or PRIME).

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

    Is RL on LLMs the course to AGI?

    As a final note on explaining DeepSeek-R1 and the methodologies they have actually 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 improves the design's overall efficiency by rendering the output distribution more robust, simply put, it appears that the enhancement is attributed to improving the right response from TopK rather than the enhancement of basic abilities.

    To put it simply, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are more most likely to be appropriate, even though the general capability (as measured by the diversity of appropriate answers) is mainly present in the pretrained model.

    This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing distribution of responses instead of enhancing the design with completely new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce significant performance gains, there appears to be a fundamental ceiling figured out by the underlying model's pretrained understanding.

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

    Running DeepSeek-R1

    I've utilized DeepSeek-R1 via the main chat user interface for numerous problems, which it appears to fix all right. The extra search performance makes it even better to use.

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

    I likewise rented a single H100 by means of 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 carry out when deployed on a single H100 GPU-not to thoroughly check the model's capabilities.

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

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

    Performance:

    A r/localllama user explained that they were able to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional gaming setup. Digital Spaceport wrote 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 for any severe work, shiapedia.1god.org but it's enjoyable to run these big designs on available hardware.

    What matters most to me is a combination of effectiveness and time-to-usefulness in these designs. Since reasoning models require to think before addressing, their time-to-usefulness is generally greater than other models, visualchemy.gallery however their usefulness is likewise normally greater. We need to both maximize effectiveness and decrease time-to-usefulness.

    70B by means of Ollama

    70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:

    GPU utilization shoots up 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 dish 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 merges multimodal understanding and generation. It can both understand and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning design that equals the efficiency of OpenAI's o1. It provides a detailed method for training such models using massive reinforcement learning strategies. DeepSeek-V3 Technical Report (December 2024) This report goes over the implementation of an FP8 blended accuracy training framework confirmed on a very massive model, attaining both sped up training and reduced GPU memory usage. 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, 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 introduces 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 premium project-level code corpus and employ 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 provides DeepSeek-V2, a Mixture-of-Experts (MoE) language design defined by affordable 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 equivalent to GPT-4 Turbo in code-specific tasks.

    Interesting events

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

    Liked this post? Join the newsletter.