Power grid equipment fault case detection method and system based on multi-granularity retrieval
By using a multi-granularity retrieval method to structure and index power grid equipment fault cases, the problem of low efficiency and poor accuracy in querying power grid equipment fault cases in existing technologies is solved. This enables efficient and accurate fault detection and question answering, thereby improving the level of intelligent operation and maintenance of power grids.
Patent Information
- Application Number
- CN202511439913.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-10
- Publication Date
- 2026-01-09
AI Technical Summary
Existing technologies for querying power grid equipment fault cases are inefficient, inaccurate, lack sufficient data cleaning precision, have coarse knowledge representation granularity, use a single retrieval mechanism, employ simple sorting strategies, and have poor question-answer interpretability.
A multi-granularity retrieval method is adopted, and text data is extracted through optical character recognition technology. A domain-adaptive natural language processing model is constructed for error correction and structured processing. Fault cases are decomposed into knowledge units of equipment-defect-cause-processing-result. A dual-path index of dense vectors and sparse keywords is constructed. A comprehensive score is calculated by combining semantic similarity and keyword matching degree. A time decay factor is introduced for re-sorting, and finally an interpretable natural language answer is generated.
It enables efficient and accurate detection and Q&A of power grid equipment fault cases, improves data utilization efficiency and interpretability, and significantly reduces the time cost of fault query and handling decisions.
Smart Images

Figure CN121301522A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of power grid equipment fault detection, and in particular to a power grid equipment fault case detection method and system based on multi-granularity retrieval, which is suitable for intelligent question answering, defect diagnosis and operation and maintenance decision support of fault cases of devices such as transformers, circuit breakers and disconnectors in power systems. BACKGROUND
[0002] With the expansion of the power grid scale and the aggravation of the equipment aging problem, equipment failures occur frequently, which seriously threatens the safe and stable operation of the power grid. Power grid enterprises have accumulated a large amount of fault case data in the long-term operation and maintenance process. These data usually exist in the form of paper books or scanned documents, and the content is complex and the format is different, which is difficult to be efficiently utilized.
[0003] The traditional fault case query method mainly relies on manual retrieval, which is low in efficiency, poor in accuracy, and strongly dependent on personnel experience. In recent years, with the development of natural language processing (NLP) and knowledge graph technology, some research attempts to structure the fault cases and build a knowledge base to realize intelligent question answering. However, the existing methods generally have the following problems: 1) Insufficient data cleaning accuracy: optical character recognition (OCR) recognition error, non-standard terminology, and much text noise affect the subsequent processing effect; 2) Coarse knowledge representation granularity: only the whole document or paragraph is indexed, which cannot accurately match the user query intention; 3) Single retrieval mechanism: relying on keyword matching or pure semantic retrieval, it is difficult to balance accuracy and recall rate; 4) Simple sorting strategy: without considering multi-dimensional factors such as case timeliness and relevance, the sorting result is unreasonable; 5) Poor question and answer explainability: the generated answer does not provide reference sources, and the user cannot verify the credibility of the answer.
[0004] Therefore, there is an urgent need for a high-precision, interpretable and easy-to-expand power grid equipment fault case detection method to improve the usability and intelligent level of case knowledge. SUMMARY
[0005] The present application provides a power grid equipment fault case detection method and system based on multi-granularity retrieval, which aims to solve the problems of incomplete case data cleaning, non-precise knowledge representation, single retrieval mechanism, simple sorting strategy and poor question and answer explainability in the prior art, and realizes efficient, accurate and intelligent detection and question answering of power grid equipment fault cases.
[0006] To achieve the above-mentioned purpose, the technical solution provided by the present application is: a power grid equipment fault case detection method based on multi-granularity retrieval, comprising the following steps: S1: Collect power grid equipment failure case documents, extract original text data through optical character recognition technology, and build a field-adaptive natural language processing cleaning model based on a power grid field dictionary and a pre-trained language model to correct errors, sentence segmentation, named entity recognition and denoising processing of the original text data, and generate a structured text set; S2: Divide the structured text into knowledge units, decompose each failure case into several standardized knowledge units, each knowledge unit includes five types of core information: device type, defect description, failure cause, treatment measure and treatment result, forming a "device-defect-cause-treatment-result" five-tuple structure representation; S3: Build a multi-granularity semantic index based on the knowledge unit, use a dense vector encoder to embed the semantic of the knowledge unit, build a vector index while retaining the key word information to build an inverted index, forming a dual-channel retrieval mechanism; S4: Receive the user's input query statement, calculate the semantic similarity and keyword matching degree between it and each knowledge unit respectively, calculate the comprehensive score by weighted fusion method, and recall the top K most relevant knowledge units according to the comprehensive score; S5: Introduce time decay factor and regional similarity as auxiliary features, combine semantic score and keyword matching degree, and use a ranking model (Learning-to-Rank) for re-ranking to output the ranking results of the recalled knowledge units; S6: Based on the retrieval enhancement generation framework, based on the re-ranking results of the recalled knowledge units, input the top-ranked knowledge units as context to the pre-trained language model, generate fault analysis answers in natural language form, and attach the original text of the reference case, similarity score and highlighted key sentences, realize the explainability output.
[0007] Further preferably, the field-adaptive natural language processing cleaning model is: fine-tuning the BERT model based on the power grid equipment failure field corpus, and combining the CRF layer for named entity recognition, identifying entities including: device name, defect type, failure phenomenon, processing action, result state, and building a field dictionary for correcting optical character recognition errors.
[0008] Further preferably, the five-tuple structure representation of the knowledge unit is: ; Wherein, i is the failure case index, j is the knowledge unit index, represents the jth knowledge unit in the ith failure case, represents the device type of the jth knowledge unit in the ith failure case, represents the defect description of the jth knowledge unit in the ith failure case, failure cause of the jth knowledge unit in the ith failure case, handling measure of the jth knowledge unit in the ith failure case, handling result of the jth knowledge unit in the ith failure case, each field is a natural language text segment, supporting subsequent semantic encoding and retrieval.
[0009] Further preferably, the comprehensive score calculation formula in the two-way retrieval mechanism is: ; wherein, comprehensive score, user query statement dense vector representation generated by a pre-trained semantic encoder; dense vector representation of the knowledge unit , also generated by a pre-trained semantic encoder, vector with dimensions; cosine similarity between and , used to measure the degree of matching at the semantic level; sparse retrieval score based on the bag-of-words model, used to measure the degree of matching at the keyword level; is a dynamically learnable weight parameter.
[0010] Further preferably, the pre-trained semantic encoder is fine-tuned based on a power grid equipment failure domain corpus, adopts a contrastive learning approach, constructs positive sample pairs and negative sample pairs, and optimizes the pre-trained semantic encoder by maximizing the semantic similarity between positive sample pairs and minimizing the similarity between negative sample pairs.
[0011] Further preferably, the knowledge unit text is preprocessed before calculating the sparse retrieval score based on the bag-of-words model, including removing stop words, unifying device terminology, and introducing synonym expansion.
[0012] Further preferably, the reordering process is as follows: first, the timeliness of the case is measured by a time decay factor, and the calculation formula is: ; wherein, weight coefficient based on the time decay factor, publication time of the failure case ; current query time; decay coefficient, positive real number domain; Subsequently, the feature vector of the candidate case is constructed: ; wherein, is a feature vector, including a dense vector of a user query statement and a dense vector of a fault case and a cosine similarity of the dense vector of the user query statement and the dense vector of the fault case and a text similarity of the user query statement and the fault case, and a weight coefficient ; and input the feature vector of the candidate case into a Learning-to-Rank model to output a final ranking score for fine ranking of the candidate case; the Learning-to-Rank model is trained based on a small amount of artificially labeled query-case relevance labels, the labels including three categories of very relevant, relatively relevant and irrelevant, and the model is trained in a pairwise ranking or overall ranking manner to optimize a ranking loss function.
[0013] The application also provides a power grid equipment fault case detection system based on multi-granularity retrieval, comprising: a data preprocessing module configured to perform the following operations: collecting power grid equipment fault case documents, extracting original text data through an optical character recognition technology, and constructing a field-adaptive natural language processing cleaning model based on a power grid field dictionary and a pre-trained language model to perform error correction, sentence segmentation, named entity recognition and denoising processing on the original text data to generate a structured text set; a knowledge unit division module configured to perform the following operations: dividing the structured text into knowledge units, decomposing each fault case into a plurality of standardized knowledge units, each knowledge unit including five types of core information of device type, defect description, fault reason, treatment measure and treatment result to form a five-tuple structure representation of "device-defect-reason-treatment-result"; an index construction module configured to perform the following operations: constructing a multi-granularity semantic index based on the knowledge units, performing semantic embedding of the knowledge units by using a dense vector encoder, constructing a vector index while retaining key word information to construct an inverted index, and forming a dual-path retrieval mechanism; a retrieval module configured to perform the following operations: receiving a user input query statement, calculating the semantic similarity and the key word matching degree between the query statement and each knowledge unit respectively, calculating a comprehensive score by using a weighted fusion method, and recalling the top K most relevant knowledge units in order of the comprehensive score; a re-ranking module configured to perform the following operations: introducing a time decay factor and a regional similarity as auxiliary features, combining the semantic score and the key word matching degree, performing re-ranking by using a ranking model, and outputting a ranking result of the recalled knowledge units; The generating module is used for performing the following operations: based on a retrieval enhancement generation framework, based on a reordering result of a recall knowledge unit, inputting a knowledge unit with high ranking to a pre-trained language model as a context to generate a fault analysis answer in a natural language form, and attaching a reference case original text, a similarity score and a highlighted key sentence to realize an interpretable output.
[0014] The application further provides a computer readable storage medium, which has a computer program stored thereon, and the computer program is executed by a processor to realize the power grid equipment fault case detection method based on multi-granularity retrieval.
[0015] The application further provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory, and the processor realizes the power grid equipment fault case detection method based on multi-granularity retrieval when executing the computer program.
[0016] The application can convert unstructured power grid fault cases into high-structured representations of fine-grained and computable semantic vectors by constructing a five-tuple knowledge unit of "equipment-defect-cause-treatment-result", can accurately match user query intentions at a field level compared with a traditional whole-text indexing mode, and can significantly improve recall accuracy; a dense vector and a keyword double-path retrieval fusion mechanism is introduced, and a learnable weight Dynamic balance between semantic generalization and term accurate matching enables the model to have strong semantic fault tolerance while maintaining professional term sensitivity; a time decay factor and a Learning-to-Rank model are introduced in the reordering stage, a small amount of labeled query-case relevance labels can be used to realize continuous optimization of the sorting strategy, and ensure that new cases and highly relevant results are always in the front row; reference-level question and answer generation based on a retrieval augmentation generation (RAG) framework inputs a retrieval result and a prompt template into a field fine-tuned language model, and outputs a structured natural language answer with highlighted references, so that users can directly trace the source and similarity score of each conclusion, and realize integrated and interpretable decision support of "phenomenon-reason-treatment-reference"; the whole process is optimized end to end from OCR cleaning, knowledge extraction, double-path retrieval, time-effect reordering to reference generation, and can adaptively evolve with the growth of the case library without manual rule writing, can be quickly landed in the power grid operation field, and significantly reduces the time cost of fault query and processing decision. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 The figure is a schematic diagram of the framework process of the method. DETAILED DESCRIPTION
[0018] The present application will be further clarified by the following examples, which should be considered as merely illustrative of the present application and not in limitation of the present application's scope. Modifications of the various embodiments of the present application, as they occur to those skilled in the art, are to be within the scope of the application, which is set forth in the claims now appended.
[0019] A power grid equipment fault case detection method based on multi-granularity retrieval, comprising the following steps: S1: Collecting power grid equipment fault case documents, extracting original text data through optical character recognition technology, and constructing a field-adaptive natural language processing cleaning model based on a power grid field dictionary and a pre-trained language model to perform error correction, sentence division, named entity recognition and denoising processing on the original text data to generate a structured text set; S2: Dividing the structured text into knowledge units, each fault case is decomposed into several standardized knowledge units, each knowledge unit includes: equipment type, defect description, fault reason, treatment measures, treatment result five kinds of core information, forming a "equipment-defect-reason-treatment-result" five tuple structure representation; S3: Based on the knowledge unit, a multi-granularity semantic index is constructed, a dense vector encoder is used to perform semantic embedding on the knowledge unit, a vector index is constructed, and a reverse index is constructed while retaining keyword information, forming a dual-channel retrieval mechanism; S4: Receiving a user input query statement, calculating the semantic similarity and keyword matching degree between each knowledge unit, calculating the comprehensive score by using a weighted fusion method, and recalling the top K most relevant knowledge units according to the comprehensive score; S5: Introducing time decay factor and regional similarity as auxiliary features, combining semantic score and keyword matching degree, using a ranking model (Learning-to-Rank) for reordering, and outputting the ranking result of the recalled knowledge units; S6: Based on the retrieval enhancement generation framework, based on the reordering result of the recalled knowledge units, the knowledge units with high ranking are input into the pre-trained language model as context to generate fault analysis answers in natural language form, and the original text of the similar cases, similarity score and highlighted key sentences are attached to realize the explainable output.
[0020] The field-adaptive natural language processing cleaning model in step S1 is based on a power grid equipment standard term library (including equipment name, defect type, fault phenomenon, processing action, etc.) to construct a field dictionary; adopts a BERT+CRF architecture, fine-tunes the BERT model based on the power grid equipment fault field corpus on the basis of a general Chinese BERT, and performs named entity recognition in combination with a CRF layer to identify entities including equipment name, defect type, fault phenomenon, processing action, result state, and improve the identification capability of professional entities; meanwhile, an OCR post-processing module is designed to automatically correct common recognition errors (such as “flashover”→“flash road”, “iron core”→“iron core”) based on the field dictionary and context semantics; then a sentence segmentation model (based on a Transformer) is used to perform semantic-level sentence segmentation on long texts to avoid semantic fragmentation caused by traditional rule methods; finally, the cleaned texts are subjected to denoising processing, including removing the header and footer, deleting invalid characters, and unifying unit symbols to generate a structured and standardized text collection.
[0021] The knowledge unit division and five-tuple structure based on the joint extraction framework of rules+model in step S2: the rules are used to identify high-frequency patterns (such as “appear…defect”, “reason is…”, “handle…”) and the model is used to extract variant expressions; and each field in the five-tuple is a natural language text segment, supporting subsequent semantic coding and retrieval; multiple fault phenomena in the same case are supported to be split to generate multiple knowledge units, improving the retrieval granularity; all knowledge units are uniformly coded as a JSON structure, supporting subsequent index construction and front-end display. The five-tuple structure of the knowledge unit is represented as: ; wherein i is the fault case index, j is the knowledge unit index, represents the jth knowledge unit in the ith fault case, represents the equipment type of the jth knowledge unit in the ith fault case, represents the defect description of the jth knowledge unit in the ith fault case, represents the fault reason of the jth knowledge unit in the ith fault case, represents the processing measure of the jth knowledge unit in the ith fault case, represents the processing result of the jth knowledge unit in the ith fault case, and each field is a natural language text segment, supporting subsequent semantic coding and retrieval.
[0022] Further, step S3 uses SimCSE-chinese to encode each field of the five-tuple respectively to obtain a d-dimensional vector, then splices by bit to obtain a 5d-dimensional overall representation, and constructs two-level FAISS index: field-level IndexFlatIP supports single-field query, and overall-level IndexIVFFlat supports whole-unit query; at the same time, the text after term normalization and stop word removal is written into the Elasticsearch inverted index, the field weight is configured as "defect>reason>processing>device>result", and a dense-sparse double-path retrieval mechanism that can be independently retrieved and jointly recalled is formed. The comprehensive score calculation formula in the double-path retrieval mechanism is: ; wherein, represents the comprehensive score, represents the dense vector representation of the user query statement , generated by a pre-trained semantic encoder; represents the dense vector representation of the knowledge unit , also generated by a pre-trained semantic encoder, represents a vector with a dimension of ; represents and cosine similarity between them, used to measure the matching degree at the semantic level; represents the sparse retrieval score based on the bag-of-words model, used to measure the matching degree at the keyword level; is a dynamic learnable weight parameter.
[0023] Further, before calculating the sparse retrieval score based on the bag-of-words model, the knowledge unit text is preprocessed, including: removing stop words, unifying device terms, and introducing synonym expansion.
[0024] Further, in step S4, the pre-trained semantic encoder is fine-tuned based on the power grid device fault domain corpus for domain adaptation, adopts a contrastive learning method, constructs positive sample pairs and negative sample pairs, optimizes the pre-trained semantic encoder by maximizing the semantic similarity between positive sample pairs and minimizing the similarity between negative sample pairs. In this embodiment, the query statement is mapped to a d-dimensional space by the same SimCSE encoder, and the cosine similarity is calculated with the device, defect, reason, processing, and result five field vectors in turn, and the maximum value is taken as ; after synonym expansion and term normalization are performed on the query, the BM25 score is calculated according to the preset field weight ; the final fusion score is controlled by the learnable parameter : , Initial 0.6 and fine-tune on a small amount of labeled data with NDCG as the indicator, and the top K units in the recall stage are entered into the subsequent rearrangement.
[0025] Further, step S5 introduces a time decay factor for the recall set , Automatic selection according to the case library update cycle; build features , input LightGBM-LambdaMART model training, target optimization NDCG@10, output during inference Complete fine arrangement, put new cases and highly relevant units in the front row. The process of reordering is as follows: first, measure the timeliness of the case through the time decay factor, and its calculation formula is: ; Among them, is the weight coefficient based on the time decay factor, is the release time of the fault case ; is the current query time; is the decay coefficient, is a positive real number field; Subsequently, the feature vector of the candidate case is constructed: ; Among them, is the feature vector, including the dense vector of the user query statement and the cosine similarity of the dense vector of the fault case , as well as the text similarity between the user query statement and the fault case , and the weight coefficient ; ; And input the feature vector of the candidate case into the ranking model to output the final ranking score , which is used to fine arrange the candidate cases; the ranking model is trained based on a small amount of artificially labeled query-case relevance labels, which include three categories: very relevant, relatively relevant, and irrelevant. Pairwise ranking or overall ranking is used for training, and the ranking loss function is optimized.
[0026] Further, step S6 takes the top three knowledge units before fine arrangement and concatenates them in descending order of score to form the context C, designs a fixed Prompt template to guide ChatGLM-6B-LoRA to generate an answer containing "phenomenon-reason-treatment-reference" four paragraphs, and inserts references at the end of each paragraph in the form of [case+i|similarity:score|time:yyyy-mm|"highlight sentence"]. The highlight sentence is located by the field-level similarity and highlighted in the front end, realizing natural and smooth and traceable interpretable output.
[0027] The embodiments of the present application are further illustrated below in combination with actual cases.
[0028] Firstly, in the data input stage, the system receives scanned documents or PDF files from the power grid operation department, covering equipment defect reports, accident analysis records and other unstructured texts. After extracting the original text through the OCR engine, it enters the cleaning and structured preprocessing link. To cope with the characteristics of dense terminology and strong professional expression in the power field, the NLP cleaning model built by the present application adopts the BERT-CRF architecture, which is based on the general Chinese pre-training model and fine-tuned on the power grid domain corpus. This corpus contains a large amount of annotated text covering fault descriptions in typical scenarios such as transformers, circuit breakers, GIS devices, etc. The CRF layer is used for sequence labeling to accurately identify five types of entities: "device name", "defect type", "fault cause", "treatment action" and "result status". At the same time, the system has a built-in power grid terminology dictionary to support automatic error correction of common OCR errors in the context, such as correcting "flash road" to "flashover" according to semantic context, and restoring "iron core" to "iron core", thereby improving the semantic accuracy of the original text. Text cleaning also includes semantic-based sentence segmentation to avoid information fragmentation caused by traditional punctuation segmentation, and removes interference information such as headers, page numbers and table markers through a denoising module, outputting a standardized and clearly structured text set.
[0029] After the text cleaning is completed, the structured extraction of knowledge units is carried out. Each fault case is decomposed into several standardized knowledge units, forming a "device-defect-cause-treatment-result" five-tuple representation , where each field is a natural language segment that retains the original semantic information. The extraction process adopts a rule and model cooperative strategy: rule template matches common sentence structures, such as "because…causes…" for extracting causes, and "after…" for extracting treatments and results; for complex or non-standard expressions, a Span-based extraction model is called to complete the information to ensure completeness. If multiple independent fault phenomena are involved in the same case, the system supports splitting into multiple knowledge units to improve the granularity and matching accuracy of subsequent retrieval. All extraction results are stored in a structured format for indexing and system integration.
[0030] To achieve efficient and accurate retrieval, a multi-granularity semantic indexing system is constructed. A dual-path retrieval mechanism is adopted, combining dense vectors and sparse keywords. In the dense retrieval aspect, SimCSE-chinese-large is selected as the semantic encoder, and fine-tuned on the power grid domain corpus for comparative learning, optimizing its semantic discrimination ability in the professional field. The five fields of each knowledge unit are encoded into dimensional vectors, respectively, and then concatenated into , the whole expression is represented, the FAISS vector index is constructed, and efficient approximate nearest neighbor search is supported. At the same time, field-level vector index is established to support directional retrieval according to specific dimensions such as equipment and defects. In the aspect of sparse retrieval, after the knowledge unit text is normalized by terms (such as "main variable" unified as "transformer") and synonym expansion (such as "oil leakage" expanded as "oil seepage, leakage"), the text is written into the Elasticsearch inverted index, and the weight is configured according to the field importance, and the defect field weight is the highest, so as to ensure that the key information is matched preferentially.
[0031] When a user submits a query statement , the system performs parallel two-way retrieval. The query statement is encoded into a dense vector by the same SimCSE encoder, the cosine similarity between the dense vector and the five-field vector of each knowledge unit is calculated, and the maximum value is taken as the semantic score ; meanwhile, the BM25 keyword matching score in Elasticsearch is calculated . The two scores are combined to obtain: ; After the preliminary recall of the top K candidate knowledge units, the reordering stage is entered. In order to improve the relevance and timeliness of the results, a time decay factor is introduced, which is dynamically adjusted according to the case library update frequency. A multi-dimensional feature vector is constructed, including semantic score, keyword score, time decay weight, knowledge unit length and field coverage, which is input into the LightGBM-LambdaMART sorting model. The model is trained on artificially annotated query-case relevance data, and the NDCG@10 index is optimized, and the fine sorting score is output to realize accurate sorting.
[0032] Finally, in the generation stage, the Retrieval Augmentation Generation (RAG) framework is used, and the fine sorting result is input into the domain fine-tuned generation model (such as ChatGLM-6B-LoRA) as context. By designing a fixed Prompt template, the model is guided to generate structured answers containing phenomena, reasons, treatment measures, etc., and reference information is inserted at the end of each paragraph to mark the case source, similarity score and highlighted key sentences, realizing traceable, verifiable and interpretable output.
[0033] This method realizes end-to-end processing from unstructured text to intelligent question and answer through full-process collaborative design, which significantly improves the retrieval accuracy and decision support capability of power grid fault cases.
[0034] Table 1: Performance comparison of the present application and other methods under various evaluation indicators
[0035] BM25 is a classic sparse retrieval function, which retrieves and ranks documents based on the term frequency-inverse document frequency ranking formula; SimCSE is a dense sentence vector model obtained by unsupervised contrastive learning; GNNRet is a context-node retrieval model based on graph neural network; RAG-only represents an end-to-end baseline of "retrieval + splicing generation" without additional fine-tuning; PromptRet is a parameterized retriever driven by a learnable prompt vector; MultiRet is a cascading retriever supporting multi-hop evidence chain retrieval.
[0036] Another embodiment of the application provides a power grid equipment fault case detection system based on multi-granularity retrieval, comprising: A data preprocessing module is configured to collect power grid equipment fault case documents, extract original text data through optical character recognition technology, and construct a field-adaptive natural language processing cleaning model based on a power grid field dictionary and a pre-trained language model to generate a structured text set by performing error correction, sentence segmentation, named entity recognition, and denoising processing on the original text data. A knowledge unit division module is configured to divide the structured text into knowledge units, decompose each fault case into a plurality of standardized knowledge units, and form a "device-defect-cause-treatment-result" five-tuple structure representation, wherein each knowledge unit includes device type, defect description, fault cause, treatment measure, and treatment result. An index construction module is configured to construct a multi-granularity semantic index based on the knowledge units, perform semantic embedding of the knowledge units using a dense vector encoder, construct a vector index while retaining keyword information to construct an inverted index, and form a dual-path retrieval mechanism. A retrieval module is configured to receive a user input query statement, calculate the semantic similarity and keyword matching degree between the query statement and each knowledge unit, calculate a comprehensive score using a weighted fusion method, and rank the top K most relevant knowledge units according to the comprehensive score. A re-ranking module is configured to introduce a time decay factor and a regional similarity as auxiliary features, combine the semantic score and the keyword matching degree, perform re-ranking using a ranking model, and output the ranking result of the recalled knowledge units. A generation module is configured to perform the following operations: based on the re-ranking result of the recalled knowledge units, input the top-ranked knowledge units as context to a pre-trained language model based on a retrieval enhancement generation framework, generate a fault analysis answer in natural language form, and attach the original text of the reference case, the similarity score, and the highlighted key sentence to realize explainable output.
[0037] Another embodiment of the present application provides a computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the power grid equipment fault case detection method based on multi-granularity retrieval.
[0038] Another embodiment of the present application provides an electronic device, comprising a memory, a processor and a computer program stored on the memory, wherein the processor implements the power grid equipment fault case detection method based on multi-granularity retrieval when executing the computer program.
[0039] The above description is only the preferred embodiment of the present application, and is not intended to limit the other forms of the present application, any skilled person in the art can use the above disclosed content to make changes or modifications into equivalent embodiments with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiments without departing from the technical solution of the present application, and according to the technical essence of the present application, still belongs to the protection scope of the technical solution of the present application.
Claims
1. A method for detecting fault cases in power grid equipment based on multi-granularity retrieval, characterized in that, Includes the following steps: S1: Collect power grid equipment fault case documents, extract the original text data through optical character recognition technology, and build a domain-adaptive natural language processing cleaning model based on the power grid domain dictionary and pre-trained language model to perform error correction, sentence segmentation, named entity recognition and noise reduction on the original text data to generate a structured text set. S2: Divide the structured text into knowledge units, decompose each fault case into several standardized knowledge units, each knowledge unit includes five core information categories: equipment type, defect description, fault cause, handling measures, and handling result, forming a five-tuple structure representation of "equipment-defect-cause-handling-result"; S3: Construct a multi-granularity semantic index based on the knowledge unit, use a dense vector encoder to semantically embed the knowledge unit, construct a vector index, and at the same time retain keyword information to construct an inverted index, forming a dual-path retrieval mechanism; S4: Receive the query statement input by the user, calculate the semantic similarity and keyword matching degree between it and each knowledge unit, calculate the comprehensive score by weighted fusion, and recall the top K most relevant knowledge units according to the comprehensive score. S5: Introduce time decay factor and region similarity as auxiliary features, combine semantic score and keyword matching degree, use ranking model to re-rank, and output the ranking result of recalled knowledge units; S6: Based on the retrieval enhancement generation framework, and based on the re-ranking results of recalled knowledge units, the top-ranked knowledge units are used as context input to the pre-trained language model to generate fault analysis answers in natural language form, along with the original text of cited cases, similarity scores, and highlighted key sentences, achieving interpretable output.
2. The method according to claim 1, characterized in that, The domain-adaptive natural language processing cleaning model is as follows: the BERT model is fine-tuned based on the domain corpus of power grid equipment faults, and named entity recognition is performed by combining the CRF layer. The recognized entities include: equipment name, defect type, fault phenomenon, processing action, and result status. At the same time, a domain dictionary is constructed to correct optical character recognition errors.
3. The method according to claim 1, characterized in that, The five-tuple structure of the knowledge unit is represented as follows: ; Where i is the fault case index and j is the knowledge unit index. This represents the j-th knowledge unit in the i-th fault case. This represents the device type of the j-th knowledge unit in the i-th fault case. Let represent the defect description of the j-th knowledge unit in the i-th fault case. Let represent the cause of failure in the j-th knowledge unit within the i-th failure case. This represents the handling measures for the j-th knowledge unit in the i-th fault case. This represents the processing result of the j-th knowledge unit in the i-th fault case. Each field is a natural language text fragment, supporting subsequent semantic encoding and retrieval.
4. The method according to claim 3, characterized in that, The formula for calculating the comprehensive score in the dual-path retrieval mechanism is as follows: ; in, This represents the overall score. Represents the user's query statement The dense vector representation is generated by a pre-trained semantic encoder; Representing knowledge units The dense vector representation is also generated by a pre-trained semantic encoder. The dimension is ; express and The cosine similarity between them is used to measure the degree of semantic matching. This represents the sparse retrieval score based on the bag-of-words model, used to measure the degree of matching at the keyword level. These are dynamically learnable weight parameters.
5. The method according to claim 4, characterized in that, The pre-trained semantic encoder is performed based on domain-adaptive fine-tuning of the corpus of power grid equipment faults. It adopts a contrastive learning approach to construct positive and negative sample pairs. By maximizing the semantic similarity between positive sample pairs and minimizing the similarity between negative sample pairs, the pre-trained semantic encoder is optimized.
6. The method according to claim 4, characterized in that, Before calculating the sparse retrieval score based on the bag-of-words model, the knowledge unit text is preprocessed, including: removing stop words, standardizing device terminology, and introducing synonym expansion.
7. The method according to claim 4, characterized in that, The reordering process is as follows: First, the timeliness of the case is measured using a time decay factor, the calculation formula of which is: ; in, These are weighting coefficients based on the time decay factor. Fault Case Release time; The current query time; The attenuation coefficient is... It is the field of positive real numbers; Then, the feature vectors of the candidate cases are constructed: ; in, The feature vector includes the user's query statement. Dense vectors and failure cases The cosine similarity of dense vectors, and the user query statement and failure cases Text similarity and weighting coefficients ; The feature vectors of the candidate cases are input into the ranking model, and the final ranking score is output. The ranking model is used to refine the candidate cases. It is trained based on a small number of manually labeled query-case relevance tags, which include three categories: highly relevant, somewhat relevant, and irrelevant. The model is trained using pairwise or overall ranking methods to optimize the ranking loss function.
8. A power grid equipment fault case detection system based on multi-granularity retrieval, characterized in that, include: The data preprocessing module is used to perform the following operations: collect power grid equipment fault case documents, extract raw text data through optical character recognition technology, and build a domain-adaptive natural language processing cleaning model based on the power grid domain dictionary and pre-trained language model to perform error correction, sentence segmentation, named entity recognition and noise reduction on the raw text data to generate a structured text set. The knowledge unit segmentation module is used to perform the following operations: segment structured text into knowledge units, decompose each fault case into several standardized knowledge units, each knowledge unit includes five core information categories: equipment type, defect description, fault cause, handling measures, and handling result, forming a five-tuple structure representation of "equipment-defect-cause-handling-result"; The index building module is used to perform the following operations: build a multi-granularity semantic index based on the knowledge unit, use a dense vector encoder to semantically embed the knowledge unit, build a vector index, and at the same time retain keyword information to build an inverted index, forming a dual-path retrieval mechanism; The retrieval module is used to perform the following operations: receive the query statement input by the user, calculate the semantic similarity and keyword matching degree between it and each knowledge unit, calculate the comprehensive score using a weighted fusion method, and retrieve the top K most relevant knowledge units according to the comprehensive score. The re-ranking module is used to perform the following operations: introduce time decay factor and region similarity as auxiliary features, combine semantic score and keyword matching degree, use ranking model to re-rank, and output the ranking result of the recalled knowledge units. The generation module performs the following operations: based on the retrieval enhancement generation framework and the re-ranking results of the recalled knowledge units, it inputs the top-ranked knowledge units as context into the pre-trained language model to generate a fault analysis answer in natural language form, along with the original text of the cited case, similarity score, and highlighted key sentences, thus achieving interpretable output.
9. 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 method as described in any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.