Understanding DeepSeek R1

Comments · 35 Views

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

DeepSeek-R1 is an open-source language design developed on DeepSeek-V3-Base that's been making waves in the AI community. Not just does it match-or even surpass-OpenAI's o1 model in many criteria, but it also features fully MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong thinking abilities in an open and available manner.


What makes DeepSeek-R1 particularly interesting is its transparency. Unlike the less-open methods from some industry leaders, DeepSeek has actually published a detailed training method in their paper.
The design is likewise remarkably affordable, 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 wisdom was that much better models needed more data and compute. While that's still valid, models like o1 and R1 demonstrate an option: inference-time scaling through thinking.


The Essentials


The DeepSeek-R1 paper presented multiple models, 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 significant ideas:


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


R1 and R1-Zero are both thinking models. This essentially indicates they do Chain-of-Thought before responding to. For the R1 series of models, this takes form as thinking within a tag, before answering with a last summary.


R1-Zero vs R1


R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any monitored fine-tuning (SFT). RL is utilized to enhance the model's policy to maximize benefit.
R1-Zero attains excellent accuracy but in some cases produces confusing outputs, such as blending multiple languages in a single action. R1 repairs that by incorporating restricted supervised fine-tuning and multiple RL passes, which enhances both correctness and readability.


It is interesting how some languages may express certain concepts better, which leads the model to pick the most expressive language for menwiki.men the task.


Training Pipeline


The training pipeline that DeepSeek published in the R1 paper is exceptionally intriguing. It showcases how they produced such strong reasoning designs, and what you can anticipate from each stage. This includes the issues that the resulting models from each stage have, and how they solved it in the next phase.


It's intriguing that their training pipeline varies from the usual:


The normal training technique: Pretraining on big dataset (train to forecast next word) to get the base model → monitored fine-tuning → choice tuning through RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with multiple SFT and RL stages


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 provides an excellent design to start RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning correctness and format (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL process, they moved to the next action. The outcome of this action is a strong thinking design but with weak basic abilities, e.g., poor formatting and language blending.
Rejection Sampling + general data: Create brand-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 high-quality thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k general jobs) for wider capabilities. This action led to a strong reasoning model with basic capabilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the last design, in addition to the thinking rewards. The outcome is DeepSeek-R1.
They likewise did model 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 an instructor design to improve a trainee design by producing training data for the trainee model.
The teacher is usually a larger design than the trainee.


Group Relative Policy Optimization (GRPO)


The standard concept behind utilizing support knowing for LLMs is to tweak the model's policy so that it naturally produces more precise and beneficial responses.
They used a reward system that inspects not just for accuracy however also for appropriate formatting and language consistency, so the design slowly finds out to favor responses that fulfill these quality criteria.


In this paper, they motivate the R1 design to produce chain-of-thought thinking through RL training with GRPO.
Rather than including a separate module at reasoning time, the training process itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the enhanced policy.


What makes their technique particularly interesting is its reliance on straightforward, rule-based reward functions.
Instead of depending on expensive external models or human-graded examples as in standard RLHF, the RL used for R1 utilizes simple requirements: it might give a higher reward if the response is correct, if it follows the expected/ formatting, and if the language of the response matches that of the timely.
Not depending on a reward design also means you don't have to hang out and effort training it, and it doesn't take memory and compute far from your main design.


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


1. For each input prompt, the design generates different responses.
2. Each reaction receives a scalar benefit based on elements like precision, formatting, and language consistency.
3. Rewards are changed relative to the group's performance, basically measuring just how much better each reaction is compared to the others.
4. The model updates its strategy a little to prefer actions with higher relative benefits. It just makes slight adjustments-using strategies like clipping and a KL penalty-to guarantee the policy does not wander off too far from its original behavior.


A cool element of GRPO is its versatility. You can use simple rule-based reward functions-for instance, granting a bonus offer when the design properly uses the syntax-to guide the training.


While DeepSeek used GRPO, you might use alternative methods rather (PPO or PRIME).


For those aiming to dive deeper, Will Brown has actually composed quite a nice execution of training an LLM with RL utilizing GRPO. GRPO has actually also already 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 course to AGI?


As a last 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 upon a point Yannic Kilcher made in his video.


These findings indicate that RL improves the design's overall efficiency by rendering the output circulation more robust, in other words, it seems that the enhancement is credited to enhancing the appropriate response from TopK instead of the enhancement 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 appropriate, despite the fact that the total ability (as determined by the variety of proper responses) is mainly present in the pretrained design.


This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing distribution of responses rather than endowing the design with completely new abilities.
Consequently, while RL techniques such as PPO and GRPO can produce considerable performance gains, there appears to be an inherent ceiling determined 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 delighted to see how it unfolds!


Running DeepSeek-R1


I have actually used DeepSeek-R1 by means of the main chat user interface for alldogssportspark.com different issues, which it seems to fix 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 testing, R1 appears more powerful at mathematics than o3-mini.


I likewise 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 objective was to see how the model would perform 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 running 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 overcome 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their local video gaming setup.
Digital Spaceport composed a full 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 rather manageable for any severe work, however it's fun to run these big models on available hardware.


What matters most to me is a mix of effectiveness and time-to-usefulness in these designs. Since reasoning designs require to believe before addressing, their time-to-usefulness is typically higher than other models, however their usefulness is likewise normally greater.
We need to both optimize effectiveness and lessen 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 anticipated 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 scientist" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish 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 granny - 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 comprehend and produce images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking design that equals the efficiency of OpenAI's o1. It presents a detailed method for training such models utilizing massive reinforcement knowing methods.
DeepSeek-V3 Technical Report (December 2024) This report goes over the execution of an FP8 blended precision training framework verified on an extremely large-scale design, attaining both sped up training and decreased GPU memory usage.
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 large-scale designs in open-source configurations. It presents the DeepSeek LLM job, 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 presents 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 top quality project-level code corpus and 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 defined by economical training and effective reasoning.
DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research introduces DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains efficiency 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 scientist confirms the DeepSeek team individually found and used some core concepts the OpenAI team utilized en route to o1


Liked this post? Join the newsletter.

Comments