Power grid graph structure data generation method and device, equipment and storage medium
By acquiring grid structure data and generating multimodal data, such as scatter plots, electrical test charts and textual descriptions, the problem of lack of multimodal data in the power grid topology generation in the prior art is solved, and the accuracy and interpretability of grid diagram structure are improved.
Patent Information
- Application Number
- CN202411704977.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-14
AI Technical Summary
The existing grid topology generation technology only provides grid structure information, lacks the combination with other data types, limiting the effectiveness of large language models when training and understanding grid topology.
By acquiring the grid structure data, a scatter plot, electrical test chart and textual description are generated, and the grid diagram structure data is generated based on these multimodal data.
The accuracy and interpretability of the generated grid diagram structure are improved, and the topological structure of the grid structure can be better demonstrated.
Smart Images

Figure CN119622035A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power grid diagram structure, and in particular to a method, device, equipment and storage medium for generating power grid diagram structure data. Background Art
[0002] Most current research methods for power grid graph structure data generation focus on topology generation, such as graph enhancement and machine learning techniques. These methods mainly focus on the topology itself, aiming to modify or analyze the existing power grid structure to generate graphs of similar scale. Although the existing power grid graph structure generation methods can generate synthetic power system graph structures to a certain extent, the current power grid topology generation technology usually only provides power grid structure information and lacks integration with other data types, such as text descriptions, images, node features, etc. The lack of this multimodal data limits the effectiveness of large language models (LLMs) in training and understanding power grid topology. Due to the lack of sufficient multimodal data support, existing systems find it difficult to fully utilize the potential of large models to generate high-precision and interpretable power grid graph structures, which limits the ability of large language models in training and topology understanding, resulting in low accuracy and interpretability of the generated power grid graph structure. Summary of the invention
[0003] The present invention provides a method, device, equipment and storage medium for generating power grid diagram structure data to solve the technical problem that the current power grid topology generation technology only provides power grid structure information and lacks the ability to be combined with other data types.
[0004] In order to solve the above technical problems, an embodiment of the present invention provides a method for generating power grid diagram structure data, comprising:
[0005] Acquire power grid structure data; wherein the power grid structure data includes: electrical nodes of the power grid and edges representing connection relationships between the electrical nodes;
[0006] Scattering the electrical nodes in a preset blank graph in the form of points, connecting the corresponding electrical nodes with the edges in the form of line segments, and generating a scatter plot corresponding to the power grid structure data;
[0007] Generate a code of an electrical test diagram corresponding to the power grid structure data according to the node type of the electrical node and the connection type of the edge, and then generate a corresponding electrical test diagram according to the code; wherein the node types include: PQ nodes, PV nodes and Slack nodes; the connection types of the edges include: connection from PV nodes to PQ nodes and connection from PQ nodes to PQ nodes;
[0008] According to the node type of each electrical node and the node type of the electrical node connected to each edge, the power grid bus where each type of electrical node is located is determined, and then according to the power grid bus where each type of electrical node is located, a text description of each type of electrical node in the power grid is generated; wherein the text description includes: the function of the power grid bus where each type of electrical node is located;
[0009] Graph structure data corresponding to the power grid structure data is generated according to the scatter plot, the electrical test diagram and the textual description.
[0010] As a preferred solution, in the electrical test diagram, electrical nodes of different node types are represented by different colors or shapes according to the node type of each electrical node.
[0011] As a preferred solution, the determining of the power grid bus where each type of electrical node is located according to the node type of each electrical node and the node type of the electrical node connected to each edge, and then generating a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located, includes:
[0012] Obtaining a textual description query of a user, and decomposing the textual description query into a plurality of textual description sub-queries; wherein each textual description sub-query corresponds to an electrical node;
[0013] For each textual description subquery, calculating the similarity between the textual description subquery and each document fragment in the preset power grid document, and taking the document fragment with the greatest similarity to the textual description subquery as the target document fragment;
[0014] Based on the document description information of the target document fragment, the node type of each electrical node and the node type of the electrical nodes connected by each edge, the power grid bus where each type of electrical node is located is determined, and then based on the power grid bus where each type of electrical node is located, a textual description of each type of electrical node in the power grid is generated.
[0015] As a preferred solution, the calculating of the similarity between the textual description subquery and each document fragment in the preset power grid document includes:
[0016] Converting the textual description subquery into a textual description subquery vector of a preset dimension, and converting each document fragment in a preset power grid document into a document fragment vector of a preset dimension;
[0017] The cosine similarity between the textual description subquery vector and each of the document fragment vectors is calculated, and the cosine similarity is used as the similarity between the textual description subquery and each document fragment in the preset power grid document.
[0018] Based on the above embodiment, another embodiment of the present invention provides a power grid diagram structure data generating device, including: a power grid structure data acquisition module, a scatter diagram generating module, an electrical test diagram generating module, a text description generating module and a diagram structure data generating module;
[0019] The power grid structure data acquisition module is used to acquire power grid structure data; wherein the power grid structure data includes: electrical nodes of the power grid and edges representing connection relationships between the electrical nodes;
[0020] The scatter plot generation module is used to scatter the electrical nodes in a preset blank graph in the form of points, connect the corresponding electrical nodes in the form of line segments, and generate a scatter plot corresponding to the power grid structure data;
[0021] The electrical test diagram generation module is used to generate a code of the electrical test diagram corresponding to the power grid structure data according to the node type of the electrical node and the connection type of the edge, and then generate a corresponding electrical test diagram according to the code; wherein the node types include: PQ node, PV node and Slack node; the edge connection types include: connection from PV node to PQ node and connection from PQ node to PQ node;
[0022] The textual description generation module is used to determine the power grid bus where each type of electrical node is located according to the node type of each electrical node and the node type of the electrical node connected to each edge, and then generate a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located; wherein the textual description includes: the function of the power grid bus where each type of electrical node is located;
[0023] The graph structure data generating module is used to generate graph structure data corresponding to the power grid structure data according to the scatter plot, the electrical test diagram and the textual description.
[0024] As a preferred solution, in the electrical test diagram, electrical nodes of different node types are represented by different colors or shapes according to the node type of each electrical node.
[0025] As a preferred solution, the determining of the power grid bus where each type of electrical node is located according to the node type of each electrical node and the node type of the electrical node connected to each edge, and then generating a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located, includes:
[0026] Obtaining a textual description query of a user, and decomposing the textual description query into a plurality of textual description sub-queries; wherein each textual description sub-query corresponds to an electrical node;
[0027] For each textual description subquery, calculating the similarity between the textual description subquery and each document fragment in the preset power grid document, and taking the document fragment with the greatest similarity to the textual description subquery as the target document fragment;
[0028] Based on the document description information of the target document fragment, the node type of each electrical node and the node type of the electrical nodes connected by each edge, the power grid bus where each type of electrical node is located is determined, and then based on the power grid bus where each type of electrical node is located, a textual description of each type of electrical node in the power grid is generated.
[0029] As a preferred solution, the calculating of the similarity between the textual description subquery and each document fragment in the preset power grid document includes:
[0030] Converting the textual description subquery into a textual description subquery vector of a preset dimension, and converting each document fragment in a preset power grid document into a document fragment vector of a preset dimension;
[0031] The cosine similarity between the textual description subquery vector and each of the document fragment vectors is calculated, and the cosine similarity is used as the similarity between the textual description subquery and each document fragment in the preset power grid document.
[0032] Based on the above embodiments, another embodiment of the present invention provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, the method for generating power grid diagram structure data described in the above embodiments of the invention is implemented.
[0033] Based on the above embodiments, another embodiment of the present invention provides a storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the power grid diagram structure data generation method described in the above invention embodiment.
[0034] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0035] The present invention provides a method for generating power grid graph structure data, obtaining power grid structure data; wherein the power grid structure data includes: electrical nodes of the power grid and edges representing the connection relationship between the electrical nodes; the electrical nodes are scattered in a preset blank graph in the form of points, and the edges are connected to the corresponding electrical nodes in the form of line segments to generate a scatter diagram corresponding to the power grid structure data; according to the node type of the electrical node and the connection type of the edge, a code of an electrical test diagram corresponding to the power grid structure data is generated, and then a corresponding electrical test diagram is generated according to the code; wherein the node types include: PQ nodes, PV node and Slack node; the connection types of the edges include: connection from PV node to PQ node and connection from PQ node to PQ node; according to the node type of each electrical node and the node type of the electrical node connected by each edge, determine the power grid bus where each type of electrical node is located, and then generate a text description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located; wherein the text description includes: the function of the power grid bus where each type of electrical node is located; according to the scatter plot, electrical test diagram and the text description, generate the graph structure data corresponding to the power grid structure data. The present invention can generate multimodal data corresponding to the power grid structure data: scatter plot, scatter plot and text description, and then generate the graph structure data corresponding to the power grid structure data according to the multimodal data. The multimodal data can better display the topological structure of the power grid structure data, and improve the accuracy and interpretability of the generated power grid graph structure. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flow chart of a method for generating power grid diagram structure data provided by one embodiment of the present invention;
[0037] Figure 2 It is a multimodal data generation structure diagram;
[0038] Figure 3 It is a detailed structure diagram to generate a flow chart;
[0039] Figure 4 It is a structural schematic diagram of a power grid diagram structure data generating device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0041] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.
[0042] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0043] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0044] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0045] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0046] In the description of the embodiments of the present application, unless otherwise clearly specified and limited, technical terms such as "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal connection of two elements or the interaction relationship between two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the embodiments of the present application can be understood according to the specific circumstances.
[0047] Embodiment 1
[0048] Please refer to Figure 1, is a flow chart of a method for generating power grid diagram structure data provided by an embodiment of the present invention, comprising the following specific steps:
[0049] S1. Acquire grid structure data; wherein the grid structure data includes: electrical nodes of the grid and edges representing connection relationships between the electrical nodes;
[0050] Specifically, in view of the above-mentioned shortcomings of the prior art, the present invention aims to solve the deficiencies and technical problems existing in the existing power grid structure generation technology in the following aspects:
[0051] Existing grid structure generation methods mainly focus on the overall structure of the macro grid, often ignoring the detailed description of the internal grid. Such methods usually establish simple connections by determining the location and basic parameters of power stations, lacking a refined description of local details such as nodes, edges, and devices, and cannot generate a multi-level, information-rich grid structure. This limits the operability and application effect of the generated structure in actual scenarios.
[0052] Current grid topology generation technologies usually only provide grid structure information and lack integration with other data types, such as text descriptions, images, node features, etc. This lack of multimodal data limits the effectiveness of large language models (LLMs) in training and understanding grid topology. Without sufficient multimodal data support, existing systems have difficulty fully leveraging the potential of large models to generate high-precision, interpretable grid structures.
[0053] In view of this, the present invention proposes a method for generating multimodal data and detailed structure of power grid diagram based on a large model, and in particular conducts in-depth exploration of the method for generating multimodal data. The method can generate multimodal data output including graph structure, power grid node features, edge features and based on the structure, such as image and text description. The specific steps of the technical solution are as follows:
[0054] 1. Specific implementation steps:
[0055] 1.1 Multimodal Data Generation of Graph Structures:
[0056] Please refer to Figure 2 , which is a multimodal data generation structure diagram, the present invention proposes a multimodal data generation module, which can generate two main types of multimodal data based on the power grid topology provided by the user:
[0057] 1. Image generation: The image of the power grid structure is generated in two different ways:
[0058] First, the program generates node and edge data based on the structure of the main network and subnetwork of the power grid. The characteristics of each node include its number and type (such as generator, load node, etc.), and each edge consists of the starting node, the ending node, and the connection type of the edge. The data of the main network and subnetwork are generated through steps such as random generation and connectivity detection, and the reasonable connection between nodes is ensured. After generating the data, it will process the nodes and edges to ensure their connectivity and reasonable structure. The edge connections between nodes are processed according to certain logical rules (such as power transmission rules), and different types of edges are classified (such as main network edges, subnetwork edges, and interface edges). In addition, the program will evaluate the generated subnetwork structure through a similarity detection algorithm to ensure that its structure meets expectations. After processing, the program uses the NetworkX and Matplotlib libraries in the Python program to draw these nodes and their connection relationships as images. Specifically, the nodes are represented as points in the figure, and the edges connect different nodes with line segments.
[0059] S2. Scattering the electrical nodes in a preset blank graph in the form of points, connecting the corresponding electrical nodes with the edges in the form of line segments, and generating a scatter plot corresponding to the power grid structure data;
[0060] 1.1 Scatter plot generation: Draw the nodes and their connections directly as images, using Python libraries such as NetworkX. This method can provide an intuitive display of the power grid topology and is suitable for analyzing the overall network structure. The nodes represent the various elements in the power grid (such as generators, loads, etc.), and these nodes are displayed in the graph by coordinate positions; the connections represent the power grid transmission lines between the nodes, and the nodes are connected by line segments to show the power transmission path in the power grid. The generated image is a scatter plot of the power grid topology, with nodes scattered in the graph in the form of points, and edges connecting the corresponding nodes with line segments, showing the overall structure and connection relationship of the power grid.
[0061] S3. Generate a code of an electrical test diagram corresponding to the power grid structure data according to the node type of the electrical node and the connection type of the edge, and then generate a corresponding electrical test diagram according to the code; wherein the node types include: PQ nodes, PV nodes and Slack nodes; the connection types of the edges include: connection from PV nodes to PQ nodes and connection from PQ nodes to PQ nodes;
[0062] Preferably, in the electrical test diagram, electrical nodes of different node types are represented by different colors or shapes according to the node type of each electrical node.
[0063] 1.2 Electrical test diagram generation: Use large language models (such as LLMs) combined with tool libraries such as Graphviz to generate power grid test diagrams that meet industrial standards. This type of image is mainly used to display the details of electrical lines, equipment, and buses, which is helpful for further testing and analysis. The specific method is as follows:
[0064] Data collection and processing: First, the system obtains detailed data of electrical lines from the node and edge index files of the power grid, which contain electrical nodes (such as generators, loads, etc.) and the connection relationships between them. Such data is usually based on industry standard test cases, such as the IEEE 39bus test case, which is an industrial standard power grid structure.
[0065] Generate descriptions and queries using LLM: Generate structured descriptions of collected node and edge data through large language models (such as LlamaCpp or Google GenerativeAI), clarifying the types of nodes in the power grid (such as PQ, PV, slack, and other types of buses) and edge connection types (such as PV to PQ, PQ to PQ connections, etc.). These descriptions are used to further generate graph layouts that meet industry standards.
[0066] Generate graphical representations: Use the Graphviz tool library to generate the code for the electrical test diagram based on the generated descriptions and connections. Graphviz will draw a topological diagram of the nodes and their connections based on these codes. These diagrams meet industry standards and show in detail how the electrical lines, devices, and buses are connected.
[0067] The electrical test diagram generation is based on IEEE industry standard test cases (such as IEEE 39bus test case) and is processed by node and edge data extracted from actual power grid data files. The large language model generates descriptions that meet industry standards based on these data and automatically generates structured graphs.
[0068] The generated electrical test diagram shows the various electrical nodes in the power grid (such as generators, loads, buses) and the connections between them. Each node is represented by a different color or shape according to its type (PQ, PV, slack bus, etc.), and the edges show the power transmission relationship between the nodes. The diagram shows the key details of the power grid topology in detail and is suitable for power grid analysis and testing.
[0069] S4. Determine the power grid bus where each type of electrical node is located according to the node type of each electrical node and the node type of the electrical node connected to each edge, and then generate a text description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located; wherein the text description includes: the function of the power grid bus where each type of electrical node is located;
[0070] Preferably, the method determines the power grid bus where each type of electrical node is located according to the node type of each electrical node and the node type of the electrical nodes connected to each edge, and then generates a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located, including: obtaining a user's textual description query, and decomposing the textual description query into a plurality of textual description sub-queries; wherein each textual description sub-query corresponds to an electrical node; for each textual description sub-query, calculating the similarity between the textual description sub-query and each document fragment in a preset power grid document, and taking the document fragment with the greatest similarity to the textual description sub-query as the target document fragment; determining the power grid bus where each type of electrical node is located according to the document description information of the target document fragment, the node type of each electrical node and the node type of the electrical nodes connected to each edge, and then generating a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located.
[0071] Preferably, the calculation of the similarity between the textual description subquery and each document fragment in the preset power grid document includes: converting the textual description subquery into a textual description subquery vector of a preset dimension, and converting each document fragment in the preset power grid document into a document fragment vector of a preset dimension; calculating the cosine similarity between the textual description subquery vector and each of the document fragment vectors, and using the cosine similarity as the similarity between the textual description subquery and each document fragment in the preset power grid document.
[0072] 2. Text description generation: By using a large language model, the system can generate a textual description of the graph structure. The specific process includes:
[0073] 2.1 Text description generation process Based on the processing and analysis of the power grid diagram structure data, a detailed text description of each part of the power grid is generated through a large language model (LLM). The specific steps are as follows:
[0074] Get data: The system first gets node and edge data from the grid topology. The data includes the characteristics of various buses in the grid (such as PQ bus, PV bus, Slack bus) and the connection relationship between them. The data comes from industrial standard grid test cases (such as IEEE 39bus test case) or is extracted from the input file provided by the user.
[0075] Data processing: After acquiring the raw data, the system classifies and preprocesses it. Nodes are classified according to their type and connection mode, and edges are labeled according to the types of nodes they connect. For example, the edges between nodes of the PQ bus and other types of nodes (such as the PV bus) will be labeled with different connection types.
[0076] Generate text description: The processed data is input into the system through the large language model. According to different bus types (such as PQ, PV, Slack), the large language model is guided by the preset prompt to generate corresponding text descriptions. For example, the system will generate a standardized description similar to "This bus is a PQ bus, mainly used for..." to ensure that the characteristics of each bus type can be clearly expressed.
[0077] 2.2Prompt is designed to be customized according to different types of grid buses (such as PQ bus, PV bus, Slack bus). The specific steps are as follows:
[0078] PQ bus: The prompts designed for the PQ bus include the functions of the bus and its role in the power grid, such as "This bus is a PQ bus, which is mainly used to respond to load demands and stabilize voltage in the power grid." This type of prompt is designed to guide the large language model to generate a functional description of the PQ bus.
[0079] PV bus: The prompt design for the PV bus focuses more on its role in power generation, for example, "This bus is a PV bus, which is mainly used for power transmission and maintains the stability of the power grid by adjusting the power output of the generator."
[0080] Slack bus: The prompt for the Slack bus mainly emphasizes its role as a reference point for grid frequency and voltage, for example, "This bus is the Slack bus, which is the reference point for the entire grid and is used to balance power and maintain frequency stability."
[0081] These cues provide explicit context to the large language model, guiding it to generate targeted descriptions of the power grid.
[0082] 2.3 Large language models are pre-trained with massive natural language text data, covering a wide range of fields, and are designed to learn the semantic and structural relationships in text. The model predicts and generates grammatical and contextual language output through autoregressive or self-supervised learning.
[0083] Model input: The input is the designed prompt and key information of the power grid structure. The prompt guides the model to focus on the functional description of a certain type of bus through clear language prompts, such as "this bus is a PQ bus, mainly used for..."
[0084] Model output: The model generates a complete text description related to the input prompt. For example, after inputting "This bus is a PQ bus, which is mainly used for...", the model will generate a text description of the specific functions, roles and application scenarios of the PQ bus in the power grid.
[0085] The process of generating targeted descriptions: Through prompt design, the large language model is guided to generate text related to specific components of the power grid. The keywords contained in the prompt (such as "PQ bus" and "PV bus") enable the model to focus on describing the characteristics of this type of bus when outputting, thereby ensuring that the generated text content is highly relevant to the target component.
[0086] 2. Detailed structure diagram generation method based on LLM agent:
[0087] 2.1 Term Generation and Query Construction:
[0088] The system generates power grid terms and generates descriptive queries based on them. In descriptive queries, we use a technology called RAG (Retrieval-Augmented Generation), which is a technology that combines retrieval and generation to process complex queries. It decomposes complex queries into multiple sub-queries and gradually extracts core information. The specific block division method is to first analyze the query, identify the key parts or terms in it, and then treat each key point as an independent sub-query and process them in sequence to ensure that each sub-query can obtain accurate retrieval results. The user's input query may be a relatively complex natural language description. The RAG module will first decompose the query and extract the core information. Through the decomposed query, the RAG module will retrieve relevant document fragments (such as power grid structure files, various bus connection information, etc.) from the internal power grid database. In order to improve the accuracy of retrieval, RAG uses a pre-trained embedding model to convert user queries and power grid documents into vector representations, and finds the document fragment that best matches the query through a vector search method. The embedding model used in the retrieval process is obtained through pre-training technology and is trained based on a large amount of natural language text data. The purpose is to learn the semantic and contextual features of the text. The model input can be unstructured text such as natural language queries from users or grid document snippets, and the model output is a high-dimensional vector representation of these texts. The vector representation converts the semantic content of the text into a computable numerical form, making the text comparable not only at the lexical level but also at the semantic level.
[0089] When a user issues a query, the query text is converted into a fixed-dimensional vector through the embedding model, which expresses the semantic features of the query. Similarly, each fragment in the power grid document is also converted into a vector representation through the embedding model. These generated vectors are stored in the Chroma vector database for subsequent similarity retrieval.
[0090] During the retrieval process, the system first compares the user's query vector with the power grid document vectors stored in the database, usually using metrics such as cosine similarity or Euclidean distance. By calculating the similarity between these vectors, the system can quickly find the document fragment that best matches the query. This process effectively improves the accuracy and speed of retrieval, allowing the system to handle complex queries and return relevant power grid document content.
[0091] 2.2 Vector database retrieval and description generation:
[0092] The system uses the decomposed subqueries to retrieve relevant document information through the vector database and generates detailed description information for each type of bus and edge.
[0093] Specifically, the system reads the grid node data from the node index path and divides the nodes into transmission network and distribution network according to the "subnet" field. Then, the system generates corresponding description information according to the node type (such as PQ bus, PV bus, Slack bus).
[0094] When generating descriptions, the system not only explains the functions of the bus, but also assigns colors to it. For example, the color of the PQ bus in the transmission network is purple and in the distribution network is red; the PV bus is green in the transmission network and blue in the distribution network; the color of the Slack bus in the transmission network and the distribution network is green and blue respectively according to the rules. Through these colors, different types of buses can be intuitively distinguished in visualization.
[0095] The system further classifies and describes the bus types in different subnets, and saves the detailed information of each bus into corresponding text files, such as PQ bus description file, PV bus description file and Slack bus description file. These files are saved in corresponding directories to ensure accurate expression of each bus and edge connection.
[0096] To verify the matching of the generated description with the query, we introduced prompt methods. This method ensures that the generated description fully meets the user's query requirements and uses LLM intelligent agents to generate component codes corresponding to the detailed description. These generated codes are processed by a specific model to form the intermediate results of the component and generate visualization data.
[0097] Finally, we use prompt methods to combine all the processes and technologies mentioned above, through a series of designs and logics, to realize a complete and detailed workflow. The specific implementation method is as follows:
[0098] First, the prompt method uses a specific template (such as PromptTemplate) to decompose the complex query of the user into multiple sub-queries. The code uses a pre-designed template to generate independent queries for each bus in the power grid (such as PQ bus, PV bus, Slack bus), ensuring that each user's demand point is processed separately. Each sub-query is retrieved through the vector database to find the document fragment that best matches it, thereby generating an accurate description.
[0099] To ensure that the generated description meets the user's query requirements, the prompt method also introduces a verification step. The generated results are checked by using the LLM (Large Language Model) intelligent agent. This process can compare the answers generated by LLM with the original query to ensure that all answers are consistent with the query content. In the code, the generated subqueries are processed by the Google Generative AI model, and the model returns the results of multiple subqueries, which are then verified and screened through comparison.
[0100] Then, in this scenario, the LLM intelligent agent, an automated component driven by a large language model (such as Google GenerativeAI), will generate specific queries based on the input prompt, or decompose the query into multiple sub-questions and retrieve or generate corresponding answers for each question. These generated answers can form an accurate response to user needs.
[0101] Next, a pre-trained large language model (such as Google's Gemini or Llama model) is trained with a large amount of power grid documents and data to handle complex natural language queries. Its input is usually a user's natural language query or prompt, and the output is generated text or code. In the code, the model processes the input and outputs the generated code snippets, which correspond to the structural description of the power grid and are ultimately used to generate intermediate results and visualization data.
[0102] Second, the generation of intermediate results is done by matching the query with documents in the power grid database. The model uses vector retrieval technology to find the description information of the power grid nodes or edge connections related to the query, and generates a detailed description or visualization of the power grid structure based on this information. Finally, these results are presented to the user in a graphical form for further analysis and processing.
[0103] S5. Generate graph structure data corresponding to the power grid structure data according to the scatter plot, the electrical test diagram and the textual description.
[0104] 2.3 Image generation and final component integration:
[0105] While generating the text description and code, the system creates a series of image files to store the final detailed description of each bus type and grid combination in the grid. These image files can be used for subsequent grid structure display and analysis.
[0106] In the last step, the system integrates the various generated components (text description, code, image) into a detailed visualization result. Through the prompt method, the system uses LLM to generate Mermaid code to realize the visualization of the power grid structure. First, the system generates Mermaid codes for PV, PQ, Slack bus and other types based on the decomposed subqueries using different prompt contents, and applies different color markings to each bus according to the node type, for example, green for PV transmission and red for PQ distribution. Through keywords such as "PV" or "PQ", the system classifies the nodes and generates corresponding codes. Finally, the generated Mermaid codes are combined into a complete power grid visualization diagram, keeping the color of the legend consistent and automatically removing duplicate legends to ensure a clear display of the power grid structure. The generated intermediate and final results, including graphical descriptions and codes, will be saved to ensure a comprehensive and accurate display of the power grid structure.
[0107] Please refer to Figure 3 , generate a flow chart for the detailed structure diagram, according to Figure 3 The process based on the large model Agent is as follows:
[0108] Step 1: Input grid structure and feature extraction: The system receives the original grid structure data and extracts key information such as nodes, edges, buses, etc. Through the feature extraction model, the summary features of the grid are generated, providing basic information of the grid, such as topology and load conditions, to prepare for subsequent processing.
[0109] Step 2: Query generation and knowledge requirement determination: Based on the extracted grid characteristics, the system generates targeted queries to determine the knowledge required to generate a more detailed grid structure. These queries help determine the grid knowledge that needs to be supplemented in specific dispatch or assessment scenarios by calling the large model (LLM).
[0110] Step 3: Knowledge generation and structure refinement: The system uses query enhancement technology to optimize the input query and calls the large model to generate the required knowledge. The large model outputs a refined grid structure based on the query, including detailed busbar topology, circuit breaker locations, etc. This step ensures that the generated structure is accurate and meets actual needs through multimodal data fusion.
[0111] Step 4: Combining data fragments with domain knowledge: The system combines the generated grid structure fragments with the knowledge base of the grid domain. Through knowledge verification, the correctness and consistency of the structure are ensured. The system integrates multimodal data fragments (such as historical grid operation data and sensor data) to verify the generated results and supplement the necessary domain knowledge.
[0112] Step 5: Structural evaluation and image generation: The system evaluates and optimizes the generated grid structure through predefined formulas and standards to ensure that it meets the actual operating standards. Finally, the system generates a detailed grid image, and users can visually evaluate the grid structure to further optimize the dispatch plan or conduct operation verification.
[0113] It can be seen that the present invention provides a method for generating power grid diagram structure data, and the present invention can achieve the following beneficial effects:
[0114] (1) Significantly improve automation level and accuracy:
[0115] Fully automated generation and evaluation: This invention uses large language models (LLM) and retrieval-augmented generation (RAG) technology to automatically generate the power grid structure, evaluate the connectivity and complexity of each node and edge, and output the corresponding text and images. This fully automated approach reduces the need for manual intervention, making the power grid structure analysis process faster and more accurate.
[0116] Dynamic adaptation: The system can automatically adjust the generated graph structure and data according to the real-time topological changes of the power grid to ensure that it is highly matched with the current power grid status, reducing the probability of errors in system operation and improving the accuracy of power grid structure assessment.
[0117] (2) Accurate generation and presentation of multimodal data:
[0118] Enhanced reliability: With the help of factual information data and logical calculation tools, the system can generate more reliable operation tickets to ensure that they meet actual operation requirements. Multimodal generation of text, images and codes: The present invention can automatically generate multimodal data of the power grid diagram structure, including detailed text descriptions, images and codes. For example, the system can generate images with color and connection information for different types of buses and edges, and provide visual output through the Mermaid code generation tool. These multimodal data can not only show the topological structure of the power grid, but can also be directly used for further analysis and operation of the power grid.
[0119] Data verification and prompt generation: Using prompt technology and LLM agent technology, the system can generate detailed descriptions that conform to the power grid scenario and ensure the accuracy of these generated descriptions through verification steps. Especially in complex power grid structures, the system can accurately guide the model to generate data that conforms to the actual power grid structure through the prompt mechanism.
[0120] (3) Reduce operation and maintenance costs and training requirements:
[0121] Adaptive rule updates: The system uses embedded models and retrieval technology to automatically adapt to changes in grid rules and parameters, reducing the need for frequent updates and maintenance of the system. Developers do not need to manually adjust the code for each new rule, greatly reducing the workload of development and maintenance.
[0122] Simplified user operation and training: Through automatically generated multimodal data, users can quickly understand complex grid structures without extensive training. In addition, the highly automated solution provided by the system reduces the technical requirements for grid managers, further reducing training time and costs.
[0123] (4) Improving grid visualization capabilities:
[0124] Refined grid structure image generation: The present invention can generate a grid structure diagram that meets actual application requirements through image generation tools (such as Graphviz and NetworkX), including node connection information, edge attributes, etc. of each bus type. This high-precision image generation greatly improves the visualization capability of the grid structure, allowing users to more intuitively analyze the operating status of the grid.
[0125] Customized power grid diagram components: The system allows users to customize the generation of power grid diagrams according to different needs, including color, node connection style, etc., so that the display results of each power grid can be highly consistent with actual operational needs.
[0126] In summary, the present invention generates an evaluation method and multimodal data through a power grid diagram structure, significantly improves the level of automation and accuracy, provides accurate generation and presentation of multimodal data, improves the visualization capability and safety of the power grid, and reduces labor costs, thus having significant technical and economic advantages.
[0127] Embodiment 2
[0128] Please refer to Figure 4 , is a schematic diagram of the structure of a power grid diagram structure data generating device provided by an embodiment of the present invention, the device comprising: a power grid structure data acquisition module, a scatter diagram generating module, an electrical test diagram generating module, a text description generating module and a diagram structure data generating module;
[0129] The power grid structure data acquisition module is used to acquire power grid structure data; wherein the power grid structure data includes: electrical nodes of the power grid and edges representing connection relationships between the electrical nodes;
[0130] The scatter plot generation module is used to scatter the electrical nodes in a preset blank graph in the form of points, connect the corresponding electrical nodes in the form of line segments, and generate a scatter plot corresponding to the power grid structure data;
[0131] The electrical test diagram generation module is used to generate a code of the electrical test diagram corresponding to the power grid structure data according to the node type of the electrical node and the connection type of the edge, and then generate a corresponding electrical test diagram according to the code; wherein the node types include: PQ node, PV node and Slack node; the edge connection types include: connection from PV node to PQ node and connection from PQ node to PQ node;
[0132] The textual description generation module is used to determine the power grid bus where each type of electrical node is located according to the node type of each electrical node and the node type of the electrical node connected to each edge, and then generate a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located; wherein the textual description includes: the function of the power grid bus where each type of electrical node is located;
[0133] The graph structure data generating module is used to generate graph structure data corresponding to the power grid structure data according to the scatter plot, the electrical test diagram and the textual description.
[0134] Preferably, in the electrical test diagram, electrical nodes of different node types are represented by different colors or shapes according to the node type of each electrical node.
[0135] Preferably, the power grid bus where each type of electrical node is located is determined according to the node type of each electrical node and the node type of the electrical nodes connected to each edge, and then a textual description of each type of electrical node in the power grid is generated according to the power grid bus where each type of electrical node is located, including: obtaining a user's textual description query, and decomposing the textual description query into a plurality of textual description sub-queries; wherein each textual description sub-query corresponds to an electrical node; for each textual description sub-query, calculating the similarity between the textual description sub-query and each document fragment in a preset power grid document, and taking the document fragment with the greatest similarity to the textual description sub-query as the target document fragment; determining the power grid bus where each type of electrical node is located according to the document description information of the target document fragment, the node type of each electrical node and the node type of the electrical nodes connected to each edge, and then a textual description of each type of electrical node in the power grid is generated according to the power grid bus where each type of electrical node is located.
[0136] Preferably, the calculation of the similarity between the textual description subquery and each document fragment in the preset power grid document includes: converting the textual description subquery into a textual description subquery vector of a preset dimension, and converting each document fragment in the preset power grid document into a document fragment vector of a preset dimension; calculating the cosine similarity between the textual description subquery vector and each of the document fragment vectors, and using the cosine similarity as the similarity between the textual description subquery and each document fragment in the preset power grid document.
[0137] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0138] Those skilled in the art can clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0139] Embodiment 3
[0140] Accordingly, an embodiment of the present invention provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method for generating power grid diagram structure data described in the above-mentioned embodiment of the invention when executing the computer program.
[0141] The electronic device may be a computing device such as a desktop computer, a notebook, a palmtop computer, a cloud server, etc. The device may include, but is not limited to, a processor and a memory.
[0142] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the device, and various interfaces and lines are used to connect various parts of the entire device.
[0143] Embodiment 4
[0144] Accordingly, an embodiment of the present invention provides a storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the power grid diagram structure data generation method described in the above-mentioned embodiment of the invention.
[0145] The memory can be used to store the computer program, and the processor realizes various functions of the device by running or executing the computer program stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0146] The storage medium is a computer-readable storage medium, and the computer program is stored in the computer-readable storage medium. When the computer program is executed by the processor, the steps of each method embodiment described above can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0147] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for generating power grid diagram structure data, characterized in that: include: Acquire power grid structure data; wherein the power grid structure data includes: electrical nodes of the power grid and edges representing connection relationships between the electrical nodes; Scattering the electrical nodes in a preset blank graph in the form of points, connecting the corresponding electrical nodes with the edges in the form of line segments, and generating a scatter plot corresponding to the power grid structure data; Generate a code of an electrical test diagram corresponding to the power grid structure data according to the node type of the electrical node and the connection type of the edge, and then generate a corresponding electrical test diagram according to the code; wherein the node types include: PQ nodes, PV nodes and Slack nodes; the connection types of the edges include: connection from PV nodes to PQ nodes and connection from PQ nodes to PQ nodes; According to the node type of each electrical node and the node type of the electrical node connected to each edge, the power grid bus where each type of electrical node is located is determined, and then according to the power grid bus where each type of electrical node is located, a text description of each type of electrical node in the power grid is generated; wherein the text description includes: the function of the power grid bus where each type of electrical node is located; Graph structure data corresponding to the power grid structure data is generated according to the scatter plot, the electrical test diagram and the textual description.
2. The method for generating power grid diagram structure data according to claim 1, characterized in that: In the electrical test diagram, electrical nodes of different node types are represented by different colors or shapes according to the node type of each electrical node.
3. The method for generating power grid diagram structure data according to claim 1, characterized in that: The determining, according to the node type of each electrical node and the node type of the electrical node connected to each edge, the power grid bus where each type of electrical node is located, and then generating a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located, includes: Obtaining a textual description query of a user, and decomposing the textual description query into a plurality of textual description sub-queries; wherein each textual description sub-query corresponds to an electrical node; For each textual description subquery, calculating the similarity between the textual description subquery and each document fragment in the preset power grid document, and taking the document fragment with the greatest similarity to the textual description subquery as the target document fragment; Based on the document description information of the target document fragment, the node type of each electrical node and the node type of the electrical nodes connected by each edge, the power grid bus where each type of electrical node is located is determined, and then based on the power grid bus where each type of electrical node is located, a textual description of each type of electrical node in the power grid is generated.
4. The method for generating power grid diagram structure data according to claim 3, characterized in that: The calculating of the similarity between the textual description subquery and each document fragment in the preset power grid document includes: Converting the textual description subquery into a textual description subquery vector of a preset dimension, and converting each document fragment in a preset power grid document into a document fragment vector of a preset dimension; The cosine similarity between the textual description subquery vector and each of the document fragment vectors is calculated, and the cosine similarity is used as the similarity between the textual description subquery and each document fragment in the preset power grid document.
5. A device for generating power grid diagram structure data, characterized in that: include: Power grid structure data acquisition module, scatter plot generation module, electrical test diagram generation module, text description generation module and graph structure data generation module; The power grid structure data acquisition module is used to acquire power grid structure data; wherein the power grid structure data includes: electrical nodes of the power grid and edges representing connection relationships between the electrical nodes; The scatter plot generation module is used to scatter the electrical nodes in a preset blank graph in the form of points, connect the corresponding electrical nodes in the form of line segments, and generate a scatter plot corresponding to the power grid structure data; The electrical test diagram generation module is used to generate a code of the electrical test diagram corresponding to the power grid structure data according to the node type of the electrical node and the connection type of the edge, and then generate a corresponding electrical test diagram according to the code; wherein the node types include: PQ node, PV node and Slack node; the edge connection types include: connection from PV node to PQ node and connection from PQ node to PQ node; The textual description generation module is used to determine the power grid bus where each type of electrical node is located according to the node type of each electrical node and the node type of the electrical node connected to each edge, and then generate a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located; wherein the textual description includes: the function of the power grid bus where each type of electrical node is located; The graph structure data generating module is used to generate graph structure data corresponding to the power grid structure data according to the scatter plot, the electrical test diagram and the textual description.
6. The power grid diagram structure data generating device according to claim 5, characterized in that: In the electrical test diagram, electrical nodes of different node types are represented by different colors or shapes according to the node type of each electrical node.
7. The power grid diagram structure data generating device according to claim 5, characterized in that: The determining, according to the node type of each electrical node and the node type of the electrical node connected to each edge, the power grid bus where each type of electrical node is located, and then generating a textual description of each type of electrical node in the power grid according to the power grid bus where each type of electrical node is located, includes: Obtaining a textual description query of a user, and decomposing the textual description query into a plurality of textual description sub-queries; wherein each textual description sub-query corresponds to an electrical node; For each textual description subquery, calculating the similarity between the textual description subquery and each document fragment in the preset power grid document, and taking the document fragment with the greatest similarity to the textual description subquery as the target document fragment; Based on the document description information of the target document fragment, the node type of each electrical node and the node type of the electrical nodes connected by each edge, the power grid bus where each type of electrical node is located is determined, and then based on the power grid bus where each type of electrical node is located, a textual description of each type of electrical node in the power grid is generated.
8. The power grid diagram structure data generating device according to claim 7, characterized in that: The calculating of the similarity between the textual description subquery and each document fragment in the preset power grid document includes: Converting the textual description subquery into a textual description subquery vector of a preset dimension, and converting each document fragment in a preset power grid document into a document fragment vector of a preset dimension; The cosine similarity between the textual description subquery vector and each of the document fragment vectors is calculated, and the cosine similarity is used as the similarity between the textual description subquery and each document fragment in the preset power grid document.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method for generating power grid diagram structure data as claimed in any one of claims 1 to 4 when executing the computer program.
10. A storage medium, characterized in that: The storage medium includes a stored computer program, wherein when the computer program is executed, the device where the storage medium is located is controlled to execute the method for generating power grid diagram structure data according to any one of claims 1 to 4.
Citation Information
Cited By
Power grid test data method and system based on RAG and LLM-Agent
CN120850614A
Rag and llm-agent based power grid test data method and system
CN120850614B