1 Understanding DeepSeek R1
olgapeacock525 edited this page 2 weeks ago


DeepSeek-R1 is an open-source language model constructed 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 criteria, however it also features totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to provide strong thinking abilities in an open and available way.

What makes DeepSeek-R1 particularly interesting is its openness. Unlike the less-open techniques from some industry leaders, DeepSeek has actually released a detailed training methodology in their paper. The design is likewise extremely 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 common knowledge was that much better designs needed more information and calculate. 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 several designs, but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while interesting, I will not go over here.

DeepSeek-R1 utilizes 2 significant concepts:

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 approach that depends on comparing numerous design outputs per prompt to avoid the need for a separate critic.

R1 and R1-Zero are both thinking models. This essentially suggests they do Chain-of-Thought before answering. For the R1 series of designs, this takes form as thinking within a tag, before responding to with a final summary.

R1-Zero vs R1

R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any supervised fine-tuning (SFT). RL is used to optimize the design's policy to take full advantage of reward. R1-Zero attains exceptional precision however often produces complicated outputs, such as blending numerous languages in a single response. R1 repairs that by integrating limited monitored fine-tuning and several RL passes, which improves both correctness and readability.

It is intriguing how some languages might express certain concepts better, which leads the design to select the most meaningful language for the task.

Training Pipeline

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

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

The usual training technique: Pretraining on big dataset (train to forecast next word) to get the base modelsupervised fine-tuningpreference tuning via 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 few thousand Chain-of-Thought (CoT) samples to make sure the RL procedure has a decent starting point. This provides a good design to start 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 convergence in the RL process, they transferred to the next action. The result of this step is a strong thinking model however with weak general capabilities, e.g., bad formatting and language mixing. Rejection Sampling + basic information: Create new SFT information through rejection sampling on the RL checkpoint (from step 2), integrated with monitored information from the DeepSeek-V3-Base design. They gathered around 600k top quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic tasks) for more comprehensive capabilities. This step led to a strong thinking model with basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They likewise did model distillation for a number of Qwen and Llama models on the thinking traces to get distilled-R1 designs.

Model distillation is a method where you utilize an instructor design to improve a trainee model by producing training information for the trainee model. The instructor is usually a bigger model than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental idea behind using support learning for LLMs is to fine-tune the design's policy so that it naturally produces more accurate and beneficial answers. They utilized a benefit system that inspects not only for correctness however likewise for correct formatting and language consistency, so the design slowly learns to favor actions that meet these quality requirements.

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

What makes their approach especially intriguing is its dependence on straightforward, rule-based reward functions. Instead of depending on expensive external designs or human-graded examples as in conventional RLHF, the RL utilized for R1 utilizes easy requirements: it may give a higher benefit if the answer is proper, if it follows the expected/ formatting, and if the language of the response matches that of the timely. Not relying on a reward model likewise implies you don't have to invest time and effort training it, and it doesn't take memory and calculate away from your main design.

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

1. For each input timely, the model generates different responses. 2. Each reaction receives a scalar benefit based on aspects like accuracy, format, 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 favor actions with greater relative advantages. It just makes slight adjustments-using techniques like clipping and a KL penalty-to guarantee the policy doesn't wander off too far from its initial habits.

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

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

For those aiming to dive much deeper, Will Brown has actually written quite a nice implementation of training an LLM with RL utilizing GRPO. GRPO has likewise currently been contributed 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 path to AGI?

As a last note on explaining DeepSeek-R1 and the approaches they have actually presented in their paper, I desire to highlight a passage from the DeepSeekMath paper, yewiki.org based upon a point Yannic Kilcher made in his video.

These findings indicate that RL boosts the model's overall performance by rendering the output circulation more robust, in other words, it seems that the enhancement is associated to increasing the proper reaction from TopK rather than the enhancement of essential capabilities.

In other words, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are most likely to be appropriate, even though the general capability (as by the diversity of correct responses) is mainly present in the pretrained design.

This suggests that support knowing on LLMs is more about refining and "forming" the existing circulation of actions rather than endowing the design with totally brand-new abilities. Consequently, while RL strategies such as PPO and GRPO can produce considerable performance gains, there appears to be an intrinsic 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 huge turning point. I'm excited to see how it unfolds!

Running DeepSeek-R1

I have actually used DeepSeek-R1 through the main chat interface for various issues, which it seems to solve well enough. The extra search functionality makes it even nicer to utilize.

Interestingly, o3-mini(-high) was released as I was composing this post. From my initial screening, R1 seems stronger at math than o3-mini.

I also leased a single H100 by means of 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 extensively check the design's abilities.

671B by means of 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 provided this configuration.

Performance:

A r/localllama user explained that they were able to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their regional gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b completely 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 rather manageable for any serious work, but it's enjoyable to run these big models 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 believe before responding to, their time-to-usefulness is normally higher than other models, however their effectiveness is likewise typically higher. 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 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 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 recipe to replicate 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 grandma - 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 understand and generate images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning design that measures up to the performance of OpenAI's o1. It provides a detailed method for training such models using massive reinforcement knowing strategies. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 blended accuracy training framework validated on an incredibly large-scale design, attaining both sped up training and decreased GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and presents findings that help with the scaling of large-scale designs in open-source configurations. It introduces the DeepSeek LLM task, committed to advancing open-source language models with a long-lasting perspective. 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 variety 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 task to improve 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 characterized by affordable 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 model that attains performance comparable to GPT-4 Turbo in code-specific tasks.

Interesting occasions

- Hong Kong University replicates R1 outcomes (Jan 25, '25). - Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, fully open source (Jan 25, '25). - OpenAI researcher verifies the DeepSeek group individually discovered and utilized some core concepts the OpenAI group utilized en route to o1

Liked this post? Join the newsletter.