Understanding DeepSeek R1
DeepSeek-R1 is an open-source language model constructed 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 benchmarks, however it also features completely MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong reasoning abilities in an open and available way.
What makes DeepSeek-R1 particularly interesting is its openness. Unlike the less-open techniques from some market leaders, DeepSeek has released a detailed training approach in their paper.
The design is likewise incredibly cost-efficient, with input tokens costing simply $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 wisdom was that better designs required more information and compute. While that's still legitimate, designs like o1 and R1 show an option: inference-time scaling through thinking.
The Essentials
The DeepSeek-R1 paper provided multiple models, however main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I won't talk about here.
DeepSeek-R1 utilizes 2 major concepts:
1. A multi-stage pipeline where a small 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 prompt to avoid the requirement for wiki.dulovic.tech a separate critic.
R1 and R1-Zero are both reasoning designs. This basically indicates 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 utilized to enhance the model's policy to maximize reward.
R1-Zero attains excellent accuracy but often produces complicated outputs, such as blending multiple languages in a single reaction. R1 repairs that by including limited monitored fine-tuning and forum.kepri.bawaslu.go.id several RL passes, which improves both accuracy and readability.
It is interesting how some languages may reveal certain ideas better, which leads the design to pick the most expressive language for the task.
Training Pipeline
The training pipeline that DeepSeek released in the R1 paper is immensely fascinating. It showcases how they developed such strong reasoning models, and what you can get out of each stage. This includes the issues that the resulting designs from each stage have, and how they fixed it in the next stage.
It's fascinating that their training pipeline varies from the usual:
The usual training strategy: Pretraining on large dataset (train to anticipate next word) to get the base model → monitored fine-tuning → preference 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 make sure the RL process has a good starting point. This gives an excellent model to begin RL.
First RL Stage: Apply GRPO with rule-based rewards to improve thinking accuracy and format (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL process, they moved to the next action. The result of this step is a strong thinking model however with weak general capabilities, e.g., poor format and language blending.
Rejection Sampling + basic data: Create brand-new SFT data through rejection tasting on the RL checkpoint (from step 2), combined with supervised information from the DeepSeek-V3-Base design. They collected around 600k high-quality reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k general tasks) for broader capabilities. This step resulted in a strong thinking model with basic abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to improve the last design, setiathome.berkeley.edu in addition to the thinking rewards. The result is DeepSeek-R1.
They likewise did model distillation for numerous Qwen and Llama models on the thinking traces to get distilled-R1 models.
Model distillation is a strategy where you utilize an instructor model to enhance a trainee model by producing training information for the trainee model.
The teacher is generally a larger design than the trainee.
Group Relative Policy Optimization (GRPO)
The standard idea behind using reinforcement knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and helpful responses.
They utilized a reward system that examines not only for accuracy but likewise for proper formatting and language consistency, so the model gradually discovers to favor reactions that fulfill these quality requirements.
In this paper, they encourage the R1 model to produce chain-of-thought reasoning through RL training with GRPO.
Instead of including a different module at reasoning time, the training process itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the enhanced policy.
What makes their method particularly intriguing is its reliance on straightforward, rule-based reward functions.
Instead of depending upon pricey external models or human-graded examples as in traditional RLHF, the RL used for R1 uses easy criteria: it might offer a higher reward if the response is appropriate, if it follows the expected/ formatting, and if the language of the answer matches that of the prompt.
Not relying on a benefit model likewise suggests you don't have to invest time 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 prompt, the model creates various responses.
2. Each reaction gets a scalar reward based on factors like accuracy, formatting, and language consistency.
3. Rewards are changed relative to the group's performance, basically determining just how much better each response is compared to the others.
4. The design updates its method a little to favor actions with higher . It only makes minor adjustments-using strategies like clipping and a KL penalty-to make sure the policy does not stray too far from its original behavior.
A cool aspect of GRPO is its versatility. You can utilize basic rule-based benefit functions-for instance, granting a perk when the design correctly uses the syntax-to guide the training.
While DeepSeek used GRPO, you might use alternative approaches instead (PPO or PRIME).
For those aiming to dive deeper, Will Brown has actually composed rather a nice application of training an LLM with RL using GRPO. GRPO has actually also currently 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 path to AGI?
As a final note on explaining DeepSeek-R1 and the approaches they've presented in their paper, I wish to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.
These findings indicate that RL improves the design's general efficiency by rendering the output distribution more robust, to put it simply, it seems that the improvement is associated to improving the proper action from TopK rather than the enhancement of fundamental capabilities.
To put it simply, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are most likely to be correct, even though the total capability (as determined by the variety of right answers) is mainly present in the pretrained design.
This suggests that support learning on LLMs is more about refining and "forming" the existing distribution of actions rather than endowing the model with completely new abilities.
Consequently, tandme.co.uk while RL strategies such as PPO and GRPO can produce considerable performance gains, there appears to be a fundamental ceiling figured out 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 huge milestone. I'm thrilled to see how it unfolds!
Running DeepSeek-R1
I have actually utilized DeepSeek-R1 via the main chat interface for various issues, which it seems to resolve all right. The additional search functionality makes it even nicer to use.
Interestingly, o3-mini(-high) was released as I was composing this post. From my initial screening, R1 seems stronger at math than o3-mini.
I also 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 objective was to see how the model would carry out when released on a single H100 GPU-not to thoroughly evaluate the design'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 operating 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 get over 2 tok/sec with DeepSeek R1 671B, without using their GPU on their local video 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 kenpoguy.com any major work, but it's enjoyable to run these big designs on available hardware.
What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since thinking designs require to think before responding to, their time-to-usefulness is typically higher than other designs, however their usefulness is also normally greater.
We need to both maximize effectiveness and reduce time-to-usefulness.
70B by means of Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of Ollama:
GPU utilization soars 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 totally regional "deep researcher" with DeepSeek-R1 - YouTube).
DeepSeek R1's recipe to replicate 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 framework that combines multimodal understanding and generation. It can both understand 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 rivals the performance of OpenAI's o1. It provides a detailed method for raovatonline.org training such models using massive support knowing techniques.
DeepSeek-V3 Technical Report (December 2024) This report goes over the execution of an FP8 mixed accuracy training framework confirmed on a very large-scale design, attaining both accelerated training and minimized GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that facilitate the scaling of large-scale designs in open-source configurations. It presents the DeepSeek LLM task, dedicated 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 models trained from scratch on 2 trillion tokens. The models are pre-trained on a high-quality 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 affordable training and effective reasoning.
DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research study introduces DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model 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 reproduction of DeepSeek-R1 to reproduce R1, totally open source (Jan 25, '25).
- OpenAI researcher verifies the DeepSeek group independently found and used some core ideas the OpenAI group utilized on the way to o1
Liked this post? Join the newsletter.