Understanding DeepSeek R1
Vernon Beg 於 6 月之前 修改了此頁面


DeepSeek-R1 is an open-source language design constructed 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 many standards, however it likewise includes completely MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong reasoning abilities in an open and available manner.

What makes DeepSeek-R1 particularly exciting is its transparency. Unlike the less-open techniques from some industry leaders, DeepSeek has published a detailed training method in their paper. The model is also incredibly economical, 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 common wisdom was that much better models required more data and calculate. While that's still valid, designs like o1 and R1 demonstrate an option: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper provided several designs, but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while fascinating, I will not discuss here.

DeepSeek-R1 uses 2 major ideas:

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

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

    R1 and R1-Zero are both thinking designs. This essentially suggests they do Chain-of-Thought before addressing. For the R1 series of designs, this takes kind 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 supervised fine-tuning (SFT). RL is utilized to optimize the design's policy to make the most of reward. R1-Zero attains exceptional precision however often produces confusing outputs, such as blending numerous languages in a single reaction. R1 repairs that by integrating restricted supervised fine-tuning and numerous RL passes, which improves both correctness and readability.

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

    Training Pipeline

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

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

    The normal training method: Pretraining on big dataset (train to forecast next word) to get the base design → monitored fine-tuning → by means of RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL phases

    Cold-Start Fine-Tuning: wavedream.wiki Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to guarantee the RL procedure has a good beginning point. This provides a good design to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance thinking correctness 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 step is a strong reasoning model but with weak basic abilities, e.g., poor vmeste-so-vsemi.ru format and language blending. Rejection Sampling + general information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from step 2), combined 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 reasoning + 200k basic tasks) for broader capabilities. This action resulted in a strong reasoning design with general capabilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to improve the last design, in addition to the reasoning rewards. The outcome is DeepSeek-R1. They likewise did model distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.

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

    Group Relative Policy Optimization (GRPO)

    The fundamental idea behind using support knowing for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and useful responses. They used a reward system that inspects not only for correctness however likewise for appropriate formatting and language consistency, so the model slowly finds out to prefer reactions that fulfill these quality requirements.

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

    What makes their approach especially intriguing is its reliance on straightforward, rule-based benefit functions. Instead of depending on pricey external designs or human-graded examples as in standard RLHF, the RL utilized for R1 uses basic requirements: it might give a higher reward if the response is proper, if it follows the expected/ formatting, and if the language of the response matches that of the prompt. Not counting on a benefit model also means you don't have to hang out and effort training it, and it does not take memory and calculate far from your main model.

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

    1. For each input prompt, the model creates various reactions.
  2. Each action gets a scalar reward based on aspects like precision, formatting, and language consistency.
  3. Rewards are changed relative to the group's efficiency, essentially determining how much better each response is compared to the others.
  4. The design updates its method somewhat to prefer responses with greater relative benefits. It only makes small 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 aspect of GRPO is its flexibility. You can utilize simple rule-based reward functions-for instance, granting a benefit when the design correctly utilizes the syntax-to guide the training.

    While DeepSeek used GRPO, trademarketclassifieds.com you could use alternative methods instead (PPO or PRIME).

    For those aiming to dive much deeper, Will Brown has actually written rather a nice implementation of training an LLM with RL using GRPO. GRPO has actually likewise currently been included to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has a great 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 methods they have actually presented in their paper, I wish to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

    These findings show that RL boosts the model's general performance by rendering the output distribution more robust, to put it simply, it seems that the improvement is attributed to boosting the proper reaction from TopK instead of the enhancement of essential abilities.

    To put it simply, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be right, even though the overall capability (as measured by the variety of correct responses) is mainly present in the pretrained design.

    This recommends that reinforcement knowing on LLMs is more about refining and "shaping" the existing circulation of reactions rather than endowing the design with entirely brand-new abilities. Consequently, while RL methods such as PPO and GRPO can produce significant performance gains, there seems an intrinsic ceiling identified 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 huge milestone. I'm delighted to see how it unfolds!

    Running DeepSeek-R1

    I have actually utilized DeepSeek-R1 via the main chat interface for different issues, which it appears to solve well enough. The additional search performance makes it even nicer to use.

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

    I also leased a single H100 via Lambda Labs for $2/h (26 CPU cores, prawattasao.awardspace.info 214.7 GB RAM, 1.1 TB SSD) to run some experiments. The main objective was to see how the design would carry out when deployed on a single H100 GPU-not to extensively evaluate the design's abilities.

    671B via Llama.cpp

    DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized design by Unsloth, tandme.co.uk with a 4-bit quantized KV-cache and partial GPU offloading (29 layers running on the GPU), links.gtanet.com.br running by means of llama.cpp:

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

    Performance:

    A r/localllama user explained that they were able to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional 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 manageable for any serious work, but it's fun to run these large designs on available hardware.

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

    70B by means of Ollama

    70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of Ollama:

    GPU usage soars 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 completely local "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe to duplicate 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 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 combines multimodal understanding and generation. It can both understand and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source reasoning design that rivals the efficiency of OpenAI's o1. It provides a detailed method for training such designs utilizing massive support knowing methods. DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 combined precision training structure validated on an incredibly large-scale model, attaining both sped up training and decreased GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and presents findings that assist in the scaling of large-scale models in open-source setups. It introduces the DeepSeek LLM job, devoted to advancing open-source language models with a long-term 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 variety 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 employ a fill-in-the-blank job to enhance code generation and infilling. DeepSeek-V2: A Strong, Economical, thatswhathappened.wiki and Efficient Mixture-of-Experts Language Model (May 2024) This paper provides DeepSeek-V2, a Mixture-of-Experts (MoE) language model 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 design that attains performance equivalent to GPT-4 Turbo in code-specific tasks.

    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, completely open source (Jan 25, '25). - OpenAI scientist verifies the DeepSeek group separately discovered and used some core concepts the OpenAI group utilized on the method to o1

    Liked this post? Join the newsletter.