Understanding DeepSeek R1
Ada Owens edytuje tę stronę 6 miesięcy temu


DeepSeek-R1 is an open-source language model developed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not just does it match-or even surpass-OpenAI's o1 design in many standards, however it also comes with fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to provide strong thinking abilities in an open and available way.

What makes DeepSeek-R1 especially exciting is its transparency. Unlike the less-open approaches from some industry leaders, DeepSeek has actually released a detailed training method in their paper. The design is also remarkably cost-efficient, 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 typical wisdom was that much better designs required more information and compute. While that's still valid, models like o1 and R1 demonstrate an alternative: inference-time scaling through thinking.

The Essentials

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

DeepSeek-R1 utilizes 2 major ideas:

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

  1. Group Relative Policy Optimization (GRPO), a reinforcement knowing approach that relies on comparing multiple design outputs per timely to avoid the need for a different critic.

    R1 and R1-Zero are both thinking models. This essentially implies they do Chain-of-Thought before addressing. For the R1 series of designs, this takes type as believing within a tag, before responding to with a final 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 enhance the model's policy to take full advantage of reward. R1-Zero attains exceptional precision but sometimes produces complicated outputs, such as blending several languages in a single reaction. R1 repairs that by incorporating limited supervised fine-tuning and numerous RL passes, which improves both correctness and readability.

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

    Training Pipeline

    The training pipeline that DeepSeek released in the R1 paper is tremendously fascinating. It showcases how they developed such strong thinking designs, and what you can anticipate from each phase. This consists of the problems that the resulting designs from each phase have, and how they resolved it in the next phase.

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

    The usual training strategy: Pretraining on big dataset (train to anticipate next word) to get the base design → supervised fine-tuning → choice tuning via 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 couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a decent beginning point. This gives a good model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and formatting (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL procedure, they transferred to the next action. The result of this action is a strong reasoning model however with weak general abilities, e.g., poor formatting and language blending. Rejection Sampling + basic data: Create new SFT information through rejection sampling on the RL checkpoint (from step 2), integrated with supervised data from the DeepSeek-V3-Base model. They gathered around 600k premium reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k basic jobs) for more comprehensive capabilities. This step resulted in a strong reasoning model with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the last model, in addition to the thinking benefits. The outcome is DeepSeek-R1. They also did model distillation for wiki.vst.hs-furtwangen.de a number of Qwen and Llama models on the reasoning traces to get distilled-R1 models.

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

    Group Relative Policy Optimization (GRPO)

    The fundamental concept behind utilizing reinforcement knowing for LLMs is to tweak the model's policy so that it naturally produces more accurate and helpful answers. They utilized a benefit system that checks not just for accuracy but also for correct format and language consistency, so the model slowly learns to prefer reactions that meet these quality requirements.

    In this paper, they encourage the R1 model to create chain-of-thought thinking through RL training with GRPO. Rather than including a different module at inference time, the training process itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the enhanced policy.

    What makes their technique especially fascinating is its reliance on straightforward, rule-based reward functions. Instead of depending upon expensive external models or human-graded examples as in standard RLHF, the RL utilized for R1 uses basic criteria: it might provide a higher reward if the response is right, if it follows the expected/ formatting, and if the language of the response matches that of the prompt. Not relying on a benefit design also implies you don't need to hang around and effort training it, and it doesn't take memory and calculate away from your main design.

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

    1. For each input prompt, the model creates different responses.
  2. Each action receives a scalar reward based on elements like precision, format, and language consistency.
  3. Rewards are adjusted relative to the group's efficiency, essentially determining just how much better each action is compared to the others.
  4. The design updates its technique slightly to prefer responses with greater relative benefits. It just makes minor links.gtanet.com.br adjustments-using techniques like clipping and raovatonline.org a KL penalty-to guarantee the policy doesn't wander off too far from its initial habits.

    A cool aspect of GRPO is its flexibility. You can utilize basic rule-based reward functions-for instance, granting a reward when the model properly uses the syntax-to guide the training.

    While DeepSeek utilized GRPO, you might use alternative methods instead (PPO or PRIME).

    For those aiming to dive much deeper, Will Brown has actually composed rather a great execution of training an LLM with RL using GRPO. GRPO has actually likewise currently been added to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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've provided in their paper, I desire to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

    These findings suggest that RL boosts the design's total performance by rendering the output distribution more robust, to put it simply, it appears that the improvement is credited to increasing the proper response from TopK instead of the enhancement of essential abilities.

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

    This recommends that support learning on LLMs is more about refining and "shaping" the existing circulation of actions instead of enhancing the model with completely new capabilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable performance gains, there seems 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 milestone. I'm excited to see how it unfolds!

    Running DeepSeek-R1

    I have actually utilized DeepSeek-R1 via the main chat user interface for different problems, which it seems to fix all right. The additional 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 math than o3-mini.

    I also 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 was to see how the design would perform when released on a single H100 GPU-not to thoroughly 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 working on the GPU), running by means of llama.cpp:

    29 layers appeared to be the sweet spot provided this setup.

    Performance:

    A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional gaming setup. Digital Spaceport wrote a complete guide on how to run Deepseek R1 671b totally locally on a $2000 EPYC server, koha-community.cz on which you can get ~ 4.25 to 3.5 tokens per second.

    As you can see, the tokens/s isn't quite manageable for any severe work, lovewiki.faith but it's fun to run these big models 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 responding to, their time-to-usefulness is typically greater than other designs, but their effectiveness is also usually greater. We require to both make the most of effectiveness and minimize time-to-usefulness.

    70B through Ollama

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

    GPU usage 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 via Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a totally regional "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 a novel autoregressive framework that merges multimodal understanding and generation. It can both comprehend and create 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 approach for training such designs utilizing large-scale support learning techniques. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 blended precision training framework validated on an exceptionally massive model, attaining both sped up training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and provides findings that facilitate the scaling of massive designs in open-source setups. It presents the DeepSeek LLM project, committed to advancing open-source language designs with a long-lasting perspective. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study introduces the DeepSeek-Coder series, a variety of open-source code models trained from scratch on 2 trillion tokens. The models 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 defined 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 design that attains efficiency equivalent to GPT-4 Turbo in code-specific jobs.

    Interesting events

    - Hong Kong University reproduces R1 results (Jan 25, '25).
  5. Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, fully open source (Jan 25, '25).
  6. OpenAI scientist validates the DeepSeek group individually discovered and used some core ideas the OpenAI group used on the way to o1

    Liked this post? Join the newsletter.