Understanding DeepSeek R1
dorotheagrassi редактировал эту страницу 1 месяц назад


DeepSeek-R1 is an open-source language design 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 design in many standards, but it also comes with totally MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong thinking capabilities in an open and available way.

What makes DeepSeek-R1 particularly interesting is its openness. Unlike the less-open approaches from some industry leaders, DeepSeek has published a detailed training approach in their paper. The model is likewise remarkably cost-effective, 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 typical wisdom was that much better designs needed more information and compute. While that's still valid, designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.

The Essentials

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

DeepSeek-R1 uses 2 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 knowing method that relies on comparing numerous model 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 thinking within a tag, before responding to 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 utilized to enhance the design's policy to make the most of reward. R1-Zero attains exceptional precision however often produces complicated outputs, such as mixing multiple languages in a single action. R1 repairs that by including restricted supervised fine-tuning and several RL passes, which enhances both accuracy and readability.

    It is fascinating how some languages may express certain concepts better, which leads the model to choose the most meaningful language for the task.

    Training Pipeline

    The training pipeline that DeepSeek released in the R1 paper is immensely interesting. It showcases how they created such strong thinking models, and what you can expect from each phase. This includes the problems that the resulting models from each phase have, and wikibase.imfd.cl how they solved it in the next stage.

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

    The typical training strategy: Pretraining on large dataset (train to predict next word) to get the base design → supervised fine-tuning → choice tuning via RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage 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 ensure the RL process has a good beginning point. This gives an excellent model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning correctness and passfun.awardspace.us formatting (such as requiring chain-of-thought into believing tags). When they were near convergence in the RL procedure, they moved to the next step. The outcome of this action is a strong thinking model but with weak basic abilities, e.g., bad format and language mixing. Rejection Sampling + basic information: Create new SFT information through rejection tasting on the RL checkpoint (from step 2), combined with monitored information from the DeepSeek-V3-Base model. They collected around 600k high-quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k basic jobs) for broader capabilities. This step led to a strong reasoning design with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They also did model distillation for a number of Qwen and archmageriseswiki.com Llama designs on the thinking traces to get distilled-R1 designs.

    Model distillation is a strategy where you utilize a teacher design to improve a trainee design by creating training information for the trainee model. The instructor is typically a larger design than the trainee.

    Group Relative Policy Optimization (GRPO)

    The standard idea behind utilizing support knowing for LLMs is to tweak the design's policy so that it naturally produces more precise and beneficial answers. They used a reward system that checks not only for correctness but likewise for correct format and language consistency, so the model slowly learns to favor actions that meet these quality criteria.

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

    What makes their technique especially fascinating is its dependence on straightforward, rule-based benefit functions. Instead of depending on costly external designs or human-graded examples as in conventional RLHF, the RL utilized for R1 uses simple criteria: it may give a greater reward if the answer is appropriate, if it follows the anticipated/ formatting, and if the language of the answer matches that of the timely. Not depending on a benefit model also implies you do not need to hang out and effort training it, and it does not take memory and compute away from your main model.

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

    1. For scientific-programs.science each input prompt, pipewiki.org the model produces various responses.
  2. Each action gets a scalar benefit based upon factors like accuracy, format, and language consistency.
  3. Rewards are changed relative to the group's efficiency, essentially determining just how much better each action is compared to the others.
  4. The design updates its method slightly to favor reactions with higher relative benefits. It just makes slight adjustments-using techniques like clipping and a KL penalty-to ensure the policy doesn't stray too far from its initial behavior.

    A cool element of GRPO is its flexibility. You can use easy rule-based reward functions-for circumstances, granting a perk when the model correctly utilizes the syntax-to guide the training.

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

    For those aiming to dive deeper, Will Brown has written rather a nice implementation of an LLM with RL using GRPO. GRPO has also already been included 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 approaches they've presented 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 design's general performance by rendering the output distribution more robust, to put it simply, it seems that the enhancement is credited to improving the right reaction from TopK rather than the improvement of essential capabilities.

    To put it simply, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more likely to be appropriate, even though the total capability (as determined by the diversity of correct answers) is mainly present in the pretrained model.

    This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing distribution of reactions instead of endowing the model with entirely brand-new abilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable efficiency 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 turning point. I'm delighted to see how it unfolds!

    Running DeepSeek-R1

    I've utilized DeepSeek-R1 by means of the main chat user interface for different issues, which it appears to solve well enough. The additional search functionality makes it even better to use.

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

    I likewise 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 objective was to see how the model would carry out when deployed on a single H100 GPU-not to extensively check the design's capabilities.

    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 running on the GPU), running via llama.cpp:

    29 layers seemed to be the sweet spot 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 video gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b totally 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 major work, however 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 models. Since thinking models need to think before responding to, their time-to-usefulness is usually higher than other models, however their usefulness is also usually greater. We require to both make the most of usefulness and reduce 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 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 totally regional "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe 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 grandma - 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 merges multimodal understanding and generation. It can both understand and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking model that rivals the efficiency of OpenAI's o1. It presents a detailed methodology for training such designs utilizing large-scale reinforcement learning techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 mixed precision training framework validated on an incredibly large-scale design, attaining both accelerated training and [mariskamast.net](http://mariskamast.net:/smf/index.php?action=profile