Understanding DeepSeek R1

Comments · 11 Views

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

DeepSeek-R1 is an open-source language design constructed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not only does it match-or even surpass-OpenAI's o1 model in many criteria, however it likewise comes with totally MIT-licensed weights. This marks it as the first non-OpenAI/Google model to provide strong reasoning capabilities in an open and available manner.


What makes DeepSeek-R1 particularly interesting is its openness. Unlike the less-open methods from some industry leaders, DeepSeek has actually published a detailed training method in their paper.
The model is likewise extremely 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 required more information 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, however main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while intriguing, I will not talk about here.


DeepSeek-R1 utilizes two major concepts:


1. A multi-stage pipeline where a small set of cold-start data kickstarts the model, followed by massive RL.
2. Group Relative Policy Optimization (GRPO), a support learning technique that counts on comparing multiple model outputs per timely to avoid the requirement for a different critic.


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


R1-Zero vs R1


R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is used to enhance the design's policy to optimize benefit.
R1-Zero attains exceptional precision but in some cases produces complicated outputs, such as mixing several languages in a single action. R1 repairs that by integrating restricted monitored fine-tuning and numerous RL passes, which enhances both accuracy and readability.


It is intriguing how some languages may express certain concepts much better, which leads the model to pick the most expressive language for the job.


Training Pipeline


The training pipeline that DeepSeek published in the R1 paper is immensely interesting. It showcases how they produced such strong thinking designs, and what you can anticipate from each stage. This consists of the issues that the resulting models from each stage have, and how they resolved it in the next phase.


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


The normal training method: hb9lc.org Pretraining on big dataset (train to predict next word) to get the base design → supervised fine-tuning → choice tuning via RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with numerous SFT and RL stages


Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a good starting point. This gives an excellent model to start RL.
First RL Stage: Apply GRPO with rule-based rewards to improve reasoning accuracy and formatting (such as forcing chain-of-thought into believing tags). When they were near merging in the RL procedure, they relocated to the next action. The outcome of this action is a strong reasoning model however with weak general capabilities, e.g., bad formatting and language blending.
Rejection Sampling + general data: Create brand-new SFT information through rejection sampling on the RL checkpoint (from step 2), combined with monitored information from the DeepSeek-V3-Base model. They collected 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 capabilities. This step resulted in a strong reasoning model with general capabilities.
Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the final model, in addition to the reasoning rewards. The outcome is DeepSeek-R1.
They likewise did design distillation for several Qwen and Llama designs on the reasoning traces to get distilled-R1 models.


Model distillation is a strategy where you use an instructor model to improve a trainee model by producing training information for the trainee model.
The instructor is normally a bigger model than the trainee.


Group Relative Policy Optimization (GRPO)


The basic idea behind utilizing support knowing for LLMs is to tweak the model's policy so that it naturally produces more precise and beneficial responses.
They utilized a reward system that inspects not just for accuracy however likewise for proper format and language consistency, so the model slowly finds out to favor actions 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 adding a different module at reasoning time, the training procedure itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the optimized policy.


What makes their technique particularly intriguing is its reliance on straightforward, rule-based benefit functions.
Instead of depending upon costly external designs or human-graded examples as in standard RLHF, the RL used for R1 utilizes simple criteria: it may offer a higher reward if the response is correct, if it follows the expected/ formatting, and if the language of the answer matches that of the timely.
Not depending on a benefit design also suggests you do not have to hang around and effort training it, and it doesn't take memory and compute far from your main design.


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


1. For each input prompt, the model produces different actions.
2. Each reaction receives a scalar reward based on factors like precision, formatting, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, essentially determining just how much better each action is compared to the others.
4. The design updates its technique a little to favor reactions with greater relative benefits. It just makes slight adjustments-using strategies like clipping and a KL penalty-to make sure the policy doesn't stray too far from its initial habits.


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


While DeepSeek used GRPO, you could utilize alternative methods rather (PPO or PRIME).


For those aiming to dive much deeper, Will Brown has written quite a great implementation of training an LLM with RL using GRPO. GRPO has actually likewise already been included 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 path to AGI?


As a last note on explaining DeepSeek-R1 and yewiki.org the approaches they've 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 show that RL boosts the design's general performance by rendering the output circulation more robust, in other words, it appears that the improvement is credited to boosting the right action from TopK instead of the enhancement of basic capabilities.


To put it simply, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more most likely to be proper, although the overall capability (as measured by the variety of correct answers) is mainly present in the pretrained design.


This recommends that support learning on LLMs is more about refining and "forming" the existing circulation of responses instead of endowing the design with totally brand-new abilities.
Consequently, while RL techniques such as PPO and GRPO can produce substantial performance gains, there appears to be an intrinsic ceiling figured out 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 big milestone. I'm thrilled to see how it unfolds!


Running DeepSeek-R1


I have actually used DeepSeek-R1 via the main chat user interface for different problems, which it seems to solve all right. The additional search functionality makes it even nicer to use.


Interestingly, o3-mini(-high) was released as I was writing this post. From my initial testing, R1 appears more powerful at math than o3-mini.


I likewise rented a single H100 via 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 by means of Llama.cpp


DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized design 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 provided this configuration.


Performance:


A r/localllama user explained that they were able to get over 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 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 quite bearable for any major work, but it's enjoyable to run these large designs on available hardware.


What matters most to me is a combination of effectiveness and time-to-usefulness in these designs. Since reasoning models need to think before addressing, their time-to-usefulness is typically higher than other designs, however their usefulness is likewise normally greater.
We need to both maximize effectiveness and decrease time-to-usefulness.


70B via Ollama


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


GPU usage 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 via Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a fully local "deep researcher" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to duplicate 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 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 comprehend and create images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking design that equals the performance of OpenAI's o1. It presents a detailed method for training such models using massive reinforcement learning methods.
DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 combined accuracy training structure confirmed on an exceptionally massive design, attaining both accelerated training and lowered GPU memory use.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and provides findings that assist in the scaling of massive designs in open-source setups. It introduces the DeepSeek LLM job, dedicated to advancing open-source language models with a long-term 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 designs are pre-trained on a high-quality project-level code corpus and utilize a fill-in-the-blank job to enhance 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 identified by economical training and efficient 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 design that attains efficiency comparable to GPT-4 Turbo in code-specific tasks.


Interesting occasions


- Hong Kong University reproduces 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 validates the DeepSeek team independently discovered and used some core ideas the OpenAI team used on the way to o1


Liked this post? Join the newsletter.

Comments