Understanding DeepSeek R1
shayna29015120 đã chỉnh sửa trang này 3 tháng trước cách đây


DeepSeek-R1 is an open-source language design 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 design in lots of standards, however it likewise includes fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong thinking abilities in an open and available way.

What makes DeepSeek-R1 especially interesting is its transparency. Unlike the less-open methods from some industry leaders, DeepSeek has published a detailed training methodology in their paper. The model is also extremely affordable, 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 needed more data and compute. While that's still legitimate, designs like o1 and trademarketclassifieds.com R1 demonstrate an alternative: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper provided numerous designs, but main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while fascinating, I will not talk about here.

DeepSeek-R1 utilizes 2 major ideas:

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

  1. Group Relative Policy Optimization (GRPO), a support learning technique that relies on comparing several design outputs per timely to prevent 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 designs, 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 monitored fine-tuning (SFT). RL is used to enhance the design's policy to take full advantage of reward. R1-Zero attains excellent precision but often produces confusing outputs, such as blending numerous languages in a single response. R1 repairs that by including restricted monitored fine-tuning and numerous RL passes, which improves both accuracy and readability.

    It is intriguing how some languages may express certain concepts better, hikvisiondb.webcam 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 immensely interesting. It showcases how they created such strong reasoning models, and what you can get out of each phase. This consists of the issues that the resulting designs from each stage have, and how they solved it in the next stage.

    It's intriguing that their training pipeline differs from the typical:

    The usual training method: Pretraining on large dataset (train to predict next word) to get the base design → monitored fine-tuning → preference tuning by means of RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with numerous SFT and RL stages

    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 good beginning point. This provides a great model to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning correctness and formatting (such as forcing chain-of-thought into believing tags). When they were near merging in the RL procedure, they relocated to the next action. The outcome of this step is a strong thinking model however with weak basic capabilities, e.g., poor format and language blending. Rejection Sampling + basic data: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), wiki.rrtn.org combined with supervised information from the DeepSeek-V3-Base design. They gathered around 600k top quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k general tasks) for wider abilities. This step resulted in a strong reasoning model with basic abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the reasoning benefits. The result is DeepSeek-R1. They likewise did model distillation for numerous Qwen and Llama designs on the thinking traces to get distilled-R1 designs.

    Model distillation is a technique where you utilize a teacher design to improve a trainee design by producing training information for the trainee model. The teacher is generally a bigger model than the trainee.

    Group Relative Policy Optimization (GRPO)

    The fundamental concept behind utilizing support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and helpful answers. They used a benefit system that examines not only for correctness however also for proper format and language consistency, so the model slowly finds out to favor responses that meet these quality criteria.

    In this paper, they encourage the R1 model to produce chain-of-thought thinking through RL training with GRPO. Rather than 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 behavior of the enhanced policy.

    What makes their approach especially fascinating is its dependence on straightforward, rule-based reward functions. Instead of depending on expensive external models or human-graded examples as in standard RLHF, the RL utilized for R1 utilizes basic criteria: it may offer a higher reward if the response is correct, if it follows the anticipated/ formatting, and if the language of the answer matches that of the prompt. Not relying on a benefit design also means you do not have to hang out and effort training it, and it doesn't take memory and compute away from your main model.

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

    1. For each input timely, the model creates different responses.
  2. Each action receives a scalar reward based on factors like accuracy, format, and language consistency.
  3. Rewards are changed relative to the group's performance, basically measuring how much better each reaction is compared to the others.
  4. The model updates its technique slightly to prefer responses with greater relative advantages. It just makes small adjustments-using strategies like clipping and a KL penalty-to make sure the policy does not wander off too far from its initial habits.

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

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

    For those aiming to dive deeper, Will Brown has actually composed quite a good application of training an LLM with RL using GRPO. GRPO has likewise currently been added to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 methods 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 indicate that RL improves the model's general performance by rendering the output distribution more robust, disgaeawiki.info in other words, it appears that the enhancement is attributed to enhancing the correct response from TopK instead of the enhancement of basic abilities.

    In other words, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are more likely to be correct, even though the total capability (as determined by the diversity of right responses) is mainly present in the pretrained design.

    This recommends that reinforcement knowing on LLMs is more about refining and "shaping" the existing distribution of reactions rather than enhancing the design with totally brand-new capabilities. Consequently, while RL methods such as PPO and GRPO can produce considerable efficiency gains, there seems an intrinsic ceiling figured out 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 big turning point. I'm thrilled to see how it unfolds!

    Running DeepSeek-R1

    I have actually used DeepSeek-R1 by means of the main chat user interface for various issues, which it appears to solve well enough. The extra search performance makes it even nicer to utilize.

    Interestingly, o3-mini(-high) was released as I was composing this post. From my preliminary testing, 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 objective was to see how the model would perform when deployed on a single H100 GPU-not to thoroughly test the model's abilities.

    671B by means of 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 area provided this setup.

    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 wrote 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 bearable for any major work, but 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 designs. Since reasoning models need to believe before addressing, their time-to-usefulness is typically greater than other models, but their effectiveness is likewise typically greater. We require to both maximize usefulness and reduce 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 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 fully regional "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to replicate o1 and the future of thinking LMs. The Illustrated DeepSeek-R1 - by . 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 unifies multimodal understanding and generation. It can both understand and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking design that matches the performance of OpenAI's o1. It presents a detailed method for training such models using large-scale support knowing strategies. DeepSeek-V3 Technical Report (December 2024) This report talks about the implementation of an FP8 combined precision training framework verified on an incredibly massive model, attaining both sped up training and lowered GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that facilitate the scaling of large-scale models in open-source configurations. It introduces the DeepSeek LLM task, committed to advancing open-source language models with a long-term 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 designs trained from scratch on 2 trillion tokens. The models are pre-trained on a high-quality project-level code corpus and utilize 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 presents DeepSeek-V2, a Mixture-of-Experts (MoE) language model characterized by cost-effective training and effective reasoning. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research introduces DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language design that attains performance equivalent to GPT-4 Turbo in code-specific jobs.

    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 duplicate R1, completely open source (Jan 25, '25).
  6. OpenAI researcher verifies the DeepSeek group independently discovered and used some core concepts the OpenAI group utilized en route to o1

    Liked this post? Join the newsletter.