Power system digital twin interaction method and system based on large language model

By applying a large language model to generate basic components and topology codes in a power system simulation platform, and combining it with a multi-agent system, the problem of insufficient performance of traditional simulation platforms in new power systems is solved, and automated and efficient simulation modeling is achieved.

CN119442853BActive Publication Date: 2025-12-05TSINGHUA UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411447582.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-12-05
Estimated Expiration
2044-10-16

AI Technical Summary

Technical Problem

Traditional simulation platforms require a great deal of expertise and human resources to build and maintain new power systems, making it difficult to meet their complexity and high-efficiency requirements.

Method used

By adopting a large language model to access the power system simulation platform, and generating basic components, topology relationship codes, and multi-agent systems, automated component generation and interactive operation are achieved.

Benefits of technology

It reduces the need for specialized knowledge and manpower, improves the efficiency and automation level of the new power system simulation platform, and meets the modeling needs of complex systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119442853B_ABST
    Figure CN119442853B_ABST
Patent Text Reader

Abstract

The application provides a power system digital twin interaction method and system based on a large language model, which comprises the following steps: connecting the large language model to a simulation platform of a power system to perform a basic element generation task of the simulation platform; generating an element code based on a topological relationship by using the large language model according to a simulation model of the digital twin; the digital twin comprises a plurality of basic elements; and constructing a multi-agent system based on the large language model to perform interaction of the simulation model of the digital twin by using the multi-agent system. The application applies the large language model to the simulation interaction of a new type of power system digital twin, utilizes the processing capacity of natural language text of the large language model, and performs basic element generation, topological relationship code generation and intelligent interaction operation relying on the simulation platform, so that the demand of the new type of power system can be met, and the application has important theoretical and practical significance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power system technology, and in particular to a power system digital twin interaction method and system based on a large language model. Background Technology

[0002] In the field of power system research, power system simulation is a key tool for ensuring the stability and reliability of the power grid. Simulation platforms provide crucial support for the design, planning, operation, and fault diagnosis of power systems. By simulating various operating conditions, researchers can calculate the steady-state characteristics of the system, simulate different types of faults, and infer the impact of power system upgrades, thereby ensuring the stability and reliability of the power grid. With the continuous development of new power systems, their diverse components, high proportion of renewable energy, and significant component differences pose challenges to their simulation and modeling. The emergence of digital twin technology has placed higher demands on the modeling of new power systems. How to automatically process large amounts of measurement data to maintain the digital twin of the power system is a key focus in the research of new power system modeling. Faced with increasingly complex system structures, the construction and maintenance of traditional simulation platforms typically require significant investment of professional knowledge and human resources, and their efficiency is insufficient to meet the needs of new power systems. Summary of the Invention

[0003] This invention provides a method and system for digital twin interaction in power systems based on a large language model. It addresses the shortcomings of existing simulation platforms, which typically require significant investment of specialized knowledge and human resources for construction and maintenance, resulting in performance insufficient to meet the needs of modern power systems. This invention applies a large language model to the simulation interaction of digital twins in modern power systems. Leveraging the natural language text processing capabilities of the large language model, it utilizes the simulation platform to generate basic components, generate topology relationship codes, and perform intelligent interactive operations. This approach meets the requirements of modern power systems and has significant theoretical and practical implications.

[0004] This invention provides a method for interaction between a power system digital twin based on a large language model, comprising: connecting the large language model to a power system simulation platform to execute a basic component generation task of the simulation platform; generating component code based on topology relationships using the large language model according to the simulation model of the digital twin; the digital twin including multiple basic components; and constructing a multi-agent system based on the large language model to interact with the simulation model of the digital twin using the multi-agent system.

[0005] According to the present invention, a method for interactive digital twins of power systems based on a large language model is provided. The method involves connecting the large language model to a power system simulation platform to execute the basic component generation task of the simulation platform. This includes: inputting the return result of a program interface call of the power system simulation platform to the large language model to obtain a component document output by the large language model; the return result is a logical description of the basic components in the simulation platform obtained through a query on the simulation platform; the component document represents the logic and functional understanding information of the large language model for the basic components of the simulation platform; inputting the component document and basic component generation prompts to the large language model to obtain the attributes of the component parameters, the attributes of the component pins, and the component logic function code output by the large language model; the basic component generation prompts include component generation examples generated based on a Few-shot algorithm.

[0006] According to the present invention, a power system digital twin interaction method based on a large language model is provided. The generation process of the component logic function code includes: determining the logic function to be evaluated generated by the large language model based on the attributes of the component parameters and the attributes of the component pins; performing static code checking and feedback on the logic function to be evaluated to obtain syntactically correct function code; performing differential logic testing on the syntactically correct function code, and using the logically correct function code as the component logic function code.

[0007] According to the present invention, a power system digital twin interaction method based on a large language model is provided. The step of generating topology-based component codes using the large language model based on the simulation model of the digital twin includes: determining topology code generation prompts through the program interface of a power system simulation platform based on the simulation model of the digital twin; the topology code generation prompts include a logical description of the simulation model of the digital twin, multiple basic components, and the topology relationships between the basic components; inputting the topology code generation prompts into the large language model to obtain the topology-based component codes output by the large language model.

[0008] According to the present invention, a power system digital twin interaction method based on a large language model is provided. The step of determining topology relationship codes and generating prompt words based on the simulation model of the digital twin and through the program interface of the power system simulation platform includes: obtaining the component connection line relationships of the simulation model of the digital twin through the program interface of the power system simulation platform; dividing the pins of all basic components in the simulation model of the digital twin into several interconnected pin groups according to the component connection line relationships; each pin group includes one output pin and several input pins; the pin group is used to characterize the pin name and the connection relationship between the pins; and determining the topology relationship codes and generating prompt words based on several of the pin groups.

[0009] According to the present invention, a power system digital twin interaction method based on a large language model is provided. The step of generating component codes based on topological relationships using the large language model according to the simulation model of the digital twin includes: obtaining the composition and topological structure of multiple basic components in the simulation model of the digital twin through the program interface of the power system simulation platform; obtaining component codes based on the topological relationships by chaining logic according to a preset topological order using the large language model based on the topological structure; wherein the chaining logic is achieved by the large language model sequentially generating basic component logic codes according to the preset topological order, and synthesizing the logic code of the current basic component with the logic codes of several previously generated basic components.

[0010] According to the present invention, a power system digital twin interaction method based on a large language model is provided. The method involves constructing a multi-agent system based on the large language model to interact with the simulation model of the digital twin. The method includes: constructing an agent system comprising administrator agents and non-administrator agents based on the large language model; the non-administrator agents comprising a task planning agent, a simulation platform operation agent, a location agent, and an analysis agent; the administrator agent determining which non-administrator agent to speak based on a finite state machine, combined with the capabilities and applicable scenarios of each non-administrator agent; the finite state machine characterizing the state transitions of the multi-agent system; the task planning agent generating specific execution steps based on user natural language descriptions; the user natural language description representing the operation instructions performed on the simulation model of the digital twin; the simulation platform operation agent completing the actual operation of the simulation platform according to the specific execution steps; the location agent locating target components according to the operation instructions; and the analysis agent understanding the logical functions of the target components and the simulation model, providing decision-making or answering user questions.

[0011] According to the present invention, a digital twin interaction method for power systems based on a large language model is provided, wherein the multi-agent system directly generates and executes the calling code for the program interface of the simulation platform based on the retrieval enhancement generation algorithm and the long context characteristics.

[0012] The present invention also provides a power system digital twin interaction system based on a large language model, comprising: a first generation module for connecting the large language model to a power system simulation platform to perform a basic component generation task of the simulation platform; a second generation module for generating component code based on topology relationships using the large language model according to the simulation model of the digital twin; the digital twin includes multiple basic components; and an interaction module for constructing a multi-agent system based on the large language model to interact with the simulation model of the digital twin using the multi-agent system.

[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the power system digital twin interaction method based on a large language model as described above.

[0014] This invention provides a method and system for interaction of digital twins in power systems based on a large language model. The method includes: connecting a large language model to a power system simulation platform to execute the basic component generation task of the simulation platform; generating component codes based on topological relationships using the large language model according to the simulation model of the digital twin; the digital twin includes multiple basic components; and constructing a multi-agent system based on the large language model to interact with the simulation model of the digital twin. This invention applies a large language model to the simulation interaction of digital twins in novel power systems, utilizing the natural language text processing capabilities of the large language model and relying on the simulation platform for basic component generation, topological relationship code generation, and intelligent interactive operations. This can meet the needs of novel power systems and has significant theoretical and practical implications. Attached Figure Description

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

[0016] Figure 1 This is a flowchart illustrating a power system digital twin interaction method based on a large language model provided by the present invention.

[0017] Figure 2This is a schematic diagram of the structure of a power system digital twin interactive system based on a large language model, provided by the present invention.

[0018] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0020] With the continuous development of new power systems, the high proportion of new energy sources, small unit capacity, large differences in components, and the wide variety of simulation components make the modeling process and data processing more complex. Faced with increasingly complex system structures, the construction and maintenance of traditional simulation platforms typically require a large investment of professional knowledge and human resources, and their efficiency is insufficient to meet the needs of new power systems.

[0021] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a power system digital twin interaction method based on a large language model, provided by the present invention.

[0022] This invention provides a method for digital twin interaction in power systems based on a large language model, comprising:

[0023] 101: Integrate the large language model into the power system simulation platform to perform the basic component generation task of the simulation platform;

[0024] 102: Based on the simulation model of the digital twin, use a large language model to generate component codes based on topological relationships; the digital twin includes multiple basic components;

[0025] 103: Construct a multi-agent system based on a large language model to enable interaction between simulation models of digital twins using the multi-agent system.

[0026] With the development of natural language processing, large-scale language models trained using natural language have attracted considerable attention. Due to the significant increase in model size and training data volume, large language models possess capabilities exceeding those of previous machine learning models in learning, generation, reasoning, and planning. Because of the large amount of training data, large language models exhibit certain versatility; that is, pre-trained models can handle a wide range of tasks. The ChatGPT software, designed for general users, is an application based on large language models. Since it does not require the collection of specific datasets or a training process, large language models are widely used in natural science research, power system maintenance applications, and content generation tasks. This invention applies large language models to the simulation interaction of a novel power system digital twin. Utilizing its natural language text processing capabilities and relying on the CloudPSS platform, it attempts to perform component generation, code generation, and intelligent interactive operations.

[0027] The CloudPSS simulation platform is one of the aforementioned power system simulation platforms. Based on simulation components and models, CloudPSS allows researchers to build simulation models of real-world power systems through component combinations and code writing. The CloudPSS platform supports various computational tasks, such as steady-state power flow calculations and electromagnetic transient simulations, to obtain simulation data for different application scenarios.

[0028] Specifically, this invention integrates a large language model into the CloudPSS platform to perform simple generation tasks. For example, it uses a few-shot generation method to generate simple component documents and component code. Then, based on the simulation model of the digital twin, it uses the topological relationship information between the basic components of the large language model to generate component code based on the topological relationships. Finally, it constructs a multi-agent system based on the large language model to enable interaction with the simulation model of the digital twin. For example, it constructs several agents related to power system simulation tasks and uses a finite state machine to model the system state. This invention can meet the needs of new power systems and has significant theoretical and practical implications.

[0029] In a preferred embodiment, a large language model is connected to a power system simulation platform to perform the basic component generation task of the simulation platform. This includes: inputting the return result of the program interface call of the power system simulation platform to the large language model to obtain the component document output by the large language model; the return result is the logical description of the basic component in the simulation platform queried through the simulation platform; the component document is used to characterize the logic and functional understanding information of the basic component of the simulation platform by the large language model; inputting the component document and basic component generation prompts to the large language model to obtain the attributes of the component parameters, the attributes of the component pins, and the component logic function code output by the large language model; the basic component generation prompts include component generation cases generated based on the Few-shot algorithm.

[0030] As a preferred embodiment, the process of generating component logic function code includes: determining the logic function to be evaluated by generating a large language model based on the attributes of component parameters and component pins; performing static code checking and feedback on the logic function to be evaluated to obtain syntactically correct function code; performing differential logic testing on the syntactically correct function code, and using the logically correct function code as the component logic function code.

[0031] Since the documentation for the CloudPSS platform's API (Application Programming Interface) is not included in the training data of the large language model (taking GPT as an example), it cannot understand content related to "CloudPSS". In this embodiment, it is not necessary for the large language model to learn the specific usage of the API; only the API call results need to be provided to the large language model. This leverages the generalization ability of the large language model, meaning that it possesses power system-related knowledge without training or fine-tuning, and it is not strongly coupled with the CloudPSS platform, allowing for migration to other simulation platforms at minimal cost. By directly providing the large language model with the component information of the simulation platform queried from CloudPSS, the large language model is guided to output its understanding of the logic and functions of the simulation platform and its basic components (component documentation).

[0032] In implementation, the large language model can provide a good logical summary document for simple components. However, it performs poorly for complex components composed of multiple components. Because the training data for the large language model consists of a large amount of text, it often fails to correctly understand graph structures. Listing relevant information for each component and connection line in the prompts is insufficient to establish a comprehensive understanding of the component graph by the large language model.

[0033] Simulation components in the CloudPSS platform can be broadly categorized into "electrical components" and "control components." The fundamental characteristic of control components is that both their input and output are control signals. Through signal analysis and computation, several control components can be combined to achieve complex control functions. Control components are widely used in electromagnetic transient analysis. This embodiment uses a text-formatted logic description document of the component as input. The large language model first generates the attributes of the component parameters and the attributes of the component pins, and then generates the component logic function code based on these attributes. Specifically, a Few-shot algorithm is used to add component generation examples to the basic component generation prompts to guide the format of the content generated by the large language model. Utilizing contextual learning capabilities, the large language model can master the attribute and pin definition formats in the examples to generate parameters and pins that conform to this format.

[0034] The component logic function code describes how the signals from its input pins are processed to obtain the signals from its output pins. This function code will be repeatedly called in electromagnetic transient simulations, taking in the component's input signal value, component parameters, current time, and other information at a given moment, and returning the component's output signal value. For each time step, this function will be called once to calculate the component's output for a given input signal value at the current time. Since the properties of the component parameters and component pins are already determined, the component logic function code can be obtained directly.

[0035] After the large language model generates the logic function to be evaluated, the correctness of the code can be further checked. If errors are found, the error information can be fed back to the large language model, and the code can be regenerated until the correct code is obtained. This embodiment uses a static code analysis tool, which can identify errors without running the code itself.

[0036] Furthermore, after obtaining syntactically correct function code, to determine whether the logic of the syntactically correct function code meets the requirements, this embodiment employs a differential logic test. For a single component, a set of candidate codes is generated using a large language model. Test data is obtained through random generation, and after local execution, the output differences of each candidate data are compared. A majority voting method is used to select the candidate code with the most identical outputs as the generated result. Due to the instability of the output results of the large language model, logical errors may occur. By comparing the results of multiple candidate codes, candidate codes with outlier results can be eliminated, thus allowing the logically consistent function code to be used as the component's logic function code.

[0037] It's worth noting that the CloudPSS platform provides a flexible application programming interface (API) for easy integration with other systems. It allows modification of project files, invocation of official algorithms, interface with actuators, and formatted message output. Using the API, simulation applications can be built quickly. The basic entities in the CloudPSS simulation platform are models. Each model represents a real-world physical entity, such as a motor, a substation, or a regional power distribution network. A model consists of several basic components. Once the pinout, specific parameter configuration, and internal logic of a simulation component are determined, a precise definition of that basic component can be given.

[0038] Adding other solution cases for the same task to the prompts can also improve model performance. These cases are called "Shots," and the Few-shot algorithm adds several cases to the prompts before guiding the large language model to generate the components. The Few-shot algorithm utilizes the generative capabilities of the large language model, taking natural language logical descriptions as input, to automatically generate control elements in the CloudPSS platform. Due to the large training dataset and model size of the pre-trained language model, its generality allows it to possess certain power system-related knowledge without requiring additional training or fine-tuning specific to the power sector. Simultaneously, the large language model's contextual learning ability can grasp the CloudPSS platform's definition specifications for component parameters and pins from the cases provided by the basic component generation prompts. This facilitates the application of the large language model to other simulation platforms. This embodiment demonstrates good generation results for basic control elements with simple logic.

[0039] As a preferred embodiment, generating topology-based component codes using a large language model based on the simulation model of the digital twin includes: determining topology code generation prompts through the program interface of the power system simulation platform based on the simulation model of the digital twin; the topology code generation prompts include a logical description of the simulation model of the digital twin, multiple basic components, and the topology relationships between the basic components; inputting the topology code generation prompts into the large language model to obtain the topology-based component codes output by the large language model.

[0040] In a preferred embodiment, based on the simulation model of the digital twin, the topology relationship code is determined and prompt words are generated through the program interface of the power system simulation platform. This includes: obtaining the component connection line relationship of the simulation model of the digital twin through the program interface of the power system simulation platform; dividing the pins of all basic components in the simulation model of the digital twin into several interconnected pin groups based on the component connection line relationship; each pin group includes one output pin and several input pins; the pin group is used to characterize the pin name and the connection relationship between the pins; and determining the topology relationship code and generating prompt words based on the several pin groups.

[0041] Digital twins contain a far greater number of components than traditional simulation models, necessitating real-time computation to guide the maintenance of the physical entity's state. Furthermore, to enable the execution of the entire simulation model's logic in a single step, this embodiment uses the power system simulation platform's program interface to determine topology relationship codes and generate prompts based on the digital twin's simulation model. These prompts are then input into a large language model, which automatically understands the internal logic of the digital twin's simulation model and generates component codes based on the topology relationships to realize the overall logic of the digital twin's simulation model. This improves the computational efficiency of the simulation process on the CloudPSS platform. Specifically, the CloudPSS platform's API uses topology analysis to obtain the component connection relationships of the digital twin's simulation model, and prompts are written in the form of several connected pin groups to enhance the large language model's reasoning capabilities.

[0042] To facilitate topology analysis, this embodiment starts with a pin of a basic component, continuously acquiring adjacent connecting lines and pins reachable by those connecting lines to add them to pin groups until the entire graph has been searched. Based on known connecting line relationships, the pins of all basic components in the digital twin simulation model are divided into several interconnected pin groups. Within each pin group, each pin should have the same signal value at the same time. Furthermore, since pins have input / output attributes, each pin group should have exactly one output pin and several input pins. That is, the signal from the output pin is received by several input pins for further computation. Pin names and the connection relationships between pins (signal transmission direction between pins) are added to the topology relationship code generation prompts of the large language model in the form of pin groups to enhance its understanding of topology relationships.

[0043] The topology code generation prompt should contain all the information necessary to understand the overall logic of the simulation model controlling the digital twin. Specifically, this includes: the logic description, pin definitions, and parameter information of the control model; the logic description, pin definitions, and parameter information of the control elements used; and the topology relationships between the control elements.

[0044] As a preferred embodiment, based on the simulation model of the digital twin, a large language model is used to generate component codes based on topological relationships. This includes: obtaining the composition and topological structure of multiple basic components in the simulation model of the digital twin through the program interface of the power system simulation platform; based on the topological structure, the large language model performs chain-like thinking according to a preset topological order to obtain component codes with topological relationships; the chain-like thinking method is that the large language model generates basic component logic codes sequentially according to the preset topological order, and synthesizes the logic code of the current basic component with the logic codes of several previously generated basic components.

[0045] To further improve the generation effect of large language models on topology-based component codes, this embodiment obtains the composition and topology of multiple basic components in the digital twin simulation model through the program interface of the power system simulation platform. Based on the topology, the reasoning ability of the large language model is improved through chain-like thinking, and logic codes are generated "step by step". The process of generating component codes based on topology can proceed according to a preset topology order, generating logic codes for each component and combining them. To avoid the overhead of function calls, in this embodiment, for each basic component, its basic component logic code is "continued" and added to the logic codes of several existing basic components to form a function expressing the overall logic. That is, the logic code generated for a certain basic component is "synthesized" with the logic codes of several previously generated basic components to obtain the overall simulation code of the complex component, i.e., the component code based on topology.

[0046] To facilitate subsequent merging of component codes, further formalization of the logic code is provided. The logic code of a basic component should consist of a simulation calculation function and the component's internal state variables. The input to the simulation function includes the component's input signals and parameters, as well as other information: whether it is the first time step, the current time, and the time interval. The function must return the values ​​of each output signal of the component. Unlike intermediate variables within the function, internal state variables record data that is retained across different time steps. The data of the internal state variables is retained between multiple calls to the simulation function. That is, the function can obtain certain state information of this component in the previous time step through simulating the internal state variables. Furthermore, the simulation function does not cause any other side effects. The simulation function reads and modifies the internal state variables. After obtaining the internal state table, the structure of the component's simulation function can be accurately obtained. The internal state, input signal variable names, and output signal variable names are added as prompt words.

[0047] The connections between components are directional (signals are transmitted from output ports to input ports), forming a directed graph. For directed graphs like simulation models that do not contain cycles, there must be a node ordering known as "topological order." In the topological order of a directed graph, if node A precedes node B, then there is no path from B to A in the graph. Using topological order to calculate the simulation of each component ensures that when calculating node X, all other nodes required for its input signal have already been calculated. Similar to the CloudPSS platform's component-by-component simulation calculations, components can be logically merged according to topological order. Newly added components always use the output signals of the existing component set as inputs, and the outputs of the new components become the inputs of subsequently added components.

[0048] As a preferred embodiment, a multi-agent system is constructed based on a large language model to facilitate interaction between the simulation model of the digital twin. This includes: constructing an agent system based on the large language model, comprising administrator agents and non-administrator agents; the non-administrator agents include a task planning agent, a simulation platform operation agent, a location agent, and an analysis agent; the administrator agent determines which non-administrator agent to speak based on a finite state machine, combined with the capabilities and applicable scenarios of each non-administrator agent; the finite state machine characterizes the state transitions of the multi-agent system; the task planning agent generates specific execution steps based on the user's natural language description; the user's natural language description represents the operation instructions performed on the simulation model of the digital twin; the simulation platform operation agent completes the actual operation of the simulation platform according to the specific execution steps; the location agent locates the target element according to the operation instructions; and the analysis agent understands the logical functions of the target element and the simulation model, providing decision-making or answering user questions.

[0049] In practical applications, there are numerous scenarios requiring specific modifications to the simulation model of a digital twin. Examples include modifying the location or type of a fault in a fault simulation model, or updating the parameters of a device in the simulation model based on actual conditions. Such operations require operators to have a deep understanding of the simulation model to accurately pinpoint the area needing modification. Furthermore, due to the diverse types of equipment and components involved in a digital twin, modifications to existing components are prone to errors. In this embodiment, a multi-agent system based on a large language model is used to construct a tool capable of modifying the simulation model of a digital twin in this way. This tool takes natural language as input; the user describes the operations to be performed on the simulation model. Based on an understanding of the simulation model, the tool executes the corresponding operations to achieve the user's desired result.

[0050] This embodiment employs the AutoGen multi-agent system, which can be used to organize and automate the interaction process between multiple large language models as agents. Each agent will interact with other agents in text form. In addition to using the logical reasoning capabilities of the large language models themselves to solve problems, AutoGen provides an interface to register external tools with the agents. The agents will make judgments and use external tools when necessary. They will automatically generate the parameters and input information required to use the external tools, collect the results returned by the tools, and interpret them. The GroupChat mode in AutoGen can organize the multi-agent system.

[0051] One agent is designated as the administrator agent. All functions and capabilities of non-administrator agents are registered with the administrator agent. Before each round of dialogue, the administrator agent assesses the situation and assigns the task to an appropriate agent. After completing the task, the agent returns the result to the administrator agent. The administrator agent then broadcasts the result to the remaining non-administrator agents in the system and initiates the next round of dialogue until the administrator agent determines that the task is completely resolved.

[0052] Based on the fundamental understanding of the digital twin simulation model established by the large language model, the interface provided by the CloudPSS platform will be utilized to allow users to edit the digital twin simulation model through natural language descriptions (such as "add a short-circuit fault at bus 5 of this simulation model"). The large language model will then automatically understand, orchestrate, and execute these operations. Within the large language model, the above processes will be categorized into several classes, and an intelligent agent will be created for each class to perform the tasks within that class.

[0053] When faced with complex tasks, humans tend to break them down into executable subtasks and solve them one by one. This embodiment constructs a planning agent responsible for generating specific execution steps. Planning is divided into two categories: "feedback planning" and "non-feedback planning".

[0054] To facilitate interface operations on the CloudPSS platform, this embodiment encapsulates its provided interface as a "CloudPSS Operation Agent" (simulation platform operation agent) and adds it to the multi-agent system. Given a CloudPSS platform user token, this agent will simulate user behavior according to specific execution steps to complete the actual operation of the simulation platform.

[0055] In the constructed multi-agent system, there are also other agents to perform different functions:

[0056] Localization agent: Based on the fuzzy natural language description provided by the user, locate a specific element (target element) in the model.

[0057] Analytical agents: understand the logical functions of target components and simulation models, and provide decisions or answers to user questions.

[0058] To further enhance the management capabilities of administrator agents, taking a multi-agent system interacting with the CloudPSS platform as an example, the operation of such a system exhibits distinct "phased" characteristics. For instance, after reading user requests, the system first enters the "planning" phase. During this phase, only agents related to planning (planning agents, planning review agents, etc.) can speak, while other agents are unaffected. After the plan is finalized, the system enters the "execution" phase. At this point, only agents related to execution speak, while agents related to planning should exit the system. After execution, the system returns to the initial "waiting for user requests" phase. This process can be represented by a finite state machine. In a given phase, only some agents are activated. After each agent completes its action, a determination is made as to whether a state transition should occur.

[0059] Finite state machines (FSMs) are a type of automaton in automata theory and computation theory, used to represent a finite number of states and the transitions between them. Using FSMs to characterize the state transitions of multi-agent systems can effectively avoid the problem of agents speaking at the wrong time. Furthermore, since the number of agents that can speak when the system is in a certain state is limited, it helps improve the system's operational efficiency and reduces the decision-making burden on the administrator.

[0060] Furthermore, in AutoGen, all agents receive all previous statements from other agents as input. This results in a large amount of useless information occupying the prompts in the large language model. For example, in the planning phase, there is a large amount of discarded statements between the planning agent, the planning review agent, and the user feedback. If all of these statements are used as input to other agents, the presence of a large amount of useless or distracting information in the prompts will negatively impact reasoning ability. In contrast, in a multi-agent system based on finite state machines, only the final result generated in the planning phase (i.e., executing the plan) is used as input to the next phase of the system, effectively avoiding the above problems.

[0061] As a preferred embodiment, the multi-agent system directly generates and executes the calling code for the program interface of the simulation platform based on the retrieval enhancement generation algorithm and the long context feature.

[0062] Since the information related to the CloudPSS API is not in the training dataset of the large language model, the model does not "know" the details of the API interface, meaning it cannot generate code to call the interface. This embodiment is based on a vector database pre-built using the Retrieval Augmented Generation (RAG) algorithm. The database stores textual data and its vectorized representation for easy querying. Using RAG can reduce the occurrence of illusions. After providing relevant context to the large language model, the model can use the relevant content in the context to generate code, avoiding factual errors. The large language model can use the information provided by RAG without prior training, further decoupling the information source from the model. Modifying the contents of the database can generate relevant code for other platforms (Simulink, etc.). The vector database in RAG can serve as a "storage" module for the agent, enhancing its capabilities.

[0063] Using RAG technology allows the model to select k most relevant prompt words from a near-massive dataset, adding them to enhance the model's generation capabilities. However, with the development of large language models, the upper limit of prompt word length is constantly increasing. For smaller databases, all data can be completely included in the prompt words without a "retrieval" step. Due to the ability to learn within context, large language models with long contexts can combine complete database content for generation. In this embodiment, for the CloudPSS API, the text information in its PDF document is pre-extracted and organized. After removing some irrelevant content, the final document length is around 40,000 units, less than the upper limit of prompt word length for most models (taking GPT-4 as an example). Therefore, prompt words with long context characteristics can be used to guide the large language model to generate the program interface call code of the simulation platform, realizing the automated execution of interactive tasks of the simulation model.

[0064] The following describes the power system digital twin interaction system based on a large language model provided by this invention. The power system digital twin interaction system based on a large language model described below can be referred to in correspondence with the power system digital twin interaction method based on a large language model described above.

[0065] Please refer to Figure 2 , Figure 2 This invention provides a schematic diagram of the structure of a power system digital twin interaction system based on a large language model.

[0066] The present invention also provides an interactive system for a power system digital twin based on a large language model, comprising: a first generation module 1, used to connect the large language model to a power system simulation platform to perform the basic component generation task of the simulation platform; a second generation module 2, used to generate component codes based on topological relationships using the large language model according to the simulation model of the digital twin; the digital twin includes multiple basic components; and an interaction module 3, used to construct a multi-agent system based on the large language model to interact with the simulation model of the digital twin using the multi-agent system.

[0067] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, communications interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a power system digital twin interaction method based on a large language model. This method includes: connecting the large language model to a power system simulation platform to perform the basic component generation task of the simulation platform; generating component codes based on topology relationships using the large language model according to the simulation model of the digital twin; the digital twin includes multiple basic components; and constructing a multi-agent system based on the large language model to use the multi-agent system for interaction between the simulation model of the digital twin.

[0068] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0069] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the power system digital twin interaction method based on a large language model provided by the above methods. The method includes: connecting the large language model to a power system simulation platform to perform the basic component generation task of the simulation platform; generating component code based on topology relationships using the large language model according to the simulation model of the digital twin; the digital twin includes multiple basic components; and constructing a multi-agent system based on the large language model to use the multi-agent system to interact with the simulation model of the digital twin.

[0070] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described method for interactive power system digital twins based on a large language model. This method includes: connecting the large language model to a power system simulation platform to perform a task of generating basic components for the simulation platform; generating component codes based on topological relationships using the large language model according to the simulation model of the digital twin; the digital twin including multiple basic components; and constructing a multi-agent system based on the large language model to interact with the simulation model of the digital twin using the multi-agent system.

[0071] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0072] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A digital twin interaction method for power systems based on a large language model, characterized in that, include: The large language model is connected to the power system simulation platform to perform the basic component generation task of the simulation platform; Based on the simulation model of the digital twin, the large language model is used to generate component codes based on topological relationships; The digital twin includes multiple of the aforementioned basic components; A multi-agent system is constructed based on the large language model to enable interaction between the simulation model of the digital twin and the digital twin. The process of integrating a large language model into a power system simulation platform to execute the basic component generation task of the simulation platform includes: The return result of the program interface call of the power system simulation platform is input to the large language model to obtain the component document output by the large language model; the return result is the logical description of the basic component in the simulation platform queried through the simulation platform; the component document is used to characterize the logic and functional understanding information of the large language model for the basic component of the simulation platform; Input the component document and basic component generation prompts into the large language model to obtain the component parameter attributes, component pin attributes, and component logic function codes output by the large language model; the basic component generation prompts include component generation examples generated based on the Few-shot algorithm; The step of generating topology-based component code using the large language model based on the simulation model of the digital twin includes: Based on the simulation model of the digital twin, the topology relationship code generation prompts are determined through the program interface of the power system simulation platform; the topology relationship code generation prompts include a logical description of the simulation model of the digital twin, the multiple basic components, and the topology relationships between the basic components; The topology code is used to generate prompt words, which are then input into the large language model to obtain the topology-based component code output by the large language model.

2. The power system digital twin interaction method based on a large language model according to claim 1, characterized in that, The process of generating the logic function code for the component includes: Based on the properties of the component parameters and the properties of the component pins, determine the logic function to be evaluated generated by the large language model; Static code analysis and feedback are performed on the logic function to be evaluated to obtain syntactically correct function code; Perform a difference logic test on the grammatically correct function code, and use the logically correct function code as the component logic function code.

3. The power system digital twin interaction method based on a large language model according to claim 1, characterized in that, The step of determining topology relationship codes and generating prompt words based on the simulation model of the digital twin through the program interface of the power system simulation platform includes: The component connection relationships of the simulation model of the digital twin are obtained through the program interface of the power system simulation platform. Based on the component connection relationships, the pins of all basic components in the simulation model of the digital twin are divided into several interconnected pin groups; each pin group includes one output pin and several input pins; the pin groups are used to characterize the pin names and the connection relationships between the pins; Based on several of the aforementioned pin groups, the topological relationship is determined, and a prompt word is generated.

4. The power system digital twin interaction method based on a large language model according to claim 1, characterized in that, The step of generating topology-based component code using the large language model based on the simulation model of the digital twin includes: The composition and topology of multiple basic components in the simulation model of the digital twin are obtained through the program interface of the power system simulation platform. Based on the topology, the large language model performs chain thinking according to a preset topology order to obtain the component code of the topology relationship; the chain thinking method is that the large language model generates basic component logic code sequentially according to the preset topology order, and synthesizes the logic code of the current basic component with the logic codes of several previously generated basic components.

5. The power system digital twin interaction method based on a large language model according to any one of claims 1 to 4, characterized in that, The construction of a multi-agent system based on the large language model, for interacting with the simulation model of the digital twin using the multi-agent system, includes: Based on the large language model, an intelligent agent system is constructed, comprising an administrator agent and non-administrator agents; the non-administrator agents include a task planning agent, a simulation platform operation agent, a localization agent, and an analysis agent. The administrator agent is used to determine the non-administrator agent to speak based on the finite state machine and the capabilities and applicable scenarios of each non-administrator agent; the finite state machine is used to characterize the state transitions of the multi-agent system. The task planning agent is used to generate specific execution steps based on the user's natural language description; the user's natural language description is used to characterize the operation instructions performed on the simulation model of the digital twin; The simulation platform operation agent is used to complete the actual operation of the simulation platform according to the specific execution steps. The positioning agent is used to locate the target element according to the operation instructions; The analytical agent is used to understand the logical functions of the target component and the simulation model, and to provide decisions or answer user questions.

6. The power system digital twin interaction method based on a large language model according to claim 5, characterized in that, The multi-agent system directly generates and executes the calling code for the program interface of the simulation platform based on the retrieval enhancement generation algorithm and the long context feature.

7. A power system digital twin interactive system based on a large language model, characterized in that, include: The first generation module is used to connect the large language model to the simulation platform of the power system to perform the basic component generation task of the simulation platform. The second generation module is used to generate component code based on topological relationships using the large language model based on the simulation model of the digital twin; The digital twin includes multiple of the aforementioned basic components; An interaction module is used to construct a multi-agent system based on the large language model, so as to use the multi-agent system to interact with the simulation model of the digital twin; The process of integrating a large language model into a power system simulation platform to execute the basic component generation task of the simulation platform includes: The return result of the program interface call of the power system simulation platform is input to the large language model to obtain the component document output by the large language model; the return result is the logical description of the basic component in the simulation platform queried through the simulation platform; the component document is used to characterize the logic and functional understanding information of the large language model for the basic component of the simulation platform; Input the component document and basic component generation prompts into the large language model to obtain the component parameter attributes, component pin attributes, and component logic function codes output by the large language model; the basic component generation prompts include component generation examples generated based on the Few-shot algorithm; The step of generating topology-based component code using the large language model based on the simulation model of the digital twin includes: Based on the simulation model of the digital twin, the topology relationship code generation prompts are determined through the program interface of the power system simulation platform; the topology relationship code generation prompts include a logical description of the simulation model of the digital twin, the multiple basic components, and the topology relationships between the basic components; The topology code is used to generate prompt words, which are then input into the large language model to obtain the topology-based component code output by the large language model.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the power system digital twin interaction method based on a large language model as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Public opinion propagation modeling simulation and risk early warning method based on large language model

    CN117575829A

  • Simulation scene building method and device, electronic equipment and readable storage medium

    CN118052147A