1 Understanding DeepSeek R1
Alana Yeager edited this page 2 months ago


DeepSeek-R1 is an open-source language design developed 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 criteria, however it also includes totally MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to provide strong reasoning capabilities in an open and available manner.

What makes DeepSeek-R1 particularly interesting is its transparency. Unlike the less-open techniques from some market leaders, DeepSeek has released a detailed training method in their paper. The model is likewise extremely economical, 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 information 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 numerous models, however main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while interesting, I will not go over here.

DeepSeek-R1 utilizes 2 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 reinforcement learning method that counts on comparing multiple design outputs per timely to prevent the requirement for a separate critic.

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

R1-Zero vs R1

R1-Zero applies Reinforcement Learning (RL) straight to DeepSeek-V3-Base without any monitored fine-tuning (SFT). RL is utilized to enhance the model's policy to optimize benefit. R1-Zero attains exceptional precision however often produces complicated outputs, such as mixing several languages in a single response. R1 repairs that by integrating limited supervised fine-tuning and several RL passes, lespoetesbizarres.free.fr which improves both correctness and readability.

It is interesting how some languages may reveal certain ideas much better, which leads the design to pick the most meaningful language for the task.

Training Pipeline

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

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

The normal training strategy: Pretraining on large dataset (train to predict next word) to get the base model → 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 procedure has a decent beginning point. This gives a good model to start RL. First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning correctness 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 outcome of this action is a strong thinking design however with weak general abilities, e.g., bad format and language blending. Rejection Sampling + basic data: Create brand-new SFT information through rejection sampling on the (from step 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 resulted in a strong reasoning design with general abilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the thinking benefits. The outcome is DeepSeek-R1. They likewise did design distillation for numerous Qwen and Llama models on the thinking traces to get distilled-R1 designs.

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

Group Relative Policy Optimization (GRPO)

The standard idea behind utilizing support knowing for LLMs is to tweak the model's policy so that it naturally produces more accurate and useful answers. They utilized a reward system that examines not just for accuracy however likewise for correct formatting and language consistency, so the design slowly discovers to prefer reactions that satisfy these quality criteria.

In this paper, they motivate the R1 design to generate chain-of-thought reasoning through RL training with GRPO. Instead of 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 behavior of the optimized policy.

What makes their method especially fascinating is its dependence on straightforward, rule-based reward functions. Instead of depending upon costly external designs or human-graded examples as in standard RLHF, the RL utilized for R1 uses simple requirements: it may give a higher reward if the answer is proper, 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 suggests you do not have to hang around and effort training it, and it doesn't take memory and calculate 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 responses. 2. Each reaction receives a scalar benefit based on elements like accuracy, formatting, and language consistency. 3. Rewards are adjusted relative to the group's efficiency, essentially measuring how much better each action is compared to the others. 4. The design updates its strategy somewhat to favor actions with higher relative advantages. It only makes minor adjustments-using strategies like clipping and a KL penalty-to guarantee the policy does not wander off too far from its original behavior.

A cool aspect of GRPO is its versatility. You can utilize simple rule-based benefit functions-for instance, awarding a bonus when the design properly 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 rather a good execution of training an LLM with RL using GRPO. GRPO has actually also currently been added to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has a great 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 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 enhances the design's total efficiency by rendering the output distribution more robust, to put it simply, it appears that the enhancement is credited to improving the proper response from TopK instead of the improvement of fundamental capabilities.

Simply put, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be right, even though the overall capability (as measured by the diversity of right answers) is mainly present in the pretrained design.

This suggests that support knowing on LLMs is more about refining and "shaping" the existing distribution of reactions instead of endowing the model with totally new capabilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable efficiency gains, there seems a fundamental ceiling figured out 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 turning point. I'm thrilled to see how it unfolds!

Running DeepSeek-R1

I've used DeepSeek-R1 through the main chat user interface for different problems, which it seems to solve well enough. The extra search functionality makes it even better to utilize.

Interestingly, o3-mini(-high) was launched as I was composing this post. From my preliminary screening, R1 appears stronger at math than o3-mini.

I also 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 deployed on a single H100 GPU-not to thoroughly test the model's capabilities.

671B via 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 through 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 local video gaming setup. Digital Spaceport composed 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 quite manageable for any serious 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 thinking models require to believe before answering, their time-to-usefulness is normally greater than other designs, but their effectiveness is likewise generally greater. We need to both optimize usefulness and decrease 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 expected 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 local "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 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 merges multimodal understanding and generation. It can both understand and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source reasoning model that measures up to the performance of OpenAI's o1. It provides a detailed methodology for training such designs utilizing large-scale reinforcement knowing strategies. DeepSeek-V3 Technical Report (December 2024) This report goes over the implementation of an FP8 blended precision training framework verified on an exceptionally large-scale model, attaining both accelerated training and reduced GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper delves into scaling laws and presents findings that assist in the scaling of large-scale designs in open-source configurations. It introduces the DeepSeek LLM task, 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 utilize 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 provides DeepSeek-V2, a Mixture-of-Experts (MoE) language design defined by economical training and efficient reasoning. 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 design that attains performance comparable to GPT-4 Turbo in code-specific jobs.

Interesting occasions

- Hong Kong University replicates R1 outcomes (Jan 25, '25). - Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to reproduce R1, completely open source (Jan 25, '25).

  • OpenAI scientist validates the DeepSeek team separately found and used some core concepts the OpenAI team used en route to o1

    Liked this post? Join the newsletter.