Multi-agent-based query statement correction method and device, equipment and product
Through the multi-agent collaboration process, the problem of inefficient manual correction is solved and efficient and accurate data query is achieved.
Patent Information
- Application Number
- CN202510813306.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-06-17
AI Technical Summary
In the prior art, there are problems of poor correction effect and low efficiency in correcting SQL statements based on manual methods, especially in big data queries that are prone to errors and inefficient efficiency.
Through the cooperation of multiple agents, the first agent obtains error correction information, the second agent uses the associated large model to perform error recognition, and the third agent performs error correction, forming a closed-loop collaboration process, and automatically implements error recognition and correction of query statements.
It reduces errors and omissions caused by human negligence during manual correction, improves correction efficiency and effectiveness, and ensures the accuracy and reliability of data query.
Smart Images

Figure CN120336361A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of large models, intelligent agents, and artificial intelligence. Specifically, it relates to a method, apparatus, device, and product for query statement correction based on multiple intelligent agents. Background Art
[0002] With the advent of the big data era, data has grown explosively. To quickly obtain target data from a database, data can generally be queried from the database through a query statement. For example, a large language model can be used to generate a SQL (Structured Query Language) statement based on user requirements, and then data can be queried from the database based on this SQL statement.
[0003] However, when generating a SQL statement based on a large language model, there may be cases where the SQL statement is incorrect. Therefore, after obtaining the SQL statement output by the large language model, the SQL statement generally needs to be corrected. However, in related technologies, the SQL statement is generally corrected manually, which has problems such as poor correction effect and low correction efficiency. Summary of the Invention
[0004] This Summary of the Invention section is provided to introduce concepts in a brief form, which will be described in detail in the subsequent Detailed Description section. This Summary of the Invention section 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 method for query statement correction based on multiple intelligent agents. The method for query statement correction based on multiple intelligent agents includes: Obtaining error correction information through a first intelligent agent, where the error correction information includes a query statement to be corrected, a data table structure for data query using the query statement, and an error correction description text for the query statement; Determining, by the first intelligent agent, a first prompt word based on the error correction information and preset error reference information, and sending the first prompt word to a second intelligent agent, where the second intelligent agent is used to identify errors in the query statement based on the first prompt word through an associated large model, obtain first error information for the query statement, and send the first error information to the first intelligent agent; Determining, by the first intelligent agent, a second prompt word based on the first error information and the error correction information, and sending the second prompt word to a third intelligent agent, where the third intelligent agent is used to correct errors in the query statement based on the second prompt word through an associated large model to obtain a target query statement.
[0006] Second aspect, the present disclosure provides a query statement correction device based on multi-agent, and the query statement correction device based on multi-agent includes: An acquisition module, configured to obtain error correction information through a first agent, where the error correction information includes a query statement to be corrected, a data table structure for data query using the query statement, and an error correction description text for the query statement; A first processing module, configured to determine a first prompt word through the first agent according to the error correction information and preset error reference information, and send the first prompt word to a second agent, where the second agent is configured to identify an error in the query statement according to the first prompt word through an associated large model, obtain first error information for the query statement, and send the first error information to the first agent; A second processing module, configured to determine a second prompt word through the first agent according to the first error information and the error correction information, and send the second prompt word to a third agent, where the third agent is configured to correct the error in the query statement according to the second prompt word through an associated large model, and obtain a target query statement.
[0007] Third aspect, the present disclosure provides a computer-readable medium, on which a computer program is stored, and when the computer program is executed by a processing device, the steps of the method described in the first aspect are implemented.
[0008] Fourth aspect, the present disclosure provides an electronic device, including: A storage device, on which a computer program is stored; A processing device, configured to execute the computer program in the storage device to implement the steps of the method described in the first aspect.
[0009] Fifth aspect, the present disclosure provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0010] Through the above technical solution, the first intelligent agent can determine the first prompt word based on the preset error reference information and the obtained error correction information, and can send the first prompt word to the second intelligent agent; after receiving the first prompt word, the second intelligent agent can, through the associated large model, identify the error in the query statement in the error correction information according to the first prompt word, obtain the first error information for the query statement, and can send the first error information to the first intelligent agent; after receiving the first error information, the first intelligent agent can determine the second prompt word based on the first error information and the error correction information, and can send the second prompt word to the third intelligent agent; after receiving the second prompt word, the third intelligent agent can, through the associated large model, correct the error in the query statement according to the second prompt word to obtain the target query statement. Thus, a closed-loop collaboration process can be formed based on the first intelligent agent, the second intelligent agent, and the third intelligent agent, that is: the error identification and error correction of the query statement can be automatically realized through the collaboration of multiple intelligent agents, thereby reducing the error omission and error correction caused by human negligence in the manual correction process, and further improving the correction efficiency. In addition, since the error correction is based on the collaboration of multiple intelligent agents, different intelligent agents can focus on their respective specific fields of expertise during the correction process, thereby further improving the error correction effect.
[0011] Other features and advantages of the present disclosure will be described in detail in the subsequent specific implementation part. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In combination with the accompanying drawings and with reference to the following specific implementation manners, the above and other features, advantages and aspects of the various embodiments of the present disclosure will become more obvious. Throughout the accompanying drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic and the original elements and elements are not necessarily drawn to scale. In the drawings: Figure 1 is a flowchart of a method for correcting a query statement based on multiple intelligent agents according to an exemplary embodiment of the present disclosure; Figure 2 is a flowchart of another method for correcting a query statement based on multiple intelligent agents according to an exemplary embodiment of the present disclosure; Figure 3 is a structural block diagram of a device for correcting a query statement based on multiple intelligent agents according to an exemplary embodiment of the present disclosure; Figure 4 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0013] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the 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 set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.
[0014] It should be understood that the various steps recited in the method embodiments of the present disclosure can be executed in a different order 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 regard.
[0015] The term "including" and its variations used herein are open-ended, that is, "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0016] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependent relationships.
[0017] It should be noted that the modifications of "one" and "plural" mentioned in the present disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly specified in the context, it should be understood as "one or more".
[0018] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.
[0019] It can be understood that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, usage scopes, usage scenarios, etc. of the personal information involved in the present 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.
[0020] For example, when responding to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested by the user will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, an application program, a server or a storage medium that performs the operations of the technical solutions of the present disclosure according to the prompt message.
[0021] As an optional but non-limiting implementation manner, in response to receiving an active request from a user, the manner of sending a prompt message to the user may be, for example, in the form of a pop-up window, and the prompt message may be presented in text in the pop-up window. In addition, the pop-up window may also carry selection controls for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0022] It can be understood that the above notification and user authorization acquisition process is only illustrative and does not limit the implementation manner of the present disclosure. Other manners that comply with relevant laws and regulations can also be applied to the implementation manner of the present disclosure.
[0023] At the same time, it can be understood that the data involved in the present technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of corresponding laws, regulations and related regulations.
[0024] As described in the background art, in the related art, SQL statements are generally corrected manually, and there are problems such as poor correction effect and low correction efficiency.
[0025] Exemplarily, with the rise of large language models, Text2SQL (Text to Structured Query Language) technology has emerged. Text2SQL technology can convert the natural language query requirements input by the user into corresponding SQL statements, then execute the SQL statements in the database, and finally return the query results to the user.
[0026] When performing data query based on this method, although the difficulty of data query can be reduced, due to the complexity and diversity of natural language, as well as the limitations of the Text2SQL model in understanding certain semantics, there are cases where the Text2SQL outputs incorrect SQL statements. To avoid performing data query based on incorrect SQL statements, generally, after the Text2SQL outputs the SQL statements, it is necessary to manually correct the SQL statements output by the Text2SQL.
[0027] However, when manually correcting SQL statements, users generally only focus on the correspondence between natural language query requirements and SQL statements, and know little about the complete structure of the data table. Especially when the data table to be queried contains a large number of fields, it is necessary to manually check the fields in the SQL statements one by one to ensure the accuracy of field selection. This process is not only inefficient but also extremely prone to errors, resulting in inaccurate data query results or even query failures, seriously affecting the reliability of data query and the user experience.
[0028] In view of this, the present disclosure provides a query statement correction method, device, device and product based on multi-agent to solve the above technical problems.
[0029] The following further explains the embodiments of the present disclosure in conjunction with the accompanying drawings.
[0030] Figure 1 is a flowchart of a query statement correction method based on multi-agent shown according to an exemplary embodiment of the present disclosure. Referring to Figure 1 this, the query statement correction method based on multi-agent may include the following steps: 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 for querying data using the query statement, and an error correction description text for the query statement.
[0031] It should be understood that an agent refers to an entity that can perceive the environment and take actions to achieve specific goals, which can be software, hardware, or a system, and has autonomy, adaptability, and interaction capabilities. Thus, the agents involved in the present disclosure can be servers deployed with large models, or terminal devices deployed with large models. Of course, it can also be others, and the embodiments of the present disclosure do not impose any restrictions on this. By way of example, the large models involved in the present disclosure can be large language models or multi-modal large models, etc.
[0032] For example, when the first agent is a server deployed with a large model, obtaining error correction information through the first agent can be: displaying a first page for the user to input error correction information in a terminal device that has established a communication connection with the first agent, and in response to the user inputting error correction information on the first page, obtaining the error correction information through the first agent. It can also be: displaying a second page for the user to input natural language query requirements in a terminal device that has established a communication connection with the first agent, and in response to the user inputting natural language query requirements on the second page, converting the natural language query requirements input by the user into a corresponding query statement through a preset large language model. After converting the natural language query requirements into a query statement, the query statement can be used as the query statement to be corrected, and the natural language query requirements can be sent to the first agent with this query statement, so that the first agent can determine the data table structure based on the natural language query requirements, and can determine the error correction description text based on the natural language query requirements and this query statement, thereby obtaining the error correction information. Of course, it can also be others, and the embodiments of the present disclosure do not impose any restrictions on this.
[0033] For another example, when the first intelligent agent is a terminal device deployed with a large model, obtaining error correction information through the first intelligent agent can be as follows: A third page for the user to input error correction information can be displayed in the first intelligent agent, and when the user inputs error correction information on the third page, the error correction information is obtained. It can also be: A fourth page for the user to input natural language query requirements is displayed in the first intelligent agent. When the user inputs natural language query requirements on the fourth page, the natural language query requirements input by the user are converted into corresponding query statements through a preset large language model. After converting the natural language query requirements into query statements, the query statements can be used as the query statements to be corrected, and the data table structure can be determined based on the natural language query requirements, and the error correction description text can be determined based on the natural language query requirements and the query statements, so as to obtain the error correction information. Of course, there can be other ways, and the embodiments of the present disclosure do not impose any restrictions on this.
[0034] It should be understood that a query statement is an instruction used to retrieve, filter, count, or operate on data from a database. Depending on the database, the query statement can be a MongoDB query statement, a Redis query statement, or of course others, and the embodiments of the present disclosure do not impose any restrictions on this. Given that the SQL query statement is a standardized query language and its syntax and functions are supported in most relational database systems, thus, in a possible way, the query statement can be a structured query language statement.
[0035] S102: The first intelligent agent determines a first prompt word according to the error correction information and preset error reference information, and sends the first prompt word to the second intelligent agent. The second intelligent agent is used to identify errors in the query statement according to 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.
[0036] In this embodiment, determining the first prompt word can be as follows: A prompt word template a is preset. Thus, after the first intelligent agent obtains the error correction information, the error correction information and the preset error reference information can be filled into the corresponding positions in the prompt word template a to obtain the first prompt word; or, based on the template format a of the prompt word template a, the first prompt word with the same format as the template format a can be generated according to the error correction information and the preset error reference information. It can also be: After the first intelligent agent obtains the error correction information, based on the large model associated with the first intelligent agent, the first prompt word is randomly generated according to the error correction information and the preset error reference information. Of course, the first prompt word can also be determined by other means, and the embodiments of the present disclosure do not impose any restrictions on this.
[0037] S103: The first agent determines a second prompt word according to 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 perform error correction on the query statement according to the second prompt word through the associated large model to obtain the target query statement.
[0038] In this embodiment, the second prompt word can be determined by: presetting a prompt word template b, so that after the first agent receives the first error message, the first error message and the error correction information can be filled into the corresponding position in the prompt word template b, thereby obtaining the second prompt word; or, based on the template format b of the prompt word template b, according to the first error message and the error correction information, a first prompt word with the same template format b can be generated. Alternatively, after the first agent receives the first error message, based on the large model associated with the first agent, the second prompt word is randomly generated according to the first error message and the error correction information. Of course, the second prompt word can also be determined by other methods, and the embodiment of the present disclosure does not impose any restrictions on this.
[0039] 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 a possible way, in order to improve the accuracy of error correction, a prompt word template can be set for each error type. For example, for a syntax error type, 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 a logical error type, the prompt word template can be: "You are a database expert. Please correct the query statement's query conditions, field references, and / or conditional expressions 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 meet 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, and then when the query statement is corrected according to the second prompt word, the position to be corrected can be quickly located, and the correction can be carried out in a targeted manner, thereby improving the correction effect and efficiency.
[0040] That is to say, among possible ways, the first error message may include an error type. Correspondingly, the second prompt word is determined by the first agent according to the first error message and the error correction information, which may include: the first agent determines a target prompt word template corresponding to the error type according to the error type and a preset prompt word template library, and determines the second prompt word according to the first error message, the error correction information, and the target prompt word template, where the prompt word template library is used to store the correspondence between the prompt word template and the error type.
[0041] Among possible ways, in order to further improve the correction effect and efficiency, if it is found that the use effect of some prompt word templates in the prompt word template library is not good during actual use, the first agent can analyze the reasons and modify the prompt word template. In addition, when the second agent is used for error recognition, if a new error type or error scenario is found, 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.
[0042] Through the above technical solution, a closed-loop collaboration process can be formed based on the first agent, the second agent, and the third agent, that is: the error recognition and correction of the query statement can be automatically realized through the cooperation of multiple agents, thereby reducing the error omission and error correction caused by human negligence during the manual correction process, and further improving the correction efficiency. In addition, since the error correction is based on the cooperation of multiple agents, different agents can focus on their respective specific fields during the correction process, thereby further improving the error correction effect.
[0043] To facilitate the understanding of the query statement correction method based on multiple agents provided in this disclosure, the possible implementation manners in this disclosure are described below.
[0044] Among possible ways, the third agent is further used to send the target query statement to the first agent. Correspondingly, the query statement correction method based on multiple agents may further include: The first intelligent agent determines a correction result according to the target query statement, and the correction result is used to indicate whether the error correction for the query statement is completed; in the case where the correction result indicates that the error correction for the query statement is not completed, the first intelligent agent performs the following process: determining the number of correction times for the query statement; optimizing the first prompt word based on the first error information and the number of correction times to obtain a third prompt word, and sending the third prompt word to the second intelligent agent, where the second intelligent agent is used to identify errors in the query statement according to the third prompt word through the associated large model, obtain the second error information for the query statement, and send the second error information to the first intelligent agent; determining a fourth prompt word according to the second error information and the error correction information, and sending the fourth prompt word to the third intelligent agent, where the third intelligent agent is used to correct the error in the query statement according to the fourth prompt word through the associated large model to obtain a new target query statement.
[0045] In this embodiment, whether the error correction for the query statement is completed may mean: whether the query statement is corrected to a correct query statement, or it may mean: within a preset number-of-correction times threshold, whether the query statement is corrected to a correct query statement. Of course, it may also be other, for example, whether the number of correction times of the query statement reaches the preset number-of-correction times threshold. The embodiments of the present disclosure do not make any restrictions on this.
[0046] Exemplarily, if the query statement is not corrected to a correct query statement within the preset number-of-correction times threshold, the correction result can be determined as that the error correction for the query statement is not completed. At this time, the number of correction times for the query statement can be determined, and the first prompt word is optimized based on the first error information and the number of correction times. For example, if the number of correction times is one, the first error information is: the structure of the query statement does not conform to the grammar rules, and the first prompt word is: You are a database expert. Please identify the error in the query statement based on the following content: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC". Then when optimizing the first prompt word based on the first error information and the number of correction times, the first prompt word can be optimized to the following third prompt word: You are a database expert. You have generated the error information once for the following information "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC". The error information is: the structure of the query statement does not conform to the grammar rules. However, when performing error correction based on this error information, the correction was not successful. Please re-check for errors and generate the error information.
[0047] After obtaining the third prompt word, the third prompt word can be sent to the second intelligent agent, which is used to identify errors in the query statement according to the third prompt word through the associated large model, obtain the 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 according to the second error information and the error correction information, and sends the fourth prompt word to the third intelligent agent, which is used to correct the errors in the query statement according to the fourth prompt word through the associated large model to obtain a new target query statement.
[0048] It should be understood that after obtaining the 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 correction times for the query statement can be determined, and the first prompt word can be optimized based on the correction times and the second error information and the subsequent corresponding steps can be executed until the correction result indicates that the error correction for the query statement is completed.
[0049] In the above manner, 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 correction times, so that the optimized first prompt word can better fit the actual situation of the current query statement. Furthermore, when the second intelligent agent performs error identification again based on the optimized first prompt word, it can more accurately locate or describe the problems in the query statement, thereby improving the accuracy of error identification. Furthermore, when the third intelligent agent performs error correction based on the error information output by the second intelligent agent, the efficiency and effect of error correction can be improved.
[0050] Exemplarily, determining the correction result by the first intelligent agent according to the target query statement may include: determining the eighth prompt word by the first intelligent agent according to the target query statement and the data table structure, and sending the eighth prompt word to the second intelligent agent, and the second intelligent agent performs error identification on the target query statement based on the eighth prompt word. If the second intelligent agent identifies an error, it can be determined that the error correction for the query statement is not completed; if the second intelligent agent does not identify an error, it can be determined that the error correction for the query statement is completed.
[0051] Exemplarily, the error reference information may include a correct reference query statement. Correspondingly, determining the correction result by the first intelligent agent according to the target query statement may further include: The first intelligent agent executes the following process: Determine the target reference query statement corresponding to the query statement in the error reference information; based on the semantic information of the target query statement and the semantic information of the target reference query statement, determine the first correction result for the query statement, where the first correction result is used to indicate whether the semantics of the target query statement is consistent with the semantics of the target reference query statement; determine the first data queried by the query statement in the data table structure, and determine the second data queried by the target reference query statement in the data table structure. According to the first data and the second data, determine the second correction result for the query statement, where the second correction result is used to indicate whether the first data is consistent with the second data; according to the first correction result and the second correction result, determine the correction result for the query statement.
[0052] Exemplarily, after obtaining the target query statement, the first intelligent agent can first determine the semantic similarity and / or syntactic similarity between the target query statement and each reference query statement, and can use the reference query statement with the maximum semantic similarity and / or syntactic similarity as the target reference query statement. After obtaining the target reference query statement, on the one hand, a syntax analyzer can be used to construct the syntax trees of the target query statement and the target reference query statement respectively, and the first correction result can be obtained by comparing the structures and / or node contents 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 is 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 is 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, it is determined that the error correction for the query statement has been completed; otherwise, it is determined that the error correction for the query statement has not been completed.
[0053] 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. Since the first correction result is used to indicate whether the semantics of the target query statement is 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 two dimensions of semantics and data consistency, thereby improving the accuracy of the correction result.
[0054] In a possible way, the third intelligent agent is also used to send the target query statement to the first intelligent agent. Correspondingly, the query statement correction method based on multiple intelligent agents can also include: The first intelligent agent determines a correction result according to the target query statement, and the correction result is used to indicate whether the error correction for the query statement is completed; in the case where the correction result indicates that the error correction for the query statement is not completed, the first intelligent agent performs the following process: determining the number of correction times for the query statement, optimizing the second prompt word based on the number of correction times, the target query statement, and the first error message to obtain a fifth prompt word, and sending the fifth prompt word to a third intelligent agent, where the third intelligent agent is used to correct the error of the query statement based on the fifth prompt word through an associated large model to obtain a new target query statement.
[0055] In this embodiment, the manner in which the first intelligent agent determines the correction result according to the target query statement refers to the foregoing related description and will not be elaborated here.
[0056] Exemplarily, continuing to refer to the above example, if the query statement is not corrected to a correct query statement within a preset correction times threshold, the correction result can be determined as that the error correction for the query statement is not completed. At this time, the number of correction times for the query statement can be determined, and the second prompt word can be optimized based on the number of correction times, the target query statement, and the first error message. For example, if the number of correction times is one, the first error message is: the structure of the query statement does not conform to the grammar rules, and the second prompt word is: You are a database expert. Please 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 grammar rules" correct the spelling and format of the query statement to ensure that keywords and symbols are used correctly. Then when optimizing the second prompt word based on the number of correction times, the target query statement, and the first error message, the second prompt word can be optimized to the following fifth prompt word: You are a database expert. You have corrected the following information "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 grammar rules" once, and the corrected target query statement is: KKKKKK, but this target query statement is incorrect. Please re-correct the spelling and format of the query statement to ensure that keywords and symbols are used correctly.
[0057] After obtaining the fifth prompt word, the fifth prompt word can be sent to the third intelligent agent, and the third intelligent agent is used to correct the error of the query statement based on the fifth prompt word through an associated large model to obtain a new target query statement.
[0058] It should be understood that after obtaining the 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 the 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 the subsequent corresponding steps can be executed until the correction result indicates that the error correction for the query statement is completed.
[0059] In the above manner, 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 better fit the actual situation of the current query statement, and further, when the third intelligent agent performs error correction again based on the optimized second prompt word, the efficiency and effect of error correction can be improved.
[0060] In a possible way, the third intelligent agent is also used to send the target query statement to the first intelligent agent. Correspondingly, the query statement correction method based on multiple intelligent agents may further include: The first intelligent agent determines a correction result according to 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 first intelligent agent performs the following process: determines the number of corrections for the query statement, optimizes the first prompt word based on the first error information and the number of corrections to obtain a sixth prompt word, and sends the sixth prompt word to the second intelligent agent. The second intelligent agent is used to perform error recognition on the query statement according to the sixth prompt word to obtain a third error information for the query statement and send the third error information to the first intelligent agent; optimizes 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 sends the seventh prompt word to the third intelligent agent. The third intelligent agent is used to perform error correction on the query statement based on the seventh prompt word through an associated large model to obtain a new target query statement.
[0061] In this embodiment, the manner in which the first intelligent agent determines the correction result according to the target query statement refers to the foregoing related description and will not be elaborated here.
[0062] Exemplarily, continuing to refer to the above example, if the query statement is not corrected to the correct query statement within the preset correction times threshold, the correction result can be determined as the error correction for the query statement is not completed. At this time, the number of correction times 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 correction times. For example, if the number of correction times is one, the first error message is: The structure of the query statement does not conform to the grammar rules, and the first prompt word is: You are a database expert. Please identify the error in the query statement based on the following content: "Query statement: AAAAA; Data table structure: BBBBB; Error correction description text: CCCCC". Then when optimizing the first prompt word based on the first error message and the number of correction times, the first prompt word can be optimized to the following sixth prompt word: You are a database expert. You have generated an error message once 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 grammar rules. However, when correcting the error based on this error message, the correction was not successful. Please re-check for errors and generate an error message.
[0063] 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 the error in the query statement according to the sixth prompt word, obtain the 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 correction times, the target query statement, and the third error message. For example, if the number of correction times 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 the grammar rules" to ensure that the keywords and symbols are used correctly. Then when optimizing the second prompt word based on the number of correction times, the target query statement, and the third error message, the second prompt word can be optimized to the following seventh prompt word: You are a database expert. You have corrected the following information "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 grammar rules" once. The corrected target query statement is: KKKKKK, but this target query statement is incorrect. Please correct the query statement again based on the "Third error message: The field referenced in the query statement does not exist".
[0064] After obtaining the seventh prompt word, the seventh prompt word can be sent to the third intelligent agent, which 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.
[0065] It should be understood that after obtaining the 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 optimized again until the correction result indicates that the error correction for the query statement is completed.
[0066] 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 second prompt word can better fit the actual situation of the current query statement, thereby improving the efficiency and effect of error correction.
[0067] In a possible way, the query statement correction method based on multiple intelligent agents may further include: The first intelligent agent determines a correction result according to 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 intelligent agent and / or the heuristic strategy parameters of the large model associated with the third intelligent agent are adjusted according to the correction result and / or the error information output by the second intelligent agent.
[0068] In this embodiment, the method for the first intelligent agent to determine the correction result according to the target query statement refers to the foregoing related description and will not be elaborated here.
[0069] It should be understood that heuristic strategy parameters generally refer to hyperparameters set by empirical rules or exploratory methods, and generally may include learning rate, batch size, regularization parameter, optimizer parameter, network depth, and network width, etc.
[0070] It should also be understood that 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 does not fully explore new possibilities. Therefore, according to the correction result and / or the error information output by the second agent, the heuristic strategy parameter can be increased 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 attempting new error recognition strategies and / or new error correction strategies, and then completing the correction of the query statement. That is to say, by adopting the intelligent heuristic correction strategy, the large model associated with the second agent and / or the large model associated with the third agent can, when faced with the query statement to be corrected, not be limited to fixed rule replacement, but can select the optimal correction plan from multiple correction plans according to the nature of the error, the database structure, and / or the user's query intention, etc., for correction.
[0071] In a possible way, the error reference information can be determined as follows: Determine the sample information, where the sample information includes the sample query statement to be corrected, the sample data table structure, the sample error correction description text, and the correct query statement corresponding to the sample query statement; the first agent determines the first sample prompt word according to the sample information and sends the first sample prompt word to the second agent, and the second agent is used to identify errors in the sample query statement according to the first sample prompt word through the associated large model, obtain the sample error information for the sample query statement, and send the sample error information to the first agent; the first agent determines the second sample prompt word according to the sample error information and the sample information and sends the second sample prompt word to the third agent, and the third agent is used to correct the sample query statement according to the second sample prompt word through the associated large model to obtain the corrected target sample query statement; the sample information, the sample error information, and the target sample query statement are used as the error reference information.
[0072] 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. In the case where 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 is corrected for errors again until the sample correction result indicates that the error correction for the sample query statement is completed.
[0073] Among them, the implementation method of optimizing the first sample prompt information and / or the second sample prompt information, and based on the optimized first sample prompt information and / or the second sample prompt information, correcting the sample query statement for errors again until the sample correction result indicates that the error correction for the sample query statement is completed can refer to the process of optimizing the first prompt word and / or the second prompt word described above, which will not be elaborated here.
[0074] In a possible way, taking the sample information, the sample error information, and the corrected query statement as the error reference information may include: After obtaining a preset number of sample error information, the first intelligent agent sends 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 the fourth 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 the error reference information.
[0075] Through the above method, after obtaining a preset number of sample error messages, the first agent can send the preset number of sample error messages, the corresponding sample information, and the target sample query statement to the fourth agent, thereby reducing the interaction frequency between the first agent and the fourth agent, 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 recognition and error correction may be repeatedly performed. Therefore, a set of sample information may generate multiple sample error messages and multiple target sample query statements. Thus, in order for the second agent to accurately and comprehensively identify the error messages in different query statements based on the error reference information, after receiving the preset number of sample error messages, the corresponding sample information, and the target sample query statement, the fourth agent can aggregate the preset number of sample error messages, the corresponding sample information, and the target sample query statement, classify and summarize different sample error messages, and discover the correlation between different sample error messages and the corresponding relationships between different sample error messages, different target sample query statements, and different sample information, thereby generating an error correction guide set, that is, the error reference information. Furthermore, in actual application, the second agent can accurately identify the error messages in different query statements based on the error reference information, so that the third agent can correct errors more precisely, improve the overall correction efficiency and accuracy, and better meet the actual application requirements.
[0076] To facilitate understanding of the query statement correction method based on multiple agents provided by the embodiments of the present disclosure, the following further describes the solution with reference to the accompanying drawings.
[0077] Exemplarily, as Figure 2 shown, a query statement correction system can be constructed based on the first agent, the second agent, and the third agent. Before correcting the query statements in the actual application scenario based on the query statement correction system, a sample information set can be constructed first, and the large model associated with the query statement correction system can be trained based on the sample information set. The sample information set can include multiple groups of sample information, and each group of sample information can include the sample query statement to be corrected, the sample data table structure, the sample error correction description text, the correct query statement corresponding to the sample query statement, the sample domain knowledge, and the sample prompt information, where the sample domain knowledge and the sample prompt information can be optional items.
[0078] When training the large model associated with the query statement correction system based on multiple groups of sample information, the following process can be executed by the first agent: For each set of sample information, it is possible to first determine whether the sample query statement needs to be corrected. In the case where correction is required, based on the sample information and a preset prompt template, a first sample prompt is determined, and the first sample prompt is sent to a second intelligent agent. The second intelligent agent is used to identify errors in the sample query statement according to the first sample prompt through an associated large model, obtain a first sample error message for the sample query statement, and send the first sample error message to the first intelligent agent; According to the first sample error message and the sample information, a second sample prompt is determined, and the second sample prompt is sent to a third intelligent agent. The third intelligent agent is used to correct the errors in the sample query statement according to the second sample prompt through an associated large model, obtain a corrected target sample query statement, and send the corrected target sample query statement to the first intelligent agent; According to the target sample query statement, a correction result is determined that indicates whether the error correction for the sample query statement is completed. In the case where the correction result indicates that the error correction for the sample query statement is completed, the next set of sample information is replaced. In the case where the correction result indicates that the error correction for the sample query statement is not completed, the number of correction attempts for the sample query statement is determined, and based on the first sample error message and the number of correction attempts, the first sample prompt is optimized to obtain a third sample prompt, and the third sample prompt is sent to the second intelligent agent. The second intelligent agent is used to identify errors in the sample query statement according to the third sample prompt, obtain a second error message for the sample query statement, and send the second error message to the first intelligent agent; Based on the number of correction attempts, the target sample query statement, and the second error message, the second sample prompt is optimized to obtain a fourth sample prompt, and the fourth sample prompt is sent to the third intelligent agent. The third intelligent agent is used to correct the errors in the query statement based on the fourth sample prompt through an associated large model, obtain a new target query statement, and send the new target query statement to the first intelligent agent; The first intelligent agent again determines, according to the target sample query statement, a correction result that indicates whether the error correction for the sample query statement is completed, and performs corresponding steps according to the correction result until the correction result indicates that the error correction for the sample query statement is completed.
[0079] After obtaining a preset number of sample error messages, the first intelligent agent can send the preset number of sample error messages, the corresponding sample information, and the target sample query statement to a fourth intelligent agent. The fourth intelligent agent is used to aggregate the preset number of sample error messages, the corresponding sample information, and the target sample query statement to obtain error reference information, and send the error reference information to the first intelligent agent.
[0080] 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 cooperation of the first agent, the second agent, and the third agent.
[0081] Among them, the error reference information at least includes the query statement to be corrected, the data table structure for data query using the query statement, and the error correction description text for the query statement. In a possible way, in order to further improve the correction effect, the error reference information can also include other contents, such as domain knowledge and prompt information, etc. That is to say, when generating the first prompt word through the first 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 domain knowledge and prompt information, etc. can be selectively added to the first prompt word. When generating the second prompt word through the first agent, the second prompt word must include the query statement, the error correction description text, the data table structure, and the error information, and domain knowledge and prompt information, etc. can be selectively added to the first prompt word.
[0082] Through the above method, the error recognition and error correction of the query statement can be automatically realized through the cooperation of multiple agents, thereby reducing the error omission and error correction caused by human negligence in the manual correction process, further improving the correction efficiency, and reducing the probability of correction errors. In addition, since the error correction is based on the cooperation of multiple agents, different agents can focus on their respective specific fields during the correction process, thereby further improving the error correction effect.
[0083] Based on the same concept, the embodiments of the present disclosure also provide a query statement correction device based on multiple agents, as Figure 3 shown, the query statement correction device 300 based on multiple agents may include: An acquisition module 301, configured to obtain error correction information through the first agent, where the error correction information includes the query statement to be corrected, the data table structure for data query using the query statement, and the error correction description text for the query statement; A first processing module 302, configured to determine a first prompt word through the first agent according to the error correction information and the preset error reference information, and send the first prompt word to the second agent, where the second agent is configured to identify errors in the query statement according to 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 agent; The second processing module 303 is configured to determine a second prompt word according to the first error information and the error correction information through the first agent, and send the second prompt word to the third agent. The third agent is configured to correct the query statement according to the second prompt word through the associated large model to obtain a target query statement.
[0084] Through the above query statement correction device 300 based on multiple agents, the error recognition and error correction of the query statement can be automatically realized through the cooperation of multiple agents, thereby reducing the error omission and error correction caused by human negligence in the manual correction process, improving the correction efficiency, and reducing the probability of correction errors. In addition, since the error correction is based on the cooperation of multiple agents, different agents can focus on their respective specific fields during the correction process, thereby further improving the error correction effect.
[0085] In a possible manner, the third agent is further configured to send the target query statement to the first agent. Correspondingly, the query statement correction device 300 based on multiple agents may further include: The first determination module is configured to determine a correction result according to the target query statement through the first agent. The correction result is used to indicate whether the error correction for the query statement is completed; 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: Determine the number of correction times for the query statement, optimize the first prompt word based on the first error information and the number of correction times to obtain a third prompt word, and send the third prompt word to the second agent. The second agent is configured to identify the error of the query statement according to the third prompt word through the associated large model, obtain the second error information for the query statement, and send the second error information to the first agent; Determine a fourth prompt word according to the second error information and the error correction information, and send the fourth prompt word to the third agent. The third agent is configured to correct the query statement according to the fourth prompt word through the associated large model to obtain a new target query statement.
[0086] In a possible manner, the third agent is further configured to send the target query statement to the first agent. Correspondingly, the query statement correction device 300 based on multiple agents may further include: The second determination module is configured to determine a correction result according to the target query statement through the first agent. The correction result is used to indicate whether the error correction for the query statement is completed; 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: 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 the fifth prompt word, and send the fifth prompt word 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.
[0087] In a possible way, the third intelligent agent is also used to send the target query statement to the first intelligent agent. Correspondingly, the query statement correction device 300 based on multiple intelligent agents may further include: The third determination module is used to determine the correction result through the first intelligent agent according to the target query statement. The correction result is used to indicate whether the error correction for the query statement is completed; The fifth processing module is used to execute the following steps through the first intelligent agent when the correction result indicates that the error correction for the query statement is not completed: Determine the number of corrections for the query statement, optimize the first prompt word based on the first error message and the number of corrections to obtain the sixth prompt word, and send the sixth prompt word to the second intelligent agent. The second intelligent agent is used to identify the error of the query statement according to the sixth prompt word to obtain the third error message for the query statement and send the third error message to the first intelligent agent; Optimize the second prompt word based on the number of corrections, the target query statement, and the third error message to obtain the seventh prompt word, and send 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.
[0088] In a possible way, the query statement correction device 300 based on multiple intelligent agents may further include: The fourth determination module is used to determine the correction result through the first intelligent agent according to the target query statement. The correction result is used to indicate whether the error correction for the query statement is completed; The adjustment module is used to adjust the heuristic policy parameters of the large model associated with the second intelligent agent and / or the heuristic policy parameters of the large model associated with the third intelligent agent according to the correction result and / or the error information output by the second intelligent agent when the correction result indicates that the error correction for the query statement is not completed.
[0089] In a possible way, the error reference information includes the correct reference query statement. Correspondingly, the fourth determination module is used to execute the following process through the first intelligent agent: Determine the reference query statement corresponding to the query statement in the error reference information; based on the semantic information of the target query statement and the semantic information of the reference query statement, determine the first correction result for the query statement, where the first correction result is used to indicate whether the semantics of the target query statement is consistent with the semantics of the reference query statement; determine the first data queried by the query statement in the data table structure, and determine the second data queried by the reference query statement in the data table structure, and based on the first data and the second data, determine the second correction result for the query statement, where the second correction result is used to indicate whether the first data is consistent with the second data; based on the first correction result and the second correction result, determine the correction result for the query statement.
[0090] In a possible manner, the query statement correction device 300 based on multi-agent may further include: The sixth processing module is configured to determine sample information, where the sample information 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 the first agent according to the sample information, and send the first sample prompt word to the second agent, where the second agent is configured to identify errors in the sample query statement according to 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 according to the sample error information and the sample information, and send the second sample prompt word to the third agent, where the third agent is configured to correct errors in the sample query statement according to the second sample prompt word through an associated large model, obtain the corrected target sample query statement; use the sample information, the sample error information, and the target sample query statement as error reference information.
[0091] In a possible manner, the sixth processing module may further be configured to, after obtaining a preset number of sample error information, 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 agent through the first agent, where the fourth agent is configured 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.
[0092] In a possible manner, the first error information may include an error type. Correspondingly, the second processing module may be configured to determine a target prompt word template corresponding to the error type by the first agent according to the error type and a preset prompt word template library, and determine a second prompt word according to the first error information, the error correction information, and the target prompt word template, where the prompt word template library is used to store the correspondence between the prompt word template and the error type.
[0093] Among possible ways, the query statement is a Structured Query Language statement.
[0094] Based on the same concept, an embodiment of the present disclosure also provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processing device, the steps of any one of the above-mentioned query statement correction methods based on multi-agent are implemented.
[0095] Based on the same concept, an embodiment of the present disclosure also provides an electronic device, which may include: A storage device, on which a computer program is stored; A processing device, configured to execute the computer program in the storage device to implement the steps of any one of the above-mentioned query statement correction methods based on multi-agent.
[0096] Based on the same concept, an embodiment of the present disclosure also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned query statement correction methods based on multi-agent are implemented.
[0097] Next, refer to 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), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is only an example, and should not bring any limitation to the functions and usage scopes of the embodiments of the present disclosure.
[0098] As Figure 4 shown, the electronic device 400 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 401, which may perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 402 or the program loaded from the storage device 408 into the random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. The input / output (I / O) interface 405 is also connected to the bus 404.
[0099] Typically, the following devices can be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, 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 can allow the electronic device 400 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 4 the electronic device 400 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices can be implemented or had.
[0100] 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 program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a 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 functions defined in the method of the embodiment of the present disclosure are executed.
[0101] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0102] In some embodiments, communication can be carried out using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (for example, a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (for example, the Internet), and end-to-end networks (for example, ad hoc end-to-end networks), as well as any currently known or future-developed networks.
[0103] The above-mentioned computer-readable medium can be included in the above-mentioned electronic device; it can also exist separately without being assembled into the electronic device.
[0104] The above computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: obtain error correction information through a first agent, where the error correction information includes a query statement to be corrected, a data table structure for querying data using the query statement, and an error correction description text for the query statement; determine a first prompt word through the first agent according to the error correction information and preset error reference information, and send the first prompt word to a second agent, where the second agent is used to identify errors in the query statement according to the first prompt word through an associated large model, obtain a first error information for the query statement, and send the first error information to the first agent; determine a second prompt word through the first agent according to the first error information and the error correction information, and send the second prompt word to a third agent, where the third agent is used to correct the errors in the query statement according to the second prompt word through an associated large model, and obtain a target query statement.
[0105] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partially on the user's computer, execute as a stand-alone software package, execute partially on the user's computer and partially on a remote computer, or execute entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through 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., by connecting through an Internet service provider using the Internet).
[0106] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or by a combination of dedicated hardware and computer instructions.
[0107] The modules described in the embodiments of the present disclosure can be implemented in software or in hardware. In some cases, the name of the module does not constitute a limitation on the module itself.
[0108] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. By way of 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 a chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0109] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection 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, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0110] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0111] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although a number of specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0112] Although the subject matter has been described in 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. On the contrary, the specific features and acts described above are merely example forms for implementing the claims. Regarding the apparatus in the above 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 here.
Claims
1. A query statement correction method based on multi-agent, characterized in that The multi-agent-based query statement correction method includes: Obtaining error correction information through a first agent, where the error correction information includes the query statement to be corrected, the data table structure for data query using the query statement, and an error correction description text for the query statement; Determining a first prompt word by the first agent according to the error correction information and preset error reference information, and sending the first prompt word to a second agent. The second agent is used to identify errors in the query statement according to the first prompt word through an associated large model, obtain first error information for the query statement, and send the first error information to the first agent; Determining a second prompt word by the first agent according to the first error information and the error correction information, and sending the second prompt word to a third agent. The third agent is used to correct errors in the query statement according to the second prompt word through an associated large model, obtaining a target query statement.
2. The multi-agent based query statement correction method according to claim 1, wherein The third agent is further used to send the target query statement to the first agent. The multi-agent-based query statement correction method further includes: Determining a correction result by the first agent according to the target query statement, where the correction result is used to indicate whether the error correction for the query statement is completed; In the case where the correction result indicates that the error correction for the query statement is not completed, the first agent executes the following process: Determining the number of correction times for the query statement; Optimizing the first prompt word based on the first error information and the number of correction times to obtain a third prompt word, and sending the third prompt word to the second agent. The second agent is used to identify errors in the query statement according to the third prompt word through an 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 according to 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 errors in the query statement according to the fourth prompt word through an associated large model, obtaining a new target query statement.
3. The method for correcting query statements based on multi-agent according to claim 1, characterized in that The third agent is further used to send the target query statement to the first agent. The multi-agent-based query statement correction method further includes: Determining a correction result by the first agent according to the target query statement, where the correction result is used to indicate whether the error correction for the query statement is completed; In the case where the correction result indicates that the error correction for the query statement is not completed, the first agent executes the following process: Determining the number of correction times for the query statement; 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 the third intelligent agent, which is used to correct the error of the query statement based on the fifth prompt word through an associated large model to obtain a new target query statement.
4. The method for correcting query statements based on multi-agent according to claim 1, characterized in that The third intelligent agent is further used to send the target query statement to the first intelligent agent. The query statement correction method based on multiple intelligent agents further includes: Determine a correction result through the first intelligent agent according to the target query statement, where the correction result is used to indicate whether the error correction for the query statement is completed; In the case where the correction result indicates that the error correction for the query statement is not completed, the following process is executed through the first intelligent agent: Determine the number of corrections for the query statement; Optimize the first prompt word based on the first error message and the number of corrections to obtain a sixth prompt word, and send the sixth prompt word to the second intelligent agent, which is used to identify errors in the query statement according to the sixth prompt word to obtain a third error message for the query statement and send the third error message to the first intelligent agent; Optimize the second prompt word based on the number of corrections, the target query statement, and the third error message to obtain a seventh prompt word, and send the seventh prompt word to the third intelligent agent, which is used to correct the error of the query statement based on the seventh prompt word through an 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-4, characterized in that The query statement correction method based on multiple intelligent agents further includes: Determine a correction result through the first intelligent agent according to the target query statement, where the correction result is used to indicate whether the error correction for the query statement is completed; In the case where the correction result indicates that the error correction for the query statement is not completed, adjust the heuristic strategy parameters of the large model associated with the second intelligent agent and / or the heuristic strategy parameters of the large model associated with the third intelligent agent according to the correction result and / or the error information output by the second intelligent agent.
6. The method for correcting query statements based on multi-agent according to claim 5, characterized in that The error reference information includes a correct reference query statement. The process of determining the correction result through the first intelligent agent according to the target query statement includes: Execute the following process through the first intelligent agent: Determine the reference query statement corresponding to the query statement in the error reference information; Based on the semantic information of the target query statement and the semantic information of the reference query statement, determine a first correction result for the query statement, where the first correction result is used to indicate whether the semantics of the target query statement is 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. According to the first data and the second data, determine the second correction result for the query statement, where 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 according to the first correction result and the second correction result.
7. The method for correcting query statements based on multi - agents according to any one of claims 1 - 4, characterized in that, The error reference information is determined in the following manner: Determine the sample information, where the sample information includes the sample query statement to be corrected, the sample data table structure, the sample error correction description text, and the correct query statement corresponding to the sample query statement; The first intelligent agent determines the first sample prompt word according to the sample information and sends the first sample prompt word to the second intelligent agent. The second intelligent agent is used to identify errors in the sample query statement according to the first sample prompt word through the associated large model, obtain the sample error information for the sample query statement, and send the sample error information to the first intelligent agent; The first intelligent agent determines the second sample prompt word according to the sample error information and the sample information, and sends the second sample prompt word to the third intelligent agent. The third intelligent agent is used to correct the errors in the sample query statement according to the second sample prompt word through the associated large model, and obtain the corrected target sample query statement; Use the sample information, the sample error information, and the target sample query statement as the error reference information.
8. The multi-agent-based query statement correction method according to claim 7, wherein The step of using the sample information, the sample error information, and the target sample query statement as the error reference information includes: After obtaining the preset number of sample error information, the first intelligent agent sends 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. 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 the error reference information.
9. The multi-agent-based query statement correction method according to any one of claims 1-4, characterized in that The first error information includes the error type. The step of the first intelligent agent determining the second prompt word according to the first error information and the error correction information includes: The first intelligent agent determines the target prompt word template corresponding to the error type according to the error type and the preset prompt word template library, and determines the second prompt word according to the first error information, the error correction information, and the target prompt word template, where the prompt word template library is used to store the corresponding relationship between the prompt word template and the error type.
10. The multi-agent-based query statement correction method according to any one of claims 1-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 a first intelligent agent, where the error correction information includes a query statement to be corrected, a data table structure for data query using the query statement, and an error correction description text for the query statement; A first processing module, configured to determine a first prompt word through the first intelligent agent according to the error correction information and preset error reference information, and send the first prompt word to a second intelligent agent, where the second intelligent agent is configured to identify an error in the query statement according to the first prompt word through an associated large model, obtain a first error information for the query statement, and send the first error information to the first intelligent agent; A second processing module, configured to determine a second prompt word through the first intelligent agent according to the first error information and the error correction information, and send the second prompt word to a third intelligent agent, where the third intelligent agent is configured to correct the error in the query statement according to the second prompt word through an associated large model, to obtain a 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, it implements the steps of the method according to any one of claims 1-10.
13. An electronic device, characterized in that, Comprising: A storage device, on which a computer program is stored; 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-10.
14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-10.
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
Fault root cause positioning method and device, storage medium and program product
CN118964080A
Text generation system and method based on multi-agent cooperation mechanism MOPAR
CN119250033A
Modeling method and device of entity network based on agent system
CN119364380A