1 Understanding DeepSeek R1
Adela Dewitt edited this page 2025-02-09 18:24:55 +01:00


DeepSeek-R1 is an open-source language model built on DeepSeek-V3-Base that's been making waves in the AI community. Not just does it match-or even surpass-OpenAI's o1 design in many standards, but it also features totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to deliver strong reasoning capabilities in an open and available way.

What makes DeepSeek-R1 particularly amazing is its transparency. Unlike the less-open techniques from some market leaders, DeepSeek has actually released a detailed training methodology in their paper. The model is likewise extremely 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 common wisdom was that better designs needed more information 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 several designs, however main among 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 uses 2 significant ideas:

1. A multi-stage pipeline where a small set of cold-start data kickstarts the design, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a support knowing technique that counts on comparing multiple design outputs per timely to prevent the requirement for a different critic.

R1 and R1-Zero are both reasoning models. This essentially suggests 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 applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is utilized to enhance the design's policy to make the most of benefit. R1-Zero attains excellent accuracy but sometimes produces confusing outputs, such as mixing numerous languages in a single action. R1 repairs that by integrating minimal supervised fine-tuning and numerous RL passes, which enhances both correctness and readability.

It is fascinating how some languages may reveal certain concepts much 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 exceptionally interesting. It showcases how they produced such strong reasoning models, and what you can anticipate from each stage. This consists of the problems that the resulting designs from each phase have, and how they solved it in the next stage.

It's fascinating that their training pipeline varies from the typical:

The usual training technique: Pretraining on large dataset (train to predict next word) to get the base designmonitored fine-tuningchoice tuning by means of RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with several SFT and RL phases

Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to guarantee the RL procedure has a good beginning point. This offers an excellent model to begin RL. First RL Stage: Apply GRPO with rule-based rewards to enhance thinking correctness and format (such as requiring chain-of-thought into thinking tags). When they were near convergence in the RL process, they relocated to the next step. The outcome of this step is a strong reasoning design but with weak general capabilities, e.g., links.gtanet.com.br poor format and language blending. Rejection Sampling + basic data: Create new SFT data through rejection tasting on the RL checkpoint (from action 2), integrated with supervised data from the DeepSeek-V3-Base design. They collected around 600k top quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k basic tasks) for broader abilities. This step resulted in a strong thinking design with general abilities. 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 model distillation for numerous Qwen and Llama designs on the thinking traces to get distilled-R1 models.

Model distillation is a method where you utilize a teacher design to enhance a trainee design by producing training information for the trainee model. The instructor is normally a larger model than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental idea behind using support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and helpful answers. They utilized a benefit system that inspects not only for correctness however likewise for proper formatting and language consistency, so the design slowly learns to prefer responses that fulfill these quality requirements.

In this paper, they motivate the R1 model to generate chain-of-thought reasoning through RL training with GRPO. Instead of including a separate module at inference time, the training procedure itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emergent behavior of the enhanced policy.

What makes their technique especially fascinating is its reliance on straightforward, rule-based benefit functions. Instead of depending on expensive external designs or human-graded examples as in traditional RLHF, the RL used for R1 utilizes easy requirements: it might offer a higher benefit if the answer is right, if it follows the anticipated/ format, and if the language of the answer matches that of the timely. Not counting on a benefit model likewise suggests you don't have to spend time and effort training it, and it does not take memory and compute far from your main model.

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

1. For each input timely, the design produces various actions. 2. Each response gets a scalar reward based upon factors like accuracy, format, and language consistency. 3. Rewards are adjusted relative to the group's performance, wiki.myamens.com basically measuring just how much better each action is compared to the others. 4. The design updates its technique slightly to prefer reactions with higher relative benefits. It only makes small adjustments-using strategies like clipping and a KL penalty-to guarantee the policy does not stray too far from its initial habits.

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

While DeepSeek utilized GRPO, you might utilize alternative approaches instead (PPO or PRIME).

For those aiming to dive deeper, Will Brown has written quite a great execution of training an LLM with RL utilizing GRPO. GRPO has likewise already been contributed to the Transformer Reinforcement Learning (TRL) library, 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 path to AGI?

As a final note on explaining DeepSeek-R1 and the approaches they have actually provided 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 boosts the model's total performance by rendering the output distribution more robust, to put it simply, it appears that the improvement is associated to boosting the correct response from TopK rather than the enhancement of basic capabilities.

Simply put, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be correct, although the overall capability (as determined by the variety of right answers) is mainly present in the pretrained model.

This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing circulation of responses rather than enhancing the design with entirely brand-new abilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable performance gains, there seems a fundamental 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 huge turning point. I'm thrilled to see how it unfolds!

Running DeepSeek-R1

I've utilized DeepSeek-R1 through the main chat user interface for different issues, which it seems to resolve all right. The additional search performance makes it even better to utilize.

Interestingly, o3-mini(-high) was launched as I was writing this post. From my preliminary screening, R1 appears more powerful at math 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 model would carry out when released on a single H100 GPU-not to thoroughly check 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 running on the GPU), running via llama.cpp:

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

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 local video 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 models on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these models. Since reasoning models need to think before addressing, their time-to-usefulness is generally greater than other models, but their usefulness is also usually greater. We require to both make the most of usefulness and lessen time-to-usefulness.

70B by means of Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:

GPU utilization 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 by means of Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a totally regional "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to replicate 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 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 unifies multimodal understanding and generation. It can both understand and produce 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 equals the efficiency of OpenAI's o1. It provides a detailed method for training such designs using massive support learning methods. DeepSeek-V3 Technical Report (December 2024) This report talks about the execution of an FP8 combined accuracy training framework confirmed on an incredibly massive design, attaining both sped up training and decreased GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with (January 2024) This paper looks into scaling laws and presents findings that facilitate the scaling of massive designs in open-source configurations. It introduces the DeepSeek LLM project, committed 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 study presents the DeepSeek-Coder series, a range 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 utilize a fill-in-the-blank task to boost code generation and infilling. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model (May 2024) This paper presents DeepSeek-V2, a Mixture-of-Experts (MoE) language model defined by affordable training and efficient inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains performance similar to GPT-4 Turbo in code-specific tasks.

Interesting occasions

- Hong Kong University reproduces R1 results (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, totally open source (Jan 25, '25).

  • OpenAI scientist confirms the DeepSeek team individually discovered and used some core ideas the OpenAI group used on the method to o1

    Liked this post? Join the newsletter.