Understanding DeepSeek R1

Comentários · 97 Visualizações

DeepSeek-R1 is an open-source language design constructed on DeepSeek-V3-Base that's been making waves in the AI neighborhood.

DeepSeek-R1 is an open-source language design constructed 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 many benchmarks, but it also features fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to deliver strong reasoning capabilities in an open and available way.


What makes DeepSeek-R1 especially exciting is its transparency. Unlike the less-open methods from some market leaders, DeepSeek has actually published a detailed training method in their paper.
The model is likewise incredibly cost-effective, with input tokens costing just $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 models required more data and calculate. While that's still valid, models like o1 and R1 show an alternative: inference-time scaling through thinking.


The Essentials


The DeepSeek-R1 paper provided numerous designs, but main among them were R1 and R1-Zero. Following these are a series of distilled designs that, while intriguing, I won't talk about here.


DeepSeek-R1 utilizes two major 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 reinforcement knowing approach that relies on comparing numerous design outputs per prompt to prevent the need 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 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 utilized to optimize the model's policy to take full advantage of reward.
R1-Zero attains exceptional precision but sometimes produces confusing outputs, such as blending several languages in a single reaction. R1 repairs that by including limited monitored fine-tuning and multiple RL passes, which improves both accuracy and readability.


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


Training Pipeline


The training pipeline that DeepSeek released in the R1 paper is exceptionally intriguing. It showcases how they created such strong thinking models, and what you can anticipate from each stage. This consists of the issues that the resulting designs from each phase have, and how they fixed it in the next phase.


It's intriguing that their training pipeline differs from the normal:


The typical training strategy: Pretraining on big dataset (train to anticipate next word) to get the base model → monitored 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 couple of thousand Chain-of-Thought (CoT) samples to ensure the RL procedure has a decent beginning point. This offers a good design to begin RL.
First RL Stage: Apply GRPO with rule-based benefits to enhance reasoning accuracy and pipewiki.org format (such as forcing chain-of-thought into believing tags). When they were near convergence in the RL procedure, they relocated to the next step. The outcome of this step is a strong thinking model however with weak basic capabilities, e.g., poor format and language blending.
Rejection Sampling + general data: Create brand-new SFT data through rejection tasting on the RL checkpoint (from step 2), integrated with supervised data from the DeepSeek-V3-Base model. They collected around 600k premium reasoning samples.
Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k basic jobs) for more comprehensive abilities. This action led to a strong thinking design with general abilities.
Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to improve the last design, in addition to the thinking benefits. The result is DeepSeek-R1.
They also did model distillation for several Qwen and Llama models on the reasoning traces to get distilled-R1 designs.


Model distillation is a technique where you use an instructor model to enhance a trainee model by generating training data for the trainee design.
The teacher is normally a bigger design than the trainee.


Group Relative Policy Optimization (GRPO)


The standard idea behind using support knowing for LLMs is to fine-tune the design's policy so that it naturally produces more precise and beneficial answers.
They utilized a reward system that examines not only for accuracy but likewise for correct formatting and language consistency, so the design gradually learns to favor reactions that satisfy these quality criteria.


In this paper, they encourage the R1 design to produce 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 emerging habits of the enhanced policy.


What makes their technique especially interesting is its reliance on straightforward, rule-based benefit functions.
Instead of depending upon costly external designs or human-graded examples as in conventional RLHF, the RL used for R1 uses basic requirements: it might offer a greater benefit if the answer is right, if it follows the expected/ formatting, and if the language of the answer matches that of the timely.
Not relying on a reward model likewise implies you don't have to hang around and effort training it, and it does not take memory and compute far from your main model.


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


1. For each input prompt, the model generates different reactions.
2. Each response gets a scalar reward based upon aspects like precision, format, and language consistency.
3. Rewards are changed relative to the group's efficiency, basically determining how much better each response is compared to the others.
4. The design updates its method somewhat to prefer reactions with higher relative advantages. It only makes small adjustments-using methods like clipping and a KL penalty-to make sure the policy does not wander off too far from its initial behavior.


A cool element of GRPO is its flexibility. You can use easy rule-based benefit functions-for setiathome.berkeley.edu circumstances, awarding a bonus when the design correctly uses the syntax-to guide the training.


While DeepSeek used GRPO, you might use alternative methods 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 likewise already been added to the Transformer Reinforcement Learning (TRL) library, which is another excellent 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 approaches they've presented in their paper, I wish to highlight a passage from the DeepSeekMath paper, based on a point Yannic Kilcher made in his video.


These findings indicate that RL boosts the design's general performance by rendering the output circulation more robust, simply put, it seems that the improvement is credited to improving the right reaction from TopK rather than the enhancement of essential abilities.


To put it simply, RL fine-tuning tends to form the output distribution so that the highest-probability outputs are most likely to be correct, even though the overall ability (as measured by the variety of right responses) is mainly present in the pretrained design.


This recommends that support knowing on LLMs is more about refining and "forming" the existing distribution of actions rather than enhancing the model with completely new capabilities.
Consequently, while RL methods such as PPO and GRPO can produce substantial efficiency gains, there appears to be a fundamental ceiling figured out by the underlying design'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 used DeepSeek-R1 through the main chat interface for numerous issues, which it seems to fix well enough. The extra search functionality makes it even nicer to utilize.


Interestingly, o3-mini(-high) was launched as I was writing this post. From my initial screening, R1 seems more powerful 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 design would perform when deployed on a single H100 GPU-not to extensively evaluate 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 running on the GPU), running by means of llama.cpp:


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


Performance:


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


What matters most to me is a combination of usefulness and time-to-usefulness in these designs. Since thinking designs need to believe before answering, their time-to-usefulness is normally higher than other designs, but their effectiveness is also typically greater.
We require to both make the most of effectiveness and decrease time-to-usefulness.


70B through Ollama


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


GPU usage 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 totally local "deep researcher" with DeepSeek-R1 - YouTube).
DeepSeek R1's dish to reproduce 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 combines multimodal understanding and generation. It can both comprehend and asteroidsathome.net generate images.
DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source reasoning model that measures up to the performance of OpenAI's o1. It presents a detailed methodology for training such designs utilizing large-scale support learning methods.
DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 combined accuracy training framework validated 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 looks into scaling laws and provides findings that help with the scaling of massive designs in open-source configurations. It presents the DeepSeek LLM task, devoted to advancing open-source language designs with a long-term viewpoint.
DeepSeek-Coder: When the Large Language Model Meets Programming-The Rise of Code Intelligence (January 2024) This research study presents the DeepSeek-Coder series, a range of open-source code models 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 task to boost 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 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 study 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 events


- Hong Kong University replicates R1 results (Jan 25, '25).
- Huggingface reveals huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to replicate R1, fully open source (Jan 25, '25).
- OpenAI researcher confirms the DeepSeek team individually found and used some core concepts the OpenAI team utilized on the method to o1


Liked this post? Join the newsletter.

Comentários