Task decomposition tree-based data query method and system for power equipment
By clustering and clustering tasks on the power equipment query API, generating a task decomposition tree, and optimizing a large language model, the inefficiency and accuracy of the power equipment data query method in complex scenarios is solved, and efficient and reliable data query is achieved.
Patent Information
- Application Number
- CN202510470218.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-08-01
AI Technical Summary
The existing power equipment data query methods are inefficient in complex scenarios and inaccurate results, and lack task decomposition and hierarchical understanding of complex query problems.
Using a method based on the task decomposition tree, the power equipment query API is clustered and clustered, and the task decomposition tree is generated. The large language model is optimized through optimal path evaluation and loss function, and API call instructions that meet the needs of power equipment data query are generated.
It significantly improves the accuracy and efficiency of complex queries, reduces manual annotation costs, improves the diversity and quality of training data, enhances the flexibility and adaptability of the system, and ensures the reliability and accuracy of query results.
Smart Images

Figure CN120407649A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power equipment data query, and particularly relates to a data query method and system based on a task decomposition tree for power equipment. Background Art
[0002] With the continuous increase in business complexity in the field of power equipment, power equipment usually generates a large amount of complex data, which involves multiple dimensions and attributes, including equipment status, operating parameters, fault information, maintenance records, equipment defects, etc. Traditional query methods often rely on manually writing SQL statements, which have a high threshold for business personnel and the query process is cumbersome and error-prone.
[0003] Technologies based on natural language processing (NLP) and large language models (such as GPT) can help automate the processing of data query requirements and convert natural language into specific database query commands. However, existing large language models perform poorly when dealing with complex query problems, lacking task decomposition and hierarchical understanding of complex query problems, and cannot effectively support complex multi-task nested queries. This makes it often face problems of low efficiency and inaccurate results in complex scenarios such as fault diagnosis or load prediction. Summary of the Invention
[0004] The purpose of the present invention is to provide a data query method and system based on a task decomposition tree for power equipment to solve the problems of low efficiency and inaccurate results faced by existing query methods in complex scenarios.
[0005] To achieve the above purpose, the present invention adopts the following technical solutions: In the first aspect, the present invention provides a data query method based on a task decomposition tree for power equipment, including: Performing task clustering on the power equipment query application programming interface API to form an API clustering cluster, and constructing an API clustering cluster - query problem pair based on the API clustering cluster; For each API clustering cluster - query problem pair, generating a task decomposition tree within a set task set, evaluating all links of the task decomposition tree, and selecting the optimal path as a training sample; Performing API call chain execution verification on the generated training samples, verifying the logical consistency between the API clustering cluster - query problem pair and the path, and retaining samples that meet the execution success rate and consistency threshold to construct a training set; Based on the training set, constructing a loss function that maximizes the difference between the optimal inference path and the worst inference path, and adjusting the parameters of the large language model based on the loss function to optimize the model and generate API call instructions that meet the power equipment data query requirements.
[0006] Optionally, the task clustering of the power equipment query application programming interface (API) to form an API clustering cluster includes: Based on the working domain of the grid equipment query API, the APIs in the same working domain form a subset that can be interoperably called ; within each working domain, the APIs are divided into subsets of different dimensions according to the labels of the APIs , and at the same time, combining the entities and relationships in the power knowledge graph, the API documents are matched, and the labels are extracted and supplemented to the label markings of the APIs; for each the k-th API in , its document is encoded into a vector , and then a clustering algorithm is used to cluster the vectors to obtain task clusters
[0007] Optionally, the construction of the API clustering cluster-query problem pair based on the API clustering cluster includes: For each API clustering cluster, an instruction generation large model is used to construct query problems. Each API clustering cluster generates several single-task query problems and several complex query problems to obtain an API clustering cluster-query problem pair
[0008] Optionally, for each API clustering cluster-query problem pair, generating a task decomposition tree within a set task includes: Randomly select an API clustering cluster-query problem pair , where , for each Construct fine-tuning data based on the task decomposition tree. First, define a task set that includes single-step queries, multi-step queries, sub-problem decomposition, and query condition reconstruction, and then generate a task decomposition tree based on the task set
[0009] Optionally, evaluating all links of the task decomposition tree and selecting the optimal path as the training sample includes: Evaluating based on the expected consistency of all inference links in the decomposition tree
[0010]
[0011] where represents the score of the link of the task decomposition tree , T represents all output sets in the task decomposition tree represents the input query problem and the dialogue context represents the given input when generating probability represents the output and The vector consistency metric between indicates that the output is vector-encoded using the BERT encoder; finally, select the inference link with the highest score as the optimal link, and the one with the lowest score as the worst link.
[0012] Optionally, perform API call chain execution verification on the generated optimal path, verify the logical consistency between the API cluster-query problem pair and the path, and retain the samples that meet the execution success rate and consistency threshold to construct a training set, including: Verify the API call chain: Verify whether the API call chain of the optimal link in the task decomposition tree can be successfully executed; Verify sample consistency: Use the verification large model to verify the API cluster-query problem pair -> inference link -> the consistency of the API call instruction; if the consistency passes, retain it, otherwise delete it from the training set; Verify sample consistency: Use the verification large model to verify the API cluster-query problem pair -> inference link -> the consistency of the API call instruction; if the consistency fails, retain it, otherwise randomly intercept a fragment of the link as the link; Construct samples that meet the above three conditions as the training set.
[0013] Optionally, based on the training set, construct a loss function that maximizes the difference between the optimal inference path and the worst inference path, and adjust the parameters of the large language model based on the loss function to generate API call instructions that meet the power equipment data query requirements, including: Based on Construct a loss function
[0014]
[0015] Construct the following optimization objective to enhance it for the data query inference link with the highest evaluation score and suppress the data query inference link with the lowest evaluation score ; maximize the difference between the data query link with the highest evaluation score and the data query link with the lowest evaluation score:
[0016] The final loss function combines and and uses to regulate the weights:
[0017] Finally, the above loss function is used to adjust the model.
[0018] In a second aspect, the present invention provides a data query system based on a task decomposition tree for power equipment, including: A task partitioning module, configured to perform task clustering on the power equipment query application programming interface API to form API clustering clusters, and construct API clustering cluster - query problem pairs based on the API clustering clusters; An optimal path generation module, configured to generate a task decomposition tree within a set task set for each API clustering cluster - query problem pair, evaluate all links of the task decomposition tree, and select the optimal path as a training sample; A training set construction module, configured to perform API call chain execution verification on the generated training samples, verify the logical consistency between the API clustering cluster - query problem pairs and the paths, and retain the samples that meet the execution success rate and consistency threshold to construct a training set; An adjustment output module, configured to construct a loss function that maximizes the difference between the optimal inference path and the worst inference path based on the training set, adjust the parameters of the large language model based on the loss function, and generate API call instructions that meet the power equipment data query requirements.
[0019] Optionally, in the task partitioning module, the performing task clustering on the power equipment query application programming interface API to form API clustering clusters includes: Based on the working domains of the grid equipment query APIs, the APIs in the same working domain form a subset that can be interoperably called ; within each working domain, according to the labels of the APIs, the APIs are divided into subsets of different dimensions , and at the same time, in combination with the entities and relationships in the power knowledge graph, the API documents are matched, and the extracted labels are supplemented to the label markings of the APIs; for each the kth API in , its document is encoded into a vector , and then a clustering algorithm is used to cluster the vectors to obtain task clusters; The constructing API clustering cluster - query problem pairs based on the API clustering clusters includes: For each API clustering cluster, a query problem is constructed using an instruction generation large model, and each API clustering cluster generates several single - task query problems and several complex query problems to obtain API clustering cluster - query problem pairs.
[0020] Optionally, in the optimal path generation module, for each API cluster-query problem pair, generating a task decomposition tree within a set task set includes: Randomly select an API cluster-query problem pair , where , for each Construct fine-tuning data based on the task decomposition tree. First, define a task set that includes single-step queries, multi-step queries, sub-problem decomposition, and query condition reconstruction, and then generate a task decomposition tree based on the task set; Evaluating all links of the task decomposition tree and selecting the optimal path as the training sample includes: Evaluating based on the expected consistency of all inference links in the decomposition tree;
[0021]
[0022] where represents the score of the link of the task decomposition tree, T represents all output sets in the task decomposition tree, represents the input query problem and the dialogue context, represents the given input when generating probability; represents the output and vector consistency metric between, where represents vector encoding of the output using the BERT encoder; finally select the inference link with the highest score as the optimal link, and the one with the lowest score as the worst link.
[0023] Optionally, in the training set construction module, validating the generated optimal path through API call chain execution, verifying the logical consistency between the API cluster-query problem pair and the path, and retaining samples that meet the execution success rate and consistency threshold to construct the training set, including: Verify the API call chain: Verify whether the API call chain of the optimal link in the task decomposition tree can be successfully executed; Verify sample consistency: Use the verification large model to verify the API cluster-query problem pair -> inference link -> Consistency of API call instructions; if the consistency passes, it is retained; otherwise, it is deleted from the training set; Verification Sample consistency: Use the verification large model to verify the API clustering cluster-query problem pair ->Inference link -> Consistency of API call instructions; if the consistency fails, it is retained; otherwise, a random segment is intercepted The segment of the link as Link; Construct samples that meet the above three conditions as the training set.
[0024] Optionally, in the output module, based on the training set, construct a loss function that maximizes the difference between the optimal inference path and the worst inference path, and adjust the parameters of the large language model based on the loss function to generate API call instructions that meet the data query requirements of power equipment, including: Based on Construct a loss function
[0025]
[0026] Construct the following optimization objective to enhance the data query inference link with the highest evaluation score And suppress the data query inference link with the lowest evaluation score ; Maximize the difference between the data query link with the highest evaluation score and the data query link with the lowest evaluation score:
[0027] The final loss function combines And And use To regulate the weights:
[0028] Finally, use the above loss function to adjust the model.
[0029] In a third aspect, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the data query method based on the task decomposition tree for power equipment are implemented.
[0030] In a fourth aspect, the present invention provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data query method based on the task decomposition tree for power equipment are implemented.
[0031] Compared with the prior art, the present invention has the following technical effects: The data query method based on task decomposition tree for power equipment of the present invention realizes the automatic decomposition and structured processing of power equipment data query tasks through task clustering and the construction of API clustering cluster-query problem pairs, reducing the difficulty of complex queries. Through the task decomposition tree and optimal path evaluation, the accuracy and efficiency of complex nested queries are significantly improved, especially in complex scenarios such as equipment fault diagnosis and load prediction. Through automatic sample construction and model fine-tuning, the dependence on manual annotation is reduced, the cost is lowered, and at the same time, the diversity and quality of training data are improved.
[0032] Furthermore, through multi-dimensional API clustering based on work domain and labels, the efficient organization and classification of power equipment query APIs are realized, providing a clear set of candidate subtasks for complex query tasks. Combining with the power knowledge graph, the label information of the APIs is supplemented, enhancing the accuracy and domain adaptability of API clustering. Through the BERT model and clustering algorithm, the API documents are encoded into vectors and clustered, ensuring the semantic consistency and functional relevance of the task clusters.
[0033] Furthermore, by using the instruction generation large model to automatically generate single-task and complex query problems, the workload of manually writing query problems is significantly reduced. The generated query problem set covers various scenarios of power equipment data query, including single-task queries and multi-task nested queries, improving the diversity and practicality of training data. The ability to generate complex query problems enables the system to better adapt to the actual needs of the power equipment field. Furthermore, by defining a task set including single-step queries, multi-step queries, sub-problem decomposition, and query condition reconstruction, a flexible operation framework is provided for complex query tasks. The generation method of the task decomposition tree can gradually decompose complex problems into simple subtasks, ensuring the coherence and logic of each step of reasoning. Through the diversity of the task set, the system can dynamically adapt to different query requirements, improving the flexibility and adaptability of the query process.
[0034] Furthermore, through expected consistency evaluation, the quality of the reasoning link can be quantified to ensure the selection of the optimal path as the training sample. The output is vector-encoded using the BERT encoder, and the reasoning link is evaluated through consistency measurement, improving the accuracy and objectivity of the evaluation. By selecting the optimal link and suppressing low-score links, the quality of the training data is optimized, providing high-quality samples for model fine-tuning.
[0035] Furthermore, verification is performed through the API call chain to ensure that the generated inference path can be successfully executed in practical applications, improving the reliability of the system. The verification large model is used to check the logical consistency of the API clustering cluster-query problem pairs and the inference path, further enhancing the accuracy and practicality of the training data. Through the sample screening mechanism, inconsistent or invalid samples are removed, ensuring the high quality and efficiency of the training set.
[0036] Furthermore, by constructing a loss function that maximizes the difference between the optimal inference path and the worst inference path, the model's learning ability for high-quality inference paths is enhanced. By suppressing low-score inference links, the deviation of the model on low-quality paths is reduced, improving the overall performance of the model. Combining multi-objective optimization and weight regulation, fine-tuning of the model parameters is achieved, enabling it to better adapt to the requirements of power equipment data queries.
[0037] Through hierarchical API clustering, task decomposition tree generation, optimal path evaluation, and automated sample construction, the present invention significantly improves the accuracy, efficiency, and automation level of power equipment data queries. At the same time, by reducing the manual annotation cost and optimizing the model fine-tuning process, the complexity of system development and maintenance is reduced, providing an efficient and reliable solution for complex data queries in the field of power equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flowchart of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0039] The present invention is further described below with reference to the accompanying drawings: Example 1, please refer to Figure 1 , the present invention provides a data query method based on a task decomposition tree for power equipment, including: S1. Perform task clustering on the power equipment query application programming interface (API) to form API clustering clusters, and construct API clustering cluster-query problem pairs based on the API clustering clusters; S2. For each API clustering cluster-query problem pair, generate a task decomposition tree within the set task collection, evaluate all links of the task decomposition tree, and select the optimal path as the training sample; S3. Perform API call chain execution verification on the generated optimal path, check the logical consistency of the API clustering cluster-query problem pair and the path, and retain the samples that meet the execution success rate and consistency threshold to construct the training set; S4. Based on the training set, construct a loss function that maximizes the difference between the optimal inference path and the worst inference path, adjust the parameters of the large language model based on the loss function, and generate API call instructions that meet the requirements of power equipment data queries after optimizing the model.
[0040] The API is the application programming interface for power equipment data query, which refers to encapsulating the database query logic in the power equipment business into an executable API call.
[0041] Through the construction method of the data query task decomposition tree, complex problems are gradually decomposed into a series of simple subtasks, enabling the system to clearly select the most suitable operation at each step (such as single-step query, multi-step query, or sub-problem decomposition, etc.), thereby gradually collecting the necessary data and analyzing complex problems. For example, the fault diagnosis task of the power grid may involve data collection and reasoning steps in multiple dimensions, and the decomposition tree method of the present invention can ensure the coherence and consistency of each step of reasoning, avoiding data omission or errors caused by single queries in traditional methods. In addition, through task decomposition and reasoning path evaluation, the system can automatically evaluate the effectiveness of each reasoning path and select the optimal path, which can provide more reliable and accurate results when facing the changing operating conditions of power equipment. By designing a multi-objective model fine-tuning loss function to enhance high-score reasoning links and suppress low-score links, it helps the model better distinguish different-quality reasoning links, thereby improving the accuracy and performance of the model.
[0042] A method for automatically constructing complex query fine-tuning samples in the field of power equipment, which is adapted to the power equipment data query scenario with the least manual annotation cost. Through hierarchical multi-dimensional API clustering, complex query problems and their corresponding data query task decomposition trees are generated. Then, an evaluation function for expected consistency is designed to screen out the optimal reasoning link and the worst reasoning link as fine-tuning samples. Compared with traditional methods, this method does not require manual intervention or a large amount of manual annotation, thus greatly reducing the workload of data annotation and improving the quality and diversity of training data. Through automatic sample construction, the system can dynamically adapt to various power equipment operating scenarios.
[0043] Example 2, the present invention provides a data query method based on a task decomposition tree for power equipment, specifically including: Step 1: Construct fine-tuning training data 1. API clustering to form API clustering clusters as candidate subtasks for complex nested tasks: Objective: Through a hierarchical multi-dimensional API clustering method, the existing APIs for power grid equipment data query are task-clustered to form a candidate subtask set that supports complex nested queries. The APIs within each cluster can be used as candidate subtasks for complex queries: Preliminary domain division: The APIs are initially grouped based on the working domains of the power grid equipment query APIs. The APIs in the same working domain form a subset that can be interoperably called.
[0044] Let the set of all power grid equipment query APIs be A, and the set of working domains be , define a function to obtain the working domain to which the API belongs. Then, the preliminary grouping result based on the working domain is , where .
[0045] Multi-dimensional label division: within each working domain, based on the labels of the APIs, the APIs are divided into subsets of different dimensions. Each API may belong to multiple labels. At the same time, entities and relationships in the power knowledge graph can be combined to match the API documents and extract relevant labels to supplement the label markings of the APIs. These labels can include device types, business types, application scenarios, and function categories, etc.
[0046] Within each preliminary grouping , let the label set be . Define a function to return the label set that APIa has. Then, the division result based on the labels is , where .
[0047] API clustering to form task clusters: For each the k-th API in , encode its document into a vector through the BERT model , and then use the K-means algorithm to cluster these vectors. The resulting task clusters are .
[0048] Aggregate related APIs together to form task clusters. Each API may appear in multiple clustering clusters, indicating its multiple roles in different tasks.
[0049] 2. Construct a query question set in the training data based on the API clustering clusters <API clustering clusters -> query questions>: For each API clustering cluster, use an instruction generation large model (CHATGPT + question generation prompt words) to construct query questions. Each API clustering cluster generates several single-task query questions and several complex query questions. The complex query questions involve multi-task nesting and multi-intention combination. Each query question is not just a single numerical query for API calls, but a combined data query for multiple numerical query APIs within the clustering cluster.
[0050] Finally, obtain the query question set corresponding to the API clustering cluster , .
[0051] Example explanation: Given an API clustering cluster {API_1, API_2,...}, the set of questions generated for the clustering cluster prediction task: Complex query problem: Query the load usage in the power grid today. When the load exceeds 90%, can the load regulation be triggered? Combine historical load and weather data to generate the load demand curve for the next 24 hours.
[0052] Single-task query problem: Query the load usage in the power grid today.
[0053] 3. Construct fine-tuning data based on the task decomposition tree Randomly select an API clustering cluster - query problem pair , where , for each Construct fine-tuning data based on the task decomposition tree. First, define the task set, then generate the task decomposition tree based on the task set, and finally evaluate all the links of the task decomposition tree to select the optimal path as the output of the fine-tuning sample.
[0054] A) Definition of the task set: O1: Single-step query Operation description: Based on the existing reasoning process, generate the next-step query API call instruction for the given problem.
[0055] Example: Query the operating status of the circuit breaker with the device number AH-LINE-003 in the last 24 hours.
[0056] O2: Multi-step query Operation description: Based on the existing reasoning process, generate multiple-step API query plans and corresponding query API call instructions for the given problem.
[0057] Example: Query the number of substations with a load exceeding 80% and their equipment status.
[0058] O3: Decompose sub-problems and query sub-data Operation description: This operation decomposes complex data query problems into simpler sub-problems and generates query API call instructions for each sub-problem. This method is especially suitable for handling complex power grid analysis tasks, such as load balancing, equipment fault diagnosis, etc. By decomposing a large problem into multiple small problems, it is solved step by step.
[0059] Example: For a complex power grid fault diagnosis problem, the system first proposes a sub-problem: "Are there any devices reporting overload?" and queries the status of the devices. Then, based on the query results, it further proposes "Does the overloaded device have a fault history?" and conducts a query.
[0060] O4: Reformulate query conditions or data query problems Operation Instructions: When the system detects errors in the query API call instructions or the API parameters are not filled correctly, the O4 operation can help the system reformulate the query problem. Reconstruct the query conditions from different perspectives to ensure the accuracy and comprehensiveness of the problem.
[0061] Example: If the system misinterprets the query requirements for grid load (e.g., missing some specific conditions), it can prompt the system to reformulate the query: "Requery the maximum value of grid load within a specific time period." The task set is defined as 。
[0062] B) Generate the data query task decomposition tree: At each step i, the inference process can be advanced by selecting the task The new state is determined by the current state and the task Suppose is the initialized inference state. At each step of inference i, based on the current state select the task and generate a new inference state :
[0063] For the entire analysis process, the trajectory of the data query task decomposition tree can be represented as a series of states:
[0064] where the trajectory T consists of a series of tasks and corresponding states.
[0065] The analysis process continues until a certain termination condition is met, such as all necessary data has been queried, or the question has been answered, or the depth reaches the maximum limit of the decomposition tree.
[0066] The decision formula for the termination condition is:
[0067] where task_complete indicates that the task is completed, d represents the current depth, represents the maximum depth of the decomposition tree. Through the data query task decomposition tree, efficient exploration and reasoning can be carried out in the query of grid equipment operation data, ensuring that the system can gradually collect sufficient information and avoid ineffective space exploration caused by a single query.
[0068] C) Evaluation of the inference trajectory of the task decomposition tree: The correct reasoning trajectory usually follows consistent planning steps and references the same information in context. Based on this idea, all outputs of the task decomposition tree are scored. The core idea of scoring is to prefer the reasoning link that is more consistent with other outputs, and the evaluation is based on the expected consistency of all reasoning links in the decomposition tree.
[0069]
[0070]
[0071] Among them represents the score of the link of the task decomposition tree T represents the set of all outputs in the task decomposition tree, represents the input query question and the dialogue context, represents the given input when generating probability.
[0072] represents the vector consistency measure between the output and Among them represents vector encoding the output using the BERT encoder. Finally, select the reasoning link with the highest score as the optimal link, and the one with the lowest score as the worst link.
[0073] Step 2: Sample Screening Verify the API call chain: Verify whether the API call chain of the optimal link in the task decomposition tree can be successfully executed.
[0074] Verify Sample consistency: Use the verification large model (Chatgpt) to verify the API cluster - query question pair -> reasoning link -> Consistency of API call instructions. If the consistency passes, keep it; otherwise, delete it from the training set.
[0075] Verify Sample consistency: Use the verification large model (Chatgpt) to verify the API cluster - query question pair -> reasoning link -> Consistency of API call instructions. If the consistency fails, keep it; otherwise, randomly intercept a segment of the link as the link.
[0076] Construct samples that meet the above three conditions as the training set Step 3: Model fine-tuning Based on Construct a loss function
[0077]
[0078] Construct the following optimization objective to enhance the data query inference link with the highest evaluation score and suppress the data query inference link with the lowest evaluation score . Maximize the difference between the data query link with the highest evaluation score and the data query link with the lowest evaluation score
[0079]
[0080] The final loss function combines and and uses to regulate the weights
[0081] Finally, fine-tune the model using the above loss function
[0082] This solution significantly improves the accuracy, efficiency, and automation level of power equipment data queries through hierarchical API clustering, task decomposition tree generation, optimal path evaluation, and automated sample construction. The following is a detailed analysis of the overall technical effects Improve the accuracy and efficiency of complex queries 1. Through API clustering and task decomposition tree, the complex power equipment data query task is decomposed into multiple simple subtasks, significantly reducing the difficulty of complex queries
[0083] 2. The generation of the task decomposition tree and optimal path evaluation ensure the logic and coherence of the query process, avoiding data omission or errors caused by a single query in traditional methods
[0084] 3. In complex scenarios such as equipment fault diagnosis and load prediction, the system can gradually collect and analyze data through multi-step reasoning and sub-problem decomposition, significantly improving the accuracy of query results
[0085] Reduce the cost of manual annotation 1. Through hierarchical multi-dimensional API clustering and automated query problem generation, the workload of manually writing query problems and annotating data is reduced
[0086] 2. Leveraging instruction - based large models (such as ChatGPT) to automatically generate single - task and complex query questions significantly reduces the cost of data annotation.
[0087] 3. Through the automated sample construction and screening mechanism, the system can dynamically adapt to various power equipment operation scenarios, reducing the need for manual intervention.
[0088] Enhance the flexibility and adaptability of the system 1. By defining a task set that includes single - step queries, multi - step queries, sub - problem decomposition, and query condition reconstruction, the system can flexibly handle different query requirements.
[0089] 2. The method of generating the task decomposition tree enables the system to dynamically adjust the query strategy to adapt to complex multi - dimensional query tasks.
[0090] 3. By combining the power knowledge graph and the BERT model, the system can better understand the semantics and functions of APIs, enhancing domain adaptability.
[0091] Improve the quality and diversity of training data 1. Through API clustering and task decomposition tree generation, the system can construct high - quality training data covering various scenarios of power equipment data queries.
[0092] 2. Through the optimal path evaluation and sample screening mechanism, inconsistent or invalid samples are eliminated, ensuring the high quality of the training set.
[0093] 3. The ability to generate complex query questions makes the training data more diverse, improving the generalization ability of the model.
[0094] Optimize model performance 1. By constructing a loss function that maximizes the difference between the optimal inference path and the worst inference path, the model's learning ability for high - quality inference paths is enhanced.
[0095] 2. By suppressing low - score inference links, the deviation of the model on low - quality paths is reduced, improving the overall performance of the model.
[0096] 3. Combining multi - objective optimization and weight regulation enables fine - tuning of model parameters, making it better adapt to the needs of power equipment data queries.
[0097] Support complex nested queries 1. Through the task decomposition tree and optimal path evaluation, the system can effectively support complex multi - task nested queries.
[0098] 2. In complex multi - dimensional query and data query tasks, the system can accurately infer and obtain the required results.
[0099] 3. Especially in the field of power equipment, in complex scenarios such as equipment fault diagnosis, load prediction, and maintenance decision-making, it significantly improves the accuracy of query results.
[0100] This solution significantly improves the accuracy, efficiency, and automation level of complex queries for power equipment data through hierarchical API clustering, task decomposition tree generation, optimal path evaluation, and automated sample construction. At the same time, by reducing the manual annotation cost and optimizing the model fine-tuning process, it reduces the complexity of system development and maintenance, providing an efficient and reliable solution for complex data queries in the field of power equipment.
[0101] In another embodiment of the present invention, a data query system for power equipment based on a task decomposition tree is provided, which can be used to implement the above-mentioned data query method for power equipment based on a task decomposition tree. Specifically, the system includes: A task division module, which is used to perform task clustering on the power equipment query application programming interface (API), form API clustering clusters, and construct API clustering cluster-query problem pairs based on the API clustering clusters; An optimal path generation module, which is used to generate a task decomposition tree within a set task set for each API clustering cluster-query problem pair, evaluate all links of the task decomposition tree, and select the optimal path as a training sample; A training set construction module, which is used to perform API call chain execution verification on the generated optimal path, verify the logical consistency between the API clustering cluster-query problem pair and the path, and retain samples that meet the execution success rate and consistency threshold to construct a training set; An adjustment output module, which is used to construct a loss function that maximizes the difference between the optimal inference path and the worst inference path based on the training set, adjust the parameters of the large language model based on the loss function, and optimize the model to generate API call instructions that meet the requirements of power equipment data queries.
[0102] When the task division module performs task clustering on the power equipment query application programming interface (API) to form API clustering clusters, it specifically is used for: Based on the working domain of the grid equipment query API, APIs in the same working domain form a subset that can be interoperably called ; within each working domain, according to the labels of the APIs, the APIs are divided into subsets of different dimensions , and at the same time, combined with the entities and relationships in the power knowledge graph, the API documents are matched, and the extracted labels are supplemented to the label markings of the APIs; for each the k-th API in , its document is encoded into a vector , and then the vectors are clustered using a clustering algorithm to obtain task clusters.
[0103] In the task division module, API cluster-query problem pairs are constructed based on API clusters, including: For each API cluster, a large language model for instruction generation is used to construct query problems. Each API cluster generates a number of single-task query problems and a number of complex query problems, resulting in API cluster-query problem pairs.
[0104] When the optimal path generation module generates a task decomposition tree within a set task collection for each API cluster-query problem pair, it specifically is used for: Randomly select an API cluster-query problem pair , where , for each Construct fine-tuning data based on the task decomposition tree. First, define a task collection that includes single-step queries, multi-step queries, sub-problem decomposition, and query condition reconstruction, and then generate a task decomposition tree based on the task collection.
[0105] In the optimal path generation module, evaluating all links of the task decomposition tree and selecting the optimal path as a training sample includes: Evaluating based on the expected consistency of all inference links in the decomposition tree;
[0106]
[0107] where represents the score of the link of the task decomposition tree, T represents all output sets in the task decomposition tree, represents the input query problem and the dialogue context, represents the given input when generating probability; represents the output and vector consistency metric between, where represents vector encoding of the output using the BERT encoder; finally select the inference link with the highest score as the optimal link, and the one with the lowest score as the worst link.
[0108] The training set construction module is specifically used for: Verify the API call chain: Verify whether the API call chain of the optimal link in the task decomposition tree can be successfully executed; Verify Sample Consistency: Verifying API Cluster-Query Problem Pairs Using a Verification Large Model -> Inference Link -> Consistency of API Call Instructions; If the consistency passes, retain it; otherwise, delete it from the training set; Verification Sample Consistency: Verifying API Cluster-Query Problem Pairs Using a Verification Large Model -> Inference Link -> Consistency of API Call Instructions; If the consistency fails, retain it; otherwise, randomly intercept a segment of the link as the link; Construct samples that meet the above three conditions as the training set.
[0109] When adjusting the output module to construct a loss function that maximizes the difference between the optimal inference path and the worst inference path based on the training set, and adjusting the parameters of the large language model based on the loss function to generate API call instructions that meet the power equipment data query requirements, it is specifically used for: Based on Construct a loss function
[0110] ; Construct the following optimization objective to enhance the data query inference link with the highest evaluation score and suppress the data query inference link with the lowest evaluation score ; Maximize the difference between the data query link with the highest evaluation score and the data query link with the lowest evaluation score:
[0111] The final loss function combines and and uses to regulate the weights:
[0112] Use the above loss function to adjust the model.
[0113] The division of modules in the embodiments of the present invention is illustrative, merely a logical function division. In actual implementation, there may be other division methods. Additionally, in each embodiment of the present invention, the functional modules can be integrated in one processor, or exist separately physically, or two or more modules can be integrated in one module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules.
[0114] In another embodiment of the present invention, a computer device is provided. The computer device includes a processor and a memory. The memory is used to store a computer program, and the computer program includes program instructions. The processor is used to execute the program instructions stored in the computer storage medium. The processor may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, and is suitable for implementing one or more instructions. Specifically, it is suitable for loading and executing one or more instructions in the computer storage medium to implement the corresponding method flow or corresponding function. The processor described in the embodiments of the present invention can be used for the operation of the data query method based on the task decomposition tree for power equipment.
[0115] In another embodiment of the present invention, a storage medium is also provided, specifically a computer-readable storage medium (Memory). The computer-readable storage medium is a memory device in a computer device and is used to store programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and, of course, the extended storage medium supported by the computer device. The computer-readable storage medium provides a storage space, and the operating system of the terminal is stored in this storage space. Moreover, one or more instructions suitable for being loaded and executed by the processor are stored in this storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the data query method based on the task decomposition tree for power equipment in the above embodiments.
[0116] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0117] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices produce means for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0118] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0119] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0120] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that: still can modify the specific implementation manners of the present invention or make equivalent replacements, and any modification or equivalent replacement that does not depart from the spirit and scope of the present invention shall be covered by the protection scope of the claims of the present invention.
Claims
1. A data query method based on a task decomposition tree for power equipment, characterized in that, including: Performing task clustering on the power equipment query application programming interface (API) to form API clustering clusters, and constructing API clustering cluster-query problem pairs based on the API clustering clusters; For each API clustering cluster-query problem pair, generating a task decomposition tree within a set task collection, evaluating all links of the task decomposition tree, and selecting the optimal path as a training sample; Performing API call chain execution verification on the generated training samples, verifying the logical consistency between the API clustering cluster-query problem pairs and the paths, and retaining samples that meet the execution success rate and consistency threshold to construct a training set; Based on the training set, constructing a loss function that maximizes the difference between the optimal inference path and the worst inference path, adjusting the parameters of the large language model based on the loss function, and generating API call instructions that meet the power equipment data query requirements after optimizing the model.
2. The data query method based on a task decomposition tree for power equipment according to claim 1, characterized in that The performing task clustering on the power equipment query application programming interface (API) to form API clustering clusters includes: Based on the working domain of the power grid equipment query API, the APIs within the same working domain form a subset that can be interoperably called. ; Within each working domain, the APIs are divided into subsets of different dimensions according to the tags of the APIs. , At the same time, combining the entities and relationships in the power knowledge graph, match the API documents, and extract tags to supplement the tag markings of the APIs; For each the k-th API in , encode its document into a vector , and use a clustering algorithm to cluster the vectors to obtain API task clusters.
3. The data query method based on a task decomposition tree for power equipment according to claim 1, wherein, The constructing API clustering cluster-query problem pairs based on the API clustering clusters includes: For each API clustering cluster, using an instruction generation large model to construct query problems, and generating several single-task query problems and several complex query problems for each API clustering cluster to obtain API clustering cluster-query problem pairs.
4. The data query method for power equipment based on a task decomposition tree according to claim 1, characterized in that, The generating a task decomposition tree within a set task collection for each API clustering cluster-query problem pair includes: Randomly select an API clustering cluster - query problem pair , where , is the query problem set; for each Construct fine-tuning data based on the task decomposition tree. First, define a task set that includes single-step queries, multi-step queries, sub-problem decomposition, and query condition reconstruction, and generate a task decomposition tree based on the task set.
5. The data query method based on a task decomposition tree for power equipment according to claim 1, wherein The evaluating all links of the task decomposition tree and selecting the optimal path as a training sample includes: Evaluating based on the expected consistency of all inference links in the decomposition tree; Among them represents the link of the task decomposition tree score, T represents all output sets in the task decomposition tree, represents the input query problem and conversation context, represents the given input when generating probability; Represents the output and The vector consistency metric between, where Represents vector encoding of the output using the BERT encoder; Select the inference link with the highest score as the optimal link, and the one with the lowest score as the worst link; the optimal link is the optimal path.
6. The data query method for power equipment based on a task decomposition tree according to claim 5, wherein The performing API call chain execution verification on the generated training samples, verifying the logical consistency between the API clustering cluster-query problem pairs and the paths, and retaining samples that meet the execution success rate and consistency threshold to construct a training set includes: Verify the API call chain: Verify whether the optimal link in the task decomposition tree of the API call chain can be successfully executed; Verification Sample consistency: Use the verification large model to verify the API clustering cluster - query question pair -> Inference link -> Consistency of API call instructions; if the consistency passes, keep it, otherwise delete it from the training set; verify Sample consistency: Using the validation model to verify API cluster-query pairs ->Inference link -> The consistency of the API call instructions; if the consistency does not pass, it is retained, otherwise it is randomly intercepted The fragment of the link is link; Constructing samples that meet the above three conditions as a training set.
7. The data query method based on a task decomposition tree for power equipment according to claim 6, wherein The constructing a loss function that maximizes the difference between the optimal inference path and the worst inference path based on the training set, optimizing the parameters of the large language model based on the loss function, and enabling the model to generate API call instructions that meet the user data query requirements includes: Based on Construct a loss function ; Construct the following optimization objective to enhance the data query inference link with the highest evaluation score and suppress the data query inference link with the lowest evaluation score ; maximize the difference between the data query link with the highest evaluation score and the data query link with the lowest evaluation score: The final loss function combines and , and uses to adjust the weights: Adjusting the model using the above loss function.
8. A data query system based on a task decomposition tree for power equipment, characterized in that including: A task division module for performing task clustering on the power equipment query application programming interface (API) to form API clustering clusters, and constructing API clustering cluster-query problem pairs based on the API clustering clusters; An optimal path generation module for generating a task decomposition tree within a set task collection for each API clustering cluster-query problem pair, evaluating all links of the task decomposition tree, and selecting the optimal path as a training sample; A training set construction module for performing API call chain execution verification on the generated training samples, verifying the logical consistency between the API clustering cluster-query problem pairs and the paths, and retaining samples that meet the execution success rate and consistency threshold to construct a training set; An adjustment output module for constructing a loss function that maximizes the difference between the optimal inference path and the worst inference path based on the training set, adjusting the parameters of the large language model based on the loss function, and generating API call instructions that meet the power equipment data query requirements after optimizing the model.
9. The data query system for power equipment based on a task decomposition tree according to claim 8, wherein When the task division module performs task clustering on the power equipment query application programming interface (API) to form API clustering clusters, it is specifically used for: Based on the working domain of the power grid equipment query API, the APIs in the same working domain form a subset that can be interoperably called. ; Within each working domain, the APIs are divided into subsets of different dimensions according to the labels of the APIs. , and at the same time, combining the entities and relationships in the power knowledge graph, the API documents are matched, and the extracted labels are supplemented to the label markings of the APIs; for each the k-th API in , its document is encoded into a vector , and then a clustering algorithm is used to cluster the vectors to obtain task clusters.
10. The data query system for power equipment based on a task decomposition tree according to claim 8, characterized in that When constructing the API clustering cluster-query problem pair based on the API clustering cluster, the task division module is further used for: For each API clustering cluster, use an instruction generation large model to construct query problems. Each API clustering cluster generates several single-task query problems and several complex query problems to obtain the API clustering cluster-query problem pair.
11. The data query system for power equipment based on a task decomposition tree according to claim 8, characterized in that When the optimal path generation module generates a task decomposition tree within the set task set for each API clustering cluster-query problem pair, it is specifically used for: Randomly select an API clustering cluster - query problem pair , where , for each Construct fine-tuning data based on the task decomposition tree. First, define a task set that includes single-step queries, multi-step queries, sub-problem decomposition, and query condition reconstruction, and then generate a task decomposition tree based on the task set.
12. The data query system for power equipment based on a task decomposition tree according to claim 8, wherein When the optimal path generation module evaluates all the links of the task decomposition tree and selects the optimal path as the training sample, it is specifically used for: Evaluate based on the expected consistency of all the inference links in the decomposition tree; Among them represents the link of the task decomposition tree score, T represents all output sets in the task decomposition tree, represents the input query problem and dialogue context, represents the given input when generating probability; Represents the output and The vector consistency metric between, where Indicates that the output is vector-encoded using a BERT encoder; finally, select The inference link with the highest score As the optimal link, the one with the lowest score As the worst link.
13. The data query system for power equipment based on a task decomposition tree according to claim 8, wherein The training set construction module is specifically used for: Verify the API call chain: Verify the optimal link in the task decomposition tree whether the API call chain can be successfully executed; Verification Sample consistency: Use the verification large model to verify the API clustering cluster-query problem pair -> Inference link -> Consistency of API call instructions; if the consistency passes, keep it, otherwise delete it from the training set; Verification Sample consistency: Use the verification large model to verify the API clustering cluster - query problem pair -> Inference link -> Consistency of API call instructions; If the consistency fails, retain it, otherwise randomly intercept The fragment of the link as Link Construct samples that meet the above three conditions as the training set.
14. The data query system for power equipment based on a task decomposition tree according to claim 8, wherein When the adjustment output module constructs a loss function that maximizes the difference between the optimal inference path and the worst inference path based on the training set, and adjusts the parameters of the large language model based on the loss function to generate API call instructions that meet the power equipment data query requirements, it is specifically used for: Based on Construct a loss function ; Construct the following optimization objective to enhance the data query reasoning link with the highest evaluation score , and suppress the data query reasoning link with the lowest evaluation score ; Maximize the difference between the data query link with the highest evaluation score and the data query link with the lowest evaluation score: The final loss function combines and , and uses to regulate the weights: Adjust the model using the above loss function.
15. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the data query method based on the task decomposition tree for power equipment according to any one of claims 1 to 7.
16. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the data query method based on the task decomposition tree for power equipment according to any one of claims 1 to 7.
Citation Information
Patent Citations
Training method of path reasoning model and path reasoning method
CN115438193A
API information retrieval method, electronic equipment, storage medium and program product
CN118820237A
Method and system for solving thinking chain reasoning mathematical problem based on feature classifier
CN119443267A
Method and system for indexing and serializing data
US20080215520A1
Natural-language database interface with automated keyword mapping and join-path inferences
US20210200761A1