Files
Maven/docs/plans/2026-07-11-route-data.md
T
kami 0c65387a5f feat(router): array route contract + shorter RU router prompt
Route contract is now a JSON array of action objects (one per ask) so
compound utterances route all their intents, not just the first. Grammar
root emits `[{intent...},...]`; parseActions tolerates a bare object.
Cascade still returns one Decision — full N-action dispatch lands with the
engine turn-on (marked in-code).

Router prompt rewritten shorter + decision-ordered (prompt-guy feedback),
fact redefined as "implicit update" not "trackable state", kept in Russian
to match the CPT base + phraser. "интент" → "намерение".

CLAUDE.md: routing-architecture section + refreshed open items.
docs/plans: route-data generation plan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GMrVfuYN3nE4L1vEiFYC9
2026-07-11 23:27:44 +04:00

43 lines
2.2 KiB
Markdown

# Route-training data plan (LLM-as-router)
Goal: training data that teaches the CPT'd Qwen3-1.7B to emit the **route
contract** — `{"intent":<enum>, key?, value?, text?, verb?}`, GBNF-constrained —
matching `internal/router/llmrouter.go` (`routeSystem` + `routeGrammar`) verbatim.
Train=deploy parity: label with the EXACT prompt the daemon sends.
7 intents: `fact, reminder, note, query, act, chat, system`. Hard cases (grammar
can't enforce): note vs reminder («запомни» vs «напомни»), fact vs note (trackable
state vs static memo).
## Steps
1. **Source utterances** — real RU turns, not synthetic. Main: `function_calling.jsonl`
(473); plus `user-*.jsonl` fragments for chat/fact/system coverage. `gen_route_data.py`
dedups across all.
2. **Relabel, don't convert** — old taxonomy (time/weather/timer) ≠ 7 intents. Feed
each utterance through `routeSystem` to a strong router model → take its `{intent,...}`.
3. **Validate** — intent ∈ enum, keys ⊆ {intent,key,value,text,verb}. Drop invalid.
4. **Balance check** — after a run, count intents. `act`/`system`/`fact` likely thin
(function_calling skews query/act). Author extra examples for the holes; re-run.
5. **Better prompt first** — improve `routeSystem` for sub-1B disambiguation before a
big generation run (awaiting prompt-guy input). Re-labeling is cheap; regenerate.
6. **Train** — route-LoRA on top of CPT base, OR fold into the persona SFT as a second
contract (decide once volume known). Eval = route accuracy on a held-out REAL set.
## Blocking
- Router at `inference.kvmx.ru` / `localhost:6446` must be up (currently down).
- CPT must finish before the route-LoRA trains on it.
## Files
- `esp32-whisper-fine-tune/llm/gen_route_data.py` — the relabeler (done, self-checks).
`ROUTE_SYSTEM` const = verbatim copy of Go `routeSystem`; **keep in sync**.
- Output: `llm/data/route_train.jsonl` (resumable append).
## Prompt-guy question (sent 2026-07-11)
How to structure the router system prompt for a sub-1B model doing 7-intent
classification + slot extraction, GBNF-constrained — example ordering/count,
contrastive near-miss pairs (note vs reminder) vs more singles, rule placement.