Understanding DeepSeek R1
johniemcleay1 edited this page 5 months ago


DeepSeek-R1 is an open-source language model 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 numerous benchmarks, however it likewise comes with totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to deliver strong thinking capabilities in an open and available way.

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 approach in their paper. The design is also extremely cost-effective, 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 typical wisdom was that better designs needed more data and compute. While that's still legitimate, designs like o1 and R1 demonstrate an alternative: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper provided numerous models, but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I will not go over here.

DeepSeek-R1 utilizes 2 major ideas:

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

  1. Group Relative Policy Optimization (GRPO), a support knowing approach that counts on comparing several design outputs per timely to avoid the requirement for a different critic.

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

    R1-Zero vs R1

    R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is used to enhance the design's policy to optimize benefit. R1-Zero attains excellent accuracy however often produces confusing outputs, such as blending multiple languages in a single response. R1 repairs that by integrating minimal monitored fine-tuning and numerous RL passes, which improves both accuracy and readability.

    It is intriguing how some languages might express certain ideas better, which leads the design to select the most meaningful language for the job.

    Training Pipeline

    The training pipeline that DeepSeek published in the R1 paper is immensely interesting. It showcases how they created such strong thinking designs, and akropolistravel.com what you can anticipate from each phase. This consists of the problems that the resulting designs from each stage have, and how they fixed it in the next phase.

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

    The typical training method: Pretraining on large dataset (train to anticipate next word) to get the base model → monitored fine-tuning → preference tuning through 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 couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a decent starting point. This offers an excellent design to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance thinking accuracy and formatting (such as requiring chain-of-thought into believing tags). When they were near merging in the RL process, they transferred to the next action. The outcome of this step is a strong thinking design however with weak basic abilities, e.g., bad formatting and language mixing. Rejection Sampling + general data: 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 gathered around 600k premium reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k general tasks) for more comprehensive abilities. This step resulted in a strong reasoning design with general capabilities. Second RL Stage: addsub.wiki Add more benefit signals (helpfulness, harmlessness) to fine-tune the last design, 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 reasoning traces to get distilled-R1 models.

    Model distillation is a method where you use an instructor design to improve a trainee model by producing training information for the trainee design. The teacher is typically a larger design than the trainee.

    Group Relative Policy (GRPO)

    The standard concept behind using support learning for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and useful answers. They used a benefit system that inspects not only for accuracy however also for appropriate formatting and language consistency, so the design slowly finds out to prefer responses that satisfy these quality requirements.

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

    What makes their approach especially intriguing is its dependence on straightforward, rule-based reward functions. Instead of depending on expensive external designs or human-graded examples as in traditional RLHF, the RL used for R1 uses simple criteria: it may provide a greater reward if the response is right, if it follows the expected/ format, and if the language of the response matches that of the timely. Not relying on a reward design likewise implies you don't need to hang around 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 timely, the model produces different reactions.
  2. Each response gets a scalar benefit based upon aspects like accuracy, formatting, and language consistency.
  3. Rewards are adjusted relative to the group's efficiency, basically measuring how much better each response is compared to the others.
  4. The design updates its technique a little to favor actions with higher relative benefits. It only makes small adjustments-using techniques like clipping and a KL penalty-to guarantee the policy does not stray too far from its original habits.

    A cool aspect of GRPO is its flexibility. You can utilize simple rule-based benefit functions-for circumstances, awarding a benefit when the design correctly utilizes the syntax-to guide the training.

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

    For those aiming to dive deeper, Will Brown has written rather a good implementation of training an LLM with RL using GRPO. GRPO has actually likewise already been contributed 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 path to AGI?

    As a last note on explaining DeepSeek-R1 and the methodologies they have actually 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 model's total efficiency by rendering the output circulation more robust, simply put, it appears that the improvement is associated to enhancing the proper reaction from TopK instead of 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 most likely to be correct, despite the fact that the total capability (as measured by the diversity of appropriate answers) is mainly present in the pretrained model.

    This recommends that support knowing on LLMs is more about refining and "forming" the existing distribution of responses rather than endowing the design with completely brand-new abilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable performance gains, there appears to be an intrinsic ceiling determined 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 milestone. I'm delighted to see how it unfolds!

    Running DeepSeek-R1

    I've used DeepSeek-R1 by means of the main chat interface for different issues, which it appears to fix well enough. The extra search performance makes it even better to utilize.

    Interestingly, o3-mini(-high) was launched as I was composing this post. From my preliminary screening, R1 appears more powerful at mathematics than o3-mini.

    I likewise leased a single H100 through Lambda Labs for annunciogratis.net $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 perform when released on a single H100 GPU-not to extensively test the design's abilities.

    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 by means of llama.cpp:

    29 layers appeared to be the sweet area offered this configuration.

    Performance:

    A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, disgaeawiki.info without using their GPU on their regional video gaming setup. Digital Spaceport composed 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 quite bearable for any severe work, but it's enjoyable 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 models require to believe before answering, their time-to-usefulness is typically higher than other models, but their usefulness is also typically higher. We require to both optimize effectiveness and lessen time-to-usefulness.

    70B via 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 via Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a completely regional "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to duplicate o1 and the future of reasoning LMs. The Illustrated DeepSeek-R1 - by Jay Alammar. Explainer: humanlove.stream 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 merges multimodal understanding and generation. It can both comprehend and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that equals the efficiency of OpenAI's o1. It provides a detailed methodology for training such designs utilizing massive reinforcement learning methods. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 combined accuracy training framework validated on an incredibly massive design, attaining both sped up training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper digs into scaling laws and provides findings that help with the scaling of large-scale models in open-source configurations. It presents the DeepSeek LLM task, 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 study presents the DeepSeek-Coder series, a range of open-source code designs trained from scratch on 2 trillion tokens. The models 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 characterized by economical training and efficient inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research study presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains performance comparable to GPT-4 Turbo in code-specific jobs.

    Interesting events

    - Hong Kong University duplicates R1 results (Jan 25, '25).
  5. Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, completely open source (Jan 25, '25).
  6. OpenAI scientist validates the DeepSeek team independently discovered and utilized some core ideas the OpenAI group utilized on the method to o1

    Liked this post? Join the newsletter.