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 just does it match-or even surpass-OpenAI's o1 design in numerous standards, however it likewise includes completely MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong reasoning capabilities in an open and lovewiki.faith available way.
What makes DeepSeek-R1 especially amazing is its transparency. Unlike the less-open methods from some market leaders, DeepSeek has published a detailed training method in their paper.
The design is likewise remarkably cost-effective, 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 wisdom was that much better designs needed more information and calculate. While that's still valid, models like o1 and R1 demonstrate an option: inference-time scaling through reasoning.
The Essentials
The DeepSeek-R1 paper provided numerous designs, but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I won't discuss here.
DeepSeek-R1 utilizes two significant ideas:
1. A multi-stage pipeline where a little set of cold-start data kickstarts the design, followed by massive RL.
2. Group Relative Policy Optimization (GRPO), a reinforcement knowing technique that depends on comparing multiple design outputs per timely to avoid the requirement for a different critic.
R1 and R1-Zero are both reasoning designs. This essentially implies they do Chain-of-Thought before responding to. For the R1 series of models, this takes kind as believing within a tag, before responding to with a last summary.
R1-Zero vs R1
R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any monitored fine-tuning (SFT). RL is used to enhance the design's policy to take full advantage of reward.
R1-Zero attains excellent precision however in some cases produces confusing outputs, such as mixing several languages in a single reaction. R1 repairs that by incorporating limited supervised fine-tuning and multiple RL passes, which improves both accuracy and readability.
It is fascinating how some languages may reveal certain ideas better, which leads the model to choose the most meaningful language for the task.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is tremendously intriguing. It showcases how they created such strong reasoning designs, and what you can anticipate from each stage. This includes the issues that the resulting models from each stage have, and how they solved it in the next phase.
It's intriguing that their training pipeline differs from the usual:
The normal training method: Pretraining on large dataset (train to forecast next word) to get the base design → supervised fine-tuning → choice 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 couple of thousand Chain-of-Thought (CoT) samples to make sure the RL process has a good starting point. This provides an excellent model to begin RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance thinking accuracy and formatting (such as requiring chain-of-thought into believing tags). When they were near merging in the RL process, they transferred to the next step. The result of this action is a strong reasoning model but with weak general abilities, e.g., poor format and language blending.
Rejection Sampling + basic information: Create new SFT information through rejection sampling on the RL checkpoint (from action 2), integrated with supervised data from the DeepSeek-V3-Base model. They collected around 600k top quality thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic jobs) for more comprehensive capabilities. This step resulted in a strong thinking model with basic abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the final design, in addition to the thinking benefits. The result is DeepSeek-R1.
They likewise did design distillation for numerous Qwen and Llama designs on the thinking traces to get distilled-R1 designs.
Model distillation is a technique where you utilize an instructor model to improve a trainee design by creating training data for the trainee model.
The instructor is typically a bigger design than the trainee.
Group Relative Policy Optimization (GRPO)
The fundamental concept behind utilizing support learning for LLMs is to tweak the design's policy so that it naturally produces more accurate and useful answers.
They used a benefit system that inspects not just for accuracy however likewise for proper formatting and language consistency, so the model slowly finds out to prefer reactions that meet these quality criteria.
In this paper, they motivate the R1 model to generate chain-of-thought reasoning through RL training with GRPO.
Rather than including a different module at reasoning time, the training procedure itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the enhanced policy.
What makes their method particularly interesting is its dependence on straightforward, rule-based benefit functions.
Instead of depending on costly external designs or human-graded examples as in conventional RLHF, the RL used for R1 uses simple requirements: it may give a greater reward if the answer is correct, if it follows the expected/ format, and if the language of the response matches that of the prompt.
Not counting on a reward model also suggests you don't need to hang out and effort training it, and it doesn't take memory and compute away from your main design.
GRPO was introduced in the DeepSeekMath paper. Here's how GRPO works:
1. For each input timely, the model produces various actions.
2. Each response gets a scalar benefit based upon factors like accuracy, format, and language consistency.
3. Rewards are adjusted relative to the group's performance, basically measuring just how much better each action is compared to the others.
4. The model updates its technique a little to prefer actions with greater relative benefits. It only makes slight adjustments-using techniques like clipping and a KL penalty-to make sure the policy doesn't wander off too far from its original behavior.
A cool element of GRPO is its flexibility. You can utilize simple rule-based benefit functions-for instance, granting a benefit when the model correctly utilizes the syntax-to guide the training.
While DeepSeek utilized GRPO, you might utilize alternative methods rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has composed rather a nice application of training an LLM with RL utilizing GRPO. GRPO has also currently been added to the Learning (TRL) library, 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 final note on explaining DeepSeek-R1 and the approaches they have actually 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 improves the design's general efficiency by rendering the output circulation more robust, in other words, it appears that the improvement is credited to enhancing the proper action from TopK instead of the improvement of essential capabilities.
Simply put, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are most likely to be right, despite the fact that the general capability (as determined by the diversity of correct answers) is mainly present in the pretrained design.
This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing distribution of reactions instead of endowing the design with totally new abilities.
Consequently, while RL techniques such as PPO and GRPO can produce considerable efficiency gains, there seems a fundamental ceiling identified 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 huge turning point. I'm excited to see how it unfolds!
Running DeepSeek-R1
I've used DeepSeek-R1 by means of the main chat user interface for different problems, which it appears to solve all right. The extra search functionality makes it even better to use.
Interestingly, o3-mini(-high) was launched as I was writing this post. From my initial screening, R1 appears more powerful at mathematics than o3-mini.
I also rented 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 perform when released on a single H100 GPU-not to extensively check the design's capabilities.
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 running on the GPU), running through 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 using their GPU on their local video gaming setup.
Digital Spaceport composed a complete 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 serious work, however it's enjoyable to run these big designs 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 think before responding to, their time-to-usefulness is normally higher than other designs, however their usefulness is also normally greater.
We require to both optimize usefulness and minimize time-to-usefulness.
70B through Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:
GPU utilization 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 via Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a completely regional "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 create images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that equals the performance of OpenAI's o1. It presents a detailed methodology for training such designs utilizing large-scale support learning strategies.
DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 combined precision training framework verified on an exceptionally massive model, attaining both sped up training and decreased GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and presents findings that assist in the scaling of large-scale designs in open-source configurations. It presents the DeepSeek LLM task, committed 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 study introduces the DeepSeek-Coder series, a series of open-source code designs trained from scratch on 2 trillion tokens. The models are pre-trained on a premium project-level code corpus and utilize 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 presents DeepSeek-V2, a Mixture-of-Experts (MoE) language model characterized by cost-effective training and effective 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 efficiency 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 duplicate R1, totally open source (Jan 25, '25).
- OpenAI researcher validates the DeepSeek group independently found and used some core concepts the OpenAI group utilized on the method to o1
Liked this post? Join the newsletter.