Power language model optimization method and device based on abnormal output trace analysis, equipment, storage medium and program product
By performing fine-grained source analysis and logical comparison on the abnormal output of the power language model, model optimization samples are constructed and parameters are accurately updated. This solves the problems of model errors and inaccurate parameter updates in traditional technologies, and improves the reliability of model reasoning in complex business scenarios.
Patent Information
- Application Number
- CN202611697560.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Traditional reinforcement learning techniques lack a fine-grained mechanism for locating the root causes of abnormal outputs in power language models. This makes the models prone to repeating the same systematic logical errors, and indiscriminate parameter updates can easily lead to catastrophic forgetting, undermining the model's existing general capabilities.
In response to the received model optimization instructions, the response text of the power language model is compared with the power business constraints to generate abnormal content fragments. A traceability path from the abnormal content fragments to the input context information is established. Logical comparison is performed using a preset power knowledge graph to construct model optimization samples and accurately map them to the corresponding network layer parameter areas for parameter updates.
It enables accurate tracing and structured attribution of the causes of abnormal outputs in the power language model, avoids indiscriminate parameter updates, and improves the reliability of the model's inference in complex business scenarios.
Smart Images

Figure CN123180174A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for optimizing a power language model based on anomaly output source analysis. Background Technology
[0002] In the digital transformation of the power industry, large language models are widely used in scenarios such as dispatch instruction generation, equipment fault diagnosis assistance, and operation and maintenance knowledge Q&A. Currently, the optimization of large language models in the power industry mainly adopts a technical approach of supervised fine-tuning combined with human feedback reinforcement learning. This method fine-tunes the model by collecting power documents to build a dataset, and uses expert scoring to build a reward model to update the policy network, aiming to improve the accuracy and safety of the model in power scenarios.
[0003] However, traditional reinforcement learning techniques rely solely on the overall score of the final result, lacking a fine-grained mechanism to pinpoint the root causes of anomalous outputs. They cannot distinguish whether errors stem from factual conflicts, logical gaps, or instruction deviations. This "black-box" approach to overall optimization makes the model prone to repeating the same systemic logical errors, and indiscriminate parameter updates easily lead to catastrophic forgetting, undermining the model's existing general capabilities. Therefore, traditional methods, lacking precise source tracing, structured attribution, and targeted parameter isolation and update mechanisms, result in low reasoning reliability for power language models in complex business scenarios. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer equipment, computer-readable storage medium, and computer program product for optimizing power language models based on abnormal output source analysis to address the above-mentioned technical problems.
[0005] Firstly, this application provides a method for optimizing a power language model based on anomaly output source tracing analysis, including:
[0006] In response to the received model optimization instruction, the response text generated during the test of the power language model to be processed is compared with the power business constraints to obtain the abnormal content fragments.
[0007] Based on the attention connection relationship when generating the abnormal content fragment according to the power language model, a tracing path from the abnormal content fragment to the input context information is established to obtain the source content. Then, based on the source content and the abnormal content fragment, a logical comparison is performed on the standard operation topology path and abnormal operation topology path matched in the preset power knowledge graph to obtain the logical difference attribution.
[0008] Based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path, a model optimization sample is constructed, and the model optimization sample is mapped to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the range of parameters to be updated.
[0009] The power language model is updated based on the model optimization samples and the range of parameters to be updated, resulting in an optimized power language model.
[0010] In one embodiment, the step of establishing a tracing path from the abnormal content fragment to the input context information based on the attention connection relationship generated according to the power language model to obtain the source content includes:
[0011] The process involves: 1) searching the attention connections for source positions pointing to the anomalous content fragment within the output sequence of the power language model to obtain the final-layer source positions; 2) comparing the character content corresponding to each final-layer source position in the input context information with the power business operation procedure text to obtain the final-layer procedure source positions; 3) traversing the power language model layer by layer from the final layer towards the input layer, and for each final-layer procedure source position, searching the attention connections for the previous-layer source positions; 4) comparing the character content corresponding to each previous-layer source position in the input context information with the power business operation procedure text to obtain the previous-layer procedure source positions, and so on, until the input layer of the power language model is traversed to obtain a multi-layer procedure source position group; and 5) determining the source content based on the statement units in the input context information of the multi-layer procedure source position group.
[0012] In one embodiment, determining the source tracing content based on the statement units in the input context information according to the multi-level procedure source location group includes:
[0013] Using the merged and deduplicated source positions in the multi-layered procedure source position group as candidate procedure positions, the natural sentence boundaries separated by punctuation marks or line breaks to which each candidate procedure position belongs in the input context information are determined; based on the candidate procedure positions belonging to the same natural sentence boundary, they are merged into a statement unit to obtain a candidate statement unit, and statement units containing the last-layer procedure source position are selected from the candidate statement units to obtain candidate statement units; based on the number of candidate procedure positions contained in each candidate statement unit, the candidate statement unit with the most positions is determined as the target statement unit, and the text content corresponding to the target statement unit in the input context information is used as the source tracing content.
[0014] In one embodiment, the step of logically comparing the standard operation topology path and the abnormal operation topology path matched in a preset power knowledge graph based on the source content and the abnormal content fragment respectively, to obtain the logical difference attribution, includes:
[0015] The source content is segmented and matched according to a preset power terminology dictionary to obtain a first power business entity and a first operational verb. The abnormal content fragment is then segmented and matched according to the same dictionary to obtain a second power business entity and a second operational verb. Node matching is performed on the preset power knowledge graph based on the first power business entity and the first operational verb to obtain a target knowledge graph node. Similarly, node matching is performed on the preset power knowledge graph based on the second power business entity and the second operational verb to obtain an abnormal knowledge graph node. Recursive traversal of reachable paths is performed along the logical connection edges of the preset power knowledge graph based on the target knowledge graph node, with the path containing the most nodes designated as the standard operational topology path. The same recursive traversal is performed along the logical connection edges of the abnormal knowledge graph node, with the path containing the most nodes designated as the abnormal operational topology path. Node missing and redundancy analyses are performed on the standard and abnormal operational topologies to determine the logical difference attribution.
[0016] In one embodiment, the step of performing node missing analysis and node redundancy analysis based on the standard operation topology path and the abnormal operation topology path to obtain the logical difference attribution includes:
[0017] Node connection order analysis is performed based on the first node sequence of the standard operation topology path and the second node sequence of the abnormal operation topology path. Node sequences with the same node name but inconsistent connection order are identified as sequence difference path segments. Node missingness analysis is performed based on the first path nodes of the standard operation topology path and the second path nodes of the abnormal operation topology path. Nodes present in the standard operation topology path but not in the abnormal operation topology path are identified as target missing nodes. Node redundancy analysis is performed on the first path nodes and the second path nodes. Nodes present in the abnormal operation topology path but not in the standard operation topology path are identified as target redundant nodes. The logical difference attribution is generated by filling in the sequence difference path segments, the target missing nodes, and the target redundant nodes according to a preset logical attribution template.
[0018] In one embodiment, constructing model optimization samples based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path includes:
[0019] Based on the operation instruction text and pre-condition logic constraint text obtained by traversing the preset power knowledge graph using the first node sequence, the correct logic deduction text is generated by alternately combining the nodes in the first node sequence according to their order in the standard operation topology path. Then, based on the position of the target missing node in the first node sequence, the position of the target redundant node in the second node sequence, and the positions of the two nodes in the sequence difference node pair corresponding to the sequence difference path segment in the first node sequence, the correct logic deduction text is subjected to error logic evolution to generate an error logic demonstration sample. Finally, based on the input context information of the source content, the correct logic deduction text, and the error logic demonstration sample, the model optimization sample is constructed by associating them.
[0020] Secondly, this application also provides a power language model optimization device based on abnormal output source tracing analysis, comprising:
[0021] The text comparison module is used to respond to the received model optimization instructions and compare the response text generated by the power language model to be processed during testing according to the power business constraints to obtain abnormal content fragments.
[0022] The logic comparison module is used to establish a tracing path from the abnormal content fragment to the input context information based on the attention connection relationship when the abnormal content fragment is generated by the power language model, to obtain the source content, and to perform a logical comparison based on the standard operation topology path and abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragment, respectively, to obtain the logical difference attribution.
[0023] The sample construction module is used to construct model optimization samples based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path, and to map the model optimization samples to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the parameter range to be updated.
[0024] The parameter update module is used to update the parameters of the power language model based on the model optimization samples and the range of parameters to be updated, so as to obtain the optimized power language model.
[0025] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0026] In response to the received model optimization instruction, the response text generated during testing by the power language model to be processed is compared according to the power business constraints to obtain abnormal content fragments. Based on the attention connection relationship when the power language model generates the abnormal content fragments, a tracing path from the abnormal content fragments to the input context information is established to obtain the source content. Logical comparisons are then performed on the standard operation topology path and the abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragments, respectively, to obtain the logical difference attribution. Based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path, model optimization samples are constructed, and these samples are mapped to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the parameter range to be updated. The power language model is then updated based on the model optimization samples and the parameter range to be updated to obtain the optimized power language model.
[0027] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0028] In response to the received model optimization instruction, the response text generated during testing by the power language model to be processed is compared according to the power business constraints to obtain abnormal content fragments. Based on the attention connection relationship when the power language model generates the abnormal content fragments, a tracing path from the abnormal content fragments to the input context information is established to obtain the source content. Logical comparisons are then performed on the standard operation topology path and the abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragments, respectively, to obtain the logical difference attribution. Based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path, model optimization samples are constructed, and these samples are mapped to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the parameter range to be updated. The power language model is then updated based on the model optimization samples and the parameter range to be updated to obtain the optimized power language model.
[0029] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0030] In response to the received model optimization instruction, the response text generated during testing by the power language model to be processed is compared according to the power business constraints to obtain abnormal content fragments. Based on the attention connection relationship when the power language model generates the abnormal content fragments, a tracing path from the abnormal content fragments to the input context information is established to obtain the source content. Logical comparisons are then performed on the standard operation topology path and the abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragments, respectively, to obtain the logical difference attribution. Based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path, model optimization samples are constructed, and these samples are mapped to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the parameter range to be updated. The power language model is then updated based on the model optimization samples and the parameter range to be updated to obtain the optimized power language model.
[0031] The aforementioned power language model optimization method, device, computer equipment, computer-readable storage medium, and computer program product based on anomaly output source analysis accurately screens out anomalous content fragments in the model output by comparing the test response text of the power language model with power business constraints. This breaks through the limitations of traditional technologies that only score the overall model output results and cannot accurately locate the specific content of the anomalous output. Based on the attention connection relationship when the power language model generates anomalous content fragments, a complete tracing path from the anomalous content fragment to the input context information is built to obtain the source content. At the same time, the source content and the anomalous content fragment are matched with the power knowledge graph to obtain the standard operation topology path and the anomalous operation topology path, respectively. Through logical comparison of the two, fine-grained logical difference attribution is completed. This effectively solves the defects of existing reinforcement learning technologies, such as the lack of a fine-grained localization mechanism for the root cause of anomalous output, the inability to distinguish various error causes such as factual conflicts, logical breaks, and instruction deviations. It achieves accurate source tracing and structured attribution of the causes of model anomalous output. Based on logical difference attribution, standard operation topology paths, and abnormal operation topology paths, targeted model optimization samples are constructed to adapt to specific model problems. These samples are then precisely mapped to the corresponding network-level parameter regions in the power language model that correspond to the logical difference attribution. This locks in the range of parameters to be updated, abandoning the indiscriminate global parameter update method of traditional techniques. This solves the problems of catastrophic amnesia and damage to the model's existing general capabilities that traditional optimization methods easily lead to, achieving precise isolation and targeted adaptation of parameter updates. Based on the model optimization samples and the precisely locked range of parameters to be updated, targeted and differentiated parameter updates are performed on the power language model, accurately correcting the corresponding systemic logical errors in the model and preventing the model from repeating the same problems. This improves the reasoning reliability of the power language model in complex business scenarios. Attached Figure Description
[0032] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0033] Figure 1 This is a diagram illustrating the application environment of a power language model optimization method based on anomaly output source analysis in one embodiment.
[0034] Figure 2 This is a flowchart illustrating a power language model optimization method based on anomaly output source analysis in one embodiment.
[0035] Figure 3 This is a flowchart illustrating the steps for establishing a traceability path in one embodiment;
[0036] Figure 4 This is a flowchart illustrating the logical comparison steps in one embodiment;
[0037] Figure 5 This is a flowchart illustrating the model optimization sample construction steps in one embodiment;
[0038] Figure 6 This is a flowchart illustrating a power language model optimization method based on anomaly output source analysis in a specific embodiment.
[0039] Figure 7 This is a structural block diagram of a power language model optimization device based on abnormal output source analysis in one embodiment;
[0040] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0042] The power language model optimization method based on abnormal output source analysis provided in this application embodiment can be applied to, for example... Figure 1 The application environment shown illustrates this. In this environment, the terminal can communicate with the server via a network. The data storage system can store the data that the server needs to process. The data storage system can be integrated onto the server or located on the cloud or other network servers. In situations such as... Figure 1In the application environment shown, the terminal can be, but is not limited to, various personal computers, laptops, smartphones, and tablets. The server can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0043] In one embodiment, such as Figure 2 As shown, a power language model optimization method based on anomaly output source analysis is provided. This method can be applied to... Figure 1 In the terminal, the method may include the following steps:
[0044] Step S201: In response to the received model optimization instruction, the response text generated during the test of the power language model to be processed is compared with the power business constraints to obtain the abnormal content fragment.
[0045] Optionally, the terminal obtains the response text generated by the power language model based on the input context information during testing, performs semantic parsing on the response text, and extracts the sequence of operation actions in the response text.
[0046] The terminal compares the sequence of operational actions with power service constraints, which include power service operation procedure texts and logical constraints. The power service operation procedure texts are standardized guidance documents recording the operating specifications, safety distances, and operating sequences of power system equipment. Logical constraints are directed acyclic graph rules describing the sequential dependencies and mutual exclusions between power equipment operational actions. Specifically, the terminal performs text matching between the sequence of operational actions and the standardized sequence of actions in the power service operation procedure text, and performs topological sorting comparison between the execution sequence of the operational actions and the directed acyclic graph rules in the logical constraints. When text matching fails or the topological sorting comparison is inconsistent, the terminal identifies the text fragment corresponding to the operational action sequence that violates the power service operation procedure text or logical constraints in the response text as an abnormal content fragment.
[0047] For example, given the input context "The heavy gas protection of the No. 1 main transformer at 110kV Substation A has tripped; please generate dispatch instructions for fault isolation and power restoration," the power language model generates the response text: "Immediately open the 1101 isolating switch on the 110kV side of the No. 1 main transformer, then disconnect the 1101 circuit breaker on the 110kV side, and close the 100 circuit breaker of the bus tie to restore 10kV bus power supply." The extracted action sequence is: "Open the 1101 isolating switch," "Disconnect the 1101 circuit breaker," and "Close the 100 circuit breaker of the bus tie." The power business operation procedure text stipulates that "It is strictly forbidden to open or close isolating switches under load; power outage operations must first disconnect the circuit breaker and then open the isolating switch." Logical constraints stipulate that the "disconnect the circuit breaker" node must precede the "open the isolating switch" node. Topological sorting comparison revealed that the phrase "open the 1101 disconnect switch" in the response text occurred before "disconnect the 1101 circuit breaker," violating logical constraints and resulting in the abnormal content fragment "open the 1101 disconnect switch on the 110kV side of the No. 1 main transformer, and then disconnect the 1101 circuit breaker on the 110kV side."
[0048] Step S202: Based on the attention connection relationship when generating abnormal content fragments using the power language model, establish a tracing path from the abnormal content fragments to the input context information to obtain the source content. Then, based on the source content and the abnormal content fragments, perform a logical comparison between the standard operation topology path and the abnormal operation topology path matched in the preset power knowledge graph to obtain the logical difference attribution.
[0049] Optionally, the attention connection relationship is the distribution of attention weights of the currently generated lexical to each lexical in the input sequence and the generated sequence during the autoregressive generation process of the power language model.
[0050] The terminal acquires the attention connections generated by the power language model when generating abnormal content fragments. Based on these connections, it establishes a tracing path from the abnormal content fragment to the input context information. This tracing path is a directed path that starts from the word corresponding to the abnormal content fragment and backtracks along the connection edge with the largest attention weight to the corresponding word in the input context information. The terminal uses the corresponding input context information as the source content based on the attention weights on the tracing path. This source content consists of the text paragraph that caused the error in the input information.
[0051] Optionally, the preset power knowledge graph includes a structured graph database containing power equipment entities, equipment status attributes, operating procedure actions, and temporal constraints between actions. The terminal performs subgraph matching on the source content and abnormal content fragments in the preset power knowledge graph to obtain standard operation topology paths and abnormal operation topology paths. Therefore, the standard operation topology path is a directed acyclic graph path in the preset power knowledge graph that matches the operation action corresponding to the source content and conforms to the power business operation procedure text. The abnormal operation topology path is a directed graph path in the preset power knowledge graph that matches the sequence of operation actions corresponding to the abnormal content fragments. Based on the logical differences between the standard operation topology path and the abnormal operation topology path, the terminal obtains a logical difference attribution, where the logical difference attribution is the text describing the logical deviation from the content.
[0052] Step S203: Based on logical difference attribution, standard operation topology path and abnormal operation topology path, construct model optimization samples, and map the model optimization samples to the network layer parameter region corresponding to logical difference attribution in the power language model to obtain the range of parameters to be updated.
[0053] Optionally, the terminal constructs model optimization samples based on the input context information corresponding to the traced content, error logic demonstration samples, and correct logic deduction samples. The error logic demonstration samples contain text sequences of abnormal content fragments and their corresponding erroneous reasoning steps. The correct logic deduction samples contain text sequences of correct operation instructions conforming to the standard operation topology path and their corresponding correct reasoning steps.
[0054] Optionally, the terminal performs word segmentation on the logical difference attribution, extracting key entity words and action words from the logical difference attribution. These key entity words and action words are mapped to feature vectors through the word embedding layer of the power language model. The cosine similarity between the feature vectors and the parameter matrices of the feedforward neural network layer and attention mechanism layer in each network layer of the power language model is calculated. The terminal identifies network layer parameter regions with cosine similarity greater than a preset similarity threshold as the network layer parameter regions corresponding to the logical difference attribution. After determining the network layer parameter regions, the terminal inputs the model optimization sample into the power language model for forward propagation calculation, obtaining the hidden state feature matrix of the model optimization sample at each network layer of the power language model. The terminal projects the hidden state feature matrix of the model optimization sample onto the network layer parameter region corresponding to the logical difference attribution, calculates the activation weights of the hidden state feature matrix and the low-rank adapter matrix parameters within that network layer parameter region, and identifies the low-rank adapter matrix parameters with activation weights greater than a preset activation threshold as the parameter range to be updated.
[0055] For example, assuming the power language model includes 32 layers of feedforward neural network and attention mechanism layers, with a preset similarity threshold of 0.7, the resulting logical difference is attributed to "incorrect timing of disconnecting switch operation, failing to follow the procedure of disconnecting the circuit breaker before opening the disconnecting switch." Key entity words and action words "disconnecting switch," "circuit breaker," and "operation timing" are extracted, and these words are mapped to feature vectors through a word embedding layer. The cosine similarity between the feature vector and the parameter matrices of the feedforward neural network and attention mechanism layers in layers 1 to 32 of the power language model is calculated. Assuming the calculated cosine similarity between the feature vector and the parameter matrices of the feedforward neural network layers from layers 8 to 12 is 0.85, which is greater than the preset similarity threshold of 0.7, layers 8 to 12 are identified as the network layer parameter region corresponding to the logical difference attribution, and the low-rank adapter matrix parameters of layers 8 to 12 are used as the parameter range to be updated.
[0056] Optionally, the preset activation threshold is 0.8. The model optimization sample, which includes the input context information "The heavy gas protection of the No. 1 main transformer of the 110kV Jia substation tripped, please generate the dispatching instruction for fault isolation and power restoration", the error logic demonstration sample and the correct logic deduction sample, is input into the power language model for forward propagation calculation to obtain the hidden state feature matrix of the model optimization sample in layers 8 to 12.
[0057] Project the hidden state feature matrix onto the network layer parameter regions of layers 8 to 12, and calculate the activation weights of the hidden state feature matrix and the low-rank adapter matrix parameters of layers 8 to 12. Assume that the calculated activation weights of the low-rank adapter matrix parameters of layers 8 and 9 are 0.92, which is greater than the preset activation threshold of 0.8, while the activation weights of layers 10 to 12 are 0.45, which is less than the preset activation threshold of 0.8. Therefore, the low-rank adapter matrix parameters of layers 8 and 9 are determined as the parameter range to be updated.
[0058] Step S204: Update the parameters of the power language model based on the model optimization samples and the range of parameters to be updated to obtain the optimized power language model.
[0059] Optionally, the terminal extracts model optimization samples from the sample database in batches, inputs the input context information corresponding to the input fields in the extracted model optimization samples into the power language model, and obtains the predicted response text output by the power language model. Based on the obtained range of parameters to be updated, the terminal locates the target parameter subset corresponding to the range in the parameter matrix of the power language model, and sets all other parameters in the power language model except for the target parameter subset to a frozen state. A frozen state means that the current value remains unchanged during subsequent parameter updates.
[0060] The terminal calculates the difference between the predicted response text and the correct logical deduction text corresponding to the positive sample output field in the model optimization samples to obtain a positive guidance loss value. This positive guidance loss value characterizes the degree to which the predicted response text deviates from the correct logical deduction text. The terminal calculates the similarity between the predicted response text and the incorrect logical demonstration sample corresponding to the negative sample output field in the model optimization samples to obtain a reverse correction loss value. This reverse correction loss value characterizes the degree of similarity between the predicted response text and the incorrect logical demonstration sample. The terminal then performs a weighted summation of the positive guidance loss value and the reverse correction loss value, and determines the result of the weighted summation as the comprehensive loss value for the current iteration.
[0061] The preset optimization cutoff conditions in this embodiment include a loss value convergence condition and a maximum iteration round condition. First, it is determined whether the current iteration round has reached the round threshold set by the maximum iteration round condition. If the current iteration round reaches the round threshold, the preset optimization cutoff condition is satisfied. If the current iteration round has not reached the round threshold, it is determined whether the comprehensive loss value of the current iteration round satisfies the loss value convergence condition. The loss value convergence condition is determined as follows: obtain the comprehensive loss values of multiple consecutive historical iteration rounds, calculate the absolute value of the difference between the comprehensive loss value of the current iteration round and the average of the comprehensive loss values of multiple consecutive historical iteration rounds. If the absolute value of this difference is less than or equal to a preset loss change threshold, it is determined that the comprehensive loss value has converged, i.e., the loss value convergence condition is satisfied, and thus the preset optimization cutoff condition is satisfied. If the absolute value of this difference is greater than the preset loss change threshold, it is determined that the preset optimization cutoff condition is not satisfied. When the preset optimization cutoff condition is satisfied, the iteration loop is terminated, the parameters of the power language model are stopped from being updated, the parameter freeze state is lifted, and the power language model under the current parameter state is saved and determined as the optimized power language model. When the preset optimization cutoff condition is not met, based on the comprehensive loss value of the current iteration, the backpropagation algorithm is used to calculate the gradient values of only the parameters in the target parameter subset, while other parameters in the frozen state do not participate in the gradient calculation. The gradient descent algorithm, combined with a preset learning rate, is used to update the values of only the parameters in the target parameter subset, while the values of other parameters in the frozen state remain unchanged. The current iteration number is incremented by 1, and the updated power language model is used as the initial model for the next iteration. The next batch of model optimization samples is extracted for iterative optimization until the preset optimization cutoff condition is met, resulting in the optimized power language model.
[0062] For example, the maximum iteration threshold in the preset optimization cutoff condition is 500, the number of consecutive historical iterations in the loss convergence condition is 10, the preset loss change threshold is 0.005, the preset learning rate is 0.0001, the weight of the positive guidance loss value is 0.7, the weight of the negative correction loss value is 0.3, and the range of parameters to be updated is the low-rank adapter matrix parameters of the 8th and 9th layers in the power language model.
[0063] The first iteration extracts one model optimization sample from the preset sample database. Assuming its input context is "The heavy gas protection of the No. 1 main transformer in the 110kV Jia substation tripped; please generate a dispatching instruction for fault isolation and power restoration," this sample is input into the power language model to obtain the predicted response text. The low-rank adapter matrix parameters of layers 8 and 9 in the power language model's parameter matrix are located as the target parameter subset. The parameters of layers 1 to 7 and layers 10 to 32 in the power language model are set to a frozen state. The cross-entropy between the predicted response text and the correct logical deduction text is calculated, assuming a positive guidance loss value of 1.25. The cosine similarity between the predicted response text and the incorrect logical demonstration sample is calculated, and the negative logarithm is taken after subtracting this cosine similarity from 1, assuming a negative correction loss value of 0.15. The overall loss value is 0.92, calculated by multiplying 1.25 by 0.7 and adding 0.15 by 0.3.
[0064] The current iteration round is round 1, which has not reached the round threshold of 500. Since the historical iteration rounds are less than 10, the loss value convergence condition is not met, and therefore the preset optimization cutoff condition is not met.
[0065] Based on a comprehensive loss value of 0.92, the backpropagation algorithm is used to calculate the gradient values of the low-rank adapter matrix parameters in layers 8 and 9. The parameters of other layers do not participate in the gradient calculation. The gradient descent algorithm is used in combination with a preset learning rate of 0.0001 to update the values of the parameters in the target parameter subset only, while the parameters of other layers remain unchanged. The current iteration round is incremented by 1, and the second iteration round begins.
[0066] Iterations from round 2 to round 119: The iteration process is repeated. In each iteration, optimization samples are extracted from the model, the comprehensive loss value is calculated, and it is determined whether the preset optimization cutoff condition is met.
[0067] Since the overall loss value has not yet converged, the parameters of the target parameter subset are continuously updated. Assume that the overall loss value gradually decreases with each iteration: 0.85 in round 10, 0.78 in round 50, 0.71 in round 100, 0.698 in round 110, and 0.693 in round 119. Assume that the absolute value of the difference between the overall loss values from round 10 to round 119 is not less than 0.0005; therefore, proceed to round 120.
[0068] Iteration Round 120: Extract model optimization samples, assuming the calculated comprehensive loss value for iteration round 120 is 0.691. The current iteration round is 120, which has not yet reached the round threshold of 500. Obtain the comprehensive loss values for the 10 historical iteration rounds from round 110 to round 119, assuming their average is 0.695. Calculate the absolute value of the difference between 0.695 and 0.691, which is 0.004. Since 0.004 is less than the preset loss change threshold of 0.005, it is determined that the comprehensive loss value has converged, satisfying the loss value convergence condition, and thus satisfying the preset optimization cutoff condition.
[0069] Since the preset optimization cutoff condition is met, the iteration loop terminates, updates to the parameters of the power language model cease, the frozen state of all parameters is released, and the power language model in the parameter state of round 120 is saved and identified as the optimized power language model. This embodiment improves the reasoning reliability of the power language model in complex business scenarios.
[0070] In one embodiment, such as Figure 3 As shown, in step S202 above, establishing a tracing path from the abnormal content fragment to the input context information based on the attention connection relationship when generating abnormal content fragments using the power language model, and obtaining the source content, may include the following steps:
[0071] Step S301: Find the source position of the abnormal content fragment in the output sequence of the power language model from the attention connection relationship to obtain the last layer source position. Based on the character content corresponding to each last layer source position in the input context information, compare it with the power business operation procedure text to obtain the last layer procedure source position.
[0072] Step S302: Traverse layer by layer from the last layer of the power language model toward the input layer. For each last layer procedure source position, find the source position of the previous layer pointing to each last layer procedure source position from the attention connection relationship.
[0073] Step S303: Based on the character content corresponding to each upper-level source position in the input context information, compare it with the power business operation procedure text to obtain the upper-level procedure source position, until the input layer of the power language model is traversed to obtain a multi-level procedure source position group; determine the source content based on the statement unit in the input context information of the multi-level procedure source position group.
[0074] Optionally, the terminal determines the position range of the abnormal content fragment in the output sequence of the power language model, and the position range is represented by a word index. The terminal obtains the attention weight matrix of the last layer of the power language model, i.e., the last decoder layer. This attention weight matrix records the distribution of attention weights of each word in the output sequence to each word in the input sequence and the generated sequence.
[0075] The terminal extracts the attention weight vectors corresponding to each word within the position range of the abnormal content fragment from the attention weight matrix. For each attention weight vector, the terminal selects the input sequence position with the largest attention weight value as the corresponding source position, and merges all selected source positions to obtain the final source position.
[0076] For example, the abnormal content fragment "open the 1101 isolating switch on the 110kV side of main transformer No. 1, and then disconnect the 1101 circuit breaker on the 110kV side" is located in the output sequence from the 2nd to the 15th word. Obtain the attention weight matrix of layer 32 of the power language model, and extract the attention weight vectors corresponding to the 2nd to 15th words from this matrix. For each attention weight vector, select the input sequence position with the largest attention weight value as the source position. Assume that, after searching, the largest attention weight corresponding to the 2nd word "open" points to the 4th word "main transformer" in the input context information; the 3rd word "No. 1" points to the 3rd word "No. 1"; the 4th word "main transformer" points to the 4th word "main transformer"; the 8th word "isolating switch" points to the 12th word "fault"; the 11th word "disconnect" points to the 8th word "trip"; and the 15th word "circuit breaker" points to the 6th word "protection". All source positions are deduplicated and merged to obtain the final source positions as the 3rd word "1", 4th word "main transformer", 6th word "protection", 8th word "trip", and 12th word "fault" in the input context information.
[0077] Optionally, the terminal obtains the character content corresponding to each last-layer source position in the input context information, performs string matching between each character content and the power business operation procedure text, and determines whether the character content is contained in the power business operation procedure text. If the character content is contained in the power business operation procedure text, the last-layer source position corresponding to the character content is determined as the last-layer procedure source position. If the character content is not contained in the power business operation procedure text, the last-layer source position corresponding to the character content is removed. The terminal summarizes all retained last-layer source positions to obtain the last-layer procedure source position.
[0078] For example, the source positions at the last layer are the 3rd word "1", the 4th word "main transformer", the 6th word "protection", the 8th word "trip", and the 12th word "fault".
[0079] Retrieve the character content corresponding to each last-layer source position and perform string matching between each character content and the power business operation procedure text. The matching results are as follows: "1" is a specific equipment number, which is not contained in the power business operation procedure text and is therefore removed. "Main transformer" is contained in the "Main transformer power outage operation procedure" section of the power business operation procedure text and is retained. "Protection" is contained in the "heavy gas protection action handling procedure" section of the power business operation procedure text and is retained. "Tripping" is contained in the "tripping fault handling process" section of the power business operation procedure text and is retained. "Fault" is contained in the "tripping fault handling process" section of the power business operation procedure text and is retained. Summarize the retained last-layer source positions to obtain the last-layer procedure source positions as the 4th word element "main transformer", the 6th word element "protection", the 8th word element "tripping", and the 12th word element "fault" in the input context information.
[0080] Optionally, the terminal starts from the last layer of the power language model and traverses it layer by layer in decreasing order towards the input layer. When traversing to the current layer, it obtains the attention weight matrix of the layer above the current layer, i.e., the layer whose layer number is one less than the current layer. For each procedure source position in the current layer, it finds the input sequence position with the largest attention weight value pointing to that procedure source position from the attention weight matrix of the previous layer, and uses it as the corresponding source position of the previous layer.
[0081] For each source position in the previous layer, the corresponding character content in the input context is matched against the power business operation procedure text. If the character content is contained within the power business operation procedure text, the source position in the previous layer is identified as the source position of the previous layer procedure. If the character content is not contained within the power business operation procedure text, the source position in the previous layer is discarded. The terminal uses all source positions of the previous layer procedure as the source positions of the current layer for the next round of traversal, and continues to traverse towards the input layer until it reaches the input layer of the power language model, i.e., layer 1. The source positions of the procedure obtained from each layer during the traversal are summarized according to the layer number to obtain a multi-layer procedure source position group.
[0082] For example, starting from layer 32 and traversing layer by layer back to layer 1, in layer 32, the current layer's procedure source position is the last layer's procedure source position, which is the 4th term "main transformer", the 6th term "protection", the 8th term "trip", and the 12th term "fault". The module obtains the attention weight matrix of layer 31, and for each procedure source position in layer 32, it searches the attention weight matrix of layer 31 for the source position with the largest attention weight value pointing to that position. Assuming that, after searching, the 4th term "main transformer" points to the 3rd term "No. 1" and the 4th term "main transformer"; the 6th term "protection" points to the 5th term "heavy gas" and the 6th term "protection"; the 8th term "trip" points to the 7th term "action" and the 8th term "trip"; and the 12th term "fault" points to the 12th term "fault" and the 13th term "isolation," then the source location of the layer above layer 31 is: the 3rd term "No. 1," the 4th term "main transformer," the 5th term "heavy gas," the 6th term "protection," the 7th term "action," the 8th term "trip," the 12th term "fault," and the 13th term "isolation." Matching these characters with the power business operation procedure text: "No. 1" is not included in the power business operation procedure text and is therefore removed. The term "heavy gas" is included in the "Heavy Gas Protection Action Handling Procedure" section of the power business operation procedure text and is retained. The term "action" is included in the "Heavy Gas Protection Action Handling Procedure" section of the power business operation procedure text and is retained. The term "isolation" is included in the "Isolation Switch Operation Specification" section of the power business operation procedure text and is retained. The source locations of the procedure above layer 31 are found to be the 4th term "main transformer," the 5th term "heavy gas," the 6th term "protection," the 7th term "action," the 8th term "trip," the 12th term "fault," and the 13th term "isolation." The process continues to traverse layer by layer towards layer 1, repeating the above search and comparison process until layer 1 is reached. The source locations of the procedure obtained from layers 32 to 1 are then summarized by layer number to obtain a multi-layer procedure source location group.
[0083] Optionally, the terminal determines the source content based on the statement units in the input context information of the multi-level procedure source location group.
[0084] This embodiment traverses layer by layer from the last layer to the input layer. At each layer, it uses the attention weight matrix of the previous layer to trace back to the source position with the largest attention weight value and compares and filters it with the power business operation procedure text to obtain a multi-layer procedure source position group that runs through all network layers of the power language model. Based on the sentence unit corresponding to the multi-layer procedure source position group in the input context information, the source content is determined. This can accurately locate the erroneous input information fragment that causes the power language model to produce abnormal output, effectively eliminating redundant information interference that is unrelated to the power business operation procedure, thereby improving the accuracy of parameter optimization and the reliability of inference of the power language model in complex business scenarios.
[0085] In one embodiment, step S303 above, determining the source content based on the statement units of the multi-level procedure source location group in the input context information, may include the following steps:
[0086] The candidate procedure positions are determined by merging and deduplicating the procedure source positions in the multi-level procedure source position group. The natural sentence boundaries separated by punctuation marks or line breaks are determined for each candidate procedure position in the input context information. Candidate procedure positions belonging to the same natural sentence boundary are merged into a statement unit to obtain a candidate statement unit. Statement units containing the last-level procedure source position are selected from the candidate statement units to obtain the candidate statement units. Based on the number of candidate procedure positions contained in each candidate statement unit, the candidate statement unit with the most positions is determined as the target statement unit. The text content corresponding to the target statement unit in the input context information is used as the source content.
[0087] Optionally, the terminal merges and deduplicates all procedure source positions in each layer of the multi-layer procedure source position group to obtain candidate procedure positions. The terminal performs boundary scanning on the input context information, identifying the position indices of all punctuation marks and newlines in the input context information. The text interval between two adjacent punctuation marks or newlines is used as a natural statement boundary. When there is no left boundary between the start position of the input context information and the first punctuation mark or newline, the start position of the input context information is used as the left boundary of the natural statement boundary. When there is no right boundary between the last punctuation mark or newline and the end position of the input context information, the end position of the input context information is used as the right boundary of the natural statement boundary. For each candidate procedure position, it determines which natural statement boundary's text interval the term index of the candidate procedure position falls into, and identifies that natural statement boundary as the natural statement boundary to which the candidate procedure position belongs.
[0088] For example, by merging and deduplicating all the source locations of the multi-layered procedure source locations from the 32nd layer to the 1st layer, the candidate procedure locations are: the 3rd term "No. 1", the 4th term "main transformer", the 5th term "heavy gas", the 6th term "protection", the 7th term "action", the 8th term "trip", the 12th term "fault", and the 13th term "isolation".
[0089] A boundary scan of the input context information identifies the 9th word, "," as a punctuation mark, thus defining two natural sentence boundaries: the first natural sentence boundary is the text interval corresponding to the 1st to 8th words, i.e., "110kV Jia Substation No. 1 Main Transformer Heavy Gas Protection Trip"; the second natural sentence boundary is the text interval corresponding to the 10th to 19th words, i.e., "Please generate dispatch instructions for fault isolation and power restoration". The natural sentence boundary to which each candidate procedure position belongs is determined: the word index 3 of the 3rd word "No. 1" falls within the text interval of the 1st natural sentence boundary (i.e., words 1 to 8), and its natural sentence boundary is the 1st natural sentence boundary. The word index 4 of the 4th word "Main Transformer" falls within the 1st natural sentence boundary. The word index 5 of the 5th word "Heavy Gas" falls within the 1st natural sentence boundary. The lexical index 6 of the 6th lexical unit "protect" falls within the first natural sentence boundary. The lexical index 7 of the 7th lexical unit "action" falls within the first natural sentence boundary. The lexical index 8 of the 8th lexical unit "trip" falls within the first natural sentence boundary. The lexical index 12 of the 12th lexical unit "fault" falls within the text range of the second natural sentence boundary, i.e., from the 10th to the 19th lexical unit, and its natural sentence boundary is the second natural sentence boundary. The lexical index 13 of the 13th lexical unit "isolate" falls within the second natural sentence boundary.
[0090] Optionally, the terminal merges all candidate procedure positions belonging to the same natural statement boundary, constructs a statement unit based on the text interval corresponding to the natural statement boundary, and obtains a candidate statement unit. The terminal obtains the candidate procedure positions contained in each candidate statement unit, and obtains the last-level procedure source positions, and determines whether each candidate statement unit contains at least one last-level procedure source position among its candidate procedure positions.
[0091] A candidate statement unit is selected as a candidate statement unit if its candidate procedure positions contain at least one last-level procedure source position. A candidate statement unit is eliminated if its candidate procedure positions do not contain any last-level procedure source positions.
[0092] For example, candidate procedure positions within the same natural statement boundary are merged into a statement unit. The candidate procedure positions contained within the first natural statement boundary are the 3rd word "No. 1", the 4th word "main transformer", the 5th word "heavy gas", the 6th word "protection", the 7th word "action", and the 8th word "trip". These are merged to obtain the 1st candidate statement unit, whose text content is "Heavy gas protection action trip of No. 1 main transformer of 110kV Jia substation". The candidate procedure positions contained within the second natural statement boundary are the 12th word "fault" and the 13th word "isolation". These are merged to obtain the 2nd candidate statement unit, whose text content is "Please generate dispatch instructions for fault isolation and power restoration".
[0093] The source positions of the final-level procedure are obtained as the 4th term "main transformer", the 6th term "protection", the 8th term "trip", and the 12th term "fault". Each candidate statement unit is then determined to contain a source position of the final-level procedure: If the first candidate statement unit contains three source positions (the 4th term "main transformer", the 6th term "protection", and the 8th term "trip"), it satisfies the condition of containing at least one source position of the final-level procedure and is thus identified as a candidate statement unit. If the second candidate statement unit contains one source position (the 12th term "fault"), it also satisfies the condition of containing at least one source position of the final-level procedure and is thus identified as a candidate statement unit.
[0094] Optionally, the terminal counts the number of candidate procedure positions contained in the candidate procedure positions of each candidate statement unit, compares the number of positions of all candidate statement units, and selects the candidate statement unit with the largest number of positions as the target statement unit. When there are two or more candidate statement units with the same number of positions, and both are the maximum value, the candidate statement unit containing the largest number of last-level procedure source positions is selected as the target statement unit. The terminal extracts the text content corresponding to the target statement unit in the input context information and determines this text content as the source content.
[0095] For example, count the number of candidate procedure positions contained in each candidate statement unit. Assume the first candidate statement unit contains the third term "No. 1", the fourth term "main transformer", the fifth term "heavy gas", the sixth term "protection", the seventh term "action", and the eighth term "trip", for a total of 6 positions. The second candidate statement unit contains the twelfth term "fault" and the thirteenth term "isolation", for a total of 2 positions. Therefore, the first candidate statement unit is determined as the target statement unit, and its corresponding text content in the input context, "110kV Jia Substation No. 1 Main Transformer Heavy Gas Protection Action Trip", is determined as the source content.
[0096] This embodiment can accurately extract the error-causing input information fragments most relevant to the abnormal output of the power language model from the input context information, effectively avoiding the source location deviation caused by excessively long input context information or the presence of multiple independent semantic fragments, thereby improving the pertinence of parameter optimization and the credibility of inference of the power language model in complex business scenarios.
[0097] In one embodiment, such as Figure 4 As shown, in step S202 above, a logical comparison is performed on the standard operation topology path and the abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragments, respectively, to obtain the logical difference attribution. This may include the following steps:
[0098] Step S401: Perform word segmentation and matching on the source content according to the preset power terminology dictionary to obtain the first power business entity and the first operation verb, and perform word segmentation and matching on the abnormal content fragments according to the preset power terminology dictionary to obtain the second power business entity and the second operation verb.
[0099] Step S402: Node matching is performed in the preset power knowledge graph based on the first power business entity and the first operation verb to obtain the target knowledge graph node; and node matching is performed in the preset power knowledge graph based on the second power business entity and the second operation verb to obtain the abnormal knowledge graph node.
[0100] Step S403: Based on the target knowledge graph nodes, recursively traverse the reachable paths along the logical connection edges in the preset power knowledge graph, and take the path containing the most nodes as the standard operation topology path. Also, based on the abnormal knowledge graph nodes, recursively traverse the reachable paths along the logical connection edges, and take the path containing the most nodes as the abnormal operation topology path.
[0101] Step S404: Perform node missing analysis and node redundancy analysis based on the standard operation topology path and the abnormal operation topology path to obtain the logical difference attribution.
[0102] Optionally, the preset power terminology dictionary includes a power equipment entity vocabulary sub-library and a power operation verb vocabulary sub-library. The power equipment entity vocabulary sub-library records the standard terms for the names, numbers, voltage levels, protection types, and statuses of various types of equipment in the power system, while the power operation verb vocabulary sub-library records the standard terms for equipment operation actions in the power system.
[0103] The terminal scans the source content using a sliding window from left to right. Each substring obtained is matched against a sub-database of power equipment entities in a pre-defined power terminology dictionary. If a substring completely matches a standard term in the power equipment entity sub-database, that substring is identified as the first power business entity. Similarly, each substring is matched against a sub-database of power operation verbs in a pre-defined power terminology dictionary. If a substring completely matches a standard term in the power operation verbs sub-database, that substring is identified as the first operation verb.
[0104] The terminal uses the same sliding window scanning and matching method as the source content for abnormal content fragments. It identifies the standard terms in the matched power equipment entity vocabulary sub-library as the second power business entity and the standard terms in the matched power operation verb vocabulary sub-library as the second operation verb.
[0105] For example, the sub-database of power equipment entities in the pre-defined power terminology dictionary contains standard terms such as "main transformer," "disconnecting switch," "circuit breaker," "heavy gas protection," "bus tie circuit breaker," and "busbar." The sub-database of power operation verbs contains standard terms such as "open," "disconnect," "close," "trip," "engage," and "exit." A sliding window scan and matching is performed on the source content "110kV Jia Substation No. 1 main transformer heavy gas protection trip." During the scan, the substring "main transformer" completely matches "main transformer" in the power equipment entity sub-database, thus identifying it as a first power business entity. The substring "heavy gas protection" completely matches "heavy gas protection" in the power equipment entity sub-database, thus identifying it as a first power business entity. The substring "trip" completely matches "trip" in the power operation verbs sub-database, thus identifying it as a first operation verb. Therefore, the first power business entities are "main transformer" and "heavy gas protection," and the first operation verb is "trip."
[0106] A sliding window scan and matching was performed on the abnormal content fragment "Open the 1101 disconnecting switch on the 110kV side of the No. 1 main transformer, and then disconnect the 1101 circuit breaker on the 110kV side". During the scan, the substring "main transformer" completely matched "main transformer" in the power equipment entity vocabulary sub-library, thus identifying it as a second power business entity. The substring "disconnecting switch" completely matched "disconnecting switch" in the power equipment entity vocabulary sub-library, thus identifying it as a second power business entity. The substring "circuit breaker" completely matched "circuit breaker" in the power equipment entity vocabulary sub-library, thus identifying it as a second power business entity. The substring "open" completely matched "open" in the power operation verb vocabulary sub-library, thus identifying it as a second operation verb. The substring "disconnect" completely matched "disconnect" in the power operation verb vocabulary sub-library, thus identifying it as a second operation verb. Therefore, the second power business entities obtained are "main transformer", "disconnecting switch" and "circuit breaker", and the second operation verbs are "open" and "disconnect".
[0107] Optionally, the preset power knowledge graph includes three types of nodes: equipment status nodes, operation action nodes, and protection action nodes. Among them, equipment status nodes are identified by the name of the power equipment and the equipment status attribute, operation action nodes are identified by the operation verb and the operation object, and protection action nodes are identified by the protection type and the action result.
[0108] For each first power business entity, the terminal searches the preset power knowledge graph for a device status node or protection action node that matches the first power business entity, and uses the found node as the target knowledge graph node corresponding to the first power business entity. For each first operation verb, the terminal searches the preset power knowledge graph for an operation action node or protection action node that contains the first operation verb, and uses the found node as the target knowledge graph node corresponding to the first operation verb.
[0109] For each second power business entity, a node identifier matching the device status node or operation action node in the preset power knowledge graph is searched, and the found node is designated as the corresponding abnormal knowledge graph node for that second power business entity. For each second operation verb, a node identifier containing the operation action node in the preset power knowledge graph is searched, and the found node is designated as the corresponding abnormal knowledge graph node for that second operation verb.
[0110] For example, the preset power knowledge graph includes the following nodes: equipment status node "Main Transformer - Operating Status", equipment status node "Main Transformer - Out of Service Status", protection action node "Heavy Gas Protection - Tripping Action", operation action node "Open - Disconnect Switch", operation action node "Disconnect - Circuit Breaker", equipment status node "Disconnect Switch - Open Status", equipment status node "Circuit Breaker - Open Status", equipment status node "Disconnect Switch - Closed Status", and equipment status node "Circuit Breaker - Closed Status".
[0111] For the first power business entity "Main Transformer", assuming that the equipment status nodes "Main Transformer - Operating Status" and "Main Transformer - Outage Status" are found in the preset power knowledge graph, and considering the state transition direction indicated by the first operation verb "Trip", the equipment status node "Main Transformer - Outage Status" is selected as the corresponding target knowledge graph node. For the first power business entity "Heavy Gas Protection", assuming that the protection action node "Heavy Gas Protection - Action Trip" is found, it is determined as the corresponding target knowledge graph node. For the first operation verb "Trip", assuming that the protection action node "Heavy Gas Protection - Action Trip" is found, this node has already been obtained during the matching of the first power business entity "Heavy Gas Protection", and deduplication is performed. Therefore, the target knowledge graph nodes include: the equipment status node "Main Transformer - Outage Status" and the protection action node "Heavy Gas Protection - Action Trip".
[0112] For the second power business entity "Main Transformer", assuming the equipment status nodes "Main Transformer - Operating Status" and "Main Transformer - Out of Service Status" are found, they are identified as the corresponding abnormal knowledge graph nodes. For the second power business entity "Disconnect Switch", assuming the equipment status nodes "Disconnect Switch - Open Status" and "Disconnect Switch - Closed Status" are found, they are identified as the corresponding abnormal knowledge graph nodes. For the second power business entity "Circuit Breaker", assuming the equipment status nodes "Circuit Breaker - Open Status" and "Circuit Breaker - Closed Status" are found, they are identified as the corresponding abnormal knowledge graph nodes. For the second operation verb "Open", assuming the operation action node "Open - Disconnect Switch" is found, it is identified as the corresponding abnormal knowledge graph node. For the second operation verb "Disconnect", assuming the operation action node "Disconnect - Circuit Breaker" is found, it is identified as the corresponding abnormal knowledge graph node. Therefore, the abnormal knowledge graph nodes include: equipment status nodes "main transformer - operating status", equipment status nodes "main transformer - out of service status", equipment status nodes "disconnecting switch - open status", equipment status nodes "disconnecting switch - closed status", equipment status nodes "circuit breaker - open status", equipment status nodes "circuit breaker - closed status", operation action nodes "open - disconnecting switch", and operation action nodes "disconnect - circuit breaker".
[0113] Optionally, for each target knowledge graph node, starting from that target knowledge graph node, a recursive traversal is performed along the directed logical connection edges originating from that starting node in the preset power knowledge graph. Each time a new reachable node is encountered, that reachable node is added to the current path, and the recursive traversal continues along the directed logical connection edges originating from that reachable node until no directed logical connection edges originate from the current reachable node. This process stops the recursive traversal of that branch, resulting in at least one reachable path corresponding to the target knowledge graph node. The terminal counts the number of nodes contained in each reachable path and selects the reachable path with the most nodes as the standard operation topology path corresponding to the target knowledge graph node.
[0114] For each abnormal knowledge graph node, the same recursive traversal method as the target knowledge graph node is adopted. Starting from the abnormal knowledge graph node, the recursive traversal is performed along the directed logical connection edge to obtain at least one reachable path. The reachable path with the most nodes is selected as the abnormal operation topology path corresponding to the abnormal knowledge graph node.
[0115] For example, the directed logical connection edges in the preset power knowledge graph include: the protection action node "heavy gas protection - tripping" points to the equipment status node "main transformer - out of service", the equipment status node "main transformer - out of service" points to the operation action node "disconnect - circuit breaker", the operation action node "disconnect - circuit breaker" points to the equipment status node "circuit breaker - disconnected", the equipment status node "circuit breaker - disconnected" points to the operation action node "open - disconnecting switch", and the operation action node "open - disconnecting switch" points to the equipment status node "disconnecting switch - disconnected".
[0116] Starting with the protection action node "Heavy Gas Protection - Trip", a recursive traversal is performed along the directed logical connection edges to the equipment status nodes "Main Transformer - Off-line", "Disconnect - Circuit Breaker", "Circuit Breaker - Off-line", "Open - Disconnect Switch", and "Disconnect Switch - Off-line", resulting in one reachable path: "Heavy Gas Protection - Trip" → "Main Transformer - Off-line" → "Disconnect - Circuit Breaker" → "Circuit Breaker - Off-line" → "Open - Disconnect Switch" → "Disconnect Switch - Off-line" (a total of 6 nodes). Starting with the equipment status node "Main Transformer - Off-line", a recursive traversal also yields one reachable path: "Main Transformer - Off-line" → "Disconnect - Circuit Breaker" → "Circuit Breaker - Off-line" → "Open - Disconnect Switch" → "Disconnect Switch - Off-line" (a total of 5 nodes). The standard operating topology path is selected as the reachable path containing 6 nodes, namely "Heavy Gas Protection - Trip Operation" → "Main Transformer - Off Operation" → "Disconnect - Circuit Breaker" → "Circuit Breaker - Disconnected Operation" → "Open - Disconnect Switch" → "Disconnect Switch - Disconnected Operation".
[0117] Starting with the operation action node "Open - Disconnect Switch", a recursive traversal yields one reachable path: "Open - Disconnect Switch" → "Disconnect Switch - Open State". Similarly, starting with the operation action node "Disconnect - Circuit Breaker", a recursive traversal yields another reachable path: "Disconnect - Circuit Breaker" → "Circuit Breaker - Open State" → "Open - Disconnect Switch" → "Disconnect Switch - Open State". Therefore, the abnormal operation topology path is: "Disconnect - Circuit Breaker" → "Circuit Breaker - Open State" → "Open - Disconnect Switch" → "Disconnect Switch - Open State".
[0118] Optionally, node missing analysis and node redundancy analysis are performed based on the standard operation topology path and the abnormal operation topology path to obtain the logical difference attribution, as in steps 2081 to 2084.
[0119] This embodiment can transform the abnormal output of the power language model from the unstructured text level into structured topological path differences in the preset power knowledge graph, enabling fine-grained localization and structured attribution of the root cause of abnormal output. It can accurately distinguish whether the error stems from factual conflict, logical discontinuity or instruction deviation, effectively avoiding the problem of the model repeatedly committing the same systematic logical errors and catastrophic forgetting caused by "black box" overall optimization, and improving the reasoning credibility of the power language model in complex business scenarios.
[0120] In one embodiment, step S404 above, which involves performing node missingness analysis and node redundancy analysis based on the standard operation topology path and the abnormal operation topology path to obtain logical difference attribution, may include the following steps:
[0121] Node connection order analysis is performed based on the first node sequence of the standard operation topology path and the second node sequence of the abnormal operation topology path. Node sequences with the same node name but inconsistent connection order are identified as sequence difference path segments. Node missingness analysis is performed based on the first path nodes of the standard operation topology path and the second path nodes of the abnormal operation topology path. Nodes present in the standard operation topology path but not in the abnormal operation topology path are identified as target missing nodes. Node redundancy analysis is performed on the first and second path nodes. Nodes present in the abnormal operation topology path but not in the standard operation topology path are identified as target redundant nodes. Logical difference attribution is generated by filling in the sequence difference path segments, target missing nodes, and target redundant nodes according to a preset logical attribution template.
[0122] Optionally, the terminal obtains the first node sequence of the standard operation topology path and the second node sequence of the abnormal operation topology path. It extracts all node names from the first node sequence to form a first name, and extracts all node names from the second node sequence to form a second name. An intersection operation is performed on the first name and the second name to obtain a common node name, which includes node names that exist simultaneously in both the first and second node sequences.
[0123] For every two node names in the common node name set, the terminal obtains their sequence positions in the first node sequence, recording the node name with the earlier position as its order in the first node sequence. The terminal then obtains their sequence positions in the second node sequence, recording the node name with the earlier position as its order in the second node sequence. When the order of two node names in the first node sequence differs from their order in the second node sequence, the terminal identifies these two node names as a pair of node names with order differences. The terminal arranges all pairs of node names with order differences from front to back according to their sequence positions in the second node sequence, forming a path segment with order differences.
[0124] For example, the node names extracted from the first node sequence form the first name {"Heavy Gas Protection - Tripped", "Main Transformer - Out of Service", "Disconnect - Circuit Breaker", "Circuit Breaker - Disconnected", "Open - Disconnect Switch", "Disconnect Switch - Disconnected"}, and the node names extracted from the second node sequence form the second name {"Open - Disconnect Switch", "Disconnect Switch - Disconnected", "Disconnect - Circuit Breaker", "Circuit Breaker - Disconnected"}. The intersection of the first and second names yields a common node name {"Disconnect - Circuit Breaker", "Circuit Breaker - Disconnected", "Open - Disconnect Switch", "Disconnect Switch - Disconnected"}, containing a total of four node names. For every two node names in the common node name set, their order in the first and second node sequences is determined. The specific analysis is as follows:
[0125] Group 1: "Disconnect-Circuit Breaker" and "Circuit Breaker-Disconnected State". In the first node sequence, "Disconnect-Circuit Breaker" is the 3rd node and "Circuit Breaker-Disconnected State" is the 4th node, with "Disconnect-Circuit Breaker" coming first. In the second node sequence, "Disconnect-Circuit Breaker" is the 3rd node and "Circuit Breaker-Disconnected State" is the 4th node, with "Disconnect-Circuit Breaker" coming first. They are identical and do not constitute a node pair with a difference in order.
[0126] Group 2: "Disconnect-Circuit Breaker" and "Open-Disconnect Switch". In the first node sequence, "Disconnect-Circuit Breaker" is the 3rd node and "Open-Disconnect Switch" is the 5th node, with "Disconnect-Circuit Breaker" coming first. In the second node sequence, "Open-Disconnect Switch" is the 1st node and "Disconnect-Circuit Breaker" is the 3rd node, with "Open-Disconnect Switch" coming first. These two sequences are inconsistent, forming a pair of node pairs with different sequences: {"Disconnect-Circuit Breaker", "Open-Disconnect Switch"}.
[0127] Group 3: "Disconnect - Circuit Breaker" and "Disconnect Switch - Disconnected State". In the first node sequence, "Disconnect - Circuit Breaker" is the 3rd node and "Disconnect Switch - Disconnected State" is the 6th node, with "Disconnect - Circuit Breaker" preceding it. In the second node sequence, "Disconnect - Circuit Breaker" is the 3rd node and "Disconnect Switch - Disconnected State" is the 2nd node, with "Disconnect Switch - Disconnected State" preceding it. These two sequences are inconsistent, forming a pair of nodes with different order: {"Disconnect - Circuit Breaker", "Disconnect Switch - Disconnected State"}.
[0128] Group 4: "Circuit breaker - Open state" and "Open - Disconnect switch". In the first node sequence, "Circuit breaker - Open state" is the 4th node and "Open - Disconnect switch" is the 5th node, with "Circuit breaker - Open state" coming first. In the second node sequence, "Open - Disconnect switch" is the 1st node and "Circuit breaker - Open state" is the 4th node, with "Open - Disconnect switch" coming first. These two sequences are inconsistent, forming a pair of nodes with different order: {"Circuit breaker - Open state", "Open - Disconnect switch"}.
[0129] Group 5: "Circuit Breaker - Open State" and "Disconnect Switch - Open State". In the first node sequence, "Circuit Breaker - Open State" is the 4th node and "Disconnect Switch - Open State" is the 6th node, with "Circuit Breaker - Open State" coming first. In the second node sequence, "Disconnect Switch - Open State" is the 2nd node and "Circuit Breaker - Open State" is the 4th node, with "Disconnect Switch - Open State" coming first. These two sequences are inconsistent, forming a pair of nodes with different order: {"Circuit Breaker - Open State", "Disconnect Switch - Open State"}.
[0130] Group 6: "Open-Disconnect Switch" and "Disconnect Switch-Off State". In the first node sequence, "Open-Disconnect Switch" is the 5th node and "Disconnect Switch-Off State" is the 6th node, with "Open-Disconnect Switch" coming first. In the second node sequence, "Open-Disconnect Switch" is the 1st node and "Disconnect Switch-Off State" is the 2nd node, with "Open-Disconnect Switch" coming first. They are identical and do not constitute a node pair with a difference in order.
[0131] The sequential difference node pairs are {"Disconnect-Circuit Breaker", "Open-Disconnect Switch"}, {"Disconnect-Circuit Breaker", "Disconnect Switch - Disconnected State"}, {"Circuit Breaker - Disconnected State", "Open-Disconnect Switch"}, {"Circuit Breaker - Disconnected State", "Disconnect Switch - Disconnected State"}. All sequential difference node pairs are arranged from front to back according to their earliest occurrence in the second node sequence. All the nodes involved, arranged in the second node sequence, are "Open-Disconnect Switch", "Disconnect Switch - Disconnected State", "Disconnect-Circuit Breaker", "Circuit Breaker - Disconnected State", forming a sequential difference path segment: "Open-Disconnect Switch" → "Disconnect Switch - Disconnected State" → "Disconnect-Circuit Breaker" → "Circuit Breaker - Disconnected State".
[0132] Optionally, the terminal obtains the first path node of the standard operation topology path and the second path node of the abnormal operation topology path. It performs a difference operation using the first path node as the minuend and the second path node as the subtrahend, traversing each node in the first path node sequence to determine if that node exists in the second path node sequence. When the node does not exist in the second path node sequence, the terminal records it as a candidate missing node. All candidate missing nodes are then arranged from front to back according to their sequence position in the first node sequence to obtain the target missing node.
[0133] For example, the first path node is {"Heavy Gas Protection - Tripped", "Main Transformer - Out of Service", "Disconnect - Circuit Breaker", "Circuit Breaker - Out of Service", "Open - Disconnect Switch", "Disconnect Switch - Out of Service"}, and the second path node is {"Open - Disconnect Switch", "Disconnect Switch - Out of Service", "Disconnect - Circuit Breaker", "Circuit Breaker - Out of Service"}. Using the first path node as the minuend and the second path node as the subtrahend, a difference operation is performed, iterating through each node in the first path node: "Heavy Gas Protection - Tripped" does not exist in the second path node and is recorded as one candidate missing node. "Main Transformer - Out of Service" does not exist in the second path node and is recorded as one candidate missing node. "Disconnect - Circuit Breaker" exists in the second path node but is not recorded. "Circuit Breaker - Out of Service" exists in the second path node but is not recorded. "Open - Disconnect Switch" exists in the second path node but is not recorded. "Disconnect Switch - Out of Service" exists in the second path node but is not recorded. Two candidate missing nodes were obtained and arranged from front to back according to their sequence position in the first node sequence. The first target missing node is "heavy gas protection - tripping" and the second target missing node is "main transformer - out of service".
[0134] Optionally, the terminal performs a difference operation using the second path node as the minuend and the first path node as the subtrahend, traversing each node in the second path node sequence and determining whether the node exists in the first path node sequence. When the node does not exist in the first path node sequence, the terminal records the node as a candidate redundant node, and arranges all candidate redundant nodes from front to back according to their sequence position in the second node sequence to obtain the target redundant node.
[0135] For example, the second path nodes are {"Open-Disconnect Switch", "Disconnect Switch - Open State", "Open-Circuit Breaker", "Circuit Breaker - Open State"}, and the first path nodes are {"Heavy Gas Protection - Tripped", "Main Transformer - Out of Service", "Open-Circuit Breaker", "Circuit Breaker - Open State", "Open-Disconnect Switch", "Disconnect Switch - Open State"}. Using the second path node as the minuend and the first path node as the subtrahend, a difference operation is performed, iterating through each node in the second path node: "Open-Disconnect Switch" exists in the first path node but is not recorded. "Disconnect Switch - Open State" exists in the first path node but is not recorded. "Open-Circuit Breaker" exists in the first path node but is not recorded. "Circuit Breaker - Open State" exists in the first path node but is not recorded.
[0136] Optionally, the preset logical attribution template includes three fields: a sequence difference fill field, a node missing fill field, and a node redundancy fill field. The terminal performs semantic description transformation on the sequence difference path segment, extracts the operation verbs and device names contained in the node names in the sequence difference path segment, generates a first description text describing the operation timing deviation according to the arrangement order in the second node sequence, and fills the sequence difference fill field in the preset logical attribution template with this first description text.
[0137] The terminal performs semantic description transformation on target missing nodes, extracting the device name or protection type contained in the node name of each target missing node to generate a second descriptive text describing the missing link in the standard operation, and fills this second descriptive text into the node missing fill field in the preset logical attribution template. Semantic description transformation is performed on target redundant nodes. When the number of target redundant nodes is greater than 0, the device name and operation verb contained in the node name of each target redundant node are extracted to generate a third descriptive text describing the redundant link in the abnormal operation, and this third descriptive text is filled into the node redundancy fill field in the preset logical attribution template. When the number of target redundant nodes is equal to 0, the node redundancy fill field in the preset logical attribution template is filled with "no redundant nodes". The text content of all fields in the filled preset logical attribution template is concatenated in the order of sequence difference fill field, node missing fill field, and node redundancy fill field to obtain the logical difference attribution.
[0138] For example, the preset logical attribution template includes a sequence difference fill field, a node missing fill field, and a node redundancy fill field. Semantic description transformation is performed on the sequence difference path segment "Open - Isolating Switch" → "Isolating Switch - Disconnected State" → "Disconnect - Circuit Breaker" → "Circuit Breaker - Disconnected State". Operation verbs and device names are extracted, and a first description text, "Isolating switch operation timing error, opening the isolating switch before disconnecting the circuit breaker, not following the operating procedure of disconnecting the circuit breaker before opening the isolating switch," is generated according to the order in the second node sequence. This first description text is then filled into the sequence difference fill field.
[0139] Semantic description transformation is performed on the two missing target nodes. For the first missing target node "Heavy Gas Protection - Trip", the protection type is extracted as "Heavy Gas Protection" and the action result is "Trip". For the second missing target node "Main Transformer - Outage Status", the equipment name is extracted as "Main Transformer" and the equipment status is "Outage Status". A second description text "Missing triggering conditions for heavy gas protection trip and confirmation steps for main transformer outage status" is generated and filled into the missing node filling field.
[0140] Assuming the number of target redundant nodes is 0, the node redundancy fill field is filled with "No redundant nodes". The text content of all filled fields is then concatenated in sequence, resulting in the following logical difference attribution: "Incorrect disconnector operation timing; the disconnector was opened before the circuit breaker was disconnected, failing to follow the procedure of disconnecting the circuit breaker before opening the disconnector. The triggering condition for the heavy gas protection trip and the confirmation of the main transformer's shutdown status are missing. No redundant nodes."
[0141] This embodiment can transform the structured topological path differences in the preset power knowledge graph into attribution conclusions in natural language form. This allows the logical difference attribution to simultaneously cover logical deviation information in three dimensions: operational timing deviation, missing standard links, and redundant abnormal links. This effectively avoids the problem of relying solely on surface text differences for model optimization while ignoring the root causes of deep logical errors, and improves the pertinence and reasoning credibility of the power language model in complex business scenarios.
[0142] In one embodiment, such as Figure 5 As shown, in step S203 above, constructing model optimization samples based on logical difference attribution, standard operation topology path, and abnormal operation topology path may include the following steps:
[0143] Based on the operation instruction text and pre-condition logic constraint text obtained by traversing the first node sequence in the preset power knowledge graph, the correct logic deduction text is generated by alternating the order of each node in the first node sequence in the standard operation topology path. Based on the position of the target missing node in the first node sequence, the position of the target redundant node in the second node sequence, and the positions of the two nodes in the first node sequence of the sequence difference node pair corresponding to the sequence difference path segment, the correct logic deduction text is subjected to error logic evolution to generate error logic demonstration samples. Based on the input context information of the source content, the correct logic deduction text, and the error logic demonstration samples, the model optimization samples are constructed by associating them.
[0144] Optionally, for each node in the first node sequence of the standard operation topology path, the terminal searches for an attribute text node connected to that node via an labeled connection edge in a preset power knowledge graph. The attribute text node stores the operation instruction text and the prerequisite logical constraint text corresponding to that node. The operation instruction text is a natural language description of the operation steps corresponding to that node, and the prerequisite logical constraint text is a natural language description of the prerequisite conditions that must be met before executing the operation steps. The operation instruction text and the prerequisite logical constraint text are extracted from the attribute text node.
[0145] The terminal sequentially arranges the pre-condition logic constraint text and operation instruction text corresponding to each node in the first node sequence, from the first node to the last node. The arrangement rule is as follows: for the i-th node, the pre-condition logic constraint text of that node is arranged first, followed by the operation instruction text of that node, where i is a positive integer greater than or equal to 1 and less than or equal to the total number of nodes in the first node sequence. The terminal then concatenates the pre-condition logic constraint text and operation instruction text corresponding to all nodes into a coherent text in the above alternating arrangement order, inserts a newline character between adjacent text segments to separate them, and generates the correct logical deduction text.
[0146] For example, for the six nodes in the first node sequence, we search for attribute text nodes connected by labeled edges in the preset power knowledge graph one by one. Suppose that the extracted operation instruction text and pre-condition logic constraint text are as follows:
[0147] The first node, "Heavy Gas Protection - Trip Operation", has the following pre-logic constraint text: "When a serious fault occurs inside the main transformer, the heavy gas protection device detects that the oil flow velocity exceeds the set value." The operation instruction text is: "Heavy gas protection operation, circuit breakers on all sides of the main transformer trip."
[0148] The second node, "Main Transformer - Off-line Status", has the following pre-logic constraint text: "Confirm that the heavy gas protection action signal has been issued and that all circuit breakers on each side have tripped". The operation instruction text is: "Confirm that the main transformer has switched to the off-line status and check that the current indication on each side is zero".
[0149] The third node, "Disconnect-Circuit Breaker", has the following pre-logic constraint text: "Confirm that the main transformer has been switched to the off state and the protection device action signal is normal", and the operation instruction text: "Disconnect the 1101 circuit breaker on the 110kV side of the main transformer".
[0150] The fourth node, "Circuit Breaker - Open Status", has the following pre-logic constraint text: "Confirm that the circuit breaker opening operation has been completed" and the operation instruction text: "Confirm that the 110kV side 1101 circuit breaker is in the open state and check that the circuit breaker position indicator shows that it is open."
[0151] The fifth node, "Open the disconnect switch", has the following pre-logic constraint text: "Confirm that the 1101 circuit breaker on the 110kV side is in the open state", and the operation instruction text: "Open the 1101 disconnect switch on the 110kV side of the main transformer".
[0152] The 6th node, "Disconnecting Switch - Open Status", has the following pre-logic constraint text: "Confirm that the 110kV side 1101 disconnecting switch opening operation has been completed", and the operation instruction text: "Confirm that the 110kV side 1101 disconnecting switch is in the open status, and check that the mechanical position indication of the disconnecting switch is correct".
[0153] Following the order of nodes 1 to 6, the preceding logical constraint text and operation instruction text of each node are alternately arranged to generate the correct logical deduction text as follows:
[0154] "When a serious fault occurs inside the main transformer, the heavy gas protection device detects that the oil flow velocity exceeds the set value. The heavy gas protection activates, and the circuit breakers on all sides of the main transformer trip. Confirm that the heavy gas protection activation signal has been issued and that the circuit breakers on all sides have tripped. Confirm that the main transformer is in a shutdown state and check that the current indication on each side is zero. Confirm that the main transformer is in a shutdown state and that the protection device activation signal is normal. Disconnect the 1101 circuit breaker on the 110kV side of the main transformer. Confirm that the circuit breaker disconnection operation has been completed. Confirm that the 1101 circuit breaker on the 110kV side is in the open state and check that the circuit breaker position indicator shows open. Confirm that the 1101 circuit breaker on the 110kV side is in the open state. Open the 1101 isolating switch on the 110kV side of the main transformer. Confirm that the 1101 isolating switch opening operation on the 110kV side is completed. Confirm that the 1101 isolating switch on the 110kV side is in the open state and check that the isolating switch mechanical position indication is correct."
[0155] Optionally, the terminal performs erroneous logic evolution on the correct logical deduction text based on the position of the target missing node in the first node sequence, the position of the target redundant node in the second node sequence, and the positions of the two nodes in the first node sequence of the sequence difference node pair corresponding to the sequence difference path segment. For example, based on the correct logical deduction text, according to the logical deviation indicated by the target missing node, the target redundant node, and the sequence difference node pair, the terminal performs deletion, insertion, and sequence swapping operations on the text content in the correct logical deduction text, so that the final generated text presents the same logical error pattern as the correct logical deduction text, thus obtaining an erroneous logic demonstration sample.
[0156] Optionally, a data structure for the model optimization sample is constructed, including three fields: an input field, a positive sample output field, and a negative sample output field. The terminal obtains the input context information to which the traceable content belongs, fills the input context information into the input field of the model optimization sample, fills the correct logical deduction text into the positive sample output field of the model optimization sample, which is used to indicate the correct response content that the power language model should output when it receives the input context information corresponding to the input field, and fills the incorrect logic demonstration sample into the negative sample output field of the model optimization sample, which is used to indicate the response content containing logical errors that the power language model previously output when it received the input context information corresponding to the input field, serving as a counterexample reference in the model optimization process.
[0157] The terminal adds text content of logical difference attribution to the output field of negative samples in the model optimization samples, and establishes a relationship between logical difference attribution and negative sample output field. This allows the model optimization samples to simultaneously use correct logical deduction text for positive guidance and incorrect logical demonstration samples to combine with logical difference attribution for reverse correction in the subsequent model optimization process.
[0158] For example, the input context information for obtaining the traceability content "110kV Jia Substation No. 1 main transformer heavy gas protection trip" is "110kV Jia Substation No. 1 main transformer heavy gas protection trip, please generate dispatch instructions for fault isolation and power restoration".
[0159] Construct a data structure for the model optimization samples, including input fields, positive sample output fields, and negative sample output fields. Fill the input fields with the input context information "The heavy gas protection of the No. 1 main transformer in the 110kV Jia substation has tripped. Please generate a dispatching instruction for fault isolation and power restoration". The correct logical derivation text, "When a serious fault occurs inside the main transformer, the heavy gas protection device detects that the oil flow velocity exceeds the set value. The heavy gas protection activates, and the circuit breakers on all sides of the main transformer trip. Confirm that the heavy gas protection activation signal has been issued and that all circuit breakers on all sides have tripped. Confirm that the main transformer has switched to a shutdown state and check that the current indication on each side is zero. Confirm that the main transformer has switched to a shutdown state and that the protection device activation signal is normal. Disconnect the 1101 circuit breaker on the 110kV side of the main transformer. Confirm that the circuit breaker disconnection operation has been completed. Confirm that the 1101 circuit breaker on the 110kV side is in the disconnected state and check that the circuit breaker position indicator shows open. Confirm that the 1101 circuit breaker on the 110kV side is in the disconnected state. Open the 1101 isolating switch on the 110kV side of the main transformer. Confirm that the 1101 isolating switch opening operation on the 110kV side is completed. Confirm that the 1101 isolating switch on the 110kV side is in the disconnected state and check that the isolating switch mechanical position indication is correct." is filled into the positive sample output field.
[0160] The generated error logic demonstration sample is populated into the negative sample output field, and the logic difference is attributed to "Incorrect timing of disconnecting switch operation: the disconnecting switch is opened before the circuit breaker is disconnected, failing to follow the operating procedure of disconnecting the circuit breaker before opening the disconnecting switch. The triggering condition for the heavy gas protection trip and the confirmation of the main transformer's shutdown status are missing. There are no redundant nodes" is appended to the negative sample output field.
[0161] This embodiment constructs a model optimization sample that simultaneously includes positive correct inference guidance and reverse error correction reference. This enables the model optimization sample to accurately correspond to the specific logical deviation types generated by the power language model in specific business scenarios. It effectively avoids the problem of repeated errors caused by the model's inability to perceive its own error patterns when relying solely on correct samples for model optimization. At the same time, through the correlation of logical difference attribution, the model can clearly identify the specific dimensions and deviation directions of errors during parameter updates, thereby improving the convergence efficiency and inference credibility of the power language model in complex power business scenarios.
[0162] In one embodiment, such as Figure 6 As shown, a power language model optimization method based on abnormal output source analysis is provided in a specific embodiment, which includes the following steps:
[0163] Step S601: In response to the received model optimization instruction, the response text generated by the power language model to be processed during testing is compared with the power business constraints to obtain abnormal content fragments; the source positions pointing to the abnormal content fragments in the output sequence of the power language model are found from the attention connection relationship to obtain the final source positions; the character content corresponding to each final source position in the input context information is compared with the power business operation procedure text to obtain the final procedure source positions.
[0164] Step S602: Traverse layer by layer from the last layer of the power language model towards the input layer. For each last-layer procedure source position, find the previous layer source position pointing to each last-layer procedure source position from the attention connection relationship. Based on the character content corresponding to each previous layer source position in the input context information, compare it with the power business operation procedure text to obtain the previous layer procedure source position. Continue until the input layer of the power language model is traversed to obtain a multi-layer procedure source position group. Determine the source content based on the statement units of the multi-layer procedure source position group in the input context information.
[0165] Step S603: Perform word segmentation and matching on the source content according to a preset power terminology dictionary to obtain a first power business entity and a first operational verb; perform word segmentation and matching on the abnormal content fragment according to the preset power terminology dictionary to obtain a second power business entity and a second operational verb; perform node matching on the preset power knowledge graph according to the first power business entity and the first operational verb to obtain a target knowledge graph node; and perform node matching on the preset power knowledge graph according to the second power business entity and the second operational verb to obtain an abnormal knowledge graph node.
[0166] Step S604: Based on the target knowledge graph nodes, recursively traverse the reachable paths along the logical connection edges in the preset power knowledge graph, and take the path containing the most nodes as the standard operation topology path. Based on the abnormal knowledge graph nodes, recursively traverse the reachable paths along the logical connection edges, and take the path containing the most nodes as the abnormal operation topology path. Perform node missing analysis and node redundancy analysis based on the standard operation topology path and the abnormal operation topology path to obtain the logical difference attribution.
[0167] Step S605: Based on the operation instruction text and the pre-condition logic constraint text obtained by traversing the preset power knowledge graph according to the first node sequence, the correct logic deduction text is generated by alternating the order of each node in the first node sequence in the standard operation topology path; based on the position of the target missing node in the first node sequence, the position of the target redundant node in the second node sequence, and the positions of the two nodes in the first node sequence of the sequence difference node pair corresponding to the sequence difference path segment, the correct logic deduction text is subjected to error logic evolution to generate an error logic demonstration sample.
[0168] Step S606: Based on the input context information of the source content, the correct logical deduction text, and the incorrect logical demonstration sample, the model optimization sample is constructed by association; the model optimization sample is mapped to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the parameter range to be updated; the power language model is updated based on the model optimization sample and the parameter range to be updated to obtain the optimized power language model.
[0169] The beneficial effects of the above embodiments are as follows:
[0170] This embodiment compares the test response text of the power language model with the power business constraints to accurately screen out abnormal content fragments in the model output. This breaks through the limitations of traditional technologies that only score the overall model output and cannot accurately locate the specific content of the abnormal output. Based on the attention connection relationship when the power language model generates abnormal content fragments, a complete tracing path from the abnormal content fragment to the input context information is built and the source content is obtained. At the same time, the source content and the abnormal content fragment are matched with the power knowledge graph to obtain the standard operation topology path and the abnormal operation topology path. By comparing the logic of the two, fine-grained logical difference attribution is completed. This effectively solves the defects of existing reinforcement learning technologies, such as the lack of a fine-grained localization mechanism for the root cause of abnormal output, the inability to distinguish various error causes such as factual conflicts, logical breaks, and instruction deviations. It realizes accurate tracing and structured attribution of the causes of abnormal model output. Based on logical difference attribution, standard operation topology paths, and abnormal operation topology paths, targeted model optimization samples are constructed to adapt to specific model problems. These samples are then precisely mapped to the corresponding network-level parameter regions in the power language model that correspond to the logical difference attribution. This locks in the range of parameters to be updated, abandoning the indiscriminate global parameter update method of traditional techniques. This solves the problems of catastrophic amnesia and damage to the model's existing general capabilities that traditional optimization methods easily lead to, achieving precise isolation and targeted adaptation of parameter updates. Based on the model optimization samples and the precisely locked range of parameters to be updated, targeted and differentiated parameter updates are performed on the power language model, accurately correcting the corresponding systemic logical errors in the model and preventing the model from repeating the same problems. This improves the reasoning reliability of the power language model in complex business scenarios.
[0171] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0172] Based on the same inventive concept, this application also provides an apparatus for optimizing a power language model based on anomaly output source tracing analysis to implement the aforementioned method for optimizing a power language model based on anomaly output source tracing analysis. The solution provided by this apparatus is similar to the solution described in the above method. Therefore, the specific limitations of one or more embodiments of the apparatus for optimizing a power language model based on anomaly output source tracing analysis provided below can be found in the limitations of the power language model optimization method based on anomaly output source tracing analysis described above, and will not be repeated here.
[0173] In one exemplary embodiment, such as Figure 7 As shown, a power language model optimization device based on abnormal output source tracing analysis is provided. The device may include:
[0174] The text comparison module 701 is used to respond to the received model optimization instruction and compare the response text generated by the power language model to be processed during testing according to the power business constraints to obtain abnormal content fragments.
[0175] The logic comparison module 702 is used to establish a tracing path from the abnormal content fragment to the input context information based on the attention connection relationship when the abnormal content fragment is generated by the power language model, to obtain the source content, and to perform a logical comparison based on the standard operation topology path and abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragment, respectively, to obtain the logical difference attribution.
[0176] The sample construction module 703 is used to construct model optimization samples based on the logical difference attribution, the standard operation topology path and the abnormal operation topology path, and map the model optimization samples to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the parameter range to be updated.
[0177] The parameter update module 704 is used to update the parameters of the power language model based on the model optimization sample and the parameter range to be updated, so as to obtain the optimized power language model.
[0178] In one embodiment, the logic comparison module 702 is further configured to: search for the source position of the abnormal content fragment within the position range of the output sequence of the power language model from the attention connection relationship to obtain the final layer source position; compare the character content corresponding to each final layer source position in the input context information with the power business operation procedure text to obtain the final layer procedure source position; traverse layer by layer from the final layer of the power language model towards the input layer, and for each final layer procedure source position, search for the previous layer source position from the attention connection relationship; compare the character content corresponding to each previous layer source position in the input context information with the power business operation procedure text to obtain the previous layer procedure source position, until the input layer of the power language model is traversed to obtain a multi-layer procedure source position group; and determine the source content based on the statement unit in the input context information of the multi-layer procedure source position group.
[0179] In one embodiment, the logic comparison module 702 is used to determine the natural sentence boundary separated by punctuation marks or line breaks to which each candidate procedure position belongs in the input context information, using the merged and deduplicated procedure source positions in the multi-layer procedure source position group as candidate procedure positions; merge the candidate procedure positions belonging to the same natural sentence boundary into a statement unit to obtain a candidate statement unit, and filter out the statement units contained in the last-layer procedure source position from the candidate statement units to obtain a candidate statement unit; based on the number of positions of the candidate procedure positions contained in each candidate statement unit, determine the candidate statement unit with the most positions as the target statement unit, and use the text content corresponding to the target statement unit in the input context information as the source tracing content.
[0180] In one embodiment, the logical comparison module 702 is further configured to perform word segmentation and matching on the source content according to a preset power terminology dictionary to obtain a first power business entity and a first operational verb, and perform word segmentation and matching on the abnormal content fragment according to the preset power terminology dictionary to obtain a second power business entity and a second operational verb; perform node matching on the preset power knowledge graph according to the first power business entity and the first operational verb to obtain a target knowledge graph node, and perform node matching on the preset power knowledge graph according to the second power business entity and the second operational verb to obtain an abnormal knowledge graph node; perform recursive traversal of reachable paths along the logical connection edges in the preset power knowledge graph based on the target knowledge graph node, and take the path containing the most nodes as the standard operation topology path; perform recursive traversal of reachable paths along the logical connection edges based on the abnormal knowledge graph node, and take the path containing the most nodes as the abnormal operation topology path; perform node missing analysis and node redundancy analysis based on the standard operation topology path and the abnormal operation topology path to obtain the logical difference attribution.
[0181] In one embodiment, the logical comparison module 702 is further configured to perform node connection order analysis based on the first node sequence of the standard operation topology path and the second node sequence of the abnormal operation topology path, and determine the node sequences with the same node name but inconsistent connection order as sequence difference path segments; perform node missing analysis based on the first path nodes of the standard operation topology path and the second path nodes of the abnormal operation topology path, and determine the nodes that exist in the standard operation topology path but not in the abnormal operation topology path as target missing nodes; perform node redundancy analysis on the first path nodes and the second path nodes, and determine the nodes that exist in the abnormal operation topology path but not in the standard operation topology path as target redundant nodes; and fill in the sequence difference path segments, the target missing nodes, and the target redundant nodes according to a preset logical attribution template to generate the logical difference attribution.
[0182] In one embodiment, the sample construction module 703 is further configured to: generate correct logical deduction text by alternatingly combining the operation instruction text and pre-condition logic constraint text obtained by traversing the preset power knowledge graph according to the first node sequence, and according to the order of each node in the first node sequence in the standard operation topology path; evolve the correct logical deduction text into incorrect logic based on the position of the target missing node in the first node sequence, the position of the target redundant node in the second node sequence, and the positions of the two nodes in the sequence difference node pair corresponding to the sequence difference path segment in the first node sequence; and construct the model optimization sample by associating the input context information of the source content, the correct logical deduction text, and the incorrect logic demonstration sample.
[0183] The modules in the aforementioned power language model optimization device based on anomaly output source analysis can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.
[0184] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a power language model optimization method based on anomaly output source analysis. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0185] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0186] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0187] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0188] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0189] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0190] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0191] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0192] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A power language model optimization method based on abnormal output source tracing analysis, characterized in that, The method includes: In response to the received model optimization instruction, the response text generated during the test of the power language model to be processed is compared with the power business constraints to obtain the abnormal content fragments. Based on the attention connection relationship when generating the abnormal content fragment according to the power language model, a tracing path from the abnormal content fragment to the input context information is established to obtain the source content. Then, based on the source content and the abnormal content fragment, a logical comparison is performed on the standard operation topology path and abnormal operation topology path matched in the preset power knowledge graph to obtain the logical difference attribution. Based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path, a model optimization sample is constructed, and the model optimization sample is mapped to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the range of parameters to be updated. The power language model is updated based on the model optimization samples and the range of parameters to be updated, resulting in an optimized power language model.
2. The method according to claim 1, characterized in that, The attention connection relationship generated when generating the abnormal content fragment based on the power language model establishes a tracing path from the abnormal content fragment to the input context information, thereby obtaining the source content, including: The source position of the abnormal content fragment is found in the attention connection relationship and located within the position range of the output sequence of the power language model. The final source position is obtained. The character content corresponding to each final source position in the input context information is compared with the power business operation procedure text to obtain the final procedure source position. The process traverses layer by layer from the last layer of the power language model toward the input layer. For each last layer procedure source position, the process searches the attention connection relationship for the source position of the previous layer that points to each last layer procedure source position. The source positions of each upper-level source position are compared with the character content corresponding to the input context information and the power business operation procedure text to obtain the source position of the upper-level procedure. This process is repeated until the input layer of the power language model is traversed to obtain a multi-level procedure source position group. The source content is determined based on the statement units in the input context information of the multi-level procedure source position group.
3. The method according to claim 2, characterized in that, The step of determining the source tracing content based on the statement units in the input context information according to the multi-level procedure source location group includes: Using the merged and deduplicated procedure source positions in the multi-layer procedure source position group as candidate procedure positions, determine the natural sentence boundaries separated by punctuation marks or line breaks to which each candidate procedure position belongs in the input context information. Candidate procedure positions belonging to the same natural statement boundary are merged into a statement unit to obtain a candidate statement unit. Then, statement units contained in the last-level procedure source position are selected from the candidate statement units to obtain the candidate statement units. Based on the number of candidate procedure positions contained in each candidate statement unit, the candidate statement unit with the most positions is determined as the target statement unit, and the text content corresponding to the target statement unit in the input context information is used as the source content.
4. The method according to claim 1, characterized in that, The logical comparison of the standard operation topology path and the abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragment respectively, to obtain the logical difference attribution, includes: The source content is segmented and matched according to a preset power terminology dictionary to obtain a first power business entity and a first operation verb. The abnormal content fragment is segmented and matched according to the preset power terminology dictionary to obtain a second power business entity and a second operation verb. Based on the first power business entity and the first operation verb, node matching is performed in the preset power knowledge graph to obtain the target knowledge graph node; and based on the second power business entity and the second operation verb, node matching is performed in the preset power knowledge graph to obtain the abnormal knowledge graph node. Based on the target knowledge graph node, recursively traverse the reachable path along the logical connection edge in the preset power knowledge graph, and takes the path containing the most nodes as the standard operation topology path. Based on the abnormal knowledge graph node, recursively traverse the reachable path along the logical connection edge, and takes the path containing the most nodes as the abnormal operation topology path. Based on the standard operation topology path and the abnormal operation topology path, node missing analysis and node redundancy analysis are performed to obtain the logical difference attribution.
5. The method according to claim 4, characterized in that, The step of performing node missing and node redundancy analysis based on the standard operation topology path and the abnormal operation topology path to obtain the logical difference attribution includes: Based on the first node sequence of the standard operation topology path and the second node sequence of the abnormal operation topology path, the node connection order is analyzed, and the node sequences with the same node name but inconsistent connection order are identified as sequence difference path segments. Node missing analysis is performed based on the first path node of the standard operation topology path and the second path node of the abnormal operation topology path. Nodes that exist in the standard operation topology path but not in the abnormal operation topology path are identified as target missing nodes. Perform node redundancy analysis on the first path node and the second path node, and identify the nodes that exist in the abnormal operation topology path but not in the standard operation topology path as target redundant nodes. The logical difference attribution is generated by filling in the sequential difference path segments, the target missing nodes, and the target redundant nodes according to a preset logical attribution template.
6. The method according to claim 5, characterized in that, The step of constructing model optimization samples based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path includes: Based on the operation instruction text and the pre-logical constraint text obtained by traversing the preset power knowledge graph according to the first node sequence, the correct logical deduction text is generated by alternately combining each node in the first node sequence in the standard operation topology path. Based on the position of the target missing node in the first node sequence, the position of the target redundant node in the second node sequence, and the positions of the two nodes in the first node sequence of the sequence difference node pair corresponding to the sequence difference path segment, the correct logic deduction text is subjected to error logic evolution to generate an error logic demonstration sample. The model optimization sample is constructed by associating the input context information of the source content, the correct logical deduction text, and the incorrect logical demonstration sample.
7. A power language model optimization device based on abnormal output source tracing analysis, characterized in that, The device includes: The text comparison module is used to respond to the received model optimization instructions and compare the response text generated by the power language model to be processed during testing according to the power business constraints to obtain abnormal content fragments. The logic comparison module is used to establish a tracing path from the abnormal content fragment to the input context information based on the attention connection relationship when the abnormal content fragment is generated by the power language model, to obtain the source content, and to perform a logical comparison based on the standard operation topology path and abnormal operation topology path matched in the preset power knowledge graph based on the source content and the abnormal content fragment, respectively, to obtain the logical difference attribution. The sample construction module is used to construct model optimization samples based on the logical difference attribution, the standard operation topology path, and the abnormal operation topology path, and to map the model optimization samples to the network layer parameter region in the power language model corresponding to the logical difference attribution to obtain the parameter range to be updated. The parameter update module is used to update the parameters of the power language model based on the model optimization samples and the parameter range to be updated, so as to obtain the optimized power language model.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
