Design Query Routing Between Small and Large Gemini Models

Last updated: November 29, 2026

Quick Overview

Serving every request with the largest model is expensive, while a small model handles most easy requests well. Design a router that sends each query to a small or large model to cut cost without lowering answer quality.

Google
ML System Design
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
Technical Screen
ML System Design
Easy

0

0

0 solved


Serving every request with the largest model is expensive, while a small model handles most easy requests well. Design a router that sends each query to a small or large model to cut cost without lowering answer quality.

Cost-aware serving is a common topic for teams launching generative features at Google scale. In a screen, the interviewer looks for a clear router objective, a way to get training labels, and a safe rollout plan.

What the Interviewer Expects
  • Define the objective as quality parity at lower cost
  • Get labels by comparing small and large model outputs with an autorater
  • Train a lightweight classifier on query features
  • Pick a threshold from a cost versus quality curve
  • Roll out with A/B tests and monitor per-slice quality
Key Topics to Cover
Model routing
Cost optimization
Autoraters
Classification thresholds
Cascades
How to Approach This
  1. Start by mapping the business objective to a concrete ML objective and metric.
  2. Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
  3. Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
  4. Address the serving latency budget and whether batch or real-time inference is needed.
  5. Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
  • How do you handle a query that looks simple but needs reasoning?
  • Would you ever cascade: try small first, then escalate?
  • How do you keep the router valid when either model is updated?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice ML System Design Problems
Sample Answer
Requirements

Two models: small (about 10x cheaper, faster) and large. Goal: route at least half of traffic to the small model with no measurable quality loss overall and on key slices (coding, math, long context)....

High-Level Design
  1. Router: a small classifier on the query (embedding plus features like length, presence of code, multi-step wording, language) outputs P(small is good enough)P(\text{small is good enough}).
  2. Policy: route to s...

Submit Your Answer
Markdown supported