Retrieval enhancement generation method and device based on electric power knowledge graph
By enhancing generation through retrieval in the power knowledge graph and combining dual-channel retrieval from the power knowledge base and knowledge graph, the problem of poor generation quality in the power field in existing methods is solved, and higher-quality answers to professional questions are achieved.
Patent Information
- Application Number
- CN202511689439.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-02-13
AI Technical Summary
Existing retrieval-enhanced generation methods lack effective utilization of structured knowledge in the power sector, resulting in poor generation quality.
The power knowledge graph is introduced to enhance retrieval and generation. By conducting text retrieval in the power knowledge base, relevant text results are obtained. The structured knowledge is then queried in conjunction with the power knowledge graph, and unified integration and organization optimization are performed. After constructing contextual prompts, the input is entered into a preset language model.
It improved the quality of language model generation for professional questions in the power industry, made up for the lack of professional knowledge, and improved retrieval coverage and generation accuracy.
Smart Images

Figure CN121525867A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a retrieval augmented generation method and device based on a power knowledge graph. BACKGROUND
[0002] With the rapid development of artificial intelligence technology, large language models (LLM) have been widely used in intelligent question answering, automatic customer service and other fields. However, although large language models have powerful text generation capabilities, they often have "hallucination" when facing professional problems in the power field, that is, the generated answers do not match the real situation. This is mainly because the training data of general large language models mainly comes from extensive public corpus, and they lack understanding of professional knowledge in the power field, often cannot effectively identify professional concepts specific to the power field, and thus lead to inaccurate or misleading answers.
[0003] Currently, the retrieval augmented generation (RAG) method is one of the technologies that have made breakthroughs in large language model generation in recent years. This method retrieves relevant information in external documents or databases to enhance the context knowledge of the generation model, thereby reducing generation errors and improving credibility.
[0004] However, the existing retrieval augmented generation method relies on unstructured text information retrieval and lacks effective use of structured knowledge involved in the power field, so it often generates poor quality when dealing with professional problems in the power industry. SUMMARY
[0005] The present application provides a retrieval augmented generation method and device based on a power knowledge graph, which can introduce a power knowledge graph into the retrieval augmented generation process to solve the problem of lack of effective use of structured knowledge involved in the power field in the existing retrieval augmented generation method, and improve the generation quality of language models when dealing with professional problems in the power industry.
[0006] According to a first aspect of the present application, a retrieval augmented generation method based on a power knowledge graph is provided, comprising:
[0007] performing text retrieval on the obtained query text in the power knowledge base to obtain a text retrieval result related to the query text;
[0008] querying the power knowledge graph according to the text retrieval result to obtain a knowledge graph retrieval result;
[0009] unifying and integrating the text retrieval result and the knowledge graph retrieval result, and optimizing the organization to construct a context prompt;
[0010] input the query text and the context prompt into a preset language model to generate question and answer content.
[0011] According to a second aspect of the present application, a device for generating retrieval enhancement based on a power knowledge graph is provided, comprising:
[0012] a first retrieval module configured to perform text retrieval on the obtained query text in a power knowledge base to obtain a text retrieval result related to the query text;
[0013] a second retrieval module configured to query the power knowledge graph according to the text retrieval result to obtain a knowledge graph retrieval result;
[0014] a construction module configured to uniformly integrate and optimize the text retrieval result and the knowledge graph retrieval result to construct a context prompt;
[0015] a generation module configured to input the query text and the context prompt into a preset language model to generate question and answer content.
[0016] According to a third aspect of the present application, an electronic device is provided, comprising:
[0017] at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the retrieval enhancement generation method based on the power knowledge graph according to any one of the embodiments of the present application.
[0018] According to a fourth aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to implement the retrieval enhancement generation method based on the power knowledge graph according to any one of the embodiments of the present application when executed by the processor.
[0019] According to a fifth aspect of the present application, a computer program product is provided, which comprises a computer program for implementing the retrieval enhancement generation method based on the power knowledge graph according to any one of the embodiments of the present application when executed by a processor.
[0020] The technical scheme of the embodiment of the present application can first perform text retrieval on the obtained query text in the power knowledge base to obtain a text retrieval result related to the query text, then query the power knowledge graph according to the text retrieval result to obtain a knowledge graph retrieval result, then uniformly integrate and organize and optimize the text retrieval result and the knowledge graph retrieval result, construct a context prompt, finally input the query text and the context prompt into a preset language model to generate question and answer content, which not only introduces the power knowledge graph into the retrieval enhancement generation process, makes up for the deficiency of the language model in the power professional knowledge, and improves the retrieval coverage through graph-text dual-channel retrieval, solves the problem of poor quality of the existing retrieval enhancement generation method in processing power industry professional problems, and improves the generation quality of the language model in processing power industry professional problems.
[0021] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained from these drawings by those skilled in the art without creative labor.
[0023] Figure 1 is a flowchart of a retrieval enhancement generation method based on a power knowledge graph provided by the first embodiment of the present application;
[0024] Figure 2 is a flowchart of a retrieval enhancement generation method based on a power knowledge graph provided by the second embodiment of the present application;
[0025] Figure 3 is a structural schematic diagram of a retrieval enhancement generation device based on a power knowledge graph provided by the third embodiment of the present application;
[0026] Figure 4 is a structural schematic diagram of an electronic device for implementing the retrieval enhancement generation method based on the power knowledge graph of the present application. DETAILED DESCRIPTION
[0027] In the following, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative effort should fall within the protection scope of the present application.
[0028] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or device including a series of steps or units does not necessarily have to be limited to only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product, or device.
[0029] Embodiment one
[0030] Figure 1 A flowchart of a retrieval enhancement generation method based on a power knowledge graph is provided for the first embodiment of the present application. The present embodiment can be applicable to intelligent question answering, fault diagnosis, and decision support scenarios in the power system field. The method can be executed by a retrieval enhancement generation device based on a power knowledge graph. The retrieval enhancement generation device based on a power knowledge graph can be realized in the form of hardware and / or software and can be configured in an electronic device in which a language model is deployed. As shown in the figure, the method includes: Figure 1
[0031] S101, performing text retrieval on the obtained query text in the power knowledge base to obtain a text retrieval result related to the query text.
[0032] The power knowledge base can be an information base storing unstructured or semi-structured documents or data related to the power industry. Specifically, it can include device archives, work order records, business process specifications, and other unstructured or semi-structured text content.
[0033] The query text can be a natural text sentence input by a user. It should be noted that in the intelligent question answering, fault diagnosis, and decision support scenarios in the power system field, a user can input a natural text sentence to an electronic device in which a language model is deployed to inquire about related issues of power business.
[0034] Exemplarily, after receiving the query text input by the user, the embodiment can first preprocess the query text to ensure the normativity and semantic integrity of the query text as the input content of the preliminary text retrieval. The preprocessing can include, but is not limited to, uniform time and number format, case and model string normalization, word segmentation and part-of-speech tagging, spelling correction and phrase recognition, and truncation or important information extraction in the case of query length exceeding, and the like.
[0035] After preprocessing the query text, the similarity between the query text and each text paragraph stored in the power knowledge base can be calculated by a semantic similarity algorithm, so as to determine the text paragraph with high matching similarity as the text retrieval result.
[0036] Optionally, the text retrieval on the obtained query text in the power knowledge base to obtain the text retrieval result related to the query text can further include:
[0037] determining the semantic features of the query text;
[0038] performing semantic vector retrieval and keyword retrieval in parallel based on the semantic features, retrieving the text paragraph related to the semantic features from the power knowledge base as the text retrieval result.
[0039] The semantic features can be a representation reflecting the deep semantic information of the query text.
[0040] It should be noted that, in order to further improve the accuracy of the text retrieval process, the embodiment can use the semantic vector retrieval and keyword matching method to retrieve the relevant text paragraph from the power knowledge base based on the semantic features of the query text, and obtain the power business background information related to the query text.
[0041] Exemplarily, after obtaining the query text input by the user, the query text can be first converted into a high-dimensional vector representation by using a semantic encoding model to capture its deep semantic information. Then, a pre-trained model text vectorization method can be used to map the query text and the text content in the power knowledge base to the same semantic space, and filter out the first target text with high semantic relevance through similarity calculation. On this basis, a keyword matching algorithm can also be used to retrieve the second target text containing the keywords or key words in the query text in the power knowledge base. Finally, the first target text and the second target text are aggregated as the text retrieval result.
[0042] The advantage of such a setting is that by fusing two retrieval strategies, both semantic relevance and complete coverage of power business vocabulary are guaranteed, greatly improving the accuracy of the text retrieval process.
[0043] S102. Based on the text retrieval results, query the power knowledge graph to obtain the knowledge graph retrieval results.
[0044] In this context, the power knowledge graph can be a graph that represents knowledge in the power field in a structured form. For example, each node in the power knowledge graph can represent an entity (such as equipment, work order, personnel, etc.), and edges can represent relationships between entities (such as belonging, containing, processing, etc.). Attributes (such as state, time, parameters, etc.) can also be attached to nodes and edges to construct a knowledge graph that electronic devices can understand.
[0045] Knowledge graph retrieval results can be a collection of local knowledge subgraphs that are related to the text retrieval results and obtained from the power knowledge graph.
[0046] It should be noted that knowledge about the power industry includes a large amount of structured information, such as power equipment models, fault analysis procedures, and equipment installation and maintenance history. This information is crucial for language models to generate effective answers. However, traditional language models cannot directly process this structured knowledge, and existing retrieval enhancement methods mainly rely on unstructured or semi-structured text content stored in power knowledge bases, lacking effective utilization of structured knowledge in the power industry. Therefore, after obtaining text retrieval results, in order to further extract deep business semantics from the structured power knowledge graph and fully utilize the structured knowledge of the power industry, this invention further queries a pre-constructed power knowledge graph through the text retrieval results to obtain knowledge graph retrieval results.
[0047] For example, after the text search results, entity recognition can be performed on the text search results to determine the names of the entities (such as equipment, work orders, personnel, etc.) involved in the text search results. Then, based on the entity names involved in the text search results, a query is performed in a pre-constructed power knowledge graph to retrieve the attribute information and relationship network associated with them, forming a local subgraph centered on the entity, and the local subgraph centered on the entity is used as the knowledge graph search result.
[0048] It is understandable that this embodiment, through power knowledge graph retrieval, can overcome the limitations of text retrieval and capture the actual business logic relationships between entities. For example, when a text search result mentions a device number, the power knowledge graph can further provide the device's technical parameters, region, maintenance records, and other attribute information, as well as its association paths with relevant work orders and fault events. Therefore, by introducing a structured power knowledge graph, this invention enables language models to understand the complex entity relationship network and attribute information in power business, thereby laying the foundation for generating answers that conform to the logic of the power industry.
[0049] S103. The text retrieval results and the knowledge graph retrieval results are integrated and optimized in a unified manner to construct contextual prompts.
[0050] Contextual hints can refer to input text that can be directly used by the language model, which may contain some knowledge elements needed to answer the user's query.
[0051] It should be noted that after completing text retrieval and knowledge graph retrieval, this embodiment can integrate and optimize the knowledge content with different structures obtained from the retrieval, so as to construct contextual prompts that not only conform to the business logic of power information and communication, but can also be efficiently processed by the language model.
[0052] For example, after obtaining unstructured text search results and structured knowledge graph search results, these results can be integrated and converted into search content in a unified format to ensure consistency and standardized structure across different search results. Then, redundant information in the unified search content is removed, filtering out the core content relevant to the query text. Finally, the organization order of the core content can be optimized based on the inherent patterns of the power business scenario, constructing contextual hints for direct use by the language model.
[0053] For example, in equipment status queries, equipment attributes are displayed first. In work order processing scenarios, the time logic of "work order creation → processing steps → execution results" is followed. Contextual prompts that can be directly used by the language model are constructed. This ensures that the final contextual prompts not only contain the necessary knowledge elements, but also present a semantic order that conforms to the logic of the power industry, greatly reducing the difficulty of understanding the language model.
[0054] S104. Input the query text and the contextual prompts into a preset language model to generate question and answer content.
[0055] The preset language model can be an artificial intelligence model that has been pre-trained on large-scale text data and possesses strong natural language understanding and generation capabilities. The question-and-answer content can be the text content output by the preset language model based on the received contextual prompts and the query text input by the user. This text content can be used to answer the user's questions about electricity business.
[0056] For example, this embodiment can combine the user-input query text with corresponding contextual hints to construct the target input content of a preset language model. This target input sequence includes both the power business question the user wants to query and contextual hints related to power knowledge. Furthermore, the contextual hints not only include unstructured business descriptions from text retrieval but also integrate structured knowledge information obtained from knowledge graph retrieval, forming complete hint content covering the power business logic. This allows the preset language model to effectively avoid "illusion" phenomena during reasoning and generation, reducing the risk of generated content not matching actual business, thereby ensuring the accuracy and professionalism of the answer.
[0057] After the target input is fed into a pre-defined language model, the model can generate question-and-answer content that conforms to relevant power knowledge by combining contextual hints about the user's query regarding power business issues. Specifically, during generation, the pre-defined language model can capture information such as entities, attributes, and relationships from contextual hints through an attention mechanism, and perform semantic modeling based on the user's query intent. In this process, the pre-defined language model is strongly guided by the structured knowledge in the contextual hints, ensuring that the generated question-and-answer content not only answers the query text but also connects upstream and downstream business logic. For example, when the contextual hints include "work order processing steps" or "equipment history," the pre-defined language model can organize and utilize the information contained in the contextual hints in the answer, ensuring that the generated question-and-answer content conforms to the standards and processes of the power industry.
[0058] For example, when a user queries "What recent fault handling records has TR-120 had?", this invention can input optimized contextual prompts into a preset language model. The contextual prompts can include knowledge elements such as "TR-120 generated work order G-001 in May 2024 due to an overload fault," "Work order G-001 includes dispatching, on-site inspection, and fault confirmation steps," and "The work order result is closed." During the generation process, the preset language model can use an attention mechanism to aggregate and model the above knowledge elements, ultimately outputting the question-and-answer content: "Equipment TR-120 created work order G-001 in May 2024 due to an overload fault. The handling steps included dispatching, on-site inspection, and fault confirmation. The current status is closed." This question-and-answer content covers the user's query needs while maintaining the integrity of the business logic, avoiding redundancy or omissions.
[0059] The technical solution of this embodiment can first perform text retrieval on the obtained query text in the power knowledge base to obtain text retrieval results related to the query text, and then query the power knowledge graph based on the text retrieval results to obtain knowledge graph retrieval results. Then, the text retrieval results and the knowledge graph retrieval results are uniformly integrated and optimized to construct contextual hints. Finally, the query text and the contextual hints are input into a preset language model to generate question and answer content. This not only introduces the power knowledge graph into the retrieval enhancement generation process, making up for the shortcomings of the language model in power professional knowledge, but also improves the retrieval coverage by using a dual-channel retrieval of graph and text. It solves the problem of poor quality in existing retrieval enhancement generation methods when dealing with professional issues in the power industry, and improves the generation quality of the language model when dealing with professional issues in the power industry.
[0060] Based on the above embodiments, the present invention also provides an optional embodiment, which can further illustrate the construction process of the power knowledge graph in the above embodiments, and may specifically include:
[0061] The method for constructing the power knowledge graph may include:
[0062] The pre-collected power knowledge data is processed in a unified and standardized manner to obtain standardized data;
[0063] Based on domain-adaptive entity recognition and relation extraction technology, business entities and semantic relationships are extracted from the standardized data;
[0064] The extracted business entities and semantic relationships are organized into triples to construct an electricity knowledge graph.
[0065] The construction of the power knowledge graph can be based on in-depth analysis of power knowledge data involved in the power business industry. This power knowledge data can cover multi-source heterogeneous data such as equipment, work orders, business processes, and FAQs. Business entities can be equipment, work orders, personnel, etc., involved in the power knowledge data. Semantic relationships can be the semantic information corresponding to the text of business entities contained in the power knowledge data.
[0066] Understandably, the triple form can be (business entity, attribute, attribute value) or (business entity, relation, business entity), which can be flexibly determined by the semantic relation corresponding to the business entity. For example, the semantic relation extracted for the business entity (device TR-120) is: device TR-120 belongs to the Southwest region and the installation date is 2020-05-10. In this case, the triple form can be (business entity, attribute, attribute value), and the specific content can be: (device TR-120, belongs to, Southwest region) and (device TR-120, installation date, 2020-05-10). The semantic relation extracted for the business entity (device TR-120) is: the latest work order for device TR-120 is WO:G-001. In this case, the triple form can be (business entity, relation, business entity), and the specific content can be: (device TR-120, latest work order, WO:G-001).
[0067] For example, this optional embodiment can pre-establish a complete data ingestion and preprocessing pipeline to batch collect raw power knowledge data from various business subsystems such as scheduling systems, equipment management systems, work order management platforms, operation and maintenance logs, quality inspection records, and knowledge bases. Furthermore, after acquiring the raw power knowledge data, it can be first subjected to unified standardization processing, specifically including field name normalization, timestamp formatting, unit and dimension standardization, string standardization (e.g., unified writing of model and work group names), and noise filtering (e.g., log template denoising), to obtain unified and standardized data.
[0068] Furthermore, in the extraction stage, a strategy combining domain-adaptive Entity Recognition (NER) and Relation Extraction (RE) methods can be employed to identify business entities such as equipment, work orders, regions, statuses, work groups, steps, and fault types, and their semantic relationships within standardized data. For the extraction of routine business entities and semantic relationships, rule-based or template-based high-confidence extraction (e.g., matching syntactic patterns like "work order.* contains steps" or "equipment.* current status is") can be prioritized. For complex or variable text scenarios, supervised sequence labeling based on Transformer and a relation classifier can be used, fine-tuned with domain-specific corpora to improve extraction coverage and accuracy.
[0069] Finally, based on the extracted business entities and their corresponding semantic relationships, they can be organized into triples (business entity, attribute, attribute value) or (business entity, relationship, business entity) according to standardized templates to construct a power knowledge graph.
[0070] It should be noted that, in order to avoid the same business entity appearing multiple times in different data sources and the business entity having inconsistent names, this embodiment can also perform disambiguation and normalization (entity linking) processing on the business entity. By combining rule priority, vectorized similarity matching and human review verification, the standardized representation of the business entity is determined. At the same time, an alias table and source links can be retained in the power knowledge graph for auditing purposes.
[0071] Furthermore, to enhance the semantic expressive power of the power knowledge graph, graph embedding-based semantic modeling can be introduced during the construction phase. This maps business entities and semantic relationships into a vector space representation, supporting similarity retrieval and semantic reasoning. Simultaneously, to address the common issue of missing attributes, rule inference and attribute prediction based on similar entities can be combined to complete missing attributes and label their confidence levels. For time-series or process-related information, hierarchical modeling can organize business entities according to business scope and process hierarchy, ensuring the graph possesses both horizontal coverage and vertical process expression capabilities. The final constructed power knowledge graph can serve as a structured knowledge source for enhanced retrieval and also provide foundational support for subsequent contextual organization.
[0072] Based on the above embodiments, the present invention also provides an optional embodiment, which can further optimize and organize the text retrieval results and the knowledge graph retrieval results in step S103 of the above embodiments, construct contextual prompts, and perform further optimization. Specifically, it may include:
[0073] The structured triples in the knowledge graph retrieval results are converted into natural language description fragments;
[0074] Entity alignment and redundancy elimination are performed on the text retrieval results and the natural language description fragments to obtain a core content set;
[0075] The core content in the core content set is ordered according to semantic coherence, and the context prompt is constructed.
[0076] It should be noted that the contextual hints used to provide the power knowledge foundation for the language model may contain a large amount of text content and involve multiple steps. To optimize the organization of long, multi-step contextual hints and enhance the semantic coherence and reasoning ability during the language model generation process, this optional embodiment can convert text retrieval results and knowledge graph retrieval results into uniformly formatted contextual content. This ensures consistency and standardized structure of information from different sources. Redundant information in the contextual content is then removed, and core content relevant to the query intent is selected. Finally, based on the power knowledge graph, the organization order of the contextual content is optimized to generate semantically coherent contextual hints that conform to business logic.
[0077] Understandably, this process involves content standardization, redundancy elimination, and context group leader optimization to ensure that the final context prompts are both compact and efficient, as well as logically clear.
[0078] First, in the content standardization stage, this optional embodiment can unify the representation of content from two types of data sources: On the one hand, unstructured paragraphs obtained from text retrieval often contain noise and need to be formatted after sentence segmentation, referential resolution, and removal of redundant phrases; on the other hand, structured triples obtained from knowledge graph expansion need to be converted into natural language fragments to maintain stylistic consistency with the paragraph corpus. For example, the triple ("Device TR-120", "Operating Status", "Overload") is converted into "Device TR-120 is currently in an overloaded operating status"; ("Work Order G-001", "Includes Steps", "Dispatch") is converted into "The processing steps of Work Order G-001 include dispatch." In this stage, the consistency of description of retrieval results with different structures can be guaranteed, avoiding the impact of expression differences on the language model's understanding.
[0079] Secondly, in the redundancy resolution stage, duplicate information can be merged through entity alignment and semantic similarity calculation. For example, if both text retrieval results and knowledge graph retrieval results return "TR-120 experienced an overload failure in May 2024," only the description with the highest confidence level is retained, along with a source annotation, so that the model can cite more authoritative evidence when generating answers. Information with low semantic relevance is filtered using a similarity threshold (e.g., cosine similarity less than 0.6) to prevent irrelevant content from interfering with the generation process.
[0080] Finally, in the context organization optimization stage, a "process-aware sorting" mechanism can be introduced. This mechanism can utilize the relational information in the power knowledge graph and power business specifications to arrange contextual prompts according to the order of business logic. For example, for tasks involving work order queries, the context is arranged in the order of "basic work order information → processing steps → processing results → related equipment information," while for tasks involving equipment operation status queries, equipment attributes and status are displayed first, followed by historical work orders and regional information. This organization not only improves semantic coherence but also makes it easier for the big data model to capture the business logic chain, thereby generating answers that conform to industry standards.
[0081] Example 2
[0082] Figure 2This is a flowchart of a retrieval enhancement generation method based on a power knowledge graph provided in Embodiment 2 of the present invention. This embodiment can further optimize step S102 of Embodiment 1 above, which involves querying the power knowledge graph based on the text retrieval results to obtain the knowledge graph retrieval results. For example... Figure 2 As shown, the method includes:
[0083] S201. Perform a text search on the obtained query text in the power knowledge base to obtain text search results related to the query text.
[0084] S202. Identify key entities in the text search results; the key entity is at least one business entity involved in the text search results.
[0085] Understandably, a key entity can be at least one business object identified in the text search results that plays a core role in understanding and answering user queries. It is usually one of the business objects involved in each text paragraph in the text search results.
[0086] For example, after obtaining the text retrieval results, entity recognition technology can be used to perform in-depth analysis on each text segment in the text detection results to identify and extract the business entities mentioned therein. For instance, a pre-trained entity recognition model can be used to locate key entities such as the device number "TR-120" and the work order number "G-001" from each text segment in the text detection results.
[0087] S203. Based on the key entity, perform a controllable multi-hop expansion query in the power knowledge graph to determine the target subgraph set, and use the target subgraph set as the knowledge graph retrieval result; wherein, the number of hops, path type, and expansion branch of the controllable multi-hop expansion query are constrained by the type of the key entity.
[0088] Controllable multi-hop extended query can be a graph structure traversal query in the power knowledge graph, starting from a key entity and following a predefined path type and extension branch relationship path with a finite step size (number of hops). The target subgraph set can be a set of local graph structures in the power knowledge graph centered on the key entity, containing the key entity and its associated other entities, attributes, and relationships.
[0089] It should be noted that the number of hops, path type, and extension branches of the controllable multi-hop extended query are constrained by the type of the key entity. For example, the maximum number of hops can be predefined for different categories of business entities (e.g., max_hops=2 for the device class, max_hops=1 for the work order class), and restrictions can be placed on the allowed relationship types and directions (e.g., prohibiting cross-domain relationships unrelated to the query, such as "company of origin → external contract"). Therefore, after identifying the key entity, the number of hops, path type, and extension branches of the controllable multi-hop extended query can be determined based on the type of the key entity.
[0090] For example, an extended constraint configuration table can be pre-established to define the maximum number of hops allowed for different types of business entities, a whitelist of allowed extended relationship types, and a blacklist of prohibited extended relationship types. Once a key entity is identified, the corresponding extended constraint parameters can be obtained from the extended constraint configuration table based on the type of the key entity. Controlled multi-hop extended queries can then be performed based on these parameters, ensuring that the extended queries obtain sufficient relational knowledge without introducing irrelevant or redundant information.
[0091] Optionally, the step of determining the target subgraph set by performing a controllable multi-hop extended query in the power knowledge graph based on the key entity may further include:
[0092] Determine the canonical entity identifiers of the key entities in the power knowledge graph;
[0093] Starting from the standardized entity identifier, the associated adjacency information is retrieved in the power knowledge graph to obtain a one-hop adjacency subgraph;
[0094] Perform a controllable multi-hop expansion query on the one-hop adjacency subgraph to obtain a multi-hop expanded subgraph;
[0095] The one-hop adjacency subgraph and the multi-hop extended subgraph are merged to form the target subgraph set.
[0096] Among them, the standardized entity identifier can be a standardized code that uniquely identifies a business entity in the power knowledge graph, and is used to accurately locate entity nodes in the power knowledge graph.
[0097] A one-hop adjacency subgraph can be a local graph structure centered on a key entity, containing adjacent entities directly connected to the key entity and their relationships. A multi-hop extended subgraph can be a larger graph structure obtained by continuing to perform extended queries with a finite step size on each entity node in the one-hop adjacency subgraph.
[0098] For example, after identifying key entities, this embodiment can further normalize the identified key entities and map them to standardized entity identifiers in the power knowledge graph, laying the foundation for accurate subsequent queries in the power knowledge graph and improving the efficiency of knowledge graph retrieval.
[0099] Next, using the entity identifier in the specification as the starting point, the query interface of the power knowledge graph is invoked to obtain all adjacent entities and relationships within its one-hop range, forming a one-hop adjacency subgraph. Then, based on preset expansion constraint rules, a second round of expansion queries can be performed on each entity node in the one-hop adjacency subgraph: for entity types that are allowed to continue expansion, expansion queries are performed according to pre-configured hop count limits and path relationship constraints to obtain their two-hop adjacency information; for entity types that are not allowed to expand or have reached the maximum hop count, expansion is stopped. It is understood that this process can be iterated as needed, but the total number of hops will not exceed the preset maximum hop count corresponding to the entity type that is a key entity.
[0100] Finally, the initial one-hop adjacency subgraph can be merged with all the extended subgraphs obtained through multi-hop expansion, and duplicate nodes and edges can be removed to form a complete set of target subgraphs.
[0101] The advantage of this setup is that it ensures the integrity of related knowledge while also achieving controllability of the query process through type constraints, effectively balancing retrieval performance and computational efficiency.
[0102] S204. The text retrieval results and the knowledge graph retrieval results are integrated and optimized in a unified manner to construct contextual prompts.
[0103] S205. Input the query text and the contextual prompts into a preset language model to generate question and answer content.
[0104] The technical solution of this embodiment can determine the knowledge graph retrieval results by performing controllable multi-hop extended queries based on key entities in the power knowledge graph. This further improves the depth and breadth of the detection process, thereby making the final constructed contextual prompts richer and more complete in structure. This is conducive to guiding the language model to generate accurate, professional, and high-quality answers that conform to the power business process, and significantly improves the accuracy and reliability of the question and answer content.
[0105] Example 3
[0106] Figure 3 This is a schematic diagram of a retrieval enhancement generation device based on a power knowledge graph, provided in Embodiment 3 of the present invention. Figure 3 As shown, the device includes:
[0107] The first retrieval module 31 can be used to perform text retrieval on the obtained query text in the power knowledge base and obtain text retrieval results related to the query text;
[0108] The second retrieval module 32 can be used to query the power knowledge graph based on the text retrieval results and obtain the knowledge graph retrieval results;
[0109] Module 33 can be used to integrate and organize the text retrieval results and the knowledge graph retrieval results in a unified manner, and to build contextual prompts;
[0110] The generation module 34 can be used to input the query text and the context prompts into a preset language model to generate question and answer content.
[0111] The technical solution of this embodiment can first perform text retrieval on the obtained query text in the power knowledge base to obtain text retrieval results related to the query text, and then query the power knowledge graph based on the text retrieval results to obtain knowledge graph retrieval results. Then, the text retrieval results and the knowledge graph retrieval results are uniformly integrated and optimized to construct contextual hints. Finally, the query text and the contextual hints are input into a preset language model to generate question and answer content. This not only introduces the power knowledge graph into the retrieval enhancement generation process, making up for the shortcomings of the language model in power professional knowledge, but also improves the retrieval coverage by using a dual-channel retrieval of graph and text. It solves the problem of poor quality in existing retrieval enhancement generation methods when dealing with professional issues in the power industry, and improves the generation quality of the language model when dealing with professional issues in the power industry.
[0112] Optionally, the method for constructing the power knowledge graph may include:
[0113] The pre-collected power knowledge data is processed in a unified and standardized manner to obtain standardized data;
[0114] Based on domain-adaptive entity recognition and relation extraction technology, business entities and semantic relationships are extracted from the standardized data;
[0115] The extracted business entities and semantic relationships are organized into triples to construct an electricity knowledge graph.
[0116] Optionally, the first retrieval module 31 can be specifically used to determine the semantic features of the query text;
[0117] Based on the semantic features, semantic vector retrieval and keyword retrieval are performed in parallel to retrieve text paragraphs related to the semantic features from the power knowledge base, which are then used as the text retrieval results.
[0118] Optionally, the second retrieval module 32 may include: an identification unit and a query unit;
[0119] The identification unit can be used to identify key entities in the text search results; the key entity is at least one business entity involved in the text search results;
[0120] The query unit can be used to perform a controllable multi-hop extended query in the power knowledge graph based on the key entity, determine the target subgraph set, and use the target subgraph set as the knowledge graph retrieval result;
[0121] The number of hops, path type, and extension branches of the controllable multi-hop extended query are constrained by the type of the key entity.
[0122] Optionally, the query unit can be specifically used to determine the canonical entity identifier of the key entity in the power knowledge graph;
[0123] Starting from the standardized entity identifier, the associated adjacency information is retrieved in the power knowledge graph to obtain a one-hop adjacency subgraph;
[0124] Perform a controllable multi-hop expansion query on the one-hop adjacency subgraph to obtain a multi-hop expanded subgraph;
[0125] The one-hop adjacency subgraph and the multi-hop extended subgraph are merged to form the target subgraph set.
[0126] Optionally, the construction module 33 can be specifically used to convert the structured triples in the knowledge graph retrieval results into natural language description fragments;
[0127] Entity alignment and redundancy elimination are performed on the text retrieval results and the natural language description fragments to obtain a core content set;
[0128] The core content in the core content set is ordered according to semantic coherence, and the context prompt is constructed.
[0129] The retrieval enhancement generation device based on power knowledge graph provided in this embodiment of the invention can execute the retrieval enhancement generation method based on power knowledge graph provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0130] Example 4
[0131] Figure 4A schematic diagram of an electronic device 40 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0132] like Figure 4 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded from storage unit 48 into the RAM 43. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0133] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0134] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as a retrieval enhancement generation method based on an electrical knowledge graph.
[0135] In some embodiments, a retrieval enhancement generation method based on an electricity knowledge graph can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the retrieval enhancement generation method based on an electricity knowledge graph described above can be performed. Alternatively, in other embodiments, processor 41 can be configured to execute a retrieval enhancement generation method based on an electricity knowledge graph by any other suitable means (e.g., by means of firmware).
[0136] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0137] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0138] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0139] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0140] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0141] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0142] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0143] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A retrieval enhancement generation method based on power knowledge graph, characterized in that, include: The obtained query text is searched in the power knowledge base to obtain text search results related to the query text; Based on the text retrieval results, query the power knowledge graph to obtain the knowledge graph retrieval results; The text retrieval results and the knowledge graph retrieval results are integrated and optimized in a unified manner to construct contextual prompts; Input the query text and the contextual hints into a preset language model to generate question and answer content.
2. The method according to claim 1, characterized in that, The method for constructing the power knowledge graph includes: The pre-collected power knowledge data is processed in a unified and standardized manner to obtain standardized data; Based on domain-adaptive entity recognition and relation extraction technology, business entities and semantic relationships are extracted from the standardized data; The extracted business entities and semantic relationships are organized into triples to construct an electricity knowledge graph.
3. The method according to claim 1, characterized in that, The step of performing a text search on the obtained query text in the power knowledge base to obtain text search results related to the query text includes: Determine the semantic features of the query text; Based on the semantic features, semantic vector retrieval and keyword retrieval are performed in parallel to retrieve text paragraphs related to the semantic features from the power knowledge base, which are then used as the text retrieval results.
4. The method according to claim 1, characterized in that, The step of querying the power knowledge graph based on the text retrieval results to obtain the knowledge graph retrieval results includes: Identify key entities in the text search results; the key entity is at least one business entity involved in the text search results; Based on the key entities, a controllable multi-hop extended query is performed in the power knowledge graph to determine the target subgraph set, and the target subgraph set is used as the retrieval result of the knowledge graph. The number of hops, path type, and extension branches of the controllable multi-hop extended query are constrained by the type of the key entity.
5. The method according to claim 4, characterized in that, Based on the key entities, a controllable multi-hop extended query is performed in the power knowledge graph to determine the target subgraph set, including: Determine the canonical entity identifiers of the key entities in the power knowledge graph; Starting from the standardized entity identifier, the associated adjacency information is retrieved in the power knowledge graph to obtain a one-hop adjacency subgraph; Perform a controllable multi-hop expansion query on the one-hop adjacency subgraph to obtain a multi-hop expanded subgraph; The one-hop adjacency subgraph and the multi-hop extended subgraph are merged to form the target subgraph set.
6. The method according to claim 1, characterized in that, The process of unifying and optimizing the text retrieval results and the knowledge graph retrieval results to construct contextual prompts includes: The structured triples in the knowledge graph retrieval results are converted into natural language description fragments; Entity alignment and redundancy elimination are performed on the text retrieval results and the natural language description fragments to obtain a core content set; The core content in the core content set is ordered according to semantic coherence, and the context prompt is constructed.
7. A retrieval enhancement generation device based on an electricity knowledge graph, characterized in that, include: The first retrieval module is used to perform text retrieval on the obtained query text in the power knowledge base and obtain text retrieval results related to the query text. The second retrieval module is used to query the power knowledge graph based on the text retrieval results to obtain the knowledge graph retrieval results; The module is used to integrate and organize the text retrieval results and the knowledge graph retrieval results in a unified manner, and to build contextual prompts; The generation module is used to input the query text and the contextual prompts into a preset language model to generate question-and-answer content.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the retrieval enhancement generation method based on the power knowledge graph as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the retrieval enhancement generation method based on the power knowledge graph as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the retrieval enhancement generation method based on the power knowledge graph as described in any one of claims 1-6.
Citation Information
Cited By
Power grid intelligent scheduling decision-making method, device and equipment based on retrieval enhancement generation
CN121920790A