adaptive-memory-multi-model-router 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +73 -42
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -177,57 +177,88 @@ A3M Router combines multi-signal routing, semantic caching, and load balancing t
177
177
 
178
178
  ### Routing Signals
179
179
 
180
+ A3M Router uses **multi-signal heuristic scoring** — 12 keyword signals across 5 dimensions — to classify query complexity and route to the cheapest capable model. No ML model weights. No GPU required. <1ms latency.
181
+
180
182
  ```
181
183
  User Query
182
184
 
183
- ┌─────────────────────────────────────────┐
184
- 5-Signal Complexity Scoring (0.0–1.0)
185
- │ │
186
- 1. Domain Detection
187
- legal/medical/finance/security/
188
- architecture/ML research
189
-
190
- 2. Task Indicators
191
- code / math / creative / multilingual
192
-
193
- 3. Query Structure
194
- length + clauses + qualifiers
195
-
196
- 4. Action Verb Intensity
197
- expert(+0.20) / mid(+0.10) /
198
- simple(-0.10)
199
-
200
- 5. Specificity
201
- multi-step + detailed requirements
202
-
203
- ├─────────────────────────────────────────┤
204
- Tier: free ← 0.19 | cheap ← 0.44 |
205
- mid 0.64 | premium → 1.0
206
- ├─────────────────────────────────────────┤
207
- Pick cheapest available model in tier
208
- + 2 fallback models
209
- + adaptive quality scores from history
210
- └─────────────────────────────────────────┘
185
+ ┌──────────────────────────────────────────────────────────────┐
186
+ 12-Keyword Signal Extraction
187
+ ├──────────────────────────────────────────────────────────────┤
188
+
189
+ Signal 1: Domain Detection (+0.35 max)
190
+ ┌────────────────────────────────────────────────────────┐
191
+ legal/contract/liability/clause → +0.35 │ │
192
+ medical/clinical/patient/diagnosis → +0.35
193
+ finance/investment/risk/portfolio +0.30
194
+ security/vulnerability/exploit → +0.35 │ │
195
+ architecture/system design → +0.25
196
+ ML/model/training/gradient → +0.25
197
+ └────────────────────────────────────────────────────────┘
198
+
199
+ Signal 2: Task Indicators (+0.25 max)
200
+ ┌────────────────────────────────────────────────────────┐
201
+ code/function/algorithm/debug → +0.25 │ │
202
+ │ math/calculate/equation/formula → +0.20
203
+ creative/story/poem → +0.10 │
204
+ translate/multilingual/language → +0.15 │ │
205
+ │ └────────────────────────────────────────────────────────┘ │
206
+
207
+ Signal 3: Query Structure (+0.20 max)
208
+ │ ┌────────────────────────────────────────────────────────┐ │
209
+ Length > 200 chars → +0.05 │
210
+ Multiple clauses (and/or/but) → +0.10
211
+ Qualifiers (explain, analyze) → +0.05
212
+ │ └────────────────────────────────────────────────────────┘ │
213
+ │ ↓ │
214
+ │ Signal 4: Action Verb Intensity (+0.20 max) │
215
+ │ ┌────────────────────────────────────────────────────────┐ │
216
+ │ │ Expert: design/architect/optimize → +0.20 │ │
217
+ │ │ Mid: analyze/review/evaluate → +0.10 │ │
218
+ │ │ Simple: what/who/when/where → -0.10 │ │
219
+ │ └────────────────────────────────────────────────────────┘ │
220
+ │ ↓ │
221
+ │ Signal 5: Multi-Step Detection (+0.15 max) │
222
+ │ ┌────────────────────────────────────────────────────────┐ │
223
+ │ │ "first...then...finally" → +0.15 │ │
224
+ │ │ "step 1, step 2, step 3" → +0.15 │ │
225
+ │ └────────────────────────────────────────────────────────┘ │
226
+ │ │
227
+ ├──────────────────────────────────────────────────────────────┤
228
+ │ Complexity Score → Tier Assignment │
229
+ │ │
230
+ │ 0.00 ────────── 0.19 ─────────── 0.44 ──────────── 1.00 │
231
+ │ ├─── free ─────|── cheap ───────|── mid ─────────| premium │
232
+ │ └── taste-1 ───┘ └── llama3.3 ──┘ └── gpt-4o-mini ┘ └──gpt4o│
233
+ │ $0 $0.20/M $0.60/M $2.50/M │
234
+ │ │
235
+ │ Route: Pick cheapest available model in tier │
236
+ │ Fallback: +2 fallback models if primary fails │
237
+ │ Quality: Adaptive scores from historical success rates │
238
+ └──────────────────────────────────────────────────────────────┘
211
239
 
212
- Result: { model, tier, cost, complexity, reasoning, fallbackModels }
240
+ Result: { model, tier, cost, complexity, reasoning[], fallbackModels[] }
213
241
  ```
214
242
 
215
243
  ### Complexity Examples
216
244
 
217
- | Query | Domain | Complexity | Tier | Model |
218
- |-------|--------|:----------:|:----:|-------|
219
- | "What is 2+2?" | | 0.10 | free | commandcode/taste-1 |
220
- | "Write a Python sort function" | coding | 0.33 | cheap | groq/llama-3.3-70b |
221
- | "Analyze economic implications of AI" | | 0.41 | cheap | groq/llama-3.3-70b |
222
- | "Review this contract for liability" | legal | 0.87 | premium | anthropic/claude-3.5-sonnet |
223
- | "Design a clinical trial for oncology" | medical | 1.00 | premium | openai/gpt-4o |
245
+ | Query | Signals Detected | Score | Tier | Route To |
246
+ |-------|------------------|:-----:|:----:|----------|
247
+ | "What is 2+2?" | Simple structure | 0.10 | free | taste-1 ($0) |
248
+ | "Write a Python sort" | code+0.25, simple-0.10 | 0.33 | cheap | llama-3.3-70b ($0.20/M) |
249
+ | "Analyze AI implications" | analyze+0.10 | 0.41 | cheap | llama-3.3-70b ($0.20/M) |
250
+ | "Review contract liability" | legal+0.35, review+0.10, long+0.05 | 0.87 | premium | claude-3.5-sonnet ($1.50/M) |
251
+ | "Design oncology trial" | medical+0.35, design+0.20, steps+0.15 | 1.00 | premium | gpt-4o ($2.50/M) |
252
+
253
+ ### Cost Savings by Query Type
254
+
224
255
  | Query Type | % Traffic | GPT-4o Only | A3M Routes To | A3M Cost | Savings |
225
- |-----------|:---------:|:-----------:|:-------------:|:--------:|:-------:|
226
- | Simple Q&A | 47% | $4.94 | CommandCode (free) | $0.00 | 100% |
227
- | Code gen | 15% | $4.88 | DeepSeek ($0.14/1M) | $0.17 | 97% |
228
- | Summarization | 18% | $7.20 | GPT-4o-mini ($0.15/1M) | $0.43 | 94% |
229
- | Reasoning | 12% | $8.70 | Claude Haiku ($0.80/1M) | $3.36 | 61% |
230
- | Expert | 8% | $8.40 | GPT-4o ($2.50/1M) | $8.40 | 0% |
256
+ |------------|:---------:|:-----------:|:-------------:|:--------:|:-------:|
257
+ | Simple Q&A | 47% | $4.94 | taste-1 (free) | $0.00 | **100%** |
258
+ | Code gen | 15% | $4.88 | deepseek ($0.14/M) | $0.17 | **97%** |
259
+ | Summarization | 18% | $7.20 | gpt-4o-mini ($0.15/M) | $0.43 | **94%** |
260
+ | Reasoning | 12% | $8.70 | claude-haiku ($0.80/M) | $3.36 | **61%** |
261
+ | Expert | 8% | $8.40 | gpt-4o ($2.50/M) | $8.40 | **0%** |
231
262
  | **Total** | **100%** | **$34.11** | — | **$12.36** | **64%** |
232
263
 
233
264
  | Monthly Queries | GPT-4o Only | A3M Router | You Save | Annualized |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adaptive-memory-multi-model-router",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "shortName": "A3M Router",
5
5
  "displayName": "A3M Router - Adaptive Memory Multi-Model Router",
6
6
  "description": "LLM router & AI gateway — 99.5% routing accuracy, 47 providers (DeepSeek, Kimi/Moonshot, Qwen, Zhipu GLM, Yi + more). Semantic cache, guardrails, cost analytics. Built on 30+ arXiv papers (SGLang, Medusa, MemoRAG). Zero ML, 19.5KB. TypeScript + Python SDK. MIT.",