Power grid event identification method, identification device, computer equipment and computer readable storage medium
Patent Information
- Application Number
- CN202610856430.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-15
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]然而目前电网事件的识别主要依赖基于规则引擎的静态阈值判断方法,因为规则引擎的匹配逻辑基于预设的条件表达式和阈值范围,要求输入数据必须为类型明确、字段固定的结构化数据,这导致电网事件识别仅依赖结构化数据,忽略了工单描述和电网现场图像蕴含的丰富的非结构化信息,从而造成电网事件识别的准确性较低
[0010]上述电网事件的识别方法、识别装置、计算机设备、计算机可读存储介质和计算机程序产品,若电网数据包括非结构化数据,则对电网数据进行编码,得到保留电网数据完整语义的目标文本向量,以及预先对电网规则文本中每条规则文本进行直接编码,得到能够充分保留上下文语义信息的规则向量以及提取结构化的原始规则,进而在进行规则匹配时能够基于目标文本向量在向量库中查询匹配的规则向量,匹配的规则向量为相似度降序排序后位于前面的预设数量的规则向量或相似度大于预设相似度阈值的规则向量,由于目标文本向量和规则向量均保留了完整的语义上下文信息,可实现基于向量相似度的匹配,避免忽略掉电网数据和规则文本中的非结构化语义上下文信息,提升规则匹配的准确性,进而在将目标文本向量及候选规则子集注入预设提示词模板,根据预设提示词模板引导目标语义模型输出当前的电网事件时,由于候选规则子集已通过语义匹配得到了有效准确的筛选,且候选规则子集包括规则向量及原始规则,使得目标语义模型能够基于该高质量的候选规则子集进行推理,综合分析规则向量中的完整语义信息与原始规则中的事件属性、事件属性约束、事件类型、事件风险等级及事件关联性等结构化信息,从而显著提升电网事件识别的准确性。
Smart Images

Figure CN123011898A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, device, computer equipment, computer-readable storage medium, and computer program product for identifying power grid events. Background Technology
[0002] With the continuous improvement of the digitalization and intelligence of the power grid, the means of monitoring power grid operation are becoming increasingly diverse. The collected power grid data is no longer limited to structured data such as voltage, current, power, and frequency collected from power grid equipment, but also includes work order text descriptions from work order management systems, such as equipment alarm content, abnormal phenomena and handling processes, as well as power grid field image data. These work order descriptions and power grid field image data contain rich unstructured information, which is of great value for the identification of power grid events.
[0003] However, the current identification of power grid events mainly relies on static threshold judgment methods based on rule engines. This is because the matching logic of rule engines is based on preset condition expressions and threshold ranges, requiring the input data to be structured data with clear types and fixed fields. This leads to power grid event identification relying only on structured data, ignoring the rich unstructured information contained in work order descriptions and power grid field images, resulting in low accuracy in power grid event identification. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, device, computer equipment, computer-readable storage medium, and computer program product for identifying power grid events that can improve the accuracy of power grid event identification, in response to the above-mentioned technical problems.
[0005] In a first aspect, this application provides a method for identifying power grid events, comprising: acquiring power grid data to be detected; if the power grid data includes unstructured data, encoding the power grid data into a target text vector; querying a vector library for matching rule vectors based on the target text vector, obtaining the original rules associated with the rule vectors, and obtaining a subset of candidate rules composed of the rule vectors and the original rules; the matching rule vectors are a preset number of rule vectors that are ranked first after descending similarity or rule vectors with a similarity greater than a preset similarity threshold; the vector library stores rule vectors obtained by encoding power grid rule text and original rules extracted from the power grid rule text, wherein the rule vectors are associated with the original rules; injecting the target text vectors and the subset of candidate rules into a preset prompt word template, and guiding a target semantic model to output the current power grid event according to the preset prompt word template.
[0006] Secondly, this application also provides an identification device, comprising: an acquisition module for acquiring power grid data to be detected; an encoding module for encoding the power grid data into a target text vector if the power grid data includes unstructured data; a matching module for querying matching rule vectors in a vector library based on the target text vector, obtaining the original rules associated with the rule vectors, and obtaining a subset of candidate rules composed of the rule vectors and the original rules; the matched rule vectors are a preset number of rule vectors that are ranked first after descending similarity or rule vectors with similarity greater than a preset similarity threshold; the vector library stores rule vectors obtained by encoding power grid rule text and original rules extracted from the power grid rule text, and the rule vectors are associated with the original rules; and a target module for injecting the target text vector and the subset of candidate rules into a preset prompt word template, and guiding a target semantic model to output the current power grid event according to the preset prompt word template.
[0007] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the methods described in the first aspect.
[0008] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any one of the first aspects.
[0009] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in any of the first aspects.
[0010] The aforementioned methods, devices, computer equipment, computer-readable storage media, and computer program products for identifying power grid events, if the power grid data includes unstructured data, encode the power grid data to obtain a target text vector that preserves the complete semantics of the power grid data. They also pre-encode each rule text in the power grid rule text to obtain a rule vector that fully preserves contextual semantic information and extracts structured original rules. Furthermore, during rule matching, the system can query a vector library for matching rule vectors based on the target text vector. The matched rule vectors are either a preset number of rule vectors ranked in descending order of similarity or rule vectors with a similarity greater than a preset similarity threshold. Since both the target text vector and the rule vectors preserve complete semantic contextual information... It enables vector similarity-based matching, avoiding the neglect of unstructured semantic context information in power grid data and rule text, thus improving the accuracy of rule matching. Furthermore, when the target text vector and candidate rule subset are injected into a preset prompt word template, and the target semantic model is guided to output the current power grid event based on the preset prompt word template, the candidate rule subset has been effectively and accurately filtered through semantic matching. Since the candidate rule subset includes rule vectors and original rules, the target semantic model can perform reasoning based on this high-quality candidate rule subset. It comprehensively analyzes the complete semantic information in the rule vector and the structured information such as event attributes, event attribute constraints, event types, event risk levels, and event correlations in the original rules, thereby significantly improving the accuracy of power grid event identification. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a diagram illustrating the application environment of a power grid event identification method in one embodiment.
[0013] Figure 2 This is a flowchart illustrating a method for identifying power grid events in one embodiment;
[0014] Figure 3 This is a flowchart illustrating a method for identifying power grid events in one embodiment;
[0015] Figure 4 This is a flowchart illustrating a method for identifying power grid events in one embodiment;
[0016] Figure 5 This is a flowchart illustrating a method for identifying power grid events in one embodiment;
[0017] Figure 6 This is a flowchart illustrating a method for identifying power grid events in one embodiment;
[0018] Figure 7 This is a flowchart illustrating a method for identifying power grid events in one embodiment;
[0019] Figure 8 This is a schematic diagram of the network structure of the target rule engine in one embodiment;
[0020] Figure 9 This is a structural block diagram of the identification device in one embodiment;
[0021] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0023] The power grid event identification method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated on server 104 or placed on a cloud or other network server. Both the terminal and server can be used independently to execute the power grid event identification method provided in this embodiment. The terminal and server can also work together to execute the power grid event identification method provided in this embodiment. For example, terminal 102 acquires power grid data to be detected. If the power grid data includes unstructured data, it encodes the power grid data into a target text vector. Based on the target text vector, it queries the corresponding rule vector in the vector library, obtains the original rule associated with the rule vector, and obtains a subset of candidate rules composed of the rule vector and the original rule. The matched rule vectors are the preset number of rule vectors that appear at the top after descending similarity sorting or rule vectors with a similarity greater than a preset similarity threshold. The vector library stores the rule vectors obtained by encoding the power grid rule text and the original rules extracted from the power grid rule text. The rule vectors are associated with the original rules. The target text vector and the subset of candidate rules are injected into a preset prompt word template. The preset prompt word template guides the target semantic model to output the power grid event. The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, and projection devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0024] In one exemplary embodiment, such as Figure 2 As shown, a method for identifying power grid events is provided. This embodiment uses the application of this method to a computer device as an example for illustration, including the following steps 202 to 208.
[0025] Step 202: Obtain the power grid data to be tested;
[0026] Grid data refers to multi-source data obtained from multiple business systems related to the power system, which can be used to assess grid events. Due to the different levels of intelligence in different power systems and the differences in data collection time points corresponding to different business systems, the obtained grid data may include unstructured data in addition to structured data. Specifically, unstructured data includes work order text descriptions and / or on-site images. Work order text descriptions refer to textual descriptions of tasks such as power system faults, inspections, and maintenance. On-site images refer to images of power equipment and / or the environment taken at the power system site. Structured data includes power system operation data, equipment status monitoring data, and environmental data.
[0027] For example, the power grid data to be monitored includes structured and unstructured data. The structured data includes: main transformer winding temperature 98.6℃, load rate 93%, bus voltage fluctuation 8.4%, and ambient temperature 36℃. The bus voltage fluctuation is operational data, the main transformer winding temperature and load rate are equipment status monitoring data, and the ambient temperature is environmental data. The unstructured data includes the work order description "continuous alarm at night and significant temperature rise of the main transformer, indicating operational risk" and on-site images.
[0028] Step 204: If the power grid data includes unstructured data, then the power grid data is encoded into a target text vector;
[0029] If the power grid data includes unstructured data, the power grid data will be encoded to obtain a target text vector that integrates structured and unstructured data, so as to lay a data foundation for subsequent determination of power grid event types. This embodiment does not limit the specific encoding method of the power grid data.
[0030] In one embodiment, if the power grid data is structured data, the structured data is directly used as input to the target rule engine, and the original rule matching the structured data and the power grid event associated with the original rule are determined based on the target rule engine.
[0031] The power grid event includes the event type and the event risk level. If at least two matching power grid events are obtained, the target power grid event is selected according to the event risk level of each matching power grid event, and the target power grid event is used as the current power grid event. If only one matching power grid event is obtained, that power grid event is used as the current power grid event.
[0032] In one embodiment, selecting the target power grid event based on the event risk level corresponding to each matched power grid event further includes: selecting the power grid event with the highest event risk level as the target power grid event, thereby ensuring that high-risk events are identified and handled first, and improving the safety of power grid operation.
[0033] Step 206: Based on the target text vector, query the vector library for matching rule vectors, obtain the original rules associated with the rule vectors, and obtain a subset of candidate rules composed of the rule vectors and the original rules; the matching rule vectors are a preset number of rule vectors that are ranked first after descending similarity or rule vectors with similarity greater than a preset similarity threshold; the vector library stores rule vectors obtained by encoding power grid rule text and original rules extracted from power grid event text, and the rule vectors are associated with the original rules;
[0034] In this context, the original rules serve as metadata for the rule vectors, and together with the rule vectors, they constitute the retrieval targets for the target text vectors. It's important to note that the original rules, as metadata, are the core retrieval targets of the vector library. The purpose of vector retrieval is to quickly locate this metadata, not merely to obtain the vectors themselves.
[0035] The power grid rule text includes expert knowledge and rule texts related to power grid event determination, both of which are unstructured data containing rules for power grid event determination. Specifically, expert knowledge refers to the empirical criteria for power grid event determination accumulated by experts in the power system field over a long period of time, while rule texts refer to normative documents related to power system operation, dispatch, and maintenance, such as operating procedures, fault handling plans, and technical standards. Both contain rules for power grid event determination. Traditional rule engines can only process structured data and cannot utilize unstructured information such as work order descriptions and on-site images, resulting in low accuracy in power grid event identification.
[0036] To this end, this application uniformly encodes structured and unstructured data in power grid data to obtain target text vectors that retain the complete semantics of power grid data. It also pre-encodes each rule text in the power grid rule text to obtain rule vectors that fully preserve contextual semantic information, and extracts structured original rules from each rule text in the power grid rule text. Therefore, in step 206, when performing rule matching, it can query matching rule vectors in the vector library based on the target text vectors. Since both the target text vectors and rule vectors retain complete semantic context information, vector-based matching can be achieved, avoiding the neglect of unstructured semantic context information in the power grid data and power grid rule texts, improving the accuracy of rule matching, and thus significantly improving the accuracy of the final power grid event identification.
[0037] The original rules include at least one of the following information: event attributes (occurrence time, geographical location, affected equipment type, and fault duration, etc.), event attribute constraints, event type, event risk level, and event correlation (similarity to historical events and cascading failure paths). The event attribute constraints include the judgment logic for all event attributes, such as whether the occurrence time falls within a certain time period, whether the geographical location belongs to a certain region, whether the equipment type is equal to a certain model, and whether the fault duration exceeds a certain value. These judgment logics are expressed using comparison operators (>, <, =, in, between, etc.). A cascading failure path refers to the sequence of fault propagation from the initial device to other devices, i.e., the chronological order and propagation path of the fault. Therefore, the original rules not only include the event's own attribute information but also incorporate cascading failure paths into the matching constraints. This allows rule matching to comprehensively consider the propagation correlation of events, avoiding isolated judgments of event types and thus improving the accuracy of rule matching.
[0038] For example, for the rule text "The main transformer load rate of substation A is 118% for 7 minutes, accompanied by a temperature rise of 95°C and line protection tripping, affecting approximately 12,000 users, event level 2", the extracted cascading fault path is "overload → temperature rise → protection action → power outage".
[0039] In one embodiment, querying for matching rule vectors in a vector library based on the target text vector further includes: sorting the rule vectors in descending order according to the similarity between the target text vector and the rule vectors in the vector library, and selecting a preset number of rule vectors that are at the top after the descending similarity sort, where the preset number is K, which is a preset fixed value or adaptively determined based on the size of the vector library; or directly selecting rule vectors with a similarity greater than a preset similarity threshold as the matching rule vectors, where the preset similarity threshold can be a cosine similarity threshold.
[0040] In one embodiment, after selecting rule vectors with similarity greater than a preset similarity threshold as matching rule vectors, the method further includes: if the number of rule vectors with similarity greater than the preset similarity threshold is less than a preset number, then the matching ends directly; or if the number of rule vectors with similarity greater than the preset similarity threshold is less than a preset number, then the rule vectors that are ranked first in descending order of similarity from the remaining rule vectors are selected as matching rule vectors, until the number of matching rule vectors reaches a preset number.
[0041] In one embodiment, step 206 is followed by: visualizing a subset of candidate rules.
[0042] Step 208: Inject the target text vector and the candidate rule subset into a preset prompt word template, and guide the target semantic model to output power grid events according to the preset prompt word template.
[0043] Among them, power grid events refer to abnormalities or state changes that occur during the operation of the power system and may affect the safety of the power grid or equipment, including event type and event risk level. The candidate rule subset obtained by rule matching in step 206 above is only a set of rules matched from the vector library that are semantically related to the target text vector, and the final power grid event has not yet been determined. This step 208 injects the target text vector and the candidate rule subset together into a preset prompt word template, guiding the target semantic model to reason with each candidate rule in the candidate rule subset, thereby accurately outputting the current power grid event. It should be noted that, as mentioned above, the candidate rule subset includes the matched rule vector and its associated original rules. Therefore, power grid event identification is not simply based on the target text vector and rule vector, but rather combines semantic information such as event attributes, event attribute constraints, event type, event risk level, and event correlation in the original rules associated with the rule vector for comprehensive judgment, thereby improving the accuracy of power grid event identification.
[0044] For example, the power grid data includes structured data such as "main transformer winding temperature 98.6℃, load rate 93%, bus voltage fluctuation 8.4%, ambient temperature 36℃" and work order description "110kV substation No. 2 main transformer continuously alarms at night, accompanied by abnormal temperature rise". The target text vector obtained by encoding the power grid data and the candidate rule subset obtained by matching the target text vector are injected into the preset prompt word template to guide the target semantic model to output the current power grid event as: event type "main transformer over-temperature operation abnormality" and event risk level "level two (higher risk)".
[0045] In one embodiment, the target semantic model adopts a large language model, but this embodiment does not limit this.
[0046] In the aforementioned method for identifying power grid events, if the power grid data includes unstructured data, the power grid data is encoded to obtain a target text vector that preserves the complete semantics of the power grid data. Additionally, each rule text in the power grid rule text is pre-encoded to obtain a rule vector that fully preserves contextual semantic information, and the original structured rules are extracted. Therefore, during rule matching, matching rule vectors can be queried in a vector library based on the target text vector. Since both the target text vector and the rule vector retain complete semantic context information, vector similarity-based matching can be achieved, avoiding the neglect of unstructured semantic context in the power grid data and rule text. By injecting target text vectors and candidate rule subsets into a preset prompt word template, and guiding the target semantic model to output the current power grid event based on the preset prompt word template, the candidate rule subset has been effectively and accurately filtered through semantic matching. Since the candidate rule subset includes rule vectors and original rules, the target semantic model can perform reasoning based on this high-quality candidate rule subset. It can comprehensively analyze the complete semantic information in the rule vectors and the structured information such as event attributes, event attribute constraints, event types, event risk levels, and event correlations in the original rules, thereby significantly improving the accuracy of power grid event identification.
[0047] In one exemplary embodiment, such as Figure 3 As shown, step 204 also includes steps 302 to 306.
[0048] Step 302: Using the target text vector as the query vector, starting from the top-level entry node of the hierarchical graph structure, the search proceeds layer by layer downwards based on the similarity between the query vector and the compression rule vectors corresponding to the neighboring nodes connected to the entry node, until the bottom-level entry node is determined; the hierarchical graph structure is the index of the vector library, including at least two layers, namely the bottom layer, the middle layer and the top layer from bottom to top, wherein the nodes of each layer above the bottom layer are selected from the nodes of the bottom layer, the number of nodes decreases layer by layer from the bottom layer to the top layer, similar nodes between adjacent layers are connected to each other, and similar nodes within a layer are connected to each other, and the nodes are represented by the data stored in the vector library;
[0049] The top-level entry node is pre-defined, while the bottom level includes all nodes, encompassing all data in the vector library. Each piece of data in the vector library represents a node. The vector library stores interrelated rule vectors and original rules. The rule vectors include the original rule vector and compressed rule vectors (obtained by compressing the original rule vector). Therefore, for a piece of data in the vector library, a node contains: the original rule vector, the compressed rule vector, and the original rule. It should be noted that the original rule vector and the original rule are the targets for rule matching.
[0050] In the hierarchical graph structure, the number of nodes decreases layer by layer from the bottom to the top. This allows for a progressive search from sparse to dense, starting from the top and moving downwards, quickly locating the entry node at the bottom layer. Similar nodes between adjacent layers are interconnected, and similar nodes within a layer are also interconnected. This eliminates the need to compare the similarity between the query vector and all nodes within that layer. Instead, within each layer, starting from the entry node, the search only compares the similarity between the query vector and the neighboring nodes connected to the entry node. The neighboring node with the higher similarity is chosen as the new entry node, and this process continues until the entry node no longer changes. The target node connected to this entry node in the next layer is then chosen as the entry node for the next layer, and the search continues until the entry node at the bottom layer is determined. This reduces the number of invalid queries, further accelerating the location of the entry node at the bottom layer. The compressed rule vector has a lower dimensionality than the original rule vector. Therefore, a coarse search is performed between the top and bottom layers based on the similarity between the query vector and the corresponding compressed rule vector, further accelerating the location of the entry node at the bottom layer by reducing the computational cost of similarity comparison. Therefore, this step, through the index of the hierarchical graph structure, can quickly locate the entry node at the bottom layer by reducing the number of invalid queries and the overhead of similarity calculation, thereby significantly improving the efficiency of rule matching.
[0051] In one embodiment, step 302 further includes: calculating the similarity between the query vector and the compressed rule vectors corresponding to the entry node and the neighboring nodes connected to the entry node in the current layer; if at least one neighboring node has a similarity greater than that of the entry node, then the neighboring node with the highest similarity is selected as the new entry node, and after each round of filtering, only the node with the highest similarity is left, and the step of calculating the similarity between the query vector and the entry node and the compressed rule vectors corresponding to the neighboring nodes connected to the entry node in the current layer is continued; if the similarity of the entry node is greater than that of all its neighboring nodes, then the node connected to the entry node in the current layer in the next layer is determined as the entry node of the next layer; in the next layer, the step of calculating the similarity between the query vector and the compressed rule vectors corresponding to the neighboring nodes connected to the entry node in the current layer is continued until the entry node of the bottom layer is determined.
[0052] As discussed above, similar nodes within each layer of a hierarchical graph structure are interconnected. Therefore, the neighboring nodes connected to the entry node refer to nodes directly connected to the entry node, and their number is variable, possibly zero, one, or more. For example, if the entry node is 'a', the connection paths to node a include: abdf, agc, and thus b and g are neighboring nodes of node a.
[0053] It's important to note that the similarity of neighboring nodes referred to here is the similarity between the query vector and the compressed rule vector corresponding to that neighboring node. Similarly, the similarity of the entry node is the similarity between the query vector and the compressed rule vector corresponding to that entry node. If the similarity of a neighboring node is greater than that of the entry node, it indicates that the similarity between the query vector and that neighboring node is higher than the similarity between the query vector and that entry node. Therefore, to find the node with the highest similarity to the query vector within the current layer, this neighboring node with the highest similarity is selected as the new entry node, and iterative searching continues within the current layer until the similarity of the current entry node is greater than the similarity of all its neighbors. At this point, the entry node is the node with the highest similarity to the query vector within the current layer, eliminating the need for a global search within the layer. This improves the efficiency of rule matching within the layer by reducing the number of invalid queries and the overhead of similarity calculation. Furthermore, after each round of filtering, only the node with the highest similarity remains, directly pursuing the local optimum along a single path. This reduces computational cost, requiring only a few iterations to reach the entry node of the next layer, thus improving the efficiency of rule matching between entry nodes from the top to the bottom layers.
[0054] Step 304: Starting from the entry node at the bottom layer of the hierarchical graph structure, a search is performed based on the similarity between the query vector and the original rule vectors corresponding to the neighboring nodes connected to the entry node to determine the matching original rule vectors;
[0055] In this process, the bottom-level nodes use the original rule vectors for similarity calculation. Compared to compressed rule vectors, these vectors contain complete semantic information. The bottom layer then performs a precise search based on the similarity between the query vector and the corresponding original rule vector, improving the accuracy of the matched original rule vectors. Furthermore, similar nodes within the layer are interconnected, eliminating the need to compare the similarity between the query vector and all nodes within the layer. Instead, starting from the bottom-level entry node, the search compares the similarity between the query vector and the neighboring nodes connected to the entry node. The search then selects the original rule vectors corresponding to the first predetermined number of neighboring nodes, sorted in descending order of similarity, as the matching original rule vectors. By using the original rule vectors for similarity comparison, precise matching is achieved, improving rule matching accuracy and reducing invalid queries, thus enabling rapid matching of the original rule vectors. This significantly improves rule matching efficiency while maintaining accuracy.
[0056] In one embodiment, step 304 further includes: adding the bottom entry node to the candidate set; calculating the similarity between the query vector and the original rule vectors corresponding to each node in the temporary candidate set, and selecting a first preset number of nodes that are at the top after sorting the similarity in descending order to construct a target candidate set; the first preset number is consistent with the maximum number of nodes that the candidate set can accommodate; adding each node in the candidate set to the visited set, removing nodes that already exist in the visited set from the target candidate set, and removing each node from the temporary candidate set; using the target candidate set as a new candidate set, and continuing to execute the step of adding the neighboring nodes corresponding to each node in the candidate set to the temporary candidate set, until a preset convergence condition is met; selecting the original rule vectors corresponding to a second preset number of nodes that are at the top after sorting the similarity in descending order from the visited set, and determining the selected original rule vectors as the matching original rule vectors.
[0057] In this process, the nodes are sorted in descending order of similarity, with the similarity decreasing sequentially from front to back. The first preset number of nodes selected are the nodes with the highest similarity to the query vector in the temporary candidate set. Nodes with low similarity to the query vector are eliminated, allowing for parallel search expansion of nodes with high similarity to the query vector in subsequent steps.
[0058] It should be noted that this step differs from the search between the top-level and bottom-level entry nodes described earlier. Instead, it constructs the target candidate set by calculating the similarity between the query vector and all nodes in the temporary candidate set, and selecting the first preset number of nodes that appear at the top after sorting the similarity in descending order. This retains multiple nodes with high similarity in each round of search, which is equivalent to exploring multiple paths simultaneously. This allows for more comprehensive coverage of possible neighboring regions and a higher recall rate in subsequent iterations. At the same time, the first preset number controls the computational cost, achieving a flexible balance between the quality and efficiency of rule matching.
[0059] After constructing the target candidate set, it indicates that the search expansion of each node in the current candidate set has been completed. Then, each node in the current candidate set is added to the visited set, and the nodes in the target candidate set that already exist in the visited set are added. This avoids repeatedly expanding the same batch of nodes in subsequent iterative searches and prevents the algorithm from getting stuck in an infinite loop.
[0060] The target candidate set is used as a new candidate set to continue searching and expanding each node in the target candidate set, iteratively filtering nodes with high similarity to the query vector until a preset convergence condition is met. The preset convergence condition includes reaching a preset maximum number of iterations or the target candidate set being empty; satisfying either condition constitutes meeting the preset convergence condition. It can be understood that when the target candidate set is empty, it indicates that all nodes reachable through the connection path from the bottom-level entry node have been visited, the search cannot be further expanded, and the algorithm naturally converges. At this point, the nodes in the visited set are those with high similarity to the query vector.
[0061] The second preset quantity is the number of query results to be returned. This embodiment does not limit its specific value, and those skilled in the art can flexibly set it according to actual needs. For example, the number of query results is set by the user or automatically determined by the vector library according to preset rules.
[0062] Step 306: Obtain the original rules associated with the matched original rule vector to obtain the candidate rule subset composed of the original rule vector and the original rules.
[0063] The matching original rule vector and its associated original rules form a subset of candidate rules. By leveraging the fast positioning capability of the hierarchical graph structure and the accurate matching capability of the underlying original rule vector, the efficiency and accuracy of rule matching are optimized in a coordinated manner, effectively supporting real-time semantic rule matching of large-scale text libraries such as power grid rules.
[0064] In this embodiment, using the target text vector as the query vector, starting from the top-level entry node of the hierarchical graph structure, a progressive coarse search is performed layer by layer from sparse to dense based on the similarity between the query vector and the compressed rule vectors corresponding to the neighboring nodes connected to the entry node, until the bottom-level entry node is determined. The number of nodes increases layer by layer from the top to the bottom, thereby reducing the number of invalid queries and the similarity calculation overhead to quickly locate the bottom-level entry node. Subsequently, starting from the bottom-level entry node of the hierarchical graph structure, a fine search is performed based on the similarity between the query vector and the original rule vectors corresponding to the neighboring nodes connected to the entry node to determine the matching original rule vector. Then, by comparing the similarity of the original rule vectors, precise matching is achieved to improve the accuracy of rule matching and reduce the number of invalid queries to achieve fast matching of the original rule vectors. Thus, the rule matching efficiency is significantly improved while ensuring the accuracy of rule matching. Finally, the original rules associated with the matched original rule vectors are obtained, and the candidate rule subset composed of the original rule vectors and the original rules can improve the accuracy of power grid event identification.
[0065] In one exemplary embodiment, such as Figure 4As shown, the method for identifying power grid events also includes steps 402 to 410.
[0066] Step 402: Construct a hierarchical graph structure, including the underlying layer, in the vector library;
[0067] At this point, the layered graph structure only includes the bottom layer and does not yet contain any nodes or establish any connections.
[0068] Step 404: Using the data representing nodes stored in the vector library, generate the highest level at which the node appears according to a preset probability decay function;
[0069] As mentioned above, a single data entry in the vector library includes the original rule vector, the compressed rule vector obtained by compressing the original rule vector, and the original rule.
[0070] The preset probability decay function is expressed as:
[0071]
[0072] in, Indicates hierarchy, This represents the hierarchical allocation parameter, used to indicate the probability of a node being assigned to different levels. The probability decreases sequentially from the bottom to the top level. The bottom level corresponds to... The value is 1, therefore the bottom layer will include all nodes. This preset probability decay function ensures that the number of nodes in the constructed hierarchical graph structure decreases layer by layer from the bottom to the top. Based on this, when performing rule matching in the vector library, the query starts from the top layer. Only a very small number of nodes need to be traversed to quickly locate the entry node of the bottom layer, avoiding direct matching of all vectors in the vector library, thus reducing computational overhead and improving rule matching efficiency.
[0073] Step 406: If the highest level is greater than the total number of layers in the hierarchical graph structure, create a target layer that matches the highest level on the bottom layer, and insert the node into each layer from the bottom layer to the highest level;
[0074] If the highest level is greater than the total number of layers in the layered graph structure, it indicates that new target layers need to be dynamically added sequentially on the bottom layer so that the total number of layers in the layered graph structure can be expanded to the highest level. If the highest level is less than or equal to the total number of layers in the layered graph structure, it indicates that a layer corresponding to the highest level already exists in the layered graph structure, and there is no need to add a new target layer. In this case, the node is inserted into each layer from the bottom to the highest level in the layered graph structure.
[0075] Step 408: For each node in each layer of the layered graph structure, calculate the similarity between the original rule vector corresponding to the node and the original rule vectors corresponding to other nodes, and connect the third preset number of other nodes that are ranked first after sorting the similarity in descending order to the node.
[0076] The similarity between the original rule vector corresponding to a node and the original rule vector corresponding to other nodes can be expressed as cosine similarity, where a larger value indicates a higher similarity, meaning the query vector is more similar to the original rule vector. Alternatively, Euclidean distance or Manhattan distance can be used, where a smaller value indicates a higher similarity. This embodiment does not impose specific limitations on this, and those skilled in the art can choose the appropriate similarity measurement method according to the actual application scenario.
[0077] Based on this, this step connects similar nodes, so that when performing rule matching based on the vector library, it can start from the entry node in each layer of the hierarchical graph structure and quickly navigate to the most similar node along the direction of similarity decrease, without having to perform rule matching on every node, thereby improving the efficiency of rule matching.
[0078] Step 410: In each adjacent layer of the hierarchical graph structure, for each node in the upper layer, calculate the similarity between the original rule vector corresponding to the node and the original rule vector corresponding to each node in the lower layer. Connect the fourth preset number of nodes in the lower layer that are sorted in descending order of similarity to the node to obtain the index of the vector library.
[0079] In this process, connections are established between similar nodes in adjacent layers, creating vertical paths between layers of the hierarchical graph structure. This allows for direct drilling down from upper-layer nodes to corresponding similar nodes in lower layers during rule matching, enabling layer-by-layer refined searching. Consequently, when performing rule matching based on a vector library, this index can quickly retrieve matching results, improving rule matching efficiency.
[0080] In one embodiment, the third preset quantity and the fourth preset quantity may be the same or different. This embodiment does not limit this. As an example, the third preset quantity and the fourth preset quantity may both be 1.
[0081] In this embodiment, an index with a hierarchical graph structure is constructed, including at least two layers, namely the bottom layer, the middle layer, and the top layer from bottom to top. The nodes of each layer above the bottom layer are selected from the nodes of the bottom layer. The number of nodes decreases from the bottom layer to the top layer. Similar nodes between adjacent layers are connected to each other, and similar nodes within a layer are connected to each other. Each node corresponds to a piece of data in the vector library. In order to quickly query the matching candidate rule subset through the hierarchical graph structure of the index when performing rule matching, the rule matching efficiency is improved.
[0082] In one exemplary embodiment, such as Figure 5 As shown, the method for identifying power grid events also includes steps 502 to 506.
[0083] Step 502: Obtain the structured data associated with the target text vector;
[0084] As mentioned earlier, the target text vector is obtained by encoding power grid data. Therefore, the structured data associated with the target text vector is the structured data within the power grid data. A detailed description of the power grid data is provided above and will not be repeated here.
[0085] Step 504: Use the structured data as input to the target rule engine, determine the original rules that match the structured data based on the target rule engine, and the matching original rules constitute an initial candidate rule subset;
[0086] Among them, such as Figure 8 The diagram shows the network structure of the target rule engine. The target rule engine decomposes the original rule, which includes at least two conditional rules, into single-conditional rules and associates the original rule with the single-conditional rules. Specifically, the conditional rule refers to the event attribute constraint in the original rule. As described above, the event attribute constraint includes the judgment logic of all event attributes. Therefore, here the event attribute constraint, which includes at least two judgment logics, is decomposed into a single judgment logic, that is, a single-conditional rule.
[0087] In one embodiment, the target rule engine determines matching single-condition rules based on the attributes of each piece of data in the structured data. It then checks whether each piece of data satisfies a single-condition rule; if so, the single-condition rule is marked as satisfied. When every single-condition rule associated with the original rule is marked as satisfied, the original rule is determined to match. This matching method decomposes complex original rules into combinations of multiple single-condition rules. The target rule engine's matching mechanism then checks the satisfaction of each single-condition rule one by one. Only when all single-condition rules are satisfied is the original rule considered to match, thus avoiding misjudgments due to only some conditions in the original rule being satisfied, and improving the accuracy of rule matching.
[0088] Step 506: In the vector library associated with the initial candidate rule subset, perform the step of using the target text vector as the query vector, starting from the top-level entry node of the hierarchical graph structure, and searching downwards layer by layer based on the similarity between the query vector and the compressed rule vectors corresponding to the neighboring nodes connected to the entry node, until the bottom-level entry node is determined.
[0089] The vector library associated with the initial subset of candidate rules stores only the target data related to the original rules in that subset, namely the original rule vectors, the compressed rule vectors obtained by compressing the original rule vectors, and the original rules. Based on this, the search scope of the target text vectors is narrowed to the vector library associated with the initial subset of candidate rules through pre-coarse matching by the target rule engine. Therefore, rule matching does not need to perform rule matching on all data extracted from the power grid rule text, i.e., all the original rule vectors, the compressed rule vectors obtained by compressing the original rule vectors, and the original rules. As mentioned above, the rule matching method based on the vector library uses a pre-built index for rule matching, which also does not require rule matching on all data in the vector library one by one. Thus, through a two-stage retrieval combining coarse matching and fine matching, the rule matching efficiency is significantly improved.
[0090] In this embodiment, the structured data associated with the target text vector is matched with the corresponding original rules in the target rule engine to obtain an initial subset of candidate rules composed of the matched original rules. Then, in the vector library associated with this initial subset of candidate rules, the search is performed layer by layer downwards from the top entry node of the hierarchical graph structure, based on the similarity between the query vector and the compressed rule vectors corresponding to the neighboring nodes connected to the entry node, until the bottom entry node is determined. By using the structured data associated with the target text vector, the rule matching range is first narrowed down to the vector library associated with the initial subset of candidate rules, and then the target text vector is quickly matched using the index in the vector library without traversing all the data in the vector library. Thus, through a two-stage retrieval combining coarse matching and fine matching, the rule matching efficiency is significantly improved.
[0091] In one exemplary embodiment, such as Figure 6 As shown, step 204 also includes steps 602 to 614.
[0092] Step 602: Convert the power grid data into a target natural language description, and segment the target natural language description into words to obtain a target word segmentation sequence;
[0093] This process involves converting multi-source power grid data into a target natural language description. This unifies and integrates the power grid data format, eliminating format differences between structured and unstructured data while preserving rich contextual semantics. This allows for further exploration of potential relationships between power grid data, improving the quality of the subsequently generated target text vectors. Segmenting the target natural language description into a target word sequence breaks it down into independent, smallest semantic units—terms—preserving complete lexical-level semantics. Compared to traditional methods of directly encoding character sequences, this application subsequently encodes the terms independently based on the target word sequence to avoid semantic fragmentation caused by character-level segmentation, thereby improving the semantic representation quality of the subsequently generated target text vectors.
[0094] In one embodiment, as described above, the power grid data includes structured data and unstructured data, wherein the unstructured data includes work order descriptions and on-site images. Converting the power grid data into a target natural language description further includes: converting the structured data into a corresponding first natural language description based on a target semantic model, converting the on-site images into a corresponding second natural language description based on a target visual semantic model, and fusing the first natural language description, the second natural language description, and the work order description to obtain the target natural language description.
[0095] The target semantic model uses a pre-defined description template to convert structured data into standardized first natural language descriptions. The target semantic model includes a Large Language Model (LLM). The target visual semantic model performs semantic understanding on field images and converts them into second natural language descriptions. The target visual semantic model includes a Visual Large Language Model (VLLM). Based on this, multi-source heterogeneous structured data and field images are converted into corresponding natural language descriptions, achieving format unification of power grid data and providing a data foundation for subsequent text vector generation.
[0096] In one embodiment, fusing the first natural language description, the second natural language description, and the work order description to obtain the target natural language description further includes: adding corresponding first prompt words and second prompt words to the beginning of the first natural language description and the second natural language description respectively; concatenating the first natural language description and the second natural language description after adding prompt words to obtain an initial natural language description; and concatenating the initial natural language description, the preset segmentation identifier, and the work order description to obtain the target natural language description, wherein the preset segmentation identifier is located between the initial natural language description and the work order description.
[0097] The first prompt word includes equipment status, the second prompt word includes on-site conditions, and the preset segmentation identifier includes ";", which is not limited in this embodiment. By adding prompt words, the target natural language description can still distinguish the task types corresponding to different natural language descriptions, so that subsequent encoding can generate more targeted feature representations. Adding the preset segmentation identifier is to distinguish different semantic segments in the obtained target natural language description, namely the initial natural language description and the work order description, to prevent the two information from interfering with each other, ensure the independence of subsequent segment encoding, and improve the understanding ability of subsequent encoding.
[0098] In one embodiment, preset prompts are added to the first and second prompts to clearly identify the boundaries and types of the prompts and avoid confusion with natural language descriptions. For example, the preset prompts are square brackets that enclose the prompts, such as "[device status]" and "[site conditions]".
[0099] The operation that fuses the first and second natural language descriptions is defined as follows:
[0100]
[0101] in, The initial natural language description indicates the device status, and the first prompt word indicates the device status. The first element is a natural language description, and the second element is a prompt indicating the situation at the scene. This indicates a description in the second natural language.
[0102] The operation for fusing the initial natural language description and the work order description is defined as follows:
[0103]
[0104] in, Represents the target natural language description, The semicolon indicates the work order description, and the semicolon ";" indicates a preset separator.
[0105] In one embodiment, segmenting the target natural language description to obtain a target segmented word sequence further includes: segmenting the target natural language description based on a preset industry terminology dictionary to obtain a target segmented word sequence. The preset industry terminology dictionary is a professional terminology dictionary for the power system field, including common power system terms and their standardized expressions. Segmentation based on the preset industry terminology dictionary enables accurate segmentation of the target natural language description in the power grid field, thereby further improving the semantic representation accuracy of the subsequently generated target text vector.
[0106] Step 604: Embed and positionally encode the target word segmentation sequence to obtain a word vector sequence; the first word vector in the word vector sequence is labeled with a preset identifier;
[0107] The process involves several steps: First, word embedding is performed on each word in the target word segmentation sequence to obtain a dense, low-dimensional embedding vector. This transforms discrete symbols (words) into continuous vector representations, ensuring that semantically similar words have similar distances in the vector space, facilitating subsequent text vector generation. Second, positional encoding is performed on each word to obtain a position vector representing its location. This provides the sequential information of the words for subsequent text vector generation, ensuring the temporal structure of the sequence is not lost. Third, the embedding vector and position vector of each word are fused to obtain a word vector for each word. Finally, the word vectors are arranged according to the original word segmentation order to obtain a word vector sequence. The first word vector in the word vector sequence is labeled with a preset identifier, such as [CLS], so that subsequent text vector generation can accurately locate and extract the global semantic information carried by the first word vector, improving the semantic representation integrity of the generated target text vector.
[0108] Step 606: Context encoding is performed on each word vector in the word vector sequence based on a self-attention mechanism to obtain the first context vector of each word vector;
[0109] Among them, the self-attention mechanism evaluates the semantic dependency of each word vector in the target word segmentation sequence with all other word vectors, and generates a first context vector for each word vector that integrates the contextual semantic information of the target word segmentation sequence. This enables the subsequently generated target text vector to cover the complex semantic relationships in the power grid data, thereby providing a more accurate vectorization basis for subsequent tasks based on the target text vector and improving the accuracy of rule matching.
[0110] In one embodiment, step 608 further includes: performing linear transformations on the word vector sequence based on the query weight matrix, key weight matrix, and value weight matrix respectively to generate a query matrix, key matrix, and value matrix of the word vector sequence; the query matrix, key matrix, and value matrix record the vector representation of each word vector; performing matrix multiplication on the transpose of the query matrix and the key matrix to obtain an attention score matrix; the attention score matrix records the attention score between each pair of word vectors; scaling the attention score matrix to obtain a scaled attention score matrix; normalizing the attention score matrix based on the Softmax function to obtain an attention weight matrix; the attention weight matrix records the attention weight of each word vector relative to each word vector in the word vector sequence; performing matrix multiplication on the attention weight matrix and the value matrix to obtain a first context vector matrix; the first context vector matrix records the first context vector of each word vector.
[0111] The query weight matrix, key weight matrix, and value weight matrix are obtained by training on historical power grid data. Each of these matrices independently performs a linear transformation on the word vector sequence to generate the query matrix, key matrix, and value matrix, respectively. The query matrix records the query vector for each word vector, the key matrix records the key vector for each word vector, and the value matrix records the value vector for each word vector. Specifically, the query vector represents the type of relevant information that the word vector needs to find in the semantic space, the key vector represents the semantic feature identifier that the word vector can provide, and the value vector represents the deep semantic information of the word vector itself.
[0112] Each attention score in the attention score matrix corresponds to the similarity between the query vector of one word vector and the key vector of another word vector, representing the relevance of the other word vector to the first word vector. For example, the element in the i-th row and j-th column of the attention score matrix represents the similarity between the query vector of the i-th word vector and the key vector of the j-th word vector. Each row of the attention score matrix records the distribution of attention scores between a word vector and each other word vector.
[0113] The scaling process involves dividing each attention score in the attention score matrix by the square root of the query vector dimension, thereby controlling the order of magnitude of the dot product between the query vector and the key vector and avoiding gradient saturation.
[0114] The attention weight matrix obtained after normalization using the Softmax function has a sum of 1 for each row, representing the contribution ratio of all word vectors to a single word vector.
[0115] Each row of the first context vector matrix records the first context vector of a word vector. This first context vector is an enhanced representation of a corresponding word vector after fusing the semantic information of all word vectors in the word vector sequence. Based on this, the self-attention mechanism completes the global context modeling of the word vector sequence through the above steps, outputting a first context vector matrix that fuses the semantic information of all words. This significantly improves the ability to represent long-distance dependencies and semantic associations in the target natural language description, enhances the semantic representation integrity of the subsequently generated target text vectors, and improves the efficiency and accuracy of subsequent vector operations, i.e., rule matching, using the target text vectors.
[0116] In one embodiment, the operation of the self-attention mechanism is defined as follows:
[0117]
[0118] Where Q is the query matrix, K is the key matrix, V is the value matrix, and T denotes transpose. Represents the attention score matrix. It is the dimension of the key vector. This represents the activation function, used for normalization.
[0119] Step 608: The first context vector and the corresponding word vector before context encoding are fused and normalized to obtain the second context vector;
[0120] The first context vector encompasses the global semantic information of the target word segmentation sequence, while the word vector before context encoding retains its own local semantic information. By fusing and normalizing the first context vector with the corresponding word vector before context encoding, the complementary enhancement of local and global semantic information is achieved, thereby improving the semantic representation capability of the second context vector. This avoids the loss of the original local semantic information of the word in subsequent processing, thus improving the semantic representation quality of the subsequently generated target text vector.
[0121] Step 610: Perform a nonlinear transformation on the second context vector based on the feedforward neural network to obtain the third context vector;
[0122] Among them, the feed-forward neural network (FFN) performs nonlinear transformations on each second context vector to enhance the feature expression capability, thereby obtaining a third context vector with richer semantic representation. This avoids the semantic information decay caused by the decline in feature expression capability in subsequent processing, which would prevent the extraction of effective semantic information and thus improve the semantic representation quality of the subsequently generated target text vector.
[0123] In one embodiment, step 610 further includes: performing dimensionality increase processing on the second context vector to obtain a first intermediate vector, performing nonlinear mapping on the first intermediate vector based on the ReLU activation function to obtain a second intermediate vector, and performing dimensionality reduction processing on the second intermediate vector to obtain a third context vector.
[0124] Among them, the dimensionality increase process increases the dimension of the second context vector to a higher dimension space to enhance the expressive power of the features. This makes it easier for subsequent nonlinear mappings to combine and transform various dimensions in the high-dimensional space to form richer feature representations, thereby fully capturing the nonlinear complex relationships hidden in the word vectors and improving the quality of the subsequently generated target text vectors.
[0125] For example, the second context vector has a dimension of 256, and the first intermediate vector obtained after the dimension increase process has a dimension of 1024.
[0126] The ReLU activation function introduces non-linear features into the first intermediate vector, making the resulting second intermediate vector more sparsity while maintaining gradient numerical stability and avoiding numerical decay in subsequent iterations, thereby improving the quality of the subsequently generated target text vector.
[0127] For example, the first intermediate vector is input into the ReLU activation function, the negative values in the first intermediate vector are set to 0, and the positive values remain unchanged, to obtain the second intermediate vector.
[0128] Dimension reduction restores the second intermediate vector to the same dimension as the second context vector, resulting in the final third context vector. This retains key semantic information while having a lower dimension, thereby improving the computational efficiency and quality of subsequent iterative encoding, and enhancing the computational efficiency and accuracy of subsequent vector operations using the target text vector, i.e., rule matching.
[0129] For example, the second intermediate vector has a dimension of 1024, and the third context vector obtained after dimensionality reduction has a dimension of 256.
[0130] In one embodiment, the operation of the feedforward neural network performing a nonlinear transformation on the second context vector is defined as follows:
[0131]
[0132]
[0133]
[0134] Where x represents the second context vector, and It is a weight matrix. and It is the bias term, and ReLU() represents the activation function. Represents the first intermediate vector. This represents the second intermediate vector. This represents the third context vector.
[0135] Step 612: Take the vector sequence composed of each third context vector as the new word vector sequence, and continue to perform the step of context encoding each word vector in the word vector sequence based on the attention mechanism to obtain the first context vector of each word vector, until the preset number of iterations is reached;
[0136] In this process, through a predetermined number of iterative encoding steps, the third context vector can be continuously optimized to cover long-distance dependencies and complex associations, thereby enhancing the semantic representation quality and robustness of the final output third context vector.
[0137] Step 614: Extract the target context vector labeled with the preset identifier from the third context vector, and use the target context vector as the target text vector.
[0138] Among them, the target text vector marked with a preset identifier is the result of the first word vector in the target word segmentation sequence after multiple iterations of encoding. It has aggregated the global semantic information of the target word segmentation sequence, extracted it as the target text vector, and thus can represent the complete contextual semantics of the power grid data in a fixed dimension, thereby significantly improving the quality of the target text vector and improving the accuracy of subsequent vector operations, i.e., rule matching, when using the target text vector.
[0139] In one embodiment, step 614 further includes: performing L2 normalization on the extracted target context vector to obtain a target text vector. This L2 normalization process ensures that the target text vector has a unit length, thereby eliminating interference caused by differences in vector magnitude in subsequent power grid event recognition and improving recognition efficiency and accuracy.
[0140] The L2 normalization operation is defined as follows:
[0141]
[0142] in, Represents the target text vector. This represents the target context vector.
[0143] In this embodiment, data format unification and multi-source data integration are achieved by converting power grid data into a target natural language description. The target natural language description is segmented into words to obtain a target word segmentation sequence, thus preserving complete lexical-level semantics. The target word segmentation sequence is embedded and positionally encoded to obtain a word vector sequence, with the first word vector labeled with a preset identifier. The word vector sequence is then context-encoded using a self-attention mechanism to obtain a first context vector, which integrates the contextual semantic information of the target word segmentation sequence. The first context vector is then fused and normalized with the corresponding word vector before context encoding to obtain a second context vector. This process achieves complementary enhancement of local and global semantics, thereby avoiding the original local semantics... The system avoids semantic loss by performing a nonlinear transformation on the second context vector using a feedforward neural network to obtain a third context vector, thereby enhancing feature expression and avoiding semantic decay. The third context vector sequence is then used as a new word vector sequence, and context encoding and other steps are performed until a preset number of iterations are reached, enabling the third context vector to continuously optimize its ability to cover long-distance dependencies and complex associations. The target context vector corresponding to the preset identifier is extracted from the third context vector as the target text vector, which can then represent the complete context semantic information of the power grid data with a fixed dimension, thereby significantly improving the quality of the target text vector and enhancing the accuracy of subsequent vector operations, i.e., rule matching, using the target text vector.
[0144] In one exemplary embodiment, such as Figure 7 As shown, the method for identifying power grid events also includes steps 702 to 710.
[0145] Step 702: Based on a preset industry terminology dictionary, the power grid rule text is segmented into words to obtain a rule segmentation sequence;
[0146] Specifically, word segmentation breaks down the power grid rule text into independent, minimal semantic units, preserving complete lexical-level semantics. This allows for independent encoding of each lexical unit in the subsequent rule-based word segmentation sequence. Compared to traditional direct encoding of character sequences, this avoids semantic fragmentation caused by character-level segmentation, thereby improving the semantic representation accuracy of the generated original rule vectors. The pre-defined industry terminology dictionary is a professional terminology dictionary for the power system field, including common power system terms and their standardized expressions, enabling comprehensive word segmentation of the power grid rule text.
[0147] Step 704: For each word element in the rule-based word segmentation sequence, convert the unit of measurement of the word element into a preset standard unit, query the standard term matching the word element in the preset standard term database, replace the word element with the standard term, and obtain the target rule-based word segmentation sequence.
[0148] The system includes a pre-defined standard terminology database that records the mapping relationships between standard terms and their variations, such as aliases, abbreviations, and common misspellings. The unit of measurement for each word is converted to the pre-defined standard unit, ensuring consistency across all units of measurement in the resulting target rule segmentation sequence. Furthermore, based on the standard terms matched by each word in the database, the word is replaced with the standard term, ensuring consistent expression for words with the same semantic meaning. Therefore, the resulting target rule segmentation sequence achieves uniformity in both unit of measurement and semantics, eliminating semantic inconsistencies caused by differences in unit of measurement and the diversity of word representations. This provides a standard input for subsequent vector encoding and improves the accuracy of rule matching based on the vector database.
[0149] For example, the lexical units include 10kV, 5 minutes, converting “10kV” to “10000 V”, and converting 5 minutes to 300 seconds.
[0150] In one embodiment, before step 704, the method further includes: preprocessing the rule-segmented word sequence, which includes at least one of the following steps: cleaning the rule-segmented word sequence to remove noise, such as deleting stop words, duplicate symbols, redundant punctuation, and garbled fragments that are useless for power grid event identification; extracting target data from the rule-segmented word sequence according to a preset extraction template; and reordering the words in the target data according to a preset sorting order. Target data refers to data including event objects, anomaly types, thresholds / measured values, duration, impact range, and handling actions. It should be noted that an event object refers to the object that is judged or handled in the rules, where in a power grid scenario, the event object is usually a device / line / site level object. As an example, the event object can be a main transformer, busbar, feeder, or substation.
[0151] Step 706: For the sub-rule segmentation sequence corresponding to each rule text in the target rule segmentation sequence, encode the sub-rule segmentation sequence of the rule text to obtain the original rule vector, and extract the original rule from the rule text based on the preset rule extraction template;
[0152] This method directly encodes the sub-rule word segmentation sequence of each rule text, ensuring that the resulting original rule vector retains complete contextual semantic information. This allows for comparison of the input query vector with the original rule vectors in the vector library within the same semantic space during rule matching, determining a match by calculating the similarity between the vectors. This approach overcomes the limitations of traditional keyword matching in handling synonyms, word order variations, and contextual dependencies. Even if the input query vector differs from the original rule vectors in literal expression, a correct match can still be achieved as long as the semantics are similar, thus improving the accuracy of rule matching.
[0153] In one embodiment, the original rule vector is obtained by encoding the sub-rule segmentation sequence of the rule text using the Word2Vec model. The Word2Vec model converts each word in the sub-rule segmentation sequence into a one-hot encoded vector; the one-hot encoded vector of each word is input into a weight matrix for linear mapping, resulting in a word vector matrix corresponding to each word; the target word vector corresponding to the index number of the target value 1 in the one-hot encoded vector is selected from the word vector matrix, and the target value is set to 1. The target word vectors of each word are then fused to obtain the rule vector. Based on this encoding method, the rule text is mapped from a high-dimensional discrete space to a low-dimensional continuous semantic space, resulting in a fixed-length, semantically rich, and computationally efficient original rule vector, thus improving the accuracy of rule matching.
[0154] Step 708: Compress the original rule vector to obtain a compressed rule vector;
[0155] The original rule vector is compressed using SQ8 (8-bit Scalar Quantization) technology to obtain a compressed rule vector, which in turn converts the dimension of each original rule vector from a 32-bit floating-point number to an 8-bit integer.
[0156] Step 710: Store the original rule vector, the compressed rule vector, and the original rule in the vector library.
[0157] In this embodiment, the power grid rule text is segmented based on a preset industry terminology dictionary to obtain a rule segmentation sequence. For each word in the rule segmentation sequence, the unit of measurement of the word is converted to a preset standard unit. Based on the standard term matching the word in the preset standard terminology database, the word is replaced with the standard term to obtain the target rule segmentation sequence. For the sub-rule segmentation sequence corresponding to each rule text in the target rule segmentation sequence, the sub-rule segmentation sequence of the rule text is encoded to obtain the original rule vector. The original rules are extracted from the rule text based on a preset rule extraction template. The original rule vector is compressed to obtain a compressed rule vector. The original rule vector and the compressed rule vector are then combined. The compressed rule vector and the original rule are associated and stored in a vector library. By constructing original rule vectors and compressed rule vectors that retain the complete contextual semantic information of the power grid rule text, the input query vector can be compared with the rule vectors (original rule vectors and compressed rule vectors) in the same semantic space during rule matching. The similarity between the vectors is calculated to determine whether they match. This overcomes the shortcomings of traditional keyword matching in handling synonyms, word order changes, and contextual dependencies. Even if the input query vector and the rule vector in the vector library differ in literal expression, they can still be correctly matched as long as they are semantically similar, thus improving the accuracy of rule matching.
[0158] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0159] Based on the same inventive concept, this application also provides a monitoring system for implementing the above-described method for identifying power grid events. The solution provided by this monitoring system is similar to the implementation described in the above method; therefore, the specific limitations in one or more monitoring system embodiments provided below can be found in the limitations of the power grid event identification method described above, and will not be repeated here.
[0160] In an exemplary embodiment, the monitoring system comprises a three-layer architecture consisting of an event listening layer, a message queue layer, and an execution layer, wherein:
[0161] The event listening layer is used to acquire the power grid data to be detected. If the power grid data includes unstructured data, it is encoded into a target text vector. Based on the target text vector, the matching rule vector is queried in the vector library to obtain the original rule associated with the rule vector, resulting in a subset of candidate rules composed of the rule vector and the original rule. The vector library stores the rule vectors obtained by encoding the power grid rule text and the original rules extracted from the power grid rule text, with the rule vectors associated with the original rules. The target text vector and the subset of candidate rules are injected into a preset prompt word template, and the target semantic model is guided to output the current power grid event according to the preset prompt word template.
[0162] The message queue layer is used to send current power grid events to the corresponding processing system.
[0163] In one embodiment, the message queue layer employs a hybrid message architecture combining Kafka (Apache Kafka) and RabbitMQ. If the current power grid event meets the first priority, RabbitMQ's Fanout broadcast mode is used for real-time distribution of the event message, ensuring rapid transmission of the power grid event to the corresponding processing system for a real-time, rapid response. If the current power grid event meets the second priority, Kafka's partitioning strategy is used to send the power grid event to the corresponding processing system, with the first priority taking precedence over the second priority. This achieves message routing based on power grid event priority, ensuring real-time response to emergency events while also considering reliable transmission and load balancing for large-scale daily data.
[0164] The execution layer consists of multiple distributed consumer services that execute corresponding emergency response procedures based on the event type and risk level of the power grid event. Consumer services include equipment repair systems, dispatch and command systems, and customer service systems, each receiving matching event messages through a subscription mechanism. The execution layer introduces a state machine model for full lifecycle management of the emergency response process. By defining event handling state transition rules, it achieves automated process advancement and status tracking. The state machine model works in conjunction with the message middleware to ensure the traceability of the event handling process. When an anomaly occurs in the emergency response process, a rollback mechanism is automatically triggered and a handling log is generated, providing data support for subsequent optimization.
[0165] The architecture of the aforementioned monitoring system effectively solves the problems of slow response speed and inconsistent handling measures in traditional emergency response processes, and realizes intelligent and automated handling of power grid incidents.
[0166] Based on the same inventive concept, this application also provides an identification device for implementing the above-described method for identifying power grid events. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more identification device embodiments provided below can be found in the limitations of the power grid event identification method described above, and will not be repeated here.
[0167] In one exemplary embodiment, such as Figure 9 As shown, an identification device is provided, including: an acquisition module 902, an encoding module 904, a matching module 906, and a target module 908, wherein:
[0168] The acquisition module 902 is used to acquire the power grid data to be detected;
[0169] Encoding module 904 is used to encode the power grid data into a target text vector if the power grid data includes unstructured data;
[0170] The matching module 906 is used to query the matching rule vector in the vector library based on the target text vector, obtain the original rule associated with the rule vector, and obtain a subset of candidate rules composed of the rule vector and the original rule; the matched rule vector is a preset number of rule vectors that are ranked first after descending similarity or rule vectors with similarity greater than a preset similarity threshold; the vector library stores the rule vectors obtained by encoding the power grid rule text and the original rules extracted from the power grid rule text, and the rule vectors are associated with the original rules;
[0171] The target module 908 is used to inject the target text vector and a subset of candidate rules into a preset prompt word template, and guide the target semantic model to output the current power grid event based on the preset prompt word template.
[0172] Each module in the aforementioned identification device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0173] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for identifying power grid events. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0174] Those skilled in the art will understand that Figure 10The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0175] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0176] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0177] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0178] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0179] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0180] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0181] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for identifying power grid events, characterized in that, The method includes: Acquire the power grid data to be tested; If the power grid data includes unstructured data, then the power grid data is encoded into a target text vector; Based on the target text vector, a matching rule vector is queried in the vector library to obtain the original rule associated with the rule vector, resulting in a subset of candidate rules composed of the rule vector and the original rule; the matching rule vector is a preset number of rule vectors that are ranked first after descending similarity or rule vectors with a similarity greater than a preset similarity threshold; the vector library stores the rule vectors obtained by encoding the power grid rule text and the original rules extracted from the power grid rule text, and the rule vectors are associated with the original rules; The target text vector and the subset of candidate rules are injected into a preset prompt word template, and the target semantic model is guided to output the current power grid event based on the preset prompt word template.
2. The method according to claim 1, characterized in that, The rule vector includes an original rule vector and a compressed rule vector obtained by compressing the original rule vector; the step of querying the matching rule vector in the vector library based on the target text vector, obtaining the original rule associated with the rule vector, and obtaining a subset of candidate rules composed of the rule vector and the original rule further includes: Using the target text vector as the query vector, starting from the top-level entry node of the hierarchical graph structure, the search proceeds layer by layer downwards based on the similarity between the query vector and the compression rule vectors corresponding to the neighboring nodes connected to the entry node, until the bottom-level entry node is determined. The hierarchical graph structure is the index of the vector library, including at least two layers, namely the bottom layer, the middle layer, and the top layer from bottom to top. Nodes in each layer above the bottom layer are selected from the nodes in the bottom layer, and the number of nodes decreases layer by layer from the bottom layer to the top layer. Similar nodes between adjacent layers are connected to each other, and similar nodes within a layer are connected to each other. The nodes are represented by the data stored in the vector library. Starting from the entry node at the bottom layer of the hierarchical graph structure, a search is performed based on the similarity between the query vector and the original rule vectors corresponding to the neighboring nodes connected to the entry node to determine the matching original rule vectors; Obtain the original rules associated with the matching original rule vector to obtain the candidate rule subset composed of the original rule vector and the original rules.
3. The method according to claim 2, characterized in that, The method further includes: Obtain the structured data associated with the target text vector; The structured data is used as input to the target rule engine, and the original rules that match the structured data are determined based on the target rule engine. The matched original rules constitute an initial subset of candidate rules. In the vector library associated with the initial subset of candidate rules, the following steps are performed: using the target text vector as the query vector, starting from the top-level entry node of the hierarchical graph structure, and searching downwards layer by layer based on the similarity between the query vector and the compressed rule vectors corresponding to the neighboring nodes connected to the entry node, until the bottom-level entry node is determined.
4. The method according to claim 3, characterized in that, The target rule engine decomposes the original rule, which includes at least two conditional rules, into single-conditional rules, and associates the original rule with the single-conditional rule; the step of using the structured data as input to the target rule engine, determining the original rule that matches the structured data based on the target rule engine, and the matching original rule constituting an initial candidate rule subset further includes: A single-condition matching rule is determined based on the attributes of each piece of data in the structured data; Determine whether each piece of data satisfies the single-condition rule; If satisfied, the single-condition rule is marked as satisfied; If each of the single-condition rules associated with the original rule is marked as satisfied, the original rule is determined to be matched.
5. The method according to claim 1, characterized in that, The method further includes: A hierarchical graph structure, including an underlying layer, is constructed in the vector library; The nodes are represented by data stored in the vector library, and the highest level at which the nodes appear is generated according to a preset probability decay function; If the highest level is greater than the total number of levels in the layered graph structure, a target layer matching the highest level is created on the bottom layer, and the node is inserted in each layer from the bottom layer to the highest level; if the highest level is less than or equal to the total number of levels in the layered graph structure, the node is inserted in each layer from the bottom layer to the highest level. For each node in each layer of the hierarchical graph structure, calculate the similarity between the original rule vector corresponding to the node and the original rule vectors corresponding to other nodes, and connect the node with the third preset number of other nodes that are sorted in descending order of similarity. In each adjacent layer of the hierarchical graph structure, for each node in the upper layer, the similarity between the original rule vector corresponding to the node and the original rule vector corresponding to each node in the lower layer is calculated. The nodes in the lower layer that are ranked first in descending order of similarity are connected to the node to obtain the index of the vector library.
6. The method according to claim 1, characterized in that, The process of encoding the power grid data into a target text vector further includes: The power grid data is converted into a target natural language description, and the target natural language description is segmented into words to obtain a target word segmentation sequence; The target word segmentation sequence is embedded and positionally encoded to obtain a word vector sequence; the first word vector in the word vector sequence is labeled with a preset identifier. Each word vector in the word vector sequence is context-encoded based on a self-attention mechanism to obtain the first context vector of each word vector. The first context vector and the corresponding word vector before context encoding are fused and normalized to obtain the second context vector; The second context vector is nonlinearly transformed based on a feedforward neural network to obtain the third context vector; Each third context vector is used as a new word vector sequence. The step of context encoding each word vector in the word vector sequence based on the attention mechanism is continued to obtain the first context vector of each word vector until the preset number of iterations is reached. Extract the target context vector labeled with the preset identifier from the third context vector, and use the target context vector as the target text vector.
7. The method according to claim 1, characterized in that, The method further includes: Based on a pre-set industry terminology dictionary, the power grid rule text is segmented into words to obtain a rule segmentation sequence; For each word element in the rule-based word segmentation sequence, the unit of measurement of the word element is converted into a preset standard unit. Based on the standard term matching the word element in the preset standard term database, the word element is replaced with the standard term to obtain the target rule-based word segmentation sequence. For each rule text corresponding to the target rule word segmentation sequence, the sub-rule word segmentation sequence of the rule text is encoded to obtain the original rule vector, and the original rule is extracted from the rule text based on the preset rule extraction template; The original rule vector is compressed to obtain a compressed rule vector; The original rule vector, the compressed rule vector, and the original rule are associated and stored in the vector library.
8. An identification device, characterized in that, The device includes: The acquisition module is used to acquire the power grid data to be detected. An encoding module is used to encode the power grid data into a target text vector if the power grid data includes unstructured data; The matching module is used to query the matching rule vector in the vector library based on the target text vector, obtain the original rule associated with the rule vector, and obtain a subset of candidate rules composed of the rule vector and the original rule; the matched rule vector is a preset number of rule vectors that are ranked first after descending similarity or rule vectors with similarity greater than a preset similarity threshold; the vector library stores the rule vectors obtained by encoding the power grid rule text and the original rules extracted from the power grid rule text, and the rule vectors are associated with the original rules; The target module is used to inject the target text vector and the candidate rule subset into a preset prompt word template, and guide the target semantic model to output the current power grid event according to the preset prompt word template.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
