Understanding DeepSeek R1

Comments · 97 Views

DeepSeek-R1 is an open-source language model built on DeepSeek-V3-Base that's been making waves in the AI neighborhood.

DeepSeek-R1 is an open-source language model built 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, but it also comes with totally MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong thinking capabilities in an open and available manner.


What makes DeepSeek-R1 particularly amazing is its transparency. Unlike the less-open techniques from some industry leaders, DeepSeek has published a detailed training method in their paper.
The model is likewise remarkably economical, 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 knowledge was that better designs needed more information and compute. While that's still valid, models like o1 and R1 show an option: inference-time scaling through reasoning.


The Essentials


The DeepSeek-R1 paper provided multiple models, but main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I will not discuss here.


DeepSeek-R1 uses 2 major ideas:


1. A multi-stage pipeline where a little set of cold-start data kickstarts the design, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a reinforcement learning approach that relies on comparing several model outputs per timely to avoid the need for a different critic.


R1 and R1-Zero are both thinking models. This basically indicates they do Chain-of-Thought before addressing. For the R1 series of models, this takes kind as thinking within a tag, before addressing with a final summary.


R1-Zero vs R1


R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is used to optimize the design's policy to make the most of reward.
R1-Zero attains exceptional accuracy but in some cases produces confusing outputs, such as blending multiple languages in a single reaction. R1 repairs that by integrating minimal supervised fine-tuning and several RL passes, which improves both accuracy and readability.


It is fascinating how some languages might reveal certain concepts much better, which leads the design to choose the most expressive language for the job.


Training Pipeline


The training pipeline that DeepSeek published in the R1 paper is tremendously intriguing. It showcases how they produced such strong thinking models, and what you can get out of each phase. This includes the problems that the resulting models from each stage have, and how they fixed it in the next stage.


It's interesting that their training pipeline differs from the normal:


The usual training technique: Pretraining on large dataset (train to forecast next word) to get the base designsupervised fine-tuningchoice tuning through RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with several SFT and RL stages


Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to guarantee the RL procedure has a decent starting point. This offers an excellent design to begin RL.
First RL Stage: Apply GRPO with rule-based rewards to improve reasoning accuracy and format (such as forcing chain-of-thought into believing tags). When they were near merging in the RL process, wifidb.science they moved to the next step. The result of this action is a strong reasoning model however with weak general capabilities, e.g., bad format and language mixing.
Rejection Sampling + basic data: grandtribunal.org Create brand-new SFT information through rejection sampling on the RL checkpoint (from step 2), integrated with monitored information 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 basic tasks) for more comprehensive abilities. This action resulted in a strong thinking design with basic capabilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to improve the last model, in addition to the reasoning benefits. The result is DeepSeek-R1.
They likewise did design distillation for a number of Qwen and Llama designs on the thinking traces to get distilled-R1 models.


Model distillation is a strategy where you utilize a teacher model to enhance a trainee design by generating training information for the trainee model.
The teacher is normally a bigger model than the trainee.


Group Relative Policy Optimization (GRPO)


The standard concept behind using reinforcement knowing for higgledy-piggledy.xyz LLMs is to fine-tune the model's policy so that it naturally produces more accurate and beneficial answers.
They utilized a benefit system that examines not only for accuracy however likewise for proper formatting and language consistency, so the model slowly learns to prefer reactions that meet these quality criteria.


In this paper, they motivate the R1 design to create chain-of-thought reasoning through RL training with GRPO.
Instead of including a different module at reasoning time, the training procedure itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emerging habits of the enhanced policy.


What makes their technique particularly fascinating is its reliance on straightforward, rule-based reward functions.
Instead of depending upon expensive external designs or human-graded examples as in standard RLHF, the RL utilized for R1 utilizes simple requirements: it may provide a higher benefit if the response is correct, if it follows the expected/ format, and if the language of the response matches that of the prompt.
Not depending on a benefit design likewise suggests you don't have to hang out and effort training it, and it doesn't take memory and compute away from your main design.


GRPO was presented in the DeepSeekMath paper. Here's how GRPO works:


1. For each input prompt, the design generates different reactions.
2. Each action receives a scalar benefit based upon aspects like accuracy, formatting, and language consistency.
3. Rewards are changed relative to the group's efficiency, basically measuring just how much better each action is compared to the others.
4. The model updates its strategy somewhat to favor actions with greater relative benefits. It only makes minor adjustments-using strategies like clipping and a KL penalty-to make sure the policy doesn't stray too far from its initial behavior.


A cool element of GRPO is its versatility. You can utilize easy rule-based benefit functions-for circumstances, granting a benefit when the model properly uses the syntax-to guide the training.


While DeepSeek used GRPO, you could use alternative techniques rather (PPO or PRIME).


For those aiming to dive deeper, Will Brown has actually composed quite a good application of training an LLM with RL using GRPO. GRPO has likewise currently been contributed to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource.
Finally, memorial-genweb.org 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 wish to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.


These findings show that RL enhances the design's general efficiency by rendering the output distribution more robust, to put it simply, it appears that the enhancement is credited to boosting the correct reaction from TopK instead of the enhancement of essential capabilities.


Simply put, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are more likely to be proper, even though the overall ability (as measured by the diversity of appropriate responses) is mainly present in the pretrained design.


This suggests that support knowing on LLMs is more about refining and "forming" the existing circulation of responses instead of endowing the design with entirely brand-new abilities.
Consequently, while RL strategies such as PPO and GRPO can produce considerable efficiency gains, there appears to be an inherent ceiling identified by the underlying design's pretrained understanding.


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 utilized DeepSeek-R1 through the main chat interface for different issues, which it seems to fix all right. The extra search functionality makes it even better to use.


Interestingly, o3-mini(-high) was released as I was writing this post. From my preliminary testing, R1 appears more powerful at math 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 objective was to see how the model would perform when released on a single H100 GPU-not to thoroughly evaluate 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 working on the GPU), running via llama.cpp:


29 layers appeared to be the sweet area given this configuration.


Performance:


A r/localllama user explained that they were able to overcome 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional gaming setup.
Digital Spaceport wrote a complete guide on how to run Deepseek R1 671b completely 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 manageable for demo.qkseo.in any major work, however it's enjoyable to run these large models on available hardware.


What matters most to me is a combination of effectiveness and time-to-usefulness in these models. Since thinking designs need to believe before responding to, their time-to-usefulness is normally higher than other models, however their usefulness is likewise generally higher.
We need to both take full advantage of effectiveness and lessen time-to-usefulness.


70B via Ollama


70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:


GPU usage 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 fully regional "deep scientist" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to replicate o1 and the future of reasoning LMs.
The Illustrated DeepSeek-R1 - by Jay Alammar.
Explainer: akropolistravel.com 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 a novel autoregressive framework that merges multimodal understanding and generation. It can both understand and produce images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, bio.rogstecnologia.com.br an open-source reasoning model that matches the efficiency of OpenAI's o1. It presents a detailed method for training such models utilizing massive reinforcement knowing strategies.
DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 combined precision training framework validated on a very large-scale model, attaining both sped up training and reduced GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that help with the scaling of massive models in open-source setups. It presents the DeepSeek LLM project, committed to advancing open-source language designs with a long-lasting perspective.
DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research introduces the DeepSeek-Coder series, a variety of open-source code models trained from scratch on 2 trillion tokens. The models are pre-trained on a premium project-level code corpus and employ 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 identified 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 model that attains performance equivalent to GPT-4 Turbo in code-specific jobs.


Interesting events


- Hong Kong University replicates R1 results (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
- OpenAI researcher confirms the DeepSeek group individually found and utilized some core concepts the OpenAI team utilized on the way to o1


Liked this post? Join the newsletter.

Comments