1 Understanding DeepSeek R1
Abby McPhee edited this page 2 weeks ago


DeepSeek-R1 is an open-source language model 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 numerous benchmarks, but it also comes with fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to provide strong reasoning capabilities in an open and available manner.

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

The Essentials

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

DeepSeek-R1 utilizes two significant ideas:

1. A multi-stage pipeline where a small set of cold-start information kickstarts the design, followed by large-scale RL. 2. Group Relative Policy Optimization (GRPO), a support learning method that relies on comparing multiple model outputs per prompt to avoid the requirement for a different critic.

R1 and R1-Zero are both reasoning designs. This essentially indicates they do Chain-of-Thought before responding to. For the R1 series of designs, 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 supervised fine-tuning (SFT). RL is utilized to enhance the model's policy to take full advantage of benefit. R1-Zero attains outstanding accuracy however often produces complicated outputs, such as mixing several languages in a single reaction. R1 repairs that by incorporating minimal monitored fine-tuning and several RL passes, which improves both accuracy and readability.

It is fascinating how some languages might express certain ideas better, which leads the design to choose the most meaningful language for the task.

Training Pipeline

The training pipeline that DeepSeek released in the R1 paper is tremendously interesting. It showcases how they produced such strong reasoning designs, and what you can get out of each stage. This consists of the issues that the resulting models from each phase have, and how they solved it in the next stage.

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

The usual training technique: Pretraining on big dataset (train to predict next word) to get the base model → supervised fine-tuning → preference tuning via 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 few thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a good beginning point. This provides a good model to begin RL. First RL Stage: Apply GRPO with rule-based benefits to improve reasoning accuracy and formatting (such as forcing chain-of-thought into thinking tags). When they were near merging in the RL procedure, they transferred to the next step. The result of this action is a strong thinking design but with weak general abilities, e.g., bad formatting and language mixing. Rejection Sampling + general information: Create brand-new SFT information through rejection tasting on the RL checkpoint (from action 2), integrated with supervised information from the DeepSeek-V3-Base model. They gathered around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k basic jobs) for wider abilities. This action led to a strong reasoning model with general abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the last design, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They also did design distillation for numerous Qwen and Llama models on the thinking traces to get distilled-R1 models.

Model distillation is a method where you use an instructor design to improve a trainee design by generating training data for the trainee design. The instructor is generally a bigger model than the trainee.

Group Relative Policy Optimization (GRPO)

The standard idea behind utilizing support learning for LLMs is to tweak the design's policy so that it naturally produces more precise and useful answers. They used a reward system that inspects not just for accuracy but also for correct formatting and language consistency, so the model gradually learns to favor responses that satisfy these quality criteria.

In this paper, they motivate the R1 design to generate chain-of-thought reasoning through RL training with GRPO. Instead of including a different module at inference time, the training process itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emerging habits of the optimized policy.

What makes their approach especially intriguing is its reliance on straightforward, rule-based reward functions. Instead of depending upon expensive external designs or human-graded examples as in conventional RLHF, the RL used for R1 uses simple requirements: it may give a higher benefit if the answer is appropriate, if it follows the anticipated/ formatting, and if the language of the answer matches that of the timely. Not counting on a benefit model likewise suggests you do not have to hang out and effort training it, and it doesn't 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 produces different responses. 2. Each action gets a scalar benefit based upon elements like precision, format, and language consistency. 3. Rewards are adjusted relative to the group's performance, essentially determining just how much better each reaction is compared to the others. 4. The design updates its method a little to favor responses with greater relative benefits. It just makes minor adjustments-using techniques like clipping and a KL penalty-to guarantee the policy doesn't stray too far from its initial habits.

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

While DeepSeek utilized GRPO, you might use alternative methods rather (PPO or PRIME).

For those aiming to dive deeper, Will Brown has written quite a nice implementation of training an LLM with RL using GRPO. GRPO has actually likewise already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another great resource. Finally, Yannic Kilcher has a great 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 methodologies they've presented in their paper, I wish to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

These findings suggest that RL boosts the design's overall efficiency by rendering the output circulation more robust, simply put, it appears that the improvement is attributed to boosting the proper response from TopK instead of the improvement of essential abilities.

In other words, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are more likely to be right, even though the overall ability (as measured by the variety of proper answers) is mainly present in the pretrained design.

This suggests that support learning on LLMs is more about refining and "forming" the existing distribution of reactions rather than enhancing the model with completely new capabilities. Consequently, while RL techniques such as PPO and GRPO can produce significant efficiency gains, there appears to be 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 milestone. I'm delighted to see how it unfolds!

Running DeepSeek-R1

I have actually used DeepSeek-R1 through the main chat user interface for numerous issues, which it seems to resolve well enough. The additional search functionality makes it even better to use.

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

I also rented 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 extensively evaluate the design's capabilities.

671B via 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 running on the GPU), running by means of llama.cpp:

29 layers seemed to be the sweet area offered 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 regional video gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b completely 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 severe work, however it's fun to run these large models on available hardware.

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

70B by means of Ollama

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

GPU usage 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 totally local "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to replicate o1 and the future of thinking LMs. The Illustrated DeepSeek-R1 - by Jay Alammar. Explainer: yewiki.org 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 an unique autoregressive framework that merges multimodal understanding and generation. It can both comprehend and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that matches the efficiency of OpenAI's o1. It presents a detailed approach for training such designs utilizing large-scale support learning strategies. DeepSeek-V3 Technical Report (December 2024) This report discusses the application of an FP8 blended precision training structure validated on an exceptionally large-scale design, attaining both accelerated training and wiki.snooze-hotelsoftware.de minimized GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and presents findings that assist in the scaling of large-scale models 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 range of open-source code models 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 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 cost-effective training and effective reasoning. 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 design that attains performance equivalent to GPT-4 Turbo in code-specific tasks.

Interesting occasions

- Hong Kong University replicates R1 outcomes (Jan 25, '25).