Here’s a walk-through of how DeepSeek R1 defines and uses verifiable rewards, using a Black–Scholes call‐pricing task as our toy example.
1. DeepSeek R1 Verifiable-Reward Loop
- Task
– Input x: parameters of a European option (S, K, T, r, σ, type)
– Model outputs ŷ: predicted option price
- Verifier
– Computes y*: the “ground-truth” via closed-form Black–Scholes
- Reward
– ( R = \max!\bigl(0,;1 - \tfrac{|ŷ - y^*|}{\delta}\bigr) )
– Here δ is an error‐tolerance hyperparameter (e.g. δ=2.0)
- RL Algorithm
– DeepSeek R1 uses Proximal Policy Optimization (PPO) with a clipped surrogate objective.
– The policy network outputs a distribution over continuous price predictions.
– The value network estimates the expected future reward.
2. Example: Black–Scholes Pricing
2.1. Input
{
"S": 100.0, // Underlying spot price
"K": 100.0, // Strike
"T": 1.0, // Time to maturity in years
"r": 0.05, // Risk‐free rate (5%)
"sigma": 0.20, // Volatility (20%)
"type": "call" // Option type
}
2.2. Verifiable Answer
Black–Scholes closed-form for a call:
[
d_{1} = \frac{\ln(S/K) + (r + \sigma^2/2),T}{\sigma\sqrt{T}},\quad
d_{2} = d_{1} - \sigma\sqrt{T}
]
[
y^* = S,\Phi(d_1) - K e^{-rT},\Phi(d_2)
]
Plugging in numbers gives (y^* \approx 10.4506).
2.3. Model’s Prediction & Reward
– Model predicts ŷ = 10.80
– Absolute error = |10.80 − 10.4506| ≈ 0.3494
– If δ=2.0, reward
[
R = \max\bigl(0,;1 - \tfrac{0.3494}{2.0}\bigr)
= 1 - 0.1747
= 0.8253.
]
3. PPO in DeepSeek R1
– Policy π_θ(ŷ | x): Gaussian with mean μ_θ(x) and fixed σ_p
– Value V_ϕ(x): estimate of expected cumulative reward
– Objective
[
L(θ) = \mathbb{E}\Bigl[\min\bigl(r_t(θ),A_t,; \mathrm{clip}(r_t(θ),1-ε,1+ε),A_t\bigr)\Bigr]
]
where (r_t = \frac{\pi_θ(ŷ_t|x_t)}{\pi_{θ_\text{old}}(ŷ_t|x_t)}) and (A_t = R_t - V_ϕ(x_t)).
4. Sample Dataset Entry
{
"features": {
"S": 120.0,
"K": 100.0,
"T": 0.5,
"r": 0.03,
"sigma": 0.25,
"type": "call"
},
"label": 22.3471 // precomputed via Black–Scholes
}
– Use in training:
- Feed
features → model outputs ŷ
- Compute
label → y*
- Calculate R via the verifiable‐reward formula
- Update π_θ and V_ϕ with PPO
🎯 Summary
DeepSeek R1 tightly couples each model prediction with a deterministic verifier (the Black–Scholes formula), converting numeric accuracy into a bounded reward signal that drives a PPO‐based policy/value update.