π First prize β Superlinked Γ Qwen Hackathon, 14 Aug 2026
A self-improving semantic router, built in one day.
Most LLM routers need training runs to adapt, but models and traffic change faster than retraining cycles. Darwin is training-free: routing decisions are kNN lookups over a vector index of labelled exemplars, so adaptation is literally an index write. Misroutes detected by an LLM-as-judge are written back into the index β the router improves online, live, with no training loop.
Measured on an immutable, hand-written 40-query holdout that replays against the live index and can never enter it:
| 09:54 (cold start) | 17:45 (end of day) | |
|---|---|---|
| Holdout routing accuracy | 75.0% | 85.0% |
| Avg cost per request | $0.0022 | $0.0011 |
| Exemplars in index | 57 | 91 |
Accuracy climbed 10 points while per-request cost halved β and total spend ran ~65% below the send-everything-to-qwen-max counterfactual. Every gained point came from the Darwin loop writing judged exemplars into the index.
flowchart LR
Q[query] --> P{pre-route rules}
P -->|image attached| V[qwen-vl-max]
P -->|"draw/make an image"| I[qwen-image / z-image-turbo]
P -->|"make a video"| W[happyhorse t2v]
P -->|text| E[SIE embeddings\nQwen3-Embedding-4B]
E --> K[cosine kNN over\nexemplar index]
K -->|simple| S[Qwen3.5-4B on SIE]
K -->|reasoning| R[qwen-max on Alibaba Cloud]
K -.->|margin < 0.7 or 10% sample| J[judge loop]
J -->|shadow-run other route,\nqwen-max compares both| X[insert labelled exemplar\ninto index]
X -.-> K
- SIE (Superlinked Inference Engine) is the core: every text request is
embedded with
Qwen/Qwen3-Embedding-4B, and the cheap lane is served byQwen/Qwen3.5-4Bon SIE. - Alibaba Cloud Model Studio is the offload tier:
qwen-maxfor reasoning,qwen-vl-maxfor vision,z-image-turbo/qwen-image-3.0-profor images,happyhorse-1.1-t2vfor video. - The Darwin loop: uncertain routings (low kNN margin, or a 10% random sample) trigger an async shadow-run of the alternative route. qwen-max judges both real responses blind (A/B, randomized order). On a clear verdict the query is inserted into the index as a new exemplar.
- Honest evaluation: the holdout replays every 10 minutes against a decision-only endpoint β eval traffic can never enter the index, so the accuracy curve is learning, not memorisation.
- The judge applies an adequacy rule: if the cheap model's answer is good enough, the correct route is the cheap one β quality per dollar, not maximum quality.
- The learnable boundary is adequacy, not difficulty. A 2026-era 4B model aces textbook-difficulty tasks β induction proofs, SQL, probability. What actually breaks it: pattern-matching traps (twisted river-crossing classics), stateful simulation with interruptions, exact symbol manipulation, and Python-semantics traps (MRO, mutable defaults, late binding). Embedding space captures topic more than trickiness, so this boundary is genuinely non-obvious β and worth learning.
- An LLM judge can't grade answers it can't produce. qwen-max reliably judged reasoning and writing, but on symbol-manipulation tasks it scored confidently-wrong cheap answers as adequate. Poisoning guards are load- bearing: near-duplicate dedup (cosine β₯ 0.95), per-route insert caps, immutable bootstrap exemplars, verdict-flip hysteresis (overturning an exemplar needs a decisive score gap), and an operator curation script for judge noise the guards miss.
- Index writes beat training runs on hackathon timescales. Cold start to 85% in a single day, every adaptation inspectable as a JSONL line.
uv sync
cp .env.example .env # add SIE_API_KEY and DASHSCOPE_API_KEY
uv run python -m router.bootstrap # cold-start ~40 exemplars
uv run uvicorn router.proxy:app --port 8787
uv run python -m router.replay --loop & # 10-min holdout snapshots
open http://127.0.0.1:8787/ # live dashboardSend it OpenAI-shaped traffic:
curl -s localhost:8787/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model":"darwin","messages":[{"role":"user","content":"hey there!"}]}'Responses carry an x_darwin block: route, kNN margin, model, latency, cost
estimate, and the all-qwen-max counterfactual cost.
| path | what |
|---|---|
router/proxy.py |
FastAPI proxy: pre-route β embed β kNN β dispatch β log |
router/index.py |
in-memory exemplar store, cosine kNN, JSONL persistence |
router/judge.py |
the Darwin loop: gate, shadow-run, blind judge, guarded insert |
router/replay.py |
immutable holdout replay + index snapshots |
router/bootstrap.py |
LLM-generated cold-start exemplars |
scripts/traffic.py |
demo traffic generator (independent of the holdout) |
scripts/curate_hard.py |
operator curation for judge noise on hard families |
dashboard/index.html |
live dashboard (Chart.js, polls /stats every 2s) |
data/holdout.jsonl |
hand-written eval set β never enters the index |
assets/ |
demo video, Qwen-generated poster, HappyHorse concept video |
No database, no vector store, no training infra: numpy + JSONL files.
Costs shown are hardcoded estimates ($/1M tokens). Built with Claude Code.
