Understanding DeepSeek R1
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 model in many standards, but it also features fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to provide strong thinking abilities in an open and available manner.
What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open approaches from some industry leaders, DeepSeek has actually published a detailed training methodology in their paper.
The model is also remarkably 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 models required more information and calculate. While that's still valid, models 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 fascinating, I will not talk about here.
DeepSeek-R1 utilizes two major ideas:
1. A multi-stage pipeline where a small set of cold-start data kickstarts the model, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a support knowing method that depends on comparing numerous model outputs per prompt to prevent the requirement for a separate critic.
R1 and R1-Zero are both reasoning designs. This essentially indicates they do Chain-of-Thought before responding to. For the R1 series of designs, this takes kind as believing within a tag, before addressing with a last summary.
R1-Zero vs R1
R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any supervised fine-tuning (SFT). RL is used to enhance the model's policy to maximize reward.
R1-Zero attains outstanding accuracy however often produces confusing outputs, such as blending several languages in a single action. 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 reveal certain concepts much better, which leads the design to choose the most meaningful language for the job.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is exceptionally intriguing. It showcases how they produced such strong thinking models, and what you can get out of each phase. This includes the problems that the resulting models from each stage have, and how they solved it in the next stage.
It's fascinating that their training pipeline varies from the usual:
The usual training method: Pretraining on big dataset (train to anticipate next word) to get the base design → monitored fine-tuning → choice tuning through 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 couple of thousand Chain-of-Thought (CoT) samples to ensure the RL process has a good beginning point. This offers a good design to start RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance thinking 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 step. The outcome of this action is a strong reasoning model however with weak general capabilities, e.g., poor formatting and language blending.
Rejection Sampling + basic data: Create new SFT data through rejection sampling on the RL checkpoint (from action 2), combined with monitored data from the DeepSeek-V3-Base model. They gathered around 600k top quality reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic jobs) for broader capabilities. This step led to a strong reasoning design with general capabilities.
Second RL Stage: Add more benefit signals (helpfulness, wiki.lafabriquedelalogistique.fr harmlessness) to improve the last model, in addition to the thinking rewards. The outcome is DeepSeek-R1.
They likewise did design distillation for numerous Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.
Model distillation is a technique where you use a teacher model to improve a trainee design by producing training information for the trainee design.
The instructor is usually a bigger design than the trainee.
Group Relative Policy Optimization (GRPO)
The fundamental idea behind utilizing support learning for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and helpful responses.
They used a benefit system that inspects not only for accuracy but likewise for proper formatting and language consistency, so the model gradually finds out to prefer actions that fulfill these quality requirements.
In this paper, they motivate the R1 design to create chain-of-thought reasoning through RL training with GRPO.
Instead of including a different module at inference time, the training process itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the optimized policy.
What makes their technique especially interesting is its reliance on straightforward, rule-based reward functions.
Instead of depending on expensive external designs or human-graded examples as in traditional RLHF, the RL utilized for R1 uses easy criteria: it may offer a higher benefit if the response is appropriate, if it follows the expected/ format, and if the language of the response matches that of the prompt.
Not relying on a reward model also implies you don't need to hang around and effort training it, and it doesn't take memory and calculate far from your main model.
GRPO was introduced in the DeepSeekMath paper. Here's how GRPO works:
1. For each input timely, the model generates various reactions.
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, essentially determining how much better each action is compared to the others.
4. The model updates its method slightly to favor actions with greater relative advantages. It just makes small adjustments-using methods like clipping and a KL penalty-to make sure the policy does not wander off too far from its original behavior.
A cool element of GRPO is its versatility. You can use easy rule-based reward functions-for instance, awarding a benefit when the design correctly utilizes the syntax-to guide the training.
While DeepSeek used GRPO, you could utilize alternative 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 using GRPO. GRPO has actually also currently been added to the Transformer Reinforcement Learning (TRL) library, which is another great resource.
Finally, Yannic Kilcher has a terrific video explaining GRPO by going through the DeepSeekMath paper.
Is RL on LLMs the path to AGI?
As a final note on explaining DeepSeek-R1 and the approaches they have actually presented in their paper, I desire to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.
These findings indicate that RL enhances the model's total performance by rendering the output distribution more robust, to put it simply, it seems that the enhancement is credited to increasing the correct reaction from TopK instead of the improvement of essential abilities.
In other words, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are most likely to be correct, even though the general ability (as determined by the variety of correct 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 actions instead of endowing the design with totally brand-new abilities.
Consequently, while RL strategies such as PPO and GRPO can produce significant efficiency gains, classifieds.ocala-news.com there appears to be an inherent ceiling identified 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 big turning point. I'm thrilled to see how it unfolds!
Running DeepSeek-R1
I have actually utilized DeepSeek-R1 through the main chat user interface for various issues, which it seems to fix all right. The additional search functionality makes it even nicer to utilize.
Interestingly, o3-mini(-high) was launched as I was writing this post. From my preliminary screening, R1 appears more powerful at math than o3-mini.
I likewise 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 perform when deployed on a single H100 GPU-not to thoroughly test the design's abilities.
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 appeared to be the sweet spot provided this configuration.
Performance:
A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their local gaming setup.
Digital Spaceport wrote 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 rather bearable for any severe work, but it's fun 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 thinking designs require to believe before answering, their time-to-usefulness is normally higher than other models, but their usefulness is also normally greater.
We need to both make the most of effectiveness and decrease time-to-usefulness.
70B via 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 fully local "deep scientist" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to replicate 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 a novel autoregressive framework that unifies multimodal understanding and generation. It can both understand and produce 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 reasoning model that equals the performance of OpenAI's o1. It provides a detailed method for training such designs using massive reinforcement learning techniques.
DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 blended accuracy training framework confirmed on a very large-scale model, attaining both sped up training and decreased GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper delves into scaling laws and provides findings that help with the scaling of massive models in open-source setups. It presents the DeepSeek LLM job, devoted to advancing open-source language models with a long-term 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 designs are pre-trained on a top quality project-level code corpus and employ a fill-in-the-blank task to improve 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 design identified by economical training and effective inference.
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 model that attains efficiency equivalent to GPT-4 Turbo in code-specific tasks.
Interesting occasions
- Hong Kong University reproduces R1 outcomes (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, completely open source (Jan 25, '25).
- OpenAI researcher verifies the DeepSeek team separately found and used some core concepts the OpenAI team used en route to o1
Liked this post? Join the newsletter.