Technical Architecture and Engineering Practices for Mobile AI Search
This article breaks down the technical architecture and engineering practices behind mobile AI search, covering a four-layer design, retrieval-augmented generation, deep thinking controls, mobile performance optimization, security and cost management, and evaluation. It focuses on reusable engineering patterns rather than any specific product, showing how retrieval quality, context governance, latency control, and evaluation loops matter more than the choice of model.
1. Background: Why Mobile AI Search Is More Than an Input Box
The industry trend of the past two years is clear: the traditional browser paradigm centered on “keywords → link lists” is being supplemented by a paradigm of “natural-language question → structured answer → traceable sources.” Questions on mobile tend to be longer, more conversational, and to carry implicit constraints such as time, location, version, and device model. Relying on keyword recall alone often causes noticeable semantic drift.
A widely adopted technical approach has emerged: deeply integrate large language model capabilities into the mobile browser, and from a certain point onward offer a full-featured model service that supports “deep thinking” and “web search,” presented to users as an AI search entry point. It is worth emphasizing that such capabilities are not unique to any single vendor but are a common industry solution. This article discusses only the general engineering implementation and does not evaluate any specific product.
From an engineering perspective, the difficulties concentrate in four areas:
- Resource constraints on the device: memory, CPU, battery, and network jitter all amplify end-to-end latency.
- Answer trustworthiness: models may generate plausible but unsupported content, so retrieval augmentation and source constraints are required.
- Streaming experience: time to first token (TTFT) affects perceived experience more than total duration.
- Operability: evaluation sets, canary releases, monitoring, and cost control are needed rather than a one-time launch.
2. Overall Architecture: Four Decoupled Layers
It is recommended to split the pipeline into four layers that communicate through explicit contracts, making them easier to evolve and load-test independently.
- Access layer: session management, authentication, rate limiting, parameter validation, and protocol negotiation.
- Orchestration layer: intent recognition, query rewriting, retrieval planning, tool invocation, and context assembly.
- Capability layer: model inference, vector retrieval, keyword retrieval, ranking, summarization, and safety filtering.
- Presentation layer: streaming output, incremental rendering, citation markers, follow-up suggestions, and offline fallback.
The key design principle is to decouple retrieval from generation. The generation side consumes only a standardized context package, while the retrieval side can swap implementations (self-built index, third-party search service, or an enterprise internal knowledge base), avoiding tight coupling between the model and any single data source.
User question-> Access layer (auth / rate limiting)-> Intent classification (factual / operational / chitchat)-> Query rewriting (fill in omissions, split sub-questions)-> Hybrid retrieval (vector + keyword + freshness filtering)-> Reranking and deduplication-> Context assembly (with source IDs)-> Model inference (optional deep thinking)-> Safety filtering and citation validation-> Streaming rendering
3. Web Search: Key Details of Retrieval-Augmented Generation
The engineering essence of “web search” is to inject external real-time information into the model context through retrieval-augmented generation (RAG). What truly determines quality is often not the model but retrieval quality.
1. Query Rewriting Before Parameter Tuning
Mobile questions often contain omissions and references, for example “what about its previous generation?” It is advisable to run a lightweight rewriting pass first: fill in entities, split compound questions, and generate 2 to 4 synonymous queries. A schematic logic can be expressed as:
def rewrite(query, history):# 1) Coreference resolution: fill in entities using session historyq = coreference_resolve(query, history)# 2) Sub-question splitting: break compound questions into independently retrievable sub-queriessubs = split_multi_intent(q)# 3) Synonym expansion: limit the count to avoid amplifying retrieval noisereturn [q] + subs[:3]
2. Hybrid Retrieval and Freshness
Pure vector retrieval is good at semantic similarity, while pure keyword retrieval is good at exact matching (model numbers, error codes, proper nouns). In engineering, hybrid recall followed by unified ranking is commonly used. For freshness-sensitive questions, a publish-time field must be introduced on the index side with time decay applied; otherwise outdated conclusions may be returned as facts.
3. Context Budget and Compression
The context window is a scarce resource. It is recommended to set a hard budget (for example, 70% of the total length for retrieved snippets) and apply three-step compression: deduplication, relevance-based truncation, and extractive compression. Every snippet must carry a source identifier for subsequent citation validation.
4. Citation Consistency Validation
After generation, compare the key assertions in the answer against the retrieved snippets for consistency. Sentences that cannot be aligned should either be down-weighted or labeled “no reliable source found.” This is one of the most cost-effective ways to suppress hallucination.
4. Deep Thinking: Turning “Thinking It Through” into Controllable Cost
“Deep thinking” usually refers to a model performing multi-step reasoning before giving an answer. Its value lies in complex problems (multi-constraint comparison, conditional reasoning, trade-off analysis), at the cost of increased latency and compute. Engineering recommendations:
- Route rather than enable everything: use a lightweight classifier to judge problem complexity and enable deep thinking only for complex problems.
- Budget caps: limit reasoning steps or thinking length to avoid long-tail requests dragging down overall latency.
- Invisible process, verifiable conclusion: the thinking process is not displayed by default, but intermediate conclusions are retained for citation validation and debugging.
- Failure fallback: on timeout, fall back to normal mode and give a concise answer, prioritizing availability.
{"mode": "deep | fast","complexity": 0.0,"max_steps": 3,"context_budget": 6000,"fallback": "fast"}
5. Mobile Performance and Experience Optimization
- First token first: use streaming transmission, output the conclusion skeleton first and then fill in details, significantly improving perceived latency.
- Prefetching and caching: build result caches and retrieval-snippet caches for high-frequency questions, with freshness-based expiration policies.
- Device-cloud collaboration: lightweight tasks (rewriting, classification, formatting) can be pushed down to small on-device models to reduce round trips.
- Weak-network strategy: request chunking, timeout retries, and local fallback answers to avoid blank screens.
- Rendering throttling: merge incremental text and render by frame to reduce layout jitter and battery consumption.
6. Security, Compliance, and Cost Control
- Two-way filtering of input and output: sensitive information detection, unauthorized content blocking, and prompt injection protection (treat retrieved content as untrusted data and forbid it from carrying instructions).
- Least privilege: filter on the retrieval side according to the user’s visible scope to avoid bringing unauthorized documents into the context.
- Cost control: invoke model sizes by complexity tier; cache hit rate and average context length are core cost metrics.
- Observability: instrumentation covering TTFT, total latency, retrieval hit rate, citation coverage, and fallback rate.
7. Evaluation System: No Evaluation Set, No Iteration
It is recommended to build three layers of evaluation:
- Retrieval layer: recall, hit rate, and freshness accuracy.
- Generation layer: factual consistency, citation coverage, and answer completeness.
- Experience layer: TTFT percentiles, task completion rate, and follow-up rate.
Launches use canary releases and controlled experiments, with automatic rollback when core metrics fall below target. If an enterprise already has relevant general capabilities from Baidu AI Cloud (such as object storage, message queues, container platforms, log services, and monitoring and alerting), they can be used to support index construction, asynchronous tasks, elastic inference, and full-link observability, but interface abstraction should be maintained to avoid coupling business logic to a single implementation.
8. Implementation Checklist
- Define the boundaries of AI search: which questions go through retrieval, which go through the model, and which are directly refused.
- Build the evaluation set first, then optimize, avoiding tuning by intuition.
- Retrieval quality takes priority over model size; rewriting and reranking offer the highest return on investment.
- Streaming and fallback are baseline capabilities for the mobile experience.
- Verifiable citations are the foundation of long-term trust.
In summary, the core competitiveness of mobile AI search lies not in “which model is integrated” but in the engineering system formed by retrieval quality, context governance, latency control, and an evaluation loop. Once this system is solid, replacing and upgrading capabilities is just a configuration matter.
