Intelligent agent-based data query method, electronic device, and storage medium

CN122594319APending Publication Date: 2026-08-18HANGZHOU NETEASE CLOUD MUSIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610738215.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-26
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0004]本申请的目的在于,针对上述现有技术中的不足,提供一种基于智能代理的数据查询方法、电子设备及存储介质,以解决现有技术中Text2SQL技术在实际应用中仍存在局限性,进而导致数据查询的准确性和效率较低的问题

Benefits of technology

[0009]According to the data query method, electronic device, and storage medium based on intelligent agents in this application, addressing the problem of ambiguous or incomplete query intent in user-input query information described in natural language, a multi-round interactive clarification mechanism is employed to generate corresponding clarification information. This supplements and improves the user's ambiguous intent and confirms the user's clarified intent, thereby effectively avoiding SQL generation deviations caused by misjudgment of intent. Furthermore, this application pre-constructs a structured knowledge base. Addressing the issue of errors in table or field selection in large-scale databases, based on the confirmed user clarification intent, query statement generation information is retrieved hierarchically from the constructed structured knowledge base. An initial query statement is generated based on this information, and then validated in multiple dimensions. If validation fails, automatic correction is performed, ultimately outputting the correct target query statement. The target query statement is then used to retrieve the corresponding target data from a pre-set database. Therefore, this application, through multi-round intent clarification, hierarchical retrieval using a structured knowledge base, and validation and correction of the query statement, accurately achieves the conversion from natural language to structured query language in real-world complex business environments, significantly improving the accuracy and efficiency of data querying.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122594319A_ABST
    Figure CN122594319A_ABST
Patent Text Reader

Abstract

The application provides a data query method based on an intelligent agent, an electronic device and a storage medium, and relates to the technical field of computers. The method comprises the following steps: receiving query information input by a user, performing multi-round intent clarification processing on the query information, and determining a user clarification intent; based on the user clarification intent, retrieving query sentence generation information from a structured knowledge base, generating an initial query sentence based on the query sentence generation information, the user clarification intent comprising intent information in multiple dimensions, and the query sentence generation information being used to indicate structured data in the structured knowledge base that is associated with the intent information in the multiple dimensions; verifying the initial query sentence, and generating a target query sentence after the verification is passed; and querying target data from the structured knowledge base based on the target query sentence. The application accurately realizes conversion from natural language to structured query language in a real and complex business environment, thereby significantly improving the accuracy and efficiency of data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically, to a data query method, electronic device, and storage medium based on intelligent agents. Background Technology

[0002] With the advent of the big data era, relational databases have become the core carrier for storing structured data in various fields, and Structured Query Language (SQL), as the standard language for manipulating relational databases, is increasingly widely used. However, using SQL statements requires specialized technical skills, and non-technical users cannot directly obtain data from the database. To address this, Text2SQL technology has emerged, aiming to automatically convert user-input natural language query requests into executable SQL statements, thereby lowering the barrier to database operation.

[0003] Currently, mainstream Text2SQL technologies are based on Retrieval-Augmented Generation (RAG) and Large Language Models (LLM). They simplify the SQL generation process by leveraging contextual retrieval capabilities and the semantic understanding and generation capabilities of LLM. However, they still face significant limitations in real-world business scenarios: firstly, the limited context length of LLM makes it difficult to adapt to large-scale databases, and it's prone to selecting incorrect tables or fields for similar data in real-world scenarios; secondly, it cannot effectively handle ambiguous or incomplete user intent, and the generated SQL may deviate from the user's intended meaning, leading to low accuracy and efficiency in data retrieval. Therefore, existing Text2SQL technologies still have limitations in practical applications. Summary of the Invention

[0004] The purpose of this application is to address the shortcomings of the prior art by providing a data query method, electronic device, and storage medium based on intelligent agents, so as to solve the problem that the Text2SQL technology in the prior art still has limitations in practical applications, resulting in low accuracy and efficiency of data query.

[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a data query method based on intelligent agents, the method comprising: Receive query information input by the user, the query information being described in natural language; The query information is processed through multiple rounds of intent clarification to determine the user's intent to clarify. Based on the user's clarification intent, query statement generation information is retrieved from the structured knowledge base, and an initial query statement is generated based on the query statement generation information. The user's clarification intent includes intent information of multiple dimensions, and the query statement generation information is used to indicate the structured data in the structured knowledge base associated with the intent information of the multiple dimensions. The initial query statement is validated, and the target query statement is generated after the validation passes. The target data is obtained from the preset database based on the target query statement.

[0006] Secondly, embodiments of this application provide a data query device based on an intelligent agent, the device comprising: A receiving module is used to receive query information input by the user, the query information being described in natural language; The intent clarification module is used to perform multiple rounds of intent clarification processing on the query information to determine the user's clarification intent; The generation module is used to retrieve query statement generation information from the structured knowledge base based on the user's clarification intent, and generate an initial query statement based on the query statement generation information. The user's clarification intent includes intent information of multiple dimensions, and the query statement generation information is used to indicate the structured data in the structured knowledge base associated with the intent information of the multiple dimensions. The verification module is used to verify the initial query statement and generate the target query statement after the verification is passed. The query module is used to retrieve target data from a preset database based on the target query statement.

[0007] Thirdly, embodiments of this application provide an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the data query method based on intelligent agents as described in any of the first aspects above.

[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the data query method based on an intelligent agent as described in any of the first aspects above.

[0009] According to the data query method, electronic device, and storage medium based on intelligent agents in this application, addressing the problem of ambiguous or incomplete query intent in user-input query information described in natural language, a multi-round interactive clarification mechanism is employed to generate corresponding clarification information. This supplements and improves the user's ambiguous intent and confirms the user's clarified intent, thereby effectively avoiding SQL generation deviations caused by misjudgment of intent. Furthermore, this application pre-constructs a structured knowledge base. Addressing the issue of errors in table or field selection in large-scale databases, based on the confirmed user clarification intent, query statement generation information is retrieved hierarchically from the constructed structured knowledge base. An initial query statement is generated based on this information, and then validated in multiple dimensions. If validation fails, automatic correction is performed, ultimately outputting the correct target query statement. The target query statement is then used to retrieve the corresponding target data from a pre-set database. Therefore, this application, through multi-round intent clarification, hierarchical retrieval using a structured knowledge base, and validation and correction of the query statement, accurately achieves the conversion from natural language to structured query language in real-world complex business environments, significantly improving the accuracy and efficiency of data querying. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 A flowchart illustrating a data query method based on an intelligent agent provided in an embodiment of this application is shown. Figure 2 A flowchart illustrating a user intent clarification method provided in an embodiment of this application is shown. Figure 3 A flowchart illustrating a clarification information generation method provided in an embodiment of this application is shown; Figure 4 A flowchart illustrating a method for obtaining query statement generation information provided in an embodiment of this application is shown. Figure 5 This illustration shows a flowchart of a target data table and a target reference example acquisition method provided in an embodiment of this application; Figure 6 A flowchart illustrating a target query statement generation method provided in an embodiment of this application is shown. Figure 7This illustration shows a schematic diagram of the structure of a data query device based on an intelligent agent provided in an embodiment of this application; Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation

[0012] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0013] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0014] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0015] Currently, mainstream Text2SQL technology performs well on open-source datasets, but it still has the following shortcomings in real-world business scenarios: (1) Limited LLM context length: When faced with a large database containing thousands of tables and complex many-to-many relationships, it is impossible to input all database schema information into the LLM for table and column filtering. Conventional schema-linking methods are difficult to adapt to large-scale databases. (2) Low accuracy of similar table / field selection: In real business scenarios, there are tables or fields with similar lineages. Existing methods do not incorporate business experience and are prone to selecting the wrong table in the similar table. (3) Difficulty in matching technical terms and abbreviations: LLM lacks understanding of abbreviations and technical terms in the database, making it difficult to accurately match natural language elements with database fields. The problem of misselecting columns with the same name in cross-table queries is prominent. Furthermore, the LLM illusion further reduces the accuracy of SQL generation. The LLM illusion refers to the phenomenon that LLM generates seemingly reasonable content that is actually inconsistent with the facts or even fabricated. (4) Poor user interaction experience: It only supports single-round input and cannot handle vague or incomplete query intents. Users need to repeatedly adjust the query description, resulting in high communication costs. (5) Failure to fully utilize expert experience: Most methods emphasize end-to-end SQL generation, ignoring the user's own valuable experience, making the generated results easily deviate from the user's intention; (6) Lack of guarantee of SQL validity: The generated SQL is not validated. Problems such as syntax errors, insufficient permissions, and logical contradictions can only be discovered during the execution stage, resulting in low query efficiency and even database security risks.

[0016] To address the problems existing in the prior art, this application provides a data query method based on an intelligent agent. An intelligent agent is introduced, which, upon receiving a user query, analyzes the clarity of the intent. For ambiguous or incomplete query intents, it automatically generates clarifying statements and completes the information through multiple rounds of interaction, eliminating the need for the user to repeatedly adjust the query description. Based on a clear user intent, the intelligent agent invokes a Large Language Model (LLM) and combines business experience from a structured database to generate initial SQL. It then performs comprehensive checks on the initial SQL, including syntax, semantics, permissions, execution simulation, and business logic, identifying potential problems from multiple dimensions. For any issues detected during checks, it automatically matches and corrects rules to optimize the initial SQL, resulting in an optimized target SQL. This optimized target SQL is then used for data querying, effectively improving the efficiency and accuracy of data querying.

[0017] The following will provide a detailed description of the data query method based on intelligent agents provided in the embodiments of this application.

[0018] Figure 1 This diagram illustrates a data query method based on an intelligent agent according to an embodiment of this application. The executing entity of this method is the intelligent agent (Agent). (Refer to...) Figure 1 As shown, the method specifically includes the following steps: S101, Receive query information input by the user.

[0019] Optionally, the query information is described in natural language. That is, the query information is unstructured and may contain vague expressions, omitted constraints, or use business terms and abbreviations.

[0020] S102. Perform multiple rounds of intent clarification processing on the query information to determine the user's clarification intent.

[0021] Optionally, the intelligent agent invokes a large language model (LLM) with high inference efficiency to parse the natural language query, extracting key elements such as the problem objective, involved fields, business scenario, and constraints. Based on the completeness, clarity, and constraint explicitness of the extracted key elements, the agent calculates the user's intent explicitness score. Further, the calculated intent explicitness score is compared with a preset threshold to determine if the user's intent is complete and explicit. If the user's intent is incomplete or contains missing elements, a clarification script template with a high success rate is selected based on the type of missing element. Clarification information is generated based on the clarification script template, sent to the user, and supplementary information is received from the user. This supplementary information is then integrated with the original natural language description to determine a new user intent. If the new user intent is complete and explicit, the user intent is considered clarified, i.e., the clarified user intent is obtained. If the new user intent is still incomplete or unclear, the process proceeds to the next round, iterating through the above process until the intent explicitness score is greater than or equal to the preset threshold or the maximum number of iterations is reached. Finally, a structured clarified user intent is output.

[0022] S103. Based on the user's clarification intent, retrieve query statement generation information from the structured knowledge base, and generate an initial query statement based on the query statement generation information.

[0023] Optionally, the user clarification intent includes intent information across multiple dimensions, including: problem target intent information, field intent information, business scenario intent information, and constraint condition intent information. The query statement generates information to indicate the structured data in the structured knowledge base associated with the intent information across these multiple dimensions.

[0024] Optionally, the structured knowledge base stores multiple reference examples, each used to indicate historical user intents and the corresponding query statements and results. Further, the structured knowledge base includes multiple indexes: table index, column index, reference query statement index, and interaction experience index. The table index contains structured information such as table name, purpose description, additional information, product, business, primary key, query popularity, inter-table relationships, and business priority weight. The column index contains structured information such as table name, field name, field description, field type, field examples, professional terminology / abbreviation correspondences, and field association rules. The reference SQL index contains historical query problem descriptions, actual SQL statements used, related tables / fields, validation results, correction records, and applicable business scenarios. The interaction experience index contains user fuzzy query cases, clarification scripts, user feedback, and intent clarification success rates.

[0025] Optionally, the intelligent agent performs a hierarchical retrieval in parallel within a structured knowledge base based on the user's clarification intent. Specifically, it retrieves reference examples from the reference SQL index, retrieves multiple target data tables matching the problem objective, business scenario, involved fields, and constraint intent from the table and column indexes respectively, and selects target fields from each target data table. Finally, it concatenates the target data tables, target fields, and reference examples into complete SQL generation information. The intelligent agent then calls the Large Language Model (LLM) and inputs the SQL generation information into it, allowing the LLM to generate an initial query statement that matches the user's intent.

[0026] S104. Validate the initial query statement and generate the target query statement after the validation is successful.

[0027] Optionally, the initial query statement undergoes multi-dimensional validation, including syntax validation, semantic validation, permission validation, execution simulation validation, and business logic validation. If any validation fails, the initial query statement is corrected according to preset correction rules to obtain a corrected query statement. The corrected query statement is then re-validated, and if it passes the validation, it is used as the target query statement. If the initial query statement passes the first validation, it is directly used as the target query statement.

[0028] S105. Obtain the target data from the preset database based on the target query statement.

[0029] Optionally, the default database is a relational database, such as MySQL or Oracle. After determining the target query statement, the corresponding target data is retrieved from the relational database based on the target query statement.

[0030] Furthermore, this embodiment of the application feeds back the final output executable target query statement and the target data retrieved from the preset database to the user, and collects multi-dimensional ratings and textual feedback from the user on the accuracy of the target query statement generation, interactive experience, and result satisfaction. The complete interactive information, including the original query information, multi-round clarification records, the generated initial query statement and the revised query statement, the verification log, and user evaluations, is fed back into the structured knowledge base for regularly updating high-success-rate clarification script templates and field semantic mapping rules, thereby improving the self-optimization and closed-loop evolution of the intelligent agent in query understanding, intent clarification, and SQL generation capabilities.

[0031] Based on this, the data query method based on intelligent agents according to the embodiments of this application addresses the problem of ambiguous or incomplete query intent in user-input query information described in natural language. It employs a multi-round interactive clarification mechanism to generate corresponding clarification information, supplementing and improving the user's ambiguous intent and confirming the user's clarified intent, thereby effectively avoiding SQL generation deviations caused by misjudgment of intent. Furthermore, this application pre-constructs a structured knowledge base. Addressing the issue of errors in table or field selection in large-scale databases, based on the confirmed user clarification intent, it retrieves query statement generation information hierarchically from the constructed structured knowledge base, generates an initial query statement based on this information, performs multi-dimensional validation on the initial query statement, and automatically corrects it if validation fails, ultimately outputting the correct target query statement. This target query statement is then used to retrieve the corresponding target data from the preset database. Therefore, this embodiment of the application, through multi-round intent clarification, hierarchical retrieval combined with a structured knowledge base, and validation and correction of the query statement, accurately achieves the conversion from natural language to structured query language in real and complex business environments, thereby significantly improving the accuracy and efficiency of data querying.

[0032] Figure 2 A flowchart illustrating a user intent clarification method provided in an embodiment of this application is shown. (Refer to...) Figure 2 As shown, step S102 above performs multiple rounds of intent clarification processing on the query information to determine the user's clarification intent, specifically including the following steps: S201. In the current round, extract the key elements from the query information, and determine the user's intent clarity score based on the extraction quality information of the key elements.

[0033] Optionally, the intelligent agent invokes a large language model (LLM) with fast inference speed to perform semantic parsing on the query information input by the user, and extracts core elements such as the problem objective, involved fields, business scenarios, and constraints from the query information.

[0034] Optionally, the extraction quality information of key elements includes completeness, clarity, and constraint explicitness. Based on the key element extraction results, the extraction quality information of key elements can be determined. Completeness is determined as follows: if all four key elements—problem objective, involved fields, business scenario, and constraints—are extracted, the completeness score is 40 points; deducting 10 points for each missing key element, and deducting 20-40 points for two or more missing key elements. Clarity is determined as follows: if the key elements are unambiguous and without vague descriptions, the clarity score is 30 points; deducting 10 points for each vague element, and deducting 20-30 points for two or more vague elements. Constraint explicitness is determined as follows: if specific constraints such as time and scope are included, the constraint explicitness score is 30 points; deducting 10-20 points for vague constraints, and deducting 30 points for no constraints.

[0035] Furthermore, in this embodiment, different weights are assigned to completeness, clarity, and constraint clarity, for example, completeness is assigned a weight of 40%, clarity a weight of 30%, and constraint clarity a weight of 30%. Based on this, after obtaining the scores corresponding to completeness, clarity, and constraint clarity respectively, the final score obtained by weighted summation of the scores is the user's intent clarity score, which is a specific value between 0 and 100.

[0036] Based on this, the embodiments of this application use the completeness, clarity, and explicitness of constraints extracted from key elements as metrics for intent explicitness, and obtain a standardized intent explicitness score through a weighted mechanism. This score is then used to determine whether the user's intent is clear. This not only more objectively reflects the true clarity of the user's intent but also significantly improves the accuracy of the intelligent agent's understanding of the user's intent.

[0037] S202. If the intent clarity score is less than the preset threshold, retrieve experience information from the structured knowledge base and generate clarification information based on the experience information.

[0038] Optionally, the preset threshold can be set based on the success rate statistics of intent clarification in historical interaction data. For example, if the preset threshold is set to 70 points, when the intent clarity score is less than the preset threshold of 70 points, the intelligent agent generates targeted clarification information, i.e., clarification scripts, based on the interaction experience index in the structured knowledge base. Specifically, it retrieves experience information in the interaction experience that matches the type of the currently missing element, such as fuzzy query cases, and filters clarification script templates with a high success rate of intent clarification, and then generates the final clarification script based on the clarification script templates.

[0039] In other embodiments, different thresholds can be set for different types of queries. For example, for simple scenarios involving only a single table query, the preset threshold can be set to 80 points, while for business scenarios involving multi-table joins and complex aggregation operations, the preset threshold can be set to 85 points to require a clearer user intent.

[0040] Figure 3 A flowchart illustrating a clarification information generation method provided in an embodiment of this application is shown. (Refer to...) Figure 3 As shown, if the intent clarity score is less than a preset threshold in step S202 above, then experiential information is retrieved from the structured knowledge base, and clarification information is generated based on the experiential information. Specifically, this includes the following steps: S301. If the intention clarity score is less than the preset threshold, the missing element type is determined based on the extracted quality information.

[0041] Optionally, if the intent clarity score is less than a preset threshold of 70 points, then the missing key elements are determined based on the completeness, clarity, and constraint clarity of the extracted key elements. For example, if the key element "business scenario" is not extracted, the missing element type is determined to be "missing business scenario"; if the key element "involving field" is empty or only a general description, the missing element type is determined to be "missing key field"; if the key element "problem objective" is not extracted, the missing element type is determined to be "missing problem objective"; if the key element "constraint condition" does not extract a specific time constraint, the missing element type is determined to be "missing time constraint".

[0042] S302. Retrieve experiential information matching the missing element type from the structured knowledge base, and determine the target clarification script template based on the experiential information.

[0043] Optionally, using the current missing element type, such as "missing business scenario", and keywords in the user's input query information, such as "sales volume, order", as search conditions, similar fuzzy query cases in the history are searched from the interaction experience index of the structured knowledge base as experience information. Then, the top three clarification script templates with the highest historical success rate in clarifying intent are selected from the matched fuzzy query cases. These clarification script templates usually contain replaceable placeholders, such as [product A / product B], [field X / field Y].

[0044] S303. Generate clarification information based on the target clarification script template.

[0045] Optionally, placeholders in the selected target clarification script template can be dynamically populated with candidate information from the structured knowledge base. For example, "products" related to the current query keywords can be obtained from the table index, or "core fields" with semantic matching can be extracted from the column index. These can be used to populate variables in the target clarification script template to generate the final clarification script, which is then output to the user to guide supplementary information.

[0046] For example, a clarification phrase could be: "Is your query for data related to [Product A / Product B]? If not, please provide the specific business scenario." Another example is: "Is the field corresponding to the core metric you need to query (such as sales revenue, number of users) [Field X / Field Y]? Please confirm or provide it."

[0047] S203. Obtain supplementary information from the user regarding the clarification information, and merge the supplementary information with the query information to obtain new query information.

[0048] Optionally, after generating the clarification statement, the intelligent agent will output information to the user to guide them in supplementing the information. Accordingly, after the user supplements the information, the intelligent agent semantically fuses the supplementary information with the original query information to obtain new query information. Specifically, if the supplementary information is a specific field or product, it is structured and injected into the relevant position in the original query information. If the supplementary information is new content, it is concatenated with or replaces the original vague expression in the query information, thus fusing to obtain a new query information with more complete semantics and clearer intent.

[0049] S204. Use the new query information as the query information for the next round.

[0050] Optionally, the new query information obtained by fusion can be directly used as the input for the next round of iteration processing, so as to extract new key elements from the new query information, as well as the extraction quality information based on the extracted new key elements, calculate a new intent clarity score, and then determine whether the user intent is complete and clear based on the new intent clarity score. If the new user intent is still not complete and clear enough, a clarification message is generated again. This process continues until the user intent is clear and complete, and the final user clarification intent is obtained.

[0051] S205. If the intent clarity score is greater than or equal to the preset threshold, the user's clarification intent is determined based on the extracted key elements.

[0052] Optionally, if the intent clarity score is greater than or equal to a preset threshold of 70 points, it is determined that the corresponding user intent is complete and clear. Key elements extracted from the query information, such as the problem objective, involved fields, business scenarios, and constraints, can be directly structured and integrated to form the final user clarification intent.

[0053] Based on this, the embodiments of this application clarify the user's intent through multiple rounds of interaction. Compared with the existing technology that only supports single-round user input and uses traditional fixed phrases or general follow-up questions, this application significantly improves the pertinence of clarification and mobilizes the user's enthusiasm for cooperation. It effectively solves the common problems of ambiguity and incompleteness in users' natural language queries, avoids SQL generation errors caused by blind guessing, and lays a reliable foundation for subsequent accurate SQL generation.

[0054] Figure 4 This diagram illustrates a flowchart of a method for obtaining query statement generation information according to an embodiment of this application. (Refer to...) Figure 4 As shown, step S103 above, based on the user's clarification intent, retrieves query statement generation information from the structured knowledge base, specifically including the following steps: S401. Based on the problem target intent information, field intent information, business scenario intent information, constraint condition intent information, and multiple indexes corresponding to the structured knowledge base, retrieve the target data table and target reference example from the query statement generation information in the structured knowledge base.

[0055] Optionally, the structured knowledge base stores multiple reference examples, each of which is used to indicate historical user intents and the corresponding query statements and results.

[0056] Figure 5 This illustration shows a flowchart of a target data table and a target reference example acquisition method provided in an embodiment of this application. (Refer to...) Figure 5As shown, step S401 above retrieves the target data table and target reference example from the query statement generation information based on the problem target intent information, field intent information, business scenario intent information, and multiple indexes corresponding to the structured knowledge base. Specifically, it includes the following steps: S501. Based on the problem target intent information, business scenario intent information, constraint condition intent information, and reference query statement index, retrieve the target reference example from the structured knowledge base.

[0057] Optionally, the business scenario intent information is matched with the business fields of each historical query record in the reference query statement index to filter multiple first historical query records that match the business scenario intent. The problem target intent information is matched with the problem description field in each first historical query record to filter multiple second historical query records that match the problem target intent. The constraint condition intent information is matched with the constraint condition field in each second historical query record to filter third historical query records that match the constraint condition intent. The problem description field and the corresponding executable query statement in the third historical query record are used as target reference examples.

[0058] For example, the intelligent agent first performs a precise match between the business scenario intent information and the "belonging business" field of each historical record in the reference SQL index to filter out the first set of historical query records with consistent business scenarios. Then, it performs a semantic match between the problem target intent information and the "problem description" field of each historical query record in the first set of historical query records. Specifically, it can combine keywords and calculate semantic similarity for semantic matching. From the multiple historical query records in the first set of historical query records, it filters out the multiple second historical query records with the highest relevance to obtain the second set of historical query records. Then, it matches the constraint intent information with the "constraint" field of each historical query record in the second set of historical query records to filter out the third set of historical query records with consistent constraints. Finally, it combines the problem description field in the third historical query record with its corresponding executable SQL statement as target reference examples (Few-shot examples) to prompt the Large Language Model (LLM) to generate the initial query statement.

[0059] S502. Based on the problem target intent information, business scenario intent information, and table index, multiple first candidate data tables are retrieved from the structured knowledge base.

[0060] For example, the intelligent agent performs precise matching of business scenario intent information with the business fields of each table in the table index, and performs semantic relevance matching of problem target intent information with the purpose description fields of each table. Tables that meet both of the above matching conditions are included in the candidate set to obtain multiple first candidate data tables part1.

[0061] S503. Based on field intent information and field index, retrieve multiple second candidate data tables from the structured knowledge base.

[0062] For example, the intelligent agent retrieves fields in the column index whose field descriptions, technical terms, or abbreviations match the field intent information, and extracts the table name corresponding to the matching field, thereby determining multiple second candidate data tables part2 based on the table name.

[0063] S504. Sort the multiple first candidate data tables and multiple second candidate data tables to obtain multiple target data tables.

[0064] For example, the union of multiple first candidate data tables (part1) and multiple second candidate data tables (part2) is taken to form a preliminary candidate table set. Then, using a pre-trained re-rank model, a comprehensive relevance score is calculated between the purpose description of each candidate table in the preliminary candidate table set and the current problem target intent information. The candidate tables in the preliminary candidate table set are then sorted in descending order according to this comprehensive relevance score. Based on this, the top N candidate tables are selected as the target data tables for subsequent field filtering and SQL generation. Here, N is a configurable parameter, for example, it can be set to 10.

[0065] S402. Based on the field intent information, retrieve at least one target field from the query statement generation information in the target data table.

[0066] Optionally, the semantic similarity between each field in the target data table and the field intent information is calculated, and at least one target field is selected from multiple fields in the target data table based on the semantic similarity.

[0067] For example, for each target data table, all fields are traversed and the semantic similarity between the field description and the field intent information is calculated. Then, the fields in each table are sorted in descending order of semantic similarity, and the top M fields are retained as target fields, where M is a configurable parameter, for example, it can be set to 8.

[0068] Furthermore, by concatenating the target reference examples, target fields, and target data table, a complete SQL generation information can be constructed. This SQL generation information is then used as input to the Large Language Model (LLM) to generate the initial query statement. Specifically, the Large Language Model (LLM) can output the corresponding initial query statement based on the query question target.

[0069] Based on this, the embodiments of this application significantly improve the accuracy and efficiency of filtering relevant tables and fields in ultra-large-scale database environments by integrating business scenarios, problem objectives, and semantic retrieval of fields. This effectively overcomes the problem of not being able to input the full schema due to the limited context length of the large language model. Furthermore, the reference examples constructed in this embodiment based on historical query experience serve as SQL generation information, significantly enhancing the large language model LLM's ability to understand and generate complex business queries. This effectively avoids SQL generation errors caused by incorrect table or field selection or semantic deviations in the large language model LLM, significantly improving the efficiency and accuracy of SQL generation.

[0070] Figure 6 A flowchart illustrating a method for generating a target query statement according to an embodiment of this application is shown. (Refer to...) Figure 6 As shown, step S104 above verifies the initial query statement and generates the target query statement after the verification passes. Specifically, it includes the following steps: S601. Validate the initial query statement.

[0071] Optionally, the intelligent agent performs multi-dimensional validation on the generated initial query statement, including at least one of the following: syntax validation, semantic validation, permission validation, execution simulation validation, and business logic validation. Syntax validation refers to integrating syntax parsers from mainstream databases such as MySQL and Oracle to check the compliance of SQL keywords, syntax structures, and function usage in the initial query statement, and outputting the location of syntax errors and correction suggestions. Semantic validation involves verifying the validity of table names and field names through schema mapping tables, checking the rationality of JOIN conditions using inter-table association rules, and determining whether there are field type mismatches, such as comparing string fields with numeric fields. Permission validation involves connecting to the database permission management system to obtain the current user's table / field access permission list and verifying whether the generated initial query statement involves unauthorized tables / fields. Execution simulation validation involves creating a database mirror in a test environment, executing the initial query statement, and checking whether the execution result is empty, whether there is a timeout (e.g., execution time exceeding a preset threshold), or whether there is data overflow. Business logic validation involves verifying whether the calculation logic and statistical dimensions in the initial query statement conform to business specifications based on a domain business rule library, such as "sales amount = unit price × sales volume".

[0072] S602. If the verification fails, the initial query statement is modified according to the preset correction rules to obtain the modified query statement. The modified query statement is then re-verified, and the target query statement is generated after the verification passes.

[0073] Optionally, if any of the above-mentioned dimensions fails the validation, the initial query statement is deemed to have failed validation, and the initial query statement is corrected according to preset correction rules to obtain a corrected query statement. These preset correction rules include, but are not limited to, rules for correcting syntax errors, rules for correcting incorrect table / field selection, rules for correcting insufficient permissions, and rules for correcting business logic errors. Specifically, for syntax errors, the corresponding correction rule is to directly adjust the initial query statement based on the syntax parser's correction suggestions; for incorrect table / field selection, the corresponding correction rule is to replace the incorrectly selected table / field with the correct table / field based on schema information and semantic mapping rules; for insufficient permissions, the corresponding correction rule is to generate a permission request prompt or replace it with a substitute table / field that the user has permission to access; and for business logic errors, the corresponding correction rule is to correct the business calculation logic by combining it with the business rule base.

[0074] Furthermore, after each correction, the entire validation process is re-executed on the newly generated corrected query statement, and this process is iterated until the corrected query statement passes validation in all dimensions or reaches the maximum number of corrections, at which point the final target query statement is output. Additionally, if the validation still fails after reaching the maximum number of corrections, the intelligent agent generates feedback information including the error type, possible causes, and alternative query solutions, which is then displayed to the user for selection or further explanation.

[0075] S603. If the verification passes, the initial query statement will be used as the target query statement.

[0076] Optionally, if the initial query statement passes all the initial full-dimensional validations, meaning that the initial query statement has no syntax, semantic, permission, execution, or business logic issues, then the initial query statement can be directly used as the final target query statement.

[0077] Based on this, the embodiments of this application significantly improve the accuracy of SQL generation through multiple dimensions of verification and correction mechanisms.

[0078] Based on the same inventive concept, this application also provides a data query device based on intelligent agents, which corresponds to the data query method based on intelligent agents. Since the principle of solving the problem by the data query device based on intelligent agents in this application is similar to the data query method based on intelligent agents described above, the implementation of the data query device based on intelligent agents can refer to the implementation of the data query method based on intelligent agents, and the repeated parts will not be described again.

[0079] Reference Figure 7 The diagram shown is a structural schematic of a data query device based on an intelligent agent provided in an embodiment of this application. The data query device 700 based on an intelligent agent includes: a receiving module 701, an intent clarification module 702, a generation module 703, a verification module 704, and a query module 705, wherein: The receiving module 701 is used to receive query information input by the user, which is described in natural language. The intent clarification module 702 is used to perform multiple rounds of intent clarification processing on the query information to determine the user's clarification intent; The generation module 703 is used to retrieve query statement generation information from the structured knowledge base based on the user's clarification intent, and generate an initial query statement based on the query statement generation information. The user's clarification intent includes intent information in multiple dimensions, and the query statement generation information is used to indicate the structured data in the structured knowledge base that is associated with the intent information in multiple dimensions. The verification module 704 is used to verify the initial query statement and generate the target query statement after the verification is passed. The query module 705 is used to retrieve target data from a preset database based on the target query statement.

[0080] Based on this, the data query device based on intelligent agents according to the embodiments of this application addresses the problem of ambiguous or incomplete query intent in user-input query information described in natural language. It employs a multi-round interactive clarification mechanism to generate corresponding clarification information, supplementing and improving the user's ambiguous intent and confirming the user's clarified intent, thereby effectively avoiding SQL generation deviations caused by misjudgment of intent. Furthermore, this application pre-constructs a structured knowledge base. Addressing the issue of errors in table or field selection in large-scale databases, based on the confirmed user clarification intent, it retrieves query statement generation information hierarchically from the constructed structured knowledge base, generates an initial query statement based on this information, performs multi-dimensional verification on the initial query statement, and automatically corrects it if verification fails, ultimately outputting the correct target query statement. This target query statement is then used to retrieve the corresponding target data from a preset database. Therefore, this embodiment of the application, through multi-round intent clarification, hierarchical retrieval combined with a structured knowledge base, and verification and correction of the query statement, accurately achieves the conversion from natural language to structured query language in real and complex business environments, thereby significantly improving the accuracy and efficiency of data querying.

[0081] In one possible implementation, the intent clarification module 702 described above is specifically used for: In the current round, key elements are extracted from the query information, and the user's intent clarity score is determined based on the extraction quality information of the key elements. If the intent clarity score is less than the preset threshold, then retrieve experiential information from the structured knowledge base and generate clarification information based on the experiential information; Obtain supplementary information from the user regarding the clarification information, and merge the supplementary information with the query information to obtain new query information; Use the new query information as the query information for the next round; If the intent clarity score is greater than or equal to a preset threshold, the user's clarification intent is determined based on the extracted key elements.

[0082] In one possible implementation, the intent clarification module 702 described above is specifically used for: If the intent clarity score is less than the preset threshold, the type of missing element is determined based on the extracted quality information; Retrieve experiential information matching the type of missing element from a structured knowledge base, and determine the target clarification script template based on the experiential information; Clarification information is generated based on the target clarification script template.

[0083] In one possible implementation, the intent information across multiple dimensions includes: problem target intent information, field intent information, business scenario intent information, and constraint condition intent information; the aforementioned generation module 703 is specifically used for: Based on the problem target intent information, field intent information, business scenario intent information, constraint condition intent information, and multiple indexes corresponding to the structured knowledge base, the target data table and target reference examples in the query statement generation information are retrieved from the structured knowledge base. Among them, the structured knowledge base stores multiple reference examples, each of which is used to indicate the historical user intent and the query statement and query results corresponding to the historical user intent. Based on the field intent information, at least one target field from the query statement generation information is retrieved from the target data table.

[0084] In one possible implementation, the above-mentioned generation module 703 is specifically used for: Based on the problem target intent information, business scenario intent information, constraint condition intent information, and reference query statement index, target reference examples are retrieved from the structured knowledge base; Based on the problem target intent information, business scenario intent information, and table indexes, multiple first candidate data tables are retrieved from the structured knowledge base; Based on field intent information and field indexes, multiple second candidate data tables are retrieved from the structured knowledge base; Multiple first-candidate data tables and multiple second-candidate data tables are sorted and filtered to obtain multiple target data tables.

[0085] In one possible implementation, the above-mentioned generation module 703 is specifically used for: The business scenario intent information is matched with the business fields of each historical query record in the reference query statement index, and multiple first historical query records that match the business scenario intent are filtered. Match the problem's target intent information with the problem description field in each first historical query record, and filter out multiple second historical query records that match the problem's target intent; Match the constraint intent information with the constraint fields in each second historical query record, and filter the third historical query records that match the constraint intent. The problem description field and the corresponding executable query statement in the third historical query record are used as the target reference example.

[0086] In one possible implementation, the above-mentioned generation module 703 is specifically used for: Calculate the semantic similarity between each field in the target data table and the field intent information; Based on semantic similarity, at least one target field is selected from multiple fields in the target data table.

[0087] In one possible implementation, the verification module 704 is specifically used for: The initial query statement is validated, including at least one of the following: syntax validation, semantic validation, permission validation, execution simulation validation, and business logic validation. If the verification fails, the initial query statement is modified according to the preset correction rules to obtain the modified query statement. The modified query statement is then re-verified, and the target query statement is generated after the verification passes. If the validation passes, the initial query statement will be used as the target query statement.

[0088] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0089] This application also provides an electronic device 800, such as... Figure 8The diagram shows the structure of an electronic device 800 provided in this embodiment of the application, including: a processor 801 and a memory 802. Optionally, it may also include a bus 803. The memory 802 stores machine-readable instructions executable by the processor 801. When the electronic device 800 is running, the processor 801 and the memory 802 communicate via the bus 803. When the machine-readable instructions are executed by the processor 801, the following processing is performed: Receive query information input by the user, and describe the query information in natural language; Perform multiple rounds of intent clarification processing on the query information to determine the user's intent to clarify; Based on the user's clarification intent, query statement generation information is retrieved from the structured knowledge base, and an initial query statement is generated based on the query statement generation information. The user's clarification intent includes intent information in multiple dimensions, and the query statement generation information is used to indicate the structured data in the structured knowledge base that is associated with intent information in multiple dimensions. The initial query statement is validated, and the target query statement is generated after the validation passes. The target data is retrieved from the preset database based on the target query statement.

[0090] In one possible implementation, when the processor 801 executes instructions to perform multi-round intent clarification processing on the query information and determine the user's clarification intent, it specifically performs the following: In the current round, key elements are extracted from the query information, and the user's intent clarity score is determined based on the extraction quality information of the key elements. If the intent clarity score is less than the preset threshold, then retrieve experiential information from the structured knowledge base and generate clarification information based on the experiential information; Obtain supplementary information from the user regarding the clarification information, and merge the supplementary information with the query information to obtain new query information; Use the new query information as the query information for the next round; If the intent clarity score is greater than or equal to a preset threshold, the user's clarification intent is determined based on the extracted key elements.

[0091] In one possible implementation, when the processor 801 executes the instruction to retrieve experiential information from a structured knowledge base and generate clarification information based on the experiential information if the intent clarity score is less than a preset threshold, it specifically performs the following: If the intent clarity score is less than the preset threshold, the type of missing element is determined based on the extracted quality information; Retrieve experiential information matching the type of missing element from a structured knowledge base, and determine the target clarification script template based on the experiential information; Clarification information is generated based on the target clarification script template.

[0092] In one possible implementation, the intent information across multiple dimensions includes: problem target intent information, field intent information, business scenario intent information, and constraint condition intent information; when the processor 801 executes the instruction to retrieve query statement generation information from the structured knowledge base based on the user's clarification intent, it is specifically used for: Based on the problem target intent information, field intent information, business scenario intent information, constraint condition intent information, and multiple indexes corresponding to the structured knowledge base, the target data table and target reference examples in the query statement generation information are retrieved from the structured knowledge base. Among them, the structured knowledge base stores multiple reference examples, each of which is used to indicate the historical user intent and the query statement and query results corresponding to the historical user intent. Based on the field intent information, at least one target field from the query statement generation information is retrieved from the target data table.

[0093] In one possible implementation, when the processor 801 executes an instruction to retrieve the target data table and target reference example from the query statement generation information based on the problem target intent information, field intent information, business scenario intent information, constraint condition intent information, and multiple indexes corresponding to the structured knowledge base, it specifically performs the following: Based on the problem target intent information, business scenario intent information, constraint condition intent information, and reference query statement index, target reference examples are retrieved from the structured knowledge base; Based on the problem target intent information, business scenario intent information, and table indexes, multiple first candidate data tables are retrieved from the structured knowledge base; Based on field intent information and field indexes, multiple second candidate data tables are retrieved from the structured knowledge base; Multiple first-candidate data tables and multiple second-candidate data tables are sorted and filtered to obtain multiple target data tables.

[0094] In one possible implementation, when the processor 801 executes instructions to retrieve a target reference example from a structured knowledge base based on problem target intent information, business scenario intent information, constraint condition intent information, and a reference query statement index, it specifically performs the following: The business scenario intent information is matched with the business fields of each historical query record in the reference query statement index, and multiple first historical query records that match the business scenario intent are filtered. Match the problem's target intent information with the problem description field in each first historical query record, and filter out multiple second historical query records that match the problem's target intent; Match the constraint intent information with the constraint fields in each second historical query record, and filter the third historical query records that match the constraint intent. The problem description field and the corresponding executable query statement in the third historical query record are used as the target reference example.

[0095] In one possible implementation, when the processor 801 executes an instruction to retrieve at least one target field from the query statement generation information in the target data table based on the field intent information, it specifically performs the following: Calculate the semantic similarity between each field in the target data table and the field intent information; Based on semantic similarity, at least one target field is selected from multiple fields in the target data table.

[0096] In one possible implementation, when the processor 801 executes instructions to validate the initial query statement and generate the target query statement after successful validation, it specifically performs the following: The initial query statement is validated, including at least one of the following: syntax validation, semantic validation, permission validation, execution simulation validation, and business logic validation. If the verification fails, the initial query statement is modified according to the preset correction rules to obtain the modified query statement. The modified query statement is then re-verified, and the target query statement is generated after the verification passes. If the validation passes, the initial query statement will be used as the target query statement.

[0097] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the following steps: Receive query information input by the user, and describe the query information in natural language; Perform multiple rounds of intent clarification processing on the query information to determine the user's intent to clarify; Based on the user's clarification intent, query statement generation information is retrieved from the structured knowledge base, and an initial query statement is generated based on the query statement generation information. The user's clarification intent includes intent information in multiple dimensions, and the query statement generation information is used to indicate the structured data in the structured knowledge base that is associated with intent information in multiple dimensions. The initial query statement is validated, and the target query statement is generated after the validation passes. The target data is retrieved from the preset database based on the target query statement.

[0098] In one possible implementation, when the processor executes instructions to perform multi-round intent clarification processing on the query information and determine the user's clarification intent, it specifically performs the following: In the current round, key elements are extracted from the query information, and the user's intent clarity score is determined based on the extraction quality information of the key elements. If the intent clarity score is less than the preset threshold, then retrieve experiential information from the structured knowledge base and generate clarification information based on the experiential information; Obtain supplementary information from the user regarding the clarification information, and merge the supplementary information with the query information to obtain new query information; Use the new query information as the query information for the next round; If the intent clarity score is greater than or equal to a preset threshold, the user's clarification intent is determined based on the extracted key elements.

[0099] In one possible implementation, when the processor executes the instruction to retrieve experiential information from a structured knowledge base and generate clarification information based on the experiential information if the intent clarity score is less than a preset threshold, it specifically uses: If the intent clarity score is less than the preset threshold, the type of missing element is determined based on the extracted quality information; Retrieve experiential information matching the type of missing element from a structured knowledge base, and determine the target clarification script template based on the experiential information; Clarification information is generated based on the target clarification script template.

[0100] In one possible implementation, the intent information across multiple dimensions includes: problem target intent information, field intent information, business scenario intent information, and constraint condition intent information; when the processor executes the instruction to retrieve query statement generation information from the structured knowledge base based on the user's clarification intent, it is specifically used for: Based on the problem target intent information, field intent information, business scenario intent information, constraint condition intent information, and multiple indexes corresponding to the structured knowledge base, the target data table and target reference examples in the query statement generation information are retrieved from the structured knowledge base. Among them, the structured knowledge base stores multiple reference examples, each of which is used to indicate the historical user intent and the query statement and query results corresponding to the historical user intent. Based on the field intent information, at least one target field from the query statement generation information is retrieved from the target data table.

[0101] In one possible implementation, when the processor executes an instruction to retrieve the target data table and target reference example from the query statement generation information based on the problem target intent information, field intent information, business scenario intent information, constraint condition intent information, and multiple indexes corresponding to the structured knowledge base, it specifically performs the following: Based on the problem target intent information, business scenario intent information, constraint condition intent information, and reference query statement index, target reference examples are retrieved from the structured knowledge base; Based on the problem target intent information, business scenario intent information, and table indexes, multiple first candidate data tables are retrieved from the structured knowledge base; Based on field intent information and field indexes, multiple second candidate data tables are retrieved from the structured knowledge base; Multiple first-candidate data tables and multiple second-candidate data tables are sorted and filtered to obtain multiple target data tables.

[0102] In one possible implementation, when the processor executes instructions to retrieve a target reference example from a structured knowledge base based on problem target intent information, business scenario intent information, constraint condition intent information, and a reference query statement index, it specifically performs the following: The business scenario intent information is matched with the business fields of each historical query record in the reference query statement index, and multiple first historical query records that match the business scenario intent are filtered. Match the problem's target intent information with the problem description field in each first historical query record, and filter out multiple second historical query records that match the problem's target intent; Match the constraint intent information with the constraint fields in each second historical query record, and filter the third historical query records that match the constraint intent. The problem description field and the corresponding executable query statement in the third historical query record are used as the target reference example.

[0103] In one possible implementation, when the processor executes an instruction to retrieve at least one target field from the query statement generation information in the target data table based on the field intent information, it specifically performs the following: Calculate the semantic similarity between each field in the target data table and the field intent information; Based on semantic similarity, at least one target field is selected from multiple fields in the target data table.

[0104] In one possible implementation, when the processor executes instructions to validate the initial query statement and generate the target query statement after successful validation, it specifically performs the following: The initial query statement is validated, including at least one of the following: syntax validation, semantic validation, permission validation, execution simulation validation, and business logic validation. If the verification fails, the initial query statement is modified according to the preset correction rules to obtain the modified query statement. The modified query statement is then re-verified, and the target query statement is generated after the verification passes. If the validation passes, the initial query statement will be used as the target query statement.

[0105] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.

[0106] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.

[0107] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. A data query method based on intelligent agents, characterized in that, include: Receive query information input by the user, the query information being described in natural language; The query information is processed through multiple rounds of intent clarification to determine the user's intent to clarify. Based on the user's clarification intent, query statement generation information is retrieved from the structured knowledge base, and an initial query statement is generated based on the query statement generation information. The user's clarification intent includes intent information of multiple dimensions, and the query statement generation information is used to indicate the structured data in the structured knowledge base associated with the intent information of the multiple dimensions. The initial query statement is validated, and the target query statement is generated after the validation passes. The target data is obtained from the preset database based on the target query statement.

2. The method according to claim 1, characterized in that, The process of performing multiple rounds of intent clarification on the query information to determine the user's clarification intent includes: In the current round, key elements are extracted from the query information, and the user's intent clarity score is determined based on the extraction quality information of the key elements. If the intent clarity score is less than a preset threshold, then experiential information is retrieved from the structured knowledge base, and clarification information is generated based on the experiential information. Obtain supplementary information from the user regarding the clarification information, and merge the supplementary information with the query information to obtain new query information; The new query information will be used as the query information for the next round; If the intent clarity score is greater than or equal to the preset threshold, the user's clarification intent is determined based on the extracted key elements.

3. The method according to claim 2, characterized in that, If the intent clarity score is less than a preset threshold, then experiential information is retrieved from the structured knowledge base, and clarification information is generated based on the experiential information, including: If the intent clarity score is less than the preset threshold, the missing element type is determined based on the extracted quality information; Retrieve the experience information that matches the missing element type from the structured knowledge base, and determine the target clarification script template based on the experience information; The clarification information is generated based on the target clarification script template.

4. The method according to claim 1, characterized in that, The intent information in the multiple dimensions includes: problem target intent information, field intent information, business scenario intent information, and constraint condition intent information; The step of retrieving query statement generation information from a structured knowledge base based on the user's clarification intent includes: Based on the problem target intent information, the field intent information, the business scenario intent information, the constraint condition intent information, and multiple indexes corresponding to the structured knowledge base, the target data table and target reference examples in the query statement generation information are retrieved from the structured knowledge base. The structured knowledge base stores multiple reference examples, each of which is used to indicate the historical user intent and the query statement and query results corresponding to the historical user intent. Based on the field intent information, at least one target field from the query statement generation information is retrieved from the target data table.

5. The method according to claim 4, characterized in that, The step of retrieving the target data table and target reference example from the query statement generation information based on the problem target intent information, the field intent information, the business scenario intent information, the constraint condition intent information, and multiple indexes corresponding to the structured knowledge base includes: Based on the problem target intent information, the business scenario intent information, the constraint condition intent information, and the reference query statement index, the target reference example is retrieved from the structured knowledge base; Based on the problem target intent information, the business scenario intent information, and the table index, multiple first candidate data tables are retrieved from the structured knowledge base; Based on the field intent information and field index, multiple second candidate data tables are retrieved from the structured knowledge base; The plurality of first candidate data tables and the plurality of second candidate data tables are sorted and filtered to obtain a plurality of target data tables.

6. The method according to claim 5, characterized in that, The step of retrieving the target reference example from the structured knowledge base based on the problem target intent information, the business scenario intent information, the constraint condition intent information, and the reference query statement index includes: The business scenario intent information is matched with the business fields of each historical query record in the reference query statement index to filter multiple first historical query records that match the business scenario intent. The problem target intent information is matched with the problem description field in each of the first historical query records to filter multiple second historical query records that match the problem target intent; The constraint intent information is matched with the constraint fields in each second historical query record to filter the third historical query records that match the constraint intent. The problem description field and the corresponding executable query statement in the third historical query record are used as the target reference example.

7. The method according to claim 4, characterized in that, The step of retrieving at least one target field from the query statement generation information from the target data table based on the field intent information includes: Calculate the semantic similarity between each field in the target data table and the intent information of the field; Based on the semantic similarity, at least one target field is selected from multiple fields in the target data table.

8. The method according to claim 1, characterized in that, The step of validating the initial query statement and generating the target query statement after the validation passes includes: The initial query statement is validated, and the validation includes at least one of the following: syntax validation, semantic validation, permission validation, execution simulation validation, and business logic validation. If the verification fails, the initial query statement is modified according to the preset correction rules to obtain the modified query statement, and the modified query statement is re-verified. After the verification passes, the target query statement is generated. If the verification passes, the initial query statement will be used as the target query statement.

9. An electronic device, characterized in that, include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, wherein when the electronic device is running, the processor executes the machine-readable instructions to perform the steps of the data query method based on a smart agent as described in any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the data query method based on a smart agent as described in any one of claims 1 to 8.