Engineering Multi-Model Selection in AI Office Platforms

    This article walks through the engineering practices behind adding multi-model selection to an AI office platform. It covers the architectural shift from single-model binding to a decoupled model runtime, the design of a unified abstraction layer, task profiling and routing strategies, cost attribution from per-token pricing to per-task cost, enterprise permissions and governance, and quality assurance through offline evaluation and canary releases. Readers will find interface sketches, routing and cost pseudocode, and a practical implementation checklist.

    1. From Single-Model Binding to Multi-Model Selection

    Early AI office products typically served users with a single model or a few fixed tiers. The product side only had to maintain one prompt template set and one parameter configuration. As task types expanded from simple Q&A to long-document understanding, structured extraction, complex reasoning, and multimodal analysis, the limits of a single model became more visible in three areas: capability boundaries, response latency, and cost per token. High-capability models are cost-inefficient on high-frequency lightweight tasks, while lightweight models struggle with long reasoning chains.

    Opening up model selection is therefore essentially an architectural decoupling: separating application logic from the model runtime. Upper-layer office applications program against a unified model abstraction interface, while a registry manages multiple model implementations underneath. The payoff is more than “a few extra options.” It gives the platform the ability to schedule dynamically based on task profiles, degrade under budget constraints, and isolate workloads to meet compliance requirements.

    2. Designing a Unified Abstraction Layer for Model Access

    The first step is to define a stable abstraction interface that hides differences across models in context length, multimodal input, function calling, and streaming output. The recommended capability surface includes:

    • Basic chat: system prompts, message history, and incremental streaming responses;
    • Structured output: results constrained by a JSON Schema so office forms and workflow engines can consume them;
    • Tool calling: a unified tool description format and call receipts;
    • Multimodal input: images or document pages as an optional input channel;
    • Observability instrumentation: consistent logging of request IDs, model identifiers, token usage, and latency.

    Illustrative interface definition (pseudocode):

    1. interface ModelAdapter {
    2. id: string // logical model identifier
    3. capabilities: { // capability declaration used for routing
    4. maxContext: number
    5. vision: boolean
    6. jsonSchema: boolean
    7. tools: boolean
    8. }
    9. costProfile: { inputPer1k: number, outputPer1k: number }
    10. chat(req: ChatRequest): Async<ChatChunk>
    11. }

    The key point is decoupling the logical model identifier from the physical model instance. The business side references only logical identifiers such as reasoning-strong, general-balanced, and extract-fast, and the platform maps them to specific backends through configuration. This means version upgrades or capacity adjustments require no changes to business code.

    3. Task Profiling and Routing Strategy

    The value of multiple models only materializes when routing is correct. Task profiles can be built along three dimensions: complexity, latency sensitivity, and cost budget.

    1. Complexity tiers: tasks are grouped into extraction and organization, rule validation, and complex reasoning. The first group can use a low-cost fast lane; the last uses a strong-reasoning lane.
    2. Latency tiers: interactive completion requires low time-to-first-token, so a lightweight model is preferred; background batch jobs can tolerate higher latency in exchange for quality.
    3. Cost tiers: set a token budget per tenant or department, and automatically degrade to a lower-cost model or queue requests when the budget is exceeded.

    Routing can follow a “rules first, scoring as fallback” approach:

    1. function route(task):
    2. if task.type == "extract" and task.budget == "low":
    3. return "extract-fast"
    4. if task.type == "reasoning" and task.contextTokens > 200000:
    5. return "reasoning-strong" // requires long-context capability
    6. score = 0.6*qualityEstimate + 0.25*(1-latencyNorm) + 0.15*(1-costNorm)
    7. return argmax(score, candidates(task))

    Routing decisions should be explainable and replayable. Record why a given model was chosen for each request, which supports later offline evaluation and policy iteration.

    4. Cost Control: From Per-Token Price to Per-Task Cost

    The original concern about a lower average cost per task translates, in engineering terms, into cost attribution. A three-level ledger is recommended:

    • Request level: record input and output tokens, model identifier, and latency;
    • Task level: break an office task (such as generating a weekly report) into multiple model calls and aggregate the cost;
    • Organization level: roll up by department, user group, or member to form budgets and quotas.

    Optimization measures include prompt compression and deduplication, retrieval augmentation to reduce repeated long-context input, caching frequent Q&A, using small models for extraction tasks, and batching requests. Illustrative cost aggregation:

    1. taskCost = Σ (inTokens_i * priceIn_model_i + outTokens_i * priceOut_model_i)
    2. if taskCost > budget: degradeTo("extract-fast")

    5. Enterprise Model Permissions and Governance

    Governance complexity rises sharply once model selection is open. Enterprises typically need to assign available models by department, user group, or member; require approval and quotas for high-cost models; restrict the model range for sensitive data; and retain audit logs.

    A “policy as data” permission model is recommended:

    1. policy:
    2. scope: dept:finance
    3. allow: [general-balanced, extract-fast]
    4. deny: [reasoning-strong]
    5. quota: { dailyTokens: 2000000 }
    6. audit: true

    In Baidu AI Cloud’s general capability portfolio, a container platform can host the model gateway and routing service, object storage can hold audit and evaluation datasets, a message queue can smooth batch-processing peaks, and logging plus monitoring with alerting can close the observability loop for tokens and latency. These are general-purpose capabilities and do not involve any proprietary interfaces.

    6. Quality Assurance and Canary Releases

    A system running multiple models needs unified evaluation. Build an offline evaluation set covering extraction, reasoning, long documents, and multimodal inputs, with task success rate, structured-output compliance rate, time-to-first-token, and cost per task as core metrics. Roll out with canary releases: validate the routing strategy on a small traffic share first, then ramp up gradually. Automatically circuit-break abnormal models and fall back to the default lane.

    7. Implementation Checklist

    • Establish a unified model abstraction with capability declarations;
    • Decouple business logic from backends using logical identifiers;
    • Keep routing rules explainable and replayable;
    • Maintain a three-level cost ledger with budget-based degradation;
    • Distribute enterprise policies by organizational dimension and audit them;
    • Combine offline evaluation, canary releases, and circuit-breaking fallback.

    In summary, opening multi-model selection in an AI office platform is not about connecting more models. It is about building a model runtime system that is routable, measurable, governable, and evolvable.