1 Understanding DeepSeek R1
Armando Le Grand edited this page 9 months ago


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 standards, however it also comes with completely MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong thinking capabilities in an open and available manner.

What makes DeepSeek-R1 particularly interesting is its transparency. Unlike the less-open techniques from some market leaders, DeepSeek has published a detailed training approach in their paper. The design is likewise remarkably cost-effective, 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 designs required more data and calculate. While that's still legitimate, models like o1 and R1 demonstrate an option: inference-time scaling through reasoning.

The Essentials

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

DeepSeek-R1 utilizes 2 significant ideas:

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

R1 and R1-Zero are both thinking designs. This basically implies they do Chain-of-Thought before addressing. For the R1 series of models, this takes form 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 without any monitored fine-tuning (SFT). RL is utilized to enhance the design's policy to optimize benefit. R1-Zero attains excellent accuracy however sometimes produces confusing outputs, such as mixing numerous languages in a single action. R1 repairs that by including limited monitored fine-tuning and multiple RL passes, which enhances both correctness and readability.

It is interesting how some languages might reveal certain ideas better, which leads the model to choose the most meaningful language for the job.

Training Pipeline

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

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

The typical training strategy: Pretraining on large dataset (train to anticipate 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 process has a decent starting point. This offers a great design to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve reasoning correctness and format (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL procedure, they moved to the next action. The outcome of this step is a strong reasoning design however with weak general capabilities, e.g., poor format and language mixing. Rejection Sampling + general information: Create new SFT data through rejection tasting on the RL checkpoint (from step 2), combined with monitored data from the DeepSeek-V3-Base model. They collected around 600k premium reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 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 improve the final model, in addition to the reasoning rewards. The result is DeepSeek-R1. They likewise did model distillation for a number of Qwen and Llama models on the thinking traces to get distilled-R1 models.

Model distillation is a strategy where you use an instructor design to improve a trainee model by creating training information for the trainee design. The instructor is usually a bigger design than the trainee.

Group Relative Policy Optimization (GRPO)

The standard idea behind using support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and beneficial responses. They used a benefit system that checks not only for correctness but also for proper format and language consistency, so the model gradually finds out to favor reactions that satisfy these quality requirements.

In this paper, they encourage the R1 model to produce chain-of-thought reasoning through RL training with GRPO. Rather than including a different module at reasoning time, the training procedure itself nudges the model to produce detailed, wiki.whenparked.com detailed outputs-making the chain-of-thought an emergent habits of the optimized policy.

What makes their technique especially fascinating is its reliance on straightforward, classihub.in rule-based benefit functions. Instead of depending on costly external models or human-graded examples as in conventional RLHF, the RL used for R1 uses easy criteria: it may give a higher benefit if the answer is correct, if it follows the expected/ formatting, chessdatabase.science and if the language of the answer matches that of the prompt. Not relying on a benefit design also indicates you do not have to hang out and effort training it, and it doesn't take memory and calculate far from your main model.

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

1. For each input prompt, the model produces various reactions. 2. Each reaction gets a scalar benefit based upon aspects like precision, formatting, and language consistency. 3. Rewards are changed relative to the group's efficiency, basically determining just how much better each response is compared to the others. 4. The design updates its technique slightly to prefer reactions with higher relative advantages. It just makes slight adjustments-using techniques like clipping and a KL penalty-to make sure the policy does not wander off too far from its original habits.

A cool aspect of GRPO is its versatility. You can use basic rule-based benefit functions-for circumstances, granting a reward when the design correctly utilizes the syntax-to guide the training.

While DeepSeek utilized GRPO, you could use alternative techniques rather (PPO or PRIME).

For those aiming to dive deeper, Will Brown has written rather a great implementation of training an LLM with RL utilizing GRPO. GRPO has actually also already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another good resource. Finally, Yannic Kilcher has a terrific 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 asteroidsathome.net the approaches 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 indicate that RL enhances the model's overall performance by rendering the output circulation more robust, in other words, it appears that the improvement is credited to increasing the proper action from TopK instead of the enhancement of essential abilities.

To put it simply, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are more most likely to be right, although the general ability (as measured by the variety of proper answers) is mainly present in the pretrained design.

This recommends that reinforcement knowing on LLMs is more about refining and "shaping" the existing circulation of reactions instead of endowing the model with completely brand-new capabilities. Consequently, while RL methods such as PPO and GRPO can produce significant efficiency gains, there seems 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 utilized DeepSeek-R1 via the main chat interface for various problems, which it seems to resolve well enough. The extra search functionality makes it even nicer to use.

Interestingly, o3-mini(-high) was launched 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 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 design would perform when released on a single H100 GPU-not to the model's abilities.

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 via llama.cpp:

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

Performance:

A r/localllama user explained that they were able to get over 2 tok/sec with DeepSeek R1 671B, kenpoguy.com 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 quite bearable for any severe work, however it's fun to run these large designs on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these designs. Since thinking designs require to think before addressing, their time-to-usefulness is typically greater than other models, but their effectiveness is likewise normally greater. We need to both maximize usefulness and decrease 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 expected 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 fully regional "deep scientist" 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 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 framework that unifies multimodal understanding and generation. It can both comprehend and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking model that equals the efficiency of OpenAI's o1. It presents a detailed methodology for training such designs using massive support knowing methods. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 blended accuracy training structure validated on a very massive design, attaining both sped up training and lowered GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and presents findings that assist in the scaling of massive models in open-source configurations. It introduces the DeepSeek LLM job, disgaeawiki.info devoted to advancing open-source language models with a long-term point of view. DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research presents the DeepSeek-Coder series, a variety of open-source code models trained from scratch on 2 trillion tokens. The designs are pre-trained on a premium project-level code corpus and employ a fill-in-the-blank task 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 identified by cost-effective training and efficient 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 events

- Hong Kong University duplicates R1 results (Jan 25, '25).

  • Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to duplicate R1, fully open source (Jan 25, botdb.win '25).
  • OpenAI researcher validates the DeepSeek team individually discovered and used some core concepts the OpenAI group utilized en route to o1

    Liked this post? Join the newsletter.