Understanding DeepSeek R1
dominicperreau editó esta página hace 4 meses


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 design in many criteria, however it likewise comes with fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong reasoning capabilities in an open and available way.

What makes DeepSeek-R1 especially amazing is its transparency. Unlike the less-open techniques from some industry leaders, DeepSeek has actually published a detailed training approach in their paper. The model is likewise remarkably cost-efficient, 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 much better designs needed more data and compute. While that's still valid, models like o1 and R1 demonstrate an alternative: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper presented numerous designs, however main among 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 2 major concepts:

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

  1. Group Relative Policy Optimization (GRPO), cadizpedia.wikanda.es a reinforcement learning method that depends on comparing numerous design outputs per prompt to prevent the need for a different critic.

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

    R1-Zero vs R1

    R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is used to enhance the model's policy to maximize benefit. R1-Zero attains outstanding accuracy but sometimes produces confusing outputs, such as blending numerous languages in a single response. R1 repairs that by including restricted monitored fine-tuning and several RL passes, which improves both accuracy and readability.

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

    Training Pipeline

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

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

    The usual training technique: Pretraining on large dataset (train to forecast next word) to get the base design → monitored fine-tuningpreference tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with numerous 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 process has a good beginning point. This gives a good model to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and formatting (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL process, they moved to the next step. The result of this action is a strong reasoning design however with weak general abilities, wiki.myamens.com e.g., bad formatting and language mixing. Rejection Sampling + general data: Create brand-new SFT data through rejection tasting on the RL checkpoint (from step 2), integrated with monitored data 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 thinking + 200k basic jobs) for more comprehensive abilities. This action resulted in a strong reasoning design with basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the final design, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They likewise did design distillation for several Qwen and Llama designs on the thinking traces to get distilled-R1 designs.

    Model distillation is a method where you utilize an instructor model to improve a trainee design by creating training information for the trainee design. The instructor is generally a larger model than the trainee.

    Group Relative Policy Optimization (GRPO)

    The standard concept behind utilizing support learning for LLMs is to fine-tune the model's policy so that it naturally produces more precise and beneficial responses. They used a benefit system that checks not only for correctness however also for correct format and language consistency, so the model slowly discovers to favor responses that satisfy these quality requirements.

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

    What makes their method particularly interesting is its reliance on straightforward, rule-based reward functions. Instead of depending upon pricey external models or human-graded examples as in standard RLHF, the RL utilized for elearnportal.science R1 utilizes basic requirements: it may offer a greater benefit if the response is right, if it follows the expected/ formatting, and if the language of the answer matches that of the timely. Not relying on a reward model also implies you don't have to spend time and effort training it, and it does not take memory and compute away from your main design.

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

    1. For each input prompt, the design generates various actions.
  2. Each reaction receives a scalar benefit based upon factors like precision, imoodle.win format, and language consistency.
  3. Rewards are adjusted relative to the group's efficiency, basically measuring just how much better each response is compared to the others.
  4. The model updates its method a little to favor 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 original habits.

    A cool element of GRPO is its flexibility. You can use simple rule-based reward functions-for circumstances, granting a reward when the model properly utilizes the syntax-to guide the training.

    While DeepSeek used GRPO, you might utilize alternative methods rather (PPO or wiki.whenparked.com PRIME).

    For those aiming to dive deeper, Will Brown has actually composed rather a good application of training an LLM with RL using GRPO. GRPO has actually also already been contributed 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 methodologies they've presented 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 enhances the model's overall efficiency by rendering the output circulation more robust, to put it simply, it appears that the improvement is associated to improving the correct reaction from TopK rather than the improvement of fundamental abilities.

    To put it simply, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are most likely to be right, despite the fact that the total capability (as determined by the variety of right responses) is mainly present in the pretrained design.

    This suggests that support knowing on LLMs is more about refining and "forming" the existing distribution of reactions instead of enhancing the design with entirely new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce substantial performance gains, there appears to be an inherent ceiling figured out by the underlying design'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 delighted to see how it unfolds!

    Running DeepSeek-R1

    I have actually used DeepSeek-R1 by means of the main chat interface for various issues, which it seems to resolve well enough. The extra search functionality makes it even better to use.

    Interestingly, o3-mini(-high) was released as I was composing this post. From my initial testing, R1 seems 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, oke.zone 1.1 TB SSD) to run some experiments. The main objective was to see how the model would carry out when released on a single H100 GPU-not to extensively check the model'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 setup.

    Performance:

    A r/localllama user that they were able to get over 2 tok/sec with DeepSeek R1 671B, 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 rather bearable for any severe work, but 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 models. Since reasoning models require to think before addressing, their time-to-usefulness is typically higher than other models, but their effectiveness is likewise generally higher. We need to both optimize effectiveness and reduce 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 completely regional "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish 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 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 design that measures up to the performance of OpenAI's o1. It presents a detailed methodology for training such designs utilizing massive reinforcement learning techniques. DeepSeek-V3 Technical Report (December 2024) This report goes over the implementation of an FP8 mixed accuracy training framework confirmed on an incredibly massive design, attaining both accelerated training and reduced GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and presents findings that assist in the scaling of massive models in open-source setups. It introduces the DeepSeek LLM project, dedicated to advancing open-source language models with a long-lasting viewpoint. 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 series 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 employ 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 provides DeepSeek-V2, a Mixture-of-Experts (MoE) language design defined by economical 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 design that attains efficiency equivalent to GPT-4 Turbo in code-specific jobs.

    Interesting events

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

    Liked this post? Join the newsletter.