Technical Architecture and Scenario Practices for Mobile AI Assistants

    This article explains how to build a mobile AI assistant with a dual-mode design, covering request routing between fast and deep reasoning, a layered device-cloud architecture, retrieval-augmented web search, multimodal document and image processing, and the performance, cost, security, and evaluation practices needed to operate such a system reliably.

    1. Why Mobile AI Assistants Need Two Modes

    User expectations for an AI assistant on mobile split into clear layers. Some requests need an answer immediately, such as unit conversion, concept explanations, or short text polishing. Others need the model to think before answering, such as multi-step reasoning, option comparison, or long-document summarization. These two request types differ completely in latency budget, compute cost, and the cost of failure, yet they are often served by the same inference configuration. The result is that simple questions consume excessive resources while complex questions suffer from insufficient reasoning depth.

    For this reason, the industry commonly adopts a dual-channel design: a fast mode plus a deep-thinking mode. Fast mode prioritizes time to first token and throughput. It typically uses smaller models that have been distilled or quantized, and it disables unnecessary intermediate reasoning output. Deep-thinking mode allows the model to generate a longer internal reasoning process, combined with multiple rounds of self-checking and tool calls, in exchange for higher accuracy. On the engineering side, a scheduler decides which channel a request takes. The decision can rely on an explicit switch, a question classification model, or heuristic rules based on features such as length, entity density, and whether the input contains tables or code.

    1. def route_mode(query: str, user_hint: str | None = None):
    2. if user_hint in {"fast", "deep"}:
    3. return user_hint
    4. deep_signals = ["compare", "derive", "why", "steps", "table"]
    5. score = sum(s in query for s in deep_signals) + len(query) // 200
    6. return "deep" if score >= 2 else "fast"

    It is worth stressing that switching modes does not mean longer thinking is always better. The extra token cost and waiting time introduced by deep mode are pure loss for chitchat-style requests. The routing strategy should therefore be observable and reversible, and it should record routing accuracy so that thresholds can be iterated later using real traffic.

    2. Overall Architecture: A Layered Device-Cloud Design

    A mature mobile AI assistant is usually divided into four layers. The presentation layer handles session management, streaming rendering, attachment selection, and card-based result display. The access layer handles authentication, rate limiting, content safety, and request orchestration. The capability layer consists of atomic capabilities such as model inference, retrieval augmentation, document parsing, and image text recognition. The data and operations layer carries logs, metrics, evaluation sets, and canary releases.

    The device side does more than display results. A sensible division of labor is: the device handles lightweight preprocessing (image compression and orientation correction, file type detection, initial sensitive-information screening), caching and offline fallback (hitting a local cache for common questions), and interaction-state management (interrupting generation, resampling); the cloud handles high-compute inference, cross-session memory extraction, and batch tasks. Device and cloud exchange incremental results over a streaming protocol to avoid blank screens caused by long waits.

    For capability integration, general cloud components are enough to support the whole pipeline: object storage keeps original attachments and intermediate artifacts, a message queue smooths peaks and decouples long tasks, a container platform hosts inference and parsing services, and logging plus monitoring and alerting provide full-chain tracing and capacity warnings. These are all industry-standard categories, and selection should assume replaceability to avoid tight coupling with a single implementation.

    3. Web Search and Retrieval Augmentation: From Knowing to Evidence

    The value of web access lies not in being able to reach the internet, but in introducing external evidence in a controlled way. The recommended flow is: query rewriting (resolving references, splitting compound questions) → multi-path recall (general search, structured knowledge bases, internal enterprise documents) → reranking and deduplication → evidence trimming (truncating by relevance and freshness) → generation with citations. Every step should retain intermediate results so that when an answer is wrong, it is possible to tell whether recall was missing or generation drifted.

    Three risks must be handled in engineering. The first is freshness conflict, where the same question has both old and new conclusions, requiring weighting by publication time and source authority. The second is prompt injection, since web content may contain text such as “ignore previous instructions”; external content must be strictly labeled as data rather than instructions. The third is privacy leakage: internal documents uploaded by users should not enter the public search path unconditionally, and must be routed to a private knowledge base according to data classification.

    1. {
    2. "query_rewrite": ["mobile AI assistant dual mode latency"],
    3. "evidence": [{"text": "...", "source_type": "public_web", "published_at": "2025-05-01"}],
    4. "policy": {"allow_public_search": true, "pii_masking": "on"}
    5. }

    4. Multimodal Input: Common Practices for Documents and Photo-Based Problem Solving

    Documents and images are the most frequent input forms on mobile. A robust processing pipeline includes: format detection and unpacking, layout analysis (headings, paragraphs, tables, figure captions), reading-order restoration, structured output (Markdown or table objects), and confidence annotation. For tables and formulas, the original two-dimensional structure should be preserved to avoid losing semantics by flattening everything into a single line. For low-confidence regions, the interface should prompt the user to review rather than silently guessing.

    For photo-based problem solving, the key is recognize first, then reason. The recognition stage outputs the problem text and a description of any figures; the reasoning stage gives the solution and its basis step by step; finally a consistency check runs (substitution verification, dimensional analysis, boundary-condition checks). The same flow applies to enterprise tasks such as contract clause comparison and report definition reconciliation, with differences only in prompt templates and validation rules.

    Keep in mind that recognition and parsing quality often affect the final experience more than model choice. Making layout analysis, character recognition, and structured parsing into independently evaluable modules, measured by field-level accuracy rather than an overall impression, is the prerequisite for long-term iteration.

    5. Performance, Cost, and Security: Four Operational Levers

    For performance, monitor four metric groups: time to first token, generation rate, task completion time, and failure rate, and provide progress feedback and cancellation for long tasks. For cost, use mode routing, context trimming, cache reuse, and batching to bring per-request overhead into a reasonable range; building a semantic cache for repeated questions usually gives the most direct cost reduction through its hit rate.

    Security needs to cover three layers: sensitive-information detection and minimal collection on the input side, encryption and key rotation for transport and storage, and content safety plus verifiable citations on the output side. For compliance, provide data retention policies, deletion channels, and audit logs so users know which data is kept and for how long.

    To validate the design above in your own environment, you can assemble a prototype on Baidu AI Cloud from general cloud products: use a container platform to deploy inference and parsing services, object storage for attachments, a message queue for batch document tasks, and logging plus monitoring and alerting to close the observability loop. This keeps components replaceable and makes it easy to turn evaluation sets and canary strategies into long-term assets.

    6. Implementation Advice: From Evaluable to Operable

    First, build a small but realistic evaluation set covering four sample types: simple Q&A, multi-step reasoning, tabular documents, and ambiguous images, with a clear passing bar for each. Second, launch fast mode first and get streaming interaction and the attachment path working, then roll out deep mode gradually while observing the latency-quality tradeoff curve. Third, make retrieval and parsing independent services, each with its own metrics and rollback switch. Fourth, establish an operating mechanism: badcase attribution, prompt and template iteration, and threshold recalibration.

    Overall, the competitiveness of a mobile AI assistant comes from four things: accurate routing, reliable evidence, solid parsing, and controllable operations, rather than stacking up parameters in a single model. Making each stage a measurable, replaceable module is what allows a sustainable balance among cost, experience, and compliance.