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 lots of criteria, however it also 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 exciting is its openness. Unlike the less-open approaches from some industry leaders, DeepSeek has published a detailed training methodology in their paper.
The model is also extremely cost-efficient, 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 models needed more data and compute. While that's still legitimate, designs like o1 and R1 demonstrate an alternative: inference-time scaling through reasoning.
The Essentials
The DeepSeek-R1 paper presented several models, but main among them were R1 and R1-Zero. Following these are a series of distilled models that, while intriguing, I will not discuss here.
DeepSeek-R1 uses 2 significant concepts:
1. A multi-stage pipeline where a little set of cold-start information kickstarts the design, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a support learning technique that depends on comparing several model outputs per prompt to prevent the need for a separate critic.
R1 and R1-Zero are both thinking designs. This essentially 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 with no supervised fine-tuning (SFT). RL is utilized to enhance the model's policy to make the most of reward.
R1-Zero attains exceptional accuracy however in some cases produces confusing outputs, such as mixing multiple languages in a single response. R1 repairs that by integrating minimal monitored fine-tuning and multiple RL passes, which improves both accuracy and readability.
It is intriguing how some languages may express certain ideas much better, which leads the design to choose the most expressive language for the job.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is exceptionally fascinating. It showcases how they created such strong reasoning models, and what you can anticipate from each phase. This includes the issues that the resulting models from each stage have, and how they resolved it in the next phase.
It's fascinating that their training pipeline differs from the usual:
The usual training technique: Pretraining on big dataset (train to anticipate next word) to get the base model → supervised 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 guarantee the RL process has a good beginning point. This offers a good model to begin RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance thinking accuracy 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 action. The result of this action is a strong reasoning design but with weak general abilities, e.g., poor formatting and language blending.
Rejection Sampling + basic information: photorum.eclat-mauve.fr Create new SFT data through rejection tasting on the RL checkpoint (from action 2), integrated with monitored information from the DeepSeek-V3-Base design. They collected around 600k top quality thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k general jobs) for wider abilities. This step resulted in a strong thinking model with basic capabilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the thinking benefits. The outcome is DeepSeek-R1.
They likewise did design distillation for a number of Qwen and Llama designs on the thinking traces to get distilled-R1 models.
Model distillation is a strategy where you utilize a teacher model to improve a trainee design by generating training information for the trainee model.
The instructor is usually a larger design than the trainee.
Group Relative Policy Optimization (GRPO)
The basic idea behind utilizing reinforcement knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and useful answers.
They utilized a reward system that examines not only for correctness but also for correct formatting and language consistency, so the model slowly finds out to prefer reactions that satisfy these quality requirements.
In this paper, they encourage the R1 model to generate chain-of-thought thinking through RL training with GRPO.
Instead of adding 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 behavior of the optimized policy.
What makes their approach particularly fascinating is its dependence on straightforward, rule-based reward functions.
Instead of depending upon pricey external designs or human-graded examples as in standard RLHF, the RL utilized for R1 utilizes easy criteria: it may give a greater benefit if the answer is right, if it follows the anticipated/ formatting, and if the language of the answer matches that of the prompt.
Not counting on a benefit design likewise means you do not need to hang out 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 prompt, the model generates different actions.
2. Each reaction gets a scalar reward based on aspects like accuracy, formatting, and language consistency.
3. Rewards are adjusted relative to the group's performance, basically measuring just how much better each response is compared to the others.
4. The model updates its strategy slightly to prefer responses with greater relative advantages. It just makes minor adjustments-using methods like clipping and a KL penalty-to ensure the policy does not wander off too far from its initial behavior.
A cool element of GRPO is its versatility. You can utilize basic rule-based benefit functions-for instance, granting a bonus offer when the design properly uses the syntax-to guide the training.
While DeepSeek used GRPO, you could use alternative approaches rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has composed quite a nice execution of training an LLM with RL using GRPO. GRPO has actually also currently been contributed to the Transformer Reinforcement Learning (TRL) library, thatswhathappened.wiki which is another excellent resource.
Finally, Yannic Kilcher has a fantastic video explaining GRPO by going through the DeepSeekMath paper.
Is RL on LLMs the path to AGI?
As a last note on explaining DeepSeek-R1 and the approaches they've provided 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 suggest that RL enhances the design's overall efficiency by rendering the output distribution more robust, utahsyardsale.com simply put, it seems that the enhancement is associated to increasing the correct response from TopK rather than the improvement of fundamental capabilities.
In other words, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are more most likely to be appropriate, although the general capability (as measured by the variety of right responses) is mainly present in the pretrained design.
This suggests that support knowing on LLMs is more about refining and "forming" the existing circulation of actions rather than enhancing the model with completely new abilities.
Consequently, while RL strategies such as PPO and GRPO can produce considerable performance gains, there seems a fundamental ceiling identified 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 huge milestone. I'm excited to see how it unfolds!
Running DeepSeek-R1
I've used DeepSeek-R1 through the main chat interface for various problems, which it appears to solve well enough. The extra search performance makes it even nicer to use.
Interestingly, o3-mini(-high) was released as I was composing this post. From my initial testing, R1 seems stronger at mathematics 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 goal was to see how the model would carry out when deployed on a single H100 GPU-not to thoroughly 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 working on the GPU), running via llama.cpp:
29 layers seemed to be the sweet spot offered 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 regional gaming setup.
Digital Spaceport wrote a full guide on how to run Deepseek R1 671b totally 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 manageable for any serious work, however it's fun to run these large designs on available hardware.
What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since reasoning designs require to think before answering, their time-to-usefulness is usually greater than other models, but their effectiveness is likewise typically higher.
We require to both maximize usefulness and lessen time-to-usefulness.
70B through Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:
GPU usage soars here, as expected when compared to the mainly CPU-powered run of 671B that I 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 totally regional "deep researcher" 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 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 merges multimodal understanding and generation. It can both comprehend and create images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning design that rivals the performance of OpenAI's o1. It provides a detailed methodology for training such designs using massive support knowing techniques.
DeepSeek-V3 Technical Report (December 2024) This report talks about the execution of an FP8 mixed accuracy training framework confirmed on an exceptionally massive design, surgiteams.com attaining both accelerated training and reduced GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and presents findings that assist in the scaling of massive designs in open-source configurations. It introduces the DeepSeek LLM project, devoted to advancing open-source language designs with a long-lasting viewpoint.
DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study presents the DeepSeek-Coder series, a variety of open-source code models trained from scratch on 2 trillion tokens. The models are pre-trained on a high-quality project-level code corpus and utilize 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 provides DeepSeek-V2, a Mixture-of-Experts (MoE) language model defined by economical 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 model that attains performance comparable to GPT-4 Turbo in code-specific tasks.
Interesting occasions
- Hong Kong University duplicates R1 results (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, fully open source (Jan 25, '25).
- OpenAI researcher confirms the DeepSeek team independently found and utilized some core concepts the OpenAI team utilized en route to o1
Liked this post? Join the newsletter.