Frontier models are too slow and too expensive for every keystroke of IDE autocomplete. Distillation — train a smaller student on a large teacher’s coding traces — is how you keep inline suggestions under a latency budget without giving up your internal APIs to public GitHub noise.
⚡ TL;DR: Capture teacher traces on internal completion tasks, filter for accepted/compiled suggestions, distill into a Bedrock custom/smaller model, and evaluate on exact-match + compile rate + p95 latency. Keep the frontier model for chat/refactor. See Fine-Tuning Titan: Internal SDK Autocomplete and SageMaker JumpStart vs Bedrock.
When distillation beats prompt-only routing
| Workload | Prefer |
|---|---|
| Inline autocomplete (<150ms budget) | Distilled / small custom model |
| Multi-file refactor, security review | Frontier + tools |
| Domain SDK method names | Distilled on internal corpus |
| One-off architecture advice | Frontier + ADR RAG |
Multi-model routing still applies — Multi-Model Routing: Cheap Draft Models Plus Expensive Verifiers. Distillation is how the “cheap” tier stops being generic.
Build a teacher trace corpus that compiles
# collect_traces.py — illustrative
import json
def keep(example: dict) -> bool:
# ✅ Only traces humans accepted AND that typecheck in context
if not example.get("accepted"):
return False
if example.get("compile_errors"):
return False
if example.get("path", "").startswith("generated/"):
return False
return True
def to_distill_record(ex: dict) -> dict:
return {
"prompt": ex["prefix"], # code before cursor
"completion": ex["suggestion"], # teacher or human-final text
"meta": {
"language": ex["language"],
"repo": ex["repo"],
"teacher_model": ex["teacher_model"],
},
}
with open("teacher_traces.jsonl") as f, open("distill.jsonl", "w") as out:
for line in f:
ex = json.loads(line)
if keep(ex):
out.write(json.dumps(to_distill_record(ex)) + "\n")
Strip secrets before any training export — same filters as IDE context redaction. Prefer internal SDK call sites as in the Titan fine-tune guide.
Distill, deploy, and pin an alias
# Illustrative Bedrock / custom model flow — follow current console/API names
# 1) Upload distill.jsonl to S3 (CMK encrypted)
# 2) Create distillation / fine-tune job with teacher + student model IDs
# 3) Register model; create Provisioned Throughput if autocomplete QPS needs it
# 4) Pin application inference profile alias: coding-autocomplete-prod -> student-v3
Rollback is an alias flip — same discipline as Bedrock Prompt Management.
Evaluate like a product, not a leaderboard
type AutocompleteEval = {
exactMatchRate: number; // vs held-out human accepts
compileRate: number; // suggestion + suffix typechecks
p95LatencyMs: number; // IDE round-trip
hallucinationRate: number; // unknown symbols / APIs
};
export function shipGate(e: AutocompleteEval, baseline: AutocompleteEval) {
if (e.p95LatencyMs > 150) throw new Error("latency_budget");
if (e.compileRate < baseline.compileRate - 0.02) throw new Error("compile_regress");
if (e.hallucinationRate > baseline.hallucinationRate + 0.01) throw new Error("hallucination_regress");
}
Offline harness ideas map to RAG Evaluation on AWS — swap retrieval metrics for completion metrics.
Closing checklist
- [ ] Teacher corpus filtered to accepted + compiling completions only
- [ ] Secrets redacted; generated paths excluded
- [ ] Student evaluated on exact match, compile rate, p95, hallucinations
- [ ] Alias/inference profile pins prod; one-click rollback to previous student
- [ ] Frontier model retained for chat/refactor; autocomplete uses student
- [ ] Latency budget enforced in CI before alias flip
Related reading
- Fine-Tuning Titan: Internal SDK Autocomplete Without Public GitHub Noise
- SageMaker JumpStart vs Bedrock: When Fine-Tunes Beat Prompting
- Multi-Model Routing: Cheap Draft Models Plus Expensive Verifiers
- Bedrock Prompt Management: Versioned System Prompts for Production
Last updated on September 11, 2026
Discover more from CheatCoders
Subscribe to get the latest posts sent to your email.
