Understanding DeepSeek R1
Adrian Blackman a édité cette page il y a 2 mois


DeepSeek-R1 is an open-source language model built on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not just does it match-or even surpass-OpenAI's o1 model in many standards, however it likewise comes with totally MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong thinking abilities in an open and available manner.

What makes DeepSeek-R1 particularly amazing is its transparency. Unlike the less-open methods from some market leaders, DeepSeek has published a detailed training approach in their paper. The design is also remarkably cost-efficient, 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 knowledge was that better designs needed more data and compute. While that's still legitimate, designs like o1 and R1 show an alternative: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper presented several models, however main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while fascinating, I will not go over here.

DeepSeek-R1 uses 2 major concepts:

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

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

    R1 and R1-Zero are both thinking designs. This basically implies they do Chain-of-Thought before addressing. For the R1 series of designs, this takes form as thinking within a tag, before answering with a last summary.

    R1-Zero vs R1

    R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is utilized to enhance the model's policy to optimize reward. R1-Zero attains excellent precision but in some cases produces confusing outputs, such as blending several languages in a single reaction. R1 repairs that by including minimal supervised fine-tuning and numerous RL passes, which enhances both correctness and readability.

    It is fascinating how some languages might reveal certain ideas much better, which leads the design to pick the most meaningful language for the job.

    Training Pipeline

    The training pipeline that DeepSeek released in the R1 paper is profoundly interesting. It showcases how they developed such strong reasoning designs, and what you can get out of each stage. This consists of the issues that the resulting models from each stage have, and how they resolved it in the next stage.

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

    The typical training method: Pretraining on big dataset (train to anticipate next word) to get the base design → supervised fine-tuningpreference tuning by means of RLHF R1-Zero: Pretrained → RL R1: PretrainedMultistage training pipeline with multiple SFT and RL phases

    Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to make sure the RL process has a decent starting point. This gives a good model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning correctness and formatting (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL procedure, they transferred to the next action. The result of this action is a strong reasoning model however with weak general abilities, e.g., poor format and language blending. Rejection Sampling + basic data: Create new SFT data through rejection tasting on the RL checkpoint (from step 2), combined with supervised information from the DeepSeek-V3-Base model. They collected around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k general tasks) for wider abilities. This step resulted in a strong reasoning design with general capabilities. Second RL Stage: wiki.whenparked.com Add more benefit signals (helpfulness, harmlessness) to improve the final model, in addition to the thinking rewards. The outcome is DeepSeek-R1. They likewise did model distillation for numerous Qwen and Llama designs on the thinking traces to get distilled-R1 models.

    Model distillation is a strategy where you use an instructor design to improve a trainee model by producing training information for the trainee model. The instructor is typically a larger model than the trainee.

    Group Relative Policy Optimization (GRPO)

    The standard idea behind using reinforcement knowing for LLMs is to tweak the model's policy so that it naturally produces more precise and beneficial responses. They utilized a reward system that inspects not only for correctness but likewise for correct formatting and language consistency, so the design slowly finds out to favor reactions that fulfill these quality requirements.

    In this paper, they encourage the R1 model to create chain-of-thought thinking through RL training with GRPO. Instead of including a different 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 enhanced policy.

    What makes their method especially fascinating is its reliance on straightforward, rule-based reward functions. Instead of depending upon pricey external designs or human-graded examples as in traditional RLHF, the RL utilized for R1 uses basic requirements: it might offer a higher benefit if the response is appropriate, if it follows the anticipated/ formatting, and if the language of the answer matches that of the prompt. Not relying on a reward design likewise suggests you don't have to spend time and effort training it, and it doesn't take memory and compute away from your main model.

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

    1. For each input prompt, the model creates different responses.
  2. Each response gets a scalar benefit based on factors like precision, bphomesteading.com format, and language consistency.
  3. Rewards are changed relative to the group's efficiency, basically measuring just how much better each action is compared to the others.
  4. The design updates its strategy slightly to prefer reactions with higher relative benefits. It just makes minor adjustments-using methods like clipping and forum.altaycoins.com a KL penalty-to make sure the policy does not stray too far from its initial habits.

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

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

    For those aiming to dive much deeper, Will Brown has actually written quite a great application of training an LLM with RL utilizing GRPO. GRPO has also currently been contributed to the Transformer Reinforcement Learning (TRL) library, which is another great resource. Finally, Yannic Kilcher has an excellent 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 wish to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

    These findings indicate that RL boosts the model's total performance by rendering the output circulation more robust, in other words, it seems that the enhancement is associated to increasing the correct action from TopK instead of the improvement of essential capabilities.

    Simply put, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are most likely to be appropriate, archmageriseswiki.com despite the fact that the total ability (as determined by the variety of correct answers) is mainly present in the pretrained design.

    This recommends that support learning on LLMs is more about refining and "forming" the existing distribution of responses rather than endowing the model with completely new abilities. Consequently, while RL techniques such as PPO and GRPO can produce substantial performance gains, there seems a fundamental ceiling determined 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 milestone. I'm thrilled to see how it unfolds!

    Running DeepSeek-R1

    I've utilized DeepSeek-R1 through the main chat user interface for different 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 mathematics than o3-mini.

    I also rented a single H100 through 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 check the design'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 through llama.cpp:

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

    Performance:

    A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional video gaming setup. Digital Spaceport wrote a complete 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 rather manageable for any severe work, however it's enjoyable to run these large models on available hardware.

    What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since reasoning models need to think before responding to, their time-to-usefulness is typically greater than other models, but their effectiveness is likewise generally higher. We require to both take full advantage of effectiveness and lessen time-to-usefulness.

    70B by means of Ollama

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

    GPU utilization shoots up here, as expected when compared to the mainly 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 regional "deep researcher" 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): Janus-Pro is an unique autoregressive framework that combines multimodal understanding and generation. It can both understand and produce 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 rivals the efficiency of OpenAI's o1. It presents a detailed method for training such models using massive reinforcement knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 combined accuracy training structure verified on an exceptionally massive design, attaining both accelerated training and reduced 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 massive models in open-source setups. It introduces the DeepSeek LLM job, dedicated to advancing open-source language designs with a long-lasting perspective. 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 task to improve code generation and humanlove.stream 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 design identified by cost-effective 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 model that attains efficiency equivalent to GPT-4 Turbo in code-specific tasks.

    Interesting events

    - Hong Kong University duplicates R1 results (Jan 25, '25). - Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, fully open source (Jan 25, '25).
  5. OpenAI scientist validates the DeepSeek group independently found and used some core ideas the OpenAI team used on the way to o1

    Liked this post? Join the newsletter.