Financial data query method and device, computer equipment and readable storage medium
By identifying user intent and objects, and combining the BERT model with a financial SQL template library to generate accurate SQL statements, the problem of low query accuracy in existing systems has been solved, achieving efficient and secure financial data querying.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-25
- Publication Date
- 2026-04-07
AI Technical Summary
Existing wealth analysis and planning systems have low accuracy and cannot effectively meet users' diverse query needs.
By acquiring users' financial data query requests, the system uses BERT classification and BERT-NER models to identify query intent and objects. Combined with a financial SQL template library and a pre-set SQL statement generation model, it generates accurate financial SQL statements and performs syntax, semantic, security, and permission checks to optimize query performance.
It improves the accuracy and efficiency of financial data queries, ensures that the generated SQL statements comply with business rules and system compatibility, and enhances the legality and speed of queries.
Smart Images

Figure CN121807875A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a financial data query method and device, computer equipment, computer readable storage medium and computer program product. BACKGROUND
[0002] At present, the wealth analysis planning system commonly used by banks and financial institutions is mainly based on the traditional information system architecture. As for the data query scheme, the existing system involves a fixed query interface for each query requirement in advance, which contains specific query condition fields.
[0003] However, the current traditional query method has the problem of low query accuracy. SUMMARY
[0004] Therefore, it is necessary to provide a financial data query method, device, computer equipment, computer readable storage medium and computer program product capable of improving query accuracy in view of the above technical problems.
[0005] In a first aspect, the present application provides a financial data query method, comprising:
[0006] obtaining a user input financial data query request, and obtaining a user's financial query intention, a financial query object, a target underlying financial data table and a historical financial SQL template according to the financial data query request;
[0007] obtaining a financial SQL statement corresponding to the financial data query request based on the financial query intention, the financial query object, the target underlying financial data table, the historical financial SQL template, and a pre-set SQL statement generation model for the financial field;
[0008] querying a pre-constructed financial database according to the financial SQL statement to obtain financial data corresponding to the financial data query request.
[0009] In an embodiment, obtaining a user's financial query intention, a financial query object, a target underlying financial data table and a historical financial SQL template according to the financial data query request comprises:
[0010] cleaning and standardizing the financial data query request to obtain a financial query text;
[0011] inputting the financial query text into a BERT classification model and a BERT-NER model respectively, obtaining a financial query intention through the BERT classification model, and obtaining a financial query object through the BERT-NER model;
[0012] obtaining a target underlying financial data table from an underlying financial data table library according to the financial query text;
[0013] Retrieving the historical financial SQL template similar to the financial query text in the financial SQL template library based on the financial query text.
[0014] In one of the embodiments, the target underlying financial data table is obtained from the underlying financial data table library according to the financial query text, including:
[0015] Converting the financial query text into a high-dimensional vector;
[0016] Obtaining the vector similarity between the high-dimensional vector and the underlying financial data table in the underlying financial data table library;
[0017] According to each vector similarity, each underlying financial data table is sorted from high to low;
[0018] The underlying financial data table with a sorting sequence number greater than or equal to a preset sorting sequence number threshold is determined as the target underlying financial data table.
[0019] In an exemplary embodiment, based on the financial query intent, the financial query object, the target underlying financial data table, the historical financial SQL template, and the SQL statement generation model preset for the financial field, the financial SQL statement corresponding to the financial data query request is obtained, including:
[0020] According to the financial query object, the corresponding financial business rule is obtained;
[0021] Based on the financial query intent, the financial query object, the financial business rule, the target underlying financial data table, and the historical financial SQL template, a financial SQL statement prompt context is constructed;
[0022] The financial SQL statement prompt context is input into the SQL statement generation model to obtain the financial SQL statement corresponding to the financial data query request.
[0023] In one embodiment, the financial SQL statement prompt context is input into the SQL statement generation model to obtain the financial SQL statement corresponding to the financial data query request, including:
[0024] The financial SQL statement prompt context is input into the SQL statement generation model to obtain the original financial SQL statement corresponding to the financial data query request;
[0025] The original financial SQL statement is subjected to syntax verification, semantic verification, security verification, and permission verification;
[0026] In the case where all the verifications are passed, the original financial SQL statement is subjected to performance optimization through index optimization, JOIN order rearrangement, projection clipping, and LIMT restriction to obtain the financial SQL statement.
[0027] In one embodiment, the method further includes:
[0028] If any validation fails, the original financial SQL statement will be automatically repaired.
[0029] In the event of automatic repair failure, the error information of the original financial SQL statement is returned to the SQL statement generation model to obtain a new original financial SQL statement. Then, the model performs syntax verification, semantic verification, security verification, and permission verification on the original financial SQL statement until the number of times the SQL statement generation model generates the statement reaches a preset threshold or all verifications of the new original financial SQL statement pass. If any verification fails, the error type corresponding to the new original financial SQL statement is sent to the user terminal.
[0030] In one exemplary embodiment, the financial database is constructed through the following steps:
[0031] Obtain multi-source heterogeneous unstructured financial documents provided by users;
[0032] Deep learning OCR technology is used to identify multi-source heterogeneous unstructured financial documents and obtain the corresponding financial text of the multi-source heterogeneous unstructured financial documents;
[0033] By using layout analysis models and large models, financial texts are classified, analyzed in terms of layout, and extracted from objects to obtain the corresponding financial structured data.
[0034] A financial database is constructed based on various structured financial data.
[0035] Secondly, this application also provides a financial data query device, comprising:
[0036] The acquisition module is used to acquire the financial data query request input by the user, and obtain the user's financial query intent, financial query object, target underlying financial data table and historical financial SQL template based on the financial data query request;
[0037] The statement acquisition module is used to obtain the financial SQL statement corresponding to the financial data query request based on the financial query intent, financial query object, target underlying financial data table, historical financial SQL template, and SQL statement generation model pre-set for the financial field.
[0038] The query module is used to query a pre-built financial database based on financial SQL statements to obtain the financial data corresponding to the financial data query request.
[0039] In a third aspect, the present application also provides a computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program:
[0040] obtaining a financial data query request input by a user, and obtaining a financial query intention, a financial query object, a target underlying financial data table and a historical financial SQL template of the user according to the financial data query request;
[0041] obtaining a financial SQL statement corresponding to the financial data query request based on the financial query intention, the financial query object, the target underlying financial data table, the historical financial SQL template and a pre-set SQL statement generation model for the financial field;
[0042] querying a pre-constructed financial database according to the financial SQL statement to obtain financial data corresponding to the financial data query request.
[0043] In a fourth aspect, the present application also provides a computer readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the following steps:
[0044] obtaining a financial data query request input by a user, and obtaining a financial query intention, a financial query object, a target underlying financial data table and a historical financial SQL template of the user according to the financial data query request;
[0045] obtaining a financial SQL statement corresponding to the financial data query request based on the financial query intention, the financial query object, the target underlying financial data table, the historical financial SQL template and a pre-set SQL statement generation model for the financial field;
[0046] querying a pre-constructed financial database according to the financial SQL statement to obtain financial data corresponding to the financial data query request.
[0047] In a fifth aspect, the present application also provides a computer program product comprising a computer program, the computer program being executed by a processor to implement the following steps:
[0048] obtaining a financial data query request input by a user, and obtaining a financial query intention, a financial query object, a target underlying financial data table and a historical financial SQL template of the user according to the financial data query request;
[0049] obtaining a financial SQL statement corresponding to the financial data query request based on the financial query intention, the financial query object, the target underlying financial data table, the historical financial SQL template and a pre-set SQL statement generation model for the financial field;
[0050] According to the financial SQL statement, the pre-constructed financial database is queried, and financial data corresponding to the financial data query request is obtained.
[0051] The financial data query method, device, computer device, computer readable storage medium and computer program product, by obtaining the financial data query request input by the user, obtaining the financial data query request input by the user, and obtaining the financial query intention, the financial query object, the target underlying financial data table and the historical financial SQL template of the user according to the financial data query request, based on the financial query intention, the financial query object, the target underlying financial data table, the historical financial SQL template, and the SQL statement generation model pre-set for the financial field, the financial SQL statement corresponding to the financial data query request is obtained, the pre-constructed financial database is queried according to the financial SQL statement, and the financial data corresponding to the financial data query request is obtained. In the case of receiving the financial data query request of the user, the financial query intention, the financial query object, the target underlying financial data table and the historical financial SQL template are obtained according to the financial data query request, and the corresponding financial SQL statement is generated according to the obtained data and the SQL statement generation model pre-set for the financial field. According to the financial SQL statement, the corresponding query is executed, and by performing intention analysis and obtaining historical templates, the accuracy of the generated financial SQL statement is improved, and the query accuracy of the financial data is improved. BRIEF DESCRIPTION OF DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other related drawings can also be obtained without creative labor.
[0053] Figure 1 The application environment diagram of the financial data query method in one embodiment;
[0054] Figure 2 The flowchart of the financial data query method in one embodiment;
[0055] Figure 3 The overall architecture diagram of the full-process data processing system based on OCR, customer service intelligent agent and intelligent query in one embodiment;
[0056] Figure 4 The 6-layer architecture of the intelligent wealth analysis and planning system in one embodiment and the calling relationship between the layers;
[0057] Figure 5This is a schematic diagram of multimodal feature fusion for document classification in one embodiment;
[0058] Figure 6 This is a sequence diagram of a 3-table JOIN + aggregation + filtering text2sql example.
[0059] Figure 7 This is a structural block diagram of a financial data query device in one embodiment;
[0060] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0062] The financial data query method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, user terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Server 104 obtains the financial data query request input by the user on user terminal 102, and based on the financial data query request, obtains the user's financial query intent, financial query object, target underlying financial data table, and historical financial SQL template. Based on the financial query intent, financial query object, target underlying financial data table, historical financial SQL template, and a pre-set SQL statement generation model for the financial field, it obtains the financial SQL statement corresponding to the financial data query request. It then queries a pre-built financial database based on the financial SQL statement to obtain the financial data corresponding to the financial data query request. User terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Headset devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0063] In one exemplary embodiment, such as Figure 2As shown, a financial data query method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps S201 to S203. Wherein:
[0064] Step S201: Obtain the financial data query request input by the user, and obtain the user's financial query intent, financial query object, target underlying financial data table, and historical financial SQL template based on the financial data query request.
[0065] Among them, financial query intent can be understood as the motivation, purpose or business scenario behind the result or answer that a user hopes to obtain when initiating a query; financial query object can be understood as the specific data entity or data set that is focused, retrieved and analyzed in the query; target underlying financial data table can be understood as the specific financial data table most relevant to the financial query request; and historical financial SQL template can be understood as the financial SQL statement generated in the past.
[0066] For example, server 104 obtains the financial data query request entered by the user on user terminal 102, identifies the financial query intent of the financial data query request and extracts the financial query object of the financial query request, obtains the target financial data table related to it from the underlying financial data table database according to the financial data query request, and retrieves historical SQL templates similar to the financial data query request from the SQL template database.
[0067] Step S202: Based on the financial query intent, the financial query object, the target underlying financial data table, the historical financial SQL template, and the SQL statement generation model pre-set for the financial field, obtain the financial SQL statement corresponding to the financial data query request.
[0068] Among them, the SQL statement generation model can be understood as a model that integrates and analyzes input text, which can include large language models. Financial SQL statements can be understood as a set of structured query language statements used to query, aggregate, and analyze financial-related data from financial data systems.
[0069] Optionally, server 104 inserts the determined financial query object into the corresponding financial business rule, and then generates a financial SQL statement prompt context based on the financial query intent, financial query object, financial business rule, target underlying financial data table and historical financial SQL template. The financial SQL statement prompt context is then input into a pre-set SQL statement generation model for the financial field to obtain the financial SQL statement corresponding to the financial data query request.
[0070] Step S203: Query the pre-built financial database according to the financial SQL statement to obtain the financial data corresponding to the financial data query request.
[0071] For example, server 104 queries a pre-built financial database based on a financial SQL statement to obtain the financial data corresponding to the financial data query request. It performs dynamic desensitization based on the data sensitivity level and combines data formatting strategies to improve the readability of the financial data. The intelligent display engine dynamically adapts the display format according to the query characteristics and sends the adjusted financial data to user terminal 102 for display.
[0072] In the aforementioned financial data query method, the user's input financial data query request is obtained. Based on this request, the user's query intent, query object, target underlying financial data table, and historical financial SQL templates are acquired. Using this query intent, query object, target underlying financial data table, historical financial SQL templates, and a pre-defined SQL statement generation model specific to the financial field, a corresponding financial SQL statement is generated. This financial SQL statement is then used to query a pre-built financial database to obtain the corresponding financial data. Upon receiving a user's financial data query request, the system obtains the query intent, query object, target underlying financial data table, and historical financial SQL templates. Based on this data and the pre-defined SQL statement generation model, a corresponding financial SQL statement is generated. The query is then executed. By analyzing the execution intent and retrieving historical templates, the accuracy of the generated financial SQL statement is improved, thereby enhancing the accuracy of financial data queries.
[0073] In one embodiment, obtaining a user's financial query intent, financial query object, target underlying financial data table, and historical financial SQL template based on a financial data query request includes: cleaning and standardizing the financial data query request to obtain financial query text; inputting the financial query text into a BERT classification model and a BERT-NER model respectively, obtaining the financial query intent through the BERT classification model and the financial query object through the BERT-NER model; obtaining the target underlying financial data table from the underlying financial data table database based on the financial query text; and searching the financial SQL template database based on the financial query text to obtain historical financial SQL templates similar to the financial query text.
[0074] Among them, BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language model based on Transformers, which is good at capturing contextual information; the BERT-NER model can be understood as a model that identifies entities in text and labels them with categories based on the BERT model.
[0075] Optionally, server 104 cleans and standardizes the financial data query request to obtain financial query text. The financial query text is then input into the BERT classification model and the BERT-NER model. The BERT classification model outputs candidate financial query intents corresponding to the financial query text, and the candidate financial query intent with the highest confidence score is taken as the financial query intent. The BERT-NER model outputs candidate financial query objects corresponding to the financial query text, and the candidate financial query object with the highest confidence score is taken as the financial query object. Based on the financial query text, the underlying financial data table database is queried to obtain the target underlying financial data table most relevant to the financial query text. Based on the financial query text, a search is performed in the financial SQL template database to obtain historical financial SQL templates similar to the financial query text.
[0076] Based on the above implementation methods, the "intent + entity" dual-insurance design greatly enhances the model's ability to understand complex, concise, or ambiguous natural language queries. The "retrieval + matching" mode accelerates the determination of relevant data, thereby speeding up the generation of financial SQL statements and improving the speed of financial data query.
[0077] In one embodiment, obtaining the target underlying financial data table from the underlying financial data table database based on the financial query text includes: converting the financial query text into a high-dimensional vector; obtaining the vector similarity between the high-dimensional vector and the underlying financial data tables in the underlying financial data table database; sorting each underlying financial data table from high to low according to the similarity of each vector; and determining the underlying financial data table whose sorting number is greater than or equal to a preset sorting number threshold as the target underlying financial data table.
[0078] For example, server 104 inputs the financial query text into the text-embedding model for vector transformation to obtain the high-dimensional vector corresponding to the financial query text. It calculates the vector similarity between the high-dimensional vector and the underlying financial data tables in the underlying financial data table library. According to the similarity of each vector, the underlying financial data tables are sorted from high to low. The underlying financial data tables with a sorting number greater than or equal to a preset sorting number threshold are determined as the target underlying financial data tables most relevant to the financial query text.
[0079] According to the aforementioned implementation method, by selecting the most relevant data table based on the sorted underlying financial data table according to the sorting number threshold, it is guaranteed that there will always be a most relevant data table, thus ensuring the efficiency of data collection.
[0080] In an exemplary embodiment, the financial SQL statement corresponding to the financial data query request is obtained based on the financial query intent, the financial query object, the target underlying financial data table, historical financial SQL templates, and a pre-set SQL statement generation model for the financial field. This includes: obtaining the corresponding financial business rules based on the financial query object; constructing a financial SQL statement prompt context based on the financial query intent, the financial query object, the financial business rules, the target underlying financial data table, and historical financial SQL templates; and inputting the financial SQL statement prompt context into the SQL statement generation model to obtain the financial SQL statement corresponding to the financial data query request.
[0081] Financial business rules can be understood as a set of specific constraints, processes, and calculation logic that need to be followed in financial business scenarios to ensure that business is executed in accordance with established goals, compliance requirements, and risk control.
[0082] Optionally, server 104 loads the corresponding financial business rules based on the financial query object, and then constructs a financial SQL statement hint context based on the financial query intent, financial query object, financial business rules, target underlying financial data table, and historical financial SQL template. The financial SQL statement hint context is input into the SQL statement generation model to obtain the original financial SQL statement corresponding to the financial data query request. The original financial SQL statement is then validated. After the validation passes, performance optimization is performed to obtain the financial SQL statement corresponding to the financial data query request.
[0083] Based on the above implementation method, by loading the financial business rules corresponding to the financial query object and incorporating these rules into the subsequent prompt word construction and SQL statement generation, the adaptability of the generated financial SQL statement to the system is ensured, preventing the generated financial SQL statement from existing independently of the actual situation and ensuring the availability of the financial SQL statement.
[0084] In one embodiment, the financial SQL statement is generated by inputting a financial SQL statement with a context prompt to the SQL statement generation model, thereby obtaining the financial SQL statement corresponding to the financial data query request. This includes: inputting a financial SQL statement with a context prompt to the SQL statement generation model to obtain the original financial SQL statement corresponding to the financial data query request; performing syntax verification, semantic verification, security verification, and permission verification on the original financial SQL statement; and optimizing the performance of the original financial SQL statement by index optimization, JOIN order reordering, projection pruning, and LIMT constraints, if all verifications pass.
[0085] Syntax validation can be understood as validating the structure of a statement, which may include checking keyword spelling, bracket matching, etc. Semantic validation can be understood as validating the meaning of a statement, which may include verifying the existence of tables / fields, the validity of JOIN conditions, etc. Security validation can be understood as validating the operation, which may include disabling high-risk operations such as UNION / DROP. Permission validation can be understood as validating the user's permission to access data.
[0086] For example, server 104 uses the context prompt of the financial SQL statement to input the SQL statement generation model to obtain the original financial SQL statement corresponding to the financial data query request. The original financial SQL statement is subjected to syntax verification, semantic verification, security verification, and permission verification. If all verifications pass, the performance of the original financial SQL statement is optimized through strategies such as index optimization, JOIN order reordering, projection pruning, and LIMT restrictions to obtain the financial SQL statement.
[0087] According to the aforementioned implementation method, by performing permission verification on the generated original financial SQL statement, the legality of the obtained financial SQL statement is ensured, and the performance of the legal financial SQL statement is optimized, thereby ensuring the query speed and accuracy when using financial SQL to execute queries.
[0088] In one embodiment, the method further includes: automatically repairing the original financial SQL statement if any verification fails; if automatic repair fails, returning the error information of the original financial SQL statement to the SQL statement generation model to obtain a new original financial SQL statement, and returning to perform the steps of syntax verification, semantic verification, security verification, and permission verification on the original financial SQL statement until the number of times the SQL statement generation model generates the statement reaches a preset threshold or all verifications of the new original financial SQL statement pass; and if any verification still fails, sending the error type corresponding to the new original financial SQL statement to the user terminal.
[0089] Optionally, if any check fails, the server 104 automatically repairs the original financial SQL statement. If the automatic repair fails, the server returns the error information of the original financial SQL statement to the SQL statement generation model to obtain a new original financial SQL statement. The server then returns to perform syntax verification, semantic verification, security verification, and permission verification on the original financial SQL statement until the number of times the SQL statement generation model generates the statement reaches a preset threshold or all checks on the new original financial SQL statement pass. If any check still fails, the server sends the misalignment type (which may include missing parentheses, key spelling misalignment, etc.) of the new original financial SQL statement to the user terminal 102.
[0090] Based on the above implementation method, by setting up intelligent repair and SQL statement generation model regeneration mechanism, the fault tolerance of system operation is guaranteed, and the cyclic verification process also ensures that the original financial SQL statement obtained by regeneration also meets the relevant permission requirements, thus ensuring the scalability of the entire process.
[0091] In one embodiment, a financial database is constructed through the following steps: acquiring multi-source heterogeneous unstructured financial documents provided by users; using deep learning OCR technology to identify the multi-source heterogeneous unstructured financial documents to obtain the financial text corresponding to the multi-source heterogeneous unstructured financial documents; using layout analysis models and large models to classify documents, analyze layouts, and extract objects from the financial text to obtain the financial structured data corresponding to the financial text; and constructing a financial database based on the various financial structured data.
[0092] Deep learning OCR technology can be understood as Optical Character Recognition, a technology that converts text content in images into machine-readable text information. Deep learning OCR refers to the use of neural networks, especially deep learning models, for text detection, text recognition, and joint processing of text domains. Multi-source heterogeneous unstructured financial documents can be understood as unstructured financial data from different sources, which can include scanned copies of paper materials, photos, and PDF documents.
[0093] For example, server 104 obtains multi-source heterogeneous unstructured financial documents provided by the user, uses deep OCR technology to identify the multi-source heterogeneous unstructured financial documents, obtains the financial text corresponding to the multi-source heterogeneous unstructured financial documents, and then performs document classification, layout analysis and object extraction on the financial text through layout analysis model and large model to obtain the financial structured data corresponding to the financial text, and enters the financial structured data into the system to form a financial database.
[0094] According to the aforementioned implementation method, the solution of OCR + large model + layout analysis is used to solve the problem of entity extraction anomalies caused by the absence of table lines and table spanning multiple pages. Finally, the solution of OCR + large model + wealth management knowledge base realizes the function of correcting individual character recognition errors of financial entities, thereby ensuring the validity and usability of financial data in the financial database.
[0095] In one exemplary embodiment, a full-process data processing system design for customer service agents and intelligent queries based on large models, OCR, and TEXT2SQL is proposed.
[0096] The system adopts a multi-layered, modular intelligent architecture. By integrating optical character recognition (OCR) technology, large language model to structured query language conversion (Text-to-SQL) technology, and intelligent customer service agent (customer service intelligent agent) technology, it realizes the intelligentization of the entire wealth management business process.
[0097] The core modules are divided into:
[0098] Intelligent Recognition and Data Entry Layer: Employing deep learning OCR technology, it recognizes text in multi-source heterogeneous unstructured documents (including scanned copies of paper materials, photos, and PDF documents) provided by customers. Then, through layout analysis models and large models, it performs document classification, layout analysis, and entity extraction, converting unstructured data into structured business entity data for entry into the system.
[0099] In this process, replacing a layout with an OCR+large model solution requires developing an inefficient end-to-end interface. Then, the OCR+large model+layout analysis solution is used to solve the problem of entity extraction anomalies caused by missing table lines and table spanning multiple pages. Finally, the OCR+large model+wealth management knowledge base solution implements the function of correcting individual character recognition errors in financial entities.
[0100] Natural Language Intelligent Query Layer: Employing Text-to-SQL technology based on a large language model, it enables natural language query intent understanding, query entity recognition, database schema mapping, and automatic SQL statement generation, allowing business personnel and customers to directly query wealth data using natural language without needing to learn complex query syntax and operation interfaces.
[0101] Intelligent Customer Service Interaction Layer: Constructs a customer service intelligent agent based on a multimodal large language model, with capabilities such as natural language understanding, multi-turn dialogue management, intent recognition, knowledge retrieval, business system invocation, and personalized recommendation, to achieve automated, intelligent, and personalized customer service 24 / 7.
[0102] Intelligent Wealth Analysis and Planning Layer: Integrates wealth diagnostic models, intelligent planning engines, product recommendation algorithms, and dynamic optimization modules to achieve automatic diagnosis of customers' wealth status, intelligent generation of personalized planning solutions, intelligent product matching, and dynamic adjustment of planning solutions.
[0103] Business System Integration Layer: Through a unified service orchestration and data middleware architecture, it achieves seamless integration and data flow with multiple back-end business systems such as core banking systems, wealth management systems, fund systems, order systems, and account systems.
[0104] AI Capability Platform: Constructs a unified AI service layer, providing standardized AI capability interfaces such as OCR recognition service, Text-to-SQL conversion service, intelligent dialogue service, and intelligent recommendation service, supporting unified management, invocation, monitoring, and optimization of AI capabilities.
[0105] Reference Figure 3 , Figure 4 The parallel computing components include Layer 1: Infrastructure Layer, Layer 2: Data Platform Layer, Layer 3: AI Capability Platform Layer, Layer 4: Business Application Layer, Layer 5: Interface Gateway Layer, and Layer 6: Front-end Interaction Layer, among which:
[0106] Layer 1: Infrastructure Layer
[0107] 101 represents Kubernetes: a container orchestration platform; 102 represents Spring Cloud: a microservice framework; 103 represents Kafka: a message queue; 104 represents Redis: a distributed cache; 105 represents MinIO: an object storage; 106 represents MySQL: a relational database; 107 represents Milvus: a vector database; and 108 represents Prometheus+Grafana: a monitoring system. The parallel computing component interface is a window through which parallel computing components obtain numerical data or interact with the user interface.
[0108] Layer 2: Data Platform Layer
[0109] 201 indicates the data acquisition module: real-time acquisition and batch acquisition. It captures dynamic data (such as user behavior and sensor data) through streaming technologies like Kafka and Flink. It also periodically extracts offline data from business systems (ERP, CRM) using ETL tools (such as Airflow and Nifi). This ensures data integrity and timeliness, covering all data sources (IoT, mobile, databases).
[0110] 202 indicates the data governance module: data cleaning, quality management, and standardization. Data cleaning achieves deduplication, missing value imputation, and format standardization (e.g., dates are standardized to YYYY-MM-DD). Quality management is improved by defining data quality rules (e.g., null value rate <5%) and using tools (e.g., Great Expectations) for automatic verification. Standardization is achieved by establishing an enterprise-level data dictionary and unifying field naming and business meaning (e.g., the definition of "customer ID"). This improves data credibility, reduces data silos, and ensures cross-departmental data consistency.
[0111] 203 represents the data storage module: Data Lake, Data Warehouse, and Data Mart. Data Lake stores raw, multi-structured data (such as JSON, CSV, and logs), supporting Schema-on-Read. Data Warehouse provides analytically oriented structured storage (such as Snowflake and Redshift), supporting complex queries and OLAP analysis. Data Marts provide lightweight data storage divided by business domain (such as sales data marts and user behavior data marts) for specific departments. Tiered storage meets the needs of different scenarios, reducing storage costs and improving query efficiency.
[0112] A 204 error indicates a data service module with a unified data query interface. This interface exposes SQL / RESTful APIs through an API gateway (such as ESF) to build a unified query interface. It integrates multi-source data (such as MySQL, Kafka, and MinIO) through data virtualization to provide a unified view. Frequently used query results are cached using Redis to reduce underlying storage pressure. The goal is to reduce data retrieval complexity and enable business systems to quickly obtain the data they need.
[0113] 205 represents the Master Data Management module: Customer, Product, and Account Master Data Management. It defines the fields and relationships of core entities such as customers, products, and accounts through master data modeling. It eliminates duplicate master data (such as multiple records for the same customer) through a rule engine (e.g., Golden Record). It maintains historical change records of master data (such as product specification updates) through version management. The purpose of this module is to ensure the uniqueness and authority of core business entities and avoid data conflicts.
[0114] Layer 3: AI Capability Platform Layer
[0115] 301 indicates OCR recognition service: providing document classification, text recognition, information extraction and entity mapping functions, supporting structured data processing and unstructured document parsing, and improving data collection efficiency.
[0116] 302 indicates a Text-to-SQL service: it enables the automatic conversion and execution of natural language queries into SQL statements, simplifying user operations on the database and is suitable for scenarios such as data analysis and report generation.
[0117] 303 indicates Intelligent Dialogue Service: It supports intent recognition, multi-turn dialogue management, and natural response generation, and is suitable for scenarios such as customer service robots and virtual assistants, improving the interactive experience and response accuracy.
[0118] A 304 error indicates an intelligent recommendation service: based on user behavior and preferences, it provides personalized product recommendations and combination optimization solutions to enhance user stickiness and business conversion rates.
[0119] 305 represents intelligent analytics services: focusing on high-value scenarios such as wealth diagnosis and risk assessment, providing in-depth insights and decision support through AI models to help refine operations.
[0120] 306 represents the AI Capability Registry Center: enabling unified registration, discovery, and management of AI services, building a standardized capability catalog, and facilitating rapid invocation and collaboration across business modules.
[0121] 307 indicates the AI capability orchestration engine: It supports dynamic orchestration and collaborative invocation of multiple AI capabilities, enabling flexible combinations of complex business processes and improving system response speed and scalability.
[0122] 308 indicates the model management module: manages model version iteration, canary releases, and hot updates, ensuring model stability and continuous optimization, reducing deployment risks, and supporting rapid iteration.
[0123] Layer 4: Business Application Layer
[0124] The business application layer is a collection of core functional modules geared towards users and business operations. Based on the underlying data platform and infrastructure capabilities, it enables closed-loop processes for specific business scenarios such as account management, order processing, and wealth planning. The following is a classification and description of the core modules:
[0125] A 401 error indicates the Account Management module: This module handles account opening, closing, and inquiry. Account opening supports user authentication and account information entry (such as name, ID number, and contact information). Account closing provides functions for account status changes, balance settlement, and data archiving. It supports real-time display of account balance, transaction records, and held assets. This module manages the user account lifecycle, ensuring the accuracy and security of account data. After the account manager queries the client's account asset distribution through the backend, a personalized service report is generated.
[0126] A 402 error indicates a problem with the order management module: product purchase, redemption, and order inquiry. Product purchase supports order placement for funds, insurance, and wealth management products, verifying user permissions and account balances. The redemption function processes redemption requests, calculates redemption amounts, and updates account holdings. The order inquiry provides order status tracking (e.g., "Submitted," "Processing," "Completed"). This module standardizes and automates the transaction process, reducing the risk of human intervention.
[0127] 403 indicates the Planning Goals module: This module allows users to create, query, and replace planning goals. Goal creation allows users to set financial goals (e.g., "accumulate 500,000 yuan within 5 years") and associate them with product portfolios. The query function displays current and projected goal progress (e.g., current amount, projected achievement time). Product replacement allows users to adjust product configurations within the goals based on market changes or user needs. This module provides personalized wealth management solutions, enhancing user engagement and satisfaction.
[0128] A 404 error indicates a problem with the sub-account management module: asset allocation management and sub-account query. Asset allocation management allows users to allocate assets to different sub-accounts according to their risk preferences (e.g., "conservative" or "aggressive"). Sub-account query displays the asset distribution, returns, and risk indicators of each user's sub-accounts. This enables diversified asset management and reduces the risk of volatility in a single market.
[0129] 405 indicates an event handling module: event publishing / subscription and asynchronous task processing. Event publishing / subscription broadcasts business events (such as "order completed" and "account change") via message queues (such as Kafka). Non-real-time tasks (such as email notifications, data synchronization, and log archiving) are executed asynchronously. This decouples business logic, improving system response speed and scalability.
[0130] 406 indicates the Intelligent Wealth Planning module: Wealth Diagnosis, Intelligent Planning, and Dynamic Monitoring. Wealth Diagnosis generates a health report based on user assets, liabilities, income, and other data. Intelligent Planning recommends investment portfolios and adjustment suggestions through AI models (such as machine learning). Dynamic Monitoring tracks the progress of planning goals in real time and triggers alerts (such as "goal deviation threshold"). This module provides data-driven wealth management decision support, enhancing the level of service intelligence.
[0131] Layer 5: Interface Gateway Layer
[0132] 501 indicates API Gateway: a unified entry point for authentication and authorization, traffic control, and routing.
[0133] Layer 6: Front-end interaction layer
[0134] 601 indicates the web-based platform: a financial manager work platform and a customer self-service portal. The financial manager work platform provides tools for customer management, asset allocation, product recommendations, and transaction monitoring, supporting batch operations and data analysis. Through the customer self-service portal, users can view account details, submit transaction requests, check order status, and receive intelligent planning suggestions. This solution improves the service efficiency of financial managers, lowers the operational threshold for customers, and achieves a digital closed loop in the business process.
[0135] 602 indicates mobile devices: mobile banking app and wealth management manager app. The mobile banking app supports core functions such as account inquiry, product purchase, order management, and message notifications, and is adapted to mobile operating habits. The wealth management manager app provides customer follow-up, task reminders, data visualization, and remote collaboration functions, supporting offline mode and real-time synchronization. This part realizes the mobile extension of business functions, meeting users' financial needs anytime, anywhere.
[0136] 603 indicates a bank counter terminal: integrated with the bank's core systems. It connects to the bank's core systems (such as account management and order processing), supporting highly secure, low-latency transaction operations. Identity verification and authorization are completed through hardware devices (such as USB tokens and fingerprint recognition) to verify user identity and authorize transactions. It ensures the compliance and security of offline business and meets the needs of complex transaction scenarios (such as large-amount transfers and dedicated account openings).
[0137] A 604 error indicates an intelligent customer service channel: online customer service, WeChat official account, and telephone customer service. Online customer service uses a real-time chatbot (such as an NLP-based dialogue system) to answer common questions, while complex questions are transferred to a human agent. The WeChat official account pushes personalized information, transaction notifications, and promotional activities, supporting one-click redirection to the app or web version. Telephone customer service automatically identifies user needs through an IVR system, assigning a human agent or triggering a self-service process. This solution provides omnichannel, 24 / 7 customer service, improving user experience and customer satisfaction. Specifically, users can check order status through the WeChat official account, and the system calls the data service module's interface to return real-time data. The intelligent customer service uses the Milvus vector database to match user questions with the knowledge base, providing accurate answers.
[0138] The OCR application software includes document preprocessing, document classification, OCR recognition, information extraction, entity mapping, and data storage. Document classification involves initial OCR recognition followed by keyword extraction of text features, CNN / ResNet50 image feature extraction, and an SVM / fully connected neural network as the input classifier. Key information extraction utilizes a three-layer architecture: template layer extraction, semantic layer extraction, and fusion layer. Entity mapping uses knowledge graph mapping to match OCR-recognized entities with standard entities in the knowledge graph, improving the confidence of the verification results.
[0139] In one embodiment, such as Figure 5 As shown, this provides a specific process for document classification when constructing financial data. See [link to relevant documentation]. Figure 5 The given steps perform document classification on financial texts.
[0140] In one embodiment, such as Figure 6 As shown, a specific implementation method for financial data query is provided, wherein:
[0141] Phase 1: Query Understanding (01-05) Preprocess the input query, use the BERT classification model to identify the query intent, and use the BERT-NER model to extract key entities.
[0142] Phase 2: Database Schema Retrieval (606-609), Retrieval Process:
[0143] 1. Convert the query text into a vector (using the text-embedding model).
[0144] 2. Retrieve the Top-K related tables (K=3-5) in Milvus.
[0145] 3. Ranked based on vector similarity.
[0146] Based on the extracted entities, load the corresponding business rules, and then retrieve similar historical queries from the query template library.
[0147] Phase 3: SQL generation (10-12). First, construct the prompting context, and then generate SQL using the proprietary model fine-tuned by the domain (based on GPT / Qwen fine-tuning).
[0148] Phase 4: SQL Validation and Optimization (13-18) ensures query security and performance through a multi-dimensional SQL validation and optimization mechanism: First, based on JSqlParser, it implements syntax validation (checking keyword spelling, bracket matching, etc.), semantic validation (verifying table / field existence, JOIN condition validity, etc.), and security validation (prohibiting high-risk operations such as UNION / DROP). At the same time, it automatically adds data access control policies through permission validation. For validation failure scenarios, the system provides intelligent repair (such as completing brackets) and LLM regeneration mechanism (maximum 3 attempts). If it still fails, it returns the precise error type. Through strategies such as index optimization, JOIN order reordering, projection pruning, and LIMIT restrictions, it optimizes the performance of legitimate SQL, ultimately achieving full-link validation, automated repair, and improved execution efficiency of SQL syntax, semantics, security, and permissions.
[0149] Phase 5: Query Execution (19-20), execute the SQL query and make a judgment based on the execution result.
[0150] Phase 6: Post-processing of results (21-25), achieving efficient presentation of query results through data security processing and intelligent visualization mechanisms: First, dynamic anonymization is implemented based on data sensitivity levels (e.g., hiding names, partially obscuring ID numbers, and blurring the middle four digits of mobile phone numbers), combined with data formatting strategies (converting amounts to ten thousand yuan / thousandths, dates to Chinese formats, and status codes to business semantics) to improve readability; the intelligent display engine dynamically adapts the display format according to query characteristics (simple queries to tables, aggregated data to charts, time series to line graphs, and massive data to pagination); LLM is called to generate natural language summaries (e.g., customer purchase amount statistics, key indicator analysis), and an accompanying SQL logic interpreter transforms technical query steps into user-understandable business language descriptions, covering the entire process of data filtering, table joining, and aggregation logic, ultimately achieving a triple improvement in data security, display effect, and user comprehension.
[0151] Phase 7: Return the results.
[0152] Compared with the prior art, this application has the following technical advantages:
[0153] 1. By using OCR technology, data entry efficiency is increased by more than 10 times, and the accuracy rate reaches more than 99%.
[0154] 2. By using Text-to-SQL technology, query response time is reduced from 1-3 days to seconds, allowing business personnel to independently complete more than 90% of their query needs.
[0155] 3. Through the intelligent customer service agent, more than 80% of customer questions are answered automatically, and the average customer waiting time is reduced from 10 minutes to less than 30 seconds.
[0156] 4. The intelligent planning engine reduces the time for generating wealth planning solutions from 3-7 days to minutes, significantly improving the quality and personalization of the solutions.
[0157] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0158] Based on the same inventive concept, this application also provides a financial data query device for implementing the financial data query method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more embodiments of the financial data query device provided below can be found in the limitations of the financial data query method described above, and will not be repeated here.
[0159] In one exemplary embodiment, such as Figure 7 As shown, a financial data query device is provided, including: an acquisition module 701, a statement acquisition module 702, and a query module 703, wherein:
[0160] The acquisition module 701 is used to acquire the financial data query request input by the user, and obtain the user's financial query intent, financial query object, target underlying financial data table and historical financial SQL template based on the financial data query request.
[0161] The statement acquisition module 702 is used to obtain the financial SQL statement corresponding to the financial data query request based on the financial query intent, the financial query object, the target underlying financial data table, the historical financial SQL template, and the SQL statement generation model pre-set for the financial field.
[0162] The query module 703 is used to query a pre-built financial database based on financial SQL statements to obtain the financial data corresponding to the financial data query request.
[0163] In one embodiment, the acquisition module 701 is further configured to clean and standardize the financial data query request to obtain the financial query text; input the financial query text into the BERT classification model and the BERT-NER model respectively, obtain the financial query intent through the BERT classification model, and obtain the financial query object through the BERT-NER model; obtain the target underlying financial data table from the underlying financial data table database based on the financial query text; and search the financial SQL template database based on the financial query text to obtain historical financial SQL templates similar to the financial query text.
[0164] In one embodiment, the acquisition module 701 is further configured to convert the financial query text into a high-dimensional vector; acquire the vector similarity between the high-dimensional vector and the underlying financial data tables in the underlying financial data table library; sort the underlying financial data tables from high to low according to the similarity of each vector; and determine the underlying financial data tables whose sorting number is greater than or equal to a preset sorting number threshold as the target underlying financial data tables.
[0165] In an exemplary embodiment, the statement acquisition module 702 is further configured to acquire the corresponding financial business rules based on the financial query object; construct a financial SQL statement prompt context based on the financial query intent, financial query object, financial business rules, target underlying financial data table, and historical financial SQL template; and input the financial SQL statement prompt context into the SQL statement generation model to obtain the financial SQL statement corresponding to the financial data query request.
[0166] In one embodiment, the statement acquisition module 702 is further configured to input the financial SQL statement into the SQL statement generation model based on the context prompt of the financial SQL statement to obtain the original financial SQL statement corresponding to the financial data query request; perform syntax verification, semantic verification, security verification, and permission verification on the original financial SQL statement; and optimize the performance of the original financial SQL statement by index optimization, JOIN order reordering, projection pruning, and LIMT constraints, and obtain the financial SQL statement.
[0167] In one embodiment, the statement acquisition module 702 is further configured to automatically repair the original financial SQL statement if any one of the checks fails; if the automatic repair fails, the error information of the original financial SQL statement is returned to the SQL statement generation model to obtain a new original financial SQL statement, and the steps of performing syntax check, semantic check, security check and permission check on the original financial SQL statement are returned to be executed until the number of times the SQL statement generation model generates the statement reaches a preset threshold or all checks of the new original financial SQL statement pass, and if any check still fails, the error type corresponding to the new original financial SQL statement is sent to the user terminal.
[0168] In an exemplary embodiment, the financial data query device further includes a database construction module, used to acquire multi-source heterogeneous unstructured financial documents provided by the user; use deep learning OCR technology to identify the multi-source heterogeneous unstructured financial documents to obtain the financial text corresponding to the multi-source heterogeneous unstructured financial documents; use layout analysis models and large models to classify documents, analyze layouts, and extract objects from the financial text to obtain the financial structured data corresponding to the financial text; and construct a financial database based on the various financial structured data.
[0169] Each module in the aforementioned financial data query device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0170] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores financial data query requests, financial query intentions, financial query objects, target underlying financial data tables, historical financial SQL templates, financial SQL statements, and financial data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a financial data query method.
[0171] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0172] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the financial data query method of the above embodiment.
[0173] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the financial data query method of the above embodiment.
[0174] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the financial data query method of the above embodiments.
[0175] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0176] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0177] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0178] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for querying financial data, characterized in that, The method includes: Obtain the financial data query request input by the user, and obtain the user's financial query intent, financial query object, target underlying financial data table and historical financial SQL template based on the financial data query request; Based on the financial query intent, the financial query object, the target underlying financial data table, the historical financial SQL template, and the SQL statement generation model pre-set for the financial field, the financial SQL statement corresponding to the financial data query request is obtained. The financial data corresponding to the financial data query request is obtained by querying a pre-built financial database using the financial SQL statement.
2. The method according to claim 1, characterized in that, The step of obtaining the user's financial query intent, financial query object, target underlying financial data table, and historical financial SQL template based on the financial data query request includes: The financial data query request is cleaned and standardized to obtain the financial query text; The financial query text is input into the BERT classification model and the BERT-NER model respectively. The financial query intent is obtained through the BERT classification model, and the financial query object is obtained through the BERT-NER model. Based on the financial query text, the target underlying financial data table is obtained from the underlying financial data table database; Based on the financial query text, a search is performed in the financial SQL template library to obtain historical financial SQL templates similar to the financial query text.
3. The method according to claim 2, characterized in that, The step of obtaining the target underlying financial data table from the underlying financial data table database based on the financial query text includes: Convert the financial query text into a high-dimensional vector; Obtain the vector similarity between the high-dimensional vector and the underlying financial data tables in the underlying financial data table library; Based on the vector similarity, the underlying financial data tables are sorted from high to low. The underlying financial data tables whose sorting sequence number is greater than or equal to a preset sorting sequence number threshold are identified as the target underlying financial data tables.
4. The method according to any one of claims 1-3, characterized in that, The process of obtaining the financial SQL statement corresponding to the financial data query request based on the financial query intent, the financial query object, the target underlying financial data table, the historical financial SQL template, and a pre-set SQL statement generation model for the financial field includes: Obtain the corresponding financial business rules based on the financial query object; Based on the financial query intent, the financial query object, the financial business rules, the target underlying financial data table, and the historical financial SQL template, a financial SQL statement prompt context is constructed. The financial SQL statement prompt context is input into the SQL statement generation model to obtain the financial SQL statement corresponding to the financial data query request.
5. The method according to claim 4, characterized in that, The step of inputting the financial SQL statement prompt context into the SQL statement generation model to obtain the financial SQL statement corresponding to the financial data query request includes: The financial SQL statement prompt context is input into the SQL statement generation model to obtain the original financial SQL statement corresponding to the financial data query request; The original financial SQL statement is subjected to syntax validation, semantic validation, security validation, and permission validation. If all checks pass, the original financial SQL statement is optimized for performance through index optimization, JOIN order rearrangement, projection pruning, and LIMT constraints to obtain the final financial SQL statement.
6. The method according to claim 5, characterized in that, The method further includes: If any validation fails, the original financial SQL statement will be automatically repaired. In the event of automatic repair failure, the error information of the original financial SQL statement is returned to the SQL statement generation model to obtain a new original financial SQL statement. Then, the model returns to perform syntax verification, semantic verification, security verification, and permission verification on the original financial SQL statement until the number of times the SQL statement generation model generates the statement reaches a preset threshold or all verifications of the new original financial SQL statement pass. If any verification fails, the error type corresponding to the new original financial SQL statement is sent to the user terminal.
7. The method according to claim 1, characterized in that, The financial database is constructed through the following steps: Obtain the multi-source heterogeneous unstructured financial documents provided by the user; The multi-source heterogeneous unstructured financial documents are identified using deep learning OCR technology to obtain the financial text corresponding to the multi-source heterogeneous unstructured financial documents. By using layout analysis models and large models, the financial text is classified, analyzed in terms of layout, and extracted from objects to obtain the financial structured data corresponding to the financial text. The financial database is constructed based on the aforementioned structured financial data.
8. A financial data query device, characterized in that, The device includes: The acquisition module is used to acquire the financial data query request input by the user, and obtain the user's financial query intent, financial query object, target underlying financial data table and historical financial SQL template based on the financial data query request; The statement acquisition module is used to obtain the financial SQL statement corresponding to the financial data query request based on the financial query intent, the financial query object, the target underlying financial data table, the historical financial SQL template, and the SQL statement generation model pre-set for the financial field. The query module is used to query a pre-built financial database based on the financial SQL statement to obtain the financial data corresponding to the financial data query request.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.