Local engine for typed, calibrated decisions for AI agents.
English · Русский
An agent picks a tool (search, calculator, calendar, email, weather) from the request state. Instead of calling an LLM for every choice, a local choice head is used: linear by default, option_scoring for changing tool sets. It returns a probability distribution over tools. This local layer can sit in front of an expensive LLM router.
JSONL, one example per line. The tool set and descriptions are the same for the whole file:
{"state": "add 12 plus 30", "tools": [{"name": "calculator", "description": "compute arithmetic, sums and numbers"}, {"name": "search", "description": "find facts, documents or answers on the web"}], "correct": "calculator"}
Descriptions go into the option prompt (Option: ... / Means: ...), so option_scoring can transfer the head to a new tool set without retraining (see option-scoring.md).
python -m training.recipe.tool_routing \
--from data/tool_routing/train.jsonl \
--out checkpoints/packs/tool-routing \
--encoder openai-community/gpt2 --dim 768 --steps 500 \
--choice-head linear
Gate: the pack is written only if the selected head beats chance by the Wilson lower bound and, for --choice-head option_scoring, is not worse than the linear head with --min-gain (default 0). Otherwise the directory is not created and the report shows why. --dry-run computes without writing.
DECISION_DEVICE=cuda python -m eval.tool_routing.run \
--encoder openai-community/gpt2 --dim 768 \
--train-steps 500 --seeds 0 1 2 --n-per-tool 30
5 tools, 30 examples per tool, 3 seeds, gpt2, RTX 5060 Ti:
| Metric | selected (linear) | option scoring |
|---|---|---|
| accuracy (mean±std) | 0.820±0.025 | 0.596±0.098 |
| p50 per decision | 4.99 ms | — |
| p95 per decision | 5.01 ms | — |
| cost units per decision | 0 | — |
The numbers are reproducible with the command above; raw JSON goes to data/tool_routing/metrics.json (not committed).
cost_units=0, no external LLM call. This is “cheaper than an LLM” in call cost, not proof of higher accuracy on real traffic.TOOLS set (only the phrases change).competitor-benchmark.md.