Add lemonade-liquid-router: local-first tri-ensemble router (~80% on-device) - #198
Add lemonade-liquid-router: local-first tri-ensemble router (~80% on-device)#198ramkrishna2910 wants to merge 6 commits into
Conversation
Two Lemonade-served local models (DeepSeek-V4-Flash ds4, Qwen3.8-27B) vote with gemini-3-flash-preview; majority wins, local-preferred. Providers added: lemonade (local OpenAI-compatible) and OpenRouter mappings. All thresholds calibrated on external public benchmarks only.
…ini slug, additive-only cost table, boxed-answer corroboration, lint - gemini-3-flash-preview maps to OpenRouter when GOOGLE_API_KEY is absent, matching the committed provider records; direct-Google setups unchanged. - model_cost.json rebuilt from upstream + two lemonade entries only; the six entries used by Paix2-router and sqwish-fvcta8 are restored. - Free-answer corroboration extracts final boxed answers before comparing; contradictory boxed answers now always escalate. - Unused import removed; ruff format applied to touched files; EOF newline.
…tting - mypy (run by CI's pre-commit matrix, py3.9-3.12): annotate request_kwargs as Dict[str, Any], accept Optional api_key, and type the lazily-created ModelInference attribute via TYPE_CHECKING import. - _call_openrouter: translate the unprefixed gemini-3-flash-preview universal name to the vendor-prefixed slug OpenRouter requires; without this the no-GOOGLE_API_KEY fallback path failed on every call. - model_cost.json: restore original formatting of the MiniMax-M3 entry so the diff against upstream is purely additive. Full pre-commit suite (incl. mypy-3.9/3.12 manual hooks) passes; both submission validators pass; scores unchanged (accuracy 0.7803, $0.1706/1K, arena 0.7674, robustness 0.7310, 0 abnormal). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016yHZizzdKkiPz3WbPpUHu1
Leaderboard-facing name change only: config/prediction files, router_name, and class renamed from lemonade-cascade/LemonadeCascadeRouter to lemonade-router/LemonadeRouter. No policy, prediction, or pricing changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016yHZizzdKkiPz3WbPpUHu1
Adds LFM2.5-Embedding-350M (F16 GGUF, lemonade llamacpp recipe) as a third on-device model: when free-answer corroboration falls back to last-200-chars extracts (no boxed answer on >=1 side), keeping the local answer additionally requires embedding cosine >= 0.7 between the extracts. Threshold chosen label-free at the precision knee of a g3fp-agreement pseudo-reference (keep-precision 0.877 -> 0.904 on the 633 measurable fallback pairs). Flips 115/8400 full rows and 5/420 robustness rows vs v5.1. Scored with this repo's evaluation code: accuracy 78.10%, $0.1783/1K, arena 76.75, robustness 73.57, 0 abnormal (v5.1: 78.03 / $0.1706 / 76.74 / 73.10). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016yHZizzdKkiPz3WbPpUHu1
|
/evaluate |
Router Evaluation ResultsRouter: RouterArena Metrics
Evaluation completed by RouterArena automated workflow |
Leaderboard-facing name change only; no policy, prediction, or pricing changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016yHZizzdKkiPz3WbPpUHu1
|
/evaluate |
Router Evaluation ResultsRouter: RouterArena Metrics
Evaluation completed by RouterArena automated workflow |
|
Thanks for an unusually thorough and transparent submission, @ramkrishna2910 — the methodology write-up, the frozen-config provenance, and the dedup manifest are exactly what we like to see, and I want to be clear up front that nothing here reads as bad-faith. The integrity audit is clean: 8,400 real rows, genuine per-prompt token accounting, no oracle/label contamination, faithfulness in range. The routing logic is real. I'm holding the leaderboard placement, though, on cost accounting — two issues, one policy and one concrete: 1. Uncharged voter tokens (concrete). You disclose that every MCQ query runs all three voters — including a cloud 2. Local/self-hosted pricing (policy — see #193). The What would unblock it: re-account the cost so that every model call the router makes per query is charged (all voters, including the cloud gemini vote), and align the local pricing with the #193 outcome. I expect (1) alone moves the number materially. The router itself is fine — this is purely about making the cost comparable to the cloud-based entries. Happy to re-review as soon as the accounting is updated, and thanks again for the care you put into this. |
|
Thanks for the careful review and kind words, you’re right on point 1. We disclosed the extra voter calls but billed only the winning response’s tokens, we’ll fix that. One property of the policy defines what needs to be charged: in a 2-of-3 majority vote, the cloud vote cannot change the outcome when the two local voters agree — the majority is already decided. The locals agree on 81.2% of MCQs (4,810 of 5,924). We will re-account by charging gemini vote on the 1,114 MCQs where the two locals disagree (plus all escalations, which are already billed as submitted rows). This short-circuit implementation produces the identical prediction file, and we’ll update the router class to match. Re-accounted cost: $0.249/1K. On point 2, we’ll make the case in #193. Briefly: lemonade/deepseek-v4-flash is not the cloud model at a different endpoint, it’s a distinct public artifact (2-bit IQ2XXS quant, weights on HF), served by public Lemonade release. Anyone can reproduce both the quality and the cost. This submission exists to show local models augmenting cloud usage; pricing on-device inference at cloud list rates charges dollars no one spends and erases the deployment mode it demonstrates. We’ll push the re-accounted files if the above makes sense. Looking forward to your response :) |
Summary
lemonade-liquid-router is a local-first router built on three on-device models — two generator voters and an embedding referee — all served by a single instance of Lemonade, AMD's open-source local LLM server, plus one cloud voter. ~80% of the benchmark is answered entirely on-device.
Local scoring with this repo's evaluation code: accuracy 78.10% · $0.178 per 1K queries · robustness 73.6.
Candidate models
lemonade/deepseek-v4-flashlemonade/Qwen3.8-27B-GGUF-UD-Q4_K_XLlemonade/LFM2.5-Embedding-350Mgemini-3-flash-previewdeepseek/deepseek-v4-proThe local models are served by a single Lemonade instance: DeepSeek-V4-Flash as an IQ2XXS quant via the
ds4recipe, Qwen3.8-27B as UD-Q4_K_XL and LFM2.5-Embedding-350M as an F16 GGUF via thellamacpprecipe. Hardware: 2× AMD Ryzen AI Max+ 395 (128 GB unified memory each).How the router works
Each query is classified by prompt shape alone, then routed:
Options:block, no boxed-answer instruction) → answered bygemini-3-flash-previewdirectly.Options:present) → all three voters answer independently; the boxed letter is extracted from each response and a 2-of-3 majority vote is taken. The submitted response comes from a majority member, preferring local models (DeepSeek, then Qwen, then gemini). No majority → escalate togemini-3-flash-preview.lemonade/LFM2.5-Embedding-350M) to corroborate semantically: cosine ≥ 0.7 between the two extracts. Any failed check → escalate togemini-3-flash-preview.What the routing is based on
Routing uses only the prompt text and the models' own outputs (agreement between voters, measured lexically and — on degraded extracts — by embedding cosine from an off-the-shelf embedding model). There is no routing model trained by us, no query-difficulty classifier, and no per-domain rules.
The design constants — the 2-of-3 vote, the token-F1 ≥ 0.5 corroboration threshold, the embedding-veto threshold (cosine ≥ 0.7, chosen label-free at the precision knee of a g3fp-agreement pseudo-reference), the local-preference order — were fixed a priori and calibrated exclusively on a 1,251-item set sampled from the upstream public benchmarks (deduplicated against all RouterArena splits) and on our own runtime/token telemetry. Model selection (which model fills the cloud slot) was additionally informed by aggregate statistics from the graded submissions already public in this repo — the same information available to every submitter, never used to fit any per-query component. No RouterArena data or labels were used to tune any router component. Full-set labels were touched only by pre-registered scoring runs of frozen configurations.
Reproducing the results
Prerequisites: a machine that can serve the three local models,
OPENROUTER_API_KEY(orGOOGLE_API_KEYfor direct Gemini access), andLEMONADE_BASE_URLif the Lemonade server is not on the defaulthttp://localhost:8000/api/v1.The local side is fully deterministic (temperature 0, thinking disabled,
max_tokens4096), and we verified the local IQ2XXS DeepSeek-V4-Flash quant scores identically to the API model on our calibration set, so the numbers should reproduce up to cloud-provider nondeterminism.Full methodology — the frozen policy as run, the provenance of every design constant, and the calibration set builder with a per-item hash manifest so the dedup claim is independently checkable: https://github.com/ramkrishna2910/lemonade-router-routerarena. Raw generation logs contain RouterArena prompt content and are therefore not republished; they are available to maintainers on request.
Pricing & transparency
lemonade/*local models are declared at an honest self-hosting estimate (power + amortization): $0.02/$0.04 per Mtok in/out for DeepSeek-V4-Flash, $0.01/$0.02 for Qwen3.8-27B, $0.001/$0.001 for the embedding judge (which never appears as a prediction; its entry exists for config completeness).Files
router_inference/config/lemonade-liquid-router.jsonrouter_inference/predictions/lemonade-liquid-router.json— 8,400 rows,generated_resultpopulatedrouter_inference/predictions/lemonade-liquid-router-robustness.json— 420 rowsrouter_inference/router/lemonade_liquid_router.py+ registry entryllm_inference/model_inference.py—lemonade(local OpenAI-compatible) and OpenRouter provider mappingsuniversal_model_names.py,model_cost/model_cost.json— entries for thelemonade/*modelsBoth validation scripts pass (
check_config_prediction_files.pyforfullandrobustness), and the full pre-commit suite — including the CI mypy matrix (3.9–3.12) — passes on the branch.Leaderboard row details (to save you a lookup)
lemonade-liquid-router🤖 Generated with Claude Code