On-Device Conversational AI Architecture and Practices in Financial Services

    This article explains how to build on-device conversational AI for mobile financial applications under strict regulatory constraints. It covers why embedded web views fall short, the core capabilities of context-aware perception, controlled UI generation, and secure execution, along with a layered reference architecture, compliance and risk governance, a phased implementation path, and recommended metrics. The goal is to keep perception, generation, and execution inside controllable boundaries rather than simply making the assistant more talkative.

    1. Background: From Answering Questions to Completing Tasks

    The adoption of generative AI in consumer applications is shifting the center of interaction from retrieval-style Q&A to task-style execution. Users are no longer satisfied with an explanatory block of text; they expect the system to understand intent, invoke capabilities, and produce a confirmable operational result. In heavily regulated, high-sensitivity business scenarios, this shift creates three pressures: responses must be fast enough, data boundaries must be clear, and the execution process must be auditable.

    At the same time, the maturing of on-device compute and small on-device models makes it possible to push part of the inference and orchestration down to the device itself. This creates an engineering problem: how to build a conversational AI infrastructure deeply integrated into mobile devices that can both perceive context and safely generate interfaces and execute controlled actions.

    2. Why Embedded Web Views Fall Short in Regulated Scenarios

    Many teams initially embed a web view container in the app to host the conversational interface, but structural weaknesses quickly appear.

    • Limited rendering and streaming output: streaming text depends on script-layer rendering, so first-screen and incremental update latency is high, frame rate is unstable when scrolling long text, and the experience feels disconnected from native pages.
    • Missing context signals: the web layer struggles to compliantly and reliably obtain implicit intent signals such as device location, calendar events, and motion state, so understanding stays at the literal level.
    • Limited access to local capabilities: capabilities such as notifications, biometric authentication, and payment confirmation need controlled exposure, and the web layer’s security boundary and permission model do not match.
    • Uncontrollable data path: all content is relayed through the cloud, making it hard to meet data minimization, residency, and audit requirements.

    It is worth stressing that the comparison above should not be treated as a universal conclusion based on specific numbers. The more robust engineering practice is to establish your own baseline on target device models and under target network conditions, using the same task set to measure first-response latency, streaming output frame rate, context hit rate, and task completion rate.

    3. Target Capabilities: Perceive, Generate, Execute

    3.1 Multimodal Intent Understanding: Fusing Explicit Semantics with Implicit Context

    Explicit semantics is what the user says; implicit context is the signal that can be compliantly obtained on the device. Only by fusing the two can you form a usable intent judgment. Example code:

    1. // Pseudocode: structure illustration only, not a specific platform API
    2. data class DialogueContext(
    3. val utterance: String,
    4. val timeHint: TimeHint?, // near a recurring investment date or bill date
    5. val locationHint: GeoHint?, // near a branch (requires authorization)
    6. val behaviorHint: ActionHint? // recent behavior such as using calculators
    7. )
    8. fun buildPrompt(ctx: DialogueContext): Prompt {
    9. return Prompt(
    10. system = "You are a financial assistant under strict permission constraints and must not act beyond your authority.",
    11. user = ctx.utterance,
    12. context = ctx.toStructuredSignals()
    13. )
    14. }

    The key is the principle of “minimum necessary”: collect only signals directly relevant to the current task, and set an independent authorization and expiration policy for each type of signal.

    3.2 Dynamic UI Generation: Controlled Structured Output

    If a conversational system is to “generate interfaces,” it should avoid letting the model directly produce executable code or arbitrary markup. Instead, it should output constrained structured descriptions that a client-side renderer maps to native components. The benefits are that the output is verifiable, rollback-able, and adaptable for accessibility.

    1. {
    2. "type": "Card",
    3. "title": "Transaction Confirmation",
    4. "fields": [{"key": "ratio", "label": "Target Allocation", "value": "50%"}],
    5. "actions": [
    6. {"id": "modify", "label": "Modify"},
    7. {"id": "confirm", "label": "Confirm Execution", "requiresAuth": true}
    8. ]
    9. }

    In engineering terms, you should establish schema validation and a whitelist component library. Any structure that fails validation is uniformly downgraded to a plain-text prompt to avoid UI injection risk.

    3.3 Secure Execution: Capability Gateway and Human Confirmation

    The execution layer should be consolidated into a “capability gateway” that handles identity verification, quota and rate limits, secondary confirmation, idempotency control, and audit logging. High-risk actions require biometric authentication or passphrase confirmation, with least privilege by default, on-demand authorization, and immediate revocation after use.

    4. Reference Architecture Layers

    • Interaction layer: native conversational interface, streaming rendering, accessibility, and multilingual support.
    • Orchestration layer: intent parsing, task planning, context assembly, and policy routing (on-device first, cloud fallback).
    • Capability layer: capability gateway, permission center, risk control rules, idempotency, and retries.
    • Data layer: local cache, object storage, message queues, logging services, and monitoring and alerting.
    • Governance layer: model version management, prompt and policy canary rollout, evaluation set regression, and audit and compliance reporting.

    For deployment, you can use a container platform to host stateless orchestration services, use message queues to smooth peaks and decouple long-running tasks, and use logging and monitoring systems to build end-to-end tracing.

    5. Compliance and Risk Governance

    • Data minimization and purpose limitation: bind each type of data to a clear purpose and retention period.
    • Explainability and traceability: record the linkage of “input summary—policy version—model version—execution result,” with sensitive fields masked.
    • Hallucination suppression: for factual content such as numbers, rates, and holdings, the business system’s return is the single source of truth, and the model must not fill in on its own.
    • Fallback and degradation: when the model is unavailable or validation fails, switch to a deterministic flow or a human agent.
    • Evaluation loop: build a regression evaluation set covering intent recognition, slot extraction, execution success rate, and unauthorized-action interception rate.

    6. Implementation Path and Metrics

    The first phase builds a “read-only assistant” covering queries and explanations, validating intent understanding and rendering performance. The second phase introduces controlled write operations, first opening confirmation-style execution on low-risk actions. The third phase delivers proactive services, such as reminders as a recurring investment date approaches and analysis of the impact of holding fluctuations, while strictly limiting push frequency and quiet hours.

    The metrics system should include first-response latency, streaming rendering frame rate, task completion rate, unauthorized-action interception rate, human takeover rate, cost per task, and compliance audit pass rate. All metrics should be collected on real device models and real networks to form a baseline that supports continuous comparison.

    7. Conclusion

    The value of on-device conversational AI lies not in being “better at chatting” but in bringing perception, generation, and execution within controllable boundaries. In heavily regulated scenarios, architectural consolidation and governance determine success more than model capability itself. If an enterprise wants to validate the layered design above in its own cloud environment, it can combine general-purpose capabilities such as the container platform, message queues, object storage, and monitoring and alerting offered by Baidu AI Cloud to build an evaluation and canary environment, first forming a reusable engineering baseline in low-risk scenarios.