1. Introduction
The relay protection system is a critical defense line ensuring the safe and stable operation of power systems [
1,
2]. With the increasing integration of renewable energy sources, distributed generators, and power electronic equipment, the characteristics of grid faults, short-circuit current levels, sequence component features, and protection operating conditions have all undergone significant changes. Traditional relay protection faces new challenges in sensitivity, selectivity, reliability, and coordination settings [
3,
4]. Meanwhile, digital protection devices, protection information systems, and substation monitoring systems continuously generate large volumes of SOE (Sequence of Events) alarms, action reports, device records, and O&M texts during operation, which are closely related to protection function numbers, communication protocols, and substation automation standards. Therefore, relay protection O&M is no longer merely the judgment of a single device action result, but rather a comprehensive analysis process involving multi-source data, multiple device types, various protection functions, and complex secondary circuit logic.
Relay protection O&M knowledge is typically dispersed across device manuals, operating regulations, alarm texts, and historical disposal records. Such texts are characterized by dense professional terminology, numerous abbreviations, and nested action criteria with complex logic. When on-site O&M personnel analyze complex alarms, they often need to search back and forth among multiple documents, manually sorting out the logical relationships between alarm signals, protection functions, functional components, setting parameters, and primary equipment. This process is not only time-consuming but also highly dependent on personal experience, making it difficult to ensure consistency and traceability of analysis results in complex scenarios.
Knowledge graphs can organize domain knowledge in the form of “entity–relationship–entity” triples and support semantic retrieval, association analysis, and explainable reasoning through explicit relational expressions [
5,
6]. In recent years, artificial intelligence, graph learning, and knowledge modeling methods have received widespread attention in the field of power system fault diagnosis and intelligent O&M. For example, research on distribution network fault diagnosis has shown that artificial intelligence and signal processing methods have become important technical directions for smart grid fault analysis [
7]; GraphSAGE-based power system fault diagnosis and localization methods demonstrate that graph structure modeling can effectively express power grid topology and fault association information [
8]. Furthermore, knowledge graph-enhanced methods for power secondary system operation risk assessment show that structured domain knowledge helps improve risk identification and semantic understanding capabilities [
9]; research on named entity recognition for power equipment maintenance work orders also indicates that entity extraction from professional O&M texts is an important foundation for equipment knowledge organization and intelligent retrieval [
10].
In the field of natural language processing, pre-trained language models and sequence labeling models provide effective methods for professional text knowledge extraction. BERT, MacBERT, and other pre-trained models can enhance contextual semantic representations [
11,
12], while BiLSTM-CRF and its improved models can combine contextual features and label transition constraints to improve entity boundary recognition [
13,
14]. For relation extraction, methods such as convolutional neural networks, attention mechanisms, and bidirectional recurrent neural networks have been widely used for semantic relationship discrimination between entity pairs [
15,
16]. However, in relay protection texts, entity boundaries are often determined by adjacent terms collectively. For example, continuous professional phrases such as “PT disconnection blocking logic,” “zero-sequence overcurrent protection startup,” and “distance protection blocking signal” have entity boundaries that depend on local neighborhood features near the boundaries, which may still be overlooked when relying solely on global contextual representations.
With the advancement of large language models and retrieval-enhanced generation techniques, integrating external knowledge into the Q&A generation process has become a key approach to enhancing the reliability of specialized queries. Traditional RAG systems improve Q&A performance by retrieving text fragments [
17]; recent studies have combined knowledge graphs with RAG, demonstrating how structured evidence enhances retrieval and reasoning in manufacturing document Q&A [
18], CNC fault diagnosis [
19], and the general GraphRAG framework [
20], providing valuable insights for interpreting relay protection alarms.
Although previous research has made progress in knowledge modeling and text extraction for power equipment operation and maintenance, significant shortcomings remain in relay protection applications: entity names are often lengthy with boundary dependencies that rely on local context, and existing models inadequately utilize neighborhood information; current knowledge graphs struggle to simultaneously represent engineering semantic relationships among secondary circuit signals, protection functions, functional components, set parameters, and primary equipment; existing validation efforts primarily focus on visual queries, lacking an alarm interpretation process that integrates knowledge graph triples with large language model (LLM) question-answering.
To address these limitations, this paper proposes a knowledge graph construction and application framework for relay protection O&M based on multi-source technical documents and operational alarm texts. At the knowledge extraction stage, a gated neighbor fusion (GNF) mechanism is introduced to adaptively integrate global contextual representations with adjacent semantic information without relying on external lexical resources. The mechanism is applied to entity recognition and further extended to candidate entity–pair relation classification. The main contributions of this paper are as follows:
(1) A domain schema layer oriented toward relay protection O&M is constructed, defining five core entity types—primary equipment, protection functions, functional components, setting parameters, and secondary circuit signals—along with four semantic relationships: triggers, contains, depends on, and linked to. This schema provides unified constraints for subsequent knowledge extraction, triple generation, and graph queries.
(2) A MacBERT-GNF-CRF entity recognition model is proposed, in which a learnable gate adaptively balances global contextual semantics and adjacent boundary information without requiring external lexical resources. The same GNF mechanism is further extended to candidate entity–pair relation classification.
(3) A MacBERT-GNF-RC relation extraction model is constructed to distinguish four domain relations and No Relation between candidate entity pairs. After filtering unrelated pairs, the extracted triples are normalized and imported into Neo4j for structured storage and graph-based retrieval.
(4) A knowledge graph-enhanced relay protection alarm Q&A prototype is constructed and validated using a 220 kV line protection composite alarm as an example, analyzing the role of graph triple evidence in alarm cause explanation and inspection suggestion generation.
3. Knowledge Extraction and Fusion Method
Relay protection documentation is characterized by a high concentration of technical terminology, numerous abbreviations, and complex composite naming conventions, with entity boundaries often determined by local collocation relationships between adjacent terms. Therefore, this section designs the knowledge extraction method around two requirements: first, improving boundary-aware entity representation for NER; second, converting recognized entities into reliable entity–pair relations for triple construction. Specifically, MacBERT is used to capture global contextual semantics, the gated neighbor fusion (GNF) layer is introduced to strengthen local boundary features, and the CRF layer is used to enforce global label-sequence consistency. On this basis, a relation extraction module is further constructed to generate triples for subsequent knowledge fusion and graph construction.
3.1. Named Entity Recognition Model
Named Entity Recognition (NER) is a key technology for constructing high-quality domain knowledge graphs and realizing knowledge extraction in relay protection [
21]. The proposed NER model adopts a hierarchical structure of MacBERT encoding, neighborhood feature fusion, and label decoding. It consists of a MacBERT pre-trained encoding layer, a gated neighbor feature fusion layer, a linear mapping layer, and a CRF decoding layer. The overall structure is shown in
Figure 3.
The processing flow is as follows. The input text is encoded by MacBERT to obtain contextual semantic representations at each position. For each position, left and right neighborhood information is introduced and fused through a gating mechanism. The fused features are mapped by a linear layer to obtain tag emission scores. Finally, the CRF layer uses label transition constraints to decode the globally optimal label sequence. Different from a conventional CRF model that relies only on label transition probabilities, the proposed model explicitly injects neighborhood contextual information before CRF decoding, so that entity boundary features are strengthened at the representation stage.
3.2. MacBERT Pre-Trained Encoding Layer
MacBERT is a pre-trained language model specifically optimized for Chinese corpora. It addresses the inconsistency between pre-training and fine-tuning phases through strategies such as full-word masking, and N-gram masking, while enhancing the semantic representation capability of multi-character Chinese words [
12].
In this paper, MacBERT is used as the basic encoder. Let the input text sequence be:
where
denotes the input token at the t-th position and
is the sequence length. After MacBERT encoding, the contextual representation corresponding to each position is obtained as follows:
where
and
is the hidden representation dimension. MacBERT is particularly suitable for Chinese professional texts because its masking strategy and perturbation mechanism reduce the mismatch between pre-training and downstream sequence labeling tasks.
3.3. Gated Neighbor Feature Fusion Layer
A relay protection entity typically consists of multiple consecutive terms, and its boundary identification relies on the local contextual relationships between the current position and its immediate neighbors. To enhance the local semantic representation near boundaries, this paper introduces a neighborhood-gated feature fusion layer following the MacBERT encoding layer.
Compared to existing local-feature enhancement approaches, the proposed GNF mechanism has two characteristics. First, conventional CNN-based local encoders typically aggregate neighboring features using shared convolution kernels, whereas GNF employs a learnable gate at each token position to adaptively balance the global contextual representation and the neighborhood-fused representation. This enables tokens inside long professional terms and those near entity boundaries to receive different degrees of local enhancement. Second, unlike lexicon-augmented Chinese NER methods that depend on external word dictionaries, GNF requires no additional lexical resources, making it suitable for relay protection texts containing numerous manufacturer-specific terms and abbreviations.
In the following equations, denotes the global contextual representation of the -th token generated by the MacBERT encoder, where is the hidden representation dimension. Accordingly, and denote the contextual representations of the immediate left and right neighboring tokens, respectively. The local neighborhood vector is constructed by concatenating , and . The candidate representation denotes the neighborhood-enhanced representation obtained through nonlinear transformation, while denotes the learnable gate vector that adaptively controls the element-wise contribution of and the original contextual representation . The resulting fused representation is denoted by .
For the t-th position in the sequence, its left-neighborhood representation
, current representation
, and right-neighborhood representation
are considered simultaneously, and the local neighborhood representation is constructed as:
where
denotes vector concatenation. For the first and last positions of the sequence, missing neighborhood vectors are padded with zero vectors.
On this basis, a candidate fused representation is first generated through nonlinear mapping:
where
and
are trainable parameters. A gate vector is then introduced to control the weight allocation between the original representation of the current position and the neighborhood-fused representation:
where
denotes the sigmoid function, and
and
are gate parameters. The enhanced local representation is finally defined as
where
denotes element-wise multiplication.
To improve training stability and reduce the influence of representation distribution differences across positions, the fused representation is further normalized:
After gated neighbor fusion, local structural information is directly encoded into the representation of each token without significantly increasing model complexity, which benefits subsequent tag prediction. The structure of the gated neighbor feature fusion mechanism is shown in
Figure 4.
3.4. Linear Mapping Layer
The enhanced representation from neighborhood gated feature fusion already contains the current position semantics and local neighborhood structural information. To map this feature to the label space, this paper uses a linear layer to generate the label emission score at each position:
where
and
are the linear mapping layer parameters, and
denotes the emission score of each label corresponding to the t-th position, to be used by the subsequent CRF layer for decoding.
3.5. CRF Decoding Layer
Entity recognition requires not only correct classification at each position but also overall legality of the label sequence. For example, in BIO annotation, “I-Protection Function” cannot directly follow “B-Setting Parameter”. Therefore, this paper adds a Conditional Random Field (CRF) at the output layer to jointly constrain label transitions. Let the input sequence be
and the corresponding label sequence be
; then the total score of this label sequence can be expressed as:
where
denotes the emission score when the t-th position selects label
, and
is the label transition matrix, describing the transition tendency between adjacent labels. The conditional probability is further defined as:
where
denotes the set of all possible legal label sequences for the input sequence
, and
denotes an arbitrary candidate label sequence. During training, the negative log-likelihood is used as the optimization objective. During prediction, the Viterbi algorithm is used to search for the label path with the highest score:
Here, denotes the optimal label sequence predicted by the model; and is the global sequence score computed by the CRF layer. By using Viterbi decoding, the model jointly considers label emission scores and transition constraints between adjacent labels, thereby reducing boundary errors near entities.
3.6. Relation Extraction Model
On the basis of the NER model, the CRF sequence decoding layer is replaced with a relation classification module to construct an entity–pair-oriented relation extraction model. The model also uses MacBERT to encode the text context and applies the GNF mechanism to strengthen local semantic features near entities. Following entity recognition, entity pairs co-occurring within the same sentence are generated as candidate pairs. The MacBERT-GNF-RC model classifies each candidate pair into one of five labels: triggers, contains, depends on, linked to, or No Relation. The model therefore jointly determines whether a semantic relation exists between two entities and identifies the corresponding relation type when a relation is present.
Let the head entity and tail entity in a sentence be eh and et, respectively. First, the GNF-enhanced representations of the tokens corresponding to the two entities are average-pooled to obtain the head entity representation
and the tail entity representation
. The two entity representations are then concatenated to construct the joint feature vector of the entity pair:
where
denotes vector concatenation and
denotes the joint feature vector of the entity pair. The vector is then input to a fully connected classification layer to obtain the probability distribution over candidate relation classes:
where
and
are the weight matrix and bias of the relation classification layer, respectively, and
denotes the probability distribution over the predefined relation categories. Specifically,
denotes the predicted probability that the candidate entity pair
belongs to relation category
and
denotes the predefined set of relation categories. The final predicted relation is selected as the class with the maximum probability:
Figure 5 shows the architecture of the relation extraction model. The model reuses the MacBERT encoder and GNF layer from the NER stage, so that relation classification can exploit both global contextual semantics and local features near entity boundaries. The enhanced head and tail entity representations are concatenated and input into a Softmax classifier to predict the relation label. Entity pairs predicted as No Relation are discarded, while the remaining predictions are organized as candidate triples for manual verification, knowledge fusion, and graph construction.
3.7. Knowledge Fusion and Entity Disambiguation
To minimize node redundancy caused by synonymous expressions and variations in manufacturer naming, entity names must be standardized before being stored as triples. This paper establishes a specialized terminology dictionary containing 3718 standardized relay-protection terms and an abbreviation/alias mapping table containing 974 mappings, together with entity type constraint rules based on terminology conventions in the relay protection domain. These resources provide unified mappings for synonymous, abbreviated, and manufacturer-specific expressions, such as “CT secondary circuit” and “current transformer secondary circuit”. For entities not covered by these rules, manual verification is performed considering the entity context and engineering semantics; if consistent with existing entity definitions, they are standardized into corresponding standard entities; otherwise, they are added as new entity nodes to the knowledge graph. After these steps, the processed triples are imported into the Neo4j graph database.
5. Knowledge Graph Construction and Application
The preceding section verifies the effectiveness of the proposed entity and relation extraction models. On this basis, this section organizes the extracted entities and relations into standardized triples, imports them into Neo4j, and further applies the constructed knowledge graph to KG-augmented alarm interpretation.
5.1. Graph Construction
After model evaluation, the trained MacBERT-GNF-CRF model was applied to the relay protection corpus to identify entity mentions. Entity pairs co-occurring within the same sentence were subsequently classified by MacBERT-GNF-RC. Pairs predicted as No Relation were discarded, while the remaining candidate triples were manually reviewed to correct erroneous entity or relation labels. After terminology normalization and entity fusion, 5642 validated entity instances and 5128 relation triples were retained and imported into Neo4j using Cypher statements.
5.2. Knowledge Graph-Augmented Alarm Question-Answering Prototype
After completing the knowledge graph construction, this paper developed an enhanced alarm Q&A prototype based on the knowledge graph. The prototype utilizes the relay protection knowledge graph in Neo4j as a structured knowledge source. Upon receiving an SOE alarm record or a natural language query, the system retrieves relevant graph nodes and their adjacency relationships based on alarm signals and protection terminology, returns evidence triples related to the alarm, and feeds these into a large language model as structured context to generate potential causes and inspection recommendations.
Compared to directly calling large language models, knowledge graph-enhanced Q&A addresses queries using a model constrained by structured evidence, reducing the risk of unfounded inferences and providing operations personnel with traceable relationship paths. The workflow of the KG-augmented alarm Q&A prototype is summarized in
Figure 10.
5.3. Typical Alarm Case and Comparative Analysis
A 220 kV line protection alarm event was selected as a representative case study. This incident involved multiple SOE signals—including “abnormal secondary voltage on PT,” “distance protection lockout signal,” “zero-sequence overcurrent protection activation,” and “line protection device alarm”—and encompassed information from various systems such as the secondary voltage circuit, distance protection lockout logic, and zero-sequence overcurrent protection mechanisms, making it well-suited for multi-signal correlation analysis.
From the perspective of relay protection principles, an abnormal PT secondary voltage indicates that the voltage measurement supplied to the protection device may be unreliable. When voltage-circuit supervision or PT-disconnection logic detects such an abnormality, the distance protection function may be blocked to avoid incorrect operation caused by unreliable impedance calculation. Meanwhile, the startup of zero-sequence overcurrent protection indicates the presence of a zero-sequence current component and can serve as evidence of a possible ground fault; however, this signal alone is insufficient to confirm a primary-system fault. Therefore, the main suspected causes in this composite alarm include PT secondary-circuit disconnection or abnormal voltage sampling, while the possibility of a primary ground fault should be further verified using fault waveforms and zero-sequence current records.
To ensure comparability, this study employs the DeepSeek-V3.2 model via the DeepSeek API, implementing two input approaches: direct question-answering and knowledge graph-enhanced question-answering. The former uses only alarm text as input, while the latter incorporates graph triples retrieved from Neo4j alongside the same alarm text. Both methods employ identical models, question formulations, and default API configurations, differing solely in whether graph evidence is provided. Both approaches require the model to identify the most probable cause and prioritize inspection items. This comparison represents a case study rather than a large-scale performance evaluation of question-answering systems, primarily aimed at assessing how graph triples enhance traceability in alarm explanations.
Table 10 presents the key KG evidence obtained from analysis in this case. The relevant triples establish connections between alarm signals and various parameters, including voltage circuit monitoring, distance protection, PT open-circuit lockout elements, lockout logic, and zero-sequence overcurrent protection. Specifically, triples related to PT secondary voltage anomalies and distance protection support troubleshooting of the secondary circuitry and lockout logic, while the activation of zero-sequence overcurrent protection serves as an auxiliary indicator for identifying primary ground faults.
Under identical alarm input conditions, when the large language model is directly invoked, it can provide reasonable diagnoses such as PT secondary circuit faults or open circuits, and recommend checking the PT secondary fuse, secondary wiring, grounding status, and distance protection PT lockout settings. However, this response primarily relies on the model’s general domain knowledge without providing clear structured evidence support, particularly lacking traceable justification for its diagnosis of primary ground faults.
In contrast, the knowledge graph-enhanced question-answering approach first returns the graph triple evidence shown in
Table 10, linking information such as PT secondary voltage anomalies, line protection device alarms, distance protection lockout, and zero-sequence overcurrent protection activation. Based on these structured pieces of evidence, the model identifies the primary suspected causes as PT secondary circuit abnormalities, secondary-circuit disconnection, or voltage sampling errors, recommending priority inspection of the PT secondary circuit and distance protection lockout status; for zero-sequence overcurrent protection activation, it serves as an auxiliary diagnostic clue, suggesting that the presence of a primary ground fault should be further determined by combining fault waveforms and zero-sequence current records rather than treating it as a definitive conclusion.
This case demonstrates that KG-enhanced Q&A improves the traceability of alarm explanations by leveraging structured evidence chains, distinguishes between primary causes and supporting clues, reduces unfounded inferences, and generates inspection recommendations more aligned with actual operational workflows.
This representative 220 kV alarm event was also included as Case 09 in the 50-case expert evaluation described in
Section 5.4. For this case, the average scores assigned by the three experts to the direct LLM response were 3.67, 3.00, 3.33, and 3.33 for cause correctness, evidence traceability, inspection practicality, and overall reliability, respectively. The corresponding KG-augmented response achieved average scores of 4.67, 4.33, 4.67, and 4.33, respectively. These case-level results are consistent with the overall trend observed in the 50-case evaluation and further illustrate the benefit of incorporating structured graph evidence into alarm interpretation.
5.4. Small-Scale Expert Evaluation
To provide a preliminary quantitative evaluation of the KG-augmented Q&A prototype, 50 representative composite alarm cases were selected from historical alarm records. Three experts with relay protection backgrounds independently evaluated the outputs generated by direct LLM question-answering and KG-augmented question-answering. Each answer was scored on a five-point scale in terms of cause correctness, evidence traceability, inspection practicality, and overall reliability. The average evaluation results are shown in
Table 11.
The KG-augmented approach achieved higher scores across all four evaluation dimensions, with the most evident improvement observed in evidence traceability. For each case and evaluation metric, the ratings of the three experts were averaged, and two-sided paired
-tests were then conducted across the 50 case-level mean scores. The results showed that the KG-augmented approach significantly outperformed the direct LLM approach across all four evaluation metrics (all
< 0.001). To further assess the consistency of the expert ratings, inter-rater reliability was evaluated using Fleiss’ kappa separately for each evaluation metric and each answering approach. For the calculation, the five score levels were treated as discrete rating categories. Let
denote the number of evaluated cases,
the number of experts,
the number of rating categories, and
the number of experts assigning case
to category
. In this study,
= 50,
= 3, and
= 5.
Here,
denotes the observed agreement for case
,
is the mean observed agreement across all cases,
is the overall proportion of ratings assigned to category
, and
is the agreement expected by chance. Fleiss’ kappa therefore normalizes the observed agreement relative to chance agreement, with
indicating perfect agreement and
0 indicating agreement at the chance level. The resulting coefficients are shown in
Table 12.
The Fleiss’ kappa coefficients ranged from 0.507 to 0.684 for the direct LLM approach and from 0.503 to 0.796 for the KG-augmented approach across the four evaluation dimensions, indicating generally moderate to substantial agreement among the three experts. It should be emphasized that Fleiss’ kappa measures inter-rater agreement rather than system performance; therefore, differences in kappa between the two approaches do not directly indicate differences in answer quality. Combined with the consistently higher mean scores reported in
Table 11 and the statistically significant paired comparisons, these results support the reliability of the expert evaluation and indicate that structured graph evidence improves the evidential basis of generated answers, alarm interpretation, and inspection recommendations.
6. Discussion
The experimental results indicate that the GNF mechanism is effective for extracting relay protection knowledge. Compared with MacBERT-CRF and MacBERT-BiLSTM-CRF, MacBERT-GNF-CRF achieved higher and more stable recognition performance. The ablation results further show that neighborhood information, gated fusion, CRF decoding, and LayerNorm jointly contribute to entity boundary identification. This suggests that adaptively integrating adjacent semantic units is beneficial for recognizing long and compositionally complex relay protection terms.
The improvement in MacBERT-GNF-RC demonstrates that neighborhood-enhanced entity representations are also useful for relation classification. At the application level, the knowledge graph provides explicit relation paths connecting alarm signals, protection functions, functional components, and setting information. The expert evaluation shows that KG augmentation produces the greatest improvement in evidence traceability while also improving cause correctness and inspection practicality. Therefore, the main value of the knowledge graph is to provide structured evidence constraints for alarm interpretation rather than merely support graph storage and visualization.
This study still has several limitations. First, the current relation extraction strategy generates candidate entity pairs only when the entities co-occur within the same sentence. This design helps reduce noisy candidate pairs and limits the search space, but semantic relations expressed across sentence boundaries cannot be directly captured. Future work will investigate document-level relation extraction by incorporating cross-sentence contextual representations, coreference information, and graph-based context aggregation. Second, the current corpus and relation schema cover a limited range of relay protection documents and four predefined relation types. In addition, the constructed graph mainly represents textual knowledge and does not yet incorporate fault waveforms or device event sequences. Future work will therefore expand the corpus and alarm cases and construct multimodal knowledge graphs integrating textual, waveform, and event-sequence information.
7. Conclusions
This paper proposes a method for constructing and applying a knowledge graph for relay protection operation and maintenance that incorporates a neighborhood gating mechanism. A domain model covering five types of entities and four semantic relationships was established. The proposed MacBERT-GNF-CRF and MacBERT-GNF-RC models achieved scores of 0.946 and 0.929, respectively, and the resulting knowledge graph provides a foundation for querying and structurally retrieving relay protection operation and maintenance knowledge.
In terms of application, this paper develops a knowledge graph-enhanced alarm Q&A prototype and analyzes it using a composite alarm from a 220 kV line protection system as an example. The results demonstrate that graph triples provide a traceable, structured evidence chain for alarm explanations generated by large language models, thereby supporting cause identification and diagnostic recommendations.
Although the preliminary expert evaluation supports the effectiveness of KG augmentation, the current evaluation scale remains limited, and the generated results are intended only to assist operational analysis. Future work will expand the corpus and authentic alarm dataset, evaluate additional large language models, and integrate fault waveforms, device event records, and textual knowledge into a multimodal knowledge graph.