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.
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
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- 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 ProblemsSample 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
- Router: a small classifier on the query (embedding plus features like length, presence of code, multi-step wording, language) outputs .
- Policy: route to s...