Understanding DeepSeek R1

Comments · 31 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 model 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 design in lots of benchmarks, however it likewise includes totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong reasoning abilities in an open and available manner.


What makes DeepSeek-R1 particularly amazing is its openness. Unlike the less-open methods from some industry leaders, DeepSeek has published a detailed training approach in their paper.
The model is also remarkably economical, 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 better models needed more data and calculate. While that's still valid, models like o1 and R1 demonstrate an alternative: inference-time scaling through reasoning.


The Essentials


The DeepSeek-R1 paper provided multiple designs, but main amongst them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I will not discuss here.


DeepSeek-R1 utilizes 2 major ideas:


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 knowing method that counts on comparing several model outputs per prompt to prevent the requirement for a different critic.


R1 and R1-Zero are both reasoning designs. This basically means they do Chain-of-Thought before responding to. For the R1 series of models, this takes kind 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 design's policy to take full advantage of benefit.
R1-Zero attains exceptional precision but sometimes produces complicated outputs, such as mixing several languages in a single response. R1 repairs that by including minimal monitored fine-tuning and several RL passes, which improves both correctness and readability.


It is interesting how some languages might express certain ideas 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 profoundly fascinating. It showcases how they produced such strong thinking models, and what you can expect from each phase. This includes the problems that the resulting models from each stage have, and how they resolved it in the next stage.


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


The typical training strategy: Pretraining on large dataset (train to anticipate next word) to get the base model → supervised fine-tuning → choice tuning via 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 few thousand Chain-of-Thought (CoT) samples to guarantee the RL process has a good starting point. This provides an excellent design to begin RL.
First RL Stage: Apply GRPO with rule-based benefits to improve thinking accuracy and formatting (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL process, they relocated to the next action. The result of this action is a strong thinking design however with weak basic capabilities, e.g., poor format and language mixing.
Rejection Sampling + basic information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), integrated with supervised information from the DeepSeek-V3-Base design. They collected around 600k premium reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k general jobs) for broader capabilities. This action resulted in a strong thinking model with basic capabilities.
Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the last design, in addition to the reasoning benefits. The result is DeepSeek-R1.
They likewise did model distillation for several Qwen and Llama models on the thinking traces to get distilled-R1 designs.


Model distillation is a method where you utilize an instructor design to improve a trainee model by producing training information for the trainee model.
The instructor is typically a larger design than the trainee.


Group Relative Policy Optimization (GRPO)


The standard idea behind using reinforcement knowing for LLMs is to tweak the design's policy so that it naturally produces more precise and beneficial answers.
They used a reward system that examines not only for correctness however also for appropriate formatting and language consistency, so the model slowly finds out to prefer responses that satisfy these quality criteria.


In this paper, they motivate the R1 design to create chain-of-thought thinking through RL training with GRPO.
Rather than including a separate module at reasoning time, the training procedure 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 particularly interesting is its dependence on straightforward, rule-based reward functions.
Instead of depending upon pricey external models or human-graded examples as in traditional RLHF, the RL used for R1 utilizes easy requirements: it may provide a greater reward if the response is proper, if it follows the expected/ format, and if the language of the response matches that of the prompt.
Not counting on a benefit design also indicates 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 introduced in the DeepSeekMath paper. Here's how GRPO works:


1. For each input prompt, the model creates different actions.
2. Each response gets a scalar benefit based on elements like precision, format, and language consistency.
3. Rewards are adjusted relative to the group's performance, essentially determining just how much better each response is compared to the others.
4. The model updates its technique a little to favor actions with higher relative benefits. It only makes small adjustments-using techniques like clipping and a KL penalty-to make sure the policy does not wander off too far from its initial habits.


A cool aspect of GRPO is its versatility. You can use easy rule-based reward functions-for forum.batman.gainedge.org instance, granting a reward when the model correctly utilizes 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 actually composed quite a good implementation of training an LLM with RL utilizing GRPO. GRPO has actually also currently been included to the Transformer Reinforcement Learning (TRL) library, bytes-the-dust.com which is another great 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 final note on explaining DeepSeek-R1 and the methodologies 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 indicate that RL enhances the model's total performance by rendering the output circulation more robust, in other words, it seems that the improvement is associated to boosting the correct response from TopK instead of the improvement of fundamental capabilities.


To put it simply, RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are most likely to be correct, even though the general ability (as determined by the variety of appropriate responses) is mainly present in the pretrained design.


This recommends that support knowing on LLMs is more about refining and "forming" the existing distribution of reactions rather than endowing the design with completely brand-new capabilities.
Consequently, while RL strategies such as PPO and GRPO can produce considerable efficiency gains, there seems an inherent ceiling identified 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 excited to see how it unfolds!


Running DeepSeek-R1


I have actually utilized DeepSeek-R1 via the main chat user interface for different problems, which it seems to resolve all right. The extra search functionality makes it even nicer to utilize.


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


I likewise leased 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 goal was to see how the model would carry out when released on a single H100 GPU-not to thoroughly 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 working on the GPU), running through llama.cpp:


29 layers seemed 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 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 rather manageable for any major users.atw.hu work, but 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 thinking models need to believe before answering, their time-to-usefulness is normally greater than other designs, however their effectiveness is likewise generally greater.
We require to both make the most of effectiveness and decrease 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 by means of 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 recipe 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 a novel autoregressive framework that combines multimodal understanding and generation. It can both comprehend and generate images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking design that matches the efficiency of OpenAI's o1. It presents a detailed approach for training such designs utilizing large-scale support knowing strategies.
DeepSeek-V3 Technical Report (December 2024) This report discusses the implementation of an FP8 combined accuracy training framework verified on an extremely 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 digs into scaling laws and provides findings that help with the scaling of massive models in open-source setups. It introduces the DeepSeek LLM task, committed 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 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 premium project-level code corpus and utilize a fill-in-the-blank job to enhance code generation and infilling.
DeepSeek-V2: wiki.myamens.com A Strong, Economical, and Efficient Mixture-of-Experts Language Model (May 2024) This paper provides DeepSeek-V2, a Mixture-of-Experts (MoE) language model defined by economical training and scientific-programs.science 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 model that attains efficiency equivalent to GPT-4 Turbo in code-specific jobs.


Interesting occasions


- Hong Kong University reproduces R1 results (Jan 25, '25).
- Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, fully open source (Jan 25, '25).
- OpenAI researcher confirms the DeepSeek group separately discovered and used some core ideas the OpenAI group used on the way to o1


Liked this post? Join the newsletter.

Comments