Understanding DeepSeek R1
DeepSeek-R1 is an open-source language model built on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not just does it match-or even surpass-OpenAI's o1 model in many criteria, however it also includes completely MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to deliver strong thinking abilities in an open and available manner.
What makes DeepSeek-R1 especially exciting is its openness. Unlike the less-open techniques from some industry leaders, DeepSeek has actually released a detailed training method in their paper.
The model is likewise extremely 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 data and calculate. While that's still legitimate, models like o1 and R1 demonstrate an option: inference-time scaling through thinking.
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 interesting, I won't go over here.
DeepSeek-R1 uses 2 major concepts:
1. A multi-stage pipeline where a small set of cold-start data kickstarts the model, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a support knowing approach that relies on comparing multiple design outputs per timely to avoid the requirement for a separate critic.
R1 and R1-Zero are both reasoning designs. This basically they do Chain-of-Thought before answering. For the R1 series of designs, this takes form as believing within a tag, before responding to 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 enhance the model's policy to take full advantage of reward.
R1-Zero attains outstanding accuracy however sometimes produces confusing outputs, such as mixing multiple languages in a single action. R1 repairs that by incorporating restricted monitored fine-tuning and numerous RL passes, which improves both correctness and readability.
It is interesting how some languages might express certain concepts much better, which leads the model to choose the most meaningful language for bbarlock.com the job.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is immensely intriguing. It showcases how they produced such strong thinking designs, and what you can expect from each stage. This consists of the problems that the resulting models from each stage have, and how they solved it in the next phase.
It's fascinating that their training pipeline varies from the typical:
The usual training method: Pretraining on large dataset (train to predict next word) to get the base model → monitored fine-tuning → preference tuning via RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with multiple SFT and RL phases
Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to make sure the RL procedure has a decent starting point. This gives a good design to begin RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and format (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL procedure, they transferred to the next action. The result of this step is a strong thinking design however with weak basic abilities, e.g., poor asteroidsathome.net format and language mixing.
Rejection Sampling + general information: Create new SFT information through rejection tasting on the RL checkpoint (from action 2), combined with monitored 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 overall samples (600k reasoning + 200k basic tasks) for wider capabilities. This step led to a strong reasoning design with general capabilities.
Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the final model, in addition to the thinking benefits. The result is DeepSeek-R1.
They likewise did design distillation for a number of Qwen and Llama models on the reasoning traces to get distilled-R1 models.
Model distillation is a method where you utilize a teacher model to improve a trainee design by producing training data for the trainee model.
The teacher is normally a larger model than the trainee.
Group Relative Policy Optimization (GRPO)
The basic idea behind utilizing reinforcement learning for LLMs is to tweak the design's policy so that it naturally produces more precise and useful answers.
They used a benefit system that examines not only for correctness but likewise for correct formatting and language consistency, so the design slowly discovers to favor responses that meet these quality criteria.
In this paper, they motivate the R1 design to generate chain-of-thought reasoning through RL training with GRPO.
Rather than adding a different module at inference time, the training procedure itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the enhanced policy.
What makes their approach particularly interesting is its dependence on straightforward, rule-based benefit functions.
Instead of depending upon pricey external models or human-graded examples as in standard RLHF, fishtanklive.wiki the RL used for R1 uses easy requirements: it might offer a higher benefit if the answer is right, if it follows the expected/ format, and if the language of the response matches that of the prompt.
Not counting on a benefit model likewise indicates you don't need to hang out and effort training it, and it does not take memory and calculate far from your main design.
GRPO was introduced in the DeepSeekMath paper. Here's how GRPO works:
1. For each input prompt, the design creates different responses.
2. Each action gets a scalar benefit based on factors like accuracy, formatting, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, essentially determining how much better each reaction is compared to the others.
4. The design updates its method somewhat to favor responses with higher relative benefits. It just makes minor adjustments-using methods like clipping and a KL penalty-to make sure the policy does not wander off too far from its initial behavior.
A cool aspect of GRPO is its versatility. You can utilize simple rule-based reward functions-for instance, awarding a bonus offer when the design correctly uses the syntax-to guide the training.
While DeepSeek used GRPO, you could use alternative methods rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has composed rather a great implementation of training an LLM with RL using GRPO. GRPO has also already been added to the Transformer Reinforcement Learning (TRL) library, which is another great resource.
Finally, Yannic Kilcher has a great 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 approaches they've provided in their paper, I want 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, simply put, it appears that the enhancement is credited to boosting the proper response from TopK instead of the improvement of essential capabilities.
In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more likely to be right, even though the total ability (as determined by the variety of proper answers) is mainly present in the pretrained design.
This suggests that support knowing on LLMs is more about refining and "shaping" the existing circulation of actions instead of endowing the model with totally new capabilities.
Consequently, while RL strategies such as PPO and GRPO can produce substantial performance gains, there appears to be an intrinsic ceiling determined 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 milestone. I'm thrilled to see how it unfolds!
Running DeepSeek-R1
I have actually utilized DeepSeek-R1 through the main chat interface for various issues, which it seems to resolve well enough. The extra 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 seems more powerful at mathematics than o3-mini.
I also leased a single H100 by means of 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 perform when released on a single H100 GPU-not to thoroughly test the model's capabilities.
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 working on the GPU), running through llama.cpp:
29 layers appeared to be the sweet area given this configuration.
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 regional video gaming setup.
Digital Spaceport composed 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 rather bearable for any severe work, but it's fun 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 models require to think before answering, their time-to-usefulness is normally higher than other models, but their effectiveness is also generally greater.
We require to both make the most of effectiveness and minimize time-to-usefulness.
70B by means of Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:
GPU utilization shoots up here, drapia.org as anticipated when compared to the mainly CPU-powered run of 671B that I showcased above.
Resources
DeepSeek-R1: Incentivizing Reasoning Capability in LLMs by means of Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a completely local "deep scientist" 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 structure that combines multimodal understanding and generation. It can both comprehend and produce images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that matches the performance of OpenAI's o1. It provides a detailed methodology for training such designs using large-scale reinforcement knowing strategies.
DeepSeek-V3 Technical Report (December 2024) This report talks about the implementation of an FP8 combined accuracy training framework verified on an extremely massive model, attaining both accelerated training and reduced GPU memory use.
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 models in open-source configurations. It presents the DeepSeek LLM project, devoted to advancing open-source language models 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 series of open-source code designs trained from scratch on 2 trillion tokens. The designs are pre-trained on a top quality project-level code corpus and library.kemu.ac.ke use 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 provides DeepSeek-V2, a Mixture-of-Experts (MoE) language design characterized by affordable training and efficient inference.
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 announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, fully open source (Jan 25, '25).
- OpenAI researcher verifies the DeepSeek group separately found and utilized some core ideas the OpenAI team used en route to o1
Liked this post? Join the newsletter.