1 Understanding DeepSeek R1
wilburthomson8 edited this page 3 weeks ago


DeepSeek-R1 is an open-source language model constructed on DeepSeek-V3-Base that's been making waves in the AI community. Not only does it match-or even surpass-OpenAI's o1 design in many criteria, however it likewise includes completely MIT-licensed weights. This marks it as the very first non-OpenAI/Google design to provide strong reasoning abilities in an open and available manner.

What makes DeepSeek-R1 especially interesting is its openness. Unlike the less-open approaches from some market leaders, DeepSeek has published a detailed training method in their paper. The model is also incredibly cost-efficient, 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 much better designs needed more data and compute. While that's still legitimate, designs like o1 and R1 demonstrate an alternative: inference-time scaling through thinking.

The Essentials

The DeepSeek-R1 paper presented numerous models, but main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while fascinating, I will not discuss here.

DeepSeek-R1 uses 2 major ideas:

1. A multi-stage pipeline where a little set of cold-start data kickstarts the model, followed by massive RL. 2. Group Relative Policy Optimization (GRPO), a support learning method that relies on comparing multiple design outputs per prompt to prevent the requirement for a separate critic.

R1 and R1-Zero are both reasoning models. This essentially means they do Chain-of-Thought before responding to. For the R1 series of models, this takes kind as thinking within a tag, before addressing with a last summary.

R1-Zero vs R1

R1-Zero uses Reinforcement Learning (RL) straight to DeepSeek-V3-Base with no supervised fine-tuning (SFT). RL is utilized to enhance the model's policy to optimize reward. R1-Zero attains exceptional accuracy however often produces complicated outputs, such as mixing numerous languages in a single response. R1 repairs that by integrating limited supervised fine-tuning and numerous RL passes, which enhances both correctness and readability.

It is fascinating how some languages might reveal certain concepts much better, which leads the design to pick the most meaningful language for the job.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is exceptionally fascinating. It showcases how they produced such strong thinking models, and what you can expect from each stage. This consists of the problems that the resulting models from each phase have, and how they resolved it in the next stage.

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

The normal training method: Pretraining on large dataset (train to predict next word) to get the base design → monitored fine-tuning → choice tuning by means of RLHF R1-Zero: Pretrained → RL R1: Pretrained → Multistage training pipeline with numerous 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 decent starting point. This offers a good model to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve reasoning correctness and formatting (such as requiring chain-of-thought into believing tags). When they were near convergence in the RL process, they transferred to the next step. The outcome of this action is a strong thinking model however with weak general capabilities, e.g., poor format and language mixing. Rejection Sampling + general information: Create new SFT information through rejection tasting on the RL checkpoint (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 broader abilities. This action led to a strong reasoning design with general abilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to refine the final design, in addition to the reasoning benefits. The result is DeepSeek-R1. They also did model distillation for numerous 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 improve a trainee model by generating training information for the trainee design. The instructor is typically a bigger model than the trainee.

Group Relative Policy Optimization (GRPO)

The basic idea behind using support knowing for LLMs is to tweak the model's policy so that it naturally produces more precise and beneficial answers. They utilized a benefit system that checks not just for accuracy however also for appropriate formatting and language consistency, so the design slowly discovers to prefer reactions that meet these quality criteria.

In this paper, they motivate the R1 model to create chain-of-thought reasoning through RL training with GRPO. Instead of including a separate module at reasoning time, the training process itself nudges the design to produce detailed, detailed outputs-making the chain-of-thought an emergent habits of the enhanced policy.

What makes their technique particularly interesting is its dependence on straightforward, rule-based benefit functions. Instead of depending upon costly external models or human-graded examples as in conventional RLHF, the RL utilized for R1 uses basic requirements: it may provide a greater benefit if the answer is proper, if it follows the anticipated/ format, and if the language of the response matches that of the prompt. Not depending on a benefit design likewise indicates you don't need to spend time and effort training it, and it does not 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 generates different reactions. 2. Each response gets a scalar reward based upon elements like precision, formatting, and language consistency. 3. Rewards are adjusted relative to the group's performance, basically measuring just how much better each action is compared to the others. 4. The design updates its technique a little to prefer responses with greater relative benefits. It only makes minor adjustments-using techniques 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 versatility. You can utilize basic rule-based benefit functions-for circumstances, awarding a benefit when the design properly utilizes the syntax-to guide the training.

While DeepSeek used GRPO, you could utilize alternative approaches rather (PPO or PRIME).

For those aiming to dive deeper, Will Brown has actually written rather a great application of training an LLM with RL using GRPO. GRPO has actually also already been included 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 methodologies they've provided 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 show that RL enhances the design's general performance by rendering the output circulation more robust, to put it simply, it seems that the improvement is attributed to enhancing the proper response from TopK rather than the enhancement of fundamental abilities.

Simply put, RL fine-tuning tends to form the output circulation so that the highest-probability outputs are most likely to be correct, although the total ability (as determined by the variety of correct 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 reactions rather than enhancing the model with completely brand-new abilities. Consequently, while RL strategies such as PPO and GRPO can produce significant performance gains, gratisafhalen.be there appears to be an intrinsic ceiling determined 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 milestone. I'm thrilled to see how it unfolds!

Running DeepSeek-R1

I've utilized DeepSeek-R1 via the main chat user interface for classifieds.ocala-news.com various issues, which it seems to resolve well enough. The extra search performance makes it even better to use.

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

I also leased 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 objective was to see how the model would perform when released on a single H100 GPU-not to extensively test the model's abilities.

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 operating on the GPU), running via llama.cpp:

29 layers appeared to be the sweet spot given this setup.

Performance:

A r/localllama user explained that they had the ability to get over 2 tok/sec with DeepSeek R1 671B, without utilizing their GPU on their gaming setup. Digital Spaceport composed a complete 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 rather bearable for bbarlock.com any serious work, but 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 reasoning designs need to believe before responding to, their time-to-usefulness is normally greater than other models, but their effectiveness is likewise typically greater. We require to both optimize effectiveness and reduce 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 by means of Reinforcement Learning [2402.03300] DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models DeepSeek R1 - Notion (Building a totally regional "deep researcher" with DeepSeek-R1 - YouTube). DeepSeek R1's recipe 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 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 structure that merges multimodal understanding and generation. It can both comprehend and produce images. DeepSeek-R1: Incentivizing Reasoning Capability in Large Language Models through Reinforcement Learning (January 2025) This paper presents DeepSeek-R1, an open-source thinking model that measures up to the performance of OpenAI's o1. It provides a detailed approach for training such models utilizing massive reinforcement learning strategies. DeepSeek-V3 Technical Report (December 2024) This report discusses the execution of an FP8 blended precision training framework confirmed on a very massive design, attaining both accelerated training and minimized GPU memory usage. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper explores scaling laws and provides findings that assist in the scaling of massive models in open-source setups. It presents the DeepSeek LLM project, hikvisiondb.webcam dedicated to advancing open-source language designs with a long-term point of view. 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 designs are pre-trained on a top quality project-level code corpus and use 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 presents DeepSeek-V2, oke.zone 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 introduces DeepSeek-Coder-V2, an open-source Mixture-of-Experts (MoE) code language model that attains efficiency similar to GPT-4 Turbo in code-specific jobs.

Interesting events

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

  • Huggingface announces huggingface/open-r 1: Fully open recreation of DeepSeek-R1 to duplicate R1, completely open source (Jan 25, '25).
  • OpenAI researcher verifies the DeepSeek group independently found and used some core concepts the OpenAI team utilized en route to o1

    Liked this post? Join the newsletter.