Data query method, device and equipment for judicial library system and medium

By constructing a dataset based on a base table and fine-tuning the NL2SQL model using LORA technology, and combining it with a Router model to identify query intent, the problems of difficult data labeling and complex business logic in the treasury system were solved, achieving efficient and accurate structured data query services.

CN121743337APending Publication Date: 2026-03-27RICHFIT INFORMATION TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies in treasury systems suffer from difficulties in data labeling, complex business logic, and frequent changes in the underlying data structure, making it difficult for the NL2SQL model to effectively perform structured data queries.

Method used

By constructing a dataset based on a base table, question-answer pairs are generated using manual annotation and template expansion. The NL2SQL model is fine-tuned using LORA technology, and a Router model is used to identify query intent, thus achieving automatic conversion from natural language commands to SQL queries.

Benefits of technology

It provides efficient and accurate data query services, can adapt to changes in business logic, does not require frequent model updates, and improves query convenience and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121743337A_ABST
    Figure CN121743337A_ABST
Patent Text Reader

Abstract

The invention provides a data query method and device for a judicial library system, equipment and a medium, and belongs to the technical field of data processing. Training by utilizing the first data set to obtain a plurality of NL2SQL models for different business systems, combining a financial query natural language instruction in the first data set and a bottom table used by an SQL query statement to obtain a second data set, and training by utilizing the second data set to obtain a Router model; according to a target financial query natural language instruction input by a user, a target bottom table is obtained based on the Router model, a target SQL query statement is obtained based on the NL2SQL model of the corresponding service system, the target SQL query statement is executed in the target bottom table, and a query result is obtained. Therefore, the problems that data labeling is difficult, business logic is complex and an underlying data structure is frequently changed are solved, and structured data query services of different business systems in a judicial-library system are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of data processing, in particular to a data query method and device for a treasurer system, equipment and medium. BACKGROUND

[0002] The treasurer system is an important tool for enterprise fund management, which can help enterprises improve fund management efficiency, enhance risk control ability, support strategic decision-making, and improve enterprise competitiveness. Among them, intelligent question and answer service is crucial to the operation of enterprises due to its efficient and accurate answering ability to user queries. Traditional neural network-based algorithm services have been relatively mature in meeting text-based answers, but for more complex query requirements, especially those involving structured data queries, more intelligent solutions are needed. The task of NL2SQL is to convert the questions or queries proposed by users in natural language into SQL query statements that computers can understand and execute, so as to achieve the purpose of retrieving the required information from the database. Currently, LLM (Large Language Models) also plays an important role in NL2SQL, which is a class of models capable of handling large-scale natural language tasks, such as the GPT series. They can understand the semantic and grammatical structure of natural language by learning a large amount of language data, and generate SQL queries corresponding to the input natural language queries. In practical applications, the application of NL2SQL+LLM technology in the treasurer system has the following problems:

[0003] Data annotation difficulty: NL2SQL task requires (question, answer) annotation pairs. The question is the question provided by the user, and the answer is the corresponding SQL statement. In the treasurer system, software engineers are often good at writing SQL query statements, but it is difficult for them to come up with valuable business questions. At the same time, business personnel understand the business, but they are not clear about how to associate with the tables in the database. How to effectively perform data annotation to train the NL2SQL model is a problem worth exploring;

[0004] Complex business logic: the treasurer system is a specific field, and its query requirements often have strong domain specificity. Querying a common aggregate indicator may require JOIN of five original tables, and the complete SQL statement is as long as 100 lines, even the most advanced ChatGPT is difficult to accurately generate such complex SQL statements;

[0005] Business data variability: the traditional NL2SQL architecture is difficult to adapt to changes in the underlying data structure during the construction of the treasurer system. Once the fields of the table change, the model needs to be retrained to meet the needs of the rapidly developing business. SUMMARY

[0006] Therefore, the present application aims to provide a data query method and device for a treasury system, equipment and medium, which can solve the problems of difficult data annotation, complex business logic and frequent changes in underlying data structure, and realize structured data query service of different business systems in the treasury system.

[0007] In a first aspect, the present application provides a data query method for a treasury system, the treasury system comprising a plurality of business systems, the method comprising the following steps:

[0008] Constructing a first data set based on base tables; wherein a plurality of question and answer pairs comprising financial query natural language instructions and corresponding SQL query statements are obtained by using artificial annotation; then a plurality of wide tables for different business systems are extracted from the obtained SQL query statements, which are used as base tables for NL2SQL models; finally, the question and answer pairs are expanded based on annotation templates or base table structures, and a first data set is generated;

[0009] A plurality of NL2SQL models for different business systems are trained using the first data set, and the base tables used by the financial query natural language instructions and SQL query statements in the first data set are combined to obtain a second data set, and a Router model is trained using the second data set;

[0010] According to the target financial query natural language instruction input by the user, the target base table is obtained based on the Router model, and the target SQL query statement is obtained based on the NL2SQL model of the corresponding business system, and the target SQL query statement is executed in the target base table to obtain the query result.

[0011] In a possible implementation, the plurality of question and answer pairs comprising financial query natural language instructions and corresponding SQL query statements are obtained by using artificial annotation, comprising the following steps:

[0012] Identify each data source in the treasury field, and collect data from each data source; wherein the data source comprises one or more of historical transaction records, account information, and fund flow details;

[0013] Preprocess the collected data, and generate questions for the treasury field based on the preprocessed data, which are used as financial query natural language instructions;

[0014] Annotate the corresponding SQL query statement for each question generated for the treasury field, and obtain a plurality of question and answer pairs.

[0015] In a possible implementation, the training of the first data set to obtain a plurality of NL2SQL models for different business systems includes the following steps:

[0016] Selecting a base model based on user needs;

[0017] Fine-tuning the base model by LORA method using the first data set to obtain a plurality of NL2SQL models for different business systems, so as to provide data query services for different business systems through the NL2SQL model; wherein the business system includes one or more of the account system, the fund system, and the settlement system.

[0018] In a possible implementation, the base table is obtained based on the Router model, including the following steps:

[0019] Preprocessing the target financial query natural language instruction input by the user and extracting key information; wherein the preprocessing includes text cleaning, and the key information includes time information, base table name and subject name;

[0020] Generating a target base table based on the Router model according to the key information.

[0021] In a possible implementation, after obtaining the query result, the query result is also subjected to standard processing; the standard processing includes one or more of table header arrangement, decimal point processing, and sorting.

[0022] In a possible implementation, the method further includes the following steps:

[0023] Setting a model update period;

[0024] According to the set model update period, the feedback data of the user is obtained, and the first data set is updated based on the feedback data, and the NL2SQL model and the Router model are fine-tuned using the updated first data set.

[0025] In a possible implementation, the method further includes the following steps:

[0026] Integrating the NL2SQL model for providing data query services for each business system to provide unified data query services for the treasurers system.

[0027] In a second aspect, the application provides a data query device for a treasurers system, the treasurers system including a plurality of business systems, the device including:

[0028] The constructing module is configured to construct a first data set based on a base table; wherein a plurality of question and answer pairs including a financial query natural language instruction and a corresponding SQL query statement are obtained by using a manual annotation method; a plurality of wide tables for different business systems are extracted from the obtained SQL query statements and used as base tables of an NL2SQL model; and the question and answer pairs are expanded based on an annotation template or a base table structure, and a first data set is generated;

[0029] The training module is configured to train a plurality of NL2SQL models for different business systems by using the first data set, and combine base tables used in the financial query natural language instructions and the SQL query statements in the first data set to obtain a second data set, and train a Router model by using the second data set.

[0030] The query module is configured to obtain a target base table based on the Router model according to a target financial query natural language instruction input by a user, obtain a target SQL query statement based on the NL2SQL model of a corresponding business system, and execute the target SQL query statement in the target base table to obtain a query result.

[0031] In a third aspect, the present application provides an electronic device, which comprises a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, and the machine readable instructions are executed by the processor to perform the steps of the data query method for the treasurer system according to the first aspect.

[0032] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, when the computer program is run by a processor, the steps of the data query method for the treasurer system according to the first aspect are executed.

[0033] The embodiment provides a data query method, device and equipment for a treasurer system and a medium. A first data set based on a base table is constructed. A plurality of question and answer pairs including a financial query natural language instruction and a corresponding SQL query statement are obtained by using a manual marking method. A plurality of wide tables for different business systems are extracted from the SQL query statement, and are used as base tables of an NL2SQL model. The question and answer pairs are expanded based on a marking template or a base table structure, and a first data set is generated. A plurality of NL2SQL models for different business systems are trained by using the first data set. A second data set is obtained by combining base tables used by the financial query natural language instruction and the SQL query statement in the first data set. A Router model is trained by using the second data set. A target base table is obtained based on the Router model according to a target financial query natural language instruction input by a user, and a target SQL query statement is obtained based on the NL2SQL model of a corresponding business system. The target SQL query statement is executed in the target base table, and a query result is obtained. Therefore, the technical combination of manual data marking and automatically generated training data effectively solves the problem of data marking. By abstracting complex business logic into a plurality of wide tables, the system can quickly adapt to changes in business logic without frequent model updates. The NL2SQL model for different business systems can accurately understand the natural language instruction of the user about the financial query, and automatically convert the natural language instruction into a SQL query statement for data query. BRIEF DESCRIPTION OF DRAWINGS

[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0035] Figure 1 A flowchart of the data query method for the treasurer system in an embodiment of the present application;

[0036] Figure 2 A structure diagram of the wide table in an embodiment of the present application;

[0037] Figure 3 A diagram of the MYSQL syntax in an embodiment of the present application;

[0038] Figure 4 A structure diagram of the Router-NService architecture in an embodiment of the present application;

[0039] Figure 5A flow chart of a process for obtaining a target base table based on the Router model according to an embodiment of the present application;

[0040] Figure 6 A structural block diagram of a data query device for a treasury system according to an embodiment of the present application;

[0041] Figure 7 A structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0042] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will be combined with the accompanying drawings for the embodiments of the present application to make a clear and complete description of the technical solutions in the embodiments of the present application. It should be understood that the accompanying drawings in the present application are only for the purpose of illustration and description, and are not used to limit the protection scope of the present application. In addition, it should be understood that the schematic drawings are not drawn according to the actual proportions. The flow charts used in the present application show the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow charts can not be implemented in sequence, and the steps without logical context relationship can be reversed in sequence or implemented simultaneously. In addition, one or more other operations can be added to the flow chart or removed from the flow chart under the guidance of the content of the present application by those skilled in the art.

[0043] In addition, the described embodiments are only some of the embodiments of the present application, not all the embodiments. The components of the embodiments of the present application described and indicated in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0044] It should be noted that the term “comprise” will be used in the embodiments of the present application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0045] Based on the technical problems proposed in the background art, the present application provides a data query method, device, equipment and medium for a treasury system, which can solve the problems of difficult data annotation, complex business logic and frequent changes in underlying data structure, and realize structured data query service of different business systems under the treasury system.

[0046] Referring to the drawings accompanying the specification Figure 1 In an embodiment, the present application provides a data query method for a treasury system, the treasury system comprising a plurality of business systems, the method comprising the following steps:

[0047] S1, a first data set based on the bottom table is constructed; wherein a plurality of question and answer pairs including financial query natural language instructions and corresponding SQL query statements are obtained in a manual annotation manner; then a plurality of wide tables for different business systems are extracted from the obtained SQL query statements, which are used as the bottom table of the NL2SQL model; finally, the question and answer pairs are expanded based on the annotation template or the bottom table structure, and a first data set is generated;

[0048] S2, a plurality of NL2SQL models for different business systems are trained using the first data set, and the bottom tables used by the financial query natural language instructions and SQL query statements in the first data set are combined to obtain a second data set, and a Router model is trained using the second data set;

[0049] S3, according to the target financial query natural language instruction input by the user, the target bottom table is obtained based on the Router model, and the target SQL query statement is obtained based on the NL2SQL model of the corresponding business system, and the target SQL query statement is executed in the target bottom table to obtain the query result.

[0050] Specifically, in step S1, a data set generation method combining man and machine is proposed.

[0051] First, through the judgment of business experts, a list of questions interested in the business field and corresponding SQL statements of underlying data queries are generated manually, that is, a plurality of question and answer pairs including financial query natural language instructions and corresponding SQL query statements are obtained in a manual annotation manner. The specific operation includes: (1) data source identification: through close cooperation with business experts, identify the key data sources in the treasury field, which may include historical transaction records, account information, fund flow details, etc.; (2) data collection: use automated tools and manual review in combination to collect data from each data source to ensure the integrity and accuracy of the data; (3) data preprocessing: clean and format the collected data to remove irrelevant or incorrect information and ensure data quality; (4) question generation: cooperate with business experts to generate a series of questions for the treasury field according to their professional knowledge and practical business experience, which will cover various business scenarios, from simple queries to complex analysis requirements; (5) data annotation: for each question generated, detailed annotation is performed in combination with actual data to ensure that each question can correspond to a specific data query requirement and obtain the corresponding SQL query method.

[0052] Next, the bottom table is constructed. The collected SQL query statements are refined into multiple wide tables through set judgment, which are used as the bottom table of the subsequent NL2SQL model. The wide table is a database table containing more fields, which removes specific business logic and is converted into more general and direct fields, so that the SQL generated by the subsequent NL2SQL model is more concise and efficient, thereby significantly improving the accuracy of model prediction. Among them, the problems of each business system of the treasurer business are relatively independent, the real-time data of the cooperation bank does not exist, and the characteristics of the separately processed features. Based on the characteristics, in the embodiment of the application, five wide tables with high cohesion and low coupling are designed, as shown in Table 1, and the specific table structure is shown in the accompanying drawings Figure 2 Meanwhile, the structures of the real-time table and the historical table are completely consistent, so as to reduce the complexity of the generated SQL and improve the prediction accuracy of the NL2SQL model.

[0053]

[0054] Table 1

[0055] Then, the bottom table dataset is constructed. There are mainly two ways: (1) automatic generation based on the annotation template; (2) automatic generation based on the bottom table structure.

[0056] Based on the labeled template automatic generation, first, the collected financial query natural language instructions and corresponding SQL query statements are converted into templates that do not depend on query values; then, the slots of the query template are linked with the database to generate a large number of SQL query examples; finally, after generating a large number of SQL query examples, the corresponding question and answer pairs are constructed. For example, the collected financial query natural language instructions and corresponding SQL query statements are "query the deposit amount of the whole group on each channel", "SELECT channel, SUM(amount) FROM bal_now GROUP BY channel"; the extracted templates have two kinds, the first kind of template question and corresponding template SQL are "[company] deposit amount on [channel]", "SELECT channel, SUM(amount) FROM bal_now WHERE channel = [channel] GROUP BY channel"; the second kind of template question and corresponding template SQL are "[company] deposit amount on each channel", "SELECT channel, SUM(amount) FROM bal_now GROUP BY channel"; through template expansion, the following multiple question and answer pairs including financial query natural language instructions and corresponding SQL query statements can be obtained, "how much is the deposit amount of Xifeng in the bank?", "SELECT channel, SUM(amount) FROM bal__now WHERE channel = bank GROUP BY channel"; "how much is the money fund of Shenfei in the financial company?", "SELECT channel, SUM(amount) FROM bal__now WHERE channel = financial company GROUP BY channel"; "how much is the money of Shenfei in the financial company?", "SELECT channel, SUM(amount) FROM bal_now WHERE channel = financial company GROUP BY channel". Through the automatic generation based on the labeled template, the data set close to the actual real demand can be generated with high business value and high accuracy.

[0057] Based on the bottom table structure automatic generation, referring to the description Figure 3 Based on the MYSQL syntax, the SQL statement can be automatically generated. In order to make it close to the actual business demand, it is necessary to further check whether the query question with the characteristics of the treasurer is generated. For example: in the grouping operation, the GROUPC is mainly filled through the social credit code, channel, plate, currency, opening bank, bank cooperation state, province and other fields; the numerical type fields such as original currency balance and RMB balance are mainly aggregated; when the channel is financial, the bank related fields such as opening bank and bank cooperation state cannot be queried. Through a series of rules, it is ensured that the generated SQL statement covers most of the queries and has business guiding significance. Through the automatic generation based on the bottom table structure, a large number of samples can be generated to increase the diversity of the data set to meet the diversified business needs.

[0058] Further, the question and answer pair generated by the above two ways can also be reconstructed, the question is regenerated by using a large language model (LLM), and the number of data sets is doubled.

[0059] Then, by executing the training data generation method provided in step S1, only 40 questions manually annotated as seed data for each of the three core business fields of the account system, the fund system, and the budget system are needed, and 20 to 30 groups of query templates can be automatically derived, and more than 5000 high-quality training data records can be generated. This process significantly reduces the time and cost of manual intervention, while ensuring the diversity and coverage of the data, providing a solid foundation for model learning.

[0060] In step S2, the NL2SQL model is mainly trained based on the rich training data generated in step S1. Specifically, the NL2SQL model can be defined as a function f: N→S, where N is a set of natural language queries, and S is a set of SQL queries. For any n∈N, f(n)=s, where s∈S is the SQL query equivalent to the natural language query n. With the rapid progress of large language models (LLM), the ability of the NL2SQL model to handle small sample data has been greatly improved. For example, open source models CHATGLM-6B and QWEN1.5-14B have shown excellent performance in general knowledge understanding in the financial field. However, in the face of the complexity of the treasurers' field, these models have encountered challenges in processing special named entities. For example, when analyzing queries such as "How much money does the group have in the financial company" and "How much money does the financial company have", the NL2SQL model needs to accurately distinguish the role of "financial company" in different contexts. The former is a channel for money flow, and the latter is the core subject of the query. In order to overcome this difficulty, the present application selects a base model (such as CHATGLM-6B or QWEN1.5-14B) based on user needs, and uses LORA technology for model fine-tuning. Through this technology, domain-specific knowledge can be quickly injected into the LLM, enabling it to accurately identify and process these special named entities, thereby exhibiting better adaptability and accuracy in the treasurers' field. Generally, after 5-10 EPOCH, the model can repeat the training data. In the embodiments of the present application, three NL2SQL models specifically for the three business systems of the treasurers' system (account system, fund system, and settlement system) are trained based on the rich training data generated in step S1. These models can accurately understand the natural language instructions of users about financial queries and automatically convert them into SQL query statements, effectively supporting users to query specific data in each system, greatly improving the convenience and accuracy of the query, and strengthening the practicality of the system and the user interaction experience.

[0061] In addition, a Router model is also set up in this application as a pre-processing of the NL2SQL model, aiming to analyze user intent and identify the underlying table that needs to be queried. Among them, the data set (question and answer pair) trained for NL2SQL is recombined into the data set (question, table name) of the classification model by parsing the table name used in SQL, and the open source model CHATGLM3-6B is trained using the LORA fine-tuning algorithm, usually 5-10 epochs, which can achieve a classification accuracy of 99.9% and has good scalability.

[0062] Referring to the drawings Figure 4 In the early stage of the construction of the treasurer, due to frequent changes in the underlying data structure and content, the system design adopts Router-NService architecture. The core advantage of this architecture is that it allows each business system to have an independent NL2SQL service Service. Such a design allows each business system to independently update and optimize its NL2SQL model according to its own data changes and business needs. This independence ensures that each business system can maintain optimal performance and response speed in a rapidly changing data environment, without affecting other business systems. This flexibility and independence greatly support the needs of agile development and rapid iteration.

[0063] In step S3, referring to the drawings Figure 5 When processing the target financial query natural language instruction input by the user, first, the target underlying table is obtained based on the Router model, including the following steps:

[0064] S301, pre-processing the target financial query natural language instruction input by the user and extracting key information; wherein the pre-processing includes text cleaning, and the key information includes time information, underlying table name and subject name.

[0065] S302, generating a target underlying table based on the Router model according to the key information.

[0066] In step S301, the target financial query natural language instruction input by the user is preprocessed, and key information is extracted, mainly including: text cleaning: irrelevant characters in the query are removed, such as punctuation marks and extra spaces, to ensure the purity and readability of the text; identification of plates: in the treasurers system, the secondary unit has the same name as the plate name. By judging whether the question contains "plate", it can accurately identify whether all units in the plate need to be queried, otherwise it is defaulted as a secondary single unit; entity recognition: Chinese named entity recognition technology is quite mature, for example, the accuracy rate of LAC open source tool has reached 95.5%. However, due to the flexible and variable writing method of business personnel for named entities, the model prediction is more difficult, and in view of the limited number of units under the treasurers system, the system uses enumeration method for mapping to ensure accuracy. The extracted entity name is used to load the data base table; extract time: time expression as a special entity, its accurate identification is crucial to improve the accuracy of NL2SQL. Using the open source NLP toolkit JioNLP, the related time text input by the user can be accurately identified and converted into a standard time period format, such as converting "last quarter" into [20240101, 20240331], so as to facilitate the accurate matching of date fields in subsequent SQL statements. The extracted time field is used to load the data base table; extract base table name: the user input is passed through the already trained domain classification model to obtain the table name, which is used for subsequent loading of data base table. This step ensures that the query request can be accurately mapped to the corresponding table structure in the database, thereby improving the accuracy and efficiency of data retrieval. In step S302, the key information extracted in step S301: time period, base table name, main body name, is filled into the template SQL of the base table and executed, and the result is stored in the memory. This step ensures the effective loading of data, providing necessary data basis for subsequent query processing.

[0067] After the target financial query natural language instruction input by the user is processed by the Router model to obtain the target base table, the NL2SQL model based on the corresponding business system is used to obtain the target SQL query statement. This step uses natural language processing technology to convert the user's query intention into an accurate SQL command, so that the database can be directly interacted with to perform a query operation and then generate a query result. In the embodiments of the present application, the query result returned from the database is parsed and formatted to ensure that the output result meets the user's expectations and the system's output standards. Specifically, it includes: organizing table headers: for numerical table headers, the system will intelligently select appropriate units such as "hundred million yuan", "ten thousand yuan" or "yuan" to ensure that the data presentation is both accurate and easy to understand; processing decimal points: for percentage type values, the system will automatically retain two decimal places to meet the specifications of financial reports and improve data readability; processing sorting: the system will sort the results in descending order of amount to allow users to quickly identify and analyze key data points and make more informed decisions.

[0068] It should be noted that in the present application, a model update period is also set; feedback data of users is obtained according to the set model update period, and the first data set is updated based on the feedback data, and the NL2SQL model and the Router model are fine-tuned and trained using the updated first data set, so that the query result is more accurate.

[0069] In addition, as the treasurership construction deepens and the business systems gradually stabilize, the frequency of changes in the data underlying environment decreases, and the system architecture can be timely converted from Router-NService to a more centralized Router-Service architecture. During this conversion process, a comprehensive assessment of the current business system state is first needed to determine the timing and conditions for conversion. Next, the NL2SQL services originally dispersed in various business systems are integrated into a unified service. This integration process may involve retraining or adjusting the NL2SQL model to ensure that the new model can meet the query needs of all business systems.

[0070] The data query method for a treasurership system provided in the present application provides a human-machine combined data set generation method to efficiently produce high-quality treasurership vertical training data, ensuring the accuracy and practicality of model training; to address the problem of complex business logic and frequent changes in underlying data structures during the treasurership construction process, the complex business logic is abstracted into multiple wide tables to meet different domain problems in multiple business scenarios, reducing the reasoning difficulty of the NL2SQL model and improving the accuracy of question and answer, while also quickly adapting to changes in business logic without the need for frequent model updates, improving the stability and reliability of the system.

[0071] The application also provides a data query device for a treasurer system, as shown in the accompanying drawings of the specification. Figure 6 The application also provides a data query device for a treasurer system, as shown in the accompanying drawings of the specification.

[0072] The construction module 601 is configured to construct a first data set based on a base table. First, a plurality of question and answer pairs including financial query natural language instructions and corresponding SQL query statements are obtained by manual annotation. Then, a plurality of wide tables for different business systems are extracted from the obtained SQL query statements, which are used as base tables of an NL2SQL model. Finally, the question and answer pairs are expanded based on an annotation template or a base table structure, and a first data set is generated.

[0073] The training module 602 is configured to train a plurality of NL2SQL models for different business systems by using the first data set, and combine the base tables used by the financial query natural language instructions and the SQL query statements in the first data set to obtain a second data set. The Router model is trained by using the second data set.

[0074] The query module 603 is configured to obtain a target base table based on the Router model according to a target financial query natural language instruction input by a user, and obtain a target SQL query statement based on the NL2SQL model of the corresponding business system, and execute the target SQL query statement in the target base table to obtain a query result.

[0075] In some embodiments, the construction module 601 obtains a plurality of question and answer pairs including financial query natural language instructions and corresponding SQL query statements by manual annotation, including: identifying each data source in the treasurer field, and collecting data from each data source; wherein the data source includes one or more of historical transaction records, account information, and fund flow details; preprocessing the collected data, and generating questions for the treasurer field based on the preprocessed data, which are used as financial query natural language instructions; and labeling a corresponding SQL query statement for each question generated for the treasurer field, to obtain a plurality of question and answer pairs.

[0076] In some embodiments, the training module 602 trains a plurality of NL2SQL models for different business systems by using the first data set, including: selecting a base model based on user demand; fine-tuning the base model by using the first data set through a LORA method to obtain a plurality of NL2SQL models for different business systems, so as to provide data query services for different business systems for users through the NL2SQL models; wherein the business system includes one or more of an account system, a fund system, and a settlement system.

[0077] In some embodiments, the query module 603 obtains a target base table based on the Router model, including: preprocessing the target financial query natural language instruction input by the user and extracting key information; wherein the preprocessing includes text cleaning, and the key information includes time information, base table name and subject name. According to the key information, the target base table is generated based on the Router model.

[0078] In some embodiments, the device further comprises:

[0079] A standard processing module is configured to, after obtaining the query result, further perform standard processing on the query result; the standard processing includes one or more of collating table headers, processing decimal points, and sorting.

[0080] In some embodiments, the device further comprises:

[0081] An updating module is configured to set a model updating period; obtain feedback data of the user according to the set model updating period, and update the first data set based on the feedback data, and fine-tune train the NL2SQL model and the Router model by using the updated first data set.

[0082] In some embodiments, the device further comprises:

[0083] An integration module is configured to integrate the NL2SQL models respectively providing data query services for each of the business systems, so as to provide unified data query services for the treasurers system.

[0084] The application provides a data query device for a treasurer system. A first data set based on a base table is constructed through a construction module. A plurality of NL2SQL models for different business systems are obtained through a training module by training the first data set. A second data set is obtained by combining the base tables used in the financial query natural language instructions and the SQL query statements in the first data set. A Router model is obtained by training the second data set. A target base table is obtained based on the Router model according to a target financial query natural language instruction input by a user, a target SQL query statement is obtained based on the NL2SQL model of the corresponding business system, the target SQL query statement is executed in the target base table, and a query result is obtained. Therefore, the technical combination of artificial data labeling and automatically generated training data effectively solves the problem of data labeling. The complex business logic is abstracted into a plurality of wide tables, so that the system can quickly adapt to the change of the business logic without frequent model updating. The NL2SQL model is constructed for different business systems, the natural language instruction about the financial query of the user can be accurately understood, the SQL query statement can be automatically converted, and data query can be performed.

[0085] Based on the same concept of the application, the specification is attached Figure 7 As shown in the figure, the electronic device 700 provided by the embodiment of the application includes at least one processor 701, at least one network interface 704 or other user interface 703, a memory 705, and at least one communication bus 702. The communication bus 702 is used to realize the connection and communication between the components. The electronic device 700 can optionally include a user interface 703, including a display (for example, a touch screen, an LCD, a CRT, holographic imaging (Holographic) or a projector (Projector), etc.), a keyboard or a clicking device (for example, a mouse, a trackball, a touchpad or a touch screen, etc.).

[0086] The memory 705 can include a read-only memory and a random access memory, and provide instructions and data for the processor 701. A part of the memory 705 can also include a non-volatile random access memory (NVRAM).

[0087] In some embodiments, the memory 705 stores the following elements, executable modules or data structures, or a subset of them, or an extended set of them:

[0088] An operating system 7051 includes various system programs for realizing various basic services and processing hardware-based tasks;

[0089] The application program module 7052 includes various application programs, such as a launcher, a media player, a browser, and the like, for implementing various application services.

[0090] In the embodiment of the present application, the processor 701 is configured to execute the steps in the method for querying data of a treasuries system by invoking the program or instruction stored in the memory 705, so as to solve the problems of difficult data labeling, complex business logic, and frequent changes in underlying data structure, and to implement the structured data query service of different business systems in the treasuries system.

[0091] The present application also provides a computer readable storage medium having a computer program stored thereon, and the computer program is configured to execute the steps in the method for querying data of a treasuries system when executed by a processor.

[0092] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, or the like, and the computer program stored on the storage medium is configured to execute the method for querying data of a treasuries system when executed.

[0093] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other manners. The described device embodiments are merely illustrative, for example, the division of units is only a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection between units can be indirect coupling or communication connection through some communication interfaces, and can be electrical, mechanical or other forms.

[0094] The units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0095] In addition, each functional unit in the embodiments provided in the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.

[0096] If the functions are implemented in the form of business function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that contributes to the present application or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0097] Finally, it should be noted that: the above embodiments are only specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, but not to limit them. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily think of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present application, or replace some technical features with equivalent ones. The modification, change or replacement does not make the corresponding technical solution deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A data query method for a treasury system, characterized in that, The treasury system includes multiple business systems, and the method includes the following steps: The first dataset is constructed based on a base table. First, several question-answer pairs, including financial query natural language commands and corresponding SQL query statements, are obtained by manual annotation. Then, multiple wide tables for different business systems are extracted from the obtained SQL query statements to serve as the base table for the NL2SQL model. Finally, the question-answer pairs are expanded based on the annotation template or the base table structure to generate the first dataset. Multiple NL2SQL models for different business systems are trained using the first dataset, and the tables used by the financial query natural language instructions and SQL query statements in the first dataset are combined to obtain the second dataset. The Router model is trained using the second dataset. Based on the user's input of the target financial query natural language command, the target base table is obtained based on the Router model, and the target SQL query statement is obtained based on the NL2SQL model of the corresponding business system. The target SQL query statement is then executed on the target base table to obtain the query result.

2. The data query method for a treasury system according to claim 1, characterized in that, The process of obtaining several question-and-answer pairs, including financial query natural language commands and corresponding SQL query statements, through manual annotation includes the following steps: Identify various data sources within the treasury domain and collect data from each of these data sources; wherein, the data sources include one or more of historical transaction records, account information, and fund flow details; The collected data is preprocessed, and the preprocessed data is used to generate questions for the treasury domain, which are then used as natural language commands for financial inquiries. For each question generated in the treasury domain, the corresponding SQL query statement is labeled, resulting in several question-answer pairs.

3. The data query method for a treasury system according to claim 2, characterized in that, The process of training multiple NL2SQL models for different business systems using the first dataset includes the following steps: Select the basic model based on user needs; The base model is fine-tuned and trained using the LORA method with the first dataset to obtain multiple NL2SQL models for different business systems, so as to provide users with data query services for different business systems through the NL2SQL models; wherein, the business system includes one or more of the account system, fund system, and settlement system.

4. The data query method for a treasury system according to claim 3, characterized in that, The process of obtaining the target base table based on the Router model includes the following steps: The user-inputted financial query natural language command is preprocessed and key information is extracted; wherein, the preprocessing includes text cleaning, and the key information includes time information, base table name and subject name; The target base table is generated based on the key information and the Router model.

5. The data query method for a treasury system according to claim 4, characterized in that, in, After obtaining the query results, the query results are further processed according to standard procedures; the standard processing includes one or more of the following: sorting the table headers, processing decimal points, and sorting.

6. The data query method for a treasury system according to claim 5, characterized in that, The method further includes the following steps: Set the model update cycle; According to the set model update cycle, user feedback data is obtained, and the first dataset is updated based on the feedback data. The updated first dataset is then used to fine-tune the NL2SQL model and the Router model.

7. The data query method for a treasury system according to claim 6, characterized in that, The method further includes the following steps: The NL2SQL models that provide data query services to each of the aforementioned business systems will be integrated to provide a unified data query service for the treasury system.

8. A data query device for a treasury system, characterized in that, The treasury system includes multiple business systems, and the device includes: The construction module is used to build the first dataset based on the base table. First, several question-answer pairs, including financial query natural language commands and corresponding SQL query statements, are obtained by manual annotation. Then, multiple wide tables for different business systems are extracted from the obtained SQL query statements to serve as the base table of the NL2SQL model. Finally, the question-answer pairs are expanded based on the annotation template or the base table structure to generate the first dataset. The training module is used to train multiple NL2SQL models for different business systems using the first dataset, and to combine the base tables used by the financial query natural language instructions and SQL query statements in the first dataset to obtain a second dataset, and to train a Router model using the second dataset. The query module is used to obtain a target table based on the Router model and a target SQL query statement based on the NL2SQL model of the corresponding business system, according to the user's input of a target financial query natural language command, and to execute the target SQL query statement in the target table to obtain the query result.

9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the data query method for a treasury system as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the data query method for a treasury system as described in any one of claims 1-7.