Understanding DeepSeek R1
Caridad Coffee heeft deze pagina aangepast 2 maanden geleden


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 model in lots of benchmarks, but it also comes with totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to deliver strong reasoning capabilities in an open and available way.

What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open approaches from some market leaders, DeepSeek has released a detailed training method in their paper. The design is also 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 wisdom was that better designs needed more information and calculate. While that's still legitimate, designs like o1 and R1 show an alternative: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper provided 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 two major concepts:

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

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

    R1 and R1-Zero are both reasoning models. This basically suggests they do Chain-of-Thought before addressing. For the R1 series of designs, this takes type as believing within a tag, before answering with a final summary.

    R1-Zero vs R1

    R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is used to enhance the model's policy to maximize reward. R1-Zero attains excellent precision however sometimes produces confusing outputs, such as blending multiple languages in a single action. R1 repairs that by incorporating restricted monitored fine-tuning and several RL passes, which improves both correctness and readability.

    It is intriguing how some languages may reveal certain concepts better, which leads the design to pick the most meaningful language for the task.

    Training Pipeline

    The training pipeline that DeepSeek published in the R1 paper is exceptionally intriguing. It showcases how they created such strong thinking designs, and what you can anticipate from each stage. This includes the issues that the resulting designs from each stage have, and how they fixed it in the next phase.

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

    The usual training technique: Pretraining on large dataset (train to predict next word) to get the base design → monitored fine-tuning → choice tuning by means of 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 couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a decent starting point. This offers a great design to begin RL. First RL Stage: Apply GRPO with rule-based benefits to improve thinking correctness and format (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL process, they transferred to the next action. The outcome of this step is a strong thinking model but with weak general capabilities, e.g., bad format and language blending. Rejection Sampling + basic data: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), integrated with supervised data from the DeepSeek-V3-Base model. They gathered around 600k high-quality reasoning 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 basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the final model, in addition to the reasoning rewards. The result is DeepSeek-R1. They likewise did design distillation for several Qwen and Llama models on the reasoning traces to get distilled-R1 designs.

    Model distillation is a technique where you utilize a teacher design to enhance a trainee design by creating training data for the trainee design. The teacher is usually a bigger model than the trainee.

    Group Relative Policy Optimization (GRPO)

    The basic concept behind using support knowing for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and beneficial responses. They used a benefit system that inspects not just for accuracy however likewise for correct formatting and language consistency, so the design slowly finds out to favor responses that satisfy these quality criteria.

    In this paper, they motivate the R1 design to create chain-of-thought thinking through RL training with GRPO. Rather than including a different module at inference time, timeoftheworld.date the training procedure itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the optimized policy.

    What makes their technique especially fascinating is its reliance on straightforward, rule-based benefit functions. Instead of depending on pricey external designs or human-graded examples as in conventional RLHF, the RL utilized for R1 uses basic requirements: it may give a greater benefit if the response is correct, if it follows the expected/ formatting, and if the language of the response matches that of the prompt. Not counting on a benefit design also suggests you do not need to spend time and effort training it, and it doesn't take memory and compute far from your main model.

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

    1. For each input prompt, the design produces different responses.
  2. Each action receives a scalar benefit based on elements like precision, formatting, and language consistency.
  3. Rewards are changed relative to the group's efficiency, basically determining how much better each action is compared to the others.
  4. The model updates its strategy slightly to favor reactions with greater relative benefits. It just makes small adjustments-using methods like clipping and a KL penalty-to ensure the policy doesn't stray too far from its original habits.

    A cool element of GRPO is its versatility. You can utilize easy rule-based reward functions-for instance, granting a bonus offer when the model properly uses the syntax-to guide the training.

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

    For those aiming to dive much deeper, Will Brown has composed quite a good application of training an LLM with RL utilizing GRPO. GRPO has likewise currently been added to the Transformer Reinforcement Learning (TRL) library, which is another great resource. Finally, Yannic Kilcher has a terrific 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 methodologies they've provided 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 indicate that RL improves the model's general performance by rendering the output circulation more robust, simply put, it appears that the enhancement is credited to improving the right reaction from TopK instead of the improvement of basic capabilities.

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

    This suggests that reinforcement knowing on LLMs is more about refining and "forming" the existing distribution of actions rather than enhancing the design with entirely new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce considerable performance gains, there appears to be an intrinsic ceiling identified 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 thrilled to see how it unfolds!

    Running DeepSeek-R1

    I have actually utilized DeepSeek-R1 by means of the main chat interface for different problems, which it seems to fix well enough. The extra search performance makes it even nicer to utilize.

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

    I likewise 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 goal was to see how the model would carry out when released on a single H100 GPU-not to thoroughly test the design's capabilities.

    671B through Llama.cpp

    DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized design by Unsloth, with a 4-bit quantized KV-cache and partial GPU offloading (29 layers working on the GPU), running through llama.cpp:

    29 layers appeared to be the sweet area provided 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 local gaming setup. Digital Spaceport composed a full 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 quite manageable for any severe work, however it's fun to run these big models on available hardware.

    What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since reasoning designs require to believe before addressing, their time-to-usefulness is usually greater than other models, however their usefulness is also normally higher. We need to both make the most of usefulness and reduce time-to-usefulness.

    70B via Ollama

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

    GPU usage 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 via Reinforcement Learning [2402.03300] DeepSeekMath: 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 recipe to replicate 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 a novel autoregressive framework that combines multimodal understanding and generation. It can both understand and generate 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 performance of OpenAI's o1. It provides a detailed methodology for training such designs using large-scale support knowing methods. DeepSeek-V3 Technical Report (December 2024) This report discusses 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 explores scaling laws and presents findings that help with the scaling of massive models in open-source configurations. It presents the DeepSeek LLM job, devoted 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 introduces the DeepSeek-Coder series, a series of open-source code designs trained from scratch on 2 trillion tokens. The models are pre-trained on a premium project-level code corpus and employ a fill-in-the-blank job 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 affordable training and efficient 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 model that attains efficiency equivalent to GPT-4 Turbo in code-specific jobs.

    Interesting occasions

    - Hong Kong University duplicates R1 results (Jan 25, '25).
  5. Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
  6. OpenAI researcher verifies the DeepSeek group separately found and utilized some core ideas the OpenAI team utilized en route to o1

    Liked this post? Join the newsletter.