Building a Read-Only AI Assistant for Personal Finance Analysis: A Technical Practice

    This article explains how to connect an AI assistant to personal financial data in a read-only manner, covering authorization, data access, natural language querying, anomaly detection, visualization, and security. It details a four-layer architecture, least-privilege account binding, separating computation from language generation, and audit requirements, showing how to deliver accurate, explainable, and verifiable financial answers. It also outlines an optional implementation approach on Baidu AI Cloud.

    1. Background: From Q&A to an Auditable Personal Finance Assistant

    A new category of intelligent assistant has emerged recently. Instead of only handling general questions, these assistants can read personal financial data after user authorization and answer questions that require precise calculation, such as “Where did my money go this month?”, “Are there any duplicate charges?”, and “How much interest was charged in total?” The core capability here is not making the model better at conversation. It is connecting a natural language interface to a rigorous data querying and calculation pipeline.

    From a technical perspective, this requirement can be broken down into four subproblems:

    1. Identity and authorization: How to let users securely connect external accounts and define clear authorization boundaries.
    2. Data access: How to retrieve structured data such as balances and transaction records with minimal permissions.
    3. Natural language to query: How to reliably translate natural language into executable queries and statistical logic.
    4. Result trustworthiness: How to make outputs explainable, traceable, and verifiable.

    It is worth emphasizing that the compliant and common approach is to grant read-only access only. The assistant cannot transfer money, initiate automatic deductions, place investment orders on the user’s behalf, or operate credit card, loan, or savings businesses. The absence of a financial interest is the precondition for these “objective and direct” answers to hold.

    2. Overall Architecture: A Four-Layer Decoupled Design

    The system should be split into four layers to avoid exposing the model directly to sensitive data.

    • Access layer: Handles account binding, authorization state management, and token lifecycle.
    • Data layer: Connects to external financial data interfaces in read-only mode and stores a standardized transaction model.
    • Semantic layer: Handles intent recognition, terminology explanation, query orchestration, and slot filling.
    • Presentation layer: Provides charts, bill calendars, customizable dashboards, and drill-down to details.

    An illustrative read-only query orchestration (pseudocode):

    1. def answer(question: str, user_id: str):
    2. intent = parse_intent(question) # expense summary / unusual bill / interest calculation...
    3. slots = fill_slots(intent, question) # time range, account set, category
    4. plan = build_readonly_plan(intent, slots)
    5. assert plan.mutating is False # hard block on any write operation
    6. rows = readonly_gateway.query(user_id, plan)
    7. return render(intent, rows) # chart + conclusion + detail entry

    The key point is a hard constraint like assert plan.mutating is False. Write operations should not rely on prompt constraints. They should be blocked directly at the gateway layer using a capability allowlist.

    3. Account Binding and Least Privilege

    The binding flow should follow the industry-standard authorization code pattern. The user is redirected to the data provider to complete authentication, and the platform only obtains a short-lived access token and a read-only scope identifier, never touching the account password. The engineering implementation needs to ensure:

    • Tokens are stored encrypted, rotated periodically, and support one-click unbinding and immediate revocation.
    • Scope validation is performed on the server side, and the frontend cannot pass arbitrary permission bits.
    • Transmission and at-rest encryption cover the full chain, and sensitive fields are masked before entering the model context.
    • Only the fields needed for statistics (amount, time, merchant, category) are provided to the model, avoiding leakage of the full transaction history.

    Data minimization is not only a compliance requirement. It also directly reduces the attack surface for prompt injection and unauthorized inference.

    4. Natural Language to Statistics: Do Not Let the Model Do the Math

    Large models are not good at precise arithmetic. The correct approach is “the model only orchestrates, and the calculation is handled by the engine.”

    • Terminology explanation questions (such as the meaning of annual interest rate) are answered by the model in natural language.
    • Aggregation, grouping, and year-over-year or month-over-month comparisons are handled by the query engine or calculation service.
    • Time semantics need to be normalized into explicit ranges. For example, “this month” is resolved to natural month boundaries.
    1. {
    2. "intent": "expense_summary",
    3. "range": {"start": "2024-05-01", "end": "2024-05-31"},
    4. "group_by": "category",
    5. "accounts": "all_bound_readonly"
    6. }

    The system should also support “listing the transaction details behind a conclusion,” so that every number can be drilled down to the original record. This is the minimum standard for explainability.

    5. Unusual Bill Detection: Rules First, Model as Supplement

    Duplicate charges, unexpected fees, and subscription bills that quietly increase over a year are essentially anomaly detection problems. A combination of rules and statistics is appropriate:

    1. Deterministic rules: The same merchant and same amount appearing multiple times within a short window; a fixed-cycle deduction amount changing.
    2. Statistical methods: Using quantiles or robust z-scores based on historical distributions to identify outlier transactions.
    3. Model role: Translating matched items into plain language and sorting them by impact amount, rather than “discovering” anomalies on its own.

    All prompts should include the basis for the judgment and a confidence hint, and clearly state that “important amounts should be verified with the bank.”

    6. Visualization and Custom Dashboards

    The presentation layer should support three types of components: time-series expense charts, upcoming bill calendars, and configurable metric cards. Dashboard definitions are described using declarative configuration, making them easy to adjust and persist at any time:

    1. dashboard:
    2. range: last_month
    3. widgets:
    4. - type: line_chart
    5. metric: expense_by_category
    6. - type: calendar
    7. metric: upcoming_bills
    8. - type: kpi
    9. metric: expense_vs_income

    7. Security, Privacy, and Result Verification Checklist

    • Permissions: Read-only allowlist, with write interfaces unreachable at the gateway layer.
    • Privacy: Field-level minimization, masking, retention periods, and deletion mechanisms.
    • Audit: Each query records the intent, scope, and result summary for traceability.
    • No ads or sponsored ranking: Conclusions must not be influenced by commercial recommendations.
    • Fault tolerance: Clearly state that results may be incorrect, and provide a path for detail verification and manual review.

    8. Conclusion

    Connecting an intelligent assistant to personal finance is not difficult in terms of “answering questions.” The engineering challenge lies in answering accurately, safely, and verifiably. Read-only permissions, separation of computation and generation, data minimization, and full auditing are the four bottom lines for delivering this type of capability. To implement it on Baidu AI Cloud, you can use object storage to store masked reports, a message queue for peak shaving, and a container platform to host query services, along with logging services and monitoring alerts for auditing and stability assurance.