Multi-agent-based query statement correction method, device, equipment and product
Automatically identifying and correcting SQL statements through a multi-agent collaborative process solves the problems of poor results and low efficiency of manual correction, achieves efficient and accurate SQL statement correction, and improves the reliability of data queries and user experience.
Patent Information
- Application Number
- CN202510813306.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-06-17
AI Technical Summary
The existing technology of manually correcting SQL statements has the problems of poor correction effect and low efficiency. In particular, after the large language model generates the SQL statement, it is necessary to manually check the data table fields one by one, resulting in inaccurate data query results and low efficiency.
Through the multi-agent collaborative process, the first agent is used to obtain error correction information, the second agent uses a large model to identify errors, and the third agent corrects errors, forming a closed-loop collaboration to automatically realize error identification and correction of query statements.
It reduces errors and omissions caused by human negligence during the manual correction process, improves the efficiency and effect of correction, enables different intelligent agents to focus on their respective areas of expertise, and improves the accuracy and efficiency of correction.
Smart Images

Figure CN120336361B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of large models, intelligent agents and artificial intelligence, and specifically to a query statement correction method, device, equipment and product based on multi-agent. Background Art
[0002] With the advent of the big data era, data is growing explosively. To quickly retrieve target data from databases, you can typically query data from them using query statements. For example, a large language model can be used to generate SQL (Structured Query Language) statements based on user needs, and then query data from the database based on these SQL statements.
[0003] However, when generating SQL statements based on large language models, errors may occur. Therefore, after obtaining the SQL statements output by the large language model, the SQL statements generally need to be corrected. However, in related technologies, SQL statement correction is generally based on manual methods, which has problems such as poor correction effect and low correction efficiency. Summary of the Invention
[0004] This summary is provided to briefly introduce concepts that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In a first aspect, the present disclosure provides a multi-agent-based query statement correction method, the multi-agent-based query statement correction method comprising:
[0006] Acquiring error correction information through the first agent, the error correction information including a query statement to be corrected, a data table structure used for performing data query on the query statement, and a description text of the error correction for the query statement;
[0007] The first agent determines a first prompt word based on the error correction information and preset error reference information, and sends the first prompt word to a second agent. The second agent is configured to perform error recognition on the query statement based on the first prompt word using an associated large model, obtain first error information for the query statement, and send the first error information to the first agent.
[0008] The first agent determines a second prompt word based on the first error information and the error correction information, and sends the second prompt word to the third agent. The third agent is used to correct the error of the query statement based on the second prompt word through the associated large model to obtain the target query statement.
[0009] In a second aspect, the present disclosure provides a multi-agent-based query statement correction device, the multi-agent-based query statement correction device comprising:
[0010] an acquisition module, configured to acquire error correction information through the first agent, the error correction information including a query statement to be corrected, a data table structure for performing data query based on the query statement, and a description text of the error correction for the query statement;
[0011] a first processing module configured to determine, by the first agent, a first prompt word based on the error correction information and preset error reference information, and send the first prompt word to a second agent; the second agent configured to perform error recognition on the query statement based on the first prompt word using an associated large model, obtain first error information for the query statement, and send the first error information to the first agent;
[0012] The second processing module is used to determine a second prompt word through the first intelligent agent based on the first error information and the error correction information, and send the second prompt word to the third intelligent agent. The third intelligent agent is used to correct the error of the query statement based on the second prompt word through the associated large model to obtain the target query statement.
[0013] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which implements the steps of the method described in the first aspect when executed by a processing device.
[0014] In a fourth aspect, the present disclosure provides an electronic device, comprising:
[0015] a storage device having a computer program stored thereon;
[0016] A processing device is used to execute the computer program in the storage device to implement the steps of the method in the first aspect.
[0017] In a fifth aspect, the present disclosure provides a computer program product, comprising a computer program, which implements the steps of the method described in the first aspect when executed by a processor.
[0018] Through the above technical solution, a first agent can determine a first prompt word based on preset error reference information and obtained error correction information, and can send the first prompt word to a second agent; after receiving the first prompt word, the second agent can use the associated large model to perform error recognition on the query statement in the error correction information based on the first prompt word, obtain first error information for the query statement, and send the first error information to the first agent; after receiving the first error information, the first agent can determine a second prompt word based on the first error information and the error correction information, and can send the second prompt word to a third agent; after receiving the second prompt word, the third agent can use the associated large model to perform error correction on the query statement based on the second prompt word to obtain a target query statement. In this way, a closed-loop collaborative process can be formed based on the first, second, and third agents, that is, error recognition and error correction of query statements can be automatically achieved through multi-agent collaboration, thereby reducing errors and corrections caused by human negligence during the manual correction process, thereby improving correction efficiency. In addition, since error correction is based on multi-agent collaboration, different agents can focus on their respective specific areas of expertise during the correction process, thereby further improving the error correction effect.
[0019] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The above and other features, advantages and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale. In the drawings:
[0021] Figure 1 is a flowchart of a multi-agent based query statement correction method according to an exemplary embodiment of the present disclosure;
[0022] Figure 2 is a flowchart illustrating another multi-agent-based query statement correction method according to an exemplary embodiment of the present disclosure;
[0023] Figure 3 is a structural block diagram of a query statement correction device based on multi-agents according to an exemplary embodiment of the present disclosure;
[0024] Figure 4 The figure is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0026] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0027] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0028] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0029] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0030] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0031] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0032] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the electronic device, application, server, storage medium, or other software or hardware that performs the operations of the disclosed technical solution based on the prompt message.
[0033] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0034] It is understandable that the above notification and user authorization process are merely illustrative and do not limit the implementation of the present disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0035] At the same time, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0036] As mentioned in the background art, in the related art, SQL statements are generally corrected manually, which has problems such as poor correction effect and low correction efficiency.
[0037] For example, with the rise of large language models, Text2SQL (text to structured query language) technology came into being. Text2SQL technology can convert natural language query requirements entered by users into corresponding SQL statements, then execute the SQL statements in the database, and finally return the query results to the user.
[0038] While this approach can reduce the difficulty of data querying, due to the complexity and diversity of natural language and the limitations of the Text2SQL model's understanding of certain semantics, Text2SQL may output incorrect SQL statements. To avoid data queries based on incorrect SQL statements, manual correction is generally required after Text2SQL outputs the SQL statements.
[0039] However, when manually modifying SQL statements, users typically focus only on the correspondence between natural language query requirements and SQL statements, with little understanding of the complete structure of the data table. Especially when the data table to be queried contains a large number of fields, manual verification of each field in the SQL statement is required to ensure the accuracy of field selection. This process is not only inefficient but also prone to errors, resulting in inaccurate data query results or even query failures, seriously affecting data query reliability and user experience.
[0040] In view of this, the present disclosure provides a multi-agent based query statement correction method, device, equipment and product to solve the above technical problems.
[0041] The following further explains the embodiments of the present disclosure with reference to the accompanying drawings.
[0042] Figure 1 This is a flowchart of a multi-agent based query statement correction method according to an exemplary embodiment of the present disclosure, referring to Figure 1 The multi-agent-based query statement correction method may include the following steps:
[0043] S101: Obtain error correction information through a first agent, where the error correction information includes a query statement to be corrected, a data table structure used for performing data query on the query statement, and an error correction description text for the query statement.
[0044] It should be understood that an agent is an agent that can perceive the environment and take actions to achieve specific goals. It can be software, hardware, or a system, and has autonomy, adaptability, and interactive capabilities. Therefore, the agent involved in this disclosure can be a server deployed with a large model, or a terminal device deployed with a large model, or of course other agents. The embodiments of this disclosure do not impose any restrictions on this. For example, the large model involved in this disclosure can be a large language model or a multimodal large model.
[0045] For example, when the first agent is a server deployed with a large model, obtaining error correction information through the first agent may include: displaying a first page for a user to enter error correction information on a terminal device that has established a communication connection with the first agent, and in response to the user entering the error correction information on the first page, obtaining the error correction information through the first agent. Alternatively, displaying a second page for a user to enter a natural language query on the terminal device that has established a communication connection with the first agent, and in response to the user entering the natural language query on the second page, converting the user's input natural language query into a corresponding query statement using a preset large language model. After the natural language query is converted into a query statement, the query statement may be used as a query statement to be corrected, and the natural language query statement may be sent to the first agent as the query statement, so that the first agent can determine a data table structure based on the natural language query statement, and can determine error correction description text based on the natural language query statement and the query statement, thereby obtaining the error correction information. Of course, other methods are also possible, and the present embodiment does not impose any limitations on this.
[0046] For another example, when the first agent is a terminal device deployed with a large model, obtaining error correction information through the first agent may include: displaying a third page in the first agent for the user to enter error correction information; when the user enters the error correction information on the third page, the error correction information is obtained. Alternatively, displaying a fourth page in the first agent for the user to enter a natural language query; when the user enters a natural language query on the fourth page, converting the user's natural language query into a corresponding query statement using a preset large language model; after converting the natural language query into a query statement, the query statement may be used as the query statement to be corrected; determining a data table structure based on the natural language query; and determining error correction description text based on the natural language query and the query statement, thereby obtaining the error correction information. Of course, other methods are possible, and the present disclosure does not impose any limitations on this.
[0047] It should be understood that a query statement is an instruction for retrieving, filtering, counting, or manipulating data from a database. Depending on the database, a query statement may be a MongoDB query statement, a Redis query statement, or other query statements, and the embodiments of the present disclosure do not impose any restrictions on this. Given that SQL query statements are a standardized query language, whose syntax and functions are supported by most relational database systems, query statements may be structured query language statements, if possible.
[0048] S102: The first intelligent agent determines a first prompt word based on the error correction information and the preset error reference information, and sends the first prompt word to the second intelligent agent. The second intelligent agent is used to identify the error of the query statement based on the first prompt word through the associated large model, obtain the first error information for the query statement, and send the first error information to the first intelligent agent.
[0049] In this embodiment, the first prompt word can be determined by presetting a prompt word template a. Thus, after the first agent obtains the error correction information, the error correction information and preset error reference information can be filled into the corresponding position of the prompt word template a to obtain the first prompt word. Alternatively, based on the template format a of the prompt word template a, a first prompt word identical to the template format a can be generated according to the error correction information and the preset error reference information. Alternatively, after the first agent obtains the error correction information, the first prompt word can be randomly generated based on the error correction information and the preset error reference information based on the macro model associated with the first agent. Of course, the first prompt word can also be determined by other methods, which are not limited in this embodiment.
[0050] S103: The first agent determines a second prompt word based on the first error information and the error correction information, and sends the second prompt word to the third agent. The third agent is used to correct the error of the query statement based on the second prompt word through the associated large model to obtain the target query statement.
[0051] In this embodiment, the second prompt word can be determined by presetting a prompt word template b. Thus, after the first agent receives the first error message, it can fill the first error message and error correction information into the corresponding positions in the prompt word template b to obtain the second prompt word. Alternatively, based on the template format b of the prompt word template b, a first prompt word having the same template format b as the first error message and error correction information can be generated. Alternatively, after the first agent receives the first error message, the second prompt word can be randomly generated based on the first error message and error correction information based on the macro model associated with the first agent. Of course, the second prompt word can also be determined by other methods, which are not limited in this embodiment.
[0052] Given that different query statements may have different error types, for example, in SQL statements, there are syntax errors, logic errors, and permission errors. However, different error types have different correction methods. Therefore, in order to improve the accuracy of error correction, a prompt word template can be set for each error type. For example, for syntax error types, the prompt word template can be: "You are a database expert. Please correct the spelling and format of the query statement based on the query statement: aaaaaaa; data table structure: bbbbbb; error correction description text: dddddd; and the first error message: hhhhhhh, to ensure that keywords and symbols are used correctly." For logic error types, the prompt word template can be: "You are a database expert. Please correct the query conditions, field references, and / or conditional expressions of the query statement based on the query statement: aaaaaaa; data table structure: bbbbbb; error correction description text: dddddd; and the first error message: hhhhhhh, so that the query conditions conform to the expected logic." Therefore, after obtaining the first error message, the corresponding prompt word template can be determined according to the error type in the first error message, so that the second prompt word generated based on the prompt word template can be more accurate. When the query statement is corrected according to the second prompt word, the position to be corrected can be quickly located and corrected in a targeted manner, thereby improving the correction effect and efficiency.
[0053] That is to say, in a possible manner, the first error message may include the error type. Accordingly, determining the second prompt word by the first intelligent agent based on the first error message and the error correction information may include: determining the target prompt word template corresponding to the error type by the first intelligent agent based on the error type and a preset prompt word template library, and determining the second prompt word based on the first error message, the error correction information and the target prompt word template, wherein the prompt word template library is used to store the correspondence between the prompt word template and the error type.
[0054] To further improve the effectiveness and efficiency of corrections, if certain prompt word templates in the prompt word template library are found to be ineffective in actual use, the first agent can analyze the cause and modify the prompt word template. Furthermore, if a new error type or error scenario is discovered during error recognition by the second agent, a new prompt word template can be constructed based on the new error type or error scenario, and the prompt word template library can be updated.
[0055] The above technical solution forms a closed-loop collaborative process based on the first, second, and third agents. Specifically, multi-agent collaboration enables automatic error recognition and correction of query statements. This reduces the number of errors and corrections caused by human negligence during the manual correction process, thereby improving correction efficiency. Furthermore, since error correction is performed through multi-agent collaboration, different agents can focus on their specific areas of expertise during the correction process, further enhancing the effectiveness of error correction.
[0056] To facilitate understanding of the multi-agent-based query statement correction method provided by the present disclosure, possible implementation methods of the present disclosure are described below.
[0057] In a possible embodiment, the third agent is further configured to send the target query statement to the first agent. Accordingly, the multi-agent-based query statement correction method may further include:
[0058] The first agent determines a correction result based on the target query statement, and the correction result is used to indicate whether the error correction of the query statement is completed; when the correction result indicates that the error correction of the query statement is not completed, the first agent performs the following process: determining the number of corrections for the query statement; optimizing the first prompt word based on the first error information and the number of corrections to obtain a third prompt word, and sending the third prompt word to the second agent, the second agent is used to identify the error of the query statement based on the third prompt word through the associated large model, obtain second error information for the query statement, and send the second error information to the first agent; determining a fourth prompt word based on the second error information and the error correction information, and sending the fourth prompt word to the third agent, the third agent is used to correct the error of the query statement based on the fourth prompt word through the associated large model to obtain a new target query statement.
[0059] In this embodiment, whether the error correction of the query statement is completed may refer to whether the query statement is corrected to a correct query statement, or whether the query statement is corrected to a correct query statement within a preset correction number threshold. Of course, it may also be other, for example, whether the number of corrections of the query statement reaches a preset correction number threshold. The embodiment of the present disclosure does not impose any restrictions on this.
[0060] For example, if a query statement is not corrected to a correct query statement within a preset threshold number of corrections, the correction result can be determined as incomplete error correction for the query statement. At this point, the number of corrections for the query statement can be determined, and the first prompt word can be optimized based on the first error message and the number of corrections. For example, if the number of corrections is one, the first error message is: "The structure of the query statement does not conform to grammatical rules," and the first prompt word is: "You are a database expert, please identify errors in the query statement based on the following: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC." When optimizing the first prompt word based on the first error message and the number of corrections, the first prompt word can be optimized to the following third prompt word:
[0061] You are a database expert. You have generated an error message for the following information: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC". The error message is: The structure of the query statement does not conform to the grammatical rules. However, when correcting the error based on this error message, the correction was not successful. Please re-check the error and generate the error message.
[0062] After obtaining the third prompt word, the third prompt word can be sent to the second intelligent agent. The second intelligent agent is used to identify the error of the query statement according to the third prompt word through the associated large model, obtain second error information for the query statement, and send the second error information to the first intelligent agent; the first intelligent agent determines the fourth prompt word based on the second error information and error correction information, and sends the fourth prompt word to the third intelligent agent. The third intelligent agent is used to correct the error of the query statement according to the fourth prompt word through the associated large model to obtain a new target query statement.
[0063] It should be understood that after obtaining a new target query statement, if the correction result obtained based on the new target query statement still indicates that the error correction for the query statement is not completed, the above steps can be repeated, that is: the third prompt word can be used as the new first prompt word, and the number of corrections for the query statement can be determined, and the first prompt word can be optimized based on the number of corrections and the second error information and subsequent corresponding steps can be executed until the correction result indicates that the error correction for the query statement is completed.
[0064] Through the above method, when the correction result indicates that the error correction for the query statement is not completed, the first prompt word can be optimized based on the first error information and the number of corrections, so that the optimized first prompt word can be more in line with the actual situation of the current query statement, and then when the second intelligent agent performs error recognition again based on the optimized first prompt word, it can more accurately locate or describe the problem in the query statement, thereby improving the accuracy of error recognition, and then when the third intelligent agent performs error correction based on the error information output by the second intelligent agent, it can improve the efficiency and effect of error correction.
[0065] For example, determining the correction result based on the target query statement by the first intelligent agent may include: determining the eighth prompt word based on the target query statement and the data table structure by the first intelligent agent, and sending the eighth prompt word to the second intelligent agent, the second intelligent agent performing error recognition on the target query statement based on the eighth prompt word, if the second intelligent agent recognizes the error, it can be determined that the error correction for the query statement is not completed; if the second intelligent agent does not recognize the error, it can be determined that the error correction for the query statement is completed.
[0066] For example, the erroneous reference information may include a correct reference query statement. Accordingly, determining the correction result according to the target query statement by the first agent may further include:
[0067] The first agent performs the following process:
[0068] Determine the target reference query statement corresponding to the query statement in the error reference information; determine a first correction result for the query statement based on the semantic information of the target query statement and the semantic information of the target reference query statement, and the first correction result is used to indicate whether the semantics of the target query statement are consistent with the semantics of the target reference query statement; determine the first data queried in the data table structure through the query statement, and determine the second data queried in the data table structure through the target reference query statement, and determine the second correction result for the query statement based on the first data and the second data, and the second correction result is used to indicate whether the first data is consistent with the second data; determine the correction result for the query statement based on the first correction result and the second correction result.
[0069] For example, after obtaining the target query statement, the first agent can first determine the semantic similarity and / or grammatical similarity between the target query statement and each reference query statement, and can use the reference query statement with the greatest semantic similarity and / or grammatical similarity as the target reference query statement. After obtaining the target reference query statement, on the one hand, the syntax tree of the target query statement and the target reference query statement can be constructed respectively by a syntax analyzer, and the first correction result can be obtained by comparing the structure and / or node content of the two syntax trees. On the other hand, data can be queried in the data table structure based on the target query statement and the target reference query statement respectively, and the second correction result can be obtained by comparing whether the data queried by the two query statements are consistent. After obtaining the first correction result and the second correction result, if the first correction result indicates that the semantics of the target query statement are consistent with the semantics of the target reference query statement, and the second correction result indicates that the first data is consistent with the second data, then the correction result for the query statement is determined to be that the error correction for the query statement has been completed; otherwise, the correction result for the query statement is determined to be that the error correction for the query statement is not completed.
[0070] Through the above method, the correction result for the query statement can be determined based on the first correction result and the second correction result. Because the first correction result is used to indicate whether the semantics of the target query statement are consistent with the semantics of the target reference query statement, and the second correction result is used to indicate whether the first data is consistent with the second data, the correction result can be determined from the two dimensions of semantics and data consistency, thereby improving the accuracy of the correction result.
[0071] In a possible embodiment, the third agent is further configured to send the target query statement to the first agent. Accordingly, the multi-agent-based query statement correction method may further include:
[0072] The first intelligent agent determines a correction result based on the target query statement, and the correction result is used to indicate whether the error correction of the query statement is completed; when the correction result indicates that the error correction of the query statement is not completed, the first intelligent agent performs the following process: determining the number of corrections for the query statement, optimizing the second prompt word based on the number of corrections, the target query statement and the first error information to obtain a fifth prompt word, and sending the fifth prompt word to the third intelligent agent, the third intelligent agent is used to correct the query statement based on the fifth prompt word through the associated large model to obtain a new target query statement.
[0073] In this embodiment, the manner in which the first agent determines the correction result according to the target query statement is described above and will not be repeated here.
[0074] For example, continuing to refer to the above example, if the query statement is not corrected to a correct query statement within the preset correction number threshold, the correction result can be determined as incomplete error correction for the query statement. At this time, the number of corrections for the query statement can be determined, and the second prompt word can be optimized based on the number of corrections, the target query statement and the first error message. For example, if the number of corrections is one, the first error message is: the structure of the query statement does not conform to the grammatical rules, and the second prompt word is: You are a database expert, please correct the spelling and format of the query statement based on the following content: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC; First error message: The structure of the query statement does not conform to the grammatical rules" to ensure that keywords and symbols are used correctly. When optimizing the second prompt word based on the number of corrections, the target query statement and the first error message, the second prompt word can be optimized to the following fifth prompt word:
[0075] You are a database expert. You have corrected the following information once: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC; First error message: The structure of the query statement does not conform to the grammatical rules." The corrected target query statement is: KKKKKK, but the target query statement is incorrect. Please correct the spelling and format of the query statement to ensure that keywords and symbols are used correctly.
[0076] After obtaining the fifth prompt word, the fifth prompt word can be sent to the third agent, and the third agent is used to correct the error of the query statement based on the fifth prompt word through the associated large model to obtain a new target query statement.
[0077] It should be understood that after obtaining a new target query statement, if the correction result obtained based on the new target query statement still indicates that the error correction for the query statement is not completed, the above steps can be repeated, that is: the fifth prompt word can be used as a new second prompt word, and the number of corrections for the query statement can be determined, and based on the number of corrections, the new target query statement and the first error information, the second prompt word can be optimized and subsequent corresponding steps can be executed until the correction result indicates that the error correction for the query statement is completed.
[0078] Through the above method, when the correction result indicates that the error correction for the query statement is not completed, the second prompt word can be optimized based on the number of corrections, the target query statement and the first error information, so that the optimized second prompt word can be more in line with the actual situation of the current query statement, and then when the third intelligent agent performs error correction again based on the optimized second prompt word, the efficiency and effect of the error correction can be improved.
[0079] In a possible embodiment, the third agent is further configured to send the target query statement to the first agent. Accordingly, the multi-agent-based query statement correction method may further include:
[0080] The first intelligent agent determines a correction result based on the target query statement, and the correction result is used to indicate whether the error correction of the query statement is completed; when the correction result indicates that the error correction of the query statement is not completed, the first intelligent agent performs the following process: determining the number of corrections for the query statement, optimizing the first prompt word based on the first error information and the number of corrections to obtain a sixth prompt word, and sending the sixth prompt word to the second intelligent agent, the second intelligent agent is used to identify the error of the query statement based on the sixth prompt word, obtain third error information for the query statement, and send the third error information to the first intelligent agent; optimizing the second prompt word based on the number of corrections, the target query statement and the third error information to obtain a seventh prompt word, and sending the seventh prompt word to the third intelligent agent, the third intelligent agent is used to correct the error of the query statement based on the seventh prompt word through the associated large model to obtain a new target query statement.
[0081] In this embodiment, the manner in which the first agent determines the correction result according to the target query statement is described above and will not be repeated here.
[0082] For example, continuing with the above example, if a query statement is not corrected to a correct query statement within a preset threshold of corrections, the correction result can be determined as incomplete error correction for the query statement. In this case, the number of corrections for the query statement can be determined, and the first prompt word can be optimized based on the first error message and the number of corrections. For example, if the number of corrections is one, the first error message is: "The query statement structure does not conform to grammatical rules," and the first prompt word is: "You are a database expert. Please identify errors in the query statement based on the following: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC." When optimizing the first prompt word based on the first error message and the number of corrections, the first prompt word can be optimized to the following sixth prompt word:
[0083] You are a database expert. You have generated an error message for the following information: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC". The error message is: The structure of the query statement does not conform to the grammatical rules. However, when correcting the error based on this error message, the correction was not successful. Please re-check the error and generate the error message.
[0084] After obtaining the sixth prompt word, the sixth prompt word can be sent to the second intelligent agent. The second intelligent agent is used to identify errors in the query statement based on the sixth prompt word, obtain a third error message for the query statement, and send the third error message to the first intelligent agent. After receiving the third error message, the first intelligent agent can optimize the second prompt word based on the number of corrections, the target query statement, and the third error message. For example, if the number of corrections is one, the third error message is: the field referenced in the query statement does not exist, and the second prompt word is: You are a database expert, please correct the spelling and format of the query statement based on the following content: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC; First error message: The structure of the query statement does not conform to grammatical rules" to ensure that keywords and symbols are used correctly. When optimizing the second prompt word based on the number of corrections, the target query statement, and the third error message, the second prompt word can be optimized to the following seventh prompt word:
[0085] You are a database expert. You have corrected the following information once: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC; First error message: The structure of the query statement does not conform to the grammatical rules." The corrected target query statement is: KKKKKK, but the target query statement is incorrect. Please correct the query statement again based on "Third error message: The field referenced in the query statement does not exist."
[0086] After obtaining the seventh prompt word, the seventh prompt word can be sent to the third agent, and the third agent is used to correct the error of the query statement based on the seventh prompt word through the associated large model to obtain a new target query statement.
[0087] It should be understood that after obtaining a new target query statement, if the correction result obtained based on the new target query statement still indicates that the error correction for the query statement is not completed, the above steps can be repeated, that is, the sixth prompt word can be used as the new first prompt word, the seventh prompt word can be used as the new second prompt word, and the first prompt word and the second prompt word can be re-optimized until the correction result indicates that the error correction for the query statement is completed.
[0088] Through the above method, when the correction result indicates that the error correction for the query statement is not completed, the first prompt word and the second prompt word can be optimized, so that the optimized first prompt word and the second prompt word can be more in line with the actual situation of the current query statement, thereby improving the efficiency and effect of error correction.
[0089] In a possible manner, the multi-agent-based query statement correction method may further include:
[0090] The first agent determines a correction result based on the target query statement, and the correction result is used to indicate whether the error correction for the query statement is completed; when the correction result indicates that the error correction for the query statement is not completed, the heuristic strategy parameters of the large model associated with the second agent and / or the heuristic strategy parameters of the large model associated with the third agent are adjusted according to the correction result and / or the error information output by the second agent.
[0091] In this embodiment, the manner in which the first agent determines the correction result according to the target query statement is described above and will not be repeated here.
[0092] It should be understood that heuristic strategy parameters usually refer to hyperparameters set by empirical rules or heuristic methods, which generally include learning rate, batch size, regularization parameters, optimizer parameters, network depth, and network width.
[0093] In addition, it should be understood that the heuristic strategy parameters are generally used to control the exploration direction and strategy of the large model when solving problems. When multiple error corrections fail, it indicates that the current strategy may be too dependent on existing experience and has not fully explored new possibilities. Therefore, the heuristic strategy parameters can be increased according to the correction results and / or the error information output by the second agent, so that the large model associated with the second agent and / or the large model associated with the third agent can more flexibly adjust the analysis path and strategy, thereby trying new error recognition strategies and / or new error correction strategies, and then completing the correction of the query statement. In other words, by adopting an intelligent heuristic correction strategy, the large model associated with the second agent and / or the large model associated with the third agent can not be limited to fixed rule replacement when facing the query statement to be corrected, but can select the best correction solution from a variety of correction solutions based on the nature of the error, the database structure and / or the user's query intention.
[0094] Among other things, the error reference can be determined by:
[0095] Determine sample information, which includes a sample query statement to be corrected, a sample data table structure, a sample error correction description text, and a correct query statement corresponding to the sample query statement; determine a first sample prompt word by a first agent based on the sample information, and send the first sample prompt word to a second agent, the second agent is used to perform error recognition on the sample query statement based on the first sample prompt word through an associated large model, obtain sample error information for the sample query statement, and send the sample error information to the first agent; determine a second sample prompt word by the first agent based on the sample error information and the sample information, and send the second sample prompt word to a third agent, the third agent is used to perform error correction on the sample query statement based on the second sample prompt word through an associated large model, and obtain a corrected target sample query statement; use the sample information, sample error information, and target sample query statement as error reference information.
[0096] It should be understood that after the sample query statement is corrected in the above manner, the sample query statement may be corrected to a correct sample query statement, or may not be corrected to a correct sample query statement. Therefore, in order to enable the second intelligent agent to accurately identify errors based on the error reference information, after obtaining the target sample query statement, the sample correction result for the sample query statement can be determined. The sample correction result is used to indicate whether the error correction for the sample query statement is completed. When the sample correction result indicates that the error correction for the sample query statement is not completed, the first sample prompt information and / or the second sample prompt information can be optimized, and based on the optimized first sample prompt information and / or the second sample prompt information, the sample query statement can be re-corrected until the sample correction result indicates that the error correction for the sample query statement is completed.
[0097] Among them, the first sample prompt information and / or the second sample prompt information are optimized, and based on the optimized first sample prompt information and / or the second sample prompt information, the sample query statement is re-corrected until the sample correction result indicates that the error correction of the sample query statement is completed. The implementation method can refer to the aforementioned process of optimizing the first prompt word and / or the second prompt word, and will not be repeated here.
[0098] In a possible manner, sample information, sample error information, and corrected query statements may be used as error reference information, which may include:
[0099] After obtaining a preset number of sample error information, the preset number of sample error information, the sample information corresponding to the preset number of sample error information, and the corrected query statement are sent to the fourth intelligent agent through the first intelligent agent. The fourth intelligent agent is used to aggregate the preset number of sample error information, the sample information corresponding to the preset number of sample error information, and the corrected query statement to obtain error reference information.
[0100] Through the above method, after obtaining a preset number of sample error information, the first agent can send the preset number of sample error information, the corresponding sample information, and the target sample query statement to the fourth agent through the first agent, thereby reducing the frequency of interaction between the first agent and the fourth agent, thereby improving the processing performance of the first agent and further improving the correction efficiency. In addition, as mentioned above, for each set of sample information, error identification and error correction may be repeated. Therefore, a set of sample information may generate multiple sample error information and multiple target sample query statements. Therefore, in order to enable the second agent to accurately and comprehensively identify error information in different query statements based on error reference information, the fourth agent, after receiving the preset number of sample error information, the corresponding sample information, and the target sample query statement, can aggregate the preset number of sample error information, the corresponding sample information, and the target sample query statement, classify and summarize the different sample error information, and mine the correlation between the different sample error information and the correspondence between the different sample error information, different target sample query statements, and different sample information, so as to generate a set of error correction guidelines, i.e., error reference information. As a result, in actual applications, the second agent can accurately identify error information in different query statements based on error reference information, which enables the third agent to correct errors more accurately, improve the overall correction efficiency and accuracy, and better meet actual application needs.
[0101] To facilitate understanding of the multi-agent-based query statement correction method provided by the embodiment of the present disclosure, the scheme is further explained below in conjunction with the accompanying drawings.
[0102] For example, Figure 2 As shown, a query correction system can be constructed based on the first, second, and third agents. Before the query correction system corrects queries in actual application scenarios, a sample information set can be constructed and the associated large model in the query correction system can be trained based on the sample information set. The sample information set can include multiple sets of sample information, each set of sample information can include a sample query to be corrected, a sample data table structure, sample error correction description text, a corrected query corresponding to the sample query, sample domain knowledge, and sample prompt information. The sample domain knowledge and sample prompt information can be optional.
[0103] When training a large model associated with a query statement correction system based on multiple sets of sample information, the following process can be performed by the first agent:
[0104] For each set of sample information, it can be determined whether the sample query statement needs to be corrected. If correction is required, a first sample prompt word is determined based on the sample information and a preset prompt word template, and the first sample prompt word is sent to the second agent. The second agent is used to perform error recognition on the sample query statement based on the first sample prompt word using an associated large model, obtain first sample error information for the sample query statement, and send the first sample error information to the first agent.
[0105] Determine a second sample prompt word based on the first sample error information and the sample information, and send the second sample prompt word to a third agent. The third agent is configured to correct the error of the sample query statement based on the second sample prompt word using the associated large model to obtain a corrected target sample query statement, and send the corrected target sample query statement to the first agent.
[0106] Determining, based on a target sample query statement, a correction result indicating whether error correction for the sample query statement is complete; if the correction result indicates that error correction for the sample query statement is complete, replacing the next set of sample information; if the correction result indicates that error correction for the sample query statement is not complete, determining the number of corrections for the sample query statement, and optimizing the first sample prompt word based on the first sample error information and the number of corrections to obtain a third sample prompt word, and sending the third sample prompt word to a second agent, the second agent being configured to perform error recognition on the sample query statement based on the third sample prompt word, obtain second error information for the sample query statement, and send the second error information to the first agent;
[0107] Based on the number of corrections, the target sample query, and the second error information, the second sample prompt word is optimized to obtain a fourth sample prompt word, and the fourth sample prompt word is sent to the third agent. The third agent is used to correct the query error based on the fourth sample prompt word using the associated large model to obtain a new target query statement, and the new target query statement is sent to the first agent;
[0108] The first agent again determines a correction result indicating whether the error correction for the sample query statement is completed based on the target sample query statement, and executes corresponding steps according to the correction result until the correction result indicates that the error correction for the sample query statement is completed.
[0109] After obtaining a preset number of sample error information, the preset number of sample error information, the corresponding sample information and the target sample query statement can be sent to the fourth agent through the first agent. The fourth agent is used to aggregate the preset number of sample error information, the corresponding sample information and the target sample query statement to obtain error reference information, and send the error reference information to the first agent.
[0110] After the first agent obtains the error reference information, it can obtain the error correction information in the actual application scenario through the first agent, and complete the correction of the query statement in the error correction information based on the closed collaboration of the first agent, the second agent and the third agent.
[0111] The error reference information at least includes the query statement to be corrected, the data table structure used for data query by the query statement, and the error correction description text for the query statement. In a possible manner, in order to further improve the correction effect, the error reference information may also include other content, such as domain knowledge and prompt information. That is to say, when the first prompt word is generated by the first intelligent agent, the first prompt word must include the error reference information, the query statement, the error correction description text and the data table structure, and the domain knowledge and prompt information and other contents may be optionally added to the first prompt word. When the second prompt word is generated by the first intelligent agent, the second prompt word must include the query statement, the error correction description text, the data table structure and the error information, and the domain knowledge and prompt information and other contents may be optionally added to the first prompt word.
[0112] Through this approach, query error recognition and correction can be automated through multi-agent collaboration. This reduces the number of errors and corrections caused by human negligence during the manual correction process, thereby improving correction efficiency and reducing the probability of error correction. Furthermore, since error correction is performed through multi-agent collaboration, different agents can focus on their specific areas of expertise, further improving the effectiveness of error correction.
[0113] Based on the same concept, the embodiment of the present disclosure also provides a query statement correction device based on multi-agents, such as Figure 3 As shown, the multi-agent-based query statement correction device 300 may include:
[0114] An acquisition module 301 is configured to acquire error correction information through a first agent, the error correction information including a query statement to be corrected, a data table structure used for querying data using the query statement, and a description text of the error correction for the query statement;
[0115] A first processing module 302 is configured to determine, by the first agent, a first prompt word based on the error correction information and preset error reference information, and send the first prompt word to the second agent. The second agent is configured to perform error recognition on the query statement based on the first prompt word using an associated large model, obtain first error information for the query statement, and send the first error information to the first agent.
[0116] The second processing module 303 is used to determine the second prompt word based on the first error information and error correction information through the first intelligent agent, and send the second prompt word to the third intelligent agent. The third intelligent agent is used to correct the error of the query statement based on the second prompt word through the associated large model to obtain the target query statement.
[0117] The multi-agent-based query correction device 300 described above can automatically identify and correct query errors through multi-agent collaboration. This reduces the number of errors and corrections caused by human negligence during the manual correction process, thereby improving correction efficiency and reducing the probability of error correction. Furthermore, because error correction is performed through multi-agent collaboration, different agents can focus on their specific areas of expertise during the correction process, further enhancing the effectiveness of error correction.
[0118] In a possible manner, the third agent is further configured to send the target query statement to the first agent. Accordingly, the multi-agent-based query statement correction apparatus 300 may further include:
[0119] A first determining module is configured to determine, by a first agent, a correction result based on a target query statement, the correction result being used to indicate whether the error correction for the query statement is completed;
[0120] The third processing module is configured to, when the correction result indicates that the error correction for the query statement is not completed, execute the following steps through the first agent:
[0121] determining a number of corrections for the query statement, and optimizing the first prompt word based on the first error message and the number of corrections to obtain a third prompt word, and sending the third prompt word to the second agent; the second agent is configured to identify an error in the query statement based on the third prompt word using an associated large model, obtain second error information for the query statement, and send the second error information to the first agent;
[0122] Based on the second error information and the error correction information, a fourth prompt word is determined and sent to a third agent. The third agent is used to correct the query statement according to the fourth prompt word through the associated large model to obtain a new target query statement.
[0123] In a possible manner, the third agent is further configured to send the target query statement to the first agent. Accordingly, the multi-agent-based query statement correction apparatus 300 may further include:
[0124] A second determining module is configured to determine, by the first agent, a correction result based on the target query statement, the correction result being used to indicate whether the error correction for the query statement is completed;
[0125] The fourth processing module is configured to, when the correction result indicates that the error correction for the query statement is not completed, execute the following steps through the first agent:
[0126] Determine the number of corrections for the query statement, and optimize the second prompt word based on the number of corrections, the target query statement and the first error message to obtain a fifth prompt word, and send the fifth prompt word to a third intelligent agent. The third intelligent agent is used to correct the query statement based on the fifth prompt word through an associated large model to obtain a new target query statement.
[0127] In a possible manner, the third agent is further configured to send the target query statement to the first agent. Accordingly, the multi-agent-based query statement correction apparatus 300 may further include:
[0128] A third determining module is configured to determine, by the first agent, a correction result based on the target query statement, the correction result being used to indicate whether the error correction for the query statement is completed;
[0129] The fifth processing module is configured to, when the correction result indicates that the error correction for the query statement is not completed, execute the following steps through the first agent:
[0130] determining a number of corrections for the query statement, optimizing the first prompt word based on the first error message and the number of corrections to obtain a sixth prompt word, and sending the sixth prompt word to the second agent; the second agent identifying an error in the query statement based on the sixth prompt word, obtaining third error information for the query statement, and sending the third error information to the first agent;
[0131] Based on the number of corrections, the target query statement and the third error message, the second prompt word is optimized to obtain the seventh prompt word, and the seventh prompt word is sent to the third intelligent agent. The third intelligent agent is used to correct the query statement based on the seventh prompt word through the associated large model to obtain a new target query statement.
[0132] In a possible manner, the multi-agent-based query statement correction device 300 may further include:
[0133] A fourth determining module is configured to determine, by the first agent, a correction result based on the target query statement, the correction result being used to indicate whether the error correction for the query statement is completed;
[0134] An adjustment module is used to adjust the heuristic strategy parameters of the large model associated with the second agent and / or the heuristic strategy parameters of the large model associated with the third agent according to the correction result and / or the error information output by the second agent when the correction result indicates that the error correction for the query statement is not completed.
[0135] In a possible manner, the erroneous reference information includes a correct reference query statement. Accordingly, the fourth determining module is configured to execute the following process through the first agent:
[0136] Determine a reference query statement corresponding to the query statement in the error reference information; determine a first correction result for the query statement based on the semantic information of the target query statement and the semantic information of the reference query statement, the first correction result is used to indicate whether the semantics of the target query statement are consistent with the semantics of the reference query statement; determine the first data queried in the data table structure through the query statement, and determine the second data queried in the data table structure through the reference query statement, and determine a second correction result for the query statement based on the first data and the second data, the second correction result is used to indicate whether the first data is consistent with the second data; determine the correction result for the query statement based on the first correction result and the second correction result.
[0137] In a possible manner, the multi-agent-based query statement correction device 300 may further include:
[0138] The sixth processing module is used to determine sample information, which includes a sample query statement to be corrected, a sample data table structure, a sample error correction description text, and a correct query statement corresponding to the sample query statement; the first intelligent agent determines a first sample prompt word based on the sample information, and sends the first sample prompt word to the second intelligent agent, and the second intelligent agent is used to perform error recognition on the sample query statement based on the first sample prompt word through an associated large model, obtain sample error information for the sample query statement, and send the sample error information to the first intelligent agent; the first intelligent agent determines a second sample prompt word based on the sample error information and the sample information, and sends the second sample prompt word to the third intelligent agent, and the third intelligent agent is used to perform error correction on the sample query statement based on the second sample prompt word through an associated large model to obtain a corrected target sample query statement; the sample information, sample error information, and target sample query statement are used as error reference information.
[0139] In a possible manner, the sixth processing module can also be used to send the preset number of sample error information, the sample information corresponding to the preset number of sample error information, and the target sample query statement to the fourth intelligent agent through the first intelligent agent after obtaining the preset number of sample error information, and the fourth intelligent agent is used to aggregate the preset number of sample error information, the sample information corresponding to the preset number of sample error information, and the target sample query statement to obtain error reference information.
[0140] In a possible manner, the first error information may include an error type. Accordingly, the second processing module may be used to determine the target prompt word template corresponding to the error type through the first intelligent agent based on the error type and a preset prompt word template library, and determine the second prompt word based on the first error information, the error correction information and the target prompt word template, wherein the prompt word template library is used to store the correspondence between the prompt word template and the error type.
[0141] In a possible embodiment, the query statement is a structured query language statement.
[0142] Based on the same concept, an embodiment of the present disclosure also provides a computer-readable medium on which a computer program is stored. When the program is executed by a processing device, the program implements the steps of any of the above-mentioned multi-agent-based query statement correction methods.
[0143] Based on the same concept, an embodiment of the present disclosure further provides an electronic device, which may include:
[0144] a storage device having a computer program stored thereon;
[0145] A processing device is used to execute the computer program in the storage device to implement the steps of any of the above-mentioned multi-agent-based query statement correction methods.
[0146] Based on the same concept, an embodiment of the present disclosure also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned multi-agent-based query statement correction methods.
[0147] Reference below Figure 4 , which shows a schematic structural diagram of an electronic device 400 suitable for implementing an embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0148] like Figure 4 As shown, electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 402 or programs loaded from a storage device 408 into a random access memory (RAM) 403. Various programs and data required for the operation of electronic device 400 are also stored in RAM 403. Processing device 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to bus 404.
[0149] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0150] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0151] It should be noted that the computer-readable medium described above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. Computer-readable storage media may include, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or components, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such a propagated data signal may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wire, optical cable, RF (radio frequency), or any suitable combination thereof.
[0152] In some embodiments, communications may be conducted using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.
[0153] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0154] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains error correction information through the first intelligent agent, the error correction information includes the query statement to be corrected, the data table structure used for data query of the query statement, and the error correction description text for the query statement; determines the first prompt word through the first intelligent agent based on the error correction information and the preset error reference information, and sends the first prompt word to the second intelligent agent, the second intelligent agent is used to perform error recognition on the query statement based on the first prompt word through the associated large model, obtains the first error information for the query statement, and sends the first error information to the first intelligent agent; determines the second prompt word through the first intelligent agent based on the first error information and the error correction information, and sends the second prompt word to the third intelligent agent, the third intelligent agent is used to perform error correction on the query statement based on the second prompt word through the associated large model to obtain the target query statement.
[0155] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0157] The modules described in the embodiments of the present disclosure may be implemented in software or hardware, wherein the name of a module does not necessarily limit the module itself.
[0158] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0159] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0160] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the present disclosure is not limited to technical solutions formed by specific combinations of the aforementioned technical features. It also encompasses other technical solutions formed by any combination of the aforementioned technical features or their equivalents, without departing from the scope of the above disclosure. For example, a technical solution formed by replacing the aforementioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0161] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0162] Although the subject matter has been described using language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims. Regarding the apparatus in the above-described embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method and will not be elaborated upon here.
Claims
1. A query statement correction method based on multi-agent, characterized in that: The multi-agent based query statement correction method includes: Acquiring error correction information through the first agent, the error correction information including a query statement to be corrected, a data table structure used for performing data query on the query statement, and a description text of the error correction for the query statement; The first agent determines a first prompt word based on the error correction information and preset error reference information, and sends the first prompt word to a second agent. The second agent is configured to perform error recognition on the query statement based on the first prompt word using an associated large model, obtain first error information for the query statement, and send the first error information to the first agent. The first agent determines a second prompt word based on the first error information and the error correction information, and sends the second prompt word to the third agent. The third agent is used to correct the error of the query statement based on the second prompt word through the associated large model to obtain the target query statement.
2. The multi-agent based query statement correction method according to claim 1, characterized in that: The third agent is further configured to send the target query statement to the first agent, and the multi-agent-based query statement correction method further includes: determining, by the first agent, a correction result according to the target query statement, wherein the correction result is used to indicate whether the error correction for the query statement is completed; If the correction result indicates that the error correction for the query statement is not completed, the first agent performs the following process: Determining a number of revisions to the query statement; Based on the first error message and the number of corrections, the first prompt word is optimized to obtain a third prompt word, and the third prompt word is sent to the second agent. The second agent is configured to perform error recognition on the query statement based on the third prompt word using an associated large model, obtain second error message for the query statement, and send the second error message to the first agent. Based on the second error information and the error correction information, a fourth prompt word is determined and sent to the third agent. The third agent is used to correct the error of the query statement according to the fourth prompt word through the associated large model to obtain a new target query statement.
3. The multi-agent based query statement correction method according to claim 1, characterized in that: The third agent is further configured to send the target query statement to the first agent, and the multi-agent-based query statement correction method further includes: determining, by the first agent, a correction result according to the target query statement, wherein the correction result is used to indicate whether the error correction for the query statement is completed; If the correction result indicates that the error correction for the query statement is not completed, the first agent performs the following process: Determining a number of revisions to the query statement; Based on the number of corrections, the target query statement and the first error message, the second prompt word is optimized to obtain a fifth prompt word, and the fifth prompt word is sent to the third intelligent agent. The third intelligent agent is used to correct the error of the query statement based on the fifth prompt word through the associated large model to obtain a new target query statement.
4. The multi-agent based query statement correction method according to claim 1, characterized in that: The third agent is further configured to send the target query statement to the first agent, and the multi-agent-based query statement correction method further includes: determining, by the first agent, a correction result according to the target query statement, wherein the correction result is used to indicate whether the error correction for the query statement is completed; If the correction result indicates that the error correction for the query statement is not completed, the first agent performs the following process: Determining a number of revisions to the query statement; Based on the first error message and the number of corrections, the first prompt word is optimized to obtain a sixth prompt word, and the sixth prompt word is sent to the second agent. The second agent is configured to perform error recognition on the query statement based on the sixth prompt word, obtain third error message for the query statement, and send the third error message to the first agent. Based on the number of corrections, the target query statement and the third error message, the second prompt word is optimized to obtain a seventh prompt word, and the seventh prompt word is sent to the third intelligent agent. The third intelligent agent is used to correct the error of the query statement based on the seventh prompt word through the associated large model to obtain a new target query statement.
5. The multi-agent based query statement correction method according to any one of claims 1 to 4, characterized in that: The multi-agent based query statement correction method further includes: determining, by the first agent, a correction result according to the target query statement, wherein the correction result is used to indicate whether the error correction for the query statement is completed; When the correction result indicates that the error correction for the query statement is not completed, the heuristic strategy parameters of the large model associated with the second agent and / or the heuristic strategy parameters of the large model associated with the third agent are adjusted according to the correction result and / or the error information output by the second agent.
6. The multi-agent based query statement correction method according to claim 5, characterized in that: The erroneous reference information includes a correct reference query statement, and the determining, by the first agent, a correction result based on the target query statement includes: The following process is performed by the first agent: Determining a reference query statement corresponding to the query statement in the error reference information; Determining a first correction result for the query statement based on the semantic information of the target query statement and the semantic information of the reference query statement, wherein the first correction result is used to indicate whether the semantics of the target query statement are consistent with the semantics of the reference query statement; determining first data retrieved from the data table structure by the query statement, and determining second data retrieved from the data table structure by the reference query statement, and determining a second revised result for the query statement based on the first data and the second data, the second revised result being used to indicate whether the first data is consistent with the second data; A correction result for the query statement is determined according to the first correction result and the second correction result.
7. The multi-agent based query statement correction method according to any one of claims 1 to 4, characterized in that: The error reference information is determined as follows: Determining sample information, the sample information including a sample query statement to be corrected, a sample data table structure, a sample error correction description text, and a correct query statement corresponding to the sample query statement; The first agent determines a first sample prompt word based on the sample information, and sends the first sample prompt word to the second agent; the second agent is configured to perform error recognition on the sample query statement based on the first sample prompt word using an associated large model, obtain sample error information for the sample query statement, and send the sample error information to the first agent; The first agent determines a second sample prompt word based on the sample error information and the sample information, and sends the second sample prompt word to the third agent, wherein the third agent is configured to correct the error of the sample query statement based on the second sample prompt word using an associated large model to obtain a corrected target sample query statement; The sample information, the sample error information, and the target sample query statement are used as error reference information.
8. The multi-agent based query statement correction method according to claim 7, characterized in that: The using the sample information, the sample error information, and the target sample query statement as error reference information includes: After obtaining the preset number of sample error information, the preset number of sample error information, the sample information corresponding to the preset number of sample error information, and the target sample query statement are sent to the fourth agent through the first agent, and the fourth agent is used to aggregate the preset number of sample error information, the sample information corresponding to the preset number of sample error information, and the target sample query statement to obtain error reference information.
9. The multi-agent based query statement correction method according to any one of claims 1 to 4, characterized in that: The first error information includes an error type, and the first agent determines a second prompt word according to the first error information and the error correction information, including: The first intelligent agent determines a target prompt word template corresponding to the error type based on the error type and a preset prompt word template library, and determines a second prompt word based on the first error information, the error correction information and the target prompt word template, wherein the prompt word template library is used to store the correspondence between prompt word templates and error types.
10. The multi-agent based query statement correction method according to any one of claims 1 to 4, characterized in that: The query statement is a structured query language statement.
11. A query statement correction device based on multi-agent, characterized in that: The multi-agent-based query statement correction device includes: an acquisition module, configured to acquire error correction information through the first agent, the error correction information including a query statement to be corrected, a data table structure for performing data query based on the query statement, and a description text of the error correction for the query statement; a first processing module configured to determine, by the first agent, a first prompt word based on the error correction information and preset error reference information, and send the first prompt word to a second agent; the second agent configured to perform error recognition on the query statement based on the first prompt word using an associated large model, obtain first error information for the query statement, and send the first error information to the first agent; The second processing module is used to determine a second prompt word through the first intelligent agent based on the first error information and the error correction information, and send the second prompt word to the third intelligent agent. The third intelligent agent is used to correct the error of the query statement based on the second prompt word through the associated large model to obtain the target query statement.
12. A computer-readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 10 are implemented.
13. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 10.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Natural language intelligent query method and device based on multi-agent interaction
CN118012900A
Library query system, method and equipment based on information retrieval and large model and medium
CN118733611A