1 Understanding DeepSeek R1
merrilllamilam edited this page 2025-02-09 16:14:23 +01:00


DeepSeek-R1 is an open-source language model 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 numerous criteria, however it also comes with fully MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to provide strong reasoning abilities in an open and available way.

What makes DeepSeek-R1 particularly amazing is its transparency. Unlike the less-open approaches from some industry leaders, DeepSeek has published a detailed training approach in their paper. The model is likewise remarkably 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 knowledge was that much better designs needed more data and compute. While that's still legitimate, designs like o1 and R1 demonstrate an option: inference-time scaling through thinking.

The Essentials

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

DeepSeek-R1 uses 2 significant ideas:

1. A multi-stage pipeline where a little set of cold-start information kickstarts the design, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a support learning approach that relies on comparing numerous design outputs per prompt to avoid the requirement for a different critic.

R1 and R1-Zero are both reasoning designs. This essentially implies they do Chain-of-Thought before answering. For the R1 series of models, 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 with no monitored fine-tuning (SFT). RL is utilized to enhance the design's policy to take full advantage of benefit. R1-Zero attains excellent precision however sometimes produces confusing outputs, such as blending several languages in a single action. R1 repairs that by integrating restricted supervised fine-tuning and multiple RL passes, which enhances both correctness and readability.

It is intriguing how some languages might express certain concepts better, which leads the model to pick the most for the job.

Training Pipeline

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

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

The normal training method: Pretraining on big dataset (train to predict next word) to get the base design → monitored fine-tuning → preference tuning through 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 process has a decent starting point. This provides an excellent design to start RL. First RL Stage: Apply GRPO with rule-based rewards to enhance reasoning accuracy and formatting (such as requiring chain-of-thought into believing tags). When they were near convergence in the RL procedure, they relocated to the next action. The outcome of this step is a strong reasoning model however with weak general capabilities, e.g., poor formatting and language mixing. Rejection Sampling + general data: Create new SFT data through rejection tasting on the RL checkpoint (from step 2), combined with monitored data from the DeepSeek-V3-Base model. They collected around 600k high-quality thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k overall samples (600k thinking + 200k general tasks) for broader abilities. This action resulted in a strong thinking model with basic capabilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the last model, in addition to the reasoning benefits. The outcome is DeepSeek-R1. They also did design 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 model to improve a trainee model by generating training data for the trainee model. The instructor is typically a larger model than the trainee.

Group Relative Policy Optimization (GRPO)

The fundamental idea behind using support knowing for LLMs is to tweak the design's policy so that it naturally produces more precise and beneficial responses. They utilized a reward system that examines not only for correctness however also for proper format and language consistency, so the model gradually discovers to favor reactions that fulfill these quality requirements.

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

What makes their approach particularly interesting is its reliance on straightforward, rule-based reward functions. Instead of depending upon expensive external models or human-graded examples as in standard RLHF, the RL used for R1 utilizes easy criteria: it might provide a higher benefit if the response is proper, if it follows the expected/ formatting, and if the language of the response matches that of the timely. Not depending on a reward model likewise means you don't have to hang around and wino.org.pl effort training it, and it doesn't take memory and compute far from your main design.

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

1. For each input prompt, the design generates different actions. 2. Each response gets a scalar benefit based upon elements like accuracy, formatting, and language consistency. 3. Rewards are changed relative to the group's performance, essentially measuring how much better each action is compared to the others. 4. The design updates its technique a little to favor actions with higher relative benefits. It just makes slight adjustments-using methods like clipping and a KL penalty-to make sure the policy doesn't wander off too far from its initial behavior.

A cool aspect of GRPO is its versatility. You can use simple rule-based reward functions-for instance, granting a benefit when the model correctly 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 composed rather a nice execution of training an LLM with RL utilizing GRPO. GRPO has actually likewise currently been included to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has an excellent video explaining GRPO by going through the DeepSeekMath paper.

Is RL on LLMs the path to AGI?

As a last note on explaining DeepSeek-R1 and the methods they have actually presented 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 show that RL boosts the design's total performance by rendering the output distribution more robust, in other words, it appears that the improvement is associated to improving the correct reaction from TopK rather than the enhancement of basic 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 right, although the general capability (as measured by the diversity of right responses) is mainly present in the pretrained model.

This recommends that support learning on LLMs is more about refining and "shaping" the existing distribution of actions rather than endowing the design with entirely brand-new abilities. Consequently, links.gtanet.com.br while RL strategies such as PPO and GRPO can produce substantial efficiency gains, there seems a fundamental ceiling identified by the underlying design'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 milestone. I'm excited to see how it unfolds!

Running DeepSeek-R1

I have actually used DeepSeek-R1 through the main chat interface for numerous issues, which it seems to fix all right. The additional search performance makes it even nicer to use.

Interestingly, o3-mini(-high) was released as I was composing this post. From my initial screening, R1 seems more powerful 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 goal was to see how the model would carry out when released 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 design by Unsloth, with a 4-bit quantized KV-cache and partial GPU offloading (29 layers running on the GPU), running through llama.cpp:

29 layers appeared to be the sweet spot provided this configuration.

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 gaming setup. Digital Spaceport composed a full guide on how to run Deepseek R1 671b totally 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 quite manageable for any severe work, however it's enjoyable to run these big designs on available hardware.

What matters most to me is a combination of usefulness and time-to-usefulness in these models. Since reasoning models need to think before answering, yogicentral.science their time-to-usefulness is generally higher than other models, however their effectiveness is also typically higher. We need to both make the most of usefulness and minimize time-to-usefulness.

70B through Ollama

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

GPU utilization soars 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 completely local "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's dish 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 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 understand and generate 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 reasoning model that measures up to the efficiency of OpenAI's o1. It presents a detailed methodology for training such models using massive reinforcement learning techniques. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 combined accuracy training framework confirmed on an extremely large-scale design, attaining both accelerated training and decreased GPU memory usage. 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 models in open-source setups. It presents the DeepSeek LLM task, committed to advancing open-source language models with a long-lasting 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 variety 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 utilize a fill-in-the-blank task 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 model identified by affordable training and effective reasoning. 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 efficiency equivalent to GPT-4 Turbo in code-specific jobs.

Interesting occasions

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

  • Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to replicate R1, totally open source (Jan 25, '25).
  • OpenAI scientist verifies the DeepSeek team individually discovered and used some core concepts the OpenAI group utilized en route to o1

    Liked this post? Join the newsletter.