Understanding DeepSeek R1
DeepSeek-R1 is an open-source language model developed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not only does it match-or even surpass-OpenAI's o1 design in many standards, however it also comes with totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to deliver strong thinking abilities in an open and available way.
What makes DeepSeek-R1 especially amazing is its openness. Unlike the less-open approaches from some industry leaders, DeepSeek has actually published a detailed training method in their paper.
The design is likewise 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 typical knowledge 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 reasoning.
The Essentials
The DeepSeek-R1 paper presented multiple designs, but main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while fascinating, I won't talk about here.
DeepSeek-R1 utilizes two significant concepts:
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 knowing technique that depends on comparing several model outputs per timely to prevent the need for a different critic.
R1 and R1-Zero are both thinking designs. This basically means they do Chain-of-Thought before answering. For the R1 series of models, this takes type as thinking within a tag, before answering with a final summary.
R1-Zero vs R1
R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is used to enhance the model's policy to maximize reward.
R1-Zero attains excellent precision however sometimes produces confusing outputs, such as mixing several languages in a single action. R1 repairs that by including minimal monitored fine-tuning and several RL passes, which improves both accuracy and readability.
It is fascinating how some languages might express certain concepts better, which leads the model to select the most expressive language for the job.
Training Pipeline
The training pipeline that DeepSeek released in the R1 paper is exceptionally interesting. It showcases how they produced such strong thinking models, and what you can anticipate from each phase. This includes the issues that the resulting models from each stage have, bytes-the-dust.com and how they solved it in the next stage.
It's fascinating that their training pipeline differs from the typical:
The typical training technique: Pretraining on large dataset (train to predict next word) to get the base model → supervised fine-tuning → choice tuning by means of 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 process has a good starting point. This gives a good design to begin RL.
First RL Stage: Apply GRPO with rule-based rewards to improve reasoning accuracy and format (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL procedure, they moved to the next action. The outcome of this step is a strong reasoning design but with weak basic abilities, e.g., bad formatting and language mixing.
Rejection Sampling + basic data: Create new SFT data through rejection sampling on the RL checkpoint (from step 2), combined with supervised data from the DeepSeek-V3-Base model. They gathered around 600k premium reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k basic tasks) for broader abilities. This action resulted in a strong reasoning design with general abilities.
Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the reasoning rewards. The result is DeepSeek-R1.
They likewise did design distillation for numerous Qwen and Llama models on the thinking traces to get distilled-R1 models.
Model distillation is a strategy where you use an instructor design to enhance a trainee model by creating training information for the trainee model.
The instructor is typically a larger model than the trainee.
Group Relative Policy Optimization (GRPO)
The standard idea behind using reinforcement learning for LLMs is to tweak the design's policy so that it naturally produces more precise and useful answers.
They utilized a reward system that examines not only for correctness however likewise for setiathome.berkeley.edu correct format and language consistency, so the model slowly discovers to prefer responses that satisfy these quality requirements.
In this paper, they motivate the R1 design to produce chain-of-thought thinking through RL training with GRPO.
Instead of adding 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 enhanced policy.
What makes their technique particularly fascinating is its dependence on straightforward, rule-based reward functions.
Instead of depending on costly external designs or human-graded examples as in traditional RLHF, the RL used for R1 utilizes easy criteria: it might offer a greater benefit if the answer is right, if it follows the expected/ format, and if the language of the response matches that of the timely.
Not counting on a reward model also indicates you do not need to hang out and effort training it, and historydb.date it doesn't take memory and calculate far from your main design.
GRPO was presented in the DeepSeekMath paper. Here's how GRPO works:
1. For each input prompt, the model generates various actions.
2. Each action receives a scalar benefit based upon aspects like accuracy, format, and language consistency.
3. Rewards are changed relative to the group's performance, essentially measuring just how much better each action is compared to the others.
4. The model updates its method a little to prefer responses with higher relative benefits. It just makes slight adjustments-using methods like clipping and a KL penalty-to ensure the policy does not stray too far from its initial habits.
A cool element of GRPO is its flexibility. You can utilize easy rule-based reward functions-for instance, granting a reward when the design correctly uses the syntax-to guide the training.
While DeepSeek used GRPO, you might use alternative methods rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has actually written quite a good implementation of training an LLM with RL using GRPO. GRPO has likewise currently been contributed to the Transformer Reinforcement Learning (TRL) library, which is another great resource.
Finally, Yannic Kilcher has a fantastic 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 want to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.
These findings indicate that RL enhances the design's overall performance by rendering the output distribution more robust, to put it simply, it seems that the enhancement is credited to enhancing the correct reaction from TopK instead of the enhancement of fundamental capabilities.
Simply put, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more most likely to be appropriate, although the overall ability (as measured by the variety of right responses) is mainly present in the pretrained design.
This recommends that support learning on LLMs is more about refining and "shaping" the existing circulation of actions rather than enhancing the model with totally brand-new capabilities.
Consequently, while RL strategies such as PPO and library.kemu.ac.ke GRPO can produce considerable performance gains, there seems a fundamental 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 delighted to see how it unfolds!
Running DeepSeek-R1
I have actually utilized DeepSeek-R1 by means of the main chat user interface for numerous problems, which it appears to fix all right. The extra search performance makes it even better to use.
Interestingly, o3-mini(-high) was released as I was composing this post. From my preliminary screening, R1 seems more powerful at math 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 model would carry out when released on a single H100 GPU-not to extensively check the model's abilities.
671B by means of 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 working on the GPU), running via llama.cpp:
29 layers appeared to be the sweet spot given this configuration.
Performance:
A r/localllama user explained that they were able to overcome 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their local video 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 quite bearable for any severe work, however it's enjoyable 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 reasoning models require to believe before answering, their time-to-usefulness is normally higher than other designs, however their usefulness is likewise normally greater.
We need to both take full advantage of usefulness and .
70B by means of Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running through Ollama:
GPU usage 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 through Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a completely local "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 a novel autoregressive structure that unifies multimodal understanding and generation. It can both comprehend and generate images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source reasoning model that measures up to the efficiency of OpenAI's o1. It provides a detailed method for training such designs using massive reinforcement learning methods.
DeepSeek-V3 Technical Report (December 2024) This report discusses the implementation of an FP8 blended precision training framework verified on an exceptionally large-scale design, attaining both sped up training and decreased GPU memory usage.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and provides findings that facilitate the scaling of large-scale designs in open-source setups. 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 introduces 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 top quality project-level code corpus and utilize a fill-in-the-blank job 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 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 introduces 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 replicates R1 results (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, fully open source (Jan 25, '25).
- OpenAI researcher validates the DeepSeek team separately discovered and used some core concepts the OpenAI team used en route to o1
Liked this post? Join the newsletter.