1 Understanding DeepSeek R1
Alejandra Spedding edited this page 2 weeks 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 benchmarks, however it likewise features fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google model to provide strong thinking in an open and available manner.

What makes DeepSeek-R1 especially amazing is its transparency. Unlike the less-open approaches from some market leaders, DeepSeek has published a detailed training methodology in their paper. The model is likewise remarkably economical, wavedream.wiki 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 wisdom was that much better designs needed more data and compute. While that's still valid, models like o1 and R1 demonstrate an option: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper presented several designs, however main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while intriguing, I will not talk about 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 massive RL. 2. Group Relative Policy Optimization (GRPO), a support learning technique that counts on comparing several design outputs per prompt to avoid the need for a different critic.

R1 and R1-Zero are both thinking designs. This basically indicates they do Chain-of-Thought before answering. For the R1 series of models, this takes type as thinking within a tag, before responding to with a last 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 model's policy to take full advantage of benefit. R1-Zero attains exceptional accuracy but sometimes produces complicated outputs, such as mixing several languages in a single response. R1 repairs that by incorporating minimal monitored fine-tuning and multiple RL passes, which improves both correctness and readability.

It is intriguing how some languages may express certain concepts much better, which leads the design to choose the most expressive language for the task.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is exceptionally interesting. It showcases how they produced such strong reasoning models, and what you can get out of each stage. This consists of the issues that the resulting designs from each stage have, and how they fixed it in the next phase.

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

The typical training strategy: Pretraining on big dataset (train to anticipate next word) to get the base design → supervised fine-tuning → preference tuning by means of 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 couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a decent starting point. This offers an excellent model to start RL. First RL Stage: Apply GRPO with rule-based rewards to enhance thinking accuracy and format (such as requiring chain-of-thought into thinking tags). When they were near merging in the RL process, they transferred to the next step. The result of this action is a strong reasoning model however with weak general capabilities, e.g., poor format and language mixing. Rejection Sampling + basic data: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), combined with supervised information from the DeepSeek-V3-Base model. They gathered around 600k premium thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k basic tasks) for wider capabilities. This step resulted in a strong reasoning model with basic capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the final design, in addition to the reasoning benefits. The result is DeepSeek-R1. They also did design distillation for a number of Qwen and Llama models on the reasoning traces to get distilled-R1 designs.

Model distillation is a strategy where you utilize an instructor design to enhance a trainee design by generating training information for the trainee design. The teacher is generally a bigger design than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental concept behind utilizing support learning for LLMs is to tweak the design's policy so that it naturally produces more precise and useful answers. They used a reward system that checks not just for accuracy however likewise for appropriate formatting and language consistency, so the model gradually discovers to favor responses that meet these quality criteria.

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

What makes their technique particularly fascinating is its reliance on straightforward, videochatforum.ro rule-based reward functions. Instead of depending on pricey external models or human-graded examples as in standard RLHF, the RL used for R1 utilizes simple criteria: it might provide a greater 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 depending on a reward design also indicates you do not have to invest time and effort training it, and it doesn't take memory and compute away from your main design.

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

1. For each input prompt, the model creates different reactions. 2. Each action receives a scalar benefit based upon factors like accuracy, formatting, and language consistency. 3. Rewards are adjusted relative to the group's performance, basically determining just how much better each response is compared to the others. 4. The model updates its method a little to prefer reactions with greater relative advantages. It just makes small adjustments-using strategies like clipping and a KL penalty-to guarantee the policy does not stray too far from its initial behavior.

A cool element of GRPO is its flexibility. You can use easy rule-based benefit functions-for circumstances, awarding a perk when the model properly uses the syntax-to guide the training.

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

For those aiming to dive deeper, Will Brown has actually written rather a nice application of training an LLM with RL using GRPO. GRPO has also already been contributed to the Transformer Reinforcement Learning (TRL) library, which is another great resource. Finally, Yannic Kilcher has a great 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've provided in their paper, I want to highlight a passage from the DeepSeekMath paper, based upon a point Yannic Kilcher made in his video.

These findings indicate that RL boosts the design's total efficiency by rendering the output distribution more robust, in other words, it appears that the improvement is attributed to improving the appropriate reaction from TopK instead of the enhancement of fundamental abilities.

To put it simply, RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are most likely to be proper, despite the fact that the general ability (as measured by the variety of appropriate answers) is mainly present in the pretrained model.

This recommends that reinforcement learning on LLMs is more about refining and "shaping" the existing circulation of actions rather than endowing the model with completely brand-new abilities. Consequently, while RL techniques such as PPO and GRPO can produce considerable performance gains, there seems a fundamental ceiling determined 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 huge milestone. I'm excited to see how it unfolds!

Running DeepSeek-R1

I've used DeepSeek-R1 through the main chat user interface for various problems, which it seems to solve all right. The additional search performance makes it even nicer to utilize.

Interestingly, o3-mini(-high) was launched as I was composing this post. From my preliminary screening, R1 appears stronger at mathematics 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 goal was to see how the design would carry out when deployed on a single H100 GPU-not to extensively check 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 by means of llama.cpp:

29 layers seemed to be the sweet spot 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 full guide on how to run Deepseek R1 671b fully 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 bearable for any serious work, however it's enjoyable to run these big models on available hardware.

What matters most to me is a mix of effectiveness and time-to-usefulness in these designs. Since thinking models need to believe before answering, their time-to-usefulness is typically greater than other models, but their usefulness is also usually higher. We need to both take full advantage of usefulness and reduce time-to-usefulness.

70B by means of Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running through 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 through Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a completely local "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish to reproduce 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 structure that unifies multimodal understanding and generation. It can both comprehend and create images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models by means of Reinforcement Learning (January 2025) This paper introduces DeepSeek-R1, an open-source thinking design that matches the performance of OpenAI's o1. It provides a detailed method for training such models using massive support knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 combined accuracy training framework verified on a very massive design, attaining both accelerated training and lowered GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and provides findings that facilitate the scaling of large-scale models 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 presents the DeepSeek-Coder series, a series of open-source code designs trained from scratch on 2 trillion tokens. The models are pre-trained on a top quality 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 cost-effective training and efficient reasoning. DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence (June 2024) This research presents DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language design that attains performance equivalent to GPT-4 Turbo in code-specific tasks.

Interesting occasions

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

  • OpenAI scientist validates the DeepSeek group individually found and used some core ideas the OpenAI group used on the way to o1

    Liked this post? Join the newsletter.