Power document keyword extraction method based on Prompt and knowledge graph

By constructing a knowledge graph in the power sector and using a guided large language model, the problems of accuracy and standardization in keyword extraction from power documents were solved, achieving efficient and interpretable keyword recognition and management.

CN121525801APending Publication Date: 2026-02-13STATE GRID ZHEJIANG ELECTRIC POWER CO LTD SHAOXING POWER SUPPLY CO
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511426258.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-30
Publication Date
2026-02-13

Smart Images

  • Figure CN121525801A_ABST
    Figure CN121525801A_ABST
Patent Text Reader

Abstract

The invention provides an electric power document keyword extraction method based on Prompt and a knowledge graph, relates to the technical field of electric power document processing, and constructs a lightweight multi-level index knowledge graph in the electric power field by combining entity type and relation type division based on an electric power industry standard document and an electric power field corpus. The method comprises the following steps: performing vector modeling on a power document, constructing a multi-level index from an entity to a vector, realizing standardized semantic modeling and efficient hybrid retrieval of a power document field background, and obtaining a topic vector and a core paragraph of the power document in combination with power key information; according to the method, entity types are indexed in a knowledge graph by using subject vectors, similar entities are obtained to form knowledge sub-graphs, so that multilayer Prompt is obtained to guide a large language model to extract keywords, then knowledge graph similarity constraints are introduced to decode the output of the large language model, the keyword recognition capability in the power field is improved, and the keyword recognition efficiency is improved. And the accuracy of keyword type identification and the normalization of term naming are both considered.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of electric power document processing, and in particular relates to an electric power document keyword extraction method based on a Prompt and a knowledge graph. BACKGROUND

[0002] With the rapid development of natural language processing technology, keyword extraction, as an important link of text understanding and knowledge acquisition, plays a key role in information retrieval, document classification, intelligent question answering, and knowledge graph construction. In particular, in high professional industries such as electric power, energy, and manufacturing, a large number of technical documents (such as regulations and specifications, operation and maintenance records, repair reports, and equipment manuals) are characterized by structured terminology, high-density entity relationships, and complex semantic dependencies. The keywords not only need to accurately express the document theme, but also need to have controllable types, standardized naming, and consistent structure, thereby supporting subsequent semantic retrieval and knowledge management tasks.

[0003] However, the current mainstream keyword extraction methods have obvious deficiencies in processing such professional documents. On the one hand, traditional unsupervised methods based on graph models, such as TextRank or PositionRank, mainly rely on shallow features such as word frequency and co-occurrence relationships to establish word graphs and perform node ranking, lacking the ability to model term structure, entity types, and cross-sentence dependencies, making it difficult to identify multi-word phrases or implicit semantic keywords, and limiting recognition capabilities. On the other hand, methods based on deep semantic representation, such as KeyBERT and its derivative models, although they introduce pre-trained language models for semantic similarity matching, the generation process usually lacks type constraint mechanisms, making it prone to ambiguous expressions or lacking professional terminology coverage, thus leading to inaccurate keyword type identification and non-standard term naming.

[0004] In summary, in the keyword extraction task for professional domain documents (especially electric power domain documents), the existing technology has the technical problem of being unable to balance accuracy and standardization, and thus cannot effectively support subsequent semantic retrieval and knowledge management tasks. SUMMARY

[0005] To solve the problems of limited keyword recognition ability, inaccurate keyword type identification, and non-standard term naming in the keyword extraction task for professional domain documents in the electric power field, the present application proposes an electric power document keyword extraction method based on a Prompt and a knowledge graph, which improves the keyword recognition ability in the electric power field and balances the accuracy of keyword type identification and the standardization of term naming.

[0006] To achieve the above-mentioned purposes, the present application provides the following technical solutions: The power document keyword extraction method based on Prompt and knowledge graph comprises the following steps: S1. Based on the power industry standard documents and the power field corpus, the knowledge graph of the power field with multi-level index is constructed by combining entity type division, relationship type division, entity weight mechanism and relationship weight mechanism; S2. The power document is vector modeled, and the theme vector and core paragraph of the power document are obtained by combining the power key information, the similar entities are obtained by indexing the entity types in the knowledge graph using the theme vector, a knowledge subgraph is formed, and the multi-layer Prompt is obtained based on the core paragraph and the knowledge subgraph, so as to guide the large language model to extract the initial keyword set.

[0007] The application provides a preferred scheme, S3. The association between each keyword in the initial keyword set and the knowledge subgraph is analyzed and optimized in depth by introducing the counterfactual reasoning mechanism and the path attribution mechanism, and the new keyword is introduced by introducing the new word expansion mechanism, so as to obtain the optimized and expanded keyword set.

[0008] The application provides a preferred scheme, S4. The multi-dimensional comprehensive scoring system is constructed by using the average confidence score of the model, the knowledge graph correlation score, the document distribution rationality score, the field differentiation degree score and the explanation enhancement score, each keyword in the optimized and expanded keyword set is comprehensively scored and sorted, and the core keyword set, the associated keyword set and the expanded keyword set are hierarchically output.

[0009] The application provides a preferred scheme, S1 specifically comprises the following steps: S11. The power industry standard documents are analyzed, the entity type set of the power field is constructed, and the core attribute of each entity type is defined; the core attribute comprises the model, the rated voltage and the rated power of the power equipment entity; S12. The collected power field corpus is subjected to entity boundary identification and type labeling according to the entity type, an entity set is obtained, and the frequency proportion of each entity is calculated; S13. The importance score of each entity is calculated, and the initial weight of each entity is calculated based on the frequency proportion and the importance score result, so as to obtain the entity weight dictionary; S14. The relationship type set of the power field is constructed based on the power industry standard documents and the power field corpus, which is used to represent several types of relationships between different entity types, and the extraction weight of each relationship type is allocated, so as to obtain the relationship weight dictionary, the obtained entity set is subjected to identification according to the relationship type set, the actual relationship is obtained, and the relationship set is formed; S15. The knowledge graph is obtained based on the entity set, the relationship set, the entity weight dictionary and the relationship weight dictionary.

[0010] This invention provides a preferred solution, wherein step S2 specifically includes: S21. After segmenting, sentence-by-sentence, and semantically encoding the input original power document, performing vector modeling to obtain the paragraph vector of each paragraph and the sentence vector of each sentence; S22. Obtaining the topic vector of the power document based on the sentence vector and key power information; the key power information includes equipment number, procedure number, and fault time; S23. Calculating the similarity between each paragraph vector and the topic vector, and extracting a core paragraph set based on the similarity results; S24. Indexing the topic vector in the knowledge graph, locating the corresponding entity type, calculating the similarity between the topic vector and each entity under the entity type, and extracting core entities based on the similarity results to form a knowledge subgraph; S25. Constructing a Prompt set containing a basic layer, a knowledge layer, and a constraint layer based on the topic vector, the core paragraph set, and the knowledge subgraph; S26. Concatenating the Prompt set with the document text of the power document and feeding it into a large language model, and introducing a knowledge graph similarity constraint mechanism to decode the output of the large language model to obtain an initial keyword set, the initial confidence of the model, and keyword scores.

[0011] This invention provides a preferred solution: in S21, the ElectricBERT model is used for vector modeling; in S22, weight factors are added to the key information on electricity and the sentence vectors respectively, and the topic vector of the electricity document is calculated.

[0012] This invention provides a preferred embodiment where, in step S24, the calculation of the similarity between the topic vector and each entity under the entity type, and the extraction of core entities based on the similarity results to construct a knowledge subgraph, specifically includes: Calculate the similarity between the topic vector and the cluster centers of each cluster under the entity type, and select the clusters with the highest similarity. In each selected cluster, the similarity between the topic vector and all entities is calculated. Based on the length of the power document and the similarity between the topic vector and all entities, the entity filtering range is dynamically set. The set of filtered entities and their associated high-weight relationships constitute the knowledge subgraph.

[0013] The present invention provides a preferred solution. In S26, the knowledge graph similarity constraint mechanism is specifically as follows: the keyword score is calculated by combining the generation probability of the comprehensive model and the maximum similarity with the core entities in the knowledge subgraph.

[0014] This invention provides a preferred solution, with S3 specifically including: S31. Using the original knowledge subgraph as the true subgraph, deleting key power entities or relationships to generate a counterfactual subgraph, calculating the association score in the true subgraph and the counterfactual subgraph for each initial keyword, and taking the difference as the counterfactual gain; S32. For each initial keyword, searching for all relevant evidence path sets in the knowledge subgraph, calculating the average score of the evidence paths, and obtaining the initial keyword path attribution score; S33. Weighting and fusing the counterfactual gain, path attribution score, and initial confidence of the model corresponding to each initial keyword to obtain the optimized keyword score, and filtering the initial keyword set based on the optimized keyword score to obtain the filtered keyword set; S34. Establishing reasoning relationships between high-value new keywords and existing entities in the knowledge subgraph, constructing temporary nodes, and expanding the filtered keyword set to obtain the expanded keyword set; S35. Repeating the above steps to continuously iterate and optimize the keyword set.

[0015] This invention provides a preferred embodiment, S4 specifically includes: S41. Average confidence score: For each keyword, the average confidence score over all iterations is calculated, and an average confidence score is awarded based on the average confidence score; S42. Knowledge graph relevance score: For each keyword, the semantic similarity to the most similar entity in the knowledge graph and the relational weight between the keyword and other keywords are considered to calculate the knowledge graph relevance score; S43. Document distribution specificity score: For each keyword, the frequency of its occurrence in core paragraphs, the frequency of its occurrence in the entire text, and the position of its first occurrence are counted and searched, and a document distribution specificity score is calculated accordingly; S44. Domain differentiation score. For each keyword, find its frequency of occurrence in the power industry corpus and the general corpus, and calculate the domain discrimination score accordingly; S45. Explanatory Enhancement Score: For each keyword, calculate the explanatory enhancement score based on its counterfactual gain and evidence path attribution; S46. Comprehensive Score: For each keyword, calculate the comprehensive score by weighting and fusing the average confidence score, knowledge graph relevance score, document distribution specificity score, domain discrimination score, and explanatory enhancement score; S47. After ranking each keyword according to the comprehensive score, divide the keywords into three levels: core, related, and extended, and output the core keyword set, related keyword set, and extended keyword set hierarchically.

[0016] Compared with the prior art, the present invention has the following advantages: This invention constructs a lightweight, multi-level indexed knowledge graph for the power industry by combining entity type and relation type classification with standard documents and a corpus of power-related terminology. Through vector modeling of power documents, a multi-level index from entity to vector is built, achieving standardized semantic modeling and efficient hybrid retrieval of power document domain context. Simultaneously, topic vectors and core paragraphs of power documents are obtained by combining key power information. Entity types are indexed in the knowledge graph using topic vectors, and similar entities are obtained to form a knowledge subgraph. Then, multi-level prompts are obtained based on core paragraphs and knowledge subgraphs. Keywords are extracted through a large language model generation mechanism guided by multi-level prompts. A knowledge graph similarity constraint mechanism is introduced to decode the output of the large language model, thereby improving the keyword recognition capability in the power industry while ensuring the accuracy of keyword type identification and the standardization of terminology naming.

[0017] This invention introduces counterfactual reasoning and path attribution mechanisms to conduct in-depth analysis and optimization of the associations between each keyword in the initial keyword set and the knowledge subgraph. It retains keywords with high-value path explanations and significant dependencies in the knowledge subgraph and introduces a new word expansion mechanism to include high-value new words, thereby optimizing and expanding the keyword set and achieving automatic discovery and enhanced interpretability of new electricity concepts.

[0018] This invention adopts a multi-dimensional comprehensive scoring system that integrates model confidence, knowledge graph relevance, document distribution characteristics, domain discrimination and interpretability enhancement weights. After ranking the candidate keywords, the output is hierarchical, which can be adapted to the needs of power archiving.

[0019] This invention constructs a comprehensive intelligent keyword extraction and knowledge enhancement system for domain-specific documents. It can unify the use of document semantic information and domain knowledge graphs for deep fusion analysis, significantly improving the professionalism, accuracy, and interpretability of keywords. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0021] Figure 1 A flowchart illustrating a method for extracting keywords from power documents based on Prompt and knowledge graphs, provided as a specific embodiment of the present invention; Figure 2 A flowchart of a method for extracting keywords from power documents based on Prompt and knowledge graph, provided as another specific embodiment of the present invention; Figure 3 The flowchart illustrates a method for extracting keywords from power documents based on Prompt and knowledge graphs, as provided in another specific embodiment of the present invention. Detailed Implementation

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] Example 1 Please refer to Figure 1 In one optional implementation, a method for extracting keywords from power documents based on Prompt and knowledge graphs is provided, which is mainly implemented through the following steps: S1. Based on standard documents in the power industry and a corpus in the power field, and combining entity type classification, relation type classification, entity weighting mechanism and relation weighting mechanism, a multi-level indexed knowledge graph in the power field is constructed.

[0024] S2. Perform vector modeling on the power documents, and combine key power information to obtain the topic vectors and core paragraphs of the power documents. Use the topic vectors to index entity types in the knowledge graph and obtain similar entities to form a knowledge subgraph. Based on the core paragraphs and knowledge subgraphs, obtain multi-level prompts to guide the large language model to extract the initial set of keywords.

[0025] The above-described implementation provides a power document keyword extraction method based on Prompt and knowledge graph. It constructs a lightweight, multi-level indexed knowledge graph for the power sector by combining entity type and relation type classification with standard power industry documents and a power domain corpus. Through vector modeling of power documents, a multi-level index from entity to vector is built, achieving standardized semantic modeling and efficient hybrid retrieval of power document domain background. Simultaneously, it obtains topic vectors and core paragraphs of power documents by combining key power information. Using topic vectors, it indexes entity types in the knowledge graph and obtains similar entities, forming a knowledge subgraph. Then, based on the core paragraphs and knowledge subgraph, it obtains multi-level Prompts. Keywords are extracted through a large language model generation mechanism guided by multi-level Prompts, thereby improving the keyword recognition capability in the power sector while ensuring the accuracy of keyword type identification and the standardization of terminology naming.

[0026] Example 2 Please refer to Figure 2In another alternative implementation, a method for extracting keywords from power documents based on Prompt and knowledge graphs is provided, which further includes the following steps: S3. Introduce counterfactual reasoning and path attribution mechanisms to conduct in-depth analysis and optimization of the relationship between each keyword in the initial keyword set and the knowledge subgraph. Retain keywords with high-value path explanations and significant dependencies in the knowledge subgraph, and introduce a new word expansion mechanism to include high-value new words, resulting in an optimized and expanded keyword set.

[0027] S4. Construct a multi-dimensional comprehensive scoring system based on the model's average confidence score, knowledge graph relevance score, document distribution rationality score, domain discrimination score, and explanatory enhancement score. Score and rank each keyword in the optimized and expanded keyword set, and output the core keyword set, related keyword set, and expanded keyword set in a hierarchical manner.

[0028] The above-described implementation provides a method for extracting keywords from power documents based on Prompt and knowledge graphs. By introducing counterfactual reasoning and path attribution mechanisms, it performs in-depth analysis and optimization of the associations between each keyword in the initial keyword set and the knowledge subgraph. Keywords with high-value path explanations and significant dependencies in the knowledge subgraph are retained. Furthermore, a new word expansion mechanism is introduced to incorporate high-value new words, thereby optimizing and expanding the keyword set and achieving automatic discovery and enhanced interpretability of new power concepts.

[0029] Meanwhile, a multi-dimensional comprehensive scoring system is adopted, which integrates model confidence, knowledge graph relevance, document distribution characteristics, domain differentiation and interpretability enhancement weights, and outputs candidate keywords in a hierarchical manner after ranking, which can be adapted to the needs of power archiving.

[0030] Example 3 Based on the above implementation method, a more preferred and more specific implementation method is given.

[0031] Considering the recent emergence of Prompt-based large language model keyword generation methods, while they can generate reasonable results in open corpora, their application in professional documents suffers from problems such as redundant generated words, type mismatches, and insufficient terminology standardization due to a lack of knowledge constraints and structural control. This severely impacts the accuracy and credibility of their applications. Furthermore, although some studies have attempted to use knowledge graphs for keyword candidate selection or synonym unification, these efforts are mostly limited to the post-processing stage and fail to be substantially embedded into the entire process of keyword generation, evaluation, and optimization, resulting in the underutilization of the structural advantages of knowledge graphs. In terms of keyword importance assessment, existing methods largely rely on static scoring and ranking mechanisms, making it difficult to measure the actual contribution of a term to document semantic understanding from a causal perspective, lacking interpretability and robustness. Simultaneously, existing methods lack automatic identification and semantic attribution mechanisms for the frequent occurrence of "new terms not covered by the graph" in professional domains, making it difficult to support dynamic graph expansion and term discovery. Therefore, existing technologies generally suffer from insufficient utilization of graph structure, poor controllability of generated results, lack of causal explanation in evaluation mechanisms, and insufficient ability to identify new terms in keyword extraction tasks for professional domain documents. Therefore, a novel method is needed that integrates graph structure, prompt guidance, and the semantic capabilities of large models to achieve high-quality generation and structured optimization of keywords, thereby improving their practicality and interpretability in specialized corpus scenarios. To further overcome the problems of insufficient graph utilization, non-standard keyword structure, uncontrollable generation process, and lack of causal evaluation and terminology discovery capabilities in existing technologies, this embodiment provides a document keyword extraction method based on prompt guidance, knowledge graph constraints, and a counterfactual consistency mechanism. It aims to address the challenges of complex technical document structures, uneven terminology distribution, low efficiency of manual extraction, and the difficulty of existing algorithms in balancing accuracy, standardization, and interpretability in highly specialized fields, proposing a new paradigm for intelligent keyword extraction oriented towards structured semantics and graph fusion.

[0032] Please refer to Figure 3 The following will elaborate on each step from S1 to S4: S1. Based on standard documents and a corpus of the power industry, and combining entity type classification, relation type classification, entity weighting mechanism, and relation weighting mechanism, a multi-level indexed knowledge graph of the power industry is constructed. This step achieves standardized semantic modeling and efficient hybrid retrieval of power document domain background through lightweight modeling of the power industry knowledge graph, combined with entity type classification, frequency statistics of power corpus, and expert scoring. In this embodiment, the multi-level index includes: type-level index (level 1): the index is organized according to entity type (such as equipment, procedures, faults) to quickly locate the major category (reflected in S11); cluster-level index (level 2): ​​under the same type, the cluster center is used as the intermediate level (the "cluster center" in S24 is this level); entity-level index (level 3): in the selected cluster, it then goes to the specific entity node (reflected in S24).

[0033] S1 specifically includes the following sub-steps: S11. Analyze the standard documents of the power industry, construct a set of entity types in the power field, and define core attributes for each entity type.

[0034] In this sub-step, a set of entity types in the power sector is constructed through analysis of industry standard documents: (1) Represents an entity type. n Indicates the total number of entity types.

[0035] Furthermore, core attributes are defined for each entity type. In the power field, the core attributes of an entity type include key attributes such as "model, rated voltage, and rated power," thereby ensuring the integrity and scalability of the domain knowledge system.

[0036] S12. Perform entity boundary identification and type labeling on the collected power field corpus according to the entity type to obtain an entity set, and calculate the frequency percentage of each entity.

[0037] In this sub-step, a domain corpus is collected. Data sources include technical standards, industry reports, and operation and maintenance records. Combined with manual annotation, entity boundary identification and type labeling are performed in the domain corpus text. In one specific implementation, the identification and annotation objects are candidate words or phrases in the power industry corpus, such as terms, equipment names, procedure numbers, fault phenomena, etc., and the data is then processed from... The entities that have been extracted and labeled are denoted as entities. , to obtain the entity set , .

[0038] Corpus Perform statistics and calculate for each entity. e The frequency percentage of each domain is expressed by the formula: (2) in, For entities e The total number of times it appears in the corpus This represents the total number of occurrences of all entities in the corpus.

[0039] S13. Assess the importance of each entity and calculate the initial weight of each entity based on the frequency percentage and importance score results to obtain the entity weight dictionary.

[0040] In this sub-step, domain experts are invited to independently rate the importance of entities using a Likert scale of 5 (1 being the lowest and 5 the highest). The average expert rating is then calculated. (3) Wherein, 𝑛 represents the number of experts who participated in the scoring.

[0041] Based on frequency share and expert ratings, the initial weight of each entity is calculated using a weighting coefficient φ. Thus, the entity weight dictionary is obtained. , The formula is: (4) When domain data is abundant, α is set to 0.6; when data is scarce, α is set to 0.4 to balance the weight of statistical information and expert experience.

[0042] S14. Based on standard documents in the power industry and a corpus in the power field, construct a set of relation types in the power field to represent several types of relationships between different entity types, and assign extraction weights to each relation type to obtain a relation weight dictionary. Identify the obtained entity set according to the set of relation types to obtain the actual relationships and form a relation set.

[0043] In this sub-step, based on the previous step, and drawing upon standard documents in the power industry, a corpus of power-related terminology (such as operation and maintenance reports, repair records, etc.), and combined with expert knowledge, a set of core relation types in the power industry is summarized and defined. (5) Experts then assigned extraction weights to each relation type, resulting in a relation weight dictionary. (Values ​​range from 1 to 5). This represents a category of relationships between entity types. Indicates the total number of relation types.

[0044] Then, the obtained entity set is identified according to the set of relation types to obtain the actual relations and form a relation set: (6) in, This represents a category of relationships between entity types. Indicates the total number of relations.

[0045] S15. The knowledge graph is obtained based on the entity set, relation set, entity weight dictionary, and relation weight dictionary. By simplifying the selection of entities and relations and pruning their weights, only high-frequency and high-importance entity attributes and relations are retained, reducing the size of redundant nodes to achieve lightweight modeling.

[0046] In this sub-step, a lightweight knowledge graph is ultimately constructed: (7) Where 𝐸 is the entity set and 𝑅 is the relation set. For entity weight dictionary, This is a relation weight dictionary. The graph produced in this step will serve as the basic data structure for subsequent index optimization, prompt generation, and keyword extraction.

[0047] S2. Perform vector modeling on the power documents, and combine key power information to obtain the topic vectors and core paragraphs of the power documents. Use the topic vectors to index entity types in the knowledge graph and obtain similar entities to form a knowledge subgraph. Based on the core paragraphs and knowledge subgraph, obtain multi-level prompts to guide the large language model to extract the initial keyword set. In a preferred embodiment, an entity-vector library is constructed through vector modeling. The topic vectors are used to index entity types in the knowledge graph, and similar entities are retrieved in the entity-vector library through dynamic indexing. This step uses a multi-level prompt-guided large language model generation mechanism to generate dynamic prompts by combining the power document topic vectors, core paragraphs, and power knowledge subgraphs. This drives the model to achieve initial keyword extraction, and introduces power relationship weight constraints to ensure the structural consistency between keywords and power knowledge. Specifically, this is achieved through the following sub-steps: S21. After segmenting, sentence-segmenting, and semantically encoding the input raw power document, perform vector modeling to obtain the paragraph vector of each paragraph and the sentence vector of each sentence.

[0048] In this sub-step, the input power document is first segmented, sentence-by-sentence, and semantically encoded. The ElectricBERT model is then used to generate vector representations for each segment and sentence. In this embodiment, segmentation is used for subsequent similarity calculations with topic vectors to extract core segments. Sentence-by-sentence and semantic encoding avoid diluting semantics with long segments, using fine-grained information to construct topic vectors. Sentence vectors are used to calculate topic vectors (S22) because sentence levels are more granular, facilitating the weighted integration of key power information (equipment number, procedure number, fault time). Segment vectors are used to select core segments (S23) because segments better reflect a portion of the complete semantics (such as a fault description or procedure specification).

[0049] S22. Obtain the topic vector of the power document based on sentence vector and key power information; the key power information includes equipment number, procedure number and failure time.

[0050] Unlike ordinary literary documents (such as news articles, novels, and essays), power industry documents possess domain-specific characteristics in terms of content, structure, and semantics. Content characteristics: Power industry documents often contain key entities that strongly define the document's theme. Examples include equipment numbers, procedure numbers, and fault timestamps. Structural characteristics: Power industry documents are typically formatted systematically, with clear numbering, tables, and timestamps. Semantic characteristics: Ordinary sentences contribute relatively scattered semantics. However, numbered, time-based, and standardized phrases often serve as "anchors," better pinpointing the document's theme.

[0051] In a preferred embodiment, a key information weighting mechanism is introduced. Based on the characteristics of power documents, weighting factors are added to key information such as equipment number, procedure number, and fault time. The formula for calculating the document topic vector is: (8) in, n The total number of sentences in the document. Keylnfo A collection of key power information, The weight of key information is determined by the importance of the key information. It is the first One sentence. Indicates the first The vector of each sentence, Key information items This represents the vector representation of key information items. In the formula, 70% comes from the average sentence vector (ensuring the theme covers the overall semantics of the document). 30% comes from the weighted vector of key information (highlighting core entities in the power sector, such as equipment number / procedure number / time). The weights of different key information items should be different. Within this 30% share, based on... Different key information is distinguished (e.g., equipment number is more important than time). Furthermore, the characteristics of power documents in this embodiment refer to the generally present structured key entities and strong thematic indicative features. Therefore, when calculating the topic vector, these key information items are given additional weight, making the topic vector more closely aligned with the actual semantic focus of the power document.

[0052] S23. Calculate the similarity between each paragraph vector and the topic vector, and extract the core paragraph set based on the similarity results.

[0053] In this step, the cosine similarity between each paragraph vector and the topic vector is calculated: (9) in, It is the first One paragraph, Indicates the first The vector of each paragraph.

[0054] The top 3 paragraphs with the highest similarity were selected as the core paragraph set: (10) This step ensures that the Prompt is generated by focusing on the core content in the power documentation that best reflects the equipment status and fault characteristics.

[0055] S24. Index topic vectors in the knowledge graph, locate the corresponding entity types, calculate the similarity between the topic vectors and each entity under the entity type, and extract core entities based on the similarity results to form a knowledge subgraph. Specifically, this includes: calculating the similarity between the topic vectors and the cluster centers of each cluster under the entity type, selecting several clusters with the highest similarity; in each selected cluster, calculating the similarity between the topic vectors and all entities, dynamically setting the entity filtering range based on the length of the power document and the similarity between the topic vectors and all entities, and the filtered entity set and its associated high-weight relationships constitute the knowledge subgraph.

[0056] Specifically, this sub-step utilizes topic vectors. In the power knowledge graph, the corresponding entity type is located in the first-level index. Then, the similarity between the topic vector and the cluster center is calculated under that type, which can be obtained by calculating cosine similarity. The top-2 clusters are selected. In this embodiment, it is important to emphasize that entities in the power knowledge graph are categorized, such as: equipment type (transformer, circuit breaker, etc.), parameter type (rated voltage, rated power, etc.), and time / procedure type (procedure number, maintenance time, etc.). Here, equipment type, parameter type, and time type are first-level indexes. This is equivalent to a first-level directory, allowing for better searching rather than a brute-force full-graph search. Furthermore, for the cluster center, under each entity type, the entity vectors are clustered once. The cluster center identifies the central vector of that cluster, representing the semantic center of the cluster. A cluster has many entities but only one cluster center. An entity type can contain several clusters.

[0057] To select the set of specific entities most relevant to the topic vector from within each cluster, and thus construct a knowledge subgraph, similarity is calculated for all entities within each cluster: (11) in, It is the first in the entity set One entity, It is a physical entity The semantic vector representation of .

[0058] The Top-K entity filtering range is dynamically set based on the length of the power document, and the filtering rules are as follows: (12) in, It is the length of the power document. This is the final number of entities selected.

[0059] Filtered entity set Its associated high-weight relationships ( This constitutes a domain knowledge subgraph: (13) in, This is a knowledge subgraph for the power sector, used to guide subsequent Prompt construction and keyword extraction. Let be a set of high-weighted relations between entity sets, satisfying The relationship.

[0060] S25. Based on topic vectors, core paragraph sets, and knowledge subgraphs, construct a Prompt set containing a foundation layer, a knowledge layer, and a constraint layer.

[0061] In this sub-step, specifically, based on the document topic vector and core paragraph information, combined with the Top-N entities and their high-weight relationships in the knowledge subgraph, a Prompt set containing a base layer, a knowledge layer, and a constraint layer is constructed. The core paragraphs are directly concatenated into the Prompt to construct the content of the base layer. The base layer explicitly extracts core keywords that conform to the power terminology specifications (derived from a power field corpus and power industry standard documents); the knowledge layer introduces entities such as "transformer" and "insulation aging" and their relationships. These relationships are high-weight relationships selected from the knowledge subgraph and derived from the relationship set. The constraint layer stipulates that "terms containing voltage levels and equipment numbers should be selected first," which is derived from the key information weighting mechanism (Formula (8)). The three-layer Prompt fusion formula is: (14) in, Basic layer Prompt, For the knowledge layer Prompt, For the constraint layer Prompt.

[0062] S26. After concatenating the Prompt set with the document text of the power document, feed it into the large language model, and introduce a knowledge graph similarity constraint mechanism to decode the output of the large language model to obtain the initial keyword set, the initial confidence of the model, and the keyword score.

[0063] In this sub-step, specifically, the fused Prompt and the power document text are concatenated into an input sequence and fed into the large language model. During the decoding stage, a knowledge graph similarity constraint mechanism is introduced to obtain a set of candidate keywords. Finally, the keyword score is calculated by combining the generation probability and entity similarity. (15) in, The probability of model generation (provided directly by the large language model when generating keywords in S26). This represents the maximum similarity between keywords and entities in the knowledge subgraph. For the first i These candidate keywords are the objects to be evaluated. These are weighting coefficients used for adjustment. and The degree of influence of these two factors on the final score These are weighting coefficients used for adjustment. and The degree of influence of these two factors on the final score. Retaining highly similar keywords based on keyword scores ensures structural consistency between keywords and electrical knowledge. Keyword scores are entered into S3 in the form of "initial confidence," and then integrated with counterfactual gain, path attribution scores, etc., in S3 and S4, influencing the final keyword selection.

[0064] In a preferred embodiment, a high-quality context for keyword candidates is provided through a core paragraph set to assist decoding.

[0065] Finally, by removing duplicates, noise, and non-electrical terminology (length < 2 or without voltage level or equipment characteristics) from the candidate keyword set using regular expression matching, an initial keyword set is obtained: (16) And record the initial confidence level of the model output: (17) For the normalization function, these Convert to probability, The raw, unnormalized score of the keyword generated for the large language model during the decoding phase.

[0066] S3. Introducing counterfactual reasoning and path attribution mechanisms, this step deeply analyzes and optimizes the associations between keywords in the initial keyword set and the knowledge subgraph. A new word expansion mechanism is also introduced to incorporate new keywords, resulting in an optimized and expanded keyword set. Power entity matching verification (S34) and a new word expansion mechanism are introduced. Keyword classification (S34) and confidence levels are adjusted through semantic and parameter matching (S35). Temporary nodes are established for high-value new words, and evidence paths are constructed to achieve automatic discovery and enhanced interpretability of new power concepts. On the one hand, after completing the initial keyword extraction, to improve the discriminativeness and interpretability of the power keyword set, this step introduces counterfactual reasoning and path attribution mechanisms to deeply analyze and optimize the associations between keywords and the power knowledge graph (such as equipment-fault-procedure associations). In this embodiment, through optimization, keywords with high-value path explanations and significant dependencies in the knowledge subgraph can be retained. Newly incorporated keywords refer to high-value new keywords. This is specifically achieved through the following sub-steps: S31. Using the original knowledge subgraph as the real subgraph, delete key power entities or relationships to generate a counterfactual subgraph. Calculate the association score in the real subgraph and the counterfactual subgraph for each initial keyword, and take the difference as the counterfactual gain.

[0067] Specifically, in this sub-step, within the original knowledge subgraph... Based on the true subgraph (also known as the real subgraph), key power entities or relationships are removed to generate a "counterfactual subgraph" For each initial keyword Calculate its position in the true subgraph respectively. With counterfactual subgraphs The correlation score is calculated, and the difference is taken as the "counterfactual gain": (18) in, Indicates initial keywords Counterfactual gain, Indicates initial keywords In the true subgraph The correlation score in Representing counterfactual subgraphs The correlation score in the data.

[0068] This difference reflects the keyword's dependence on a specific entity or relationship. The larger the difference, the more sensitive and critical the keyword is to the domain context.

[0069] It should be noted that the identification of key entities or relationships primarily relies on the knowledge characteristics of the power sector, the structural function of the knowledge subgraph, and the keyword association logic, comprehensively defined through three core dimensions: "domain importance," "subgraph structural influence," and "strength of association with keywords." Specifically, in this embodiment, "true power sector keywords" can be accurately screened through "counterfactual reasoning" in S31. After deletion, it is determined whether the keyword also loses its meaning or value, or whether its importance and relevance within the knowledge system significantly decreases. If the counterfactual gain is greater after deleting an entity or relationship, it indicates that the keyword is more dependent on the power sector and has stronger knowledge support; therefore, it is a keyword to be retained in S3.

[0070] S32. For each initial keyword, search for all relevant evidence paths in the knowledge subgraph, calculate the average score of the evidence paths, and obtain the initial keyword path attribution score.

[0071] In this sub-step, specifically for each initial keyword... In the original knowledge subgraph Search for the set of all evidence paths related to it. Calculate the average score of the path to obtain the path attribution score: (19) in, Initial keywords Path attribution score m The total number of paths, The weight represents the power relationship. It should be noted that the evidence path described in this embodiment specifically refers to the path in the knowledge subgraph, used to explain the association between keywords and entities in the power domain. It consists of the following parameters: Node ID: Unique identifier; Node type: Entity type; Node attributes: such as name, category, description, and domain; Node weight / confidence: The importance or credibility score of the node.

[0072] S33. The counterfactual gain, path attribution score and initial confidence of the model corresponding to each initial keyword are weighted and fused to obtain the optimized keyword score. The initial keyword set is then filtered based on the optimized keyword score to obtain the filtered keyword set.

[0073] Specifically, in this sub-step, the initial model confidence level is... Counterfactual gain and path attribution score The optimized keyword scores are obtained by weighted fusion: (20) in, To optimize keyword scores, , These are the weights.

[0074] Through this fusion, the system can prioritize retaining keywords that have high-value path explanations and significant dependencies in domain knowledge, while eliminating noise words.

[0075] S34. Establish reasoning relationships between high-value new keywords and existing entities in the knowledge subgraph, construct temporary nodes, and expand the selected keyword set to obtain the expanded keyword set.

[0076] In this sub-step, specifically for those not in the original knowledge subgraph... High-value new terms related to electricity are used to construct temporary nodes (newly added nodes) and establish reasoning relationships with existing entities.

[0077] The initial weights of the ephemeral nodes are set as follows: (twenty one) in, This represents the semantic similarity between the new word and the power context, with a value ranging from 0 to 1. It ensures that new power equipment or technical terms can be effectively incorporated into the system. The initial weight of this temporary node can be used in the decision-making processes of temporary node construction, reasoning relation weighting, path priority selection, final score fusion, and knowledge graph updating.

[0078] Definition of new keywords: Keywords that do not have a valid associated path in the knowledge subgraph. Criteria for determining "not present": Meeting one of the following two conditions: 1. In the knowledge subgraph. 1. Search for entity nodes containing the keyword. If there are no matching nodes, it is considered not present. 2. If an entity node exists, but there is no valid evidence path, and the node is isolated, it is also considered not present. The keywords mentioned above... Not all keywords can be found with a path. Some keywords can be found with paths in the knowledge subgraph; these are usually existing domain concepts that can be directly linked to nodes such as equipment, faults, and procedures. Some keywords cannot be found with paths; these are potential new words that need to enter the new word expansion mechanism in S33.

[0079] High-value evaluation factors mainly come from the outputs of S31, S32, and S33, including counterfactual gain, path attribution score, and initial model confidence. In some preferred implementations, semantic similarity and domain relevance can also be incorporated into high-value evaluation factors.

[0080] High-value assessment criteria: Counterfactual gain threshold – only words with a counterfactual gain greater than a certain value are considered high-value; Path attribution score threshold – the average keyword path score must exceed a set value to ensure sufficient explainable path support; Keyword score threshold – a keyword is considered high-value only if its weighted overall score (optimized keyword score) exceeds the threshold. In short, a keyword must have a counterfactual gain exceeding the counterfactual gain threshold, a path attribution score exceeding the path attribution score threshold, and an optimized keyword score exceeding the keyword score threshold.

[0081] Inference relationships refer to the semantic or logical connections between temporary nodes and existing entity nodes in the knowledge subgraph, reflecting the function, affiliation, or role of new terms in the power sector. These connections can include types such as "possessing function," "following procedures," "belonging to," "triggering," and "associating," with the specific relationship type determined by domain expert rules or automated inference algorithms. In practice, inference relationships are primarily obtained through semantic similarity-based matching methods. After establishing inference relationships, the system will construct corresponding paths for new terms in the knowledge subgraph to enhance their interpretability and inference capabilities.

[0082] In step S34, high-value new keywords rely on "entity matching verification." By matching entity types, semantic features, and association parameters in the existing power knowledge subgraph, new words that are "strongly related to the power field even though they are not in the existing knowledge graph" are selected, while irrelevant new words outside the power field are excluded, ensuring that the "temporary nodes" established in S34 are truly valuable power-related terms.

[0083] S35. Repeat the above steps to continuously iterate and optimize the keyword set.

[0084] In this step, after obtaining the initial keyword set and initial confidence level, optimization iteration is initiated. Specifically, the initial keyword set is gradually optimized through counterfactual gain calculation, path attribution analysis, confidence level fusion, and high-value new word expansion. This series of processes forms a cyclically executed iterative mechanism to continuously optimize the keyword set. To ensure the effectiveness and convergence of the iteration process, the system sets the following control conditions: The iteration process is considered complete when any two of the following conditions are met: a) Convergence: The average comprehensive score gain of the Top-N keywords is less than 0.01 in two consecutive iterations; b) Ranking stability: The consistency of keyword ranking between two adjacent iterations is greater than 0.9; c) Limited new value: The number of high-value new words introduced in the most recent iteration is less than 1, and their counterfactual gain and path attribution improvement are both less than 0.01; d) Boundary constraints: The number of iterations reaches the upper limit (i.e., no more than 5 iterations).

[0085] S4. Construct a multi-dimensional comprehensive scoring system based on the model's average confidence score, knowledge graph relevance score, document distribution rationality score, domain discrimination score, and interpretability enhancement score. Perform a comprehensive scoring and ranking of each keyword in the optimized and expanded keyword set, and output a hierarchical set of core keywords, related keywords, and expanded keywords. In this step, after optimizing the discriminability and interpretability of keywords, perform a multi-dimensional comprehensive scoring on the remaining candidate power keywords and output them hierarchically based on the scoring results. This adapts to power archiving requirements. Specifically, this includes the following sub-steps: S41. Average Confidence Score: For each keyword, calculate its average confidence score over all iterations, and then assign an average confidence score to the keyword based on the average confidence score.

[0086] In this sub-step, specifically, the mean confidence score of the keywords is calculated throughout the entire iteration process (including the initial extraction and optimization iterations), using the following formula: (twenty two) in: ) represents the confidence level of the keyword at the nth iteration; Indicates the total number of iterations. Keywords The average confidence score is used for subsequent comprehensive scoring.

[0087] S42. Knowledge Graph Relevance Score: For each keyword, the knowledge graph relevance score is calculated by comprehensively considering its semantic similarity to the most similar entity in the knowledge graph and the relationship weight between the keyword and other keywords.

[0088] In this sub-step, specifically, the semantic similarity (MaxSim) between the keyword and the most similar entity in the power knowledge graph, as well as the relational weight (RelScore) between the keyword and other selected keywords (keywords retained from the optimization in step S3), are comprehensively considered to calculate the knowledge graph relevance set: (twenty three) To represent the knowledge graph relevance score of keywords; The semantic similarity is the maximum similarity between the keywords and entities in the knowledge subgraph in formula (15). This is used to measure the semantic similarity between keywords and the most relevant entities in the power knowledge graph; The score represents the relationship between a keyword and other selected keywords, calculated based on the relationship types and their weights in the knowledge graph; that is, based on the set of relationships. relation weight dictionary This is obtained by weighted summation of the association paths between the entities corresponding to the keywords and the entities corresponding to the selected keywords, and is used to reflect the relevance of the keywords in the semantic structure of the domain.

[0089] S43. Document Distribution Specificity Score: For each keyword, count and find its frequency of occurrence in core paragraphs, frequency of occurrence in the whole text, and position of its first occurrence, and calculate the document distribution specificity score accordingly.

[0090] Specifically, this sub-step measures the rationality and significance of keyword distribution within the power document, focusing on the frequency of occurrence in core paragraphs (fault descriptions, test conclusions, etc.) and calculating the document distribution specificity score. (twenty four) in, This indicates the number of times the keyword appears in the core paragraph. This indicates the total number of times the keyword appears in the entire text. This represents the score for the first occurrence of a keyword, and MaxPos represents the maximum score for that position. Keywords The document distribution specificity score is used to measure the reasonableness and significance of the distribution of the keyword in power documents.

[0091] S44. Domain Discrimination Score: For each keyword, find its frequency of occurrence in the power industry corpus and the general corpus, and calculate the domain discrimination score accordingly.

[0092] Specifically, this sub-step measures the specificity of keywords in the power sector, strengthens the distinguishability of power-specific terms, and calculates the sector-specific distinguishability score: (25) in, This indicates the frequency of keyword occurrences in the domain corpus. This indicates the frequency of keyword occurrences in the general corpus. This represents the specificity score of a keyword in the power industry; the value range is (0,1). The closer the value is to 1, the stronger the specificity of the keyword in the power industry; the closer the value is to 0, the more common the keyword is in general corpora, and the lower its specificity in the field.

[0093] S45. Explanatory Enhancement Score: For each keyword, calculate the explanatory enhancement score based on its counterfactual gain and evidence path attribution.

[0094] In this sub-step, specifically, based on counterfactual gain and evidence path attribution calculations, the explanatory power sector explanatory indicators highlight the importance of safety-related keywords and calculate the explanatory enhancement score: (26) in, Counterfactual gain represents the difference in scores between the true and counterfactual subgraphs for a keyword. The average score of the path, which is the path attribution score obtained by formula (19). This is used to characterize the average path importance of keywords in a knowledge graph. , Indicates the explanatory weighting coefficient. Keywords The explanatory enhancement score is used to measure the causal explanatory value of the keyword in the knowledge graph.

[0095] S46. Comprehensive score: For each keyword, a comprehensive score is obtained by weighted fusion of the average confidence score, knowledge graph relevance score, document distribution specificity score, domain discrimination score, and explanatory enhancement score; S47. After ranking each keyword based on the comprehensive score, the keywords are divided into three levels: core, related, and extended. The core keyword set, related keyword set, and extended keyword set are output hierarchically.

[0096] Specifically, in this sub-step, after obtaining each candidate keyword... After scoring the five independent evaluation dimensions, these scores are weighted and integrated to form the final ranking. The comprehensive score calculation formula is as follows: (27) in, Keywords The final overall score; , , , , These are the weight coefficients for five dimensions, corresponding to the average confidence score, knowledge graph relevance score, document distribution specificity score, domain discrimination score, and explanatory enhancement score, and satisfying the following conditions: .

[0097] Through the above embodiments, the present invention can achieve the following beneficial technical effects: This invention discloses a method for extracting keywords from power sector documents based on Prompt and knowledge graphs. The method includes: 1) Constructing a multi-level entity-vector library index using lightweight modeling and dynamic indexing of a power sector knowledge graph, combined with entity type classification, power corpus frequency statistics, and expert scoring, to achieve standardized semantic modeling and efficient hybrid retrieval of power sector document backgrounds; 2) Generating a dynamic Prompt through a multi-layered Prompt-guided large language model generation mechanism, combining power document topic vectors, core paragraphs, and power knowledge subgraphs, driving the model to initially extract keywords, and introducing power relationship weight constraints to ensure structural consistency between keywords and power knowledge; 3) Introducing a power entity matching verification and new word expansion mechanism, classifying keywords and adjusting confidence levels through semantic and parameter matching, establishing temporary nodes and constructing evidence paths for high-value new words, achieving automatic discovery and enhanced interpretability of new power concepts; 4) Employing a multi-dimensional comprehensive scoring system, integrating model confidence, knowledge graph relevance, document distribution characteristics, domain discrimination, and security association weights, and hierarchically outputting core keyword sets, related keyword sets, and extended keyword sets after ranking candidate keywords, adapting to power sector archiving requirements. This invention constructs a comprehensive intelligent keyword extraction and knowledge enhancement system for domain-specific documents. It can unify the use of document semantic information and domain knowledge graphs for deep fusion analysis, significantly improving the professionalism, accuracy, and interpretability of keywords.

[0098] In summary, by integrating key technologies such as document topic vector modeling, knowledge graph structure constraints, Prompt instruction guidance, causal consistency assessment, and sub-module coverage optimization, this invention enables the system to automatically identify high-value keywords, control their type consistency and semantic rationality, and support automatic identification and graph completion of new terms. Ultimately, it improves the accuracy, stability, and interpretability of keyword extraction tasks, meeting the needs of knowledge indexing, structured archiving, and intelligent question answering in professional scenarios such as power, operation and maintenance, and scheduling.

[0099] 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 program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0100] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. Furthermore, the above embodiments only illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. For those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all fall within the protection scope of the present invention.

Claims

1. A method for extracting keywords from power documents based on Prompt and knowledge graph, characterized in that, include: S1. Based on standard documents in the power industry and a corpus in the power field, and combining entity type classification, relation type classification, entity weighting mechanism and relation weighting mechanism, a multi-level indexed knowledge graph in the power field is constructed. S2. Perform vector modeling on the power documents, and combine key power information to obtain the topic vectors and core paragraphs of the power documents. Use the topic vectors to index entity types in the knowledge graph and obtain similar entities to form a knowledge subgraph. Based on the core paragraphs and knowledge subgraphs, obtain multi-level prompts to guide the large language model to extract the initial set of keywords.

2. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 1, characterized in that, Also includes: S3. Introduce counterfactual reasoning and path attribution mechanisms to conduct in-depth analysis and optimization of the relationships between each keyword in the initial keyword set and the knowledge subgraph, and introduce a new word expansion mechanism to incorporate new keywords to obtain an optimized and expanded keyword set.

3. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 2, characterized in that, S4. Construct a multi-dimensional comprehensive scoring system based on the model's average confidence score, knowledge graph relevance score, document distribution rationality score, domain discrimination score, and explanatory enhancement score. Score and rank each keyword in the optimized and expanded keyword set, and output the core keyword set, related keyword set, and expanded keyword set in a hierarchical manner.

4. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 1, characterized in that, S1 specifically includes: S11. Analyze the standard documents of the power industry, construct a set of entity types in the power field, and define core attributes for each entity type; the core attributes include: the model, rated voltage, and rated power of the power equipment entity; S12. Perform entity boundary identification and type labeling on the collected power field corpus according to the entity type to obtain an entity set, and calculate the frequency ratio of each entity; S13. Assess the importance of each entity and calculate the initial weight of each entity based on the frequency ratio and importance score results to obtain the entity weight dictionary; S14. Based on standard documents in the power industry and a corpus in the power field, construct a set of relation types in the power field to represent several types of relationships between different entity types, and assign extraction weights to each relation type to obtain a relation weight dictionary. Identify the obtained entity set according to the set of relation types to obtain the actual relationships and form a relation set. S15. The knowledge graph is obtained based on the entity set, relation set, entity weight dictionary, and relation weight dictionary.

5. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 3, characterized in that, S2 specifically includes: S21. After segmenting, sentence-segmenting, and semantically encoding the input raw power document, perform vector modeling to obtain the paragraph vector of each paragraph and the sentence vector of each sentence; S22. Obtain the topic vector of the power document based on sentence vectors and key power information; the key power information includes equipment number, procedure number, and fault time. S23. Calculate the similarity between each paragraph vector and the topic vector, and extract the core paragraph set based on the similarity results; S24. Index topic vectors in the knowledge graph, locate the corresponding entity types, calculate the similarity between topic vectors and each entity under the entity type, and extract core entities based on the similarity results to form a knowledge subgraph; S25. Based on topic vectors, core paragraph sets, and knowledge subgraphs, construct a Prompt set containing a foundation layer, a knowledge layer, and a constraint layer; S26. After concatenating the Prompt set with the document text of the power document, feed it into the large language model, and introduce a knowledge graph similarity constraint mechanism to decode the output of the large language model to obtain the initial keyword set, the initial confidence of the model, and the keyword score.

6. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 5, characterized in that, In S21, the ElectricBERT model is used for vector modeling; in S22, weight factors are added to the key information on electricity and sentence vectors respectively to calculate the topic vector of the electricity document.

7. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 5, characterized in that, In S24, the calculation of the similarity between the topic vector and each entity under the entity type, and the extraction of core entities based on the similarity results to form a knowledge subgraph, specifically includes: Calculate the similarity between the topic vector and the cluster centers of each cluster under the entity type, and select the clusters with the highest similarity. In each selected cluster, the similarity between the topic vector and all entities is calculated. Based on the length of the power document and the similarity between the topic vector and all entities, the entity filtering range is dynamically set. The set of filtered entities and their associated high-weight relationships constitute the knowledge subgraph.

8. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 5, characterized in that, In S26, the knowledge graph similarity constraint mechanism is specifically as follows: the keyword score is calculated by combining the generation probability of the comprehensive model with the maximum similarity with the core entities in the knowledge subgraph.

9. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 5, characterized in that, S3 specifically includes: S31. Using the original knowledge subgraph as the real subgraph, delete key power entities or relationships to generate a counterfactual subgraph. Calculate the association score in the real subgraph and the counterfactual subgraph for each initial keyword, and take the difference as the counterfactual gain. S32. For each initial keyword, search the knowledge subgraph for all relevant evidence paths, calculate the average score of the evidence paths, and obtain the initial keyword path attribution score. S33. The counterfactual gain, path attribution score and initial confidence of the model corresponding to each initial keyword are weighted and fused to obtain the optimized keyword score. The initial keyword set is then filtered based on the optimized keyword score to obtain the filtered keyword set. S34. Establish reasoning relationships between high-value new keywords and existing entities in the knowledge subgraph, construct temporary nodes, expand the selected keyword set, and obtain the expanded keyword set. S35. Repeat the above steps to continuously iterate and optimize the keyword set.

10. The method for extracting keywords from power documents based on Prompt and knowledge graphs according to claim 9, characterized in that, S4 specifically includes: S41. Average Confidence Score: For each keyword, calculate its average confidence score over all iterations, and then assign an average confidence score to the keyword based on the average confidence score. S42. Knowledge Graph Relevance Score: For each keyword, the semantic similarity with the most similar entity in the knowledge graph and the relation weight between the keyword and other keywords are comprehensively considered to calculate the knowledge graph relevance score. S43. Document Distribution Specificity Score: For each keyword, count and find its frequency of occurrence in core paragraphs, frequency of occurrence in the whole text, and position of first occurrence, and calculate the document distribution specificity score accordingly; S44. Domain Discrimination Score: For each keyword, find its frequency of occurrence in the power domain corpus and the general corpus, and calculate the domain discrimination score accordingly. S45. Explanatory Enhancement Score: For each keyword, calculate the explanatory enhancement score based on its counterfactual gain and evidence path attribution; S46. Comprehensive score: For each keyword, a comprehensive score is obtained by weighted fusion of the average confidence score, knowledge graph relevance score, document distribution specificity score, domain discrimination score, and explanatory enhancement score; S47. After ranking each keyword based on the comprehensive score, the keywords are divided into three levels: core, related, and extended. The core keyword set, related keyword set, and extended keyword set are output hierarchically.

Citation Information

Cited By

  • Carbon inspection domain knowledge graph construction method and system based on prompt engineering

    CN122072837A

  • A method and system for constructing a carbon verification domain knowledge graph based on hint engineering

    CN122072837B