Language models, retrieval, prompting, and language adaptation · Autoregressive and open-weight model families · LNG040 · Model
DeepSeek-R1 reasoning-model family
Documents reasoning-focused models trained with reinforcement-learning-centered post-training, including the distinction between R1-Zero, the broader R1 pipeline, and distilled derivatives.
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's own run
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: The chapter's authors report running it; there is no record for this entry alone. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Documents reasoning-focused models trained with reinforcement-learning-centered post-training, including the distinction between R1-Zero, the broader R1 pipeline, and distilled derivatives. These derivatives are consolidated rather than counted as unrelated new architectures.
Question / objective
How can reward-based post-training improve reasoning on tasks with verifiable outcomes?
Architecture / computational structure
A pretrained policy is post-trained through a multi-stage reasoning pipeline; released distilled models use their own base architectures. Policy weights are learned, while rewards, sampling budgets, reference constraints, and stages define training.
Assumptions
Rewards can be gamed, verification can be incomplete, and longer reasoning can increase cost without improving correctness.
Formula / computational definition
Policy optimization increases expected reward for generated responses while constraining updates; verifiable tasks can assign reward from final-answer correctness. GRPO is a separately documented optimization method in this chapter, not an additional internal architecture invented for R1.
Parameters and notation
Learned parameters: identified in the architecture subsection. Hyperparameters, design and inference choices: Base model, reward definitions, sampling budget, response-length controls, post-training stage, distillation data, and evaluation decoding settings.
Fitting, fine-tuning, and adaptation
For a derivative, distinguish supervised distillation from reinforcement learning with verified rewards. Freeze most base weights with supported adapters or update policy weights explicitly; preserve a reference when the objective requires it. Validate verifier reliability, held-out reasoning, output length, and general-task forgetting.
How to use and calibrate
Compare final-answer accuracy, pass-at-k with fixed sampling budgets, reasoning-token usage, reliability across problem types, and verifier leakage. Use development data for settings and an independent test set for the final estimate. Report uncertainty across examples or seeds when the evaluation design supports it; model scores and self-assessments are not automatically calibrated probabilities of correctness.
Example application
Adapt a reasoning model to mathematical problems with independently executable answer checks.
Interpretation / pitfalls
Watch out
Distilled models need not inherit every behavior or capability of the source model. The code below isolates one stated component; successful execution does not validate model quality or reproduce the cited experiment.
Python and R code examples
Full implementation route: Use supported released checkpoints and their exact prompting recommendations through Python; R can bridge via reticulate. The example calculates group-relative advantages from toy rewards and illustrates the learning signal, not reproduction of the R1 training pipeline.
Example scope: Group-relative reward signal relevant to reasoning-policy training; not the R1 pipeline.
Dependencies: Python 3 standard library; base R; shared setup above. No model downloads or external services.
Validation: Python component executed in the combined example script; R counterpart supplied but not runtime-tested here. All numbers are synthetic.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Group-relative reward signal relevant to reasoning-policy training; not the R1 pipeline.
Shared setup for this chapter
import math
def softmax(xs):
m = max(xs)
es = [math.exp(x-m) for x in xs]
return [e/sum(es) for e in es]
def dot(a, b):
return sum(x*y for x, y in zip(a, b))
def matvec(matrix, vector):
return [dot(row, vector) for row in matrix]
def meanvec(rows):
return [sum(row[j] for row in rows)/len(rows) for j in range(len(rows[0]))]
def sigmoid(x):
return 1/(1+math.exp(-x))
def nll(probabilities):
return -sum(math.log(p) for p in probabilities)
rewards = [0.0,1.0,1.0,0.0]
mean = sum(rewards)/len(rewards)
sd = math.sqrt(sum((r-mean)**2 for r in rewards)/len(rewards))
advantages = [(r-mean)/(sd+1e-8) for r in rewards]
print(advantages)
Component demo, not a trained model — Group-relative reward signal relevant to reasoning-policy training; not the R1 pipeline.
Shared setup for this chapter
softmax <- function(x) {
shifted <- exp(x-max(x))
shifted/sum(shifted)
}
rewards <- c(0,1,1,0); mu <- mean(rewards)
sd_population <- sqrt(mean((rewards-mu)^2))
advantages <- (rewards-mu)/(sd_population+1e-8)
print(advantages)
Sources
- Source 1arxiv.org
From the CodeSplash reference, entry LNG040.