Intelligent financial field database interaction method driven by large language model

CN117971867BActive Publication Date: 2026-08-18UNIV OF SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410123616.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-30
Publication Date
2026-08-18
Estimated Expiration
2044-01-30

AI Technical Summary

Technical Problem

[0006]针对相关技术中的问题,本发明提出一种大语言模型驱动的智能化金融领域数据库交互方法,具备降低与数据库交互的门槛,提高用户体验的优点,进而解决现有技术中对于非技术用户上手门槛高,难以实现智能化交互的问题

Benefits of technology

[0054] (1) This invention updates the user-database interaction process from professional SQL writing and template-based fixed query methods to an intelligent language interaction mode based on natural language. Compared with traditional direct database query, this invention greatly reduces the user's usage threshold. Users no longer need to learn how to use SQL or perform any manual database queries. They can directly ask the language model to get the information they need. This lowers the threshold for user-database interaction, improves user experience, and realizes innovation in user interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117971867B_ABST
    Figure CN117971867B_ABST
Patent Text Reader

Abstract

The application discloses a large language model driven intelligent financial field database interaction method, and relates to the field of databases, and the method comprises the following steps: S1, constructing a language model and training; S2, recognizing and analyzing user input information by using the language model; S3, the language model selects a database interaction tool according to the recognition result, and queries the database; S4, the database interaction tool returns the query result, and saves the query data to an intermediate file; S5, steps S3-S4 are repeatedly executed based on an action chain until all database interaction tools finish querying, and the query result is output through the language model; S6, the output variable is replaced by using the query data in the intermediate file, and the result is returned to the user. The application reduces the threshold of user and database interaction, and realizes the innovation of user interaction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of databases, and more specifically, to an intelligent database interaction method in the financial field driven by a large language model. Background Technology

[0002] Traditional user-database interactions often rely on fixed query templates and pre-written programs, which are cumbersome and lack intelligence for users. Taking the financial sector as an example, financial institutions and professionals frequently need to process massive amounts of financial data, including market data, transaction data, and customer data. This data is highly structured and diverse, with enormous scale, different formats and structures, and high requirements for timeliness and accuracy. This necessitates that financial professionals master complex syntax and database operations such as multi-table joins and multi-condition filtering, and spend considerable time querying and analyzing large amounts of data.

[0003] Current automated database query methods primarily rely on predefined templates or fixed query patterns. These methods lack the flexibility to handle complex queries and are ill-suited to the needs of diverse users. Furthermore, while modern database management systems offer diverse user interfaces, they still require users to possess a certain level of technical knowledge, particularly in writing effective SQL queries. This presents a barrier for non-technical users, limiting their ability to obtain the necessary information. Additionally, although existing large-scale language models perform well on various tasks, relying solely on the model itself is insufficient for intelligent interaction with databases. This is particularly important for database queries in the financial sector, where the complexity and diversity of financial data often demand more flexible query methods, requiring greater domain knowledge and database query optimization skills. The high learning curve, complex queries, and low efficiency contribute to this problem.

[0004] Therefore, in order to solve the above problems, there is an urgent need for an interaction method that does not require specialized SQL writing and uses standardized templates. This method should utilize advanced language models and combine domain expertise and database query optimization techniques to achieve a more intelligent and efficient way of querying and interacting with financial databases.

[0005] No effective solutions have yet been proposed to address the problems in the relevant technologies. Summary of the Invention

[0006] To address the problems in related technologies, this invention proposes an intelligent database interaction method in the financial field driven by a large language model. This method has the advantages of lowering the threshold for database interaction and improving user experience, thereby solving the problem that existing technologies have a high learning curve for non-technical users and make it difficult to achieve intelligent interaction.

[0007] Therefore, the specific technical solution adopted by the present invention is as follows:

[0008] A large language model-driven intelligent database interaction method for the financial field includes the following steps:

[0009] S1. Construct a language model and train the language model with action chains and dictionary format;

[0010] S2. Use a language model to identify and parse user input information;

[0011] S3. The language model selects a database interaction tool based on the recognition results and inputs parameters into the database interaction tool to query the database based on the parsing results.

[0012] S4. The database interaction tool returns the query results and saves the query data to an intermediate file;

[0013] S5. Repeat steps S3-S4 based on the action chain until all database interaction tools have finished querying, and output the query results through the language model.

[0014] S6. Using the query data stored in the intermediate file, replace the variables in the language model output and return the results to the user.

[0015] Furthermore, training the language model on action chains and dictionary formats includes:

[0016] The language model is trained using data to demonstrate the interaction patterns of action chains.

[0017] The language model is trained using a dictionary-style parameter passing method based on data.

[0018] The interaction method of the action chain is as follows:

[0019] Action-Action Input-Observation-…-Action-Action Input-Observation

[0020] In the formula, Action represents a database interaction tool, corresponding to a unique Action name, which is selected and invoked by the language model;

[0021] Action Input represents a dictionary format;

[0022] An Observation represents the content retrieved from the database by a database interaction tool.

[0023] Furthermore, using language models to identify and parse user input includes:

[0024] S21. Use a language model to convert user input information into dictionary format and perform keyword parsing;

[0025] S22. Through keyword parsing, identify and extract the Action name and Action Input field;

[0026] S23. Parse the extracted Action Input field using JSON.

[0027] Furthermore, the language model selects a database interaction tool based on the recognition results, and queries the database by inputting parameters into the database interaction tool based on the parsing results, including the following steps:

[0028] S31. The language model analyzes the recognition results and calls the corresponding Action database interaction tool;

[0029] S32. The language model inputs parameters to the corresponding Action database interaction tool based on the parsing results of the Action Input field.

[0030] S33. Language model database selection;

[0031] S34. The Action database interaction tool queries the database based on the input parameters.

[0032] Furthermore, the language model analyzes the recognition results and calls the corresponding Action database interaction tools, including:

[0033] S311. The language model analyzes the Action names in the recognition results to analyze the user's query needs;

[0034] S312. Write corresponding Action database interaction tools according to the query requirements. Each Action database interaction tool is responsible for a specific database query operation.

[0035] S313. The language model calls the corresponding Action database interaction tool based on the Action name.

[0036] Furthermore, based on query requirements, corresponding Action database interaction tools are developed, including:

[0037] Specialized tools are developed to meet specific query requirements; general-purpose tools are developed to meet specific query requirements that cannot be met. These general-purpose tools are used to generate database query statements and execute query operations based on user requirements and a list of table names that may be needed.

[0038] Furthermore, the language model database selection process includes the following steps:

[0039] S331. Provide the language model with brief information for each database;

[0040] S332, Provide guidance information for the language model;

[0041] S333. Based on the user's needs, the language model selects a database;

[0042] S334. Repeat steps S332-S333 until all database selections in the prompt are complete.

[0043] Furthermore, based on user needs, the language model selects a database, which includes the following steps:

[0044] S3331. Based on the user's needs, obtain the corresponding database name and corresponding database description information in the system;

[0045] S3332. Select the corresponding database based on the guidance information prompt, and require the language model to be output in a fixed format;

[0046] S3333: Obtain the language model's database selection through format parsing.

[0047] Furthermore, the database interaction tool returns query results and saves the query data to an intermediate file, including the following steps:

[0048] S41. Save the query results returned by the database interaction tool in tabular form and use angle brackets <> to indicate them;

[0049] S42. Determine the shape of the query results, store the query results of a single value in a variable, and use double angle brackets <<>> to represent it;

[0050] S43. Render the table of query results and save all query data in an intermediate file.

[0051] Furthermore, steps S3-S4 are repeatedly executed based on the action chain until all database interaction tool queries are completed, and the query results are output through a language model, including:

[0052] The language model continuously adopts the Action-Action Input-Observation interaction method, continuously interacts with the database using the Action database interaction tool, saves the data retrieved from the database using intermediate files, and finally uses the Finish action to mark the end of the query, and outputs the query results through the language model.

[0053] The beneficial effects of this invention are as follows:

[0054] (1) This invention updates the user-database interaction process from professional SQL writing and template-based fixed query methods to an intelligent language interaction mode based on natural language. Compared with traditional direct database query, this invention greatly reduces the user's usage threshold. Users no longer need to learn how to use SQL or perform any manual database queries. They can directly ask the language model to get the information they need. This lowers the threshold for user-database interaction, improves user experience, and realizes innovation in user interaction.

[0055] (2) Compared with traditional automated database query methods, this invention no longer requires users to select a template and fill in information according to a fixed template for querying. Users only need to input a natural language question, and the language model will automatically interact with the database to obtain the information needed by the user, making the query more convenient and faster.

[0056] (3) Compared with typical large language model applications, which often rely on powerful online language model APIs, lack confidentiality and privacy, and have limited robustness, the model trained by this invention using a matching database interaction method not only has high robustness and practicality, but also ensures the privacy and confidentiality of user data. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the 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.

[0058] Figure 1 This is a flowchart illustrating an intelligent database interaction method in the financial field driven by a large language model, according to an embodiment of the present invention.

[0059] Figure 2 This is a schematic diagram of the backend operation process of querying the total liabilities of Company A in year X, which is a database interaction method in the financial field driven by a large language model according to an embodiment of the present invention.

[0060] Figure 3 This is a schematic diagram of the backend operation process of querying the total liabilities of Company B in year Y, using a large language model-driven intelligent database interaction method in the financial field according to an embodiment of the present invention.

[0061] Figure 4 This is a schematic diagram illustrating the final front-end return result of a query for the total liabilities of Company B in year Y, based on an intelligent database interaction method in the financial field driven by a large language model according to an embodiment of the present invention. Detailed Implementation

[0062] To further illustrate the various embodiments, the present invention provides accompanying drawings, which are part of the disclosure of the present invention. These drawings are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementation methods and the advantages of the present invention. The components in the drawings are not drawn to scale, and similar component symbols are generally used to represent similar components.

[0063] According to an embodiment of the present invention, an intelligent database interaction method for the financial field driven by a large language model is provided.

[0064] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments, such as... Figure 1 As shown, the intelligent financial database interaction method driven by a large language model according to an embodiment of the present invention includes the following steps:

[0065] S1. Construct a language model and train the language model with action chains and dictionary format;

[0066] S2. Use a language model to identify and parse user input information;

[0067] S3. The language model selects a database interaction tool based on the recognition results and inputs parameters into the database interaction tool to query the database based on the parsing results.

[0068] S4. The database interaction tool returns the query results and saves the query data to an intermediate file;

[0069] S5. Repeat steps S3-S4 based on the action chain until all database interaction tools have finished querying, and output the query results through the language model.

[0070] S6. Using the query data stored in the intermediate file, replace the variables in the language model output and return the results to the user.

[0071] Specifically, addressing the conflict between the precision requirements in the financial field and the probabilistic and uncertain nature of large models, this invention employs an intermediate file to ensure the accuracy of the model's output data. Specifically, this invention stores some information retrieved from the database in an intermediate file and allows the language model to output the results as variables. After the language model outputs its results, this invention uses the database data stored in the intermediate file to change the variables in the language model's output to their true values, thereby guaranteeing the accuracy of the output received by the user.

[0072] Specifically, the data we retrieved by guiding the large model has been stored in a and a <variable>. Then, the prompt guides the large model to return our and <variable> as query results. Based on this, we modify the values ​​back to the actual values ​​and match them. <xxxx>In this format, the table is retrieved from the intermediate results area based on the name xxxx, rendered to the user, and then the original... <xxxx>Change it to something like "the table below"; and match < <yyyy>This format, according to < <yyyy>>Retrieve the corresponding data from the intermediate results area and extract the original < <yyyy>> Replace it, thereby changing the variables in the language model's output to the true values.

[0073] In one embodiment, training the language model with action chains and dictionary format includes:

[0074] The language model is trained using data to demonstrate the interaction patterns of action chains.

[0075] The language model is trained using a dictionary-style parameter passing method based on data.

[0076] The interaction method of the action chain is as follows:

[0077] Action-Action Input-Observation-…-Action-Action Input-Observation

[0078] In the formula, Action represents a database interaction tool, corresponding to a unique Action name, which is selected and invoked by the language model;

[0079] Action Input represents a dictionary format;

[0080] An Observation represents the content retrieved from the database by a database interaction tool.

[0081] Specifically, the Action database interaction tool here is similar to a function, which is selected and called by the model. It has a unique Action name, can accept predefined parameters, executes certain instructions after accepting parameters, completes some actions to interact with the database, and then returns the results obtained from the database to the language model.

[0082] Specifically, the Action Input is in dictionary format, for example: {"company_name":"Company A","query":"What is the total profit this year"}. By training the language model in dictionary format, a stable and universal parameter passing method is provided. It is necessary to use the trained language model in conjunction with our database interaction tool to greatly improve robustness and make the invention truly practical.

[0083] In one embodiment, using a language model to identify and parse user input includes:

[0084] S21. Use a language model to convert user input information into dictionary format and perform keyword parsing;

[0085] S22. Through keyword parsing, identify and extract the Action name and Action Input field;

[0086] S23. Parse the extracted Action Input field using JSON.

[0087] Specifically, in order to achieve continuous interaction, we must have a set of code to parse the model's input and output and advance the continuous interaction process. In this embodiment, keyword parsing is the main method. When the model output is intercepted in the pattern "Action:xxx\nAction Input xxx", the system recognizes and extracts the Action name and Action Input field, and performs JSON parsing on the Action Input field.

[0088] In one embodiment, the language model selects a database interaction tool based on the recognition results, and inputs parameters to the database interaction tool based on the parsing results to query the database, including the following steps:

[0089] S31. The language model analyzes the recognition results and calls the corresponding Action database interaction tool;

[0090] S32. The language model inputs parameters to the corresponding Action database interaction tool based on the parsing results of the Action Input field.

[0091] S33. Language model database selection;

[0092] S34. The Action database interaction tool queries the database based on the input parameters.

[0093] Specifically, after the user input information is identified and parsed, the corresponding Action database interaction tool is called according to the Action name, and a series of input parameters are input to the tool instance based on the parsing result of Action Input, thereby interacting with the database.

[0094] In one embodiment, the language model analyzes the recognition results and invokes the corresponding Action database interaction tool, including:

[0095] S311. The language model analyzes the Action names in the recognition results to analyze the user's query needs;

[0096] S312. Write corresponding Action database interaction tools according to the query requirements. Each Action database interaction tool is responsible for a specific database query operation.

[0097] Specifically, Action database interaction tools refer to a series of tools that are the basic action units for us to interact with the database. They are usually written to meet the needs of requirements and engineering robustness optimization. A typical Action is a tool that takes SQL as input and outputs the SQL execution result. This is a general-purpose tool that relies on the SQL generation capability of the model, but the robustness of this tool cannot meet the application requirements.

[0098] Specifically, we use a series of Action database interaction tools to improve system robustness. For example, for a requirement to query a company's financial statements, we can divide it into two steps: first, find the corresponding ID information of the company through the Action "Query Company ID"; second, obtain the company's financial statements through the Action "Query Company Financial Statements" and return the company's financial statements.

[0099] S313. The language model calls the corresponding Action database interaction tool based on the Action name.

[0100] Specifically, some requirements may not have corresponding dedicated query tools. In such cases, a general tool needs to be called, which will result in a relatively longer process. For example, to find out who the legal representative of a company is, this requirement is input into the large model. The large model will select from the available tools provided in the guidance prompt. Assuming there is a pre-written tool for querying legal representatives, the model will first query the company code, then select the tool for querying legal representatives, input the company name, get the result, and return it, with a relatively short number of steps. However, in many cases, not every requirement has a relatively universal tool. In such cases, the model will first use the "select data cell" tool (if there are multiple databases and many data tables). In this case, the "Select Database" tool must be executed first, followed by the data table selection tool. After obtaining the list of tables that may be used, the language model will next call the general database tool with model participation. Within this tool, the code will obtain the corresponding data table data dictionary information (i.e., the database schema, which contains the type and description of each field in the database, etc.) based on the input data table name. Then, it will combine the database dictionary information and the input requirements to generate a query, execute the query, and return the result. The entire action chain includes: query company code -> select database -> select data table -> general query tool -> return result.

[0101] Specifically, when the parameters passed to the model do not meet the requirements, the model is guided to regenerate the parameters and try repeatedly. For example, when the model is using the legal person query tool, the input should be the company code, but the input is actually the company name. In this case, the model will be asked to query the company code again, and then query the legal person. The action chain is as follows: query legal person (incorrect input parameters) -> query company code -> query legal person (using the code obtained in the previous step) -> return the result.

[0102] Specifically, there may be needs that require multiple queries, resulting in a longer action chain. For example, if the query is to compare the 2023 profits of Company A and Company B, the model will first query the profits of Company A, then query the profits of Company B, and finally compare them. The action chain is as follows: Query Company A's code -> Query Company A's profits -> Query Company B's code -> Query Company B's profits -> Data comparison and analysis tool (when the model needs to understand variable values ​​for analysis, this tool provides a function similar to replacing variables with values ​​in the output, allowing the model to see the values, thereby helping us with the analysis) -> Return query results and analysis results.

[0103] In one embodiment, developing a corresponding Action database interaction tool based on query requirements includes:

[0104] Specialized tools are developed to meet specific query requirements; general-purpose tools are developed to meet specific query requirements that cannot be met. These general-purpose tools are used to generate database query statements and execute query operations based on user requirements and a list of table names that may be needed.

[0105] In one embodiment, selecting a language model database includes the following steps:

[0106] S331. Provide the language model with brief information for each database;

[0107] S332, Provide guidance information for the language model;

[0108] S333. Based on the user's needs, the language model selects a database;

[0109] Specifically, throughout the entire process, the selection of the database / table is done by the model itself. This invention solves the problem of the difficulty in selecting a database for a language model, mainly in two aspects. First, it provides the model with brief descriptive information for each database for the model to choose from. Before the model selects a specified database and performs further operations, it provides the model with detailed information about that database / table. Second, for engineering optimization considerations, it can also provide the model with guidance information on database selection to improve robustness and efficiency for certain needs.

[0110] S334. Repeat steps S332-S333 until all database selections in the prompt are complete.

[0111] Specifically, the database descriptive information is a summary of the overall information within the database. For example, a database called ashare_basic might be described as containing basic information about Chinese A-share listed companies, such as the company's legal representative, location, product categories, upstream and downstream relationships, etc. Another database called ashare_finance might be described as containing financial data about A-share listed companies, such as financial statements, various financial indicators, cash flow, etc. This provides the model with an objective summary of the content it contains. In a well-designed database system, there are clear distinctions in content between different databases. Therefore, by providing the model with basic database information, the large model can select databases based on the user's needs.

[0112] Specifically, for data tables, the main focus is on summarizing the content. However, because there may be some coupling between the data tables, the database / table selection process is written as a tool. Internally, this tool needs to use a separate large-scale model process, independent of the overall process control model, to select the database / table. The input is the user's requirements, or rather, the user's requirements summarized by the large-scale model. The process involves the program obtaining the names and descriptions of existing databases in the system, and then using prompts (e.g., "Existing database information is as follows: YYYYY. Please select a database that can potentially solve your requirements based on XXX, and follow the instructions..."). The large model selects the corresponding data table based on this information (e.g., "database name format output") and requires the model to output in a fixed format. We then obtain the large model's selection through format parsing. Upon returning, we add guidance information (e.g., "Database A has been selected; please select the data table next," or "The data tables that may be needed are [A, B, C]; you can use the 'General Query Tool' for the next query") to the selected database. This process is repeated from steps S332 to S333 until all database selections in the guidance information prompts are completed.

[0113] In one embodiment, the language model selects a database based on user needs, including the following steps:

[0114] S3331. Based on the user's needs, obtain the corresponding database name and corresponding database description information in the system;

[0115] S3332. Select the corresponding database based on the guidance information prompt, and require the language model to be output in a fixed format;

[0116] S3333: Obtain the language model's database selection through format parsing.

[0117] In one embodiment, the database interaction tool returns query results and saves the query data to an intermediate file, including the following steps:

[0118] S41. Save the query results returned by the database interaction tool in tabular form and use angle brackets <> to indicate them;

[0119] S42. Determine the shape of the query results, store the query results of a single value in a variable, and use double angle brackets <<>> to represent it;

[0120] S43. Render the table of query results and save all query data in an intermediate file.

[0121] Specifically, database interaction tools can be divided into three types: first, special tools required for process control, such as database selection tools and data table selection tools; second, manually written program code that implements specific query functions, which can be called dedicated tools; and third, general-purpose tools, which involve models and are used as alternatives when no specific tools are available, to achieve generalized functions. Among these, dedicated tools are more stable, while general-purpose tools can implement some functions that do not require manual writing, but their stability is not as good as that of dedicated tools.

[0122] Specifically, for the first type of tool, such as database selection tools and table selection tools, the input is the user's requirements, and the output is the selected database name and table name (list). For the second type of tool, it accepts dictionary-formatted input, parses the input, performs a query according to the pre-written program, processes the query results, and returns them to the language model in text format, along with additional guidance information to instruct the large model to retain the variable format in the returned variables. For example, in a tool for querying company reports, our guidance information would be "The relevant tables have been successfully stored in the file."<table.txt> In the first case, please return this file as the result of final_answer, and keep the angle brackets <> to indicate that it is a table. Also, in final_answer, please specify which company and table this file belongs to. For the third case, for tools that involve models, the input is still in dictionary format. The dictionary contains the user's requirement text and a list of table names that may be needed.

[0123] Specifically, for a given requirement, the language model first determines which tools might be needed. If existing, pre-written tools can meet the requirement, the language model directly selects these tools and passes in the parameters. If the large model does not find a suitable tool, a general-purpose tool will be used. First, a dedicated table selection tool is used to select the table, and then the possible table names and requirements are passed to the general-purpose database interaction tool. The general-purpose tool internally generates, executes, and returns the query results. The content obtained by the general-purpose tool is also saved in an intermediate file, using the prompt format. After the query is executed, the results are automatically saved in the intermediate file.

[0124] Specifically, <<>> and <> are used to represent tables and variables respectively, thereby saving the query data to an intermediate file, and <<>> and <> can be used as matching markers for replacement processing later.

[0125] In one embodiment, steps S3-S4 are repeatedly executed based on the action chain until all database interaction tool queries are completed, and the query results are output through a language model, including:

[0126] The language model continuously adopts the Action-Action Input-Observation interaction method, continuously interacts with the database using the Action database interaction tool, saves the data retrieved from the database using intermediate files, and finally uses the Finish action to mark the end of the query, and outputs the query results through the language model.

[0127] Specifically, at the beginning of the action chain, we provide the model with instructions on our output format Action–ActionInput–Observation, as well as functional descriptions and available parameter descriptions of all available tools. Then, we add a prompt to guide the model to perform the action chain according to user needs to obtain information that meets those needs. This prompt serves as a system prompt. When using the system prompt, the user's input is appended to it. After that, the model performs the action chain according to our instructions and the experience gained from targeted training.

[0128] Specifically, the action chain ends by the language model calling the Finish tool, at which point the model outputs:

[0129]

[0130] The model ends the action chain by calling the Finish tool (Action:Finish) and returns the final result to the system using the final_anser field of the Finish tool.

[0131] The system further processes the final returned result, for example, by processing < <data1>Replace the data and units with the correct ones so that users can see the correct data. Also, change the table...

[0132]

[0133]

[0134]

[0135]

[0136]

[0137] Figure 2 Figure 3 Figure 4 Figure 2

[0138]

[0139] Rendering into a user-visible table, etc. If the model ultimately fails to meet the requirements and retrieve the necessary content, this is a case of failure causing the action chain to end. In this case, the model outputs: After the Finish tool receives the input of give_up_and_restart, it returns "No corresponding result found, terminating this question and answer session," thus starting a new round of user input interaction. To facilitate understanding of the above technical solution of this invention, the working principle or operation method of this invention in actual process will be described in detail below. This invention updates the human-database interaction process from specialized SQL writing and templated, fixed query methods to an intelligent language interaction mode based on natural language. This lowers the barrier to database interaction and improves user experience. Especially for common needs in the financial field (such as querying company indicators and financial statements), it provides a convenient experience of language-based inquiry interaction while ensuring the accuracy of the results. By combining the above technologies, we can ultimately realize a practical prototype method that can receive user input information. After the language model understands the user's input, it continuously interacts with the database through action chains and database interaction tools to obtain the desired information from the database and finally returns the obtained information to the user. The entire process, from the user's perspective, is simply language input and language output—a new paradigm of intelligent database interaction. In practical applications, firstly, taking the query of Company A's total liabilities for year X as an example, after the user inputs the information, the actual backend process is as shown. The language model continuously interacts with the database using the Action-Action Input-Observation format, and finally uses the Finish action to indicate that it has ended and can output the final result. Secondly, taking the query of Company B's total liabilities for year Y as an example, as shown, an intermediate file is used to save the data retrieved from the database, and the output variables are replaced, thereby overcoming the illusionary nature of the model. The final returned result is as shown. The database query results obtained through this method are rendered into a table by the front end and returned to the user. In addition, an error handling method to improve robustness is also demonstrated. Sometimes the language model will incorrectly enter the company name in the Company ID field. The error handling here tells the language model that it should retrieve the correct company ID before proceeding. Thus, this method improves technical stability in practice and presents the data in the database to the user more accurately.In summary, the technical solution of this invention revolutionizes user interaction, transforming the user-database interaction process from specialized SQL writing and template-based, fixed query methods to an intelligent language interaction mode based on natural language. Compared to traditional direct database queries, this invention significantly reduces the user's learning curve. Users no longer need to learn SQL or perform any manual database queries; they can directly query the language model to obtain the required information, lowering the barrier to database interaction and improving user experience. Compared to traditional automated database query methods, this invention eliminates the need for users to select templates and fill in information according to fixed templates. Users only need to input natural language questions, and the language model will automatically and continuously interact with the database to obtain the information needed, making queries more convenient and faster. Compared to typical large language model applications, which often rely on powerful online language model APIs, lacking confidentiality and privacy, and with limited robustness, this invention uses a targeted self-trained model with a matching database interaction method, which not only has high robustness and practicality but also ensures user data privacy and confidentiality. The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention. < / yyyy> < / yyyy> < / yyyy> < / xxxx> < / xxxx>

Claims

1. A large language model-driven intelligent database interaction method in the financial field, characterized in that, This intelligent database interaction method in the financial field, driven by a large language model, includes the following steps: S1. Construct a language model and train the language model with action chains and dictionary format; S2. Use a language model to identify and parse user input information; S3. The language model selects a database interaction tool based on the recognition results and inputs parameters into the database interaction tool to query the database based on the parsing results. S4. The database interaction tool returns the query results and saves the query data to an intermediate file; S5. Repeat steps S3-S4 based on the action chain until all database interaction tools have finished querying, and output the query results through the language model. S6. Using the query data saved in the intermediate file, replace the variables in the language model output and return the results to the user; The action chain and dictionary format training of the language model includes: training the language model through action chain interaction using data; and training the language model through dictionary format parameter passing using data; wherein the action chain interaction method is as follows: Action–Action Input–Observation–…–Action–Action Input–Observation In the formula, Action represents a database interaction tool, corresponding to a unique Action name, which is selected and invoked by the language model; Action Input represents a dictionary format; Observation represents the content retrieved by the database interaction tool from the database; The process of recognizing and parsing user input using a language model includes: S21. Use a language model to convert user input information into dictionary format and perform keyword parsing; S22. Through keyword parsing, identify and extract the Action name and Action Input field; S23. Parse the extracted Action Input field using JSON; The database interaction tool returns query results and saves the query data to an intermediate file, including: S41. Save the query results returned by the database interaction tool in tabular form and use angle brackets <> to indicate them; S42. Determine the shape of the query results, store the query results of a single value in a variable, and use double angle brackets <<>> to represent it; S43. Render the table of query results and save all query data in an intermediate file.

2. The intelligent database interaction method in the financial field driven by a large language model according to claim 1, characterized in that, The language model selects a database interaction tool based on the recognition results, and then inputs parameters into the database interaction tool based on the parsing results to query the database, including the following steps: S31. The language model analyzes the recognition results and calls the corresponding Action database interaction tool; S32. The language model inputs parameters to the corresponding Action database interaction tool based on the parsing results of the Action Input field. S33. Language model database selection; S34. The Action database interaction tool queries the database based on the input parameters.

3. The intelligent database interaction method in the financial field driven by a large language model according to claim 2, characterized in that, The language model analyzes the recognition results and calls the corresponding Action database interaction tools, including: S311. The language model analyzes the Action names in the recognition results to analyze the user's query needs; S312. Write corresponding Action database interaction tools according to the query requirements. Each Action database interaction tool is responsible for a specific database query operation. S313. The language model calls the corresponding Action database interaction tool based on the Action name.

4. The intelligent financial database interaction method driven by a large language model according to claim 3, characterized in that, The process of developing corresponding Action database interaction tools based on query requirements includes: Specialized tools are developed to meet specific query requirements; general-purpose tools are developed to meet specific query requirements that cannot be met. These general-purpose tools are used to generate database query statements and execute query operations based on user requirements and a list of table names that may be needed.

5. The intelligent database interaction method in the financial field driven by a large language model according to claim 2, characterized in that, The language model database selection process includes the following steps: S331. Provide the language model with brief information for each database; S332, Provide guidance information for the language model; S333. Based on the user's needs, the language model selects a database; S334. Repeat steps S332-S333 until all database selections in the prompt are complete.

6. The intelligent database interaction method in the financial field driven by a large language model according to claim 5, characterized in that, The process of selecting a database based on user needs includes the following steps: S3331. Based on the user's needs, obtain the corresponding database name and corresponding database description information in the system; S3332. Select the corresponding database based on the guidance information prompt, and require the language model to be output in a fixed format; S3333: Obtain the language model's database selection through format parsing.

7. The intelligent database interaction method in the financial field driven by a large language model according to claim 1, characterized in that, The process of repeatedly executing steps S3-S4 based on the action chain until all database interaction tools have completed their queries, and then outputting the query results through a language model, includes: The language model continuously adopts the Action–Action Input–Observation action chain interaction method, continuously interacts with the database using the Action database interaction tool, saves the data retrieved from the database using intermediate files, and finally uses the Finish action to mark the end of the query, and outputs the query results through the language model.

Citation Information

Patent Citations

  • Document information query method based on large language model

    CN116991974A

  • Data standardization processing method based on large language model

    CN117371401A