1
Understanding DeepSeek R1
Alanna Kuhn edited this page 2025-02-09 17:14:59 +00:00


DeepSeek-R1 is an open-source language design 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 model in lots of standards, but it also comes with totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to provide strong thinking capabilities in an open and available way.

What makes DeepSeek-R1 especially exciting is its openness. Unlike the less-open methods from some industry leaders, DeepSeek has actually released a detailed training methodology in their paper. The design is also remarkably 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 typical knowledge was that much better models required more information and compute. While that's still valid, models 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 intriguing, I won't go over here.

DeepSeek-R1 utilizes two significant concepts:

1. A multi-stage pipeline where a small set of cold-start information kickstarts the model, followed by large-scale RL. 2. Group Relative Policy Optimization (GRPO), a reinforcement knowing technique that relies on comparing multiple model outputs per timely to prevent the requirement for a different critic.

R1 and R1-Zero are both reasoning designs. This basically suggests they do Chain-of-Thought before addressing. For the R1 series of designs, this takes kind as believing within a tag, before addressing with a final summary.

R1-Zero vs R1

R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no monitored fine-tuning (SFT). RL is used to enhance the model's policy to take full advantage of reward. R1-Zero attains exceptional accuracy but often produces complicated outputs, such as mixing numerous languages in a single response. R1 repairs that by incorporating restricted supervised fine-tuning and numerous RL passes, which enhances both correctness and readability.

It is intriguing how some languages may reveal certain concepts better, which leads the model to select the most expressive 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 thinking designs, and what you can anticipate from each phase. This consists of the issues that the resulting designs from each stage 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-tuningpreference tuning via RLHF R1-Zero: Pretrained → RL R1: PretrainedMultistage training pipeline with numerous SFT and RL phases

Cold-Start Fine-Tuning: Fine-tune DeepSeek-V3-Base on a couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a decent beginning point. This offers a good model to start RL. First RL Stage: Apply GRPO with rule-based benefits to improve thinking correctness and formatting (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL procedure, they relocated to the next action. The result of this step is a strong reasoning model however with weak basic capabilities, e.g., poor format and language blending. Rejection Sampling + general information: Create new SFT data through rejection tasting on the RL checkpoint (from action 2), integrated with monitored data from the DeepSeek-V3-Base model. They gathered around 600k high-quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k general jobs) for more comprehensive abilities. This step resulted in a strong reasoning model with basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to refine the final model, in addition to the thinking benefits. The outcome is DeepSeek-R1. They likewise did design distillation for numerous Qwen and Llama designs on the thinking traces to get distilled-R1 designs.

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

Group Relative Policy Optimization (GRPO)

The basic idea behind utilizing support knowing for LLMs is to tweak the design's policy so that it naturally produces more accurate and helpful answers. They utilized a benefit system that examines not only for correctness but likewise for appropriate formatting and language consistency, so the design slowly learns to favor responses that satisfy these quality requirements.

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

What makes their approach especially interesting is its dependence on straightforward, rule-based reward functions. Instead of depending upon pricey external designs or human-graded examples as in traditional RLHF, the RL utilized for R1 uses basic requirements: it may offer a higher reward if the answer is right, if it follows the expected/ format, and if the language of the answer matches that of the timely. Not counting on a reward design also implies you don't have to hang around 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 prompt, the design creates various actions. 2. Each action receives a scalar benefit based upon elements like accuracy, format, and language consistency. 3. Rewards are adjusted relative to the group's efficiency, basically measuring just how much better each action is compared to the others. 4. The design updates its method a little to prefer responses with greater relative advantages. It only makes minor adjustments-using methods like clipping and a KL penalty-to make sure the policy doesn't stray too far from its initial behavior.

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

While DeepSeek used GRPO, you could use alternative techniques instead (PPO or PRIME).

For those aiming to dive much deeper, Will Brown has composed quite a nice execution of training an LLM with RL using GRPO. GRPO has actually also already been added 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 the methods they have actually presented in their paper, I desire to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.

These findings suggest that RL boosts the model's total performance by rendering the more robust, simply put, it appears that the enhancement is credited to boosting the appropriate action from TopK rather than the improvement of essential abilities.

To put it simply, RL fine-tuning tends to shape the output distribution so that the highest-probability outputs are most likely to be correct, although the total capability (as determined by the variety 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 distribution of actions instead of enhancing the design with totally new capabilities. Consequently, while RL strategies such as PPO and GRPO can produce considerable efficiency gains, there seems an inherent ceiling identified 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 big 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 numerous problems, which it seems to fix all right. The additional search functionality makes it even nicer to use.

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

I likewise rented a single H100 via 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 extensively evaluate the design'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 working on the GPU), running via llama.cpp:

29 layers appeared to be the sweet area offered this configuration.

Performance:

A r/localllama user explained that they were able to overcome 2 tok/sec with DeepSeek R1 671B, raovatonline.org without using their GPU on their local gaming setup. Digital Spaceport composed 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 major work, but it's enjoyable to run these large models on available hardware.

What matters most to me is a mix of effectiveness and time-to-usefulness in these models. Since reasoning models need to think before responding to, their time-to-usefulness is usually higher than other designs, but their usefulness is likewise normally greater. We need to both maximize usefulness and minimize time-to-usefulness.

70B through Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running by means of 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 by means of Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a fully regional "deep researcher" 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 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 a novel autoregressive framework that merges multimodal understanding and generation. It can both understand and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning model that rivals the efficiency of OpenAI's o1. It presents a detailed methodology for training such designs using massive support learning strategies. DeepSeek-V3 Technical Report (December 2024) This report goes over the execution of an FP8 combined precision training structure confirmed on an extremely large-scale design, attaining both sped up training and minimized GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper looks into scaling laws and presents findings that assist in the scaling of massive models in open-source setups. It introduces the DeepSeek LLM project, devoted 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 introduces the DeepSeek-Coder series, a series of open-source code models trained from scratch on 2 trillion tokens. The models are pre-trained on a high-quality project-level code corpus and systemcheck-wiki.de use a fill-in-the-blank job 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 design identified by economical training and effective inference. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research study 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 jobs.

Interesting occasions

- Hong Kong University replicates R1 results (Jan 25, '25). - Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, completely open source (Jan 25, '25).

  • OpenAI scientist confirms the DeepSeek team individually discovered and used some core ideas the OpenAI group utilized en route to o1

    Liked this post? Join the newsletter.