Multi-Model Architecture for Office Automation: Design and Model Selection Practices

    This article explains how to move from a single-model setup to a multi-model architecture for office workflows. It covers a four-layer design (access, orchestration, routing, and adapter layers), a three-stage routing evolution from static rules to feedback weighting and online learning, cost control techniques such as budget tiers and caching, stability mechanisms including fallback and retries, evaluation gates, and security and compliance considerations. Readers will find interface definitions, routing and cost estimation code samples, a phased rollout plan, and common pitfalls to avoid.

    1. Why a Single Model No Longer Fits Office Scenarios

    In early LLM application projects, teams often built every capability around one model: writing, summarization, translation, spreadsheet handling, and coding assistance all ran through the same call path. This is simple from an engineering standpoint, but problems surface as usage deepens.

    The first problem is capability mismatch. Models differ in long-context understanding, structured output stability, multilingual coverage, logical reasoning, and code generation. Covering every task with one model inevitably leaves visible gaps in some of them.

    The second is the structural tension between cost and latency. Higher-tier models cost more per call and respond more slowly, yet many office requests are “light tasks” such as short-text rewriting, field extraction, and format normalization. Sending those to a high-tier model wastes resources.

    The third is availability and negotiating leverage. Depending on a single provider leaves almost no buffer when the upstream applies rate limits, becomes unstable, or changes pricing.

    An increasingly common engineering approach is to demote “the model” from a fixed dependency to a replaceable backend resource, with a scheduling layer selecting backends dynamically based on task characteristics, latency budget, and cost ceiling. This article does not evaluate any specific product; it discusses general architecture methods and selection principles.

    2. Target Architecture: Model Calls as Replaceable Backends

    A structure that can evolve sustainably usually has four layers.

    1. Access layer: unified authentication, tenant isolation, and audit instrumentation, exposing stable business APIs.
    2. Orchestration layer: task decomposition, prompt assembly, context trimming, tool invocation, and result aggregation.
    3. Routing layer: the core decision point, choosing a backend based on task type, context length, output format requirements, historical success rate, and budget constraints.
    4. Adapter layer: converging backend differences (message structure, streaming protocol, error codes, rate-limit semantics) into a unified abstraction that hides those differences from upper layers.

    The key design principle: business code depends only on the unified abstract interface and contains no backend-specific data structures. A sketch of the definitions:

    1. from dataclasses import dataclass
    2. from typing import Protocol, AsyncIterator
    3. @dataclass
    4. class ChatRequest:
    5. messages: list[dict]
    6. max_tokens: int = 1024
    7. temperature: float = 0.3
    8. need_json: bool = False
    9. deadline_ms: int = 8000 # latency budget
    10. budget_level: str = "std" # economy / std / premium
    11. @dataclass
    12. class ChatResponse:
    13. text: str
    14. backend: str
    15. latency_ms: int
    16. tokens_in: int
    17. tokens_out: int
    18. class ModelBackend(Protocol):
    19. name: str
    20. async def chat(self, req: ChatRequest) -> ChatResponse: ...
    21. async def stream(self, req: ChatRequest) -> AsyncIterator[str]: ...

    The value of the adapter layer is pluggability: adding or replacing a backend only requires implementing this protocol and registering it in the routing table, with no changes to business logic.

    3. Routing Strategy: From Rules to a Feedback Loop

    Routing should not start as a complex machine learning model. A safer path is a three-stage evolution.

    Stage one, static rules. Map task labels to tiers; this is simple, explainable, and easy to troubleshoot.

    1. def route(req: ChatRequest) -> str:
    2. if req.need_json or len(str(req.messages)) > 60000:
    3. return "backend_strong"
    4. if req.budget_level == "economy":
    5. return "backend_light"
    6. return "backend_balanced"

    Stage two, feedback weighting. Record the task label, actual latency, retry count, and human adoption rate for each call, then periodically compute each backend’s success rate and average cost per label and use the weighted results to adjust the routing table. This turns “selection by guesswork” into data-driven selection.

    Stage three, online learning. Teams with enough samples and instrumentation governance can use a lightweight classification model to predict the expected payoff of a task on a given backend, but rule-based fallbacks and a manual override switch must remain in place to avoid quality fluctuation during cold start.

    At every stage, keep three switches: forced backend selection (for troubleshooting), canary percentage (small-traffic validation of a new backend), and circuit-breaker thresholds (automatic removal when error rate or timeout rate crosses the line).

    4. Cost Control: Making Budget a First-Class Constraint

    One of the biggest benefits of multiple backends is manageable cost. Implementation points:

    • Budget tiers: tag requests as economy / std / premium based on business value, not on who is calling.
    • Context slimming: retrieve and deduplicate first, sending only necessary fragments to the model; for long documents, use a two-stage approach of segmented summarization followed by aggregation.
    • Output constraints: set explicit max_tokens and structured output requirements to avoid extra billing from verbose free text.
    • Cache reuse: normalize and cache prompt prefixes, and build a semantic cache for high-frequency questions so a hit returns immediately.
    • Observability loop: track token consumption and cost per task by tenant, scenario, and backend to build a comparable cost dashboard.

    A sketch of the cost estimation logic:

    1. def estimate_cost(usage, price_table):
    2. p = price_table[usage.backend]
    3. return usage.tokens_in * p.in_price + usage.tokens_out * p.out_price

    The price_table should be delivered by a configuration center. Prices and quotas are operational parameters and should not be hard-coded.

    5. Stability Design: Fallback, Retries, and Consistency

    Multiple backends provide natural redundancy, but turning that into availability requires explicit policies.

    • Timeouts and retries: retry only idempotent requests, use exponential backoff with jitter, and set a total retry budget to avoid an avalanche.
    • Tiered degradation: when the strong backend is unavailable, fall back to the light backend and reduce task complexity at the same time (for example, switching from long-form generation to key-point generation).
    • Semantic consistency: backends differ in output style, so converge results through a unified system prompt, output templates, and post-processing validation (field completeness, JSON validity, sensitive-word and format checks).
    • Idempotency and deduplication: generate a business idempotency key for each request to prevent retries from writing duplicate content into office documents.
    • Full-chain tracing: record the routing decision basis and backend identifier so that quality issues can be traced back to either the prompt or backend instability.
    1. async def chat_with_fallback(req, backends, max_retry=2):
    2. order = route_order(req, backends)
    3. last_err = None
    4. for b in order[:max_retry + 1]:
    5. try:
    6. return await b.chat(req)
    7. except Exception as e:
    8. last_err = e
    9. continue
    10. raise RuntimeError(f"all backends failed: {last_err}")

    6. Quality Assurance: Build the Evaluation Set First

    A multi-model strategy without an evaluation set is flying blind. Three layers are recommended:

    1. Unit-level test cases: prepare dozens to hundreds of samples with reference answers for each office task type, covering boundary inputs.
    2. Regression gates: automatically run the full evaluation when a backend or prompt changes, and block the release if metrics (accuracy, format compliance rate, average latency, cost per task) fall below baseline.
    3. Human spot checks and online feedback: combine adoption rate, edit distance, and complaint labels to continuously add hard cases.

    Evaluation results also feed back into routing: if a backend consistently lags on a task category, its weight is reduced automatically.

    7. Security and Compliance

    • Data classification: sensitive documents must be redacted or processed locally before being sent to any external backend, with clear data flow and retention policies.
    • Permissions and audit: log routing decisions, call records, and export actions, with per-tenant audit support.
    • Content safety: filter both input and output, validate structured output against a schema, and prevent prompt injection delivered through document content.
    • Provider replaceability: pay attention to quotas, price adjustment mechanisms, and data terms in contracts, and keep the adapter layer pluggable technically to lower migration cost.

    8. Suggested Rollout Path

    Phase one (1-2 weeks): abstract the unified interface and adapter layer, connect two backends, and enable only static rule routing plus full instrumentation.

    Phase two (3-4 weeks): build the evaluation set and cost dashboard, ship canary and circuit breaking, and form feedback-weighted routing.

    Phase three (ongoing): expand the task label system, introduce semantic caching and two-stage long-document processing, and gradually increase the share of automated decisions.

    9. Common Pitfalls

    • Comparing only the “strongest model” instead of cost per task, which leads to budget overruns.
    • Scattering routing logic across business code, so swapping a backend requires global changes.
    • Lacking an evaluation baseline and mistaking occasional fluctuation for a backend problem.
    • Degrading the model without degrading task complexity, which makes the user experience worse.
    • Hard-coding prices and quotas, so operational adjustments require a release.

    10. Conclusion

    Model usage in office scenarios is shifting from “pick one” to “schedule a group.” The core technical work is not chasing a particular backend but building replaceability, observability, evaluability, and budget constraints into the architecture. Once the unified abstraction, routing strategy, evaluation loop, and degradation mechanisms are in place, teams can configure capability tiers flexibly according to requirements and budget, achieving a sustainable balance among quality, latency, and cost. If an organization already uses Baidu AI Cloud products, the model scheduling layer can be combined with general capabilities such as logging services, monitoring and alerting, message queues, and object storage to form a complete engineering loop.