Understanding DeepSeek R1
audreyireland3 módosította ezt az oldalt ekkor: 3 hónapja


DeepSeek-R1 is an open-source language model built on DeepSeek-V3-Base that's been making waves in the AI community. Not only does it match-or even surpass-OpenAI's o1 model in numerous standards, but it also comes with completely MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to provide strong reasoning capabilities in an open and available way.

What makes DeepSeek-R1 especially amazing is its openness. Unlike the less-open techniques from some market leaders, DeepSeek has released a detailed training methodology in their paper. The design is likewise incredibly 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 common wisdom was that much better models required more data and calculate. While that's still valid, models like o1 and R1 show an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented several models, however main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while intriguing, I won't discuss here.

DeepSeek-R1 utilizes 2 significant ideas:

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

  1. Group Relative Policy Optimization (GRPO), a support knowing technique that relies on comparing several design outputs per timely to prevent the need for a separate critic.

    R1 and R1-Zero are both reasoning models. This basically indicates they do Chain-of-Thought before addressing. For the R1 series of models, this takes type as thinking 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 without any supervised fine-tuning (SFT). RL is utilized to enhance the model's policy to take full advantage of benefit. R1-Zero attains exceptional precision but in some cases produces complicated outputs, such as mixing multiple languages in a single reaction. R1 repairs that by including limited monitored fine-tuning and multiple RL passes, which enhances both correctness and readability.

    It is fascinating how some languages may reveal certain ideas much better, which leads the design to pick the most expressive language for the task.

    Training Pipeline

    The training pipeline that DeepSeek published in the R1 paper is exceptionally intriguing. It showcases how they developed such strong reasoning models, and what you can anticipate from 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 normal training technique: Pretraining on big dataset (train to predict next word) to get the base design → monitored fine-tuningchoice tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL stages

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to guarantee the RL process has a decent starting point. This offers a great model to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance thinking accuracy and format (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL procedure, they transferred to the next action. The result of this step is a strong thinking design however with weak basic capabilities, e.g., bad format and language mixing. Rejection Sampling + basic information: 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 premium thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k basic jobs) for wider capabilities. This action resulted in a strong thinking model with basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the final model, in addition to the thinking rewards. The result is DeepSeek-R1. They also did design distillation for numerous Qwen and Llama models on the reasoning traces to get distilled-R1 models.

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

    Group Relative Policy Optimization (GRPO)

    The fundamental concept behind using reinforcement learning for LLMs is to fine-tune the design's policy so that it naturally produces more precise and helpful responses. They utilized a reward system that inspects not only for correctness however likewise for proper formatting and language consistency, so the design slowly learns to favor responses that satisfy these quality requirements.

    In this paper, they motivate the R1 model to generate chain-of-thought reasoning through RL training with GRPO. Rather than including a separate module at inference 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 method especially intriguing 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 used for R1 utilizes easy requirements: it may provide a greater reward if the response is appropriate, if it follows the anticipated/ format, and oke.zone if the language of the response matches that of the prompt. Not relying on a benefit model also implies you do not have to hang around and effort training it, and it does not take memory and calculate far from your main design.

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

    1. For each input prompt, the model produces various actions.
  2. Each action receives a scalar benefit based upon factors like accuracy, formatting, and language consistency.
  3. Rewards are adjusted relative to the group's performance, basically measuring just how much better each reaction is compared to the others.
  4. The design updates its strategy slightly to favor actions with higher 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 behavior.

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

    While DeepSeek used GRPO, you might utilize alternative approaches 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 utilizing GRPO. GRPO has likewise already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 approaches they've 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 show that RL boosts the design's overall efficiency by rendering the output distribution more robust, simply put, it appears that the improvement is attributed to increasing the right response from TopK instead of the improvement of fundamental capabilities.

    In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be correct, despite the fact that the overall capability (as determined by the variety of correct answers) is mainly present in the pretrained model.

    This recommends that reinforcement learning on LLMs is more about refining and "forming" the existing distribution of actions rather than enhancing the design with entirely . Consequently, gratisafhalen.be while RL techniques such as PPO and GRPO can produce considerable efficiency gains, there appears to be an intrinsic 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 turning point. I'm excited to see how it unfolds!

    Running DeepSeek-R1

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

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

    I likewise leased a single H100 via 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 carry out when released on a single H100 GPU-not to extensively evaluate the design's capabilities.

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

    29 layers seemed to be the sweet spot given this configuration.

    Performance:

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

    What matters most to me is a mix of usefulness and time-to-usefulness in these models. Since thinking designs need to think before addressing, their time-to-usefulness is typically higher than other designs, however their usefulness is likewise usually higher. We need to both take full advantage of effectiveness and lessen time-to-usefulness.

    70B via Ollama

    70.6 b params, 4-bit KM quantized DeepSeek-R1 running via 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 through Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a totally local "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe 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 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 structure that merges multimodal understanding and generation. It can both understand and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that measures up to the efficiency of OpenAI's o1. It presents a detailed methodology for training such designs using large-scale reinforcement knowing strategies. DeepSeek-V3 Technical Report (December 2024) This report talks about the application of an FP8 blended accuracy training structure verified on an incredibly large-scale model, attaining both sped up training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and provides findings that help with the scaling of large-scale designs in open-source configurations. It introduces the DeepSeek LLM project, devoted 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 presents the DeepSeek-Coder series, a series of open-source code models trained from scratch on 2 trillion tokens. The models are pre-trained on a top quality project-level code corpus and use a fill-in-the-blank task to boost 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 cost-effective training and effective inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research presents DeepSeek-Coder-V2, [users.atw.hu](http://users.atw.hu/samp-info-forum/index.php?PHPSESSID=efeb8a314d53a69367c6729a8a43e3ca&action=profile