1 Understanding DeepSeek R1
Adela Elmer edited this page 4 months ago


DeepSeek-R1 is an open-source language design developed on DeepSeek-V3-Base that's been making waves in the AI community. Not only does it match-or even surpass-OpenAI's o1 design in numerous benchmarks, but it also includes fully MIT-licensed weights. This marks it as the first non-OpenAI/Google design to provide strong thinking capabilities in an open and available manner.

What makes DeepSeek-R1 particularly exciting is its transparency. Unlike the less-open methods from some industry leaders, DeepSeek has published a detailed training methodology in their paper. The model is also extremely 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 common wisdom was that better designs needed 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 provided several designs, however main among them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I won't discuss here.

DeepSeek-R1 utilizes two major ideas:

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

R1 and R1-Zero are both thinking designs. This essentially implies they do Chain-of-Thought before addressing. For the R1 series of designs, 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 monitored fine-tuning (SFT). RL is used to optimize the design's policy to take full advantage of benefit. R1-Zero attains excellent precision but in some cases produces confusing outputs, such as mixing numerous languages in a single reaction. R1 repairs that by including minimal monitored fine-tuning and numerous RL passes, wiki.whenparked.com which improves both correctness and readability.

It is interesting how some languages may 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 tremendously intriguing. It showcases how they developed such strong thinking models, and what you can get out of each stage. This includes the issues that the resulting models from each phase have, and how they resolved 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 design → supervised fine-tuning → preference tuning via RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with multiple SFT and RL phases

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 good starting point. This offers a good model to start RL. First RL Stage: Apply GRPO with rule-based rewards to improve reasoning correctness and formatting (such as requiring chain-of-thought into believing tags). When they were near merging in the RL procedure, they transferred to the next step. The outcome of this step is a strong reasoning model but with weak general abilities, e.g., bad formatting and language mixing. Rejection Sampling + basic information: Create new SFT information through rejection tasting on the RL checkpoint (from action 2), integrated with supervised data from the DeepSeek-V3-Base design. They gathered around 600k top quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k thinking + 200k general tasks) for more comprehensive abilities. This step led to a strong thinking model with general abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the final model, in addition to the thinking rewards. The outcome is DeepSeek-R1. They likewise did design distillation for several Qwen and Llama designs on the thinking traces to get distilled-R1 designs.

Model distillation is a technique where you utilize an instructor model to enhance a trainee model by creating training information for the trainee model. The instructor is typically a larger 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 precise and beneficial responses. They used a reward system that examines not just for correctness but likewise for correct format and language consistency, so the design slowly finds out to prefer actions that fulfill these quality requirements.

In this paper, they motivate the R1 model to generate chain-of-thought reasoning through RL training with GRPO. Rather than including a separate module at reasoning time, the training process itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the optimized policy.

What makes their approach especially fascinating is its dependence on straightforward, rule-based reward functions. Instead of depending upon expensive external models or human-graded examples as in traditional RLHF, the RL used for R1 utilizes easy requirements: it might provide a greater benefit if the response is appropriate, if it follows the expected/ format, and if the language of the answer matches that of the prompt. Not counting on a benefit design also indicates you don't have to spend time and effort training it, and it does not take memory and calculate far from your main design.

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

1. For each input prompt, the design generates different responses. 2. Each action receives a scalar reward based upon elements like accuracy, formatting, and language consistency. 3. Rewards are changed relative to the group's efficiency, essentially determining just how much better each reaction is compared to the others. 4. The model updates its method a little to favor actions with greater relative benefits. It only makes minor adjustments-using methods like clipping and a KL penalty-to guarantee the policy does not stray too far from its original habits.

A cool element of GRPO is its versatility. You can use easy rule-based benefit functions-for instance, awarding a perk when the design properly utilizes the syntax-to guide the training.

While DeepSeek used GRPO, you might utilize alternative methods instead (PPO or PRIME).

For those aiming to dive much deeper, Will Brown has actually composed rather a great application of training an LLM with RL using GRPO. GRPO has actually likewise already been added to the Transformer Reinforcement Learning (TRL) library, which is another great 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 wish to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

These findings indicate that RL improves the design's overall performance by rendering the output circulation more robust, to put it simply, it seems that the enhancement is credited to improving the proper action from TopK rather than the enhancement of basic capabilities.

To put it simply, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are more likely to be correct, despite the fact that the general capability (as measured by the variety of right responses) is mainly present in the pretrained model.

This suggests that on LLMs is more about refining and "forming" the existing circulation of actions instead of endowing the design with completely brand-new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce considerable efficiency gains, there appears to be an inherent ceiling identified by the underlying model's pretrained knowledge.

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 thrilled to see how it unfolds!

Running DeepSeek-R1

I have actually used DeepSeek-R1 via the main chat interface for different problems, which it appears to resolve all right. The extra search functionality makes it even nicer to utilize.

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

I likewise rented 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 design would carry out when released on a single H100 GPU-not to thoroughly evaluate the model's capabilities.

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 operating on the GPU), running via llama.cpp:

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

Performance:

A r/localllama user explained that they had the ability to overcome 2 tok/sec with DeepSeek R1 671B, without using their GPU on their local video gaming setup. Digital Spaceport composed a complete 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 manageable for any major work, however it's enjoyable to run these big designs on available hardware.

What matters most to me is a combination of effectiveness and time-to-usefulness in these designs. Since thinking models need to believe before responding to, their time-to-usefulness is normally higher than other designs, however their effectiveness is also normally higher. We require to both optimize usefulness and minimize 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 expected when compared to the mainly CPU-powered run of 671B that I showcased above.

Resources

DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a fully local "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe to duplicate 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 combines 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 presents DeepSeek-R1, an open-source thinking model that equals the performance of OpenAI's o1. It provides a detailed method for training such models utilizing massive support learning strategies. DeepSeek-V3 Technical Report (December 2024) This report talks about the application of an FP8 mixed precision training structure confirmed on an extremely massive design, attaining both accelerated training and reduced GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and provides findings that help with the scaling of massive designs in open-source setups. It introduces the DeepSeek LLM task, committed to advancing open-source language designs 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 models are pre-trained on a premium project-level code corpus and use a fill-in-the-blank job 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 characterized by economical training and effective inference. 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 efficiency equivalent to GPT-4 Turbo in code-specific jobs.

Interesting events

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

  • Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to reproduce R1, totally open source (Jan 25, '25). - OpenAI scientist validates the DeepSeek team independently discovered and utilized some core concepts the OpenAI team utilized en route to o1

    Liked this post? Join the newsletter.