Multi-Model Integration for Office Platforms: A Technical Practice
This article explains how to build an office platform that runs multiple large language models side by side. It covers a four-layer architecture with a unified adapter contract, dynamic routing based on task type, input size, quality constraints, and resource status, plus the protocol differences that appear in prompts, structured output, and tool calls. It also addresses cost, latency, and capacity governance, a three-tier evaluation system, and a practical implementation checklist.
1. Why Office Scenarios Need Multiple Models
In intelligent office applications, a single model rarely covers long-document understanding, structured extraction, code and spreadsheet handling, and stable multi-turn conversation at the same time. A common industry approach is to maintain a model registry on the platform side, register models from different vendors with different parameter sizes and different capability strengths, and then dispatch them by task type. One office platform recently published more than a dozen model options at once, spanning general-purpose flagship, lightweight fast, and reasoning-enhanced tiers. In essence, this moves model selection from the user to the platform, letting the system decide automatically per scenario.
This brings three direct benefits. First, complementary capabilities: complex document parsing and short-text rewriting can run on different paths. Second, controllable cost: high-frequency, low-difficulty requests are routed down to lightweight models. Third, risk diversification: when a single model fluctuates, alternative paths remain. The price is higher complexity, which means replaceability has to be treated as a first-class concern in the architecture.
2. Layered Architecture: Abstracting Models Behind a Replaceable Adapter Layer
Split the system into four layers so business code stays decoupled from any specific model.
- Access layer: unified authentication, rate limiting, quotas, and auditing. It exposes only internal task semantics externally, never model details.
- Adapter layer: implements one consistent call contract per model, taking a normalized message array as input and returning a normalized result object.
- Scheduling layer: selects a model based on task labels, context length, latency budget, and cost budget, and handles retries and fallback.
- Observability layer: collects call volume, time to first token, total latency, failure rate, and cost per task, forming a traceable evaluation loop.
The adapter contract can be simplified to the structure below; the point is to converge all differences in one place:
{"task": "doc_summary","messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}],"constraints": {"max_input_tokens": 32000, "max_output_tokens": 1200, "latency_budget_ms": 8000},"fallback": ["model_b", "model_c"]}
The scheduling layer reads only task and constraints and does not care which vendor or which spec is underneath. Adding or retiring a model therefore requires no changes to business logic.
3. Routing Strategy: From Static Tiers to Dynamic Decisions
Early designs usually offered only three tiers, such as standard, advanced, and flagship, selected manually by the user. With multiple models in place, this should become dynamic routing. Score four categories of signals:
- Task type: summarization, extraction, rewriting, code generation, and spreadsheet computation each have their own weight table.
- Input size: very long contexts prefer models with more stable long-window capability; short requests go through the low-latency path.
- Quality constraints: for high-risk text such as contracts and financial documents, raise the quality weight and, when necessary, cross-check with two models.
- Resource status: real-time failure rate and queueing latency act as penalty terms, so traffic is not continuously pushed onto a jittery node.
A practical scoring function looks like this:
score = w1 * task_fit + w2 * quality_est - w3 * latency_norm - w4 * cost_norm - w5 * error_rate
Here quality_est comes from fusing the offline evaluation set with manual annotation sampled from live traffic, so tuning is not driven by subjective impression alone.
4. Adapting Context and Tool Calls
In a multi-model environment, the most common problems come not from generation quality but from protocol differences. Typical pitfalls include: different handling of system prompt priority, different strictness of structured output constraints, different naming and nesting of function call fields, and different truncation strategies for very long contexts. Three engineering practices help.
First, build a compile layer for prompt templates that compiles business semantics into a form each model accepts, and forbid hand-written branches inside business code.
Second, validate structured output a second time. If schema validation fails, trigger a repair-style retry instead of writing the raw text straight to storage.
def safe_extract(raw, schema, retry=2):for i in range(retry + 1):try:return validate(parse(raw), schema)except Exception:raw = call_model(prompt=repair_prompt(raw), temperature=0)raise ValueError("structured output invalid")
Third, unify tool calls into an internal function description language, let the adapter layer translate it into each model’s dialect, and normalize return values with consistent trimming and redaction.
5. Cost, Latency, and Capacity Governance
Cost fluctuation from multiple models needs explicit governance. Set a cost ceiling and a latency budget for each task, and fall back to a lightweight model automatically when either is exceeded. Add a semantic cache for high-frequency repeated requests so a hit returns immediately. For batch offline jobs, use a queue to smooth peaks and shift throughput pressure to off-peak hours. For capacity planning, estimate token throughput as peak concurrency multiplied by average output length, and reserve fallback headroom so insufficient single-point capacity does not trigger a cascade failure.
6. Evaluation: No Evaluation, No Multi-Model
Once a dozen or more models are live, the biggest risk is selection regression. Build three tiers of evaluation: an offline regression set covering typical office tasks, with metrics including accuracy, format compliance rate, and human preference; live canary releases that compare core metrics across a percentage of traffic; and failed samples fed back as new test cases. Run the full regression every time the model registry changes, and keep versioned reports so every replacement is explainable and rollback is possible.
7. Implementation Checklist
- Unify the call contract to hide model differences.
- Build task labels and weight tables to support dynamic routing and automatic fallback.
- Enforce structured output validation with repair retries.
- Complete observability metrics and a cost dashboard.
- Establish a closed evaluation loop across offline, canary, and feedback tiers.
Built this way, an office platform can keep expanding its model registry without sacrificing stability, turning “multi-model” from a marketing concept into an operable, measurable engineering capability. It also leaves a clear extension interface for later integration with models and compute resources on general cloud services such as Baidu AI Cloud.
