Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Contribute to GitLab
  • Sign in / Register
G
g-4ingenierie
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Issues 22
    • Issues 22
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Jobs
  • Issue Boards
  • Annett Dudgeon
  • g-4ingenierie
  • Issues
  • #21

Closed
Open
Opened Feb 09, 2025 by Annett Dudgeon@annettk0294761
  • Report abuse
  • New issue
Report abuse New issue

Understanding DeepSeek R1


DeepSeek-R1 is an open-source language design 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 model in lots of standards, however it also features completely MIT-licensed weights. This marks it as the first non-OpenAI/Google model to deliver strong thinking capabilities in an open and available manner.

What makes DeepSeek-R1 particularly exciting is its openness. Unlike the less-open approaches from some industry leaders, DeepSeek has actually published a detailed training methodology in their paper. The design is also 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 wisdom was that better models needed more information and compute. While that's still legitimate, models like o1 and R1 show an alternative: inference-time scaling through reasoning.

The Essentials

The DeepSeek-R1 paper provided several models, however main amongst them were R1 and R1-Zero. Following these are a series of distilled models that, while intriguing, I won't discuss here.

DeepSeek-R1 utilizes two significant ideas:

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

R1 and R1-Zero are both thinking models. This essentially indicates they do Chain-of-Thought before responding to. For the R1 series of designs, this takes kind as believing within a tag, before addressing with a final 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 optimize the model's policy to make the most of reward. R1-Zero attains excellent precision however often produces complicated outputs, such as mixing several languages in a single action. R1 repairs that by including restricted supervised fine-tuning and numerous RL passes, which improves both correctness and readability.

It is interesting how some languages might express certain concepts much better, it-viking.ch which leads the model to choose the most meaningful language for the job.

Training Pipeline

The training pipeline that DeepSeek published in the R1 paper is profoundly interesting. It showcases how they created 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 fixed it in the next phase.

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

The normal training method: Pretraining on big dataset (train to forecast next word) to get the base design → monitored fine-tuning → choice tuning through 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 few thousand oke.zone Chain-of-Thought (CoT) samples to make sure the RL procedure has a good starting point. This gives an excellent design to begin RL. First RL Stage: Apply GRPO with rule-based rewards to improve thinking correctness and formatting (such as forcing chain-of-thought into thinking tags). When they were near merging in the RL process, they moved to the next step. The outcome of this action is a strong reasoning model but with weak basic abilities, e.g., bad format and language mixing. Rejection Sampling + general information: annunciogratis.net Create brand-new SFT data through rejection tasting on the RL checkpoint (from step 2), with monitored data from the DeepSeek-V3-Base design. They collected around 600k premium thinking samples. Second Fine-Tuning: Fine-tune DeepSeek-V3-Base again on 800k total samples (600k reasoning + 200k general tasks) for more comprehensive capabilities. This action resulted in a strong thinking design with basic abilities. Second RL Stage: Add more benefit signals (helpfulness, harmlessness) to fine-tune the final design, in addition to the reasoning benefits. The result is DeepSeek-R1. They likewise did design distillation for a number of Qwen and Llama models on the reasoning traces to get distilled-R1 models.

Model distillation is a method where you utilize an instructor design to improve a trainee design by creating training data for the trainee design. The instructor is usually a larger design than the trainee.

Group Relative Policy Optimization (GRPO)

The standard concept behind utilizing support knowing for LLMs is to tweak the model's policy so that it naturally produces more accurate and useful answers. They utilized a benefit system that inspects not just for accuracy however likewise for correct format and language consistency, so the design gradually learns to favor actions that satisfy these quality criteria.

In this paper, they encourage the R1 design to create chain-of-thought thinking through RL training with GRPO. Instead of 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 optimized policy.

What makes their approach especially fascinating is its dependence on straightforward, rule-based benefit functions. Instead of depending upon costly external designs or human-graded examples as in traditional RLHF, the RL utilized for R1 utilizes easy criteria: it might offer a greater benefit if the answer is appropriate, if it follows the anticipated/ formatting, and if the language of the response matches that of the timely. Not depending on a reward design also suggests you don't have to spend time and effort training it, and it does not take memory and compute far from your main design.

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

1. For each input timely, the model generates various actions. 2. Each reaction gets a scalar reward based on factors like accuracy, addsub.wiki format, and language consistency. 3. Rewards are adjusted relative to the group's efficiency, basically measuring how much better each reaction 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 strategies like clipping and a KL penalty-to ensure the policy does not stray too far from its initial habits.

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

While DeepSeek used GRPO, you might utilize alternative approaches instead (PPO or PRIME).

For those aiming to dive deeper, Will Brown has actually composed quite a good implementation of training an LLM with RL utilizing GRPO. GRPO has likewise already been included to the Transformer Reinforcement Learning (TRL) library, which is another excellent resource. Finally, Yannic Kilcher has a fantastic 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 approaches they've presented in their paper, I want 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 overall efficiency by rendering the output distribution more robust, to put it simply, it seems that the improvement is attributed to increasing the appropriate reaction from TopK rather than the improvement of fundamental abilities.

In other words, bio.rogstecnologia.com.br RL fine-tuning tends to shape the output circulation so that the highest-probability outputs are more likely to be appropriate, despite the fact that the overall ability (as measured by the variety of proper responses) is mainly present in the pretrained design.

This suggests that reinforcement learning on LLMs is more about refining and "shaping" the existing circulation of reactions rather than endowing the design with totally new capabilities. Consequently, while RL methods such as PPO and GRPO can produce substantial efficiency gains, there seems an inherent 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 delighted to see how it unfolds!

Running DeepSeek-R1

I have actually used DeepSeek-R1 via the main chat user interface for numerous problems, which it seems to solve all right. The extra search functionality makes it even better to utilize.

Interestingly, o3-mini(-high) was released as I was composing this post. From my preliminary testing, R1 seems more powerful at mathematics than o3-mini.

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

671B by means of Llama.cpp

DeepSeek-R1 1.58-bit (UD-IQ1_S) quantized model by Unsloth, larsaluarna.se 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 get over 2 tok/sec with DeepSeek R1 671B, without using their GPU on their local video gaming setup. Digital Spaceport composed a complete guide on how to run Deepseek R1 671b completely 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 quite bearable for any major work, but it's enjoyable to run these large models 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 think before addressing, their time-to-usefulness is typically greater than other models, but their effectiveness is likewise typically greater. We need to both maximize usefulness and decrease time-to-usefulness.

70B via 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 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 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 grandma - 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 framework 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 design that rivals the efficiency of OpenAI's o1. It presents a detailed approach for training such designs using large-scale support learning strategies. DeepSeek-V3 Technical Report (December 2024) This report goes over the application of an FP8 mixed precision training structure validated on an extremely large-scale model, attaining both accelerated training and reduced GPU memory use. DeepSeek LLM: Scaling Open-Source Language Models with Longtermism (January 2024) This paper dives into scaling laws and presents findings that assist in 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-lasting 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 series 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 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 identified by economical 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 model that attains performance comparable to GPT-4 Turbo in code-specific jobs.

Interesting events

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

  • Huggingface announces huggingface/open-r 1: Fully open reproduction of DeepSeek-R1 to duplicate R1, totally open source (Jan 25, '25).
  • OpenAI researcher verifies the DeepSeek team individually discovered and used some core ideas the OpenAI team utilized on the method to o1

    Liked this post? Join the newsletter.
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
No due date
0
Labels
None
Assign labels
  • View project labels
Reference: annettk0294761/g-4ingenierie#21