Understanding DeepSeek R1

Kommentare · 6 Ansichten

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

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


What makes DeepSeek-R1 particularly amazing is its openness. Unlike the less-open methods from some market leaders, DeepSeek has released a detailed training method in their paper.
The design is also incredibly cost-efficient, 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 knowledge was that better models needed more information and compute. While that's still valid, designs like o1 and R1 demonstrate an alternative: inference-time scaling through reasoning.


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 go over here.


DeepSeek-R1 utilizes two major ideas:


1. A multi-stage pipeline where a little set of cold-start information kickstarts the design, followed by large-scale RL.
2. Group Relative Policy Optimization (GRPO), a reinforcement knowing approach that relies on comparing several model outputs per prompt to avoid the need for a different critic.


R1 and R1-Zero are both reasoning designs. This basically implies they do Chain-of-Thought before addressing. For the R1 series of designs, this takes type as believing within a tag, before responding to with a last summary.


R1-Zero vs R1


R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any supervised fine-tuning (SFT). RL is utilized to optimize the model's policy to make the most of benefit.
R1-Zero attains exceptional precision however sometimes produces complicated outputs, such as blending several languages in a single reaction. R1 repairs that by integrating limited monitored fine-tuning and multiple RL passes, which improves both correctness and readability.


It is fascinating how some languages may reveal certain concepts better, which leads the model to choose the most meaningful language for the job.


Training Pipeline


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


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


The typical training technique: Pretraining on large dataset (train to anticipate next word) to get the base design → monitored fine-tuning → preference tuning via RLHF
R1-Zero: Pretrained → RL
R1: Pretrained → Multistage training pipeline with numerous SFT and RL phases


Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a few thousand Chain-of-Thought (CoT) samples to guarantee the RL procedure has a good starting point. This provides a great design to start RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance thinking correctness and formatting (such as forcing chain-of-thought into believing tags). When they were near merging in the RL procedure, they transferred to the next step. The outcome of this step is a strong thinking design however with weak general abilities, e.g., bad formatting and language mixing.
Rejection Sampling + basic information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), combined with supervised data from the DeepSeek-V3-Base design. They gathered around 600k high-quality reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k general tasks) for broader abilities. This step resulted in a strong thinking design with general capabilities.
Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the last design, in addition to the reasoning rewards. The result is DeepSeek-R1.
They also did design distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.


Model distillation is a strategy where you utilize a teacher design to improve a trainee design by creating training data for the trainee model.
The instructor is usually a larger design than the trainee.


Group Relative Policy Optimization (GRPO)


The standard concept behind utilizing reinforcement learning for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and useful answers.
They used a reward system that checks not only for correctness however also for correct format and language consistency, so the model slowly discovers to prefer actions that meet these quality criteria.


In this paper, they encourage the R1 design to create chain-of-thought thinking through RL training with GRPO.
Rather than including a different module at inference time, the training procedure itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the enhanced policy.


What makes their technique particularly intriguing is its reliance on straightforward, rule-based reward functions.
Instead of depending upon expensive external models or human-graded examples as in conventional RLHF, the RL utilized for R1 utilizes simple criteria: it may give a greater reward if the answer is correct, if it follows the expected/ format, and if the language of the response matches that of the prompt.
Not relying on a benefit design also means you do not have to hang around and effort training it, and it does not take memory and calculate far from your main design.


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


1. For each input timely, timeoftheworld.date the model creates various reactions.
2. Each action receives a scalar reward based upon factors like accuracy, formatting, and language consistency.
3. Rewards are adjusted relative to the group's efficiency, basically determining just how much better each action is compared to the others.
4. The model updates its technique a little to favor responses with higher relative advantages. It only makes small adjustments-using strategies like clipping and a KL penalty-to guarantee the policy does not wander off too far from its original behavior.


A cool aspect of GRPO is its versatility. You can use simple rule-based benefit functions-for circumstances, awarding a perk when the design correctly uses the syntax-to guide the training.


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


For those aiming to dive much deeper, Will Brown has composed rather a great application of training an LLM with RL utilizing GRPO. GRPO has also currently been contributed to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 methods they have actually provided in their paper, I want to highlight a passage from the DeepSeekMath paper, online-learning-initiative.org based upon a point Yannic Kilcher made in his video.


These findings suggest that RL enhances the model's general efficiency by rendering the output distribution more robust, in other words, it seems that the enhancement is credited to increasing the appropriate reaction from TopK rather than 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 more most likely to be proper, even though the overall ability (as determined by the variety of appropriate responses) is mainly present in the pretrained design.


This suggests that reinforcement knowing on LLMs is more about refining and "forming" the existing distribution of actions rather than endowing the design with totally brand-new capabilities.
Consequently, while RL methods such as PPO and GRPO can produce significant performance gains, there seems an inherent ceiling identified by the underlying model'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 thrilled to see how it unfolds!


Running DeepSeek-R1


I've used DeepSeek-R1 via the main chat interface for numerous issues, which it appears to solve all right. The additional search performance makes it even nicer to use.


Interestingly, o3-mini(-high) was released as I was composing this post. From my initial testing, R1 seems more powerful at mathematics 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 objective was to see how the design would perform when released on a single H100 GPU-not to thoroughly test the model'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 by means of 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 get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their local video gaming setup.
Digital Spaceport composed 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 quite manageable for any severe work, but it's fun to run these large designs on available hardware.


What matters most to me is a mix of effectiveness and time-to-usefulness in these designs. Since thinking designs require to believe before responding to, their time-to-usefulness is usually greater than other models, however their usefulness is also usually greater.
We need to both take full advantage of usefulness and lessen time-to-usefulness.


70B through 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 through Reinforcement Learning
[2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
DeepSeek R1 - Notion (Building a totally regional "deep scientist" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to reproduce 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 framework that unifies multimodal understanding and generation. It can both comprehend and generate images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that matches the performance of OpenAI's o1. It presents a detailed methodology for training such models utilizing massive reinforcement learning strategies.
DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 mixed precision training structure validated on an exceptionally 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 looks into scaling laws and provides findings that help with the scaling of massive designs in open-source setups. It introduces the DeepSeek LLM task, devoted to advancing open-source language designs with a long-lasting point of view.
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 top quality project-level code corpus and use 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 model defined 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 performance equivalent to GPT-4 Turbo in code-specific tasks.


Interesting events


- Hong Kong University reproduces R1 results (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, completely open source (Jan 25, '25).
- OpenAI scientist validates the DeepSeek team separately found and used some core concepts the OpenAI group used en route to o1


Liked this post? Join the newsletter.

Kommentare