Understanding DeepSeek R1

Comments · 2 Views

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


What makes DeepSeek-R1 particularly exciting is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has released a detailed training method 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 designs required more data and compute. While that's still valid, designs like o1 and mariskamast.net R1 demonstrate an alternative: inference-time scaling through thinking.


The Essentials


The DeepSeek-R1 paper provided multiple models, but main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while fascinating, I won't talk about here.


DeepSeek-R1 utilizes 2 major 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 approach that depends on comparing multiple model outputs per prompt to prevent the requirement for a separate critic.


R1 and R1-Zero are both reasoning designs. This essentially means they do Chain-of-Thought before responding to. For the R1 series of designs, this takes type as believing within a tag, before addressing 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 used to enhance the model's policy to optimize benefit.
R1-Zero attains exceptional accuracy however often produces complicated outputs, such as blending multiple languages in a single response. R1 repairs that by including minimal supervised fine-tuning and multiple RL passes, which enhances both correctness and readability.


It is intriguing how some languages might express certain concepts much better, which leads the model to select the most meaningful language for visualchemy.gallery the task.


Training Pipeline


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


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


The normal training technique: Pretraining on large dataset (train to forecast next word) to get the base design → supervised fine-tuningpreference tuning via RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with several 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 process has a good beginning point. This provides a good model to start 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 merging in the RL process, they transferred to the next action. The result of this step is a strong reasoning model but with weak general capabilities, e.g., poor formatting and language blending.
Rejection Sampling + basic information: Create brand-new SFT information through rejection sampling on the RL checkpoint (from step 2), integrated with monitored data from the DeepSeek-V3-Base design. They collected around 600k high-quality thinking samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic tasks) for broader capabilities. This step resulted in a strong thinking design with general abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to refine the final design, in addition to the thinking rewards. The outcome is DeepSeek-R1.
They also did model 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 design to enhance a trainee design by producing training data for the trainee design.
The instructor is usually a bigger model than the trainee.


Group Relative Policy Optimization (GRPO)


The fundamental concept behind utilizing reinforcement knowing for LLMs is to tweak the design's policy so that it naturally produces more accurate and useful responses.
They utilized a reward system that examines not just for correctness however also for correct format and language consistency, so the model gradually finds out to favor responses that meet these quality requirements.


In this paper, yogaasanas.science they encourage the R1 model to create chain-of-thought reasoning through RL training with GRPO.
Instead of including a different module at reasoning time, forum.batman.gainedge.org the training process itself pushes the design to produce detailed, detailed outputs-making the chain-of-thought an emerging behavior of the optimized policy.


What makes their method particularly fascinating 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 utilized for R1 uses basic criteria: it might give a greater benefit if the response is appropriate, if it follows the expected/ formatting, akropolistravel.com and if the language of the response matches that of the timely.
Not depending on a reward design likewise implies you don't have to hang out 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 design creates different actions.
2. Each response gets a scalar reward based upon aspects like precision, formatting, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, basically determining how much better each response is compared to the others.
4. The model updates its technique slightly to favor reactions with higher relative advantages. It just makes minor adjustments-using strategies like clipping and a KL penalty-to ensure the policy doesn't stray too far from its original behavior.


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


While DeepSeek utilized GRPO, you could utilize alternative approaches instead (PPO or PRIME).


For those aiming to dive deeper, Will Brown has composed quite a good application of training an LLM with RL using GRPO. GRPO has actually also already been included to the Transformer Reinforcement Learning (TRL) library, which is another good 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 final note on explaining DeepSeek-R1 and the approaches they have actually provided 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 model's general performance by rendering the output distribution more robust, to put it simply, it appears that the improvement is credited to improving the proper action from TopK instead of the enhancement of essential capabilities.


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


This recommends that reinforcement learning on LLMs is more about refining and "forming" the existing circulation of reactions instead of enhancing the model with completely new abilities.
Consequently, while RL techniques such as PPO and GRPO can produce significant performance gains, there appears to be an inherent ceiling determined 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 huge milestone. I'm delighted to see how it unfolds!


Running DeepSeek-R1


I have actually used DeepSeek-R1 via the main chat interface for different issues, wiki.dulovic.tech which it seems to fix well enough. The additional search functionality makes it even nicer to utilize.


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


I also rented a single H100 through 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 carry out when released on a single H100 GPU-not to extensively test the model's abilities.


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


29 layers appeared to be the sweet area offered this configuration.


Performance:


A r/localllama user explained that they were able to overcome 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 manageable for any severe work, but it's enjoyable to run these large models on available hardware.


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


70B through Ollama


70.6 b params, 4-bit KM quantized DeepSeek-R1 running through 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 through Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a completely regional "deep researcher" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to duplicate 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 grandma - 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 unifies multimodal understanding and generation. It can both comprehend and produce images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking design that matches the efficiency of OpenAI's o1. It provides a detailed methodology for training such models using massive support learning techniques.
DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 blended precision training structure verified on an exceptionally large-scale design, attaining both accelerated training and decreased GPU memory usage.
DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper delves into scaling laws and presents findings that help with the scaling of massive models in open-source setups. It introduces the DeepSeek LLM job, committed to advancing open-source language models with a long-lasting perspective.
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 designs are pre-trained on a top quality project-level code corpus and employ a fill-in-the-blank job 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 characterized by affordable training and effective 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 design that attains efficiency comparable to GPT-4 Turbo in code-specific jobs.


Interesting occasions


- Hong Kong University replicates R1 results (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, completely open source (Jan 25, '25).
- OpenAI scientist verifies the DeepSeek team individually found and utilized some core ideas the OpenAI team utilized on the method to o1


Liked this post? Join the newsletter.

Comments