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 just does it match-or even surpass-OpenAI's o1 design in many standards, but it also includes totally MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong thinking capabilities in an open and available way.
What makes DeepSeek-R1 particularly exciting is its openness. Unlike the less-open methods from some market leaders, DeepSeek has published a detailed training method in their paper.
The model is likewise extremely cost-effective, 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 typical knowledge was that much better models needed more information and calculate. While that's still legitimate, models like o1 and R1 show an option: inference-time scaling through reasoning.
The Essentials
The DeepSeek-R1 paper provided several models, however main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I will not discuss here.
DeepSeek-R1 uses 2 significant ideas:
1. A multi-stage pipeline where a small set of cold-start information kickstarts the model, followed by massive RL.
2. Group Relative Policy Optimization (GRPO), a support knowing technique that relies on comparing multiple design outputs per prompt to avoid the requirement for a separate critic.
R1 and R1-Zero are both reasoning designs. This essentially indicates they do Chain-of-Thought before responding to. For the R1 series of models, 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 used to optimize the model's policy to maximize benefit.
R1-Zero attains outstanding accuracy however in some cases produces confusing outputs, such as blending numerous languages in a single reaction. R1 repairs that by including minimal monitored fine-tuning and several RL passes, wiki.die-karte-bitte.de which improves both accuracy and readability.
It is interesting how some languages might reveal certain concepts better, which leads the design to select the most expressive language for the job.
Training Pipeline
The training pipeline that DeepSeek published in the R1 paper is tremendously interesting. It showcases how they created such strong reasoning designs, and what you can anticipate from each stage. This includes the issues that the resulting designs from each phase have, and how they resolved it in the next stage.
It's intriguing that their training pipeline varies from the normal:
The normal training technique: Pretraining on large dataset (train to forecast next word) to get the base design → monitored fine-tuning → choice tuning via RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with several 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 offers an excellent design to start RL.
First RL Stage: Apply GRPO with rule-based rewards to enhance thinking correctness and format (such as requiring chain-of-thought into believing tags). When they were near merging in the RL procedure, they moved to the next action. The outcome of this action is a strong thinking design however with weak general capabilities, e.g., poor formatting and language mixing.
- basic data: wiki.rrtn.org Create new SFT data through rejection sampling on the RL checkpoint (from action 2), integrated with supervised data from the DeepSeek-V3-Base model. They gathered around 600k high-quality reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k general tasks) for more comprehensive capabilities. This action resulted in a strong thinking design with general capabilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to refine the last model, in addition to the thinking benefits. The outcome is DeepSeek-R1.
They also did design distillation for numerous Qwen and Llama models on the thinking traces to get distilled-R1 designs.
Model distillation is a method where you use a teacher model to improve a trainee design by producing training information for the trainee design. The instructor is normally a bigger design than the trainee.
Group Relative Policy Optimization (GRPO)
The fundamental idea behind utilizing reinforcement knowing for LLMs is to fine-tune the design's policy so that it naturally produces more precise and beneficial responses. They utilized a reward system that inspects not only for correctness but also for correct formatting and language consistency, so the model gradually discovers to prefer reactions that fulfill these quality criteria.
In this paper, they motivate the R1 model to create chain-of-thought reasoning through RL training with GRPO. Rather than including a separate module at inference time, the training process itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emerging habits of the optimized policy.
What makes their technique especially intriguing is its dependence on straightforward, rule-based reward functions. Instead of depending upon expensive external designs or bytes-the-dust.com human-graded examples as in standard RLHF, the RL utilized for R1 uses easy criteria: it may offer a higher benefit if the answer is right, if it follows the anticipated/ formatting, and if the language of the response matches that of the prompt. Not counting on a benefit design likewise means you do not need to spend time and effort training it, and it does not take memory and compute far from your main model.
GRPO was introduced in the DeepSeekMath paper. Here's how GRPO works:
1. For each input timely, the model produces different reactions.
- Each response receives a scalar reward based on factors like precision, format, and language consistency.
- Rewards are adjusted relative to the group's performance, essentially measuring just how much better each reaction is compared to the others.
- The model updates its method a little to favor reactions with higher relative advantages. It just makes slight adjustments-using strategies like clipping and a KL penalty-to ensure the policy does not wander off too far from its initial habits.
A cool element of GRPO is its flexibility. You can utilize basic rule-based benefit functions-for instance, granting a reward when the design correctly utilizes the syntax-to guide the training.
While DeepSeek used GRPO, you could utilize alternative techniques rather (PPO or PRIME).
For those aiming to dive much deeper, Will Brown has actually written rather a nice execution of training an LLM with RL using GRPO. GRPO has actually also currently been contributed to the Transformer Reinforcement 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 path to AGI?
As a final note on explaining DeepSeek-R1 and the methods they have actually presented 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 show that RL improves the design's overall performance by rendering the output distribution more robust, to put it simply, it seems that the improvement is credited to improving the correct response from TopK rather than the enhancement of fundamental capabilities.
To put it simply, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are most likely to be right, even though the general ability (as determined by the variety of right answers) is mainly present in the pretrained model.
This suggests that reinforcement knowing on LLMs is more about refining and "forming" the existing distribution of responses rather than endowing the model with entirely new capabilities. Consequently, while RL methods such as PPO and GRPO can produce significant efficiency gains, utahsyardsale.com there appears to be an intrinsic ceiling figured out by the underlying model's pretrained understanding.
It is uncertain to me how far RL will take us. Perhaps it will be the stepping stone to the next big turning point. I'm thrilled to see how it unfolds!
Running DeepSeek-R1
I've utilized DeepSeek-R1 by means of the main chat user interface for numerous issues, which it seems to solve well enough. The extra search performance makes it even better to use.
Interestingly, o3-mini(-high) was launched as I was composing this post. From my initial screening, R1 appears more powerful at mathematics 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 released on a single H100 GPU-not to extensively check the design's abilities.
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 by means of llama.cpp:
29 layers seemed to be the sweet area offered this configuration.
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 local video gaming setup. Digital Spaceport wrote 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 major work, wiki.whenparked.com however it's fun to run these big models 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 think before responding to, their time-to-usefulness is normally greater than other models, however their effectiveness is likewise generally higher. We require to both optimize effectiveness and decrease time-to-usefulness.
70B via Ollama
70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:
GPU utilization shoots up 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 by means of Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a totally local "deep researcher" 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 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 structure that unifies 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, wiki.vst.hs-furtwangen.de an open-source thinking design that rivals the efficiency of OpenAI's o1. It presents a detailed method for training such designs using massive support knowing strategies. DeepSeek-V3 Technical Report (December 2024) This report talks about the execution of an FP8 blended accuracy training framework validated on a very massive design, attaining both sped up training and lowered GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper delves into scaling laws and provides findings that help with the scaling of massive models in open-source configurations. It presents the DeepSeek LLM project, committed to advancing open-source language designs with a long-term perspective. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study presents the DeepSeek-Coder series, a range of open-source code designs trained from scratch on 2 trillion tokens. The designs are pre-trained on a premium project-level code corpus and utilize 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, a Mixture-of-Experts (MoE) language model defined by cost-effective training and effective 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 equivalent to GPT-4 Turbo in code-specific jobs.
Interesting occasions
- Hong Kong University duplicates R1 results (Jan 25, '25).
- Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, completely open source (Jan 25, '25).
- OpenAI researcher confirms the DeepSeek group independently found and used some core ideas the OpenAI group used en route to o1
Liked this post? Join the newsletter.