Understanding DeepSeek R1

Comments · 59 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 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 model in many benchmarks, however it also comes with totally MIT-licensed weights. This marks it as the first non-OpenAI/Google design to provide strong thinking capabilities in an open and available way.


What makes DeepSeek-R1 especially amazing is its transparency. Unlike the less-open approaches from some industry leaders, DeepSeek has actually published a detailed training approach in their paper.
The design is likewise extremely 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 knowledge was that much better models required more information and compute. 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 numerous models, however main among 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 concepts:


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 method that depends on comparing multiple design outputs per timely to prevent the requirement for a separate critic.


R1 and R1-Zero are both thinking models. This essentially means they do Chain-of-Thought before addressing. For the R1 series of models, this takes kind as thinking within a tag, before responding to 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 utilized to optimize the model's policy to optimize reward.
R1-Zero attains excellent precision however in some cases produces confusing outputs, such as blending numerous languages in a single response. R1 repairs that by integrating limited monitored fine-tuning and numerous RL passes, which enhances both correctness and readability.


It is intriguing how some languages might reveal certain concepts better, which leads the model to pick the most expressive language for the task.


Training Pipeline


The training pipeline that DeepSeek released in the R1 paper is exceptionally fascinating. It showcases how they developed such strong thinking models, and what you can expect from each phase. This includes the problems that the resulting designs from each phase have, and how they solved it in the next stage.


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


The normal training method: Pretraining on big dataset (train to predict next word) to get the base design → monitored fine-tuningpreference tuning by means of RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage 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 good starting point. This offers an excellent model to start RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance thinking accuracy and format (such as requiring chain-of-thought into believing tags). When they were near convergence in the RL process, they transferred to the next action. The outcome of this step is a strong reasoning model however with weak general abilities, e.g., bad format and language mixing.
Rejection Sampling + basic information: Create new SFT information through rejection sampling on the RL checkpoint (from action 2), integrated with supervised data from the DeepSeek-V3-Base design. They gathered around 600k premium thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k general jobs) for wider capabilities. This step resulted in a strong thinking design with general abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to improve the final design, in addition to the reasoning rewards. The result is DeepSeek-R1.
They likewise did model distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.


Model distillation is a method where you utilize an instructor design to enhance a trainee design by generating training data for the trainee design.
The instructor is typically a bigger design than the trainee.


Group Relative Policy Optimization (GRPO)


The fundamental concept behind utilizing 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 correctness however likewise for correct format and language consistency, so the model gradually learns to favor reactions that meet these quality requirements.


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 inference time, the training process itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the enhanced policy.


What makes their approach especially fascinating is its dependence on straightforward, rule-based reward functions.
Instead of depending on pricey external models or human-graded examples as in traditional RLHF, the RL used for R1 uses simple criteria: it might provide a higher benefit if the answer is correct, if it follows the anticipated/ format, and if the language of the answer matches that of the prompt.
Not depending on a reward design likewise indicates you do not have to hang out and effort training it, and it doesn't take memory and calculate away from your main model.


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


1. For each input timely, the design generates various actions.
2. Each response gets a scalar reward based upon aspects like accuracy, format, and language consistency.
3. Rewards are adjusted relative to the group's performance, basically determining just how much better each action is compared to the others.
4. The design updates its technique slightly to favor reactions with greater relative benefits. It only makes small adjustments-using strategies like clipping and a KL penalty-to ensure the policy does not wander off too far from its initial behavior.


A cool aspect of GRPO is its versatility. You can utilize simple rule-based reward functions-for wiki.die-karte-bitte.de instance, awarding a benefit when the model properly uses the syntax-to guide the training.


While DeepSeek utilized GRPO, you might utilize alternative techniques rather (PPO or PRIME).


For those aiming to dive deeper, Will Brown has composed rather a good implementation 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 great resource.
Finally, Yannic Kilcher has a great 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 approaches they've presented in their paper, I desire to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.


These findings indicate that RL enhances the design's overall performance by rendering the output distribution more robust, in other words, it appears that the enhancement is attributed to improving the proper response from TopK instead of the improvement of basic capabilities.


To put it simply, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are more most likely to be proper, although the total ability (as determined by the variety of proper answers) is mainly present in the pretrained model.


This suggests that reinforcement learning on LLMs is more about refining and "forming" the existing distribution of responses instead of enhancing the design with completely new abilities.
Consequently, while RL strategies such as PPO and GRPO can produce substantial efficiency gains, there appears to be a fundamental ceiling identified by the underlying design's pretrained knowledge.


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 have actually used DeepSeek-R1 through the main chat user interface for various problems, which it appears to resolve well enough. The extra search functionality makes it even better to use.


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


I also rented 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 goal was to see how the model would perform when deployed on a single H100 GPU-not to extensively evaluate the model's capabilities.


671B through 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 running on the GPU), running via 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 video gaming setup.
Digital Spaceport wrote a full guide on how to run Deepseek R1 671b fully 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 enjoyable to run these big designs on available hardware.


What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since reasoning models need to think before responding to, their time-to-usefulness is generally higher than other designs, but their usefulness is also usually higher.
We need to both take full advantage of effectiveness and decrease time-to-usefulness.


70B by means of Ollama


70.6 b params, 4-bit KM quantized DeepSeek-R1 running through 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 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 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 framework that merges multimodal understanding and generation. It can both understand 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 performance of OpenAI's o1. It presents a detailed methodology for training such designs using large-scale reinforcement learning strategies.
DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 blended precision training framework confirmed on an incredibly large-scale model, attaining both sped up training and minimized GPU memory usage.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and presents findings that facilitate the scaling of large-scale designs in open-source configurations. It presents the DeepSeek LLM job, dedicated 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 presents 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 premium project-level code corpus and employ 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 identified by affordable training and efficient inference.
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 performance comparable to GPT-4 Turbo in code-specific jobs.


Interesting occasions


- Hong Kong University reproduces R1 outcomes (Jan 25, '25).
- Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, completely open source (Jan 25, '25).
- OpenAI researcher verifies the DeepSeek team individually found and utilized some core concepts the OpenAI team used on the method to o1


Liked this post? Join the newsletter.

Comments