Understanding DeepSeek R1
Brodie Oliver редактировал эту страницу 3 месяцев назад


DeepSeek-R1 is an open-source language design 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 design in many benchmarks, but it likewise features fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong reasoning abilities in an open and available way.

What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open methods from some market leaders, DeepSeek has actually published a detailed training approach 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 knowledge was that much better models required more information and calculate. While that's still legitimate, models like o1 and R1 demonstrate an option: inference-time scaling through reasoning.

The Essentials

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

DeepSeek-R1 uses two significant concepts:

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

  1. Group Relative Policy Optimization (GRPO), a reinforcement knowing technique that depends on comparing numerous model outputs per prompt to prevent the requirement for a separate critic.

    R1 and menwiki.men R1-Zero are both thinking designs. This essentially suggests they do Chain-of-Thought before responding to. For the R1 series of designs, this takes type as thinking within a tag, before responding to with a last summary.

    R1-Zero vs R1

    R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is used to enhance the design's policy to take full advantage of reward. R1-Zero attains excellent accuracy however in some cases produces complicated outputs, such as mixing multiple languages in a single response. R1 repairs that by including limited monitored fine-tuning and multiple RL passes, which improves both correctness and readability.

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

    Training Pipeline

    The training pipeline that DeepSeek published in the R1 paper is immensely intriguing. It showcases how they created such strong thinking designs, and what you can get out of each phase. This includes the problems that the resulting models from each phase have, and fishtanklive.wiki how they solved it in the next phase.

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

    The typical training strategy: Pretraining on big dataset (train to predict next word) to get the base design → 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 few thousand Chain-of-Thought (CoT) samples to ensure the RL process has a decent beginning point. This gives an excellent design to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning correctness and format (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL process, they transferred to the next action. The result of this action is a strong thinking model but with weak general abilities, e.g., bad formatting and language mixing. Rejection Sampling + basic information: Create brand-new SFT information through rejection sampling on the RL checkpoint (from action 2), integrated with monitored information from the DeepSeek-V3-Base model. They gathered around 600k premium thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k general jobs) for broader capabilities. This action led to a strong thinking model with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the last model, in addition to the thinking rewards. The result is DeepSeek-R1. They also did model distillation for numerous Qwen and Llama models on the thinking traces to get distilled-R1 designs.

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

    Group Relative Policy Optimization (GRPO)

    The standard concept behind utilizing reinforcement knowing for LLMs is to fine-tune the model's policy so that it naturally produces more precise and helpful answers. They utilized a benefit system that inspects not only for accuracy but also for correct formatting and language consistency, so the model slowly learns to favor responses that meet these quality criteria.

    In this paper, they motivate the R1 design to generate chain-of-thought reasoning through RL training with GRPO. Rather than adding a separate module at reasoning time, the training procedure itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the optimized policy.

    What makes their approach particularly fascinating is its dependence on straightforward, rule-based benefit functions. Instead of depending on pricey external models or human-graded examples as in traditional RLHF, the RL utilized for R1 utilizes simple criteria: it may offer a higher benefit if the response is appropriate, if it follows the expected/ formatting, and if the language of the response matches that of the timely. Not relying on a reward design likewise indicates 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 presented in the DeepSeekMath paper. Here's how GRPO works:

    1. For each input prompt, the model creates various responses.
  2. Each response receives a scalar benefit based upon elements like precision, format, and language consistency.
  3. Rewards are adjusted relative to the group's efficiency, basically determining how much better each action is compared to the others.
  4. The model updates its method somewhat to prefer actions with greater relative benefits. It only makes slight adjustments-using techniques like clipping and a KL penalty-to ensure the policy doesn't wander off too far from its original habits.

    A cool aspect of GRPO is its versatility. You can utilize simple rule-based benefit functions-for wiki.rrtn.org circumstances, granting a perk when the model correctly utilizes the syntax-to guide the training.

    While DeepSeek utilized GRPO, you could use alternative techniques instead (PPO or PRIME).

    For those aiming to dive much deeper, Will Brown has written rather a great execution of training an LLM with RL utilizing GRPO. GRPO has also currently been added to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has an excellent 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 methods they have actually provided 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 show that RL boosts the model's total efficiency by rendering the output circulation more robust, to put it simply, it appears that the improvement is credited to enhancing the appropriate response from TopK rather than the improvement of basic abilities.

    In other words, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are more most likely to be right, even though the overall ability (as measured by the diversity of correct responses) is mainly present in the pretrained model.

    This recommends that reinforcement learning on LLMs is more about refining and "forming" the existing distribution of responses instead of enhancing the design with entirely brand-new abilities. Consequently, while RL methods such as PPO and GRPO can produce substantial performance gains, there seems an intrinsic ceiling determined 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 milestone. I'm thrilled to see how it unfolds!

    Running DeepSeek-R1

    I have actually used DeepSeek-R1 via the main chat user interface for different issues, which it appears to solve all right. The extra search performance makes it even nicer to use.

    Interestingly, o3-mini(-high) was released as I was writing this post. From my initial testing, R1 appears 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 goal was to see how the model would perform when deployed on a single H100 GPU-not to extensively test the design's capabilities.

    671B via Llama.cpp

    DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized design by Unsloth, systemcheck-wiki.de 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 area given this setup.

    Performance:

    A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their local video gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b totally locally 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, however it's fun to run these big models on available hardware.

    What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since thinking models need to think before answering, their time-to-usefulness is generally greater than other designs, however their effectiveness is likewise generally greater. We need to both optimize effectiveness and lessen time-to-usefulness.

    70B by means of Ollama

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

    GPU usage 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 through Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a fully local "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe 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 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 framework that combines multimodal understanding and generation. It can both comprehend and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source reasoning design that equals the performance of OpenAI's o1. It presents a detailed methodology for training such models using large-scale reinforcement knowing strategies. DeepSeek-V3 Technical Report (December 2024) This report discusses the implementation of an FP8 mixed precision training framework confirmed on an incredibly large-scale design, both accelerated training and minimized GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and presents findings that facilitate the scaling of large-scale designs in open-source setups. It introduces the DeepSeek LLM project, committed to advancing open-source language models 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 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 job to enhance code generation and infilling. DeepSeek-V2: A Strong, Economical, wiki.whenparked.com and forum.altaycoins.com Efficient Mixture-of-Experts Language Model (May 2024) This paper presents DeepSeek-V2, a Mixture-of-Experts (MoE) language model defined by affordable training and efficient reasoning. 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 model that attains performance equivalent to GPT-4 Turbo in code-specific jobs.

    Interesting occasions

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

    Liked this post? Join the newsletter.