Understanding DeepSeek R1
santosiddins90 урећивао ову страницу пре 4 месеци


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

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

The Essentials

The DeepSeek-R1 paper provided multiple designs, however main amongst them were R1 and wiki.vst.hs-furtwangen.de R1-Zero. Following these are a series of distilled designs that, while intriguing, I will not talk about here.

DeepSeek-R1 uses 2 major concepts:

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

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

    R1 and R1-Zero are both thinking models. This basically indicates they do Chain-of-Thought before responding to. 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 uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any supervised fine-tuning (SFT). RL is utilized to optimize the model's policy to take full advantage of reward. R1-Zero attains outstanding precision but in some cases produces complicated outputs, such as blending multiple languages in a single action. R1 repairs that by including limited supervised fine-tuning and numerous RL passes, which improves both accuracy and readability.

    It is intriguing how some languages may express certain concepts better, which leads the model to select the most expressive language for the job.

    Training Pipeline

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

    It's intriguing that their training pipeline varies from the usual:

    The usual training technique: Pretraining on big dataset (train to predict next word) to get the base model → supervised fine-tuning → choice tuning through RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with multiple SFT and RL stages

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to make sure the RL procedure has a good beginning point. This offers a good design to start RL. First RL Stage: Apply GRPO with rule-based rewards to improve thinking correctness and format (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL process, they relocated to the next action. The outcome of this action is a strong thinking design but with weak basic capabilities, e.g., poor format and language mixing. Rejection Sampling + general data: Create brand-new SFT data through rejection sampling on the RL checkpoint (from step 2), combined with supervised data from the DeepSeek-V3-Base design. They gathered around 600k top quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k general tasks) for wider capabilities. This step led to a strong thinking design with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the final model, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They likewise did design distillation for several Qwen and Llama designs on the reasoning traces to get distilled-R1 models.

    Model distillation is a technique where you use a teacher model to enhance a trainee model by producing training data for the trainee model. The teacher is typically a larger design than the trainee.

    Group Relative Policy Optimization (GRPO)

    The fundamental idea behind using support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and helpful responses. They used a reward system that checks not only for accuracy however also for wiki.rolandradio.net proper format and language consistency, so the model gradually learns to favor actions that satisfy these quality requirements.

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

    What makes their method especially fascinating is its reliance on straightforward, rule-based benefit functions. Instead of depending on expensive external designs or human-graded examples as in standard RLHF, the RL utilized for R1 uses basic requirements: it may give a higher reward if the response is correct, if it follows the expected/ format, and if the language of the response matches that of the timely. Not relying on a benefit model also suggests you do not have to invest time 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 generates different reactions.
  2. Each reaction gets a scalar benefit based upon aspects like accuracy, 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 model updates its method slightly to favor actions with greater relative benefits. It only makes slight adjustments-using strategies like clipping and a KL penalty-to guarantee the policy doesn't stray too far from its initial habits.

    A cool aspect of GRPO is its versatility. You can use easy rule-based benefit functions-for circumstances, awarding a reward when the model correctly utilizes the syntax-to guide the training.

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

    For those aiming to dive deeper, Will Brown has written rather a good execution of training an LLM with RL utilizing GRPO. GRPO has actually also already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another good resource. Finally, Yannic Kilcher has an excellent 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 improves the design's total performance by rendering the output distribution more robust, simply put, it appears that the enhancement is associated to enhancing the proper response from TopK instead of the improvement of essential capabilities.

    In other words, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are more most likely to be correct, although the total capability (as measured by the diversity of proper responses) is mainly present in the pretrained model.

    This suggests that support learning on LLMs is more about refining and "shaping" the existing circulation of responses instead of endowing the model with completely brand-new abilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable efficiency gains, there appears to be an intrinsic ceiling determined 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 turning point. I'm thrilled to see how it unfolds!

    Running DeepSeek-R1

    I've utilized DeepSeek-R1 via the main chat interface for numerous issues, which it seems to fix well enough. The additional search functionality makes it even better to use.

    Interestingly, o3-mini(-high) was launched as I was composing this post. From my preliminary screening, R1 seems stronger at math than o3-mini.

    I also rented 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 model would carry out when deployed on a single H100 GPU-not to extensively test 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 via llama.cpp:

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

    Performance:

    A r/localllama user explained that they had the ability to get over 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 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 bearable for any major work, however it's enjoyable to run these large models on available hardware.

    What matters most to me is a combination of usefulness and time-to-usefulness in these models. Since thinking models require to think before responding to, their time-to-usefulness is usually higher than other models, but their usefulness is likewise normally higher. We need to both optimize usefulness and minimize time-to-usefulness.

    70B via Ollama

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

    GPU utilization 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 completely local "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish 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 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): Janus-Pro is an unique autoregressive structure that merges multimodal understanding and generation. It can both comprehend and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning design that equals the efficiency of OpenAI's o1. It provides a detailed methodology for training such models utilizing massive support learning techniques. DeepSeek-V3 Technical Report (December 2024) This report talks about the implementation of an FP8 blended accuracy training framework verified on an extremely large-scale model, attaining both sped up training and reduced GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and provides findings that assist in the scaling of large-scale models in open-source configurations. It introduces the DeepSeek LLM project, devoted to advancing open-source language designs 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 models 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, and Efficient Mixture-of-Experts Language Model (May 2024) This paper provides DeepSeek-V2, a Mixture-of-Experts (MoE) language design defined by cost-effective training and efficient 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 similar to GPT-4 Turbo in code-specific jobs.

    Interesting events

    - Hong Kong University replicates R1 results (Jan 25, '25).
  5. Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, totally open source (Jan 25, '25).
  6. OpenAI researcher validates the DeepSeek team separately found and used some core concepts the OpenAI team utilized on the method to o1

    Liked this post? Join the newsletter.