Understanding DeepSeek R1
silaswhiteside editou esta página 5 meses atrás


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 design in lots of criteria, however it likewise includes fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong thinking abilities in an open and available manner.

What makes DeepSeek-R1 particularly interesting is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has published a detailed training methodology in their paper. The model is likewise extremely cost-effective, 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 designs needed more data and compute. While that's still valid, designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.

The Essentials

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

DeepSeek-R1 uses 2 significant concepts:

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

  1. Group Relative Policy Optimization (GRPO), a reinforcement learning method that depends on comparing several model outputs per prompt to avoid the need for a separate critic.

    R1 and R1-Zero are both reasoning 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 answering with a last summary.

    R1-Zero vs R1

    R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any monitored fine-tuning (SFT). RL is used to optimize the design's policy to make the most of reward. R1-Zero attains excellent precision but sometimes produces confusing outputs, such as blending numerous languages in a single action. R1 repairs that by including minimal supervised fine-tuning and multiple RL passes, which improves both correctness and readability.

    It is interesting how some languages might reveal certain concepts better, which leads the design to select the most meaningful language for the job.

    Training Pipeline

    The training pipeline that DeepSeek released in the R1 paper is tremendously fascinating. 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 designs from each phase have, and how they fixed it in the next stage.

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

    The usual training technique: Pretraining on big dataset (train to predict next word) to get the base design → supervised fine-tuning → choice tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with numerous SFT and RL stages

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to guarantee the RL procedure has a decent beginning point. This gives a good design to start RL. First RL Stage: Apply GRPO with rule-based rewards to improve reasoning correctness and format (such as forcing chain-of-thought into thinking tags). When they were near merging in the RL procedure, they moved to the next step. The outcome of this action is a strong thinking model however with weak basic capabilities, e.g., poor format and language blending. Rejection Sampling + basic data: Create brand-new SFT information through rejection sampling on the RL checkpoint (from step 2), integrated with monitored data from the DeepSeek-V3-Base design. They collected around 600k top quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k general tasks) for broader capabilities. This step led to a strong reasoning model with general abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the final design, in addition to the reasoning benefits. The result is DeepSeek-R1. They also did model distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.

    Model distillation is a strategy where you utilize a teacher design to improve a trainee model by generating training information for the trainee design. The teacher is usually a bigger design than the trainee.

    Group Relative Policy Optimization (GRPO)

    The fundamental concept behind using reinforcement knowing for LLMs is to tweak the design's policy so that it naturally produces more precise and beneficial responses. They utilized a benefit system that checks not just for accuracy however likewise for correct formatting and language consistency, so the design gradually discovers to favor actions that meet these quality criteria.

    In this paper, they encourage the R1 design to create chain-of-thought thinking through RL training with GRPO. Instead of adding a different module at reasoning time, the training process itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the enhanced policy.

    What makes their technique particularly intriguing is its dependence on straightforward, rule-based benefit functions. Instead of depending upon pricey external designs or human-graded examples as in standard RLHF, mediawiki.hcah.in the RL utilized for R1 uses basic criteria: it may provide a higher reward if the answer is correct, if it follows the expected/ formatting, and if the language of the answer matches that of the prompt. Not relying on a benefit model also indicates you don't have to hang out and effort training it, and it doesn't take memory and calculate far from your main model.

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

    1. For each input prompt, the design produces various reactions.
  2. Each action receives a scalar benefit based on factors like accuracy, format, and language consistency.
  3. Rewards are changed relative to the group's performance, essentially measuring how much better each reaction is compared to the others.
  4. The design updates its strategy a little to prefer responses with greater relative advantages. It just makes slight adjustments-using techniques like clipping and a KL penalty-to guarantee the policy does not stray too far from its original behavior.

    A cool aspect of GRPO is its versatility. You can use simple rule-based benefit functions-for instance, granting a bonus offer when the model properly utilizes the syntax-to guide the training.

    While DeepSeek utilized GRPO, you might utilize alternative methods rather (PPO or PRIME).

    For those aiming to dive deeper, Will Brown has written quite a great execution of training an LLM with RL using GRPO. GRPO has likewise already been included 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 methodologies they have actually 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 suggest that RL improves the design's general efficiency by rendering the output distribution more robust, simply put, it seems that the improvement is credited to improving the appropriate action from TopK instead of the improvement of fundamental abilities.

    In other words, RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are most likely to be appropriate, even though the total capability (as determined by the variety of correct responses) is mainly present in the pretrained model.

    This recommends that support knowing on LLMs is more about refining and "forming" the existing distribution of reactions rather than enhancing the model with entirely new capabilities. Consequently, wikibase.imfd.cl while RL methods such as PPO and GRPO can produce significant performance gains, there appears to be 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 milestone. I'm thrilled to see how it unfolds!

    Running DeepSeek-R1

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

    Interestingly, o3-mini(-high) was released as I was writing this post. From my initial testing, R1 appears more powerful at mathematics than o3-mini.

    I also 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 model would perform when released on a single H100 GPU-not to extensively test the design'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 through llama.cpp:

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

    Performance:

    A r/localllama user explained that they were able to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their regional gaming setup. Digital Spaceport composed a complete 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 rather manageable for any serious work, however it's enjoyable to run these large models on available hardware.

    What matters most to me is a mix of effectiveness and time-to-usefulness in these models. Since thinking models need to believe before responding to, their time-to-usefulness is normally greater than other designs, but their effectiveness is also usually higher. We require to both make the most of usefulness and lessen time-to-usefulness.

    70B through Ollama

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

    GPU utilization shoots up here, as anticipated 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 replicate 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 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 a novel autoregressive structure that merges multimodal understanding and generation. It can both understand and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking model that matches the efficiency of OpenAI's o1. It presents a detailed approach for training such designs using massive reinforcement learning techniques. DeepSeek-V3 Report (December 2024) This report discusses the implementation of an FP8 mixed precision training framework confirmed on a very massive model, 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 provides findings that help with the scaling of large-scale models in open-source setups. It introduces the DeepSeek LLM job, dedicated 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 introduces the DeepSeek-Coder series, a variety of open-source code models trained from scratch on 2 trillion tokens. The designs are pre-trained on a premium 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 provides DeepSeek-V2, a Mixture-of-Experts (MoE) language design characterized by affordable training and effective reasoning. 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 design that attains performance comparable to GPT-4 Turbo in code-specific jobs.

    Interesting occasions

    - Hong Kong University reproduces R1 results (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
  5. OpenAI scientist verifies the DeepSeek team independently found and used some core concepts the OpenAI group used on the method to o1

    Liked this post? Join the newsletter.