Understanding DeepSeek R1
DeepSeek-R1 is an open-source language model developed on DeepSeek-V3-Base that's been making waves in the AI community. 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 provide strong thinking capabilities in an open and available way.
What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open methods from some industry leaders, DeepSeek has actually published a detailed training method in their paper.
The design is likewise incredibly affordable, 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 much better designs required more information and dokuwiki.stream calculate. While that's still legitimate, designs like o1 and R1 show an alternative: inference-time scaling through reasoning.
The Essentials
The DeepSeek-R1 paper presented several models, however main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while fascinating, I will not discuss here.
DeepSeek-R1 uses two significant 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 support learning approach that relies on comparing several model outputs per prompt to prevent the requirement for a different critic.
R1 and R1-Zero are both thinking models. This essentially means they do Chain-of-Thought before answering. For the R1 series of designs, this takes kind as believing within a tag, before answering with a last summary.
R1-Zero vs R1
R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is utilized to enhance the design's policy to take full advantage of reward.
R1-Zero attains excellent accuracy but sometimes produces confusing outputs, such as mixing several languages in a single action. R1 repairs that by incorporating minimal supervised fine-tuning and numerous RL passes, which enhances both correctness and readability.
It is intriguing how some languages might express certain ideas much better, which leads the model to choose the most expressive language for the task.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is immensely interesting. It showcases how they created such strong reasoning designs, timeoftheworld.date and what you can get out of each phase. This consists of the problems that the resulting designs from each stage have, and how they resolved it in the next phase.
It's fascinating that their training pipeline differs from the typical:
The typical training method: Pretraining on big dataset (train to predict next word) to get the base design → monitored fine-tuning → choice tuning through RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with numerous 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 procedure has a decent beginning point. This gives a good design to start RL.
First RL Stage: Apply GRPO with rule-based rewards to improve reasoning accuracy and formatting (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL procedure, they moved to the next action. The outcome of this step is a strong thinking model but with weak basic capabilities, e.g., bad formatting and language mixing.
Rejection Sampling + basic data: Create brand-new SFT information through rejection sampling on the RL checkpoint (from step 2), combined with monitored information from the DeepSeek-V3-Base design. They collected around 600k high-quality thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k general jobs) for more comprehensive abilities. This step led to a strong thinking model with general capabilities.
Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the final design, in addition to the reasoning rewards. The result is DeepSeek-R1.
They likewise did model distillation for a number of Qwen and Llama models 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 information for the trainee model.
The instructor is usually a bigger design than the trainee.
Group Relative Policy Optimization (GRPO)
The fundamental concept behind using support knowing for LLMs is to tweak the design's policy so that it naturally produces more precise and helpful responses.
They used a benefit system that inspects not only for correctness but also for proper format and language consistency, so the model gradually finds out to prefer responses that satisfy these .
In this paper, they motivate the R1 model to generate chain-of-thought thinking through RL training with GRPO.
Rather than including a separate module at reasoning time, the training process itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the optimized policy.
What makes their technique especially fascinating is its reliance on straightforward, rule-based benefit functions.
Instead of depending upon expensive external designs or human-graded examples as in conventional RLHF, the RL utilized for R1 utilizes easy requirements: it may give a greater reward if the response is right, if it follows the expected/ formatting, and if the language of the answer matches that of the timely.
Not depending on a reward design also implies you don't need to hang around and effort training it, and it doesn't take memory and compute away from your main model.
GRPO was introduced in the DeepSeekMath paper. Here's how GRPO works:
1. For each input prompt, the design generates various actions.
2. Each reaction gets a scalar reward based upon elements like precision, format, and language consistency.
3. Rewards are changed relative to the group's performance, basically measuring just how much better each reaction is compared to the others.
4. The design updates its technique slightly to prefer actions with greater relative advantages. It only makes small adjustments-using methods 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 versatility. You can use easy rule-based reward functions-for instance, awarding a benefit when the model properly utilizes the syntax-to guide the training.
While DeepSeek used GRPO, you could utilize alternative methods instead (PPO or wiki.eqoarevival.com PRIME).
For those aiming to dive deeper, Will Brown has composed rather a great execution of training an LLM with RL utilizing GRPO. GRPO has also already been added 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 final note on explaining DeepSeek-R1 and the methodologies they've 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 indicate that RL improves the design's total efficiency by rendering the output distribution more robust, to put it simply, it seems that the improvement is associated to increasing the right response from TopK instead of the enhancement of fundamental capabilities.
In other words, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are most likely to be proper, despite the fact that the overall capability (as measured by the diversity of proper responses) is mainly present in the pretrained model.
This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing distribution of reactions rather than enhancing the model with totally brand-new capabilities.
Consequently, while RL techniques such as PPO and online-learning-initiative.org GRPO can produce substantial performance gains, there seems a fundamental ceiling determined 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 big milestone. 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 vmeste-so-vsemi.ru various problems, which it seems to solve well enough. The additional search performance makes it even nicer to use.
Interestingly, o3-mini(-high) was launched as I was writing this post. From my preliminary testing, R1 seems stronger at mathematics than o3-mini.
I likewise 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 objective was to see how the model would perform when deployed on a single H100 GPU-not to thoroughly test the design's capabilities.
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 through llama.cpp:
29 layers appeared to be the sweet area provided this setup.
Performance:
A r/localllama user explained that they had the ability to get over 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 completely 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 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 effectiveness and time-to-usefulness in these models. Since thinking models require to believe before responding to, their time-to-usefulness is normally greater than other designs, however their effectiveness is also typically higher.
We need to both optimize effectiveness and minimize 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 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 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 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 structure that combines multimodal understanding and generation. It can both comprehend and create images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking design that matches the efficiency of OpenAI's o1. It provides a detailed method for training such designs utilizing large-scale reinforcement knowing methods.
DeepSeek-V3 Technical Report (December 2024) This report talks about the application of an FP8 combined accuracy training framework confirmed on an incredibly 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 help with the scaling of large-scale models in open-source configurations. It introduces the DeepSeek LLM job, 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 introduces 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 use a fill-in-the-blank task to boost 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 defined by affordable training and effective 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 equivalent to GPT-4 Turbo in code-specific jobs.
Interesting occasions
- Hong Kong University reproduces R1 outcomes (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to reproduce R1, completely open source (Jan 25, '25).
- OpenAI scientist validates the DeepSeek group independently found and utilized some core concepts the OpenAI group used on the way to o1
Liked this post? Join the newsletter.