Prompt optimization method and system for large language model of electric power system
By constructing a multi-dimensional problem description library and thought chain template, combining it with a large language model to generate an initial population, and utilizing mutation operations and tournament selection mechanisms, the applicability and dynamic updating issues of the large language model for power systems in the power grid field are solved, achieving more efficient and reliable power system fault diagnosis and scheduling optimization.
Patent Information
- Application Number
- CN202511643605.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-11
- Publication Date
- 2025-12-23
AI Technical Summary
Existing large language models for power systems suffer from poor applicability and high costs of repetitive development when adapting to the multi-level semantic structure, time-varying characteristics, and cross-business scenarios in the power grid field. They also lack dynamic updating and knowledge transfer mechanisms.
By constructing a multi-dimensional problem description library and thought chain template for the target power system, and generating an initial population by combining a large language model, the mutation strategy is dynamically adjusted using mutation operations and tournament selection mechanisms to generate variants adapted to specific scenarios. KL divergence analysis is used to regulate the evolutionary process, thereby achieving the prompt optimization of the large language model of the power system.
It improves the reliability and accuracy of the large language model of the power system, enhances its applicability in power grid fault diagnosis and dispatch optimization, and reduces the cost of repeated development.
Smart Images

Figure CN121188166A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of electrical automation, and particularly relates to a prompt optimization method and system of a large language model of a power system. BACKGROUND
[0002] With the development of economy and technology and the improvement of people's living standards, electric energy has become an essential secondary energy in people's production and life, bringing endless convenience to people's production and life. Therefore, ensuring the stable and reliable supply of electric energy has become one of the most important tasks of the power system.
[0003] In recent years, large language models based on artificial intelligence have shown good application potential in text analysis and dispatch log processing scenarios in the power system. At present, the large language model of the power system is generally prompted by artificially designed thinking chain templates, and then applied to tasks such as power grid fault report generation and dispatch instruction analysis. However, the existing scheme has the following defects: first, the multi-level semantic structure specific to the power grid field (such as device topology relationship and dispatch procedure terminology) leads to poor adaptability of general prompt templates; second, the time-varying characteristics of the power system operating state (such as load fluctuation and fault propagation mode) require the prompt strategy to have dynamic evolution capability, but the existing scheme cannot realize online updating of the model; finally, there are many cross-business scenarios (fault diagnosis and load prediction) in the power system, and the existing scheme lacks a corresponding knowledge transfer mechanism; this makes the applicability of the existing scheme narrow and the cost of repeated development extremely high. SUMMARY
[0004] One of the purposes of the present application is to provide a prompt optimization method for a large language model of a power system, which has high reliability, good accuracy and good applicability.
[0005] The second purpose of the present application is to provide a system for implementing the prompt optimization method for the large language model of the power system.
[0006] The prompt optimization method for the large language model of the power system provided by the present application comprises the following steps: S1. obtaining data information of a target power system and corresponding data information of a large language model; S2. constructing an initial prompt population for a fault diagnosis task of the target power system according to the data information obtained in step S1, and generating diversified strategies in combination with field problem descriptions and general thinking modes; S3. in combination with the data information obtained in step S2, performing mutation operation on task prompts by the large language model to generate variants adapted to specific scenarios, in view of the dispatch optimization requirements of the target power system; S4. screening a power grid problem solving scheme by adopting a tournament selection mechanism based on performance evaluation prompts. S5. Adjust the strategy for the next round of evolution based on population KL divergence analysis; S6. Finally, achieve the suggestion optimization of the large language model of the target power system.
[0007] Step S2 includes the following steps: Based on the data obtained in step S1, and combined with the topology of the target power system, a multi-dimensional problem description library for the target power system is constructed. Based on the target power system's dispatch manual, emergency plan, and decision-making process, a general thinking model is abstracted and transformed into a thinking chain template. Based on the obtained multi-dimensional problem description library and thought chain template, an initial population including several prompting strategies is generated through a large language model; Embedding representations are extracted from the obtained initial population, and semantic overlap is calculated.
[0008] Step S2 specifically includes the following steps: The historical fault logs, equipment operating parameters, and real-time status parameters of the target power system are analyzed to extract several key fault features. A multi-dimensional problem description library for the target power system is constructed based on its topology. This multi-dimensional problem description library is built using a knowledge graph framework. The knowledge graph framework is modeled using a graph neural network, where nodes represent power grid equipment entities, and edges represent fault propagation paths or logical relationships. The dispatching manual, emergency plan, and decision-making process of the target power system are analyzed to abstract a general thinking model, which is then transformed into a thinking chain template. The general thinking model includes a phased diagnostic thinking model, a causal reasoning diagnostic thinking model, and a hypothesis verification diagnostic thinking model. The fault entities in the constructed multi-dimensional problem description library, the reasoning steps in the thought chain template, and the scheduling terminology information of the target power system are input into the large language model. Temperature sampling and kernel sampling schemes are used to balance the generation results, generating an initial population that includes several hint strategies. During temperature sampling, the following formula is used to calculate the temperature parameters. Control: In the formula For the first i Each token The final generation probability, after temperature adjustment and normalization, is the model's selected probability. i Each word or phrase is used as a probability value for the next output; For large language models to the first iThe raw logit output of each candidate policy (or token) is the model's raw, unprocessed prediction score before Softmax normalization; This represents the total number of candidate strategies (or tokens), which typically corresponds to the size of the complete vocabulary of a large language model. when Increase the generation probability of strategies with a probability lower than the set value; when The probability of generating a strategy with a probability higher than the set value is increased. During nuclear sampling, the sampling space is dynamically adjusted using the following formula: In the formula The cumulative probability threshold is a pre-defined hyperparameter with a value between 0 and 1; k is the number of tokens in the sampled candidate set, representing the cumulative probability of all possible tokens, sorted in descending order of probability, that is exactly greater than or equal to the threshold. Minimum number of tokens required; This is the preset cumulative probability, and this value is usually chosen to be a relatively high number (e.g., 0.9) to filter out the token candidate set with the highest probability. This represents the operation of determining the size of the candidate set, which aims to find tokens from a vocabulary (token list) sorted in descending probability that satisfy both their cumulative probability and the first occurrence of a preset value. The smallest set of tokens, the number of tokens in this set is . k Subsequent sampling will only be from this k In the process of using individual tokens; The initial cues in the generated initial population are extracted using embedding representations, and the semantic overlap between the various embedding representations is calculated using the following formula: In the formula The semantic overlap between embedding representation A and embedding representation B; For Hadamah accumulation; For device-associated weight vectors; Here is the similarity calculation function, and , The L2 norm (or Euclidean norm) of a vector measures the "length" or "size" of a vector in a multidimensional space. It is the square root of the sum of the squares of the vector's elements. In similarity calculations, it is often used to normalize vectors to eliminate the influence of length differences on directional judgment.
[0009] Step S3 includes the following steps: Based on the scheduling scenario characteristics of the target power system, semantic reconstruction and mutation operations are performed on the initial prompts in the initial population obtained in step S2. Based on the obtained data, a population optimization suggestion is generated using the estimated distribution mutation method. Based on the obtained data, the mutation strategy of the target power system is optimized based on the reflexive hypermutation mechanism. By adopting the Lamarck mutation strategy and based on successful power grid dispatch cases, we optimize the prompts to generate variants that are adapted to specific scenarios.
[0010] Step S3 specifically includes the following steps: Semantic reconstruction mutation operation: First, a high-performance parent task cue is selected from the current population. Then, a specific mutation instruction is randomly selected from the mutation instruction library generated in the "mutation strategy optimization" step (e.g., "restate this cue to focus more on the N-1 safety criterion" or "add a step to the diagnostic process to verify whether the protection device is operating correctly"). The parent cue and the extracted mutation instruction are combined and input into the large language model, which guides the large language model to reorganize, simplify, or expand the parent cue to generate a new cue variant that is more semantically and logically consistent with the specific needs of the power system. Finally, to ensure that the newly generated cue variant is closely integrated with the physical reality of the power grid, the system further instructs the large language model to embed key constraint parameters (such as capacity limits of specific lines, voltage thresholds of key nodes, etc.) into the new variant based on the topological characteristics of the target power grid, thereby completing the final mutation operation. Generate population optimization tips: By calculating the semantic overlap, a set of cue variants that can represent the diversity of the target power system scheduling domain is obtained. This process is called the distribution mutation estimation method. Specifically, the set of cue variants that are selected, semantically different but have superior performance, is arranged in a logical order (e.g., according to the fault handling process or optimization target priority) and then used as context input into the large language model. The large language model is set to summarize the common elements and core differences between different scenarios, thereby generating a group optimization cue that integrates the overall advantages of the population and has a stronger generalization ability. Mutation strategy optimization: The process of combining typical mutation cases defined in the dispatch domain of the target power system with a hypermutation prompt template is known as the reflexive hypermutation mechanism. The hypermutation prompt template is a pre-defined meta-level instruction used to guide the optimization of the large language model or the generation of other mutation instructions, such as "Please analyze the following successful prompt mutation cases and summarize a more efficient mutation strategy." After combining this template with typical mutation cases, the large language model analyzes the characteristic patterns of historical successful mutation modes, thereby iterating and optimizing the mutation strategy itself. Finally, the large language model yields a more efficient mutation instruction library containing various professional features specific to the power system. Generate variants adapted to specific scenarios: This process employs a Lamarck mutation strategy, specifically: selecting effective reasoning paths from successful typical power grid fault handling cases set in the target power system, combining them with the obtained group optimization hints, and then inputting them into the large language model; in this process, the "group optimization hints" serve as a high-quality, well-structured baseline template; it provides an excellent starting point for the large language model, rather than allowing the model to be created from scratch. Subsequently, the large language model is set up based on successful reasoning paths, and the potential cue elements that can generate such paths are derived in reverse and integrated and optimized into the baseline template. Finally, by comparing the actual scheduling logs with the reasoning paths generated by the large language model, the newly generated cue is optimized again, thereby generating a highly adaptive variant that retains the excellent structure of collective intelligence (derived from collectively optimized cue) and absorbs the core logic of specific successful cases (derived from effective reasoning paths).
[0011] Step S4 includes the following steps: For each fault diagnosis scheme generated for each prompt variant obtained in step S3, a multidimensional adaptability score is calculated for each fault diagnosis scheme based on matching degree and temporal consistency. In each round of evolution, two cue variants are randomly selected to form an adversarial group, and a tournament selection mechanism is used to select the cue variants. The optimal cue variants in each round of evolution are dynamically saved, and cluster analysis is performed on the cue variants within the population to obtain a solution to the power grid problem.
[0012] Step S4 specifically includes the following steps: Calculate the multidimensional fitness score: For each fault diagnosis scheme generated from the prompt variant obtained in step S3, the corresponding multidimensional adaptability score is calculated using the following formula. : In the formula This is the first weight value set. The degree of matching between expert annotation results and the output of the large language model; This is the set second weight value; The temporal consistency score measures the degree of consistency between the fault diagnosis or scheduling operation sequence generated by the large language model and the actual power system event log in terms of time sequence. The higher the score, the more the causal chain of the model's inference conforms to the physical laws of power grid fault evolution. Suggested variant filtering: In each round of evolution, two cue variants are randomly selected to form an adversarial group, and the cue variants are selected based on a tournament selection mechanism; the selection probability of the cue variants is calculated using the following formula: In the formula The probability of variant i1 winning in the adversarial group; To provide a multidimensional fitness score for variant i1; A multidimensional fitness score for another cue variant j1 in the adversarial group; The set selection pressure coefficient; Based on the selection probabilities of the obtained cue variants, the cue variants are filtered. The specific process is as follows: Generate a random number between 0 and 1. ,like If the selection is successful, then the cue variant i1 is chosen as the winner to enter the next generation of the population; otherwise, the cue variant j1 is chosen as the winner.
[0013] Step S5 specifically includes the following steps: Quantifying population generational distribution shift: After obtaining the new generation of cue populations in step S4, to monitor the stability and diversity of the evolutionary process, the Kullback-Leibler Divergence (KL Divergence) is used to quantify the distribution differences between the old and new cue populations. The calculation formula is as follows: In the formula, is the KL divergence value, used to measure the degree of change in the cue distribution of the new generation relative to the old generation; X is the set of all cue strategies in the population; x For a specific prompting strategy in set X; For prompting strategy x The probability (or normalized frequency) of occurrence in the new generation population; for cueing strategies. x The probability of it appearing in the older generation population; Adaptive adjustment of the intensity of the next round of evolution: Based on the calculated KL divergence value, the intensity of step S3 (mutation operation) in the next iteration is adaptively adjusted, specifically including the following steps: Setting KL divergence control thresholds: Pre-determine a reasonable KL divergence range, including a lower limit threshold to prevent evolutionary stagnation. (e.g., 0.01) and an upper limit threshold to prevent population mutation. (e.g., 0.5); Dynamically adjust mutation strategy: If calculated Value lower than If the system determines that the current evolutionary process is changing too little and may be trapped in a local optimum, it will automatically increase the mutation intensity in the next cycle, for example, by increasing the temperature sampling parameter value in step S2, or by increasing the application probability of the more exploratory estimation distribution mutation operator in step S3. If calculated Value higher than If the current population change is too drastic and may have damaged the existing excellent cue structure, the system will automatically reduce the mutation intensity in the next cycle, for example, by reducing the temperature sampling parameter value or increasing the application probability of the more conservative semantic reconstruction mutation operator in step S3. This specialized control step ensures the dynamic balance of the entire iterative optimization process, effectively avoiding premature convergence or divergence in optimization direction caused by inappropriate mutation intensity, and significantly improving the robustness and efficiency of the suggested optimization.
[0014] This invention also provides a system for implementing the suggestion optimization method of the large language model of the power system, including a data acquisition module, a strategy generation module, a variant generation module, a scheme selection module, a loop optimization module, and a suggestion optimization module; the data acquisition module, strategy generation module, variant generation module, scheme selection module, loop optimization module, and suggestion optimization module are connected in series; the data acquisition module is used to acquire data information of the target power system and the corresponding large language model data information, and upload the data information to the strategy generation module; the strategy generation module is used to construct an initial suggestion population for the fault diagnosis task of the target power system based on the received data information and the acquired data information, and generate diversified strategies by combining domain problem description and general thinking patterns, and upload the data information to the variant generation module. The module comprises four sub-modules: a variant generation module, a variant selection module, and a suggestion optimization module. The variant generation module generates variants adapted to specific scenarios based on received data and the scheduling optimization requirements of the target power system, using a large language model to mutate task prompts. The scheme selection module uses a tournament selection mechanism to select solutions to power grid problems based on performance evaluation prompts and the adaptability of the variants, and uploads the data to the loop optimization module. The loop optimization module adjusts the next round of evolutionary strategies based on population KL divergence analysis, and uploads the data to the suggestion optimization module. The suggestion optimization module optimizes the large language model of the target power system based on received data.
[0015] The method and system for prompting optimization of the large language model of power systems provided by this invention, through a series of schemes such as generating diversified strategies, generating variants adapted to specific scenarios, screening and iterative optimization of power grid problem solutions, not only realizes prompting optimization of the large language model of power systems, but also has higher reliability, better accuracy, and better applicability of the solution. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the method flow of the present invention.
[0017] Figure 2 This is a schematic diagram of the functional modules of the system of the present invention. Detailed Implementation
[0018] like Figure 1 The diagram shown is a flowchart of the method of the present invention: The suggestion optimization method for a large language model of a power system disclosed in this invention includes the following steps: S1. Obtain data information of the target power system and the corresponding large language model data information; S2. Based on the data obtained in step S1, construct an initial suggestion population for the fault diagnosis task of the target power system, and generate diverse strategies by combining the domain problem description and general thinking patterns; including the following steps: This step is used to generate initial hints and mutated hints for mutating the initial hints; Based on the data obtained in step S1, and combined with the topology of the target power system, a multi-dimensional problem description library for the target power system is constructed. Based on the target power system's dispatch manual, emergency plan, and decision-making process, a general thinking model is abstracted and transformed into a thinking chain template. Based on the obtained multi-dimensional problem description library and thought chain template, an initial population including several prompting strategies is generated through a large language model; Embedding representations are extracted from the obtained initial population, and semantic overlap is calculated. The specific implementation includes the following steps: The historical fault logs, equipment operating parameters, and real-time status parameters of the target power system are analyzed to extract several key fault features. A multi-dimensional problem description library for the target power system is constructed based on its topology. This multi-dimensional problem description library is built using a knowledge graph framework. The knowledge graph framework is modeled using a graph neural network, where nodes represent power grid equipment entities, and edges represent fault propagation paths or logical relationships. The dispatching manual, emergency plan, and decision-making process of the target power system are analyzed to abstract a general thinking model, which is then transformed into a thinking chain template. The general thinking model includes a phased diagnostic thinking model, a causal reasoning diagnostic thinking model, and a hypothesis verification diagnostic thinking model. The fault entities in the constructed multi-dimensional problem description library, the reasoning steps in the thought chain template, and the scheduling terminology information of the target power system are input into the large language model. Temperature sampling and kernel sampling schemes are used to balance the generation results, generating an initial population that includes several hint strategies. During temperature sampling, the following formula is used to calculate the temperature parameters. Control: In the formula For the first i Each token The final generation probability, after temperature adjustment and normalization, is the model's selected probability. i Each word or phrase is used as a probability value for the next output; For large language models to the first i The raw logit output of each candidate policy (or token) is the model's raw, unprocessed prediction score before Softmax normalization; This represents the total number of candidate strategies (or tokens), which typically corresponds to the size of the complete vocabulary of a large language model. when Increase the generation probability of strategies with a probability lower than the set value; when The probability of generating a strategy with a probability higher than the set value is increased. During nuclear sampling, the sampling space is dynamically adjusted using the following formula: In the formula The cumulative probability threshold is a pre-defined hyperparameter with a value between 0 and 1; k is the number of tokens in the sampled candidate set, representing the cumulative probability of all possible tokens, sorted in descending order of probability, that is exactly greater than or equal to the threshold. Minimum number of tokens required; This is the preset cumulative probability, and this value is usually chosen to be a relatively high number (e.g., 0.9) to filter out the token candidate set with the highest probability. This represents the operation of determining the size of the candidate set, which aims to find tokens from a vocabulary (token list) sorted in descending probability that satisfy both their cumulative probability and the first occurrence of a preset value. The smallest set of tokens, the number of tokens in this set is . k Subsequent sampling will only be from this k In the process of using individual tokens; The initial cues in the generated initial population are extracted using embedding representations, and the semantic overlap between the various embedding representations is calculated using the following formula: In the formula The semantic overlap between embedding representation A and embedding representation B; For Hadamah accumulation; For device-associated weight vectors; Here is the similarity calculation function, and , The L2 norm (or Euclidean norm) of a vector is used to measure the "length" or "size" of a vector in a multidimensional space. It is the square root of the sum of the squares of the vector's elements. In similarity calculations, it is often used to normalize vectors to eliminate the influence of length differences on directional judgment. S3. Based on the scheduling optimization requirements of the target power system and the data obtained in step S2, a large language model is used to mutate the task prompts, generating variants adapted to specific scenarios; this includes the following steps: This step performs a series of mutation operations on the initial prompt (population). Specifically, you can randomly select a mutation operation, including semantic reconstruction mutation operation, generating population-optimized prompts, mutation strategy optimization, and generating variants adapted to specific scenarios. These are all ways to mutate this prompt population to obtain a new prompt population. Based on the scheduling scenario characteristics of the target power system, semantic reconstruction and mutation operations are performed on the initial prompts in the initial population obtained in step S2. Based on the obtained data, a population optimization suggestion is generated using the estimated distribution mutation method. Based on the obtained data, the mutation strategy of the target power system is optimized based on the reflexive hypermutation mechanism. Using the Lamarck mutation strategy and based on successful power grid dispatching cases, we perform optimization with hints to generate variants adapted to specific scenarios; The specific implementation includes the following steps: Semantic reconstruction mutation operation: First, a high-performance parent task cue is selected from the current population. Then, a specific mutation instruction is randomly selected from the mutation instruction library generated in the "mutation strategy optimization" step (e.g., "restate this cue to focus more on the N-1 safety criterion" or "add a step to the diagnostic process to verify whether the protection device is operating correctly"). The parent cue and the extracted mutation instruction are combined and input into the large language model, which guides the large language model to reorganize, simplify, or expand the parent cue to generate a new cue variant that is more semantically and logically consistent with the specific needs of the power system. Finally, to ensure that the newly generated cue variant is closely integrated with the physical reality of the power grid, the system further instructs the large language model to embed key constraint parameters (such as capacity limits of specific lines, voltage thresholds of key nodes, etc.) into the new variant based on the topological characteristics of the target power grid, thereby completing the final mutation operation. Generate population optimization tips: By calculating the semantic overlap, a set of cue variants that can represent the diversity of the target power system scheduling domain is obtained. This process is called the distribution mutation estimation method. Specifically, the set of cue variants that are selected, semantically different but have superior performance, is arranged in a logical order (e.g., according to the fault handling process or optimization target priority) and then used as context input into the large language model. The large language model is set to summarize the common elements and core differences between different scenarios, thereby generating a group optimization cue that integrates the overall advantages of the population and has a stronger generalization ability. The core idea of the Estimation of Distribution Mutation method is to enable a large language model to learn the "success patterns" of all excellent prompts in the entire population, rather than simply imitating or fine-tuning a single parent prompt. In practice, the best-performing prompts are first selected as "top students." However, to avoid these "top students" having similar approaches (e.g., the same suggestion with only different wording), a set of high-performing prompts that also encompasses various different solution approaches (i.e., semantically diverse) is selected using the semantic overlap calculated by S1. This set of high-performing prompts is then presented to the large language model, allowing it to "inductively" and "extract" the common patterns behind these successful prompts, a process known as "distribution estimation." Finally, based on the learned patterns, the model generates a completely new, theoretically optimized prompt that combines the strengths of all prompts. This generation process is equivalent to a "mutation" sampling from the learned "success pattern distribution," thereby creating a new prompt that may surpass any single member of the population. Mutation strategy optimization: The process of combining typical mutation cases defined in the dispatch domain of the target power system with a hypermutation prompt template is known as the reflexive hypermutation mechanism. The hypermutation prompt template is a pre-defined meta-level instruction used to guide the optimization of the large language model or the generation of other mutation instructions, such as "Please analyze the following successful prompt mutation cases and summarize a more efficient mutation strategy." After combining this template with typical mutation cases, the large language model analyzes the characteristic patterns of historical successful mutation modes, thereby iterating and optimizing the mutation strategy itself. Finally, the large language model yields a more efficient mutation instruction library containing various professional features specific to the power system. Generate variants adapted to specific scenarios: This process employs a Lamarck mutation strategy, specifically: selecting effective reasoning paths from successful typical power grid fault handling cases set in the target power system, combining them with the obtained group optimization hints, and then inputting them into the large language model; in this process, the "group optimization hints" serve as a high-quality, well-structured baseline template; it provides an excellent starting point for the large language model, rather than allowing the model to be created from scratch. Subsequently, the large language model is set up based on successful reasoning paths, and the potential cue elements that can generate such paths are derived in reverse and integrated and optimized into the baseline template. Finally, by comparing the actual scheduling logs with the reasoning paths generated by the large language model, the newly generated cue is optimized again, thereby generating a highly adaptive variant that retains the excellent structure of collective intelligence (derived from collectively optimized cue) and absorbs the core logic of specific successful cases (derived from effective reasoning paths). S4. Based on performance evaluation suggestions, a tournament selection mechanism is used to screen for solutions to power grid problems; this includes the following steps: This step is used to evaluate the suggested population and select for the tournament; For each fault diagnosis scheme generated for each prompt variant obtained in step S3, a multidimensional adaptability score is calculated for each fault diagnosis scheme based on matching degree and temporal consistency. In each round of evolution, two cue variants are randomly selected to form an adversarial group, and a tournament selection mechanism is used to select the cue variants. The optimal cue variants in each round of evolution are dynamically saved, and cluster analysis is performed on the cue variants within the population to obtain a solution to the power grid problem. The specific implementation includes the following steps: Calculate the multidimensional fitness score: For each fault diagnosis scheme generated from the prompt variant obtained in step S3, the corresponding multidimensional adaptability score is calculated using the following formula. : In the formula This is the first weight value set. The degree of matching between expert annotation results and the output of the large language model; This is the set second weight value; The temporal consistency score measures the degree of consistency between the fault diagnosis or scheduling operation sequence generated by the large language model and the actual power system event log in terms of time sequence. The higher the score, the more the causal chain of the model's inference conforms to the physical laws of power grid fault evolution. Suggested variant filtering: In each round of evolution, two cue variants are randomly selected to form an adversarial group, and the cue variants are selected based on a tournament selection mechanism; the selection probability of the cue variants is calculated using the following formula: In the formula The probability of variant i1 winning in the adversarial group; To provide a multidimensional fitness score for variant i1; A multidimensional fitness score for another cue variant j1 in the adversarial group; The set selection pressure coefficient; Based on the selection probabilities of the obtained cue variants, the cue variants are filtered. The specific process is as follows: Generate a random number between 0 and 1. ,like If the selection is successful, then the cue variant i1 is chosen as the winner to enter the next generation of the population; otherwise, the cue variant j1 is chosen as the winner. S5. Adjust the strategy for the next round of evolution based on population KL divergence analysis; specifically including the following steps: Quantifying population generational distribution shift: After obtaining the new generation of cue populations in step S4, to monitor the stability and diversity of the evolutionary process, the Kullback-Leibler Divergence (KL Divergence) is used to quantify the distribution differences between the old and new cue populations. The calculation formula is as follows: In the formula, is the KL divergence value, used to measure the degree of change in the cue distribution of the new generation relative to the old generation; X is the set of all cue strategies in the population; x For a specific prompting strategy in set X; For prompting strategy x The probability of occurrence (or normalized frequency) in the new generation population. For prompting strategy x The probability of it appearing in the older generation population; Adaptive adjustment of the intensity of the next round of evolution: Based on the calculated KL divergence value, the intensity of step S3 (mutation operation) in the next iteration is adaptively adjusted, specifically including the following steps: Setting KL divergence control thresholds: Pre-determine a reasonable KL divergence range, including a lower limit threshold to prevent evolutionary stagnation. (e.g., 0.01) and an upper limit threshold to prevent population mutation. (e.g., 0.5); Dynamically adjust mutation strategy: If calculated Value lower than If the system determines that the current evolutionary process is changing too little and may be trapped in a local optimum, it will automatically increase the mutation intensity in the next cycle, for example, by increasing the temperature sampling parameter value in step S2, or by increasing the application probability of the more exploratory estimation distribution mutation operator in step S3. If calculated Value higher than If the current population change is too drastic and may have damaged the existing excellent cue structure, the system will automatically reduce the mutation intensity in the next cycle, for example, by reducing the temperature sampling parameter value or increasing the application probability of the more conservative semantic reconstruction mutation operator in step S3. This specialized control step ensures the dynamic balance of the entire iterative optimization process, effectively avoiding premature convergence or divergence of optimization direction due to inappropriate mutation intensity, and significantly improving the robustness and efficiency of the suggested optimization. KL divergence guides the next evolution. If the number of iterations is reached, the solution with the highest score is directly selected as the final solution. S6. Finally, achieve the suggestion optimization of the large language model of the target power system.
[0019] The method of the present invention will be further described below with reference to an embodiment: 1. Data Acquisition The following data were obtained from the target provincial power grid: Historical dataset: Contains 1,000 real or highly simulated cases of main transformer overload faults, covering real-time data before the fault, equipment information, relevant historical scheduling logs, and the final fault analysis report.
[0020] Large Language Model: A large language model with 7B parameters, pre-trained on public corpora and internal procedure documents in the power industry, is used as the base model.
[0021] 2. Initial prompts for population building A multi-dimensional problem description library was constructed: Based on the acquired data, a knowledge graph of power grid equipment was built using graph neural networks. For example, the node "500kV A Substation No. 1 Main Transformer" is connected to nodes such as "220kV B Line" and "110kV C Bus" through edges, representing their topological and electrical relationships.
[0022] Generate a thought chain template: From the "Power Grid Dispatch Regulations" and "Accident Handling Plan", abstract general thought models such as "IF [Main transformer temperature > threshold A AND load rate > 95%] THEN [Initiate overload diagnosis process] -> [Analyze load characteristics] -> [Find transferable loads] -> [Generate pre-dispatch plan]", and convert them into thought chain templates.
[0023] Generate the initial population: Input entities from the knowledge graph (such as "A-station No. 1 main transformer"), thought chain templates, and power terminology into the large language model. Set temperature parameters. A population containing 50 different initial cue strategies was generated using kernel sampling (Top-p=0.9).
[0024] Example initial prompt: "Please analyze the following data to determine if the main transformer is overloaded, and list the handling steps." Calculate semantic overlap: The embedded representations of the 50 generated initial prompts are extracted, and the semantic overlap between any two prompts is calculated. This overlap value will be used in step S3 to filter the diverse set of prompts.
[0025] 3. Mutation operation During the evolutionary iteration, various mutation operations were applied to the parent hints: Semantic reconstruction variation example: The parent device prompts: "Diagnose main transformer overload and provide scheduling suggestions." Mutation instruction extracted from the mutation instruction library: "Restate this prompt to focus more on the N-1 safety guidelines." A new variant of the prompt generated after the large language model executes the instruction: "Diagnose main transformer overload and provide scheduling recommendations. All recommendations must pass an N-1 safety check to ensure that the grid can still withstand single-point failures after the operation." Example of mutation strategy optimization (reflexive hypermutation): The system identified a successful mutation case: after changing the prompt "Analyze fault alarms" to "Analyze fault alarms sequentially from high to low voltage level", its adaptability score improved significantly by 15%.
[0026] Combine this successful case with the super-mutation prompt template "Please analyze the following successful prompt mutation cases and summarize a more efficient and general mutation strategy", and input it into the large language model.
[0027] After analyzing the large language model, a new and better mutation instruction was summarized and generated and stored in the instruction library: "Add constraint guidance words such as 'follow topology level' or 'by voltage level' to any diagnostic process class prompt." This process realizes the iterative optimization of the mutation method itself.
[0028] Example of generating a group optimization suggestion: In the 5th generation evolution, the system first selects the top 20% of suggestions based on their adaptability scores. Then, using the semantic overlap calculated in S2, it filters out a set of semantically distinct suggestions (e.g., one suggestion focuses on "voltage analysis," and another on "power flow calculation"). This set is input into the large language model, which summarizes and generates a new group optimization suggestion: "Integrate voltage and power flow data to assess the main transformer's health status and provide operational recommendations." Lamarck mutation example: Analyzing a successful historical case, the key reasoning path is: "After discovering the overload, the dispatcher prioritized transferring the secondary load to the nearby D substation instead of directly cutting off the power supply, thus ensuring the power supply to important users." The large language model was reverse-engineered to incorporate this successful experience of "priority transfer" into a group optimization prompt, generating a new and more specific prompt: "When the main transformer is overloaded, load transfer operations should be performed first, and a list of secondary loads that can be safely transferred to a nearby substation should be evaluated and compiled before considering other control measures." 4. Evaluation and Screening Calculate the fitness score: Evaluate each cue in the population using 200 reserved test cases. The weights of the multidimensional fitness score f are set as follows: , ; Execute tournament selection: For example, if cue A has an fitness score of 0.85 and cue B has 0.72, according to the selection probability formula, cue A has a higher probability of being selected as the parent and entering the next round of evolution.
[0029] 5. Adaptive regulation based on KL divergence By the 10th generation, the system detected a KL divergence of 0.008 between the old and new generations, below the lower threshold of 0.01. This indicates insufficient evolutionary diversity and a risk of getting trapped in local optima. The system automatically implemented adjustments, modifying the temperature sampling parameters for the next iteration. The probability was increased from 0.7 to 0.9, and the application probability of the "estimated distribution mutation" operator was increased to encourage the population to produce more diverse variants.
[0030] 6. Final Result After 50 generations of evolution, the optimization process terminates, and the suggestion with the highest fitness score in the population is selected as the final solution. An example of a high-scoring suggestion strategy is: "Please comprehensively analyze the following SCADA real-time data and equipment ledger to accurately diagnose the cause of the main transformer overload. Following the accident handling principle of 'first transfer, then reduce voltage, then disconnect,' generate a dispatch instruction ticket text that conforms to the 'Dispatch Instruction Issuance Specification.' The instruction must include specific operating equipment, operating sequence, and safety precautions, and simultaneously perform N-1 safety checks to ensure the system remains stable after the operation." The final optimization prompt example is: "Please comprehensively analyze the following SCADA real-time data and equipment information to accurately diagnose the cause of the main transformer overload. Following the accident handling principle of 'transfer first, then reduce voltage, and then disconnect,' generate a dispatch instruction ticket text that conforms to the 'Dispatch Instruction Issuance Specification.' The instruction must include specific operating equipment, operating sequence, and safety precautions, and simultaneously perform N-1 safety checks to ensure that the system remains stable after the operation." 7. Comparison Method: To verify the superiority of the method of the present invention, two existing mainstream methods were selected and compared on the same historical dataset of 1000 cases.
[0031] Comparison Method 1 (Human Expert Tips): A set of fixed prompt templates jointly designed by two senior power dispatch experts based on their experience.
[0032] Comparison Method 2 (General CoT Hints): Uses the general "Let's think step by step" mind chain hints, without domain-specific adaptation.
[0033] Performance data comparison: Table 1 shows the comparison results of the method of the present invention with two comparative methods in terms of key performance indicators after evolution stabilization.
[0034] As shown in Table 1, the method of this invention significantly outperforms existing methods in all core indicators. It achieves the highest adaptability score, indicating the best overall quality of the generated solution; both diagnostic accuracy and instruction compliance rate reach the highest levels, demonstrating high reliability and precision; simultaneously, it has the shortest average response time, proving its high efficiency.
[0035] like Figure 2The diagram shows the functional modules of the system of this invention: The system disclosed in this invention for implementing the suggestion optimization method of the large language model of the power system includes a data acquisition module, a strategy generation module, a variant generation module, a scheme selection module, a loop optimization module, and a suggestion optimization module; the data acquisition module, strategy generation module, variant generation module, scheme selection module, loop optimization module, and suggestion optimization module are connected in series; the data acquisition module is used to acquire the data information of the target power system and the corresponding large language model data information, and upload the data information to the strategy generation module; the strategy generation module is used to construct an initial suggestion population for the fault diagnosis task of the target power system based on the received data information and the acquired data information, and generate diversified strategies by combining the domain problem description and general thinking patterns, and then upload the data... The system comprises the following modules: an information upload variant generation module, a scheme selection module, and a prompt optimization module. The information upload module generates variants adapted to specific scenarios based on received data, the scheduling optimization requirements of the target power system, and a large language model. The scheme selection module uses a tournament selection mechanism to select solutions to power grid problems based on performance evaluation prompts and the adaptability of the variants, and uploads the data to the loop optimization module. The loop optimization module adjusts the next round of evolutionary strategies based on received data and population KL divergence analysis, and uploads the data to the prompt optimization module. The prompt optimization module optimizes the prompts of the target power system's large language model based on received data.
Claims
1. A suggestion optimization method for a large language model of a power system, comprising the following steps: S1. Obtain data information of the target power system and the corresponding large language model data information; S2. Based on the data obtained in step S1, construct an initial prompt population for the fault diagnosis task of the target power system, and generate diverse strategies by combining domain problem description and general thinking patterns; S3. Based on the scheduling optimization requirements of the target power system, and combined with the data information obtained in step S2, the task prompts are mutated using a large language model to generate variants adapted to specific scenarios. S4. Based on performance evaluation suggestions, a tournament selection mechanism is used to screen for solutions to power grid problems; S5. Adjust the strategy for the next round of evolution based on population KL divergence analysis; S6. Finally, achieve the suggestion optimization of the large language model of the target power system.
2. The suggestion optimization method for a large language model of a power system according to claim 1, characterized in that... Step S2 includes the following steps: Based on the data obtained in step S1, and combined with the topology of the target power system, a multi-dimensional problem description library for the target power system is constructed. Based on the target power system's dispatch manual, emergency plan, and decision-making process, a general thinking model is abstracted and transformed into a thinking chain template. Based on the obtained multi-dimensional problem description library and thought chain template, an initial population including several prompting strategies is generated through a large language model; Embedding representations are extracted from the obtained initial population, and semantic overlap is calculated.
3. The suggestion optimization method for a large language model of a power system according to claim 2, characterized in that... Step S2 specifically includes the following steps: The historical fault logs, equipment operating parameters, and real-time status parameters of the target power system are analyzed to extract several key fault features. A multi-dimensional problem description library for the target power system is constructed based on its topology. This multi-dimensional problem description library is built using a knowledge graph framework. The knowledge graph framework is modeled using a graph neural network, where nodes represent power grid equipment entities, and edges represent fault propagation paths or logical relationships. The dispatching manual, emergency plan, and decision-making process of the target power system are analyzed to abstract a general thinking model, which is then transformed into a thinking chain template. The general thinking model includes a phased diagnostic thinking model, a causal reasoning diagnostic thinking model, and a hypothesis verification diagnostic thinking model. The fault entities in the constructed multi-dimensional problem description library, the reasoning steps in the thought chain template, and the scheduling terminology information of the target power system are input into the large language model. Temperature sampling and kernel sampling schemes are used to balance the generation results, generating an initial population that includes several hint strategies. During temperature sampling, the following formula is used to calculate the temperature parameters. Control: In the formula For the i-th word element The final generation probability; This represents the original logical value output by the large language model for the i-th candidate strategy or token. The total number of candidate strategies or tokens; when Increase the generation probability of strategies with a probability lower than the set value; when The probability of generating a strategy with a probability higher than the set value is increased. During nuclear sampling, the sampling space is dynamically adjusted using the following formula: In the formula is the cumulative probability threshold; k is the number of tokens in the sampled candidate set; This is the preset cumulative probability; This represents the operation that determines the size of the candidate set; The initial cues in the generated initial population are extracted using embedding representations, and the semantic overlap between the various embedding representations is calculated using the following formula: In the formula The semantic overlap between embedding representation A and embedding representation B; For Hadamah accumulation; For device-associated weight vectors; Here is the similarity calculation function, and , The L2 norm of a vector.
4. The suggestion optimization method for a large language model of a power system according to claim 3, characterized in that... Step S3 includes the following steps: Based on the scheduling scenario characteristics of the target power system, semantic reconstruction and mutation operations are performed on the initial prompts in the initial population obtained in step S2. Based on the obtained data, a population optimization suggestion is generated using the estimated distribution mutation method. Based on the obtained data, the mutation strategy of the target power system is optimized based on the reflexive hypermutation mechanism. By adopting the Lamarck mutation strategy and based on successful power grid dispatch cases, we optimize the prompts to generate variants that are adapted to specific scenarios.
5. The suggestion optimization method for a large language model of a power system according to claim 4, characterized in that... Step S3 specifically includes the following steps: Semantic reconstruction mutation operation: First, a parent task prompt with performance exceeding a set value is selected from the current population. Then, a specific mutation instruction is randomly selected from the mutation instruction library generated in the "mutation strategy optimization" step. The parent prompt and the selected mutation instruction are combined and input into the large language model, which guides the large language model to reorganize, simplify, or expand the parent prompt, generating a new prompt variant that is more semantically and logically consistent with the power system's setting requirements. Finally, to ensure that the newly generated prompt variant is closely integrated with the physical reality of the power grid, the large language model is instructed to embed new constraint parameters into the new variant based on the topological characteristics of the target power grid, thereby completing the final mutation operation. Generate population optimization tips: By calculating the semantic overlap, a set of prompt variants that can represent the diversity of the target power system scheduling domain is obtained: the set of prompt variants that are semantically different but whose performance exceeds the set threshold is arranged in logical order and used as context input into the large language model. The large language model is set to summarize the common elements and core differences between different scenarios, thereby generating a group optimization prompt that integrates the overall advantages of the population and has a stronger generalization ability. Mutation strategy optimization: The typical mutation cases set in the dispatch domain of the target power system are combined with the super mutation prompt template. The super mutation prompt template is a pre-set meta-level instruction used to guide the optimization of the large language model or generate other mutation instructions. After combining the super mutation prompt template with the typical mutation cases, the large language model is set to analyze the characteristic patterns of historical successful mutation patterns, thereby iterating and optimizing the mutation strategy. Finally, a mutation instruction library containing several types of professional characteristics of the power system is obtained through the large language model. Generate variants adapted to specific scenarios: This process employs a Lamarck mutation strategy, specifically: selecting inference paths from typical successful cases of grid fault handling in the target power system, combining them with the obtained population optimization hints, and then inputting them into a large language model; Subsequently, the large language model is set up based on the reasoning path, and the potential prompt elements that can generate the reasoning path are derived in reverse and integrated into the baseline template. Finally, by comparing the actual scheduling logs with the reasoning path generated by the large language model, the newly generated prompts are optimized again to generate a variant that retains the group structure and incorporates successful cases.
6. The suggestion optimization method for a large language model of a power system according to claim 5, characterized in that... Step S4 includes the following steps: For each fault diagnosis scheme generated for each prompt variant obtained in step S3, a multidimensional adaptability score is calculated for each fault diagnosis scheme based on matching degree and temporal consistency. In each round of evolution, two cue variants are randomly selected to form an adversarial group, and a tournament selection mechanism is used to select the cue variants. The optimal cue variants in each round of evolution are dynamically saved, and cluster analysis is performed on the cue variants within the population to obtain a solution to the power grid problem.
7. The suggestion optimization method for a large language model of a power system according to claim 6, characterized in that... Step S4 specifically includes the following steps: Calculate the multidimensional fitness score: For each fault diagnosis scheme generated from the prompt variant obtained in step S3, the corresponding multidimensional adaptability score is calculated using the following formula. : In the formula This is the first weight value set. The degree of matching between expert annotation results and the output of the large language model; This is the set second weight value; The score is based on the time sequence consistency. Suggested variant filtering: In each round of evolution, two cue variants are randomly selected to form an adversarial group, and the cue variants are selected based on a tournament selection mechanism; the selection probability of the cue variants is calculated using the following formula: In the formula The probability of variant i1 winning in the adversarial group; To provide a multidimensional fitness score for variant i1; A multidimensional fitness score for another cue variant j1 in the adversarial group; The set selection pressure coefficient; Based on the selection probabilities of the obtained cue variants, the cue variants are filtered: a random number between 0 and 1 is generated. ,like If the selection is successful, then the cue variant i1 is chosen as the winner to enter the next generation of the population; otherwise, the cue variant j1 is chosen as the winner.
8. The suggestion optimization method for a large language model of a power system according to claim 7, characterized in that... Step S5 specifically includes the following steps: Quantifying population generational distribution shift: After obtaining the new generation of cue populations in step S4, the KL divergence metric is used to quantify the distribution difference between the old and new cue populations. The calculation formula is as follows: In the formula, Let be the KL divergence value; X be the set of all cue policies in the population; and x be a specific cue policy in set X. This indicates the probability of strategy x appearing in the new generation of the population; This indicates the probability of strategy x occurring in the old generation population; Adaptive adjustment of the intensity of the next round of evolution: Based on the calculated KL divergence value, the intensity of the mutation operation in step S3 of the next iteration is adaptively adjusted, specifically including the following steps: Set KL divergence control threshold: Preset KL divergence range, including a lower limit threshold to prevent evolutionary stagnation. An upper limit threshold to prevent population mutation ; Dynamically adjust mutation strategy: If calculated Value lower than If the mutation intensity is too small in the current evolutionary process, it will be determined that the change is trapped in a local optimum; the mutation intensity will be increased in the next cycle. If calculated Value higher than If the mutation intensity is too drastic and disrupts the existing favorable feedback structure, the mutation intensity will be automatically reduced in the next cycle.
9. A system for implementing the suggestion optimization method for a large language model of a power system as described in any one of claims 1 to 8, characterized in that... It includes a data acquisition module, a strategy generation module, a variant generation module, a scheme selection module, a loop optimization module, and a prompt optimization module; the data acquisition module, strategy generation module, variant generation module, scheme selection module, loop optimization module, and prompt optimization module are connected in series; the data acquisition module is used to acquire data information of the target power system and the corresponding large language model data information, and upload the data information to the strategy generation module; The strategy generation module is used to construct an initial prompt population for the fault diagnosis task of the target power system based on the received data information and the acquired data information, and generate diversified strategies by combining the domain problem description and general thinking patterns, and upload the data information to the variant generation module; The variant generation module is used to generate variants adapted to specific scenarios by performing mutation operations on task prompts through a large language model based on the received data information and the scheduling optimization requirements of the target power system, and then uploads the data information to the solution selection module. The solution selection module is used to select solutions to power grid problems based on the received data information, performance evaluation prompts, and the adaptability of the obtained variants using a tournament selection mechanism, and then uploads the data information to the loop optimization module. The cycle optimization module is used to adjust the strategy for the next round of evolution based on the received data information and the population KL divergence analysis, and upload the data information to the prompt optimization module; The prompt optimization module is used to optimize the prompts for the large language model of the target power system based on the received data information.