Large Model Application Architecture: Technology Choices and Implementation Path
This article breaks down a publicly shared large model application architecture into six layers, from the access layer to infrastructure. It explains the key design decisions at each layer, including state-machine orchestration, batching and fallback in model serving, hybrid retrieval, and observability. It also covers common engineering pitfalls and a four-stage rollout path, giving developers a practical blueprint for building and evolving their own LLM applications.
1. Why an Architecture Diagram Attracts So Much Attention
A diagram describing the overall technical architecture of a large model application was recently shared publicly, sparking broad discussion among developers. On the surface, it is just a layered block diagram. From an engineering perspective, however, it captures a reusable methodology: translating vague product requirements into clear technical boundaries and module contracts.
There are three reasons an architecture diagram tends to be shared more widely than model weights or parameter counts:
- High portability: Models iterate and interfaces change, but the layered approach remains stable. Understanding the architecture means having the freedom to replace any component.
- Low communication cost: An architecture diagram is a common language across product, algorithm, backend, and operations teams, significantly reducing requirement rework.
- High decision value: It directly answers the three questions managers care about most: where the money goes, where the risks are, and where the bottlenecks lie.
The value of public material is not in copying a specific diagram, but in understanding the trade-offs behind it. The sections below abstract the topic into a general large model application architecture and expand on it layer by layer.
2. Overall Layers: A Practical Large Model Application Skeleton
A mature large model application can typically be divided into six layers. Each layer exposes only a stable contract, while its internal implementation can be replaced freely.
- Access layer: Handles multi-client traffic entry, authentication, rate limiting, and protocol conversion.
- Application orchestration layer: Handles session management, task decomposition, tool invocation, and flow control.
- Model serving layer: Handles model inference, batch scheduling, caching, and fallback.
- Knowledge and data layer: Handles document parsing, chunking, vectorization, and retrieval.
- Evaluation and observability layer: Handles quality evaluation, tracing, logging, and alerting.
- Infrastructure layer: Provides common capabilities such as container platforms, object storage, message queues, logging services, and monitoring and alerting.
The key constraint of this layering is that dependencies may only flow top-down; reverse dependencies and cross-layer direct access are prohibited. Once the application layer reads the vector store directly, the system’s testability collapses quickly.
3. Layer-by-Layer Breakdown and Key Design Points
3.1 Access Layer: Keep Instability Outside
The core goal of the access layer is not forwarding, but establishing a stable boundary. It should include at least unified identity verification, per-tenant quota control, request body size limits, timeout and retry policies, and connection management for streaming responses.
For streaming output scenarios, pay special attention to backpressure. When the client consumes more slowly than the server generates, the server must detect this and pause pushing; otherwise, connections and memory will be exhausted quickly.
3.2 Application Orchestration Layer: Break “Intelligence” into Controllable Steps
The orchestration layer is the easiest place to lose control. The recommended engineering approach is to model tasks explicitly as a finite state machine rather than a long chain of conditional checks.
# Example: organizing a multi-step task as a state machine for observability and rollbackclass TaskState:PLAN = "plan" # decompose the goalRETRIEVE = "retrieve" # retrieve knowledgeACT = "act" # call tools or generateVERIFY = "verify" # validate the resultDONE = "done"def run_pipeline(ctx, state):if state == TaskState.PLAN:ctx.plan = planner(ctx.query)return TaskState.RETRIEVEif state == TaskState.RETRIEVE:ctx.docs = retriever.search(ctx.query, top_k=8)return TaskState.ACTif state == TaskState.ACT:ctx.answer = generator(ctx.query, ctx.docs)return TaskState.VERIFYif state == TaskState.VERIFY:if not verifier.check(ctx.answer):return TaskState.RETRIEVE # go back to retrieval if validation failsreturn TaskState.DONEreturn TaskState.DONE
The benefit of a state-based approach is that every step has clear inputs and outputs, so it can be recorded, replayed, and load-tested individually. When a problem occurs, you can pinpoint the exact step rather than vaguely concluding that “the model answered incorrectly.”
3.3 Model Serving Layer: Balancing Throughput, Cost, and Stability
The model serving layer must address four practical problems:
- Batching and queuing: Aggregate scattered requests into batches to improve compute utilization per unit, while setting a queue limit to avoid cascading failures.
- Cache reuse: Cache results for identical requests and cache context for identical prefixes, significantly reducing repeated overhead.
- Tiered fallback: When the primary model is unavailable, automatically switch to a smaller model or a rule-based fallback to prioritize availability.
- Timeout budget allocation: Split the total timeout budget across retrieval, generation, and validation to prevent any single point from consuming all the time.
3.4 Knowledge and Data Layer: Retrieval Quality Sets the Ceiling
Practice shows that poor application performance often stems from the data side rather than the model side. The recommended pipeline is: parsing, cleaning, structured chunking, vectorization, index building, recall, and reranking.
Raw documents -> format parsing -> semantic chunking (by heading hierarchy)-> vectorization -> vector index + keyword index-> hybrid recall -> rerank -> context assembly
The key point is hybrid recall: pure vector retrieval excels at semantic similarity, while keyword retrieval excels at proper nouns and identifiers, so the two complement each other. During chunking, preserve metadata such as section paths to support traceability and permission filtering.
3.5 Evaluation and Observability Layer: No Measurement, No Improvement
Evaluation should cover three types of metrics: retrieval hit rate, answer correctness and citation consistency, and latency and cost. In engineering, this can be implemented through a combination of an offline evaluation set, online sampling with manual review, and automated regression.
For observability, standardize a unified trace specification that links retrieval, generation, and tool invocation for a single request into one trace. Combined with logging services and monitoring and alerting, this enables minute-level problem localization.
4. Common Engineering Pitfalls and How to Avoid Them
- Writing orchestration logic into prompts: Prompts are hard to version and roll back; flows should be externalized as code.
- Ignoring permissions and data isolation: Knowledge bases must support per-user filtering that takes effect during retrieval, not trimming after generation.
- Optimizing only the model, not retrieval: In most scenarios, gains come from recall and reranking rather than switching to a larger model.
- Lacking cost guardrails: Set per-request token limits, daily quotas, and anomaly usage alerts.
- Launching without an evaluation set: Without a baseline, no “optimization” can be falsified.
5. Recommended Implementation Path
In the first stage, establish a minimal closed loop: access layer + orchestration layer + a single model service + basic logging, and get end-to-end flow working. In the second stage, add knowledge and evaluation: define chunking standards, hybrid retrieval, and an offline evaluation set. In the third stage, strengthen stability and cost governance: introduce caching, fallback, quotas, and full-link tracing. In the fourth stage, build platform-level capabilities: package reusable capabilities into internal standard components for multiple business lines to integrate.
6. Conclusion
The value of an architecture diagram lies not in how well it is drawn, but in whether it breaks a complex problem into smaller problems that can evolve independently. For developers, the four principles to master are layered contracts, state-based orchestration, retrieval first, and measurability. With common infrastructure capabilities such as container platforms, object storage, message queues, logging services, and monitoring and alerting, teams on Baidu AI Cloud can quickly build and continuously evolve their own large model application architecture along the path above, focusing their attention on business value itself.
