After studying this material, you should be able to:
Think of a frontier model like a brilliant new hire on their first day. They are highly capable and broadly knowledgeable, but they have never seen your specific customers, your specific failures, or your specific edge cases.
Frontier Model Limitations:
┌─────────────────────────────────────────────┐
│ ✗ Expensive at scale │
│ ✗ Slower than specialized alternatives │
│ ✗ General-purpose, not product-specific │
│ ✗ Frozen — does not learn from production │
│ ✗ Failures pile up as prompts/code, not │
│ as improved model weights │
└─────────────────────────────────────────────┘
Every production failure is hard-won knowledge. The question is: where does that knowledge live?
Without a flywheel:
User failure → Bug report → Slack thread → Prompt edit → Still frozen model
With a flywheel:
User failure → Training signal → Better model weights → Fewer future failures
Knowledge accumulates in continuous parameter space (model weights), not just in discrete artifacts (prompts, rules, code).
The continual learning loop has five major stages. Think of it as a cycle, not a one-time process.
┌──────────────────────────────────────────────────────┐
│ THE CONTINUAL LEARNING FLYWHEEL │
│ │
│ 1. Define Quality (Rubric + Ground Truth) │
│ ↓ │
│ 2. Calibrate Your Judge (Automated Evaluator) │
│ ↓ │
│ 3. Improve Frontier Baseline (Autoresearch) │
│ ↓ │
│ 4. Self-Healing Pipeline (Failures → Training) │
│ ↓ │
│ 5. Compress for Speed (Gist Tokens) │
│ ↓ │
│ [Loop back — better model enters next cycle] │
└──────────────────────────────────────────────────────┘
If you define quality incorrectly, everything downstream optimizes the wrong behavior. This is like setting the wrong destination in a GPS — the system will efficiently take you somewhere you do not want to go.
A rubric translates product requirements into scored, concrete criteria.
Example rubric structure:
┌──────────────────┬────────────────────────────────────────┐
│ Criterion │ What it measures │
├──────────────────┼────────────────────────────────────────┤
│ Completeness │ Did the response address all parts │
│ │ of the user's request? │
├──────────────────┼────────────────────────────────────────┤
│ Execution │ Did the agent take the right actions? │
├──────────────────┼────────────────────────────────────────┤
│ Response Quality │ Was the output clear and accurate? │
├──────────────────┼────────────────────────────────────────┤
│ Safety │ Did it avoid harmful outputs? │
└──────────────────┴────────────────────────────────────────┘
Each score level needs concrete anchors — not vague descriptions, but specific examples of what a 1, 3, or 5 looks like.
⚠️ Critical rule: Include randomly sampled traffic, not only curated examples.
| Data Type | What It Tests | Risk If Overused |
|---|---|---|
| Golden/curated sets | Cases you already know about | Blind to unknown failure modes |
| Random production samples | What actually happens in the wild | None — this is the goal |
Before trusting your rubric, test it with two expert annotators scoring the same 25 samples independently.
Measurement: Cohen's Kappa (κ)
κ measures agreement ABOVE chance level
κ ≈ 0.2 → Rubric is ambiguous. Stop. Revise it.
κ ≈ 0.6 → Moderate agreement. Acceptable to proceed.
κ ≈ 0.8+ → Strong agreement. Rubric is clear.
Key principle:
If expert humans who work on this product every day cannot agree, an LLM judge will not agree either.
The IAA score becomes the ceiling for your automated judge. You are not aiming for a perfect judge — you are aiming for a judge that matches humans about as well as humans match each other.
❌ Bad annotation:
Score: 3
"Response was okay."
✅ Good annotation:
Score: 3
"The agent correctly identified the low-stock products
but failed to sort them by urgency as the merchant
implied. The query ran successfully but the response
omitted the variant-level detail the merchant needed
to act on the information."
The reasoning behind every score is what calibration algorithms learn from.
The rubric is just a starting prompt. Calibration transforms it into a judge that can reliably score millions of production conversations the way your best human experts would.
Rubric (starting prompt)
↓
+ Ground truth annotations
↓
+ Calibration optimizer (e.g., DSPy + GEPA or ACE)
↓
Calibrated Judge (automated evaluator)
GEPA (Reflective Prompt Evolution):
ACE (Agentic Context Engineering):
Your judge is an offline proxy metric. Before trusting it, you must verify it reflects real-world performance.
Validation method 1 — Backtesting:
Take previous A/B tests where you know the outcome
→ Run the judge on both variants
→ Does the judge correctly identify which variant won?
Validation method 2 — Degradation testing:
Deliberately make one specific behavior worse
→ Confirm the corresponding judge criterion drops
→ Confirm other criteria are NOT affected
Example:
Disable goal-fulfillment behavior
→ Goal-fulfillment score should fall
→ Safety score should remain unchanged
Keep each judge small and targeted. One focused judge per behavior is easier to validate and easier to trust than one giant judge trying to measure everything.
Before touching model weights, you push the existing frontier-powered system as far as it can go through automated optimization of the harness — the prompts, tool definitions, and orchestration code.
A production AI application is not a single prompt. It has:
Tuning one prompt touches only a small fraction of the system's behavior.
┌─────────────────────────────────────────────────┐
│ AUTORESEARCH LOOP │
│ │
│ Agent proposes change │
│ (prompt / tool definition / harness code) │
│ ↓ │
│ Evaluate against calibrated judge │
│ ↓ │
│ Score improved? → Keep change │
│ Score same/worse? → Discard change │
│ ↓ │
│ Repeat until improvements plateau │
└─────────────────────────────────────────────────┘
The entire configuration lives in one readable markdown file specifying:
Once harness improvements plateau, you move from optimizing words and code to optimizing model weights. This is the heart of the flywheel.
Discrete artifacts (prompts, rules, code)
↓ plateau
Continuous parameter space (model weights)
The pipeline starts by identifying hard negatives: production conversations the judge scores low. These are your richest learning opportunities.
At scale, real traffic naturally produces:
Low-scoring production conversation
↓
┌─────────────────────────────────────┐
│ Panel of frontier reasoning models │
│ critiques the failure │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Arbiter merges critiques into │
│ a single repair instruction │
└─────────────────────────────────────┘
↓
Repair instruction injected before
user's turn ("hinting" technique)
↓
Conversation replayed from that point
↓
Judge scores the replayed conversation
↓
┌─────────────┴──────────────┐
↓ ↓
Passes judge Still fails
↓ ↓
Becomes RL trajectory Human annotation
with judge score (Toloka experts)
as reward using same rubric
Stage 1 — Supervised Fine-Tuning (SFT):
Input: Healed trajectories (including reasoning, not just final answers)
Goal: Distill successful behavior into smaller model
Why include reasoning?
→ Chain-of-thought distillation lets the smaller model
inherit behavior it could not learn from answers alone
Stage 2 — Reinforcement Learning with GRPO:
For each prompt:
Model generates a GROUP of responses
↓
Judge scores each response
↓
GRPO reinforces the best-scoring responses
↓
Model directly optimizes against your definition of quality
How SFT and GRPO work together:
| Method | Role |
|---|---|
| SFT | Teaches the model what successful trajectories look like (imitation) |
| GRPO | Optimizes the model directly against the quality definition (reinforcement) |
The pipeline runs daily, continuously adding new trajectories. Each training cycle trains on both new and previous trajectories to prevent the model from forgetting earlier lessons while learning new ones.
Cycle 1 data: [A, B, C]
Cycle 2 data: [A, B, C, D, E] ← includes previous
Cycle 3 data: [A, B, C, D, E, F, G] ← includes all previous
An agent's system prompt is long and static. Every generated token must attend over the entire prompt.
Attention cost scales with sequence length
→ Long prompt = fixed latency and cost tax on EVERY request
Teacher model: [Full system prompt — ~6,000 tokens] → Output
↓ train to match
Student model: [~1,500 learned gist tokens] → Same output
What is trained: Only the gist token EMBEDDINGS
What is frozen: The model weights themselves
Gist tokens are learned compressed representations of the full prompt. They are not human-readable — they are vectors in embedding space that reproduce the prompt's behavioral effect.
System prompt: ~6,000 tokens
After gisting: ~1,500 tokens (75% reduction)
Performance impact at 350 requests/minute:
┌────────────────────────────────┬──────────┐
│ Metric │ Change │
├────────────────────────────────┼──────────┤
│ Time-to-first-token │ -19% │
│ End-to-end latency │ -38% │
│ Requests per second │ +16% │
│ Output tokens per second │ +12% │
│ GPUs needed for same traffic │ -14% │
│ Quality loss (judge score) │ None │
└────────────────────────────────┴──────────┘
Putting it all together, here is what the flywheel achieved for Shopify's GraphQL agent serving up to 2,000 requests per minute:
Frontier model baseline
↓ flywheel runs
Specialized fine-tuned model
Quality: Surpasses frontier model
Cost: ~$27M/year → ~$1M/year (96% reduction)
Latency: 38% faster end-to-end
Hardware: ~14% fewer GPUs for same traffic
Frontier model cost drivers:
- Large model = expensive per token
- Long prompts = many tokens per request
- High volume = costs multiply
Fine-tuned model advantages:
- Smaller model = cheaper per token
- Gist compression = fewer tokens per request
- Same or better quality = no quality tradeoff
Traditional approach:
Launch → Failures → Prompt edits → Still same frozen model
Knowledge lives in: words and code (discrete artifacts)
Flywheel approach:
Launch → Failures → Training signal → Better weights
Knowledge lives in: model parameters (continuous space)
Each cycle begins with a MORE CAPABLE MODEL,
not merely a more elaborate harness.
Cycle 1: Frontier model + improved harness
Cycle 2: Slightly better model + same harness improvements
Cycle 3: Better model + new production lessons folded in
Cycle N: Specialized model that surpasses frontier baseline
at a fraction of the cost and latency
| Term | Definition |
|---|---|
| Flywheel | Continual learning loop that converts production experience into model weight updates |
| Hard negatives | Production conversations the judge scores low; richest training signal |
| Cohen's Kappa | Measure of inter-annotator agreement above chance level |
| GEPA | Prompt optimizer using reflective evolution and Pareto frontier selection |
| Hinting | Injecting a repair instruction before the user's turn to guide replay |
| SFT | Supervised Fine-Tuning; teaches model to imitate successful trajectories |
| GRPO | Reinforcement learning method that scores groups of responses and reinforces the best |
| Gist tokens | Learned compressed token embeddings that replace a long system prompt |
| Catastrophic forgetting | Model losing earlier knowledge when trained on new data; prevented by including previous trajectories |
| Discrete artifacts | Prompts, rules, code — where knowledge lives without a flywheel |
| Continuous parameter space | Model weights — where knowledge lives with a flywheel |