Understanding DeepSeek R1
DeepSeek-R1 is an open-source language design developed on DeepSeek-V3-Base that's been making waves in the AI community. Not just does it match-or even surpass-OpenAI's o1 model in numerous standards, however it likewise comes with completely MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to provide strong reasoning abilities in an open and available manner.
What makes DeepSeek-R1 particularly exciting is its transparency. Unlike the less-open methods from some industry leaders, DeepSeek has actually released a detailed training approach in their paper.
The design is also extremely affordable, with input tokens simply $0.14-0.55 per million (vs o1's $15) and online-learning-initiative.org output tokens at $2.19 per million (vs o1's $60).
Until ~ GPT-4, the common knowledge was that better designs required 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 numerous designs, however main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I won't go over here.
DeepSeek-R1 uses two significant ideas:
1. A multi-stage pipeline where a little set of cold-start information kickstarts the model, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a support learning approach that counts on comparing numerous design outputs per prompt to prevent the requirement for a separate critic.
R1 and R1-Zero are both reasoning models. This basically indicates they do Chain-of-Thought before responding to. For the R1 series of models, this takes type as believing within a tag, before responding to with a final 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 optimize the design's policy to optimize reward.
R1-Zero attains excellent precision however often produces complicated outputs, such as blending multiple languages in a single response. R1 repairs that by incorporating restricted monitored fine-tuning and numerous RL passes, which enhances both accuracy and readability.
It is intriguing how some languages may express certain concepts better, which leads the design to select the most expressive language for the job.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is tremendously interesting. It showcases how they developed such strong reasoning designs, and what you can anticipate from each phase. This consists of the issues that the resulting models from each phase have, and how they solved it in the next phase.
It's fascinating that their training pipeline differs from the normal:
The normal training method: Pretraining on large 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 numerous SFT and RL stages
Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a decent starting point. This gives an excellent design to start RL.
First RL Stage: Apply GRPO with rule-based rewards to improve thinking correctness and formatting (such as forcing 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 action is a strong reasoning design but with weak general capabilities, e.g., bad formatting and language blending.
Rejection Sampling + general information: Create new SFT information through rejection sampling on the RL checkpoint (from action 2), integrated with supervised information from the DeepSeek-V3-Base model. They gathered around 600k high-quality reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k basic tasks) for broader capabilities. This action resulted in a strong reasoning design with general capabilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to refine the last model, in addition to the reasoning rewards. The result is DeepSeek-R1.
They also did model distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 models.
Model distillation is a technique where you utilize an instructor design to enhance a trainee design by generating training information for the trainee model.
The teacher is typically a larger design than the trainee.
Group Relative Policy Optimization (GRPO)
The standard idea behind using reinforcement knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and helpful responses.
They utilized a reward system that examines not only for accuracy but also for correct format and language consistency, so the design gradually learns to prefer actions that meet these quality requirements.
In this paper, they motivate the R1 design to generate chain-of-thought reasoning through RL training with GRPO.
Instead of adding a separate module at inference time, the training process itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emerging habits of the enhanced policy.
What makes their technique particularly interesting is its dependence on straightforward, rule-based benefit functions.
Instead of depending on pricey external models or human-graded examples as in conventional RLHF, the RL used for R1 uses basic criteria: it might provide a higher reward if the response is proper, if it follows the expected/ format, and if the language of the response matches that of the timely.
Not counting on a benefit design likewise implies you don't have to spend time and effort training it, and it doesn't take memory and compute 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 different actions.
2. Each reaction gets a scalar benefit based upon factors like precision, format, and language consistency.
3. Rewards are changed relative to the group's performance, basically determining how much better each response is compared to the others.
4. The model updates its method a little to favor responses with greater relative benefits. It only makes slight adjustments-using techniques like clipping and a KL penalty-to guarantee the policy does not stray too far from its original habits.
A cool aspect of GRPO is its flexibility. You can use easy rule-based benefit functions-for instance, granting a perk when the model properly utilizes the syntax-to guide the training.
While DeepSeek utilized GRPO, you could use alternative techniques instead (PPO or PRIME).
For those aiming to dive deeper, Will Brown has composed quite a nice application of training an LLM with RL utilizing GRPO. GRPO has actually also already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another good resource.
Finally, Yannic Kilcher has a great 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 approaches they have actually provided 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 suggest that RL boosts the model's general efficiency by rendering the output circulation more robust, in other words, it appears that the enhancement is attributed to improving the appropriate reaction from TopK rather than the improvement of basic capabilities.
In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be correct, although the overall ability (as measured by the diversity of correct 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 responses rather than enhancing the design with entirely brand-new abilities.
Consequently, while RL strategies such as PPO and GRPO can produce substantial performance gains, there appears to be a fundamental ceiling figured out by the underlying design'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 thrilled to see how it unfolds!
Running DeepSeek-R1
I have actually utilized DeepSeek-R1 through the main chat user interface for various problems, which it seems to solve all right. The additional search functionality makes it even nicer to utilize.
Interestingly, o3-mini(-high) was released as I was writing this post. From my initial screening, R1 appears stronger at math 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 objective was to see how the design would perform when released on a single H100 GPU-not to thoroughly test 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 operating on the GPU), running by means of llama.cpp:
29 layers appeared to be the sweet area offered 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 full guide on how to run Deepseek R1 671b completely 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 quite bearable for any serious work, however it's enjoyable to run these big designs on available hardware.
What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since reasoning designs require to believe before addressing, their time-to-usefulness is usually greater than other models, however their usefulness is also typically higher.
We need to both make the most of effectiveness and reduce time-to-usefulness.
70B through Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:
GPU usage soars 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: alldogssportspark.com Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a fully local "deep researcher" with DeepSeek-R1 - YouTube).
DeepSeek R1's recipe to reproduce 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 granny - 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 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 introduces DeepSeek-R1, an open-source reasoning model that equals the efficiency of OpenAI's o1. It provides a detailed method for training such models using large-scale support knowing methods.
DeepSeek-V3 Technical Report (December 2024) This report goes over the execution of an FP8 combined accuracy training framework 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 delves into scaling laws and presents findings that facilitate the scaling of large-scale designs in open-source setups. It presents the DeepSeek LLM project, devoted to advancing open-source language models with a long-term 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 series of open-source code models trained from scratch on 2 trillion tokens. The models are pre-trained on a premium project-level code corpus and use a fill-in-the-blank job to improve 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 efficient inference.
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 performance equivalent to GPT-4 Turbo in code-specific jobs.
Interesting occasions
- Hong Kong University replicates R1 results (Jan 25, '25).
- Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, completely open source (Jan 25, '25).
- OpenAI researcher validates the DeepSeek group separately discovered and utilized some core ideas the OpenAI group utilized on the way to o1
Liked this post? Join the newsletter.