A power system state estimation method based on a large language model

CN121189486BActive Publication Date: 2026-08-18SICHUAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511302061.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-12
Publication Date
2026-08-18
Estimated Expiration
2045-09-12

AI Technical Summary

Technical Problem

[0002]传统的电力系统状态估计模型研究对象单一,所能处理的数据与知识有限,不能提供泛化性良好的多模态数据处理能力,在面对复杂数据条件或非理想数据条件时,难以完成数据分析任务

Benefits of technology

本申请提供一种基于大语言模型的电力系统状态估计方法,通过改变用户问题和系统预设的提示词来调整输入序列,以适应复杂多变的任务,提高本申请的适应性;通过调用外部数学工具,可以执行特定于任务的复杂计算,使本申请具备了强大的自然语言理解和生成能力,拥有了解决专业领域问题的能力;进一步的,通过添加新的工具Token及其对应的外部数学工具,以支持更多类型的计算或分析任务;除此之外,利用微调好的大语言模型结合外部数学工具的预测结果,进一步提升最终状态估计的精确度。综上所述,本申请能够实现智能化、精准化、通用化的电力系统状态估计。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121189486B_ABST
    Figure CN121189486B_ABST
Patent Text Reader

Abstract

The application discloses a power system state estimation method based on a large language model, and relates to the field of power system state estimation.The method comprises the following steps: S1, obtaining an input sequence based on a user question and a preset system prompt word; S2, determining a next output Token by using a fine-tuned large language model based on the input sequence and a current output sequence; S3, if the next output Token is a preset end symbol Token, obtaining a final result of distribution network state estimation based on the current output sequence; if the next output Token is a tool Token, adding the tool Token to the current output sequence to obtain a tool output sequence, calling an external mathematical tool corresponding to the tool Token to obtain a prediction result, converting the prediction result into a text Token sequence, adding the text Token sequence to the tool output sequence, and returning to S2; and if the next output Token is a normal Token, adding the normal Token to the current output sequence and returning to S2.The application improves the accuracy and intelligence of power system state estimation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power system state estimation, and in particular to a power system state estimation method based on a large language model. Background Technology

[0002] Traditional power system state estimation models focus on a single research object, have limited data and knowledge capacity, and cannot provide good generalization capabilities for multimodal data processing. They struggle to complete data analysis tasks when faced with complex or non-ideal data conditions. Furthermore, traditional power system state estimation models are often small, functionally defined models that lack versatility. Summary of the Invention

[0003] The purpose of this application is to provide a power system state estimation method based on a large language model. Artificial intelligence with natural language communication capabilities is positioned as a research assistant, enabling automated execution of scientific experiments. Furthermore, by calling external mathematical tools, it provides multimodal data processing capabilities with good generalization, completing data analysis tasks even under complex or non-ideal data conditions. This achieves intelligent, accurate, and universal power system state estimation. When applied to computer hardware, it can improve the computing speed of computer equipment.

[0004] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a power system state estimation method based on a large language model, including: S1. Based on the user question "Estimate the state of the current distribution network according to the input data" and the preset system prompt "You are an artificial intelligence assistant that helps me solve problems by calling external tools", obtain the input sequence and initialize the current output sequence; S2. Based on the input sequence and the current output sequence, calculate the conditional probability distribution of the next output token using a fine-tuned large language model, and determine the next output token according to the conditional probability distribution of the next output token; the large language model includes a regular token embedding matrix and a preset tool token embedding matrix. S3. If the next output token is a preset end token, then the final result of the distribution network state estimation is obtained based on the current output sequence. If the next output token is a tool token, then the tool token is added to the current output sequence to obtain a tool output sequence; and the tool invocation mechanism of the large language model is triggered to invoke the external mathematical tool corresponding to the tool token; the mathematical tool is a graph convolutional neural network; The input data is fed into the mathematical tool to obtain the prediction result; the input data includes the voltage waveform vectors and bus adjacency matrix of multiple buses in the current distribution network; The prediction result is converted into a text token sequence, and the text token sequence is added to the tool output sequence, then the process returns to S2; If the next output token is a regular token, then add the regular token to the current output sequence and return to S2.

[0005] According to the specific embodiments provided in this application, this application has the following technical effects: This application provides a power system state estimation method based on a large language model. By changing the user question and the system's preset prompts, the input sequence is adjusted to adapt to complex and varied tasks, improving the adaptability of this application. By calling external mathematical tools, task-specific complex calculations can be performed, giving this application powerful natural language understanding and generation capabilities, enabling it to solve problems in specialized domains. Furthermore, by adding new tool tokens and their corresponding external mathematical tools, more types of computational or analytical tasks can be supported. In addition, by utilizing a finely tuned large language model combined with the prediction results of external mathematical tools, the accuracy of the final state estimation is further improved. In summary, this application can achieve intelligent, accurate, and universal power system state estimation. Attached Figure Description

[0006] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0007] Figure 1 This is an application environment diagram of a power system state estimation method based on a large language model in one embodiment of this application; Figure 2 A schematic diagram illustrating the basic structure of a power system state estimation method based on a large language model, provided in an embodiment of this application, in which the large language model learns to use external mathematical tools; Figure 3 A schematic diagram of the basic structure of a graph convolutional neural network with multiple physical constraints in a power system state estimation method based on a large language model provided in an embodiment of this application; Figure 4 A schematic diagram of the basic structure of an improved graphical convolutional neural network that incorporates Gaussian process regression in a power system state estimation method based on a large language model, provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0008] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0009] To make the objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0010] The power system state estimation method based on a large language model provided in this application can be applied to, for example... Figure 1 The application environment shown is illustrated. Terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be set up independently, integrated into server 104, or placed in the cloud or on another server. Terminal 102 can send the data to be input to server 104. After receiving the data, server 104 obtains the input sequence based on the user question and preset system prompts, and initializes the current output sequence. Based on the input sequence and the current output sequence, it uses a fine-tuned large language model to determine the next output token. If the next output token is a preset end token, the final result of the distribution network state estimation is obtained based on the current output sequence. If the next output token is a tool token, it is added to the current output sequence to obtain a tool output sequence. The external mathematical tool corresponding to the tool token is then called. The input data is input into the mathematical tool to obtain a prediction result. The prediction result is converted into a text token sequence and added to the tool output sequence, and the process returns to the previous step. If the next output token is a regular token, it is added to the current output sequence and the process returns to the previous step.

[0011] The terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The server 104 can be implemented using a standalone server or a server cluster composed of multiple servers, or it can be a cloud server.

[0012] In one exemplary embodiment, such as Figure 2 As shown, a power system state estimation method based on a large language model is provided. This method is executed by a computer device, specifically by a terminal or server alone, or by both a terminal and a server. In this embodiment, the method is applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps S1 to S3. Wherein: S1. Based on the user question "Estimate the state of the current distribution network based on the input data" and the preset system prompt "You are an artificial intelligence assistant, assisting me in solving problems by calling external tools", obtain the input sequence and initialize the current output sequence.

[0013] S2. Based on the input sequence and the current output sequence, calculate the conditional probability distribution of the next output token using a fine-tuned large language model, and determine the next output token according to the conditional probability distribution of the next output token. The large language model includes a regular token embedding matrix and a preset tool token embedding matrix. Specifically, the token with the highest probability is determined according to the conditional probability distribution of the next output token, and this token is the next output token. A token is the basic unit of text processing and can be a word, a punctuation mark, a number, or any other character.

[0014] S3. If the next output token is a preset end token, then the final result of the distribution network state estimation is obtained based on the current output sequence.

[0015] If the next output token is a tool token, then the tool token is added to the current output sequence to obtain a tool output sequence; and the tool invocation mechanism of the large language model is triggered to invoke the external mathematical tool corresponding to the tool token; the mathematical tool is a graph convolutional neural network. This application uses the function_call function in the large language model to call and execute the tool function with the corresponding name to invoke the external mathematical tool corresponding to the tool token.

[0016] The input data is fed into the mathematical tool to obtain the prediction result; the input data includes the voltage waveform vectors of multiple buses in the current distribution network and the bus adjacency matrix.

[0017] The prediction result is converted into a text token sequence, and the text token sequence is added to the tool output sequence, and then the process returns to S2.

[0018] If the next output token is a regular token, then add the regular token to the current output sequence and return to S2.

[0019] Perform steps S1 to S3 as described above, such as Figure 2 The process involves constructing an input sequence based on the user's question and preset system prompts, and initializing an empty current output sequence. =[], determine the next output token based on the input sequence and the current output sequence, and determine the type of the next output token. If it is a terminator token, the loop ends; if it is a regular token, such as "OK", then the normal mode is implemented and it is appended to the current output sequence. =["OK"], and use the large language model to determine the next output token, up to the output tool token; if it is a tool token, such as "[TOOL_PowerEstimate]", then implement the tool pattern and append "[TOOL_PowerEstimate]" to the current output sequence. =[TOOL_PowerEstimate], and call the external mathematical tool corresponding to the tool token to obtain the voltage amplitude of bus 1 as 0.9 pu, the voltage amplitude of bus 2 as 0.93 pu, and so on. Finally, combining the outputs of the tool mode and the normal mode, the large language model is used for adjustment to obtain the final output. In summary, this application can achieve intelligent, accurate, and generalized power system state estimation. This application aims to empower the large language model (LLM) with the ability to perceive the real physical world by teaching it to use specific tools, while also ensuring that the LLM can use tools to solve complex power system state estimation problems without large-scale fine-tuning and retraining. The role of the tool is to return some results, which can help the LLM obtain structured data that is easy to use and generate the final professional-grade text results. The LLM is trained on massive text data based on deep learning technology, that is, it learns how to predict the next token based on the previous token. The LLM can be represented as: .

[0020] Where Output is the output of the large language model, LLM is the large language model itself, Prompt is the system-preset prompt word, and θ is the parameters of the large language model. The goal of the large language model is to minimize the difference between the predicted token and the true token. This can be achieved by defining an appropriate loss function L and applying gradient descent to update the parameters θ. .in, For the updated large language model parameters, These are the parameters of the large language model before updating, where η represents the learning rate. This represents the gradient of the loss function L with respect to the parameters θ of the large language model.

[0021] Typically, large language models will use token sequences. s =( t 1, t 2,..., t g The conditional probability distribution of ) is modeled as P ( s )=Σ i g P ( t i | t <i Each token comes from the vocabulary of a large language model, i.e. t <i , t i ∈ ν Let g represent the sequence of tokens preceding the i-th token, where g is the number of tokens.

[0022] In practical applications, users typically set sequential prompts to guide the language model in generating the required content, such as answering questions. Specifically, the conditional probability distribution of the next token is... P ( t i | t <i )= softmax ( W v · h i-1 ),in, h i-1 ∈R d This is the last hidden state in the current context. W v ∈R |v|×dis the embedding matrix for ordinary tokens, v is the number of ordinary tokens, and d is the dimension of the embedding vector corresponding to each ordinary token, which is the length of the output vector. This parameter is manually specified and is set to 1024 in this application.

[0023] Given a set of useful tools τ ={ τ 1, τ 2,...}, where, τ 1 is the first tool. τ 2 represents the second tool. The core idea of ​​the tool invocation mechanism is to explicitly represent the tool as a special type of token, namely, the tool token. Each token associated with a tool invocation is parameterized as a tool token embedding vector, which can also be represented as a matrix, i.e. W τ ∈R |τ|×d This framework allows LLMs to uniformly consider both ordinary word tokens and tokens related to tool calls. Specifically, the conditional probability distribution of the next output token is determined using the following formula: .

[0024] in, For probability, Let i be the i-th token output, where i is the token's index. For all tokens preceding the i-th token, To convert the numerical values ​​in a vector into a function of a probability distribution, Embedding a matrix for ordinary tokens, The number of ordinary tokens, The preset tool token is embedded in the matrix. The number of tool tokens, Let be the hidden state vector before generating the i-th Token. The next Token can be either a regular Token or a utility Token, i.e. t i ∈ v ∪ τ , [;] represents the join operation.

[0025] Therefore, this application can quickly adapt to new tools by easily extending the ordinary token embedding matrix with only minimal fine-tuning during training. This is because the framework preserves the original LLM parameters and introduces minimal additional training overhead with the tool token embedding matrix. The tool token embedding matrix only contains the parameters that need optimization, without adjusting the gradients of the main body of the LLM parameters, thus making training more stable and efficient.

[0026] In another exemplary embodiment of this application, in order to enhance the success rate and stability of LLM tool calls, the large language model is fine-tuned twice before S1.

[0027] Among them, based on the historical input sequence, the large language model is fine-tuned for the first time using the following formula: .

[0028] in, For the loss function of a large language model, This is the weight matrix of the large language model. For a dataset that includes multiple historical input sequences, This represents the number of tokens in the historical input sequence. This is the sequence number of the token in the historical input sequence. For probability, The first in the sequence after incorporating the tool token Each Token For the first All tokens prior to this one.

[0029] The large language model is fine-tuned a second time using the following formula to obtain the fine-tuned large language model: . .

[0030] in, This is the final result of the large language model for estimating the state of the distribution network. For large language models, The preset system prompt words, For user issues, The results are used to evaluate the final results of the large language model for power distribution network state estimation. To evaluate the generated predictions, the invention uses a manually defined approach, assigning a score, reason, and suggestion to each prediction and outputting the evaluation results. Furthermore, a "+" sign indicates the concatenation of two strings. Unlike numerical gradients, which utilize the chain rule in traditional automatic differentiation methods to improve system performance relative to the objective function by calculating numerical gradients, textual gradients generate feedback in text form to guide modifications to unstructured variables in the system. They provide specific suggestions for improvement to enhance system performance relative to the objective function, rather than calculating numerical gradients. The backpropagation algorithm for textual gradients can be represented as follows: .

[0031] .

[0032] .

[0033] in, For the gradient of the large language model, The updated preset system prompt words, This is an update operation in the text gradient algorithm. Return a pair Evaluation, Return an evaluative feedback to the user's question, such as "The power system state estimation results can be obtained by calling..."<power system state estimation> The feedback, described as "tool improvement," explains how to adjust variables to optimize the entire system for the objective function, similar to numerical gradient methods. The function returns the user questions necessary to ensure stable invocation of mathematical tools by the LLM. Furthermore, the optimization function employs Text Gradient Descent (TGD) and utilizes evaluation feedback to update the prompts.

[0034] In another exemplary embodiment of this application, physical information is used to constrain the graph convolutional neural network. Specifically, the graph in the graph convolutional neural network is constructed as G=(V,A). V ={ v 1,..., v N} is the vertex set. v 1 is the first vertex. v N For the Nth vertex, where A ∈R n×n This is a bus adjacency matrix, where N represents the number of vertices, i.e., the number of network buses. Each vertex in the graph... v N From d-dimensional voltage waveform vector x n ∈R d Description. The entire voltage waveform matrix. X ∈R N×d Stack the N voltage waveform vectors vertically, that is X =[ x 1, x 2,..., x N ] T . D = diag ( m 1, m 2,..., m N ) is a degree matrix, wherem n =Σ j A nj , represents the degree of the current bus n, that is, the number of edges connected to the node n, which is the sum of the nth row of the adjacency matrix. y i ∈ Y Let represent the label of the i-th network path. Graph convolution operation can be defined as: .

[0035] in, g Here is the filter function. θ It is a non-linear activation function. I It is the identity matrix. This is the bus voltage waveform matrix of the distribution network. This is the bus voltage waveform vector. For degree matrix, This is the adjacency matrix of the busbars.

[0036] The implicit features of a vertex are calculated by averaging the features of its neighboring vertices. This operation effectively reflects the physical characteristics of electricity propagation in a network; that is, based on the actual physical topology of the power grid, with each round of graph convolution, the relevant bus can obtain feature information from buses farther away, according to the increasing number of convolutional layers. The specific calculation method is as follows: .

[0037] Where σ(·) is the sigmoid function, For the first Hierarchical implicit features. This is the index of the layer number in a graph convolutional neural network. For degree matrix, This is the adjacency matrix of the busbars. It is the first Layer weight matrix, For the first Hierarchical implicit features. This is the modified degree matrix. To add self-loops to the adjacency matrix, As a self-loop, after processing with a normalization layer, we can obtain... H (l) =[ h 1 (l) , h 2 (l) ,..., h n (l) ], as an implicit feature of layer l, hn (l) It is an implicit characteristic of bus n.

[0038] In summary, inputting the input data into the mathematical tool to obtain the prediction result specifically includes: Based on the input data, the formula is used. The implicit features in the graph convolutional neural network are obtained.

[0039] Based on the aforementioned implicit features, the formula is adopted. The prediction results were obtained; among them, H pre The prediction result is represented by softmax(), which is the activation function.

[0040] In another exemplary embodiment of this application, in order to improve the performance of the graph convolutional neural network, before S1, the method further includes: optimizing the graph convolutional neural network based on the historical input sequence using the following formula: .

[0041] in, The loss function for a graph convolutional neural network, As the first weighted parameter, The second weighting parameter, As the third weighting parameter, , , ∈[0,1], this application takes =0.2, =1, =0.8.

[0042] The loss function is guided by mutual information based on historical input sequences. The reconstruction loss function is based on the historical input sequence. This is a contrastive loss function based on historical input sequences.

[0043] In another exemplary embodiment of this application, in order to reduce data redundancy, the mutual information guided loss function based on the historical input sequence is determined using the following formula: .

[0044] .

[0045] .

[0046] in, The loss function is guided by mutual information based on historical input sequences. The final implicit characteristic of the b-th bus in the historical distribution network Tag of bus b in the historical distribution network Mutual information between them The Shannon entropy of the b-th bus in the historical distribution network. Let H(Y) be the cross-entropy loss, Y be the label set, P(Y) be the probability distribution of each label in the label set, and H(Y) be the Shannon entropy of each label in the label set. Let the final implicit feature of the b-th bus be the expectation of the label of the b-th bus. Let be the conditional probability of the final implicit feature of the b-th bus and the label of the b-th bus.

[0047] In another exemplary embodiment of this application, in order to enhance the generalization of the graph convolutional neural network, this application maximizes the final implicit features. With initial implicit features Mutual information between

[0048] To complete, It can be calculated using the following formula: .

[0049] in, For joint entropy, For conditional joint entropy, This is an intermediate process for calculating mutual information. The purpose of performing mutual information analysis on implicit features is to measure whether the implicit features closely approximate the original input data, i.e., whether any original information has been lost. Therefore, a reconstruction loss function can be used to calculate... The reconstruction loss function based on the historical input sequence is determined using the following formula: .

[0050] .

[0051] .

[0052] in, The implicit feature matrix of the historical input sequence. To reconstruct the bus adjacency matrix, The implicit feature matrix of the historical input sequence Under the condition of reconstructing the bus adjacency matrix The probability of; This represents the connection between bus u and bus v in the bus adjacency matrix of the historical input sequence. This is an implicit characteristic of the busbar u. Let v be an implicit characteristic of busbar v, and n be the number of buses. Given the implicit characteristics of bus u and bus v, this represents the probability of the connection between bus u and bus v in the bus adjacency matrix. To reconstruct the loss function, This represents the expected probability distribution of the implicit characteristic matrix under the conditions of the bus voltage waveform matrix and the bus adjacency matrix in the distribution network.

[0053] In another exemplary embodiment of this application, the contrastive loss function based on the historical input sequence is determined using the following formula: .

[0054] in, The contrastive loss function is based on the historical input sequence. z e = h e , which is the implicit feature of the bus e in the historical input sequence. This represents the average of implicit features with the same label. K This represents the number of unlabeled historical input sequences. k The index of the unlabeled historical input sequence. As a control parameter used to control the sharpness of the probability distribution, this application sets it to 0.1. For the first k Implicit features of an unlabeled historical input sequence.

[0055] Contrastive learning keeps different historical input sequences far apart in the feature space, while similar historical input sequences are brought close together. This optimizes the learning performance of graph convolutional neural networks on finite labeled training datasets.

[0056] like Figure 3 As shown, the voltage waveform vectors and bus adjacency matrices of multiple buses in the distribution network are used as inputs to a graph convolutional neural network. By utilizing a graph convolutional neural network with multiple physical constraints, the state estimation of the power system is realized, while improving the robustness of the graph convolutional neural network.

[0057] In another exemplary embodiment of this application, to address changes in distribution network topology, a Gaussian process is used to improve the graph convolutional neural network. The improved graph convolutional neural network structure after introducing Gaussian process regression is as follows: Figure 4 As shown.

[0058] The key idea is to solve the graph convolutional neural network combinatorial problem by assigning weights to the final results of distribution network state estimation under different topology types. This can be modeled as: or .

[0059] Where S represents the number of historical distribution network topology types, and r represents the index of the historical distribution network topology types. The following diagram shows the set of historical input sequences for the convolutional neural network, representing the r-th historical distribution network topology type, where ε is zero-mean Gaussian noise. w r For the first r The model parameter weights are defined for each distribution network topology type, and y represents the final state estimation result under the changed distribution network topology type. f (·) represents a graph convolutional neural network model trained under a specific distribution network topology. Let m(x) represent a Gaussian process following a Gaussian distribution with zero mean because no prior knowledge is available. k(x,x') is the covariance function, representing the correlation between any two input points x and x'. The Gaussian process is determined by the mean function. m ( x ) = E [ f ( x )] and covariance function k ( x , x' ) = cov ( f ( x ), f ( x' )) Common definition.

[0060] To achieve accurate estimation of distribution network status using only scarce data under new distribution network topology types, this application proposes to improve the distribution network topology by... β The data obtained below and the distribution network topology type α Historical data samples are combined to expand the amount of training data. Then, a specific kernel function capable of cross-task transfer is employed to find relevant patterns in samples under different distribution network topology types. Specifically, the covariance function consists of two parts, calculated as follows: .

[0061] in, For distribution network topology types α Calculate two points and The covariance function of the similarity between them. For distribution network topology types α The next data sample, For distribution network topology types β The next data sample, For distribution network topology types β Calculate two points and The covariance function of the similarity between them.

[0062] C This represents a positive semi-definite matrix, indicating the correlation between two different distribution network topologies. Taking this application as an example... C For a 2x2 matrix: .

[0063] in, C 11 Distribution network topology type α The feature variance of the training dataset itself, C 22 Distribution network topology type β The feature variance of the training dataset itself, C 12 Representative distribution network topology type α The covariance between the training datasets C 21 Representative distribution network topology type β The covariance between the training datasets. This can also be generalized to a single dataset if multiple distribution network topology types exist. S * S 3D matrix, i.e. S The correlation matrix for different distribution network topology types is calculated as follows: .

[0064] in, Distribution network topology type S The feature variance of the training dataset itself, The feature covariance between the datasets for distribution network topology type 1 and distribution network topology type S. The feature covariance between the datasets for distribution network topology type 2 and distribution network topology type S. The feature covariance between the datasets for distribution network topology type S and distribution network topology type 1. Let be the feature covariance between the datasets for distribution network topology type S and distribution network topology type 2.

[0065] also, k β (·,·) is the exponential quadratic kernel function, and its calculation method is shown below: .

[0066] in, σ f For signal variance, M=l 2I It is a positive definite matrix. l For length scale parameters, I The identity matrix is ​​a Gaussian kernel hyperparameter manually set during the training of the graph convolutional neural network model. It is used to regulate the overall variation of the data and to control the importance of features in each dimension of the input feature space by scaling the distance between input observation points. σ f In this invention, the value is 1. l The smoothness of the function variation is controlled by a value of 0.1 in this application. When in the distribution network topology type... β New observations were obtained. x * The final predicted values ​​under the new topology are shown below: .

[0067] in, Indicates the distribution network topology type β The average of the forecasts is the final forecast value; X β Indicates the type of distribution network topology β The following training samples; Indicates the Kronecker product; c β Representation matrix C The second column (in the case of only two types of topology); D This represents a 2×2 diagonal matrix, which typically contains artificially set mean Gaussian noise information; k ( · , · ) is the kernel function.

[0068] The advantages of this application are as follows: This application designs a tool token that differs from ordinary tokens and builds a jump architecture based on a function calling mechanism. This architecture enables LLM to call mathematical tools, giving LLM the ability to utilize mathematical tools. Furthermore, traditional machine learning models are essentially text prediction tools and cannot truly reflect the physical state of the power system. This application constructs a graph convolutional neural network with physical guidance mechanisms such as a mutual information-guided loss function based on historical input sequences, a reconstruction loss function based on historical input sequences, and a contrastive loss function based on historical input sequences. In addition, given that the topology of actual distribution networks is in a continuously dynamically changing state, this application uses Gaussian process regression to implement combined weighting of the model output under each topology, thereby giving the graph convolutional neural network model the ability to cope with dynamic topology changes.

[0069] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O 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, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores input data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a power system state estimation method based on a large language model.

[0070] Those skilled in the art will understand that Figure 5 The structures shown are merely block diagrams of some structures related to the present application and do 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 shown in the figures, or combine certain components, or have different component arrangements. In an exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0071] 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 specification.

[0072] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as limiting this application.

Claims

1. A power system state estimation method based on a large language model, characterized in that, The method includes: S1. Based on the user question "Estimate the state of the current distribution network based on the input data" and the preset system prompt "You are an AI assistant that helps me solve problems by calling external tools", obtain the input sequence and initialize the current output sequence; S2. Based on the input sequence and the current output sequence, calculate the conditional probability distribution of the next output token using a fine-tuned large language model, and determine the next output token according to the conditional probability distribution of the next output token; the large language model includes a regular token embedding matrix and a preset tool token embedding matrix. S3. If the next output token is a preset end token, then the final result of the distribution network state estimation is obtained based on the current output sequence. If the next output token is a tool token, then the tool token is added to the current output sequence to obtain a tool output sequence; and the tool invocation mechanism of the large language model is triggered to invoke the external mathematical tool corresponding to the tool token; the mathematical tool is a graph convolutional neural network; The input data is fed into the mathematical tool to obtain the prediction result; the input data includes the voltage waveform vectors and bus adjacency matrix of multiple buses in the current distribution network; The prediction result is converted into a text token sequence, and the text token sequence is added to the tool output sequence, then the process returns to S2; If the next output token is a regular token, then add the regular token to the current output sequence and return to S2; The conditional probability distribution of the next output token is determined using the following formula: ; in, For probability, Let i be the i-th token output, where i is the token's index. For all tokens preceding the i-th token, To convert the numerical values ​​in a vector into a function of a probability distribution, Embedding a matrix for ordinary tokens, The number of ordinary tokens, The preset tool token is embedded in the matrix. The number of tool tokens, Let be the hidden state vector before the generation of the i-th Token; Before S1, the process also includes: fine-tuning the large language model for the first time based on historical input sequences using the following formula: ; in, For the loss function of a large language model, This is the weight matrix of the large language model. For a dataset that includes multiple historical input sequences, This represents the number of tokens in the historical input sequence. This is the sequence number of the token in the historical input sequence. For probability, The first in the sequence after incorporating the tool token Each Token For the first All tokens prior to this token; The large language model is fine-tuned a second time using the following formula to obtain the fine-tuned large language model: ; ; ; ; ; in, This is the final result of the large language model for estimating the state of the distribution network. For large language models, The preset system prompt words, For user issues, The results are used to evaluate the final results of the large language model for power distribution network state estimation. For the purpose of evaluating instructions, For the gradient of the large language model, The updated preset system prompt words, This is an update operation in the text gradient algorithm.

2. The power system state estimation method based on a large language model according to claim 1, characterized in that, The input data is fed into the mathematical tool to obtain the prediction result, specifically including: Based on the input data, the formula is used. The implicit features in the graph convolutional neural network are obtained; among them, For the first Hierarchical implicit features. This is the index of the layer number in a graph convolutional neural network. For degree matrix, This is the adjacency matrix of the busbars. It is the first Layer weight matrix, For the first Hierarchical implicit features. This is the modified degree matrix. To add self-loops to the adjacency matrix, It is a self-loop; Based on the aforementioned implicit features, the formula is adopted. The prediction results were obtained; among them, H pre The prediction result is represented by softmax(), which is the activation function.

3. The power system state estimation method based on a large language model according to claim 1, characterized in that, Before S1, the process also includes: optimizing the graph convolutional neural network based on the historical input sequence using the following formula: ; in, The loss function for a graph convolutional neural network, As the first weighted parameter, The second weighting parameter, As the third weighting parameter, The loss function is guided by mutual information based on historical input sequences. The reconstruction loss function is based on the historical input sequence. This is a contrastive loss function based on historical input sequences.

4. The power system state estimation method based on a large language model according to claim 3, characterized in that, The mutual information-guided loss function based on historical input sequences is determined using the following formula: ; ; ; in, The loss function is guided by mutual information based on historical input sequences. The final implicit characteristic of the b-th bus in the historical distribution network Tag of bus b in the historical distribution network Mutual information between them The Shannon entropy of the b-th bus in the historical distribution network. Let H(Y) be the cross-entropy loss, Y be the label set, P(Y) be the probability distribution of each label in the label set, and H(Y) be the Shannon entropy of each label in the label set. Let the final implicit feature of the b-th bus be the expectation of the label of the b-th bus. Let be the conditional probability of the final implicit feature of the b-th bus and the label of the b-th bus.

5. The power system state estimation method based on a large language model according to claim 3, characterized in that, The reconstruction loss function based on the historical input sequence is determined using the following formula: ; ; ; in, The implicit feature matrix of the historical input sequence. To reconstruct the bus adjacency matrix, The implicit feature matrix of the historical input sequence Under the condition of reconstructing the bus adjacency matrix The probability of; This represents the connection between bus u and bus v in the bus adjacency matrix of the historical input sequence. This is an implicit characteristic of the busbar u. Let v be an implicit characteristic of busbar v, and n be the number of buses. Given the implicit characteristics of bus u and bus v, this represents the probability of the connection between bus u and bus v in the bus adjacency matrix. To reconstruct the loss function, This represents the expected probability distribution of the implicit characteristic matrix under the conditions of the bus voltage waveform matrix and the bus adjacency matrix in the distribution network.

6. The power system state estimation method based on a large language model according to claim 3, characterized in that, The contrastive loss function based on the historical input sequence is determined using the following formula: ; in, The contrastive loss function is based on the historical input sequence. z e = h e The implicit feature of the bus e in the historical input sequence. This represents the average of implicit features with the same label. K Number of unlabeled historical input sequences ,k The index of the unlabeled historical input sequence. For control parameters, For the first k Implicit features of an unlabeled historical input sequence.

7. The power system state estimation method based on a large language model according to claim 1, characterized in that, The method further includes: when the distribution network topology type changes, based on the historical distribution network topology type, using the following formula to obtain the final state estimation result under the changed distribution network topology type; ; Where S represents the number of historical distribution network topology types, and r represents the index of the historical distribution network topology types. Let y be the set of historical input sequences of the convolutional neural network for the r-th historical distribution network topology type shown in the figure below, where ε is zero-mean Gaussian noise and y is the final state estimation result under the changed distribution network topology type. Let m(x) represent a Gaussian process that follows a GP distribution, where m(x) has zero mean and k(x,x') is the covariance function, representing the correlation between any two input points x and x'.

Citation Information

Patent Citations

  • Voltage sag evaluation method based on graph convolutional neural network

    CN117592825A

  • Cost-aware efficient tool planning method based on large model

    CN120542481A