Understanding DeepSeek R1
DeepSeek-R1 is an open-source language design built 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 many benchmarks, however it likewise features fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to provide strong reasoning abilities in an open and available manner.
What makes DeepSeek-R1 especially exciting is its openness. Unlike the less-open techniques from some industry leaders, DeepSeek has actually released a detailed training method in their paper.
The design is also incredibly 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 typical wisdom was that much better designs required more information and compute. While that's still legitimate, models like o1 and R1 demonstrate an alternative: inference-time scaling through thinking.
The Essentials
The DeepSeek-R1 paper provided multiple models, but main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I will not discuss here.
DeepSeek-R1 utilizes two significant ideas:
1. A multi-stage pipeline where a small set of cold-start data kickstarts the design, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a reinforcement learning approach that depends on comparing numerous model outputs per timely to prevent the need for a different critic.
R1 and R1-Zero are both reasoning designs. This essentially suggests they do Chain-of-Thought before responding to. For the R1 series of models, this takes form as believing within a tag, before answering with a final summary.
R1-Zero vs R1
R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is used to optimize the model's policy to take full advantage of benefit.
R1-Zero attains outstanding accuracy but in some cases produces complicated outputs, such as mixing multiple languages in a single response. R1 repairs that by integrating minimal supervised fine-tuning and multiple RL passes, which enhances both correctness and readability.
It is intriguing how some languages may reveal certain ideas better, which leads the model to choose the most meaningful language for the job.
Training Pipeline
The training pipeline that DeepSeek released in the R1 paper is exceptionally intriguing. It showcases how they developed such strong reasoning designs, and what you can anticipate from each stage. This includes the issues that the resulting designs from each stage have, and how they resolved it in the next phase.
It's intriguing that their training pipeline differs from the typical:
The typical training method: Pretraining on big dataset (train to forecast next word) to get the base design → monitored fine-tuning → choice tuning via RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → pipeline with numerous SFT and RL phases
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 gives a good design to begin RL.
First RL Stage: Apply GRPO with rule-based rewards to enhance thinking accuracy and formatting (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL procedure, they transferred to the next step. The result of this step is a strong thinking model but with weak basic capabilities, e.g., bad formatting and language blending.
Rejection Sampling + basic information: Create brand-new SFT information through rejection sampling on the RL checkpoint (from step 2), combined with monitored data 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 thinking + 200k general tasks) for broader abilities. This step led to a strong thinking design with general abilities.
Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the final model, in addition to the reasoning benefits. The outcome is DeepSeek-R1.
They also did model distillation for numerous Qwen and Llama designs on the thinking traces to get distilled-R1 models.
Model distillation is a method where you use a teacher design to enhance a trainee design by creating training data for the trainee model.
The teacher is usually a bigger model than the trainee.
Group Relative Policy Optimization (GRPO)
The standard concept behind utilizing reinforcement knowing for LLMs is to fine-tune the design's policy so that it naturally produces more precise and helpful responses.
They utilized a benefit system that examines not just for correctness however also for proper formatting and language consistency, so the design gradually discovers to favor reactions that fulfill these quality requirements.
In this paper, they encourage the R1 design to produce chain-of-thought reasoning through RL training with GRPO.
Instead of including a separate module at inference time, the training process itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the enhanced policy.
What makes their approach especially fascinating is its dependence on straightforward, rule-based benefit functions.
Instead of depending upon expensive external models or human-graded examples as in standard RLHF, the RL used for R1 uses basic criteria: it might give a higher reward if the response is right, if it follows the anticipated/ formatting, and if the language of the response matches that of the timely.
Not counting on a benefit design also means you don't need to hang around and effort training it, and it does not 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 design creates various actions.
2. Each action receives a scalar benefit based on aspects like precision, formatting, and language consistency.
3. Rewards are changed relative to the group's efficiency, basically measuring how much better each action is compared to the others.
4. The design updates its strategy slightly to prefer responses with higher relative benefits. It just makes slight adjustments-using methods like clipping and a KL penalty-to make sure the policy doesn't stray too far from its original habits.
A cool element of GRPO is its versatility. You can use simple rule-based reward functions-for instance, granting a bonus offer when the design properly utilizes the syntax-to guide the training.
While DeepSeek used GRPO, you could utilize alternative methods rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has actually composed rather a great implementation of training an LLM with RL utilizing GRPO. GRPO has likewise currently been included 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 last note on explaining DeepSeek-R1 and the methods 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 boosts the design's total performance by rendering the output circulation more robust, simply put, it appears that the enhancement is credited to increasing the proper action from TopK instead of the improvement 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 appropriate, despite the fact that the overall capability (as measured by the variety of correct responses) 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 rather than endowing the model with totally new capabilities.
Consequently, while RL techniques such as PPO and GRPO can produce substantial efficiency gains, there seems an intrinsic ceiling figured out 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 huge turning point. I'm excited 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 all right. The additional search performance makes it even nicer to utilize.
Interestingly, o3-mini(-high) was launched as I was writing this post. From my initial testing, R1 seems stronger at math than o3-mini.
I also leased 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 released on a single H100 GPU-not to thoroughly check the model's capabilities.
671B via Llama.cpp
DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized design 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 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 regional video gaming setup.
Digital Spaceport composed a full guide on how to run Deepseek R1 671b fully 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 serious work, but it's enjoyable to run these big models on available hardware.
What matters most to me is a combination of effectiveness and time-to-usefulness in these models. Since thinking models require to believe before answering, their time-to-usefulness is generally greater than other designs, but their effectiveness is also typically greater.
We need to both make the most of effectiveness and minimize time-to-usefulness.
70B through Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of Ollama:
GPU usage 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 through Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a fully local "deep scientist" with DeepSeek-R1 - YouTube).
DeepSeek R1's recipe to duplicate 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 by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that measures up to the performance of OpenAI's o1. It provides a detailed methodology for training such models using massive reinforcement knowing methods.
DeepSeek-V3 Technical Report (December 2024) This report discusses the implementation of an FP8 combined accuracy training structure validated on a very massive model, attaining both accelerated training and lowered GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and presents findings that facilitate the scaling of large-scale designs in open-source setups. It presents the DeepSeek LLM task, devoted to advancing open-source language models 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 range of open-source code models trained from scratch on 2 trillion tokens. The designs are pre-trained on a premium project-level code corpus and use a fill-in-the-blank task to boost code generation and infilling.
DeepSeek-V2: A Strong, Economical, utahsyardsale.com and Efficient Mixture-of-Experts Language Model (May 2024) This paper provides DeepSeek-V2, a Mixture-of-Experts (MoE) language model characterized by cost-effective training and efficient inference.
DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language design that attains performance comparable 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 recreation of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
- OpenAI researcher verifies the DeepSeek group individually discovered and utilized some core ideas the OpenAI team used en route to o1
Liked this post? Join the newsletter.