Understanding DeepSeek R1

Comments · 132 Views

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

DeepSeek-R1 is an open-source language design 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 criteria, but it also includes totally MIT-licensed weights. This marks it as the first non-OpenAI/Google design to deliver strong reasoning capabilities in an open and available way.


What makes DeepSeek-R1 especially interesting is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has actually released a detailed training approach in their paper.
The model is also incredibly cost-effective, 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 designs needed more information and compute. While that's still legitimate, models like o1 and R1 show an alternative: inference-time scaling through thinking.


The Essentials


The DeepSeek-R1 paper presented multiple models, however main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while intriguing, I won't go over here.


DeepSeek-R1 utilizes two major concepts:


1. A multi-stage pipeline where a little set of cold-start information kickstarts the design, followed by massive RL.
2. Group Relative Policy Optimization (GRPO), a support learning technique that depends on comparing numerous model outputs per timely to prevent the need for a different critic.


R1 and R1-Zero are both thinking designs. This essentially implies they do Chain-of-Thought before addressing. For the R1 series of designs, this takes type as thinking within a tag, before responding to 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 used to enhance the design's policy to optimize benefit.
R1-Zero attains exceptional precision however sometimes produces complicated outputs, such as mixing several languages in a single reaction. R1 repairs that by integrating restricted monitored fine-tuning and several RL passes, which enhances both correctness and readability.


It is intriguing how some languages may reveal certain ideas better, which leads the design to choose the most meaningful language for the job.


Training Pipeline


The training pipeline that DeepSeek published in the R1 paper is profoundly interesting. It showcases how they developed such strong reasoning designs, and what you can expect from each phase. This consists of 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 normal:


The usual training strategy: Pretraining on large dataset (train to predict next word) to get the base model → monitored fine-tuning → preference tuning through 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 make sure the RL procedure has a good beginning point. This offers a good design to begin RL.
First RL Stage: Apply GRPO with rule-based rewards to improve thinking accuracy and format (such as requiring chain-of-thought into thinking tags). When they were near convergence in the RL procedure, they transferred to the next action. The outcome of this action is a strong reasoning design but with weak basic capabilities, e.g., poor format and language mixing.
Rejection Sampling + basic information: Create brand-new SFT information through rejection tasting on the RL checkpoint (from step 2), combined with monitored data from the DeepSeek-V3-Base design. They gathered around 600k top quality thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k general tasks) for broader abilities. This step led to a strong reasoning model with general capabilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to refine the final design, in addition to the reasoning rewards. The result is DeepSeek-R1.
They likewise did model distillation for numerous Qwen and Llama models on the thinking traces to get distilled-R1 designs.


Model distillation is a technique where you use a teacher model to improve a trainee design by producing training data for the trainee model.
The teacher is typically a bigger design than the trainee.


Group Relative Policy Optimization (GRPO)


The basic idea behind utilizing reinforcement knowing for LLMs is to fine-tune the design's policy so that it naturally produces more precise and helpful responses.
They used a benefit system that examines not only for correctness but likewise for appropriate formatting and language consistency, so the model slowly finds out to favor reactions that satisfy these quality requirements.


In this paper, they encourage the R1 design to create chain-of-thought reasoning through RL training with GRPO.
Instead of adding a different module at reasoning time, the training process itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the optimized policy.


What makes their technique particularly interesting is its reliance on straightforward, rule-based benefit functions.
Instead of depending upon costly external designs or human-graded examples as in conventional RLHF, the RL used for R1 utilizes simple criteria: it might provide a higher benefit if the answer is right, if it follows the expected/ formatting, and if the language of the answer matches that of the timely.
Not depending on a benefit model also implies you don't need to spend time and effort training it, and it does not take memory and calculate away from your main model.


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


1. For each input prompt, the design generates different actions.
2. Each response receives a scalar reward based upon aspects like precision, format, and language consistency.
3. Rewards are adjusted relative to the group's performance, basically measuring how much better each response is compared to the others.
4. The model updates its strategy somewhat to prefer actions with greater relative advantages. It just makes minor adjustments-using techniques like clipping and a KL penalty-to guarantee the policy does not wander off too far from its initial behavior.


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


While DeepSeek used GRPO, you might utilize alternative approaches instead (PPO or PRIME).


For those aiming to dive much deeper, Will Brown has actually written rather a nice application of training an LLM with RL using GRPO. GRPO has also 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 path to AGI?


As a last note on explaining DeepSeek-R1 and the approaches they have actually presented in their paper, I wish to highlight a passage from the DeepSeekMath paper, opentx.cz based on a point Yannic Kilcher made in his video.


These findings indicate that RL enhances the model's overall performance by rendering the output circulation more robust, to put it simply, it appears that the enhancement is credited to enhancing the proper action from TopK instead of the improvement of fundamental abilities.


Simply put, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are most likely to be proper, even though the overall capability (as determined by the variety of proper responses) is mainly present in the pretrained design.


This suggests that reinforcement knowing on LLMs is more about refining and "forming" the existing circulation of reactions instead of enhancing the design with completely brand-new abilities.
Consequently, while RL methods such as PPO and GRPO can produce substantial performance gains, there appears to be an inherent 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 turning point. I'm delighted to see how it unfolds!


Running DeepSeek-R1


I have actually used DeepSeek-R1 via the main chat interface for various issues, which it appears to resolve all right. The extra search functionality makes it even nicer to use.


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


I also rented a single H100 through Lambda Labs for wavedream.wiki $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 design would carry out when deployed on a single H100 GPU-not to extensively evaluate the design's abilities.


671B through 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 operating on the GPU), running through llama.cpp:


29 layers seemed to be the sweet area given 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 wrote a full guide on how to run Deepseek R1 671b fully 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 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 effectiveness and time-to-usefulness in these models. Since reasoning designs require to believe before responding to, their time-to-usefulness is typically greater than other models, but their effectiveness is also usually higher.
We require to both optimize usefulness and lessen time-to-usefulness.


70B by means of Ollama


70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of Ollama:


GPU utilization 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 regional "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 a novel autoregressive structure that combines 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 introduces DeepSeek-R1, an open-source thinking model that rivals the efficiency of OpenAI's o1. It provides a detailed methodology for training such designs utilizing massive reinforcement knowing methods.
DeepSeek-V3 Technical Report (December 2024) This report discusses the implementation of an FP8 combined precision training structure confirmed on a very massive design, attaining both sped up training and reduced GPU memory usage.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper delves into scaling laws and presents findings that assist in the scaling of massive designs in open-source configurations. It introduces the DeepSeek LLM project, 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 introduces the DeepSeek-Coder series, a series of open-source code designs trained from scratch on 2 trillion tokens. The models are pre-trained on a high-quality 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 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 model that attains efficiency comparable to GPT-4 Turbo in code-specific jobs.


Interesting events


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


Liked this post? Join the newsletter.

Comments