1 Understanding DeepSeek R1
alejandrinaqrx edited this page 2025-02-09 15:06:55 +00:00


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

What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open techniques from some industry leaders, DeepSeek has released a detailed training methodology in their paper. The model is likewise 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 knowledge was that better models needed more data and compute. While that's still valid, models like o1 and R1 show an option: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented multiple models, however main among them were R1 and R1-Zero. Following these are a series of distilled designs that, wiki.snooze-hotelsoftware.de while intriguing, I will not discuss here.

DeepSeek-R1 utilizes 2 major ideas:

1. A multi-stage pipeline where a small set of cold-start data kickstarts the model, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a reinforcement learning method that depends on comparing numerous design outputs per prompt to prevent the for a different 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 used to optimize the design's policy to take full advantage of benefit. R1-Zero attains outstanding accuracy but often produces complicated outputs, such as mixing multiple languages in a single action. 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 might express certain concepts better, which leads the model to select the most meaningful language for the task.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is exceptionally fascinating. It showcases how they developed such strong reasoning designs, and what you can anticipate from each phase. This consists of the issues that the resulting designs 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 normal training technique: Pretraining on big dataset (train to predict next word) to get the base modelsupervised fine-tuning → choice 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 make sure the RL procedure has a good starting point. This provides a great model to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve thinking accuracy and format (such as forcing chain-of-thought into thinking tags). When they were near merging in the RL process, they relocated to the next step. The outcome of this action is a strong reasoning model however with weak general capabilities, e.g., poor formatting and language mixing. Rejection Sampling + general information: Create brand-new SFT data through rejection tasting on the RL checkpoint (from action 2), integrated with supervised information from the DeepSeek-V3-Base model. They gathered around 600k top quality reasoning samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k reasoning + 200k general tasks) for wider capabilities. This step resulted in a strong thinking design with general capabilities. Second RL Stage: Add more reward signals (helpfulness, harmlessness) to fine-tune the final model, in addition to the reasoning benefits. The result is DeepSeek-R1. They likewise did model distillation for several Qwen and Llama models on the reasoning traces to get distilled-R1 designs.

Model distillation is a method where you use an instructor design to enhance a trainee model by producing training information for the trainee design. The instructor is generally a bigger design than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental concept behind using support knowing for LLMs is to fine-tune the model's policy so that it naturally produces more precise and helpful responses. They used a benefit system that examines not just for accuracy however likewise for appropriate format and language consistency, so the design slowly learns to favor reactions that fulfill these quality criteria.

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 inference time, the training procedure itself nudges the model to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the optimized policy.

What makes their method particularly interesting is its reliance on straightforward, rule-based benefit functions. Instead of depending on expensive external models or human-graded examples as in standard RLHF, the RL used for R1 uses basic criteria: it might provide a higher benefit if the response is correct, gdprhub.eu if it follows the anticipated/ formatting, and if the language of the answer matches that of the prompt. Not relying on a benefit model likewise suggests you do not need to invest time and effort training it, and it doesn't 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 timely, the design creates different actions. 2. Each reaction gets a scalar benefit based on aspects like precision, format, and language consistency. 3. Rewards are adjusted relative to the group's performance, basically determining how much better each response is compared to the others. 4. The design updates its method a little to favor actions with higher relative benefits. 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 original behavior.

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

While DeepSeek utilized GRPO, you could use alternative methods instead (PPO or PRIME).

For those aiming to dive much deeper, Will Brown has actually written quite a nice implementation 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 an excellent video explaining GRPO by going through the DeepSeekMath paper.

Is RL on LLMs the course to AGI?

As a last note on explaining DeepSeek-R1 and the methods they've 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 indicate that RL improves the model's general efficiency by rendering the output distribution more robust, in other words, it seems that the improvement is associated to boosting the right reaction from TopK rather than the enhancement of basic capabilities.

In other words, 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 overall capability (as measured by the variety of correct responses) is mainly present in the pretrained model.

This recommends that support knowing on LLMs is more about refining and "forming" the existing distribution of actions rather than enhancing the model with entirely new capabilities. Consequently, while RL methods such as PPO and GRPO can produce substantial efficiency gains, there appears to be an inherent ceiling figured out 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 huge turning point. I'm delighted to see how it unfolds!

Running DeepSeek-R1

I've utilized DeepSeek-R1 through the main chat interface for numerous problems, which it appears to solve well enough. 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 testing, R1 appears more powerful at math than o3-mini.

I also leased a single H100 by means of 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 evaluate the design's abilities.

671B by means of 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 by means of llama.cpp:

29 layers appeared to be the sweet area provided this setup.

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 regional gaming setup. Digital Spaceport wrote a complete guide on how to run Deepseek R1 671b completely 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 manageable for any major work, but it's fun to run these large models on available hardware.

What matters most to me is a mix of usefulness and time-to-usefulness in these models. Since thinking designs need to believe before responding to, their time-to-usefulness is generally higher than other models, however their usefulness is likewise usually higher. We need to both maximize effectiveness and decrease time-to-usefulness.

70B via Ollama

70.6 b params, 4-bit KM quantized DeepSeek-R1 running via Ollama:

GPU usage shoots up 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 via 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 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 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 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 by means of 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 designs utilizing massive reinforcement knowing techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 blended precision training structure confirmed on an extremely massive model, attaining both accelerated training and decreased GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and presents findings that facilitate the scaling of large-scale designs in open-source configurations. It introduces the DeepSeek LLM task, committed 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 study introduces the DeepSeek-Coder series, hb9lc.org a series of open-source code designs trained from scratch on 2 trillion tokens. The models are pre-trained on a high-quality project-level code corpus and employ a fill-in-the-blank job to boost 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 model identified 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 efficiency comparable to GPT-4 Turbo in code-specific jobs.

Interesting occasions

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