Skip to content

Understanding DeepSeek R1


DeepSeek-R1 is an open-source language model 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 numerous standards, however it also features fully 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 especially exciting is its openness. Unlike the less-open techniques from some market leaders, DeepSeek has actually released a detailed training method in their paper. The design is likewise remarkably affordable, 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 typical knowledge was that better designs needed more data and compute. While that's still legitimate, designs like o1 and R1 show an alternative: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper presented models, but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while fascinating, I won't discuss here.

DeepSeek-R1 uses two significant ideas:

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

R1 and R1-Zero are both reasoning models. This basically implies 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 last summary.

R1-Zero vs R1

R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is used to enhance the design's policy to optimize reward. R1-Zero attains excellent precision however sometimes produces confusing outputs, such as mixing several languages in a single action. R1 repairs that by incorporating limited supervised fine-tuning and several RL passes, which enhances both correctness and readability.

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

Training Pipeline

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

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

The typical training technique: Pretraining on large dataset (train to anticipate next word) to get the base design → monitored 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 make sure the RL process has a good beginning point. This offers a great design to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and format (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL procedure, they transferred to the next action. The result of this step is a strong thinking design but with weak general abilities, townshipmarket.co.za e.g., bad formatting and language blending. Rejection Sampling + basic data: Create new SFT data 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 reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k basic jobs) for wider capabilities. This step resulted in a strong thinking design with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to improve the final 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 method where you utilize a teacher design to enhance a trainee design by creating training information for the trainee model. The teacher is typically a larger model than the trainee.

Group Relative Policy Optimization (GRPO)

The standard concept behind utilizing support learning for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and useful responses. They used a benefit system that checks not just for accuracy however also for correct formatting and language consistency, so the model gradually learns to favor reactions that meet these quality criteria.

In this paper, they encourage the R1 model to produce chain-of-thought reasoning through RL training with GRPO. Instead of adding a separate module at reasoning time, the training procedure itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emerging habits of the enhanced policy.

What makes their approach especially interesting is its reliance on straightforward, rule-based benefit functions. Instead of depending upon pricey external models or human-graded examples as in traditional RLHF, the RL used for R1 uses basic requirements: it might provide a greater reward if the answer is proper, if it follows the anticipated/ format, and if the language of the answer matches that of the timely. Not relying on a reward model also suggests you do not need 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 design generates different responses. 2. Each action receives a scalar benefit based on elements like accuracy, formatting, and language consistency. 3. Rewards are changed relative to the group's performance, basically measuring how much better each action is compared to the others. 4. The design updates its method a little to prefer responses with higher relative advantages. It only makes minor adjustments-using techniques like clipping and a KL penalty-to guarantee the policy does not stray too far from its original behavior.

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

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

For those aiming to dive deeper, Will Brown has actually composed quite a great execution of training an LLM with RL using GRPO. GRPO has likewise currently been included 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 course to AGI?

As a last note on explaining DeepSeek-R1 and the methods they've provided in their paper, I want to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

These findings show that RL improves the model's total performance by rendering the output distribution more robust, simply put, it appears that the improvement is credited to improving the correct action from TopK instead of the improvement of essential capabilities.

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

This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing distribution of responses instead of endowing the model with completely brand-new capabilities. Consequently, while RL techniques such as PPO and GRPO can produce significant performance gains, there seems a fundamental ceiling determined 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 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 numerous issues, which it appears to fix well enough. The additional search functionality makes it even nicer to utilize.

Interestingly, o3-mini(-high) was released as I was writing this post. From my initial screening, R1 seems stronger 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 goal was to see how the model would carry out when deployed on a single H100 GPU-not to thoroughly evaluate the design'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 working on the GPU), running by means of llama.cpp:

29 layers appeared to be the sweet spot given this configuration.

Performance:

A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their regional gaming setup. Digital Spaceport wrote a complete guide on how to run Deepseek R1 671b totally 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 manageable for any severe work, but it's fun to run these big designs on available hardware.

What matters most to me is a combination of effectiveness and time-to-usefulness in these designs. Since reasoning designs require to think before answering, their time-to-usefulness is usually greater than other models, however their effectiveness is likewise generally higher. We need to both make the most of usefulness and reduce time-to-usefulness.

70B through 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 via Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a totally local "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to reproduce 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 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 an unique autoregressive structure that unifies multimodal understanding and generation. It can both understand and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning design that rivals the efficiency of OpenAI's o1. It presents a detailed method for training such models using massive reinforcement learning techniques. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 combined accuracy training structure confirmed on an exceptionally large-scale model, attaining both accelerated training and lowered GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and presents findings that help with the scaling of massive designs in open-source setups. It introduces the DeepSeek LLM project, committed to advancing open-source language designs with a long-term perspective. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research introduces 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 top quality project-level code corpus and employ 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 design identified by affordable training and efficient inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research study presents 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 outcomes (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 confirms the DeepSeek team individually discovered and used some core concepts the OpenAI team used en route to o1

Liked this post? Join the newsletter.