1 Understanding DeepSeek R1
Andra Bogner edited this page 2025-02-10 00:15:15 +08:00


DeepSeek-R1 is an open-source language model constructed on DeepSeek-V3-Base that's been making waves in the AI neighborhood. Not only does it match-or even surpass-OpenAI's o1 model in lots of standards, but it also features totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong thinking abilities in an open and available manner.

What makes DeepSeek-R1 especially amazing is its openness. Unlike the less-open methods from some industry leaders, DeepSeek has published a detailed training method in their paper. The design is also incredibly 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 wisdom was that better designs needed more data and compute. While that's still legitimate, designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper provided 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 talk about here.

DeepSeek-R1 uses two major ideas:

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

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

R1-Zero vs R1

R1-Zero applies 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 excellent precision however often produces complicated outputs, such as mixing several languages in a single reaction. R1 repairs that by integrating minimal supervised fine-tuning and multiple RL passes, which enhances both accuracy and readability.

It is intriguing how some languages may express certain concepts better, which leads the design to pick the most meaningful language for the job.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is tremendously interesting. It showcases how they produced such strong reasoning models, wiki.asexuality.org and what you can anticipate from each stage. This includes the problems that the resulting models from each phase have, and how they fixed it in the next stage.

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

The typical training method: Pretraining on big dataset (train to forecast next word) to get the base model → supervised fine-tuning → choice tuning by means of RLHF R1-Zero: wavedream.wiki 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 process has a good starting point. This provides a good model to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and format (such as forcing chain-of-thought into thinking tags). When they were near convergence in the RL process, they relocated to the next action. The result of this step is a strong thinking design but with weak basic capabilities, e.g., poor formatting and language blending. Rejection Sampling + general information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), combined with supervised information from the DeepSeek-V3-Base design. They collected around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k general tasks) for wider abilities. This action led to a strong reasoning model with basic abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the last design, in addition to the thinking benefits. The outcome is DeepSeek-R1. They likewise did model distillation for a number of Qwen and Llama designs on the reasoning traces to get distilled-R1 designs.

Model distillation is a strategy where you use an instructor model to enhance a trainee design by generating training data for the trainee design. The instructor is normally a bigger design than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental concept behind utilizing reinforcement learning for LLMs is to fine-tune the model's policy so that it naturally produces more accurate and beneficial responses. They utilized a reward system that checks not just for accuracy however likewise for appropriate formatting and language consistency, so the design slowly learns to favor reactions that fulfill these quality criteria.

In this paper, they motivate the R1 design to produce chain-of-thought thinking through RL training with GRPO. Instead of adding a different module at inference time, the training procedure itself pushes the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the enhanced policy.

What makes their approach especially interesting is its dependence on straightforward, rule-based benefit functions. Instead of depending upon costly external models or human-graded examples as in standard RLHF, the RL utilized for R1 utilizes simple criteria: it may give a greater reward if the answer is right, if it follows the anticipated/ format, and if the language of the response matches that of the timely. Not counting on a reward design likewise suggests you do not need to hang around and effort training it, and it does not take memory and compute away from your main model.

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

1. For each input prompt, the model generates various reactions. 2. Each action gets a scalar reward based upon factors like accuracy, format, and language consistency. 3. Rewards are adjusted relative to the group's performance, essentially determining just how much better each action is compared to the others. 4. The model updates its method slightly to favor responses with greater relative benefits. It only makes slight adjustments-using strategies like clipping and a KL penalty-to guarantee the policy does not stray too far from its initial behavior.

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

While DeepSeek used GRPO, you might utilize alternative approaches rather (PPO or PRIME).

For those aiming to dive much deeper, Will Brown has written quite a great implementation of training an LLM with RL utilizing GRPO. GRPO has actually likewise already been included to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has an excellent video explaining GRPO by going through the DeepSeekMath paper.

Is RL on LLMs the course to AGI?

As a final note on explaining DeepSeek-R1 and the methods they've 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 improves the model's total performance by rendering the output distribution more robust, simply put, it seems that the improvement is credited to improving the correct response from TopK rather than the enhancement of basic abilities.

In other words, RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are most likely to be right, despite the fact that 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 enhancing the design with completely new capabilities. Consequently, while RL methods such as PPO and GRPO can produce substantial efficiency 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 big milestone. I'm excited to see how it unfolds!

Running DeepSeek-R1

I have actually utilized DeepSeek-R1 by means of the main chat user interface for various issues, which it appears to resolve all right. The additional search functionality makes it even better to utilize.

Interestingly, o3-mini(-high) was launched as I was writing this post. From my initial testing, R1 seems stronger 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 objective was to see how the model would perform when released on a single H100 GPU-not to extensively evaluate the model's abilities.

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

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

Performance:

A r/localllama user explained that they were able to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their regional video gaming setup. Digital Spaceport wrote a full 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 rather bearable for any serious work, however it's enjoyable to run these large models on available hardware.

What matters most to me is a combination of usefulness and time-to-usefulness in these models. Since reasoning models require to believe before responding to, their time-to-usefulness is usually greater than other models, however their usefulness is likewise normally greater. We need 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 usage 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 through Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion ( a totally regional "deep scientist" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe 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 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 a novel autoregressive framework that unifies multimodal understanding and generation. It can both understand and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models via Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source reasoning design that rivals the efficiency of OpenAI's o1. It presents a detailed approach for training such designs using large-scale reinforcement knowing methods. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 combined accuracy training structure validated on a very massive design, attaining both accelerated training and minimized GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that facilitate the scaling of massive designs in open-source setups. It presents the DeepSeek LLM project, committed to advancing open-source language models with a long-term perspective. DeepSeek-Coder: annunciogratis.net When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study introduces the DeepSeek-Coder series, a variety of open-source code designs trained from scratch on 2 trillion tokens. The designs are pre-trained on a top quality project-level code corpus and use 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 design 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 model that attains performance comparable to GPT-4 Turbo in code-specific jobs.

Interesting occasions

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