Understanding DeepSeek R1


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

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 design in lots of standards, but it likewise features totally MIT-licensed weights. This marks it as the first non-OpenAI/Google design to provide strong thinking capabilities in an open and available manner.


What makes DeepSeek-R1 particularly amazing is its transparency. Unlike the less-open approaches from some industry leaders, DeepSeek has actually released a detailed training methodology in their paper.
The model is likewise incredibly cost-efficient, 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 common wisdom was that much better designs needed more information and calculate. While that's still valid, designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.


The Essentials


The DeepSeek-R1 paper provided several designs, but main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while intriguing, I will not discuss here.


DeepSeek-R1 uses two significant 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 reinforcement knowing method that depends on comparing multiple design outputs per prompt to prevent the requirement for a separate critic.


R1 and R1-Zero are both reasoning designs. This basically means they do Chain-of-Thought before answering. For the R1 series of designs, this takes kind as thinking within a tag, before addressing with a last summary.


R1-Zero vs R1


R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any monitored fine-tuning (SFT). RL is utilized to enhance the design's policy to optimize reward.
R1-Zero attains exceptional accuracy however sometimes produces confusing outputs, such as blending several languages in a single response. R1 repairs that by including limited monitored fine-tuning and multiple RL passes, which enhances both accuracy and readability.


It is fascinating how some languages may reveal certain ideas better, which leads the design to pick the most meaningful language for the task.


Training Pipeline


The training pipeline that DeepSeek published in the R1 paper is exceptionally interesting. It showcases how they developed such strong reasoning models, and what you can get out of each stage. This includes the problems that the resulting models from each phase have, and how they resolved it in the next phase.


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


The normal training strategy: Pretraining on large dataset (train to anticipate next word) to get the base design → supervised fine-tuning → preference tuning via RLHF
R1-Zero: Pretrained → RL
R1: PretrainedMultistage training pipeline with multiple 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 offers a great design to start RL.
First RL Stage: Apply GRPO with rule-based rewards to improve thinking correctness and formatting (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL process, they moved to the next action. The outcome of this step is a strong reasoning design however with weak general abilities, e.g., poor format and language mixing.
Rejection Sampling + basic data: Create new SFT information through rejection sampling on the RL checkpoint (from action 2), integrated with monitored information from the DeepSeek-V3-Base model. They gathered around 600k top 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 led to a strong thinking model with basic abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to improve the last design, in addition to the reasoning benefits. The result is DeepSeek-R1.
They likewise did model distillation for a number of Qwen and Llama models on the reasoning traces to get distilled-R1 designs.


Model distillation is a technique where you use an instructor design to enhance a trainee design by producing training information for the trainee model.
The teacher is usually a bigger model than the trainee.


Group Relative Policy Optimization (GRPO)


The fundamental concept behind using support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more precise and helpful responses.
They used a benefit system that inspects not just for accuracy but likewise for appropriate formatting and language consistency, so the design gradually finds out to favor responses that fulfill these quality criteria.


In this paper, they motivate the R1 model to generate chain-of-thought thinking through RL training with GRPO.
Rather than adding a different module at inference time, the training procedure itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the optimized policy.


What makes their approach especially intriguing is its dependence on straightforward, rule-based reward functions.
Instead of depending on costly external models or human-graded examples as in conventional RLHF, the RL utilized for R1 utilizes basic requirements: it may provide a greater reward if the answer is correct, if it follows the expected/ format, and if the language of the response matches that of the prompt.
Not counting on a reward design also indicates you do not need to invest time and effort training it, and it does not take memory and calculate away from your main design.


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


1. For each input timely, the model generates different reactions.
2. Each response receives a scalar benefit based on factors like precision, formatting, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, essentially determining how much better each action is compared to the others.
4. The design updates its method somewhat to favor responses with higher relative advantages. It just makes slight adjustments-using methods like clipping and a KL penalty-to make sure the policy doesn't stray too far from its initial behavior.


A cool aspect of GRPO is its versatility. You can use easy rule-based benefit functions-for circumstances, awarding a reward when the design properly uses the syntax-to guide the training.


While DeepSeek utilized GRPO, you could use alternative approaches rather (PPO or PRIME).


For those aiming to dive deeper, Will Brown has written rather a great implementation of training an LLM with RL utilizing GRPO. GRPO has actually likewise already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 methods they have actually presented 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 suggest that RL enhances the model's general efficiency by rendering the output distribution more robust, simply put, it seems that the improvement is associated to enhancing the proper response from TopK instead of the improvement of essential capabilities.


Simply put, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more most likely to be appropriate, despite the fact that the general capability (as measured by the diversity of right responses) is mainly present in the pretrained model.


This suggests that reinforcement learning on LLMs is more about refining and "forming" the existing circulation of reactions instead of endowing the model with completely brand-new abilities.
Consequently, while RL techniques such as PPO and GRPO can produce substantial efficiency gains, there seems a fundamental ceiling identified 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 milestone. I'm excited to see how it unfolds!


Running DeepSeek-R1


I have actually used DeepSeek-R1 by means of the main chat interface for numerous problems, which it seems to solve all right. The extra search functionality makes it even better to utilize.


Interestingly, o3-mini(-high) was launched as I was composing this post. From my initial testing, R1 seems stronger at math than o3-mini.


I likewise rented a single H100 via Lambda Labs for $2/h (26 CPU cores, 214.7 GB RAM, users.atw.hu 1.1 TB SSD) to run some experiments.
The main goal was to see how the model would perform when released on a single H100 GPU-not to thoroughly evaluate 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 running on the GPU), running through llama.cpp:


29 layers appeared to be the sweet spot 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 utilizing their GPU on their regional video gaming setup.
Digital Spaceport wrote a full guide on how to run Deepseek R1 671b totally 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, but it's fun to run these large 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 addressing, their time-to-usefulness is generally greater than other designs, however their usefulness is likewise normally greater.
We require to both make the most of effectiveness and reduce time-to-usefulness.


70B via Ollama


70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of 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 via Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a completely local "deep researcher" 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 framework that unifies multimodal understanding and generation. It can both understand and generate images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning model that matches the efficiency of OpenAI's o1. It provides a detailed method for training such models using massive reinforcement learning strategies.
DeepSeek-V3 Technical Report (December 2024) This report talks about the application of an FP8 mixed accuracy training structure verified on an incredibly massive model, attaining both sped up training and decreased GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper digs into scaling laws and provides findings that help with the scaling of large-scale models in open-source setups. It introduces the DeepSeek LLM task, dedicated 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 presents 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 top quality project-level code corpus and utilize a fill-in-the-blank job to enhance code generation and infilling.
DeepSeek-V2: iwatex.com A Strong, Economical, and Efficient Mixture-of-Experts Language Model (May 2024) This paper provides DeepSeek-V2, a Mixture-of-Experts (MoE) language model identified by affordable training and effective inference.
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 design that attains performance similar to GPT-4 Turbo in code-specific tasks.


Interesting events


- Hong Kong University duplicates R1 results (Jan 25, '25).
- Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, fully open source (Jan 25, '25).
- OpenAI researcher validates the DeepSeek group separately discovered and used some core concepts the OpenAI group utilized en route to o1


Liked this post? Join the newsletter.

5 Visualizações