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 just does it match-or even surpass-OpenAI's o1 design in lots of benchmarks, but it also includes fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to provide strong thinking abilities in an open and available way.
What makes DeepSeek-R1 particularly amazing is its transparency. Unlike the less-open techniques from some market leaders, DeepSeek has released 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 common knowledge was that better models needed more information and calculate. While that's still legitimate, models like o1 and R1 demonstrate an alternative: inference-time scaling through reasoning.
The Essentials
The DeepSeek-R1 paper presented several designs, but main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while fascinating, I will not go over here.
DeepSeek-R1 uses two major ideas:
1. A multi-stage pipeline where a small set of cold-start information kickstarts the design, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a reinforcement learning method that depends on comparing numerous model outputs per prompt to prevent the need for a different critic.
R1 and R1-Zero are both reasoning designs. This essentially means they do Chain-of-Thought before answering. For the R1 series of designs, this takes kind 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 utilized to optimize the design's policy to optimize reward.
R1-Zero attains excellent precision but sometimes produces confusing outputs, such as mixing multiple languages in a single response. R1 repairs that by incorporating restricted supervised fine-tuning and several RL passes, which improves both accuracy and readability.
It is interesting how some languages might reveal certain concepts much better, which leads the design to select the most meaningful language for the task.
Training Pipeline
The training pipeline that DeepSeek released in the R1 paper is immensely fascinating. It showcases how they created such strong reasoning designs, and what you can anticipate from each stage. This consists of the problems that the resulting models from each phase have, and how they fixed it in the next stage.
It's intriguing that their training pipeline differs from the usual:
The typical training strategy: Pretraining on big dataset (train to predict next word) to get the base model → supervised 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 guarantee the RL procedure has a decent beginning point. This offers a great design to start RL.
First RL Stage: Apply GRPO with rule-based rewards to improve thinking correctness and format (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL procedure, they relocated to the next action. The result of this action is a strong thinking model however with weak basic capabilities, e.g., bad format and language mixing.
Rejection Sampling + basic data: Create new SFT information through rejection tasting on the RL checkpoint (from step 2), combined with monitored data from the DeepSeek-V3-Base design. They gathered around 600k premium reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k general jobs) for wider capabilities. This action led to a strong reasoning design with general abilities.
Second RL Stage: forum.batman.gainedge.org Add more benefit signals (helpfulness, harmlessness) to refine the last design, in addition to the thinking rewards. The result is DeepSeek-R1.
They also did model distillation for numerous Qwen and Llama designs on the reasoning traces to get distilled-R1 models.
Model distillation is a method where you use a teacher model to enhance a trainee design by producing training information for the trainee model.
The instructor is normally a bigger design than the trainee.
Group Relative Policy Optimization (GRPO)
The basic concept behind using support learning for LLMs is to fine-tune the design's policy so that it naturally produces more precise and beneficial answers.
They utilized a reward system that checks not only for accuracy however also for appropriate formatting and language consistency, so the model slowly learns to prefer actions that fulfill these quality criteria.
In this paper, they motivate the R1 model to create chain-of-thought reasoning through RL training with GRPO.
Instead of including a different module at inference time, the training procedure itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the optimized policy.
What makes their technique particularly fascinating is its reliance on straightforward, rule-based reward functions.
Instead of depending on pricey external models or human-graded examples as in conventional RLHF, the RL utilized for R1 utilizes basic requirements: it may provide a greater benefit if the answer is correct, if it follows the anticipated/ formatting, and if the language of the response matches that of the timely.
Not relying on a benefit design also suggests 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 presented in the DeepSeekMath paper. Here's how GRPO works:
1. For each input timely, the model creates different actions.
2. Each reaction gets a scalar benefit based upon elements like precision, formatting, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, essentially measuring how much better each reaction is compared to the others.
4. The model updates its strategy slightly to prefer reactions with higher relative advantages. It only makes small adjustments-using strategies like clipping and a KL penalty-to ensure the policy doesn't stray too far from its original habits.
A cool aspect of GRPO is its versatility. You can utilize simple rule-based reward functions-for circumstances, awarding a bonus when the model properly utilizes the syntax-to guide the training.
While DeepSeek used GRPO, you might utilize alternative techniques instead (PPO or PRIME).
For those aiming to dive deeper, Will Brown has actually composed rather a great execution of training an LLM with RL utilizing GRPO. GRPO has actually likewise already been included to the Transformer Reinforcement Learning (TRL) library, which is another great resource.
Finally, Yannic Kilcher has an excellent 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 methodologies they've 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 general efficiency by rendering the output circulation more robust, photorum.eclat-mauve.fr simply put, it appears that the improvement is attributed to enhancing the right action from TopK rather than the improvement of essential capabilities.
In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be right, although the general capability (as measured by the diversity of proper responses) is mainly present in the pretrained design.
This suggests that reinforcement learning on LLMs is more about refining and "forming" the existing distribution of reactions rather than enhancing the model with entirely brand-new abilities.
Consequently, while RL methods such as PPO and GRPO can produce considerable efficiency gains, there seems an intrinsic ceiling figured out by the underlying design'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 milestone. I'm delighted to see how it unfolds!
Running DeepSeek-R1
I've used DeepSeek-R1 through the main chat user interface for various problems, which it appears to fix all right. The extra search performance makes it even nicer to use.
Interestingly, o3-mini(-high) was launched as I was composing this post. From my preliminary testing, R1 seems at math than o3-mini.
I likewise leased 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 design would carry out when deployed on a single H100 GPU-not to thoroughly evaluate 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 running on the GPU), running by means of llama.cpp:
29 layers seemed to be the sweet spot 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 complete guide on how to run Deepseek R1 671b completely 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 serious work, but it's enjoyable to run these large 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 answering, their time-to-usefulness is usually greater than other designs, but their usefulness is also typically higher.
We require to both make the most of usefulness and minimize time-to-usefulness.
70B through Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running through Ollama:
GPU usage shoots up 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: 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 recipe to duplicate 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 grandma - 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 produce images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking model that matches the performance of OpenAI's o1. It provides a detailed approach for training such designs utilizing large-scale reinforcement knowing techniques.
DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 combined accuracy training framework validated on a very large-scale design, attaining both accelerated training and reduced 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 massive designs in open-source setups. It presents the DeepSeek LLM task, dedicated to advancing open-source language designs with a long-lasting 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 models are pre-trained on a premium 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 provides DeepSeek-V2, forums.cgb.designknights.com a Mixture-of-Experts (MoE) language model identified by economical training and efficient reasoning.
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 design that attains performance similar to GPT-4 Turbo in code-specific tasks.
Interesting events
- Hong Kong University reproduces R1 outcomes (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to reproduce R1, fully open source (Jan 25, '25).
- OpenAI researcher verifies the DeepSeek team separately found and used some core concepts the OpenAI team utilized en route to o1
Liked this post? Join the newsletter.