
After studying this material, you should be able to:
Let's ground everything in a concrete scenario before touching any algorithms.
Imagine you are shopping online for a laptop. The title says:
"UltraBook Pro โ 512GB SSD Storage"
But the bullet points say:
"โข 128GB internal storage"
Which is true? You don't know. You might buy it expecting 512GB and receive 128GB โ you return it โ the marketplace loses money and trust.
This is called a production defect: a listing where the title contradicts its own bullet points.
| Scale Factor | Consequence |
|---|---|
| 36 million listings to check | You cannot do this manually |
| Even 1% false positive rate | = 360,000 good listings wrongly flagged |
| Flagging good listings = seller complaints, lost revenue | Precision must be extremely high (>99%) |
๐ Key Insight: At massive scale, false positives are catastrophically expensive, so precision dominates the design.
Because no single model perfectly balances speed and accuracy, the system uses two models in sequence:
All 36M Listings
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Stage 1: 4B Model โ โ Cheap, fast, runs on everything
โ (Detector) โ โ High recall: catches most defects
โโโโโโโโโโโโโโโโโโโโโโโ
โ Flags ~X candidates
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Stage 2: DeepSeek โ โ Expensive, slow, very accurate
โ R1 (Verifier) โ โ High precision: confirms true defects
โโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Confirmed Defects
Running Stage 2 on every listing is too expensive. The long-term goal is to make Stage 1 good enough to work alone. Until then, every improvement in Stage 1's recall = more defects caught per expensive Stage 2 call.
To understand CTW, you first need to understand GRPO (Group Relative Policy Optimization).
GRPO is a reinforcement learning method for training language models. Here's the intuition:
For each completion, GRPO computes an advantage:
Advantage = (reward of this completion) - (average reward of the group)
GRPO takes that one number (the advantage) and applies it equally to every token in the completion.
Example:
Completion: "The listing has a contradiction because the title says 512GB"
Advantage: +0.8 +0.8 +0.8 +0.8 +0.8 +0.8 +0.8 +0.8 +0.8 +0.8
But think about this: the word "contradiction" is the pivotal token that determines correctness. The filler words "The listing has a" contribute almost nothing to whether the answer is right or wrong.
๐ Key Problem: Uniform credit assignment wastes training signal on unimportant tokens and dilutes the signal on important ones.
CTW asks: "Which tokens actually distinguish correct completions from incorrect ones?"
Those tokens should receive more credit. Filler tokens should receive less.
Step 1: Generate a group of completions
For one input, sample multiple completions:
Completion A: "...contradiction because title says 512GB but bullet says 128GB" โ Reward: 1 (correct)
Completion B: "...no contradiction, both say the same storage" โ Reward: 0 (incorrect)
Completion C: "...contradiction in the storage specification mentioned" โ Reward: 1 (correct)
Completion D: "...listing appears consistent to me" โ Reward: 0 (incorrect)
Step 2: The reward partitions completions into two groups
Correct group: {A, C}
Incorrect group: {B, D}
Step 3: Run a frozen scorer on each token position
A frozen scorer (a model that doesn't update during training) reads both groups and asks:
"At this token position, can I tell whether I'm reading a correct or incorrect completion?"
Step 4: Reweight the gradient update
Standard GRPO:
Token: "The" "listing" "has" "contradiction" "because" "512GB"
Weight: 1.0 1.0 1.0 1.0 1.0 1.0
CTW:
Token: "The" "listing" "has" "contradiction" "because" "512GB"
Weight: 0.2 0.3 0.2 2.1 0.8 1.9
The model now learns more from the tokens that actually matter.
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ Student Model โ โโโโโโโบ โ Frozen Teacher Model โ
โ (being trained)โ โ (stronger, separate) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ
Provides token weights
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Student Model โ โโโโโโโบ โ Frozen Copy of Student โ
โ (being trained)โ โ (same model, not updated)โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
Provides token weights
๐ Why CTW-S works: Even the student model, when frozen and used contrastively, can identify which tokens separate correct from incorrect completions. The key signal comes from the reward-induced partition, not from the scorer being powerful.
The paper runs a controlled experiment on math problems to isolate causes.
Is the improvement from:
The reward-induced partition is what drives the gain, not the reweighting itself.
This means the key innovation is using the correct/incorrect split as a contrastive signal to identify important tokens โ the specific mathematical form of reweighting matters less.
What matters: Correct group vs. Incorrect group
โ โ
"These tokens appear "These tokens appear
in correct answers" in wrong answers"
โ
Contrastive difference = credit signal
| Metric | SFT Baseline | CTW-S | Improvement |
|---|---|---|---|
| F1 Score | 83.7 | 85.9 | +2.2 |
| Recall | ~82.5 | ~85.9 | +3.4 |
| Precision | maintained | maintained | ~0 |
๐ Business translation: For every 1,000 verifier (Stage 2) calls, CTW-S finds more true defects than the baseline, making the expensive stage more efficient.
PROBLEM:
Title vs. bullet contradictions mislead shoppers at 36M listing scale
CONSTRAINT:
Precision must be >99% (false positives are too costly)
SOLUTION ARCHITECTURE:
Two-stage cascade: cheap detector โ expensive verifier
OPTIMIZATION TARGET:
Improve detector recall (more defects caught per verifier call)
METHOD:
CTW = Contrastive Token Weighting for GRPO
HOW CTW WORKS:
1. Generate group of completions
2. Reward splits them: correct vs. incorrect
3. Frozen scorer finds tokens that discriminate the two groups
4. Upweight those tokens in gradient update
KEY INSIGHT:
The partition (correct vs. incorrect) is the real signal
Not all tokens deserve equal credit for a sequence-level reward
RESULT:
+2.2 F1, +3.4 Recall, precision maintained
Teacher-free variant (CTW-S) works in production