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 numerous standards, but it also includes totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong reasoning capabilities in an open and available way.
What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open techniques from some industry leaders, DeepSeek has released a detailed training methodology in their paper.
The design is also incredibly cost-effective, 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 better models required more data and calculate. While that's still valid, designs like o1 and R1 show an alternative: inference-time scaling through thinking.
The Essentials
The DeepSeek-R1 paper provided several designs, but main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while fascinating, I will not go over 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 relies on comparing several model outputs per timely to prevent the requirement for a different critic.
R1 and R1-Zero are both thinking models. 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 final summary.
R1-Zero vs R1
R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any monitored fine-tuning (SFT). RL is utilized to optimize the design's policy to optimize benefit.
R1-Zero attains excellent accuracy but often produces confusing outputs, such as mixing multiple languages in a single reaction. R1 repairs that by including restricted supervised fine-tuning and multiple RL passes, which enhances both accuracy and readability.
It is interesting how some languages may express certain concepts much better, which leads the design to choose the most meaningful language for the task.
Training Pipeline
The training pipeline that DeepSeek released in the R1 paper is immensely interesting. It showcases how they created such strong reasoning models, and what you can anticipate from each stage. This consists of the issues that the resulting models from each phase have, and how they fixed it in the next phase.
It's fascinating that their training pipeline differs from the typical:
The normal training technique: Pretraining on big dataset (train to forecast next word) to get the base design → supervised fine-tuning → preference tuning by means of RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with several SFT and RL phases
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 good starting point. This offers a great design to begin RL.
First RL Stage: Apply GRPO with rule-based rewards to improve thinking accuracy and format (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL procedure, they moved to the next action. The outcome of this action is a strong thinking model however with weak basic capabilities, e.g., poor formatting and language mixing.
Rejection Sampling + basic data: Create brand-new SFT data through rejection tasting on the RL checkpoint (from step 2), integrated with monitored information from the DeepSeek-V3-Base design. They gathered around 600k top quality reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k general tasks) for more comprehensive abilities. This action led to a strong reasoning model with basic abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to refine the final design, in addition to the reasoning rewards. The result is DeepSeek-R1.
They also did design distillation for several Qwen and Llama models on the thinking traces to get distilled-R1 models.
Model distillation is a technique where you use a teacher design to enhance a trainee design by creating training data for the trainee design.
The instructor is normally a bigger design than the trainee.
Group Relative Policy Optimization (GRPO)
The basic idea behind utilizing reinforcement learning for LLMs is to tweak 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 model slowly discovers to favor actions that satisfy these quality requirements.
In this paper, they encourage the R1 model to create chain-of-thought thinking through RL training with GRPO.
Instead of including a separate module at inference time, the training procedure itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the enhanced policy.
What makes their technique particularly interesting is its dependence on straightforward, rule-based reward functions.
Instead of depending upon expensive external designs or human-graded examples as in conventional RLHF, the RL used for R1 uses easy criteria: it might give a greater benefit if the response is right, if it follows the anticipated/ format, and if the language of the answer matches that of the timely.
Not relying on a reward model likewise implies you do not need to spend time and effort training it, and it does not take memory and compute far from your main design.
GRPO was presented in the DeepSeekMath paper. Here's how GRPO works:
1. For each input timely, the model produces various reactions.
2. Each reaction receives a scalar reward based upon elements like precision, format, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, essentially measuring how much better each action is compared to the others.
4. The model updates its technique slightly to prefer actions with higher relative advantages. It just makes slight adjustments-using techniques like clipping and a KL penalty-to make sure the policy doesn't stray too far from its initial behavior.
A cool element of GRPO is its versatility. You can use basic rule-based reward functions-for instance, awarding a benefit when the model properly utilizes the syntax-to guide the training.
While DeepSeek utilized GRPO, you might use alternative techniques rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has actually written quite a good application of training an LLM with RL utilizing GRPO. GRPO has actually also already been added to the Transformer Reinforcement Learning (TRL) library, disgaeawiki.info which is another good resource.
Finally, Yannic Kilcher has an excellent 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 have actually provided in their paper, I wish to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.
These findings suggest that RL enhances the design's total performance by rendering the output distribution more robust, in other words, it seems that the improvement is credited to improving the appropriate action from TopK instead of the improvement of fundamental abilities.
In other words, RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are more most likely to be proper, although the general capability (as measured by the variety of proper answers) is mainly present in the pretrained model.
This suggests that support knowing on LLMs is more about refining and "shaping" the existing distribution of reactions instead of enhancing the model with entirely new capabilities.
Consequently, while RL methods such as PPO and GRPO can produce substantial efficiency gains, there appears to be an inherent 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 turning point. I'm thrilled to see how it unfolds!
Running DeepSeek-R1
I have actually used DeepSeek-R1 through the main chat interface for numerous issues, which it appears to fix all right. The additional search performance makes it even nicer to use.
Interestingly, o3-mini(-high) was launched as I was composing this post. From my initial screening, R1 appears stronger at mathematics than o3-mini.
I likewise leased a single H100 via 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 design would carry out when released on a single H100 GPU-not to thoroughly test the model's abilities.
671B via 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 running on the GPU), running by means of llama.cpp:
29 layers seemed to be the sweet spot provided 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 local video gaming setup.
Digital Spaceport wrote a complete 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 for any severe work, however it's fun to run these big models on available hardware.
What matters most to me is a mix of usefulness and time-to-usefulness in these models. Since thinking models require to believe before responding to, their time-to-usefulness is usually greater than other models, however their effectiveness is also usually higher.
We need to both optimize effectiveness and decrease time-to-usefulness.
70B by means of Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running through Ollama:
GPU utilization soars 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 totally local "deep researcher" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to replicate 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 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 merges 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 presents DeepSeek-R1, an open-source thinking design that measures up to the efficiency of OpenAI's o1. It presents a detailed method for training such designs utilizing massive support learning methods.
DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 combined accuracy training structure validated on an incredibly large-scale model, attaining both accelerated training and lowered GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper delves into scaling laws and presents findings that help with the scaling of large-scale models in open-source configurations. It introduces 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 designs 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 enhance 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 characterized by cost-effective training and efficient reasoning.
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 design that attains efficiency similar to GPT-4 Turbo in code-specific tasks.
Interesting occasions
- Hong Kong University reproduces R1 outcomes (Jan 25, '25).
- Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, fully open source (Jan 25, '25).
- OpenAI scientist verifies the DeepSeek team independently discovered and utilized some core concepts the OpenAI group utilized en route to o1
Liked this post? Join the newsletter.