Understanding DeepSeek R1
DeepSeek-R1 is an open-source language model developed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not only does it match-or even surpass-OpenAI's o1 design in lots of benchmarks, however it likewise includes fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong thinking capabilities in an open and available manner.
What makes DeepSeek-R1 particularly interesting is its transparency. Unlike the less-open approaches from some industry leaders, DeepSeek has published a detailed training approach in their paper.
The design is likewise 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 better designs needed more data and compute. While that's still valid, designs like o1 and R1 show an option: inference-time scaling through reasoning.
The Essentials
The DeepSeek-R1 paper presented several designs, however main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I won't discuss here.
DeepSeek-R1 utilizes 2 major ideas:
1. A multi-stage pipeline where a little set of cold-start data kickstarts the design, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a support learning approach that counts on comparing numerous model outputs per prompt to avoid the requirement for a separate critic.
R1 and R1-Zero are both reasoning models. This basically indicates they do Chain-of-Thought before answering. For the R1 series of models, this takes kind as believing 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 supervised fine-tuning (SFT). RL is utilized to enhance the model's policy to take full advantage of benefit.
R1-Zero attains excellent accuracy but in some cases produces complicated outputs, such as blending multiple languages in a single reaction. R1 repairs that by including restricted monitored fine-tuning and numerous RL passes, which enhances both correctness and readability.
It is interesting how some languages might reveal certain concepts better, which leads the model to pick the most expressive language for the task.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is tremendously interesting. It showcases how they developed such strong thinking models, and what you can expect from each stage. This consists of the problems that the resulting designs from each phase have, and how they solved it in the next phase.
It's intriguing that their training pipeline varies from the normal:
The typical training strategy: Pretraining on big dataset (train to forecast next word) to get the base design → monitored fine-tuning → preference tuning via 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 few thousand Chain-of-Thought (CoT) samples to guarantee the RL procedure 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 accuracy and format (such as requiring chain-of-thought into believing tags). When they were near convergence in the RL procedure, they relocated to the next step. The outcome of this step is a strong reasoning design however with weak general capabilities, e.g., poor format and language mixing.
Rejection Sampling + general data: Create new SFT information through rejection sampling on the RL checkpoint (from step 2), integrated with supervised data from the DeepSeek-V3-Base model. They gathered around 600k top quality thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k basic jobs) for more comprehensive abilities. This step resulted in a strong reasoning model with basic abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the final model, in addition to the thinking benefits. The outcome is DeepSeek-R1.
They also did design distillation for several Qwen and Llama models on the thinking traces to get distilled-R1 designs.
Model distillation is a strategy where you utilize an instructor model to improve a trainee design by generating training information for the trainee model.
The teacher is usually a bigger model than the trainee.
Group Relative Policy Optimization (GRPO)
The basic idea behind utilizing support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and beneficial responses.
They utilized a reward system that examines not only for accuracy however likewise for appropriate formatting and language consistency, so the design slowly finds out to favor actions that meet these quality requirements.
In this paper, they encourage the R1 design to generate chain-of-thought thinking through RL training with GRPO.
Rather than including a separate module at reasoning time, the training process itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the optimized policy.
What makes their method particularly fascinating is its dependence on straightforward, rule-based reward functions.
Instead of depending on pricey external designs or human-graded examples as in standard RLHF, the RL used for R1 utilizes easy requirements: it may provide a higher benefit if the answer is right, if it follows the expected/ formatting, and if the language of the response matches that of the prompt.
Not counting on a benefit model likewise suggests you don't need to hang out and effort training it, and it does not take memory and calculate away from your main model.
GRPO was introduced in the DeepSeekMath paper. Here's how GRPO works:
1. For each input prompt, the design generates different reactions.
2. Each response gets a scalar reward based on aspects like precision, formatting, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, essentially determining how much better each reaction is compared to the others.
4. The model updates its a little to prefer actions with greater relative advantages. It only makes slight adjustments-using methods like clipping and a KL penalty-to guarantee the policy doesn't wander off too far from its initial habits.
A cool aspect of GRPO is its flexibility. You can utilize basic rule-based reward functions-for circumstances, granting a benefit when the design correctly utilizes the syntax-to guide the training.
While DeepSeek utilized GRPO, you could utilize alternative techniques rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has actually composed quite a nice implementation of training an LLM with RL utilizing GRPO. GRPO has actually also currently been added to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource.
Finally, Yannic Kilcher has a terrific 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 have actually provided in their paper, I want to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.
These findings suggest that RL boosts the design's overall performance by rendering the output circulation more robust, simply put, it seems that the improvement is credited to increasing the appropriate response from TopK instead of the enhancement of fundamental capabilities.
To put it simply, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more most likely to be proper, despite the fact that the total ability (as measured by the variety of appropriate answers) is mainly present in the pretrained model.
This recommends that reinforcement knowing on LLMs is more about refining and "shaping" the existing distribution of reactions rather than enhancing the model with completely new capabilities.
Consequently, while RL techniques such as PPO and GRPO can produce considerable performance gains, there appears to be a fundamental 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 huge milestone. I'm delighted to see how it unfolds!
Running DeepSeek-R1
I have actually utilized DeepSeek-R1 via the main chat user interface for numerous issues, which it appears to solve all right. The additional search functionality makes it even better to utilize.
Interestingly, pl.velo.wiki o3-mini(-high) was released as I was writing this post. From my preliminary testing, R1 seems more powerful at mathematics 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 design would perform when deployed on a single H100 GPU-not to thoroughly evaluate the model'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 working on the GPU), running through llama.cpp:
29 layers seemed to be the sweet spot provided this configuration.
Performance:
A r/localllama user explained that they were able to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional video gaming setup.
Digital Spaceport composed a complete 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 rather manageable for any severe work, but 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 need to think before responding to, their time-to-usefulness is usually higher than other models, however their usefulness is also generally greater.
We require to both maximize effectiveness and lessen 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 by means of Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a completely regional "deep scientist" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to reproduce 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 framework that combines 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 reasoning model that matches the efficiency of OpenAI's o1. It presents a detailed method for training such models using massive support learning strategies.
DeepSeek-V3 Technical Report (December 2024) This report talks about the implementation of an FP8 blended accuracy training structure verified on an extremely massive 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 presents findings that assist in the scaling of large-scale models in open-source configurations. It presents the DeepSeek LLM task, dedicated 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 introduces the DeepSeek-Coder series, a variety of open-source code designs trained from scratch on 2 trillion tokens. The designs are pre-trained on a high-quality project-level code corpus and use a fill-in-the-blank task 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 economical training and effective inference.
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 performance comparable to GPT-4 Turbo in code-specific jobs.
Interesting occasions
- Hong Kong University reproduces R1 results (Jan 25, '25).
- Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, totally open source (Jan 25, '25).
- OpenAI scientist validates the DeepSeek group individually found and utilized some core concepts the OpenAI group used on the method to o1
Liked this post? Join the newsletter.