Multi-Model LLM Architecture: Technical Selection and Engineering Practices

    This article explains how to build an engineering system for using multiple large language models together. It covers task-based evaluation, a scoring framework, a unified model gateway with dynamic routing, cost control techniques, observability, and a practical rollout plan. The focus is on treating models as replaceable, measurable, and orchestrable infrastructure rather than picking a single "best" model.

    When a team works with several large model services at once, the hard part is not choosing the “strongest model.” It is building an engineering system that is measurable, reproducible, and operable. Starting from the original scenario and stripping away product-specific details, this article frames the problem as four general technical questions: multi-model capability evaluation, dynamic routing, cost control, and quality assurance.

    1. Redefining the Problem: From Model Comparison to Capability Orchestration

    The core fact in the original material is that a heavy user subscribed to multiple mainstream large model services at the same time, and the combined monthly spend reached the hundreds of dollars range. This is not a matter of consumption preference. It reflects a typical engineering proposition: no single model is best at every task, so running multiple models side by side has become the norm.

    The problem therefore needs to be rewritten as three answerable technical questions:

    1. How do you evaluate different models on a specific task under a consistent standard;
    2. How do you decide at runtime which model handles a request;
    3. How do you make a sustainable tradeoff among quality, latency, and cost.

    2. Task Tiering: Evaluation Must Be Bound to Scenarios

    “Overall performance” measured without a scenario has no engineering value. Start by tiering business tasks:

    • Generation: long-form writing, summarization, marketing copy, with attention to coherence, factual consistency, and style control;
    • Reasoning: math, logic, and multi-step planning, with attention to accuracy and stability of the reasoning chain;
    • Code: completion, refactoring, and unit test generation, with attention to compilability and unit test pass rate;
    • Structured extraction: JSON or table output, with attention to schema conformance;
    • Long context: cross-document question answering, with attention to recall of key information and position bias;
    • Conversation: multi-turn consistency, instruction following, and refusal and safety boundaries.

    Build a separate dataset and score each tier separately. Only then can you avoid a situation where a total score hides a weak spot.

    3. Metrics: Prioritize What Can Be Automated

    The evaluation system should follow the principle of “automation first, human review as a fallback”:

    • Objective metrics: accuracy, pass rate, schema conformance rate, retrieval hit rate;
    • Stability metrics: variance across repeated samples of the same input, timeout rate, rate-limit trigger rate;
    • Cost metrics: token consumption per task, cost per task, cache hit rate;
    • Experience metrics: time to first token, end-to-end P95 latency, human preference win rate.

    An illustrative scoring aggregation:

    1. # Weighted score: adjust weights by business priority
    2. WEIGHTS = {"quality": 0.5, "latency": 0.2, "cost": 0.2, "stability": 0.1}
    3. def score(metrics: dict) -> float:
    4. return sum(WEIGHTS[k] * metrics[k] for k in WEIGHTS)

    The key point is that weights are confirmed by the business side and managed with versioning. The evaluation set and the weights together form an “evaluation contract.”

    4. Architecture: A Unified Gateway and Dynamic Routing

    The engineering solution for running multiple models is to introduce a model gateway that exposes a unified interface on top and adapts to different provider protocols below.

    1. Business applications
    2. ↓ unified protocol (chat / completion / structured output)
    3. Model gateway (auth, rate limiting, metering, logging)
    4. ↓ adapter layer
    5. Model A / Model B / Model C / local small model

    Routing strategies can be organized into four levels:

    1. Rule-based routing: hard matching by task type, context length, and compliance level;
    2. Quality-based routing: assign tasks to the best model for that task based on offline evaluation results;
    3. Cost-based routing: choose the lowest unit cost among models that meet the quality bar;
    4. Fallback routing: after the primary model is rate-limited or times out, switch to backup models in order, and if necessary fall back to a smaller model or a cached result.

    An illustrative fallback chain:

    1. def call_with_fallback(prompt, chain):
    2. for model in chain:
    3. try:
    4. return model.invoke(prompt, timeout=8)
    5. except (TimeoutError, RateLimitError):
    6. continue
    7. return cached_or_default(prompt)

    5. Cost Control: Turning Budget into an Executable Constraint

    A high monthly bill is essentially high-frequency calls stacked on top of high-price tiers. Controllable measures include:

    • Context compression: rerank and deduplicate retrieved snippets to cut wasted tokens;
    • Semantic caching: serve similar requests from cache and reuse the result directly;
    • Model tiering: route lightweight tasks such as intent recognition and format validation to small models;
    • Batching and asynchronous execution: run non-real-time tasks off-peak;
    • Budget guardrails: set daily or monthly quotas per tenant and per endpoint, with automatic degradation when exceeded.

    One point deserves emphasis: any billing detail should follow the latest official documentation of the chosen service. An engineering implementation should not hardcode price constants; unit prices should be configurable.

    6. Quality and Observability

    A multi-model architecture without observability will inevitably degrade. The minimum observability set includes request-level tracing, model name and version tags, token usage, sampled quality checks, and user feedback flowing back in. Build a three-part mechanism of “offline evaluation + online sampling + feedback loop.” Automatically trigger regression evaluation when a model or prompt changes, to prevent quality regressions.

    7. Rollout Plan

    1. Week 1: define task tiers and the evaluation set, and get a baseline running;
    2. Weeks 2-3: build the unified gateway and adapter layer, and connect two to three models;
    3. Week 4: ship rule-based routing and fallback, and wire up metering and alerting;
    4. Continuous iteration: introduce quality-based routing and semantic caching, and review weights and the evaluation set quarterly.

    Conclusion

    The value of using multiple models does not come from “subscribing to all of them.” It comes from treating models as replaceable, measurable, and orchestrable infrastructure. When the four pieces are in place: the evaluation contract, gateway routing, cost guardrails, and observability, a team can make evidence-based decisions between quality and cost. This capability can also be combined with general cloud product capabilities such as the container platform, logging service, and monitoring and alerting on Baidu AI Cloud to form a complete engineering loop.