Understanding DeepSeek R1
smjsolomon096 редактира тази страница преди 7 месеца


DeepSeek-R1 is an open-source language design 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 numerous criteria, but it also features fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to provide strong thinking abilities in an open and available manner.

What makes DeepSeek-R1 especially exciting is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has actually published a detailed training method in their paper. The model is likewise extremely economical, 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 legitimate, models like o1 and R1 show an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented numerous designs, but main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I will not go over here.

DeepSeek-R1 uses 2 major 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 support knowing approach that relies on comparing multiple design outputs per prompt to avoid the requirement for a different critic.

    R1 and R1-Zero are both reasoning models. This essentially implies they do Chain-of-Thought before answering. For the R1 series of models, this takes kind as believing within a tag, before responding to with a last 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 enhance the model’s policy to optimize benefit. R1-Zero attains outstanding precision however sometimes produces complicated outputs, such as blending multiple languages in a single reaction. R1 repairs that by integrating limited supervised fine-tuning and numerous 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 select the most meaningful language for the job.

    Training Pipeline

    The training pipeline that DeepSeek published in the R1 paper is exceptionally intriguing. It showcases how they produced such strong thinking models, and what you can get out of each stage. This consists of the problems that the resulting designs from each stage have, and how they fixed it in the next phase.

    It’s intriguing that their training pipeline varies from the normal:

    The normal training strategy: Pretraining on large dataset (train to forecast next word) to get the base design → supervised fine-tuning → choice tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL phases

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand gratisafhalen.be Chain-of-Thought (CoT) samples to guarantee the RL procedure has a good beginning point. This gives an excellent model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to enhance thinking correctness and format (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL process, they moved to the next step. The result of this step is a strong thinking design but with weak general abilities, e.g., poor format and language mixing. Rejection Sampling + general information: Create new SFT data through rejection sampling on the RL checkpoint (from step 2), integrated with supervised data from the DeepSeek-V3-Base design. They collected around 600k high-quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k basic jobs) for broader capabilities. This step resulted in a strong thinking model with basic abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the final design, in addition to the reasoning rewards. The result is DeepSeek-R1. They also 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 use an instructor design to improve a trainee design by creating training data for the trainee design. The instructor is usually a larger model than the trainee.

    Group Relative Policy Optimization (GRPO)

    The basic concept behind utilizing reinforcement knowing for LLMs is to fine-tune the design’s policy so that it naturally produces more accurate and beneficial answers. They utilized a benefit system that inspects not just for accuracy but likewise for appropriate format and language consistency, so the model slowly discovers to prefer actions that fulfill these quality criteria.

    In this paper, they motivate the R1 model to produce chain-of-thought thinking through RL training with GRPO. Rather than adding a different module at inference time, the training procedure itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the enhanced policy.

    What makes their method especially interesting is its reliance on straightforward, rule-based reward functions. Instead of depending upon expensive external models or human-graded examples as in traditional RLHF, the RL used for R1 utilizes easy requirements: it may offer a higher reward if the response is appropriate, if it follows the anticipated/ formatting, and if the language of the answer matches that of the timely. Not counting on a reward model also indicates you don’t have to invest time and effort training it, and it doesn’t take memory and compute far from your main design.

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

    1. For each input timely, the model produces different actions.
  2. Each action receives a scalar benefit based on factors like accuracy, format, and language consistency.
  3. Rewards are adjusted relative to the group’s performance, essentially measuring just how much better each action is compared to the others.
  4. The model updates its method somewhat to prefer responses with greater relative advantages. It just makes minor adjustments-using techniques like clipping and a KL penalty-to guarantee the policy doesn’t stray too far from its original behavior.

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

    While DeepSeek utilized GRPO, you might utilize alternative techniques instead (PPO or PRIME).

    For those aiming to dive much deeper, Will Brown has actually composed rather a nice application of training an LLM with RL using GRPO. GRPO has 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 last note on explaining DeepSeek-R1 and the approaches they’ve presented in their paper, I desire to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

    These findings show that RL improves the design’s general efficiency by rendering the output distribution more robust, simply put, it appears that the enhancement is credited to improving the correct action from TopK rather than the enhancement of essential capabilities.

    In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more most likely to be appropriate, even though the overall ability (as determined by the variety of right answers) is mainly present in the pretrained model.

    This recommends that support knowing on LLMs is more about refining and “forming” the existing circulation of reactions instead of enhancing the model with totally brand-new abilities. Consequently, while RL methods such as PPO and GRPO can produce significant efficiency gains, there appears to be a fundamental ceiling identified by the underlying model’s pretrained knowledge.

    It is uncertain to me how far RL will take us. Perhaps it will be the stepping stone to the next huge turning point. I’m excited to see how it unfolds!

    Running DeepSeek-R1

    I’ve utilized DeepSeek-R1 via the main chat user interface for different problems, which it seems to solve well enough. The additional search functionality makes it even nicer to use.

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

    I also 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 goal was to see how the design would perform when deployed on a single H100 GPU-not to thoroughly evaluate the model’s abilities.

    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 through llama.cpp:

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

    Performance:

    A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their local video gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b fully 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, but 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 designs. Since reasoning models require to think before responding to, their time-to-usefulness is usually higher than other models, however their effectiveness is likewise normally higher. We require to both take full advantage of and minimize time-to-usefulness.

    70B via Ollama

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

    GPU usage shoots up 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 via Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a fully local “deep scientist” 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 grandmother - YouTube

    DeepSeek

    - Try R1 at chat.deepseek.com. GitHub - deepseek-ai/DeepSeek-R 1. deepseek-ai/Janus-Pro -7 B · Hugging Face (January 2025): wavedream.wiki Janus-Pro is an unique autoregressive framework that combines multimodal understanding and generation. It can both understand and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, bryggeriklubben.se an open-source thinking design that rivals the performance of OpenAI’s o1. It presents a detailed method for training such designs utilizing massive support learning methods. DeepSeek-V3 Technical Report (December 2024) This report talks about the implementation of an FP8 mixed precision training structure confirmed on an exceptionally massive design, funsilo.date attaining both sped up training and reduced GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and dokuwiki.stream presents findings that facilitate the scaling of large-scale designs in open-source setups. It introduces the DeepSeek LLM project, committed to advancing open-source language models with a long-lasting point of view. 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 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 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 identified by affordable training and effective 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 comparable to GPT-4 Turbo in code-specific tasks.

    Interesting events

    - Hong Kong University replicates R1 outcomes (Jan 25, ‘25).
  5. Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, completely open source (Jan 25, ‘25).
  6. OpenAI researcher confirms the DeepSeek group separately discovered and used some core concepts the OpenAI group used on the method to o1

    Liked this post? Join the newsletter.