Data query method, device and equipment based on two-fusion scene, medium and product

By combining text parsing of margin trading data query questions with an intelligent question-answering model, a target SQL query statement is generated, prioritizing the query of the summary statistics table. This solves the problem of low data query efficiency in margin trading scenarios and improves real-time performance and accuracy.

CN121958321APending Publication Date: 2026-05-01ORIENT SECURITIES COMPANY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ORIENT SECURITIES COMPANY
Filing Date
2026-01-20
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In the context of margin trading and securities lending, existing technologies suffer from low data query efficiency, insufficient real-time performance, and inadequate accuracy. Especially with massive amounts of data, the NL2SQL model directly queries the finest transaction table, resulting in high response latency and failing to meet users' real-time query needs.

Method used

By acquiring the target user's margin trading data query text, performing text parsing to determine the time dimension characteristics of the query question, and if the query conditions for the current day are not met, obtaining the prompt word template, using the intelligent question-answering model to generate the target SQL query statement, prioritizing the query of the pre-built summary statistics table or transaction flow table, and generating the query results.

Benefits of technology

It improves the efficiency of data querying, ensuring the real-time nature, completeness, and accuracy of queries. By using priority matching rules and summary statistics tables, it significantly improves the efficiency of SQL query statement generation and the accuracy of query results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121958321A_ABST
    Figure CN121958321A_ABST
Patent Text Reader

Abstract

The invention discloses a data query method, device and equipment based on a two-fusion scene, a medium and a product. The method comprises the steps of obtaining a two-fusion data query problem text of a target user, performing text analysis on the two-fusion data query problem text, and determining query problem time dimension features; if it is determined that the two-fusion data query problem text does not meet preset data query judgment conditions of the day according to the text initiation time and query problem time dimension features of the two-fusion data query problem text, obtaining a prompt word template; according to the two-fusion data query problem text and the prompt word template, based on a pre-selected intelligent question and answer model, obtaining a target SQL query statement corresponding to the two-fusion data query problem text; and executing the target SQL query statement, performing data query on a pre-constructed and stored summary statistical table or a pre-acquired and stored transaction flow table, generating a two-fusion data query result, and feeding back the two-fusion data query result to the target user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of financial technology, and in particular to a data query method, apparatus, equipment, medium and product based on margin trading scenarios. Background Technology

[0002] Margin trading (securities lending) is one of the core businesses of financial institutions, generating massive amounts of margin trading settlement and transaction data every day. This transaction record stores the most granular business data, such as customer number, full margin trading business identifier, transaction quantity and amount, and other core fields. The data volume usually reaches tens of millions or even hundreds of millions.

[0003] In scenarios such as intelligent customer service, investment advisory assistance, and internal data querying in financial institutions, NL2SQL (Natural Language to SQL) technology enables the automatic conversion of users' natural language queries into SQL (Structured Query Language) statements, greatly reducing the query threshold for non-technical personnel.

[0004] However, the NL2SQL model defaults to directly querying the most detailed transaction table in margin trading. The massive amounts of data result in long SQL statement execution times and high response latency, and also have limitations in terms of data query real-time performance, completeness, and accuracy. Therefore, improving data query efficiency in margin trading scenarios, and ensuring the real-time performance, completeness, and accuracy of data queries, has become an urgent problem to be solved. Summary of the Invention

[0005] This invention provides a data query method, apparatus, device, medium, and product based on margin trading scenarios, to improve the efficiency of data query in margin trading scenarios, while ensuring that the data query results are real-time, complete, and accurate.

[0006] According to one aspect of the present invention, a data query method based on a margin trading scenario is provided, the method comprising:

[0007] Obtain the target user's margin trading data query question text, and perform text parsing on the margin trading data query question text to determine the time dimension features of the query question;

[0008] If, based on the text initiation time and time dimension characteristics of the margin trading data query question text, it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day, then a prompt word template is obtained; the prompt word template includes a pre-constructed list of summary statistics tables, priority matching rule prompt text, and SQL statement query scenario examples; the list of summary statistics tables includes table association information of at least one summary statistics table; the summary statistics table is pre-generated based on pre-determined high-frequency margin trading query question texts;

[0009] Based on the margin trading data query question text and the prompt word template, and using a pre-selected intelligent question-answering model, the target SQL query statement corresponding to the margin trading data query question text is obtained.

[0010] The target SQL query statement is executed to query data from a pre-built and stored summary statistics table or a pre-acquired and stored transaction log table, generating margin trading data query results, and then the margin trading data query results are fed back to the target user.

[0011] According to another aspect of the present invention, a data query device based on a financial services scenario is provided, the device comprising:

[0012] The query question text acquisition module is used to acquire the margin trading data query question text of the target user, and to perform text parsing on the margin trading data query question text to determine the time dimension features of the query question;

[0013] The prompt word template acquisition module is used to acquire a prompt word template if, based on the text initiation time and time dimension characteristics of the margin trading data query question text, it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day. The prompt word template includes a pre-constructed list of summary statistics tables, priority matching rule prompt text, and SQL statement query scenario examples. The list of summary statistics tables includes table association information of at least one summary statistics table. The summary statistics table is pre-generated based on pre-determined high-frequency margin trading query question texts.

[0014] The target query statement generation module is used to obtain the target SQL query statement corresponding to the margin trading data query question text based on the margin trading data query question text and the prompt word template, and based on the pre-selected intelligent question answering model.

[0015] The target query statement execution module is used to execute the target SQL query statement, perform data query on the pre-built and stored summary statistics table or the pre-acquired and stored transaction flow table, generate margin trading data query results, and feed back the margin trading data query results to the target user.

[0016] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0017] At least one processor; and

[0018] A memory communicatively connected to the at least one processor; wherein,

[0019] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to execute the data query method based on the two-way financial scenario as described in any embodiment of the present invention.

[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions, the computer instructions being configured to cause a processor to execute and implement the data query method based on a two-way fusion scenario as described in any embodiment of the present invention.

[0021] According to another aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the data query method based on a financial and financial scenario as described in any embodiment of the present invention.

[0022] The technical solution of this invention parses the obtained margin trading data query question text to determine the time dimension characteristics of the query question. When it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day, a prompt word template is obtained. Based on the margin trading data query question text and the prompt word template, and using a pre-selected intelligent question answering model, the target SQL query statement corresponding to the margin trading data query question text is obtained and executed. The target SQL query statement is used to query data from a pre-built and stored summary statistics table or a pre-acquired and stored transaction flow table, generating margin trading data query results. In the process of generating the target SQL query statement, a prompt word template containing a list of summary statistics tables and priority matching rules is used. This allows the intelligent question answering model to prioritize the retrieval of summary statistics tables based on the prompt word template, improving the efficiency of SQL query statement generation and accurately guiding the model to generate the SQL statement for querying summary statistics tables. This improves the data query efficiency in the margin trading scenario and ensures the real-time, complete, and accurate data query.

[0023] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a flowchart of a data query method based on a margin trading scenario provided in Embodiment 1 of the present invention;

[0026] Figure 2 This is a flowchart of a data query method based on a financial and securities lending scenario provided in Embodiment 2 of the present invention;

[0027] Figure 3 This is a schematic diagram of the structure of a data query device based on a financial and securities lending scenario provided in Embodiment 3 of the present invention;

[0028] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the data query method based on the two-way financial scenario in the embodiments of the present invention. Detailed Implementation

[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0031] Example 1

[0032] Figure 1This is a flowchart of a data query method based on a margin trading scenario provided in Embodiment 1 of the present invention. This embodiment is applicable to data queries in margin trading scenarios. The method can be executed by a data query device based on a margin trading scenario. This data query device can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:

[0033] S110. Obtain the target user's margin trading data query question text, and perform text parsing on the margin trading data query question text to determine the time dimension characteristics of the query question.

[0034] S120. If, based on the text initiation time and query time dimension characteristics of the margin trading data query question text, it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day, then a prompt word template is obtained. The prompt word template includes a pre-built list of summary statistics tables, priority matching rule prompt text, and SQL statement query scenario examples. The list of summary statistics tables includes table association information of at least one summary statistics table. The summary statistics table is pre-generated based on the pre-determined high-frequency margin trading query question text.

[0035] S130. Based on the margin trading data query question text and prompt word template, and using the pre-selected intelligent question-answering model, obtain the target SQL query statement corresponding to the margin trading data query question text.

[0036] S140. Execute the target SQL query statement to query the data in the pre-built and stored summary statistics table or the pre-acquired and stored transaction flow table, generate the margin trading data query results, and feed the margin trading data query results back to the target user.

[0037] The target users can be those with inquiries about margin trading and securities lending, such as individual clients, institutional clients, and internal staff. The query text for margin trading and securities lending data can be a natural language query initiated by the target user through the front-end page of the margin trading and securities lending query function. This query text targets the financial institution's transaction logs, which contain a massive amount of data and store the most granular transaction data for margin trading and securities lending. Specifically, this includes fields such as customer number, security number, business identifier, transaction quantity, transaction amount, and transaction price. The business identifier includes all types of margin trading and securities lending transactions, such as ordinary buy, ordinary sell, margin buy, short selling, buy-to-repay, and sell-to-repay.

[0038] For example, if the target user is an individual customer, the corresponding margin trading data query text could be "What was the total amount of margin purchases by my customer number 0123 in October 2024?"; if the target user is an institutional customer, the corresponding margin trading data query text could be "What was the number of short selling transactions for securities number 600066 in the past week?"; if the target user is an internal business employee of an institution, the corresponding margin trading data query text could be "What was the total amount of securities purchases and repayments for branch 001 in September?"

[0039] Text parsing of margin trading data query texts reveals time-related characteristics. For example, if the query text is "What was the amount of margin buying by my client number 0123 today (January 1, 2025)?", then the time-related characteristic is January 1, 2025. Similarly, if the query text is "What was the volume of short selling transactions for securities number 600066 in September 2025?", then the time-related characteristic is September 2025.

[0040] If, based on the text initiation time and query time dimension characteristics of the margin trading data query question text, it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the current day, then a prompt word template is obtained. The judgment conditions for the data query of the current day can be preset by relevant technical personnel. Specifically, the judgment conditions for the data query of the current day can be that the content queried by the margin trading data query question text involves transaction data of the current day. The text initiation time is the time when the target user initiates the margin trading data query question text. For example, taking the text initiation time as 2025 / 01 / 01 / 09:00, if the query time dimension characteristic of the parsed margin trading data query question text is "2025 / 01 / 01", then it can be determined that the margin trading data query question text meets the preset judgment conditions for the data query of the current day; conversely, if the query time dimension characteristic of the parsed margin trading data query question text does not include "2025 / 01 / 01", for example, if the query time dimension characteristic is "September 2024", then it can be determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the current day.

[0041] The prompt word template can be pre-generated by relevant technical personnel. The prompt word template includes a pre-built list of summary statistics tables, priority matching rule prompt text, and SQL query scenario examples. The list of summary statistics tables includes table relationship information for at least one summary statistics table; the summary statistics tables are pre-generated based on pre-determined high-frequency margin trading query question text.

[0042] It should be noted that existing NL2SQL query methods typically perform retrieval based on the finest-grained transaction log table. However, the transaction log table contains a massive amount of data, resulting in a significant deficiency in data query response efficiency. The summary statistics table generated in this embodiment is constructed based on the original transaction log table and the user's high-frequency query needs. Specifically, it summarizes the user's high-frequency queries regarding the transaction log table, resulting in a multi-dimensional summary statistics table, thereby solving the problem of slow data query efficiency.

[0043] The table relationship information of the summary statistics table included in the prompt word template can include table name, table index fields, and field list; the field list can include, for example, customer number, statistical month, and total amount of margin purchase. Priority matching rules are used to prompt the model to prioritize querying the summary statistics table. These rules can be pre-defined by relevant technical personnel. For example, the priority matching rule could be "prioritize matching the query scenario of the summary statistics table; only when the summary statistics table cannot meet the query requirements, such as when the query dimension is not covered, the statistical indicator is not supported, or the finest granular transaction data needs to be queried, will the transaction transaction table be used for querying."

[0044] The SQL query scenario examples included in the prompt word template can be example pairs from different margin trading business query scenarios. Each margin trading business query scenario can contain 3-5 example pairs. This embodiment does not impose any restrictions on this, thereby ensuring that the model can understand the statistical table query logic corresponding to different expressions. For example, the SQL query scenario examples can be referenced as follows:

[0045] Example A: The natural language question "Query the total amount of margin purchases for customer 000123202410" corresponds to the SQL statement "SELECT Total Amount of Margin Purchases FROM Margin_Customer_Monthly_Summary Table WHERE Customer Number='000123' AND Statistical Month='202410'";

[0046] Example B: The natural language question "What is the total number of shares sold short by customer 000124 on 2024-10-25?" corresponds to the SQL statement "SELECT Total Number of Shares Sold Short FROM Margin Trading_Customer_Daily_Summary Table WHERE Customer Number='000124' AND Statistics Date='20241025'".

[0047] Example C: The natural language question “Summary amount of coupon purchase and repayment for the 43rd week of 082024 in the business department” corresponds to the SQL statement “SELECT Total amount of coupon purchase and repayment FROM Margin Trading_Business Department_Weekly_Summary Table WHERE Business Department Number='08' AND Statistics Weekly='202443'”.

[0048] The system calls a pre-selected intelligent question-answering model to receive the text of a margin trading data query and loads a prompt word template, generating the target SQL query statement corresponding to the text. During the generation of the target SQL query statement, the intelligent question-answering model prioritizes matching summary statistics tables according to priority matching rules. When a matching summary statistics table is found, the target SQL query statement is generated based on the table relationship information of the summary statistics table in the prompt words. When no matching summary statistics table is found, fine-grained transaction log table matching is performed, and the target SQL query statement is generated based on the table information of the transaction log table.

[0049] Execute the target SQL query statement. If the table involved in the target SQL query statement is named a summary statistics table, then perform a table data query on the corresponding stored summary statistics table. If the table involved in the target SQL query statement is named a transaction flow table, then perform a table data query on the corresponding stored transaction flow table, generate the margin trading data query results, and send the margin trading data query results back to the target user.

[0050] Furthermore, this embodiment also provides a method for generating a summary table statistical list. The accuracy of the generated summary table statistical list affects the accuracy of the prompt word template. The purpose of generating the summary table statistical list is to improve query efficiency and the accuracy of query results. Therefore, the generation process of the summary table statistical list needs to consider the high-frequency query needs of users over historical time periods. In an optional embodiment, before obtaining the prompt word template, a process for generating the summary table statistical list is also included, and the specific implementation method is as follows:

[0051] Step a: Obtain several historical margin trading data query texts submitted by historical users within a preset historical time period, and determine the high-frequency question categories based on each historical margin trading data query text.

[0052] Specifically, it can acquire natural language queries related to margin trading submitted by users through channels such as mobile terminals, clients, and web pages during historical time periods as historical margin trading data query texts, and perform semantic clustering and high-frequency identification on several acquired historical margin trading data query texts to obtain high-frequency question categories.

[0053] In one specific implementation, determining high-frequency question categories based on historical margin trading data query texts includes: performing text preprocessing on each historical margin trading data query text to obtain each standard margin trading data query text; extracting semantic features from each standard margin trading data query text to generate text semantic feature vectors corresponding to each standard margin trading data query text; performing text clustering on each standard margin trading data query text based on each text semantic feature vector to obtain at least one semantically similar question category; each semantically similar question category includes at least one semantically similar standard margin trading data query text; and determining high-frequency question categories based on the number of standard margin trading data query texts included in each semantically similar question category.

[0054] Preprocessing operations may include deduplication, word segmentation, stop word removal, and standardization.

[0055] Specifically, deduplication of historical margin trading data query texts can be performed based on natural language semantic similarity, i.e., removing duplicate query texts. For example, historical margin trading data query text A is "Query the total amount of margin purchases by customer number 0011 in October 2025", and historical margin trading data query text B is "What is the total amount of margin purchases by customer number 0011 in October 2025?". Based on text semantic similarity, historical margin trading data query text A and historical margin trading data query text B can be determined to be duplicate query texts. Therefore, one of them can be selected to be kept and the other deleted, thus completing the deduplication of historical margin trading data query texts.

[0056] After deduplication and de-processing, the historical margin trading data query texts are segmented into words. For example, existing open-source word segmentation tools, such as jieba, can be used in conjunction with a custom dictionary for the margin trading field. This custom dictionary can contain professional terms related to margin trading, such as "margin trading," "margin buying," "short selling," "business department," and "monthly." For instance, for the historical margin trading data query text "Query the total amount of short selling by business department 008 in October 2025," the corresponding word segmentation results could be: ['query', 'business department 008', 'October 2025', 'short selling', 'total amount'.

[0057] Stop words are removed from historical margin trading data query text after deduplication and word segmentation. Specifically, this can be done by deleting stop words from a pre-defined stop word list for the margin trading field. For example, the stop word list for the margin trading field may include words without actual semantic meaning, such as "query", "of", "how much", and "please ask". The result after removing stop words from the historical margin trading data query text can be ['Business Department 008', 'October 2025', 'short selling', 'summary amount'].

[0058] The historical margin trading data query text, after deduplication, word segmentation, and stop word removal, is standardized, including unifying time representation and business identifiers. For example, "October 2025" and "2025 October" can be standardized to "202510 month"; business identifiers such as "margin purchase" and "margin purchase" can be unified to "margin purchase".

[0059] After preprocessing operations such as deduplication, word segmentation, stop word removal, and standardization, the corresponding standard margin trading data query texts for each historical margin trading data query text are obtained. Semantic features are then extracted from each standard margin trading data query text. For example, an existing semantic feature encoding model can be used to semantically encode each standard margin trading data query text, resulting in a text semantic feature vector for each standard margin trading data query text. A K-means clustering algorithm can be used to cluster the standard margin trading data query texts based on their semantic feature vectors, resulting in at least one semantically similar problem category.

[0060] Specifically, the elbow rule can be used to determine the number of clusters K. Based on experience with margin trading and securities lending business scenarios, the initial value of K can be set to 20-30, which can be adjusted according to actual data. Input the semantic feature vectors of all standard margin trading and securities lending data query texts, and iteratively calculate cluster centers using the K-means algorithm, grouping semantically similar questions into the same category. For example, all questions "query the total amount of each business identifier for a certain customer in a month" are clustered into one category, and all questions "query the daily trading volume of a certain securities" are clustered into another category, resulting in at least one semantically similar question category. Each semantically similar question category includes at least one semantically similar standard margin trading and securities lending data query text.

[0061] High-frequency question categories are determined based on the number of standard margin trading data query texts contained in each semantically similar question category. Specifically, a text quantity threshold can be preset. For any semantically similar question category, if the number of texts in that category exceeds the preset threshold, then that semantically similar question category is determined as a high-frequency question category. Optionally, different text quantity thresholds can be dynamically set for different semantically similar question categories. For example, for semantically similar question category A, the corresponding text quantity threshold can be set to 300; for semantically similar question category B, the corresponding text quantity threshold can be set to 200. This can be dynamically configured by relevant technical personnel according to actual needs, and this embodiment does not impose any restrictions on this.

[0062] Step b: Perform feature analysis on high-frequency question categories to determine core query dimension features, statistical indicator features, and filtering condition features.

[0063] Specifically, semantic model analysis can be used to extract dimensional information from high-frequency question categories, resulting in core query dimension features, statistical indicator features, and filtering condition features. Core query dimension features include subject dimensions and time dimensions; subject dimensions can include customer dimensions, securities dimensions, and brokerage dimensions, etc.; time dimensions can include year, month, day, and week, etc. Statistical indicator features include basic indicators and business identifier classification summary indicators; basic indicators can include transaction volume and transaction amount, etc.; business identifier classification summary indicators can include total amount of margin buying, total number of short selling transactions, and total amount of securities bought and returned, etc. Filtering condition features can include customer number, securities number, brokerage number, and time range, etc.

[0064] For example, for the high-frequency question category "Query the total amount of coupons sold and repaid in the month for branch 001", the extracted main dimension is "branch dimension" and the time dimension is "monthly"; the business identifier classification summary indicator is "total amount of coupons sold and repaid"; and the filter condition is "branch number 001".

[0065] Optionally, to facilitate subsequent summary statistics table construction and data querying, a list of high-frequency query features for high-frequency question categories can be generated. For example, the list can be compiled according to the category name, core query dimensions, statistical indicators, and filtering conditions of the high-frequency question categories, thus ensuring coverage of query needs corresponding to all margin trading business identifiers. For instance, the list entries could be: "Customer Monthly Business Summary Query (High-Frequency Question Category) - Customer (Subject Dimension) - Monthly (Time Dimension) - Total Margin Purchase Amount (Business Identifier Classification Summary Indicator) - Customer Number (Filter Condition)".

[0066] Step c: Based on the core query dimension features, statistical indicator features, and filtering condition features of high-frequency question categories, determine the table fields and field indexes of the pre-built blank statistical table.

[0067] Construct at least one blank statistical table and populate it with the core query dimension features, statistical indicator features, and filtering condition features obtained above as table fields. Furthermore, to further enable fast table retrieval, field indexes can be constructed, such as a field index combining customer number with the statistical month, etc. This embodiment does not impose any restrictions on this.

[0068] The system automatically constructs summary statistics tables based on the core dimension combinations of high-frequency question categories, using the dimension fields as the primary key or composite index fields. It's important to note that the number of summary statistics tables is related to the core dimension combinations of the high-frequency question categories. For example, for the high-frequency query categories "Customer Monthly Margin Purchase Total Amount Query," "Customer Monthly Short Sell Total Quantity Query," and "Customer Monthly Securities Purchase and Return Summary Amount Query," the corresponding core dimension combination is customer ID combined with the statistical month, so the corresponding summary statistics table could be "Margin Trading_Customer_Monthly_Statistics Table." Similarly, for the high-frequency query categories "Securities Daily Short Sell Transaction Quantity Query" and "Securities Daily Margin Purchase Transaction Amount Query," the corresponding core dimension combination is securities ID combined with the statistical date, so the corresponding summary statistics table could be "Margin Trading_Securities ID_Daily_Summary Table." And for the high-frequency query category "Branch Department Weekly Securities Purchase and Return Summary Amount Query," the corresponding core dimension combination is branch department number combined with the statistical week, so the corresponding summary statistics table could be "Margin Trading_Branch Department Number_Weekly_Summary Table."

[0069] Step d: Obtain and store the transaction log table, and determine the corresponding field values ​​for each table field based on the transaction log table.

[0070] Specifically, the transaction log table serves as the foundation for data tracing and is used to summarize and populate the field values ​​of the summary statistics table. For example, for the summary statistics table "Margin Trading_Customer_Monthly_Statistics Table," the data tracing for the "Margin Purchase Amount" field involves retrieving detailed transaction records from the corresponding transaction log table for transactions identified as margin purchases, and then summing the amounts based on the summarized monthly time range. In other words, after generating the table fields corresponding to different dimensions of the summary statistics table, a data input task is generated based on the transaction log table, and the field values ​​corresponding to the different table fields are calculated based on the transaction log details.

[0071] Step e: Update the blank statistical table according to the table fields and their corresponding field values ​​and field indexes to obtain at least one summary statistical table, and store each summary statistical table.

[0072] The pre-built blank statistical table is populated based on the table fields, their corresponding field values, and field indexes to obtain the final summary statistical tables of different dimensions. The generated summary statistical tables of different dimensions are then stored in tables, as is the transaction log table.

[0073] Optionally, the index structure of the statistics table can be optimized based on the frequency of queries to improve subsequent query efficiency; space can be automatically reserved for field expansion to adapt to the needs of adding new business identifiers and query dimensions in the future, without having to rebuild the summary statistics table.

[0074] Step f: Generate the table association information for each summary statistics table, and generate a summary statistics list based on the table association information for each summary statistics table.

[0075] The table relationship information may include table name, table field list, and index dimension combination, etc., and a summary table statistics list is generated based on the table relationship information of each summary statistics table. For example, a reference format for the summary table statistics list can be as follows:

[0076] A. Table Name: Margin Trading_Client_Monthly_Summary Table;

[0077] Dimension combination: Customer number + statistical month;

[0078] Field list: Customer ID, statistical month, total amount of margin purchases and total number of short sales, etc.

[0079] B. Table Name: Margin Trading_Client_Daily_Summary Table;

[0080] Dimension combination: Customer ID + Statistics Date;

[0081] Field list: Customer ID, statistical date, total amount of margin purchases, etc.;

[0082] Optionally, the table fields of the summary statistics table may also include the batch number of the data source, the start identifier of the data source, and the end identifier of the data source, which are used to mark the original data source and origin of the data to be traced and summarized, so as to facilitate subsequent data verification.

[0083] Understandably, transaction logs are fine-grained raw transaction logs, with a single client potentially generating tens of thousands of transaction records per day, and the total transaction data volume for the entire brokerage firm reaching hundreds of millions. High-frequency queries, such as "a client's total monthly margin purchase amount," are essentially aggregation queries. Directly querying the transaction log requires a full table scan and complex aggregation calculations, which is extremely time-consuming and cannot meet users' requirements for fast query response times. The solution provided by the summary statistics table is to pre-process the aggregation calculations for high-frequency queries, performing summations and other aggregation calculations across different data dimensions in advance, and storing the results in the summary statistics table. When users query, they only need to read the pre-calculated summary values, eliminating the need for recalculation and significantly improving efficiency.

[0084] Furthermore, the ability of large models to convert natural language to SQL is directly affected by the complexity of the SQL. The original transaction log table has many fields, including redundant fields such as transaction ID, fees, and settlement status, and requires frequent use of complex syntax such as SUM and GROUP. Large models are prone to problems such as missing filter conditions, incorrect aggregate functions, and misspelled field names. In contrast, the structure of the summary statistics table is perfectly adapted to high-frequency query needs, significantly simplifying the SQL generation logic and thus reducing the error rate of NL2SQL to a certain extent, while ensuring both the timeliness and accuracy of the data output results.

[0085] By using the summary statistics table list, priority matching rule prompt text, and structured query language SQL statement query scenario examples based on the above method to generate prompt word templates, the accuracy of prompt word template generation is significantly improved.

[0086] The technical solution of this invention parses the obtained margin trading data query question text to determine the time dimension characteristics of the query question. When it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day, a prompt word template is obtained. Based on the margin trading data query question text and the prompt word template, and using a pre-selected intelligent question answering model, the target SQL query statement corresponding to the margin trading data query question text is obtained and executed. The target SQL query statement is used to query data from a pre-built and stored summary statistics table or a pre-acquired and stored transaction flow table, generating margin trading data query results. In the process of generating the target SQL query statement, a prompt word template containing a list of summary statistics tables and priority matching rules is used. This allows the intelligent question answering model to prioritize the retrieval of summary statistics tables based on the prompt word template, improving the efficiency of SQL query statement generation and accurately guiding the model to generate the SQL statement for querying summary statistics tables. This improves the data query efficiency in the margin trading scenario and ensures the real-time, complete, and accurate data query.

[0087] Furthermore, to achieve real-time updates of the summary statistics table and ensure the accuracy of its content, in one optional embodiment, after updating the blank statistics table according to the table fields and their corresponding field values ​​and field indexes to obtain at least one summary statistics table, and storing each summary statistics table, the method further includes: when it is detected that the current time meets the preset non-trading period judgment condition, obtaining the first incremental transaction flow under the non-trading period, and updating the associated summary statistics table based on the preset non-trading period using the first incremental transaction flow; when it is detected that the current time meets the preset trading period judgment condition, obtaining the second incremental transaction flow under the trading period, and updating the associated summary statistics table based on the preset daily update time period using the second incremental transaction flow.

[0088] Let the current time be designated as day T, and other times be designated as day T-1 or earlier. The first incremental transaction flow is the most detailed margin trading flow data for day T-1, including all historical cumulative data and new data from the previous day. Use the daily non-trading period, such as 02:00-04:00. This can be pre-set by relevant technical personnel, avoiding peak trading hours of 9:30-11:30 and 13:00-15:00 to prevent excessive consumption of business system resources. Based on the preset non-trading period, use the first incremental transaction flow to update the associated summary statistics table.

[0089] The execution granularity for the first incremental transaction log on day T-1 is set to incremental update by default, processing only transaction data added or changed on the previous day. A full update can be performed once during the last non-trading session of each month to ensure data consistency. Its priority can be set to regular high priority, allocating resources preferentially during system scheduling to ensure that the conversion and updating of all historical transaction log data is completed before the next day's trading session (e.g., before 09:00). Task configurations, including task type, execution time, data range, and update method, can be automatically generated and submitted to an asynchronous task queue. The queue is sorted by priority to ensure that this task is scheduled first.

[0090] For the most detailed margin trading transaction data of the current trading session (Day T), only incremental data within the preset daily update time period is processed. For example, only incremental data up to the most recent 10 minutes is processed. If the task is executed at 10:00 on Day T, the new transaction data from 09:30 to 09:50 is processed; if it is executed at 10:10, the new transaction data from 09:50 to 10:00 is processed.

[0091] The daily update cycle can be preset by relevant technical personnel according to actual needs, for example, executing every 10 minutes, starting at 09:30 on day T and stopping at 15:00 after the transaction ends. The execution granularity is incremental, capturing only newly added transaction data within the most recent 10 minutes, i.e., the second incremental transaction data. This second incremental transaction data is used to update the associated summary statistics table, avoiding duplicate processing of already updated data. The priority can be set to medium priority to avoid resource contention with historical data update tasks and user query tasks. The processing mode can be set to small-batch automatic conversion, controlling the data volume processed each time to within 10,000 records, reducing database lock waiting time. Tasks are automatically generated according to scheduled rules and submitted to an asynchronous task queue, which schedules execution according to time order and priority.

[0092] Furthermore, this task targets transaction data within a very small window from the current time of day T to the most recent 10 minutes prior. For example, if a user submits a query for day T data at 10:05, and the task execution time 10 minutes ago was 10:00, the window data consists of new transactions from 10:00 to 10:05. This task is automatically triggered only when the target user's query involves day T data.

[0093] Automatically execute data input tasks in the asynchronous task queue to achieve batch conversion and updating of the most detailed transaction data of margin trading and securities lending into multi-dimensional summary statistics tables without manual intervention.

[0094] Specifically, for routine historical data update tasks, during non-trading hours each day, the task is automatically retrieved from the asynchronous task queue, and the most detailed margin trading transaction data for days less than or equal to T-1 is read according to the task configuration. Incremental updates read transaction data for T-1 days, and full updates read all historical transaction data. Transaction data is grouped by dimensions in the summary statistics table, such as customer number combined with the statistical month, and the summary value is calculated according to statistical indicator rules such as summation and counting. For example, for the margin buying transaction data of customer 000123 in 202410, the total margin buying amount is summed. The summary results can be written to the statistics table using a batch update method: if the record for that customer combined with the statistical month already exists, the numerical fields are updated; if it does not exist, a new record is created. For example, for the transaction data "Customer No. 000123, Statistical Month 202410, Margin Purchase Amount 50,000 yuan", after conversion, the "Total Margin Purchase Amount" field of the corresponding record in "Margin Trading_Customer_Monthly_Summary Table" will be updated from the original amount of 100,000 yuan to 150,000 yuan.

[0095] After the update is completed, verify whether the total sum of each dimension in the summary statistics table is consistent with the total sum of the original transaction data. For example, if the total financing purchase amount of all customers 202410 is equal to the total financing purchase amount of 202410 in the transaction table, the verification passes and the update status is updated to a successful status; otherwise, trigger the retry mechanism, and if the retry fails, notify the operation and maintenance personnel with an alarm.

[0096] For the near real-time update task, the task is retrieved from the task queue every 10 minutes, and the newly added transaction data up to the most recent 10 minutes from day T is read. Using the same grouping and statistical rules as historical data updates, the newly added transaction data is incrementally transformed. For example, on day T (assumed to be 2024 / 10 / 25), customer 000123 added 2 margin purchase transactions between 09:30 and 09:50, totaling 30,000 yuan. The "Total Margin Purchase Amount" field for customer 20241025 in the "Margin Trading_Customer_Daily_Summary Table" is updated.

[0097] For daily window period update tasks, the system immediately retrieves transaction data for the extremely short window period from the current moment to the most recent 10 minutes after the task is triggered by a query from the target user. A simplified transformation logic can be used, simply grouping and summing by the statistical table dimension, without complex data cleaning, to quickly update the corresponding fields in the statistical table. For example, if customer 000123 has one short selling transaction of 500 shares during the window period, this is directly added to the "Total Short Selling Quantity" field of the "Margin Trading_Customer_Daily_Summary Table".

[0098] In an optional embodiment, after parsing the text of the margin trading data query question and determining the time dimension characteristics of the query question, the method further includes: if the text of the margin trading data query question meets the preset daily data query judgment conditions based on the text initiation time and the time dimension characteristics of the query question, then the window time period is determined based on the daily update time period and the text initiation time; the newly added transaction flow under the window time period is obtained, and the newly added transaction flow is used to update the associated summary statistics table, and after the summary statistics table is updated, the prompt word template is obtained.

[0099] For example, if the daily update period is 10 minutes, the last update time was 2025 / 10 / 10 / 09:10, and the text initiation time was 2025 / 10 / 10 / 09:15, then the window time period is the time range of 2025 / 10 / 10 / 09:10 to 2025 / 10 / 10 / 09:15. The system retrieves new transaction records within the window time period and, based on the implementation process described above for supplementary update tasks during the daily window period, updates the associated summary statistics table using these new transaction records. After the summary statistics table is updated, the system retrieves the prompt word template.

[0100] Only when the summary statistics table data is accurate and updated in a timely manner can the intelligent question-answering model return the correct results. If a summary statistics table fails to update, the prompt words can be set to temporarily block the table, guiding the intelligent question-answering model to query the original transaction record table and avoid returning incorrect data.

[0101] In one optional embodiment, after generating the margin trading data query results, the prompt word template is updated based on the margin trading data query question text.

[0102] When the preset prompt word template update time is reached, such as 7 days, the system retrieves the margin trading data query question texts for all users within that time range, updates the high-frequency question categories based on the corresponding margin trading data query question texts for all users, updates the multi-dimensional summary statistics table list based on the updated high-frequency question categories, and updates the prompt word template based on the updated multi-dimensional summary statistics table list to ensure the real-time, comprehensive, and accurate nature of the prompt word template.

[0103] Furthermore, the prompt word template can be updated based on the margin trading data query question text and its corresponding query results. Specifically, the accuracy of the margin trading data query question text is verified based on the corresponding query results. This verification can be performed manually by relevant technical personnel. If the verification passes, the margin trading data query question text will be used as the question text for updating the high-frequency question category; if the verification fails, the margin trading data query question text will be removed and will not be included in the update of the high-frequency question category.

[0104] The closed-loop optimization stores the query record, namely the margin trading data query results for the target user's margin trading data query problem, including information such as whether the window period update was triggered, execution time, model query data source, and query result satisfaction. This provides data support for subsequent high-frequency problem detection, summary statistics table iteration, task rule optimization, and prompt word template optimization, forming a closed-loop iterative system of log collection, requirement mining, statistics table construction, data update, query execution, and log feedback to continuously improve the accuracy of query optimization.

[0105] Example 2

[0106] Figure 2 This is a schematic diagram of the flow structure of a data query method based on a financial and securities lending scenario provided in Embodiment 2 of the present invention. This embodiment provides a preferred example based on the above embodiments.

[0107] The specific implementation steps for generating prompt word templates are as follows:

[0108] S21. Obtain several historical margin trading data query texts submitted by historical users under a preset historical time period, and perform text preprocessing operations on each historical margin trading data query text to obtain each standard margin trading data query text.

[0109] S22. Extract semantic features from the query text of margin trading data for each standard, and generate text semantic feature vectors corresponding to the query text of margin trading data for each standard.

[0110] S23. Based on the semantic feature vectors of each text, perform text clustering on each standard margin trading data query text to obtain at least one semantically similar question category; each semantically similar question category includes at least one semantically similar standard margin trading data query text.

[0111] S24. Based on the number of standard margin trading data query texts contained in each semantically similar question category, determine the high-frequency question categories, and perform feature analysis on the high-frequency question categories to determine the core query dimension features, statistical indicator features, and filtering condition features.

[0112] S25. Based on the core query dimension features, statistical indicator features, and filtering condition features of high-frequency problem categories, determine the table fields and field indexes of the pre-built blank statistical table, obtain and determine the corresponding field values ​​of the table fields according to the obtained transaction flow table.

[0113] S26. Update the blank statistical table according to the table fields and their corresponding field values ​​and field indexes to obtain at least one summary statistical table, and store each summary statistical table.

[0114] S27. Generate the table association information for each summary statistics table, and generate a summary statistics list based on the table association information for each summary statistics table.

[0115] S28. Construct a prompt word template based on the summary table statistical list, priority matching rule prompt text, and SQL statement query scenario examples.

[0116] The specific implementation steps for data querying in margin trading scenarios are as follows:

[0117] S31. Obtain the target user's margin trading data query question text, and perform text parsing on the margin trading data query question text to determine the time dimension characteristics of the query question.

[0118] S32. Based on the text initiation time and query time dimension characteristics of the margin trading data query question text, determine whether the margin trading data query question text meets the preset judgment conditions for the data query of the day. If yes, execute S33-S34; otherwise, execute S35.

[0119] S33. Determine the window time period based on the daily update time period and the text initiation time.

[0120] S34. Obtain the new transaction data under the window time period, and use the new transaction data to update the associated summary statistics table. After the summary statistics table is updated, obtain the prompt word template.

[0121] S35. Obtain the prompt word template.

[0122] S36. Based on the margin trading data query question text and prompt word template, and using the pre-selected intelligent question-answering model, obtain the target SQL query statement corresponding to the margin trading data query question text.

[0123] S37. Execute the target SQL query statement to query the data in the pre-built and stored summary statistics table or the pre-acquired and stored transaction flow table, generate the margin trading data query results, and feed the margin trading data query results back to the target user.

[0124] The specific implementation method for the real-time update process of the summary statistics table is as follows:

[0125] Historical data routine update task: The execution time is during the daily non-trading hours, the execution granularity is ≤T-1 day full / incremental transaction data, and the execution priority is regular high priority to ensure that the automatic conversion and update of historical data is completed before the next day's trading.

[0126] Daily near real-time update task: The execution cycle is 10 minutes, the execution granularity is the incremental transaction data up to the most recent 10 minutes from day T, the execution priority is medium priority, and a small batch automatic conversion mode is adopted to avoid consuming too many system resources;

[0127] Daily window period supplementary update task: The execution trigger condition is that the user query involves data from day T, the execution granularity is the extremely small window period of the current time to the last 10 minutes, the execution priority is the highest priority, the execution time is ≤1 second, and it does not affect the user query experience.

[0128] The task generation methods for the above three update processes are as follows:

[0129] Historical task queue: caches historical data and regular update tasks, supports daily scheduled dequeueing and execution, automatically retry 3 times after failure, with the retry interval gradually increasing.

[0130] Near real-time task queue: Caches near real-time updated tasks for the day, supports scheduled dequeueing and execution every 10 minutes, retryes immediately after failure, and records the exception and issues an alarm if it still fails.

[0131] Window Period Supplement Task Queue: Caches the supplementary update tasks for the current window period, supports on-demand triggering and priority dequeueing for execution, and immediately retryes and quickly provides feedback to the user query process after failure.

[0132] Compared with the prior art, the technical solution of this embodiment has the following significant advantages:

[0133] 1. Maximize query efficiency: Pre-updated data avoids large-scale data intrusion during queries, automatic conversion between pipelines and statistical tables reduces manual time consumption, and automatic keyword suggestions guide large models to prioritize queries of small statistical tables, ultimately reducing SQL execution time by more than 90% and user query response time to ≤1 second.

[0134] 2. Significantly reduce labor costs: No need to manually build statistical table structures or write statistical logic, no need to manually edit and update NL2SQL prompts. The entire process is automated, reducing manual configuration workload by more than 95%, thus reducing labor costs and the probability of errors.

[0135] 3. Balancing data integrity and real-time performance: Historical data for ≤T-1 days is updated daily with full coverage, data for T days is updated almost in real-time within 10 minutes, and data during the window period is rapidly supplemented as needed, meeting the timeliness requirements of margin trading business for data across different time dimensions.

[0136] 4. Rationalization of resource usage: Historical tasks are executed during non-trading hours, near real-time tasks are executed in small batches on the same day, and tasks during window periods are executed in extremely small batches, avoiding peak business hours and reducing system resource usage by more than 60%.

[0137] 5. High flexibility and scalability: The statistical table automatically reserves expansion space, supports the addition of new business identifiers and query dimensions, and the prompt words are automatically updated synchronously. It can be seamlessly integrated into the existing NL2SQL system of financial institutions without large-scale transformation and has a wide range of applications.

[0138] In summary, this invention achieves full-process automation, significantly improves query efficiency, reduces labor costs, and optimizes system resource usage, while also ensuring data integrity and real-time performance. It covers all margin trading business identifiers and multi-dimensional query needs, and can bring significant improvements in management efficiency to financial institutions.

[0139] Example 3

[0140] Figure 3 This is a schematic diagram of a data query device based on a margin trading scenario provided in Embodiment 3 of the present invention. The data query device based on a margin trading scenario provided in this embodiment of the present invention is applicable to data querying in margin trading scenarios. This data query device based on a margin trading scenario can be implemented in hardware and / or software, such as... Figure 3 As shown, the device includes: a query question text acquisition module 301, a prompt word template acquisition module 302, a target query statement generation module 303, and a target query statement execution module 304. Among them,

[0141] The query question text acquisition module 301 is used to acquire the margin trading data query question text of the target user, and to perform text parsing on the margin trading data query question text to determine the time dimension features of the query question;

[0142] The prompt word template acquisition module 302 is used to acquire a prompt word template if, based on the text initiation time and time dimension characteristics of the margin trading data query question text, it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day. The prompt word template includes a pre-constructed list of summary statistics tables, priority matching rule prompt text, and SQL statement query scenario examples. The list of summary statistics tables includes table association information of at least one summary statistics table. The summary statistics table is pre-generated based on pre-determined high-frequency margin trading query question texts.

[0143] The target query statement generation module 303 is used to obtain the target SQL query statement corresponding to the margin trading data query question text based on the margin trading data query question text and the prompt word template, and on the basis of a pre-selected intelligent question answering model.

[0144] The target query statement execution module 304 is used to execute the target SQL query statement, perform data query on the pre-built and stored summary statistics table or the pre-acquired and stored transaction flow table, generate margin trading data query results, and feed back the margin trading data query results to the target user.

[0145] The technical solution of this invention parses the obtained margin trading data query question text to determine the time dimension characteristics of the query question. When it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day, a prompt word template is obtained. Based on the margin trading data query question text and the prompt word template, and using a pre-selected intelligent question answering model, the target SQL query statement corresponding to the margin trading data query question text is obtained and executed. The target SQL query statement is used to query data from a pre-built and stored summary statistics table or a pre-acquired and stored transaction flow table, generating margin trading data query results. In the process of generating the target SQL query statement, a prompt word template containing a list of summary statistics tables and priority matching rules is used. This allows the intelligent question answering model to prioritize the retrieval of summary statistics tables based on the prompt word template, improving the efficiency of SQL query statement generation and accurately guiding the model to generate the SQL statement for querying summary statistics tables. This improves the data query efficiency in the margin trading scenario and ensures the real-time, complete, and accurate data query.

[0146] Optionally, the device further includes:

[0147] The high-frequency problem category determination module is used to obtain several historical margin trading data query texts submitted by historical users under a preset historical time period before obtaining the prompt word template, and determine the high-frequency problem category based on each of the historical margin trading data query texts;

[0148] The feature parsing module is used to perform feature parsing on the high-frequency question categories to determine the core query dimension features, statistical indicator features, and filtering condition features;

[0149] The table field determination module is used to determine the table fields and field indexes of a pre-built blank statistical table based on the core query dimension features, statistical indicator features, and filtering condition features of the high-frequency problem category.

[0150] The field value generation module is used to acquire and store the transaction flow table, and determine the field values ​​corresponding to the table fields based on the transaction flow table.

[0151] The summary statistics table generation module is used to update the blank statistics table according to the table fields and their corresponding field values ​​and field indexes to obtain at least one summary statistics table, and to store each summary statistics table.

[0152] The table list generation module is used to generate table association information for each of the summary statistics tables, and generate a summary statistics list based on the table association information of each of the summary statistics tables.

[0153] Optional, a high-frequency problem category determination module, specifically used for:

[0154] Perform text preprocessing on the historical margin trading data query texts to obtain the standard margin trading data query texts.

[0155] Semantic features are extracted from the standard margin trading data query texts, and text semantic feature vectors corresponding to each standard margin trading data query text are generated.

[0156] Based on the semantic feature vectors of each text, text clustering is performed on each of the standard margin trading data query texts to obtain at least one semantically similar question category; each semantically similar question category includes at least one semantically similar standard margin trading data query text.

[0157] The high-frequency question categories are determined based on the number of standard margin trading data query texts contained in each of the semantically similar question categories.

[0158] Optionally, the device further includes:

[0159] The first table update module is used to update the blank statistical table according to the table fields and their corresponding field values ​​and field indexes to obtain at least one summary statistical table, and store each summary statistical table. When it is detected that the current time meets the preset non-trading period judgment condition, the module obtains the first incremental transaction flow under the non-trading period, and updates the associated summary statistical table based on the preset non-trading period using the first incremental transaction flow.

[0160] The second table update module is used to obtain the second incremental transaction flow under the current trading period when the current time meets the preset judgment conditions of the current trading period, and update the associated summary statistics table based on the preset update time period of the current day using the second incremental transaction flow.

[0161] Optionally, the device further includes:

[0162] The window time period determination module is used to determine the window time period after parsing the text of the margin trading data query question and determining the time dimension features of the query question. If the text of the margin trading data query question is determined to meet the preset daily data query judgment conditions based on the text initiation time and the time dimension features of the query question, then the window time period is determined based on the daily update time period and the text initiation time.

[0163] The third table update module is used to obtain the new transaction flow under the window time period, and use the new transaction flow to update the associated summary statistics table. After the summary statistics table is updated, the prompt word template is obtained.

[0164] Optionally, the device further includes:

[0165] The prompt word template update module is used to update the prompt word template based on the margin trading data query question text after the margin trading data query results are generated.

[0166] The data query device based on the margin trading scenario provided in the embodiments of the present invention can execute the data query method based on the margin trading scenario provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0167] Example 4

[0168] Figure 4 A schematic diagram of an electronic device 40 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0169] like Figure 4As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded from storage unit 48 into the RAM 43. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.

[0170] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0171] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as data query methods based on a two-way data retrieval scenario.

[0172] In some embodiments, the data query method based on a margin trading scenario can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the data query method based on a margin trading scenario described above can be performed. Alternatively, in other embodiments, processor 41 can be configured to perform the data query method based on a margin trading scenario by any other suitable means (e.g., by means of firmware).

[0173] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0174] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0175] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0176] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0177] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0178] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0179] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0180] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A data query method based on a margin trading scenario, characterized in that, include: Obtain the target user's margin trading data query question text, and perform text parsing on the margin trading data query question text to determine the time dimension features of the query question; If, based on the text initiation time and time dimension characteristics of the margin trading data query question text, it is determined that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day, then a prompt word template is obtained; The prompt word template includes a pre-built list of summary statistics tables, priority matching rule prompt text, and SQL statement query scenario examples; the list of summary statistics tables includes table association information for at least one summary statistics table; the summary statistics table is pre-generated based on pre-determined high-frequency margin trading query question text; Based on the margin trading data query question text and the prompt word template, and using a pre-selected intelligent question-answering model, the target SQL query statement corresponding to the margin trading data query question text is obtained. The target SQL query statement is executed to query data from a pre-built and stored summary statistics table or a pre-acquired and stored transaction log table, generating margin trading data query results, and then the margin trading data query results are fed back to the target user.

2. The method according to claim 1, characterized in that, Before obtaining the prompt word template, the method also includes: Obtain several historical margin trading data query texts submitted by historical users within a preset historical time period, and determine the high-frequency question category based on each of the historical margin trading data query texts; Feature analysis is performed on the high-frequency problem categories to determine the core query dimension features, statistical indicator features, and filtering condition features; Based on the core query dimension features, statistical indicator features, and filtering condition features of the high-frequency problem categories, determine the table fields and field indexes of the pre-constructed blank statistical table; Obtain and store the transaction log table, and determine the field values ​​corresponding to the table fields based on the transaction log table; Based on the table fields and their corresponding field values ​​and field indexes, update the blank statistical table to obtain at least one summary statistical table, and store each summary statistical table; Generate table association information for each of the summary statistics tables, and generate a summary statistics list based on the table association information of each of the summary statistics tables.

3. The method according to claim 2, characterized in that, The process of determining high-frequency problem categories based on the historical margin trading data query text includes: Perform text preprocessing on the historical margin trading data query texts to obtain the standard margin trading data query texts. Semantic features are extracted from the standard margin trading data query texts, and text semantic feature vectors corresponding to each standard margin trading data query text are generated. Based on the semantic feature vectors of each text, text clustering is performed on each of the standard margin trading data query texts to obtain at least one semantically similar question category; each semantically similar question category includes at least one semantically similar standard margin trading data query text. The high-frequency question categories are determined based on the number of standard margin trading data query texts contained in each of the semantically similar question categories.

4. The method according to claim 2, characterized in that, After updating the blank statistical table according to the table fields and their corresponding field values ​​and field indexes to obtain at least one summary statistical table, and storing each of the summary statistical tables, the method further includes: When the current time meets the preset non-trading period judgment condition, the first incremental transaction flow under the non-trading period is obtained, and the associated summary statistics table is updated based on the preset non-trading period using the first incremental transaction flow. When the current time meets the preset judgment conditions for the trading period of the day, the second incremental transaction flow under the trading period of the day is obtained, and the associated summary statistics table is updated using the second incremental transaction flow based on the preset update time period of the day.

5. The method according to claim 4, characterized in that, After parsing the text of the margin trading data query question and determining the time dimension features of the query question, the process further includes: If, based on the text initiation time and the time dimension characteristics of the margin trading data query question text, it is determined that the margin trading data query question text meets the preset daily data query judgment conditions, then the window time period is determined based on the daily update time period and the text initiation time. Obtain the new transaction data under the specified window time period, and use the new transaction data to update the associated summary statistics table. After the summary statistics table is updated, obtain the prompt word template.

6. The method according to claim 1, characterized in that, After generating the margin trading data query results, the following is also included: Update the prompt word template based on the query text of the margin trading data.

7. A data query device based on a margin trading scenario, characterized in that, include: The query question text acquisition module is used to acquire the margin trading data query question text of the target user, and to perform text parsing on the margin trading data query question text to determine the time dimension features of the query question; The prompt word template acquisition module is used to acquire a prompt word template if it is determined, based on the text initiation time of the margin trading data query question text and the time dimension characteristics of the query question, that the margin trading data query question text does not meet the preset judgment conditions for the data query of the day. The prompt word template includes a pre-built list of summary statistics tables, priority matching rule prompt text, and SQL statement query scenario examples; the list of summary statistics tables includes table association information for at least one summary statistics table; the summary statistics table is pre-generated based on pre-determined high-frequency margin trading query question text; The target query statement generation module is used to obtain the target SQL query statement corresponding to the margin trading data query question text based on the margin trading data query question text and the prompt word template, and based on the pre-selected intelligent question answering model. The target query statement execution module is used to execute the target SQL query statement, perform data query on the pre-built and stored summary statistics table or the pre-acquired and stored transaction flow table, generate margin trading data query results, and feed back the margin trading data query results to the target user.

8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the data query method based on the two-way financial scenario as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the data query method based on the two-way fusion scenario as described in any one of claims 1-6.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the data query method based on the financial and securities lending scenario according to any one of claims 1-6.