Context-aware LoRA adapter routing for VS Code
The benchmark system answers a concrete measurable question:
Does the router choose the right adapter often enough, and does that choice reduce cold misses?
LoRA-JIT treats routing as an engineering problem with numbers, not intuition.
| Metric | Description |
|---|---|
top1_accuracy |
Fraction of rows where the predicted adapter is correct (multi-label weighted) |
cache_miss_rate |
Fraction of route decisions that caused a cold miss in PagingSimulator |
avg_prediction_ms |
Mean wall-clock route time for the predictor under test |
| Name | Strategy | Trainable |
|---|---|---|
structural |
Heuristic token matching on file path, language ID, symbol path | No |
text |
Lexical overlap on path, language, symbols, metadata.query/prompt |
No |
embedding |
Deterministic pseudo-embedding cosine similarity | No |
learned |
Multinomial Naive Bayes over tokenised event context | Yes |
All predictors share the same predict(event) -> RoutingDecision interface.
Each benchmark row must contain:
{
"event": {
"session_id": "...",
"file_path": "...",
"language_id": "...",
"cursor_line": 0,
"cursor_column": 0,
"symbols_in_scope": [],
"metadata": {}
},
"expected_adapter": "sql_postgres"
}
Or the richer multi-label form (produced by the auto-labeler):
{
"event": { ... },
"expected_label": {
"primary_adapter": "sql_postgres",
"acceptable_alternatives": ["data_engineering_general"],
"confidence": 0.92,
"reasoning": "File contains parameterised PostgreSQL queries"
}
}
python scripts/run-benchmark.py examples/sample-trace.json --compare
python scripts/run-benchmark.py examples/sample-trace.json --predictor structural
# Train
python scripts/train-router.py examples/router-train.seed.json \
--output examples/router-model.seed.json
# Benchmark
python scripts/run-benchmark.py examples/router-train.seed.json \
--predictor learned \
--model-path examples/router-model.seed.json
python scripts/compile-trace.py traces/<session>.ndjson \
--rows-output benchmark.rows.json \
--windows-output benchmark.windows.json
What this does:
python scripts/annotate-benchmark.py benchmark.rows.json \
--output benchmark.annotated.json \
--print-ontology
What this does:
docs/ADAPTER_ONTOLOGY.mdprimary_adapter → expected_adapter for legacy predictor compatibilityLlmLabelProvider for richer reasoning if LORA_JIT_LLM_API_BASE is setpython scripts/run-benchmark.py benchmark.annotated.json --compare
When expected_label is present:
| Prediction | Score |
|---|---|
Matches primary_adapter |
1.0 |
Matches an acceptable_alternative |
0.5 |
| Anything else | 0.0 |
top1_accuracy is the mean of per-row scores. This captures domain ambiguity honestly
rather than penalising valid alternative predictions as errors.
Without a fixed ontology, offline label generation can hallucinate adapter IDs that do not exist in the runtime system. That silently corrupts benchmark comparisons.
LoRA-JIT prevents this by requiring all labels to use IDs from
docs/ADAPTER_ONTOLOGY.md.
The label parser rejects any ID outside the ontology before it can enter scoring.
This gives the benchmark two important properties:
The bundled examples/sample-trace.json is a smoke test, not a production benchmark.
All three baselines currently score top1_accuracy = 1.0 on it because it is small and clean.
Meaningful benchmark results require:
The benchmark infrastructure is production-ready; the bundled datasets are intentionally minimal to keep the repository lightweight.