Skip to content
SnehaNprogPublic

About

Built an adaptive router to reduce unnecessary large-model inference by routing requests across 7 LLMs based on quality, latency, and cost; reduced inference cost by 70% while maintaining 93%+ quality against a best-model baseline.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

ModelMesh

Adaptive LLM inference router — the right model for every request.

Optimises quality against cost and latency, instead of sending everything to the biggest model available.


The problem

Using the strongest model for every request is expensive and slow. Using the smallest model for everything sacrifices quality.

ModelMesh answers one question per request:

Which model should answer this?

How it works

Request
   │
Task classifier
   │
Difficulty estimate
   │
Model selection ──────────► Small / Medium / Reasoning / Large
   │
Response evaluation
   │
   ├── good enough ──► return
   │
   └── not good enough ──► escalate to the next tier

Only genuinely difficult requests reach expensive models.

Routing objective

score  =  quality  −  λ · cost  −  μ · latency

λ and μ are tunable, so the same router can be configured for a cost-sensitive workload or a quality-sensitive one.

Versions

Version Strategy
v1 Task classification → static tier mapping
v2 Explicit quality / cost / latency optimisation
v3 Adaptive escalation — start small, escalate only on failure

Baselines

The router is only interesting if it beats the obvious alternatives, so all four are benchmarked on the same request set:

Strategy Quality Cost Latency
Always cheapest — — —
Always strongest — — —
Static rule-based — — —
ModelMesh — — —

Benchmark

A request set spanning the task types a real workload actually contains:

  • simple extraction
  • classification
  • summarisation
  • coding
  • multi-step reasoning
  • complex analysis

Every request logs: query, task type, selected model, quality score, latency, tokens, cost, whether it escalated, and the final model.

Metrics

  • quality retention vs. always-strongest
  • cost reduction
  • p50 / p95 latency
  • routing accuracy
  • escalation rate
  • throughput

Stack

Python · PyTorch · Hugging Face Transformers · embeddings · vLLM

Status

🚧 In development.

License

MIT

About

Built an adaptive router to reduce unnecessary large-model inference by routing requests across 7 LLMs based on quality, latency, and cost; reduced inference cost by 70% while maintaining 93%+ quality against a best-model baseline.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors