Retrieval enhancement generation method and device of power system, medium and equipment

By constructing a power knowledge graph and combining it with query optimization and hybrid retrieval, the problems of insufficient credibility and interpretability of generated results in the power system are solved, and efficient and interpretable power system retrieval and generation are achieved.

CN120723879AInactive Publication Date: 2025-09-30STATE GRID ZHEJIANG ELECTRIC POWER CO LTD +1

Patent Information

Application Number
CN202511241253.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-02
Publication Date
2025-09-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing automatic retrieval and generation methods for power systems have problems with misjudgment and poor credibility of generated results when dealing with complex semantics in the power field. In addition, the query threshold is high, and users need to accurately enter keywords or professional terms. The generated results are not interpretable enough and are difficult to use for actual decision-making.

Method used

By constructing an electric power knowledge graph, combining query optimization, hybrid retrieval and attribution mechanisms, and utilizing the structured relationships of the electric power knowledge graph, we conduct hybrid semantic and graph retrieval to enhance the credibility and interpretability of the generated results.

Benefits of technology

It improves the credibility and retrieval efficiency of the generated results, lowers the query threshold, and enhances the interpretability of the generated results. It is suitable for fault diagnosis, dispatch instruction optimization, and intelligent customer service and training of power systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723879A_ABST
    Figure CN120723879A_ABST
Patent Text Reader

Abstract

The invention discloses a retrieval enhancement generation method and device of an electric power system, a medium and equipment, and the method comprises the steps: constructing an electric power knowledge graph according to an original corpus of the electric power system, and constructing a structure index and a semantic index according to the electric power knowledge graph; performing query optimization on the original query content input by the user to obtain professional query content; performing neighbor sampling on the electric power knowledge graph according to the professional query content to obtain a query related sub-graph; according to the professional query content, the query related sub-graph, the structure index and the semantic index, performing mixed retrieval of semantics and maps to obtain a query retrieval result; and performing enhanced generation on the query retrieval result based on an attribution mechanism to obtain a user query answer. According to the technical scheme, the credibility of the generated result can be improved, meanwhile, the retrieval efficiency is improved, the query threshold is lowered, and the interpretability of the generated result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a retrieval enhancement generation method, device, computer-readable storage medium and terminal equipment for a power system. Background Art

[0002] The operation and management of power systems involve massive amounts of structured and unstructured data, such as equipment parameters, fault records, dispatch instructions, standard specification documents, etc. Traditional manual retrieval and decision-making methods are inefficient and cannot meet the rapid response requirements of smart grids. Therefore, automatic retrieval and generation methods for power systems have emerged.

[0003] At present, the automatic retrieval and generation of power system mainly rely on the following technologies: (1) Retrieval method based on keyword matching: using traditional information retrieval technologies such as inverted index, TF-IDF (Term Frequency-Inverse Document Frequency), BM25 (BestMatch 25), such as tools such as Elasticsearch. Its advantages are high computational efficiency and suitability for structured data, but it is difficult to handle complex semantics in the power field. For example, "overload protection" and "short circuit protection" may be misjudged as irrelevant concepts, resulting in poor credibility of the generated results; (2) Generative model method based on deep learning: directly using pre-trained language models to generate power-related texts, such as GPT (Generative Pre-Training), BART (Bidirectional and Auto-Regressive Transformers) and other models. Its advantages are smooth content generation and adaptability to open domain question answering. However, it is easy to produce "hallucinations", such as generating incorrect suggestions that do not comply with power regulations, which also affects the credibility of the generated results; (3) Retrieval-Augmented Generation Retrieval and Generation (RAG): This approach combines the retrieval and generation processes, first retrieving relevant documents and then generating answers. This approach can reduce generation errors and improve credibility. However, the general RAG model is not optimized for the power sector, resulting in low retrieval efficiency. Furthermore, the query threshold is high, requiring users to accurately enter keywords or professional terms to obtain valid results. Furthermore, the generated results are not interpretable enough and lack authoritative basis, making them difficult to use for actual decision-making. Summary of the Invention

[0004] The purpose of the embodiments of the present invention is to provide a retrieval enhancement generation method, device, computer-readable storage medium and terminal device for an electric power system. By utilizing the structured relationship of the electric power knowledge graph and combining query optimization, hybrid retrieval, enhancement generation and attribution mechanism to perform retrieval enhancement generation, it is possible to improve the credibility of the generated results while improving the retrieval efficiency, lowering the query threshold and improving the interpretability of the generated results.

[0005] To achieve the above objectives, an embodiment of the present invention provides a search enhancement generation method for a power system, comprising: Constructing an electric power knowledge graph based on the original corpus of the electric power system, and constructing a structural index and a semantic index based on the electric power knowledge graph; Optimize the original query content entered by the user to obtain professional query content; Performing neighbor sampling on the electric power knowledge graph according to the professional query content to obtain a query-related subgraph; Performing a mixed search of semantics and graphs based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain a query retrieval result; The query retrieval results are enhanced and generated based on the attribution mechanism to obtain the user query answer.

[0006] Furthermore, the construction of the power knowledge graph based on the original corpus of the power system specifically includes: Preprocess the original corpus of power system; Slice and vectorize the preprocessed original corpus, and store all the obtained vectors in the vector database; Based on the recursive invariant and large language model, cross-document entity relations are extracted from the preprocessed original corpus to obtain the power knowledge graph.

[0007] Furthermore, constructing a structural index and a semantic index based on the power knowledge graph specifically includes: Using a graph neural network to extract structural information of the power knowledge graph and obtain a structural index; A large language model is used to extract entity semantic information of the power knowledge graph to obtain a semantic index.

[0008] Furthermore, the query optimization of the original query content input by the user to obtain professional query content specifically includes: Determine the intent of the original query content entered by the user; If the intention of the original query content is unclear, a reverse prompt will be performed until the intention is clear, and the query content with clear intention will be used as the professional query content.

[0009] Furthermore, the hybrid search of semantics and graphs is performed based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain query retrieval results, specifically including: Performing entity semantic retrieval based on the professional query content and the query-related subgraph, and performing similarity calculation in combination with the semantic index to obtain semantic similarity; Performing a graph structure search based on the professional query content and the query-related subgraph, and performing similarity calculation in combination with the structure index to obtain graph path similarity; The query retrieval result is obtained by performing weighted fusion based on the semantic similarity and the graph path similarity.

[0010] Furthermore, the query retrieval results are enhanced and generated based on the attribution mechanism to obtain the user query answer, specifically including: Perform sentence semantic retrieval based on the professional query content and the vector database to obtain semantic retrieval results; Acquire entity enhancement content based on the query retrieval results and the large language model; Obtaining retrieval information based on the semantic retrieval results and the entity-enhanced content, and inputting the professional query content and the retrieval information into a large language model to obtain generated content; Based on the extended attribution mechanism during testing, a dynamic attention fusion method is used to modify the generated content to obtain the user query answer, and a contribution weight is assigned to each retrieved document involved in the user query answer.

[0011] Furthermore, before modifying the generated content, the method further includes: Obtaining a domain compliance score of the generated content according to the search information; The domain compliance score is compared with a preset threshold, and it is determined whether the generated content needs to be modified based on the comparison result.

[0012] To achieve the above objectives, an embodiment of the present invention further provides a search enhancement generation device for a power system, comprising: A graph and index construction module is used to construct an electric power knowledge graph based on the original corpus of the electric power system, and to construct a structural index and a semantic index based on the electric power knowledge graph; The query optimization module is used to optimize the original query content entered by the user to obtain professional query content; A query subgraph acquisition module is used to perform neighbor sampling on the power knowledge graph according to the professional query content to obtain a query-related subgraph; A hybrid retrieval module, configured to perform a hybrid semantic and graph retrieval based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain a query retrieval result; The retrieval enhancement generation module is used to enhance the query retrieval results based on the attribution mechanism to obtain the user query answer.

[0013] An embodiment of the present invention further provides a computer-readable storage medium, comprising a stored computer program, wherein when the computer program is run, the device where the computer-readable storage medium is located controls the device to execute any one of the above-mentioned methods for enhancing the retrieval of the power system.

[0014] An embodiment of the present invention also provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements any of the above-mentioned retrieval enhancement generation methods for the power system when executing the computer program.

[0015] Compared with the prior art, the embodiments of the present invention provide a method, apparatus, computer-readable storage medium and terminal device for retrieval enhancement generation of an electric power system, construct an electric power knowledge graph based on the original corpus of the electric power system, and construct a structural index and a semantic index based on the electric power knowledge graph; perform query optimization on the original query content input by the user to obtain professional query content; perform neighbor sampling on the electric power knowledge graph based on the professional query content to obtain query-related subgraphs; perform a hybrid retrieval of semantics and graphs based on the professional query content, query-related subgraphs, structural indexes and semantic indexes to obtain query retrieval results; and perform enhanced generation of the query retrieval results based on an attribution mechanism to obtain answers to user queries. The embodiments of the present invention utilize the structured relationships of the electric power knowledge graph and combine query optimization, hybrid retrieval, enhanced generation and attribution mechanisms to perform retrieval enhancement generation, which can improve the credibility of the generated results while improving retrieval efficiency, lowering the query threshold and improving the interpretability of the generated results. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 This is a flow chart of a search enhancement generation method for a power system provided by one embodiment of the present invention; Figure 2 This is a structural block diagram of a search enhancement generation device for a power system provided by one embodiment of the present invention; Figure 3 This is a structural block diagram of a terminal device provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0017] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this technical field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0018] The embodiment of the present invention provides a search enhancement generation method for a power system, see Figure 1 FIG. 1 is a flow chart of a search enhancement generation method for a power system provided by an embodiment of the present invention, the method comprising steps S11 to S15: Step S11: constructing a power knowledge graph based on the original corpus of the power system, and constructing a structural index and a semantic index based on the power knowledge graph; Step S12: Optimize the original query content input by the user to obtain professional query content; Step S13: performing neighbor sampling on the power knowledge graph according to the professional query content to obtain a query-related subgraph; Step S14: performing a hybrid search of semantics and graphs based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain a query retrieval result; Step S15: Enhance and generate the query retrieval results based on the attribution mechanism to obtain the user query answer.

[0019] Specifically, before actually performing retrieval enhancement generation, the embodiment of the present invention pre-constructs an electric power knowledge graph based on the original corpus of the electric power system (for example, original text data such as regulations and electric power data in the electric power system), and generates a structural index and a semantic index based on the electric power knowledge graph using a dual-channel architecture for use in subsequent retrieval enhancement generation; based on this, the implementation process of retrieval enhancement generation is as follows: First, obtain the original query content entered by the user. Usually, the original query content entered by the user is not an accurate keyword or professional term, and the query intention may not be clear. Therefore, the original query content entered by the user can be dynamically optimized and automatically completed. Or guide the user to complete the query input and obtain corresponding professional query content. For example, the original query content entered by the user is "overload". After dynamic query optimization processing, the professional query content obtained can be "overload protection action threshold"; then, according to the obtained professional query content, the pre-built power knowledge graph is sampled by neighbors to obtain the corresponding query-related subgraph; then, according to the obtained professional query content and query-related subgraph, combined with the pre-built structural index and semantic index, the professional query content is subjected to a hybrid semantic and graph retrieval to obtain the corresponding query retrieval results; finally, the obtained query retrieval results are enhanced and generated based on the attribution mechanism to obtain the final user query answer.

[0020] It should be noted that when obtaining the query-related subgraph (denoted as SubG), multi-hop expansion can be performed in the pre-constructed power knowledge graph based on the entities in the professional query content, so that graph neighbor sampling can be performed to obtain a subgraph for query expansion. Specifically, the query-related subgraph SubG is constructed by sampling its neighbor nodes from the power knowledge graph. Assuming that the maximum number of hops is k, the k-hop neighborhood is expanded by random walk. Then, the implementation process of neighbor sampling is as follows: (1) Starting from the target entity e0, sample its first-order neighbors N1(e0); (2) Recursively sample its i-th order neighbors , where i represents the number of hops, N i (e0) represents the set of i-order neighbor nodes of the target entity e0 (i.e., the collection of neighbor nodes that can be reached after i steps starting from the starting entity), N i-1 (e0) represents the i-1 order neighbor node set of the target entity e0, and v represents the node in N i-1 (e0) a node in the set; (3) Finally, the query-related subgraph is formed ,in, , the subscript q represents the query tag, V q Represents the node set of the query-related subgraph SubG, R qRepresents the edge set of the query-related subgraph SubG.

[0021] Furthermore, the number of neighbors sampled at each level can be limited during the sampling process to control the size of the subgraph. This sampling implementation scheme enriches the context of subsequent vector retrieval or generation models by introducing semantic nodes adjacent to the query entity structure. At the same time, it explicitly models the relationship path between entities, improving the logic of query expansion.

[0022] Exemplarily, the embodiments of the present invention can be applied to at least the following typical scenarios: electricity knowledge question and answer, fault diagnosis and decision support, dispatch instruction optimization, and intelligent customer service and training.

[0023] An embodiment of the present invention provides a retrieval enhancement generation method for a power system. By utilizing the structured relationship of the power knowledge graph and combining query optimization, hybrid retrieval, enhancement generation and attribution mechanism to perform retrieval enhancement generation, it can improve the credibility of the generated results while improving the retrieval efficiency, lowering the query threshold, and improving the interpretability of the generated results.

[0024] In one optional embodiment, constructing a power knowledge graph based on the original corpus of the power system specifically includes: Preprocess the original corpus of power system; Slice and vectorize the preprocessed original corpus, and store all the obtained vectors in the vector database; Based on the recursive invariant and large language model, cross-document entity relations are extracted from the preprocessed original corpus to obtain the power knowledge graph.

[0025] Specifically, in combination with the above embodiments, when constructing an electric power knowledge graph based on the original corpus of the electric power system, the original corpus of the electric power system can be preprocessed first, and then the preprocessed original corpus can be sliced ​​and vectorized, and all the obtained vectors can be stored in a vector database V. Afterwards, cross-document entity relationships can be extracted from the preprocessed original corpus based on recursive invariants and large language models to output a multi-granularity electric power knowledge graph.

[0026] It should be noted that the data sources in the power sector are complex and diverse, requiring multimodal preprocessing and unstructured text extraction. In the preprocessing stage, a domain-adapted NLP (Natural Language Processing) pipeline can be used to process power text data, including using OCR (Optical Character Recognition), regular expressions, and regular expressions for cleaning, and then slicing and vectorizing it and storing it in the vector database V.

[0027] The above preprocessing process can be formalized as follows: Let the original text set be , each text d i Divided into several segments , and then pass the encoding function Mapped to the vector space, all vectors are finally stored in the vector database V: ; where n is the number of texts, m i Is the text d i The number of slices, f(s ij ) is the fragment s ij The vector representation of .

[0028] Furthermore, in order to maintain semantic continuity, a sliding window strategy can be used. Each slice is allowed to overlap. Assuming the window length is l and the step size is s, the j-th slice is: .

[0029] Among them, the embedding method can use a pre-trained LLM (Large Language Model) as an encoder. Exemplarily, the embodiment of the present invention can choose to use the ChatGLM (Chat Generative Language Model) large model for embedding.

[0030] It should be noted that existing methods are often accompanied by the problem of low entity quality when constructing knowledge graphs. Therefore, an embodiment of the present invention extracts cross-document entity relationships based on recursive invariants and large language models. Specifically, the recursive invariant determines whether to continue the extraction based on two indicators. One is θ based on expert experience, and the other is whether it is within the scope of the ontology. The recursive invariant will first extract a batch of high-confidence entities based on the ontology concept using the large model prompting technology, and determine whether it exceeds θ. If it exceeds, the entity will be further screened. Otherwise, the confidence will be further relaxed to continuously increase the high-confidence entities.

[0031] For example, we first define basic ontology categories in the power field and classify the extracted entities into ontology categories to remove entities that are not related to power. In addition, to avoid semantic duplication of entities and excessive similar entities, we also define entity screening based on recursive invariant rules to ensure that high-quality entities are obtained. The process can be formalized as follows: ; Where E represents the extracted entities, and θ represents the acceptable number of entities in the power field (i.e., θ based on expert experience). Accordingly, if it does not exceed, that is, if |E| < θ is satisfied, the confidence level is further relaxed to continuously increase the entities with high confidence, which corresponds to Extract in the above formula. If it exceeds, the entities are filtered, which corresponds to RecursiveAttribute(E) in the above formula.

[0032] Subsequently, entity linking can be further performed based on the large model prompting technology. Its main purpose is to use the open knowledge of the large model to confirm whether the head and tail entities need to be connected. After the automatic extraction is completed, manual labeling can be further performed to confirm whether the entity concept is correct, thereby further improving the quality of the constructed power knowledge graph.

[0033] In one optional embodiment, constructing a structural index and a semantic index based on the power knowledge graph specifically includes: Using a graph neural network to extract structural information of the power knowledge graph and obtain a structural index; A large language model is used to extract entity semantic information of the power knowledge graph to obtain a semantic index.

[0034] Specifically, in combination with the above embodiment, when constructing a structural index based on the power knowledge graph, since the graph neural network can effectively capture the structural similarity between nodes in the graph topology and can transmit high-order collaborative information between nodes, the graph neural network can be used to model the structural information in the power knowledge graph, which can be formally expressed as: ; Among them, h struct represents structural embedding (i.e., structural index), GNN (Graph Neural Network) represents graph neural network, A represents the adjacency information between nodes, X represents the initial embedding of the node, which can be initialized using Gaussian distribution, and n represents the number of entities.

[0035] Specifically, in combination with the above embodiment, when constructing a semantic index based on the power knowledge graph, the open source pre-trained large language model ChatGLM can be used to extract the entity semantic information of the power knowledge graph, which can be formally expressed as: ; Among them, h sem Represents semantic embedding (i.e., semantic indexing), description represents the semantic information of the entity, and the semantic information can be input by the name of the entity.

[0036] In one optional embodiment, the query optimization of the original query content input by the user to obtain professional query content specifically includes: Determine the intent of the original query content entered by the user; If the intention of the original query content is unclear, a reverse prompt will be performed until the intention is clear, and the query content with clear intention will be used as the professional query content.

[0037] Specifically, in combination with the above embodiments, when optimizing the original query content input by the user, the original query content input by the user can be first subjected to intent judgment to determine whether the query intent corresponding to the original query content is clear. If the query intent corresponding to the original query content is unclear, a reverse prompt can be performed through self-reflection technology until the intent is clear, and the query content with clear intent can be used as professional query content.

[0038] It should be noted that since the original query content entered by the user is not always clear in intent or contains necessary element information, the application of few-sample prompt technology in the power field can be used. First, based on the large language model, the original query content can be judged by using the few-sample prompt technology. Specifically, a prompt template containing multiple examples can be constructed. The examples include query text, corresponding target intent and structured representation. After the original query content entered by the user is inserted into the prompt template, it is sent to ChatGLM for inference generation. This process enables the model to classify, complete, and disassemble fuzzy queries without the need for additional training. The example is as follows: Example 1: Original query content: What caused the power outage last night? Intent: troubleshooting; Time: last night; Missing parameter: device type.

[0039] Example 2: Original query content: Are there any optimization suggestions for energy saving and consumption reduction? Intent: Energy saving suggestions; Lack of parameters: None.

[0040] If the original query intent is determined to be unclear, a small number of sample prompts will be used to prompt the large language model to play a role in self-reflection technology to generate supplementary content, thereby providing reverse prompts. This process can be repeated until the original query intent is clear and the cycle is stopped.

[0041] In one optional embodiment, performing a hybrid search of semantics and graphs based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain query retrieval results specifically includes: Performing entity semantic retrieval based on the professional query content and the query-related subgraph, and performing similarity calculation in combination with the semantic index to obtain semantic similarity; Performing a graph structure search based on the professional query content and the query-related subgraph, and performing similarity calculation in combination with the structure index to obtain graph path similarity; The query retrieval result is obtained by performing weighted fusion based on the semantic similarity and the graph path similarity.

[0042] Specifically, in combination with the above embodiments, when performing a mixed retrieval of semantics and graphs based on professional query content, query-related subgraphs, structural indexes, and semantic indexes, entity semantic retrieval can be first performed based on the entities and query-related subgraphs in the professional query content, and similarity calculation can be performed in combination with the semantic index to obtain the corresponding semantic similarity, and graph structure retrieval can be performed based on the entities and query-related subgraphs in the professional query content, and similarity calculation can be performed in combination with the structural index to obtain the corresponding graph path similarity; thereafter, weighted fusion can be performed based on the obtained semantic similarity and graph path similarity to obtain the corresponding query retrieval results.

[0043] It should be noted that the embodiment of the present invention adopts a hybrid search strategy to score the retrieved content, and the entity semantic search and graph structure search in the hybrid search can respectively use the semantic index and structure index constructed in the above embodiment to perform similarity calculation. Specifically, there are two branches for the search enhanced by the power knowledge graph: One branch is to directly perform entity-level semantic retrieval based on the entities in the professional query content. The retrieval process is similar to sentence-level semantic retrieval and can be formalized as follows: ; Among them, e q Indicates querying entities in the relevant subgraph SubG, Represents entities in the power knowledge graph and uses h sem Perform similarity calculation ( That is to use h sem Initialization and similarity calculation are performed), cos() represents cosine similarity, TopK() represents selecting the K results with the highest similarity, C entity Represents the entity set retrieved by entity semantics, Represents semantic similarity ( Each value in the corresponding query entity and C entity The semantic similarity of each entity in ); Another branch is to use structure for retrieval, which can be formalized as follows: ; Among them, eq Indicates querying entities in the relevant subgraph SubG, Represents the structural embedding of entities in the power knowledge graph and uses h struct Perform similarity calculation ( That is to use h struct Initialization and similarity calculation are performed), cos() represents cosine similarity, TopK() represents selecting the K results with the highest similarity, M entity Represents the entity set retrieved by the graph structure, Represents graph path similarity ( Each value in the corresponding query entity and M entity Graph path similarity of each entity in ); Afterwards, the final entity ranking is obtained using weighted fusion calculation, where the weighted fusion calculation method of a semantic similarity and a graph path similarity can be formalized as: ; Among them, α represents the weight coefficient, which can generally be set to around 0.6.

[0044] In one optional embodiment, the query retrieval results are enhanced and generated based on the attribution mechanism to obtain the user query answer, specifically including: Perform sentence semantic retrieval based on the professional query content and the vector database to obtain semantic retrieval results; Acquire entity enhancement content based on the query retrieval results and the large language model; Obtaining retrieval information based on the semantic retrieval results and the entity-enhanced content, and inputting the professional query content and the retrieval information into a large language model to obtain generated content; Based on the extended attribution mechanism during testing, a dynamic attention fusion method is used to modify the generated content to obtain the user query answer, and a contribution weight is assigned to each retrieved document involved in the user query answer.

[0045] Specifically, in combination with the above embodiments, when query retrieval results are enhanced and generated based on the attribution mechanism, sentence semantic retrieval can be first performed based on the professional query content and the vector database V to obtain corresponding semantic retrieval results, and entity enhancement content can be obtained based on the query retrieval results and the large language model. Retrieval information is then obtained based on the obtained semantic retrieval results and entity enhancement content, and the professional query content and retrieval information are input into the large language model for processing, and the model outputs corresponding generated content; finally, based on the extended attribution mechanism during testing, the dynamic attention fusion method is used to correct the generated content output by the model, and the final generated content, i.e., the user query answer, is obtained. At the same time, the reference source is marked for the user query answer (i.e., the source of the retrieved document involved in the user query answer), and a contribution weight is assigned to each retrieved document involved in the user query answer, so as to be able to show the user the traceable source of the final generated content.

[0046] It should be noted that in order to obtain semantic retrieval results, it is necessary to obtain the semantic embedding of professional query content. This process can use the open source pre-trained large language model ChatGLM as an encoder, obtain its encoder q, and then perform sentence-level semantic retrieval. The original corpus retrieved from the vector database V through sentence-level semantic retrieval can be used as part of the result, which can be formalized as: ; Among them, A semantic Represents semantic retrieval results, cos() represents cosine similarity, and TopK() represents selecting the K results with the highest similarity.

[0047] It should be noted that in order to obtain entity-enhanced content, the query retrieval result score (entity) obtained in the above embodiment can be further processed by TopK to obtain the final candidate entities, and then these candidate entities and their connection relationships are spliced ​​into a string and input into the large language model ChatGLM as a prompt for processing to obtain the entity-enhanced content A. entity .

[0048] It should be noted that according to the semantic retrieval result A semantic and entity enhancement content A entity When obtaining the search information, you can use the formula y t =A semantic +A entity Calculate the retrieved information y t , then, professional query content and retrieval information y t The generated content is obtained by inputting it into the large language model ChatGLM for processing.

[0049] It should be noted that the embodiment of the present invention introduces an extended attribution mechanism during testing and adopts a dynamic attention fusion method. When generating each token of each retrieved document (i.e., the reference source document annotated for the user query answer), the contribution weight of each token can be calculated: ; in, Indicates the contribution weight of the final token, s t represents the hidden state of the t-th step of the generative model, For s t The transpose of W α represents the weight matrix in the attention mechanism, Represents the i-th retrieved document r i The semantic vector of (stored in the vector database V), Represents the jth retrieved document r j The semantic vector of (stored in the vector database V), and i represents the retrieval document currently being processed, j represents any retrieval document among the k retrieval documents, and k represents the number of retrieval documents; Afterwards, based on the contribution weight of each token of the retrieved document, the contribution weight of each retrieved document can be further summarized, so that the traceability source of the final generated content can be shown to the user.

[0050] It should be noted that the embodiment of the present invention is based on the extended attribution technology during testing, which can enhance the text quality and standard traceability quality of the answer generation content.

[0051] In one optional embodiment, before modifying the generated content, the method further includes: Obtaining a domain compliance score of the generated content according to the search information; The domain compliance score is compared with a preset threshold, and it is determined whether the generated content needs to be modified based on the comparison result.

[0052] Specifically, in combination with the above embodiment, before correcting the generated content output by the model, it is also necessary to obtain the domain compliance score of the generated content based on the retrieval information (used to evaluate the relevance / consistency between the generated content and the retrieval information), and compare the obtained domain compliance score with the preset threshold, so as to determine whether the generated content needs to be corrected based on the comparison result. Accordingly, if it is determined that the domain compliance score is less than the preset threshold, it is determined that the generated content needs to be corrected; otherwise, it is determined that the generated content does not need to be corrected.

[0053] It should be noted that when performing consistency verification between generated content and retrieved information, the domain compliance score of the generated content can be defined as: ; Among them, y t Indicates retrieval information, p gen and p retrieved denote the probability distribution of generated content and retrieved information respectively, represents the mutual information between the generated content and the retrieved information; accordingly, Indicates that the correlation between the generated content and the retrieved information is 0; further, assuming the preset threshold is ε, when When the test is completed, the correction mechanism is triggered, that is, the generated content will be corrected using the test-time extended attribution technology.

[0054] It should be noted that the core idea of ​​the correction mechanism is to rewrite the input in multiple ways while preserving the semantics of the input without changing the parameters of the large language model. During the rewriting process, the prompt "Wait, let's confirm the relevance of the content" is used to continuously input these rewritten versions into the large language model, thereby continuously correcting the model's output answer and obtaining the final output answer.

[0055] The embodiment of the present invention further provides a search enhancement generation device for a power system, which is used to implement the search enhancement generation method for a power system described in any of the above embodiments, see Figure 2 FIG. 1 is a block diagram of a search enhancement generation device for a power system according to an embodiment of the present invention, wherein the device includes: A graph and index construction module 11 is used to construct an electric power knowledge graph based on the original corpus of the electric power system, and to construct a structural index and a semantic index based on the electric power knowledge graph; The query optimization module 12 is used to optimize the original query content input by the user to obtain professional query content; A query subgraph acquisition module 13 is configured to perform neighbor sampling on the power knowledge graph according to the professional query content to obtain a query-related subgraph; A hybrid search module 14 is configured to perform a hybrid search of semantics and graphs based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain query search results; The search enhancement generation module 15 is used to enhance the query search results based on the attribution mechanism to obtain the user query answer.

[0056] Preferably, the graph and index building module 11 specifically includes: A raw corpus preprocessing unit, used for preprocessing raw corpus of the power system; The slicing and vectorization processing unit is used to slice and vectorize the preprocessed original corpus and store all the obtained vectors in the vector database; The electric power knowledge graph construction unit is used to extract cross-document entity relationships from the preprocessed original corpus based on recursive invariants and large language models to obtain the electric power knowledge graph.

[0057] Preferably, the graph and index building module 11 specifically includes: A structural index building unit, configured to extract structural information of the electric power knowledge graph using a graph neural network to obtain a structural index; The semantic index construction unit is used to extract entity semantic information of the power knowledge graph using a large language model to obtain a semantic index.

[0058] Preferably, the query optimization module 12 specifically includes: A query intent identification unit is used to identify the intent of the original query content input by the user; The query optimization unit is used to provide reverse prompts if the intention of the original query content is unclear until the intention is clear, and use the query content with clear intention as the professional query content.

[0059] Preferably, the hybrid search module 14 specifically includes: An entity semantic retrieval unit, configured to perform entity semantic retrieval based on the professional query content and the query-related subgraph, and perform similarity calculation in combination with the semantic index to obtain semantic similarity; A graph structure retrieval unit, configured to perform a graph structure retrieval based on the professional query content and the query-related subgraph, and perform similarity calculation in combination with the structure index to obtain graph path similarity; The retrieval result acquisition unit is used to perform weighted fusion based on the semantic similarity and the graph path similarity to obtain the query retrieval result.

[0060] Preferably, the search enhancement generation module 15 specifically includes: A sentence semantic retrieval unit, configured to perform sentence semantic retrieval based on the professional query content and the vector database to obtain semantic retrieval results; An enhanced content acquisition unit, configured to acquire entity enhanced content based on the query retrieval result and the large language model; A generated content acquisition unit is configured to obtain search information based on the semantic search results and the entity enhanced content, and input the professional query content and the search information into a large language model to obtain generated content; The retrieval enhancement generation unit is used to modify the generated content based on the test-time extended attribution mechanism, adopt a dynamic attention fusion method to obtain the user query answer, and assign a contribution weight to each retrieval document involved in the user query answer.

[0061] Preferably, before revising the generated content, the search enhancement generation module 15 further includes a content revision judgment unit configured to: Obtaining a domain compliance score of the generated content according to the search information; The domain compliance score is compared with a preset threshold, and it is determined whether the generated content needs to be modified based on the comparison result.

[0062] It should be noted that the retrieval enhancement generation device for an electric power system provided in an embodiment of the present invention can implement all the processes of the retrieval enhancement generation method for an electric power system described in any of the above embodiments. The functions of each module and unit in the device and the technical effects achieved are respectively the same as the functions and technical effects achieved by the retrieval enhancement generation method for an electric power system described in the above embodiments, and will not be repeated here.

[0063] An embodiment of the present invention further provides a computer-readable storage medium, comprising a stored computer program, which, when run, controls the device where the computer-readable storage medium is located to execute the retrieval enhancement generation method for the power system described in any of the above embodiments.

[0064] The embodiment of the present invention also provides a terminal device, see Figure 3 As shown, it is a structural block diagram of a terminal device provided by one embodiment of the present invention, wherein the terminal device includes a processor 10, a memory 20, and a computer program stored in the memory 20 and configured to be executed by the processor 10, and the processor 10 implements the retrieval enhancement generation method of the power system described in any of the above embodiments when executing the computer program.

[0065] Preferably, the computer program can be divided into one or more modules / units (e.g., computer program 1, computer program 2, ...). These one or more modules / units are stored in the memory 20 and executed by the processor 10 to implement the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program in the terminal device.

[0066] The processor 10 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor, or the processor 10 can also be any conventional processor. The processor 10 is the control center of the terminal device, and uses various interfaces and lines to connect various parts of the terminal device.

[0067] The memory 20 primarily includes a program storage area and a data storage area. The program storage area can store an operating system, at least one application required for a function, and the data storage area can store related data. Furthermore, the memory 20 can be a high-speed random access memory or a non-volatile memory, such as a plug-in hard drive, a Smart Media Card (SMC), a Secure Digital (SD) card, or a flash card. Alternatively, the memory 20 can be other volatile solid-state memory devices.

[0068] It should be noted that the above terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 3 The structural block diagram shown is only an example of the structure of the terminal device and does not constitute a structural limitation of the terminal device. The terminal device may include more or fewer components than shown in the figure, or a combination of certain components, or different components.

[0069] In summary, the embodiments of the present invention provide a method, apparatus, computer-readable storage medium, and terminal device for enhanced search and generation of power systems, which propose a three-level architecture of "search-guidance-generation". The core contents include: (1) Semi-automatic construction of power knowledge graph and semantic index construction: Based on the original corpus in the power system field, the multi-level relationships in the original corpus are semi-automatically extracted to construct a multi-level, high-precision power knowledge graph, and the domain language model and structure model are used to generate structural indexes and semantic indexes; (2) Dynamic query guidance optimization: Using interactive query expansion technology, automatic completion or guidance of user input, converting simple user queries (such as "overload") into professional queries (such as "overload protection action threshold"), achieving dynamic query optimization and improving retrieval accuracy; (3) Hybrid retrieval strategy: Combine nearest neighbor retrieval (based on semantic similarity) and graph structure retrieval (based on knowledge graph association paths) to perform hybrid retrieval. Simultaneously calculate semantic similarity and graph path similarity, and perform weighted fusion to ensure that the retrieval results are comprehensive and consistent with power logic. (4) Generation enhancement and explainability: Introduce an attribution mechanism to dynamically integrate retrieval information with the generated content output by the generative model, and mark the reference source to ensure that the results are traceable.

[0070] Furthermore, the embodiments of the present invention provide a method, apparatus, computer-readable storage medium, and terminal device for search enhancement generation in a power system, which have the following beneficial effects: (1) The embodiment of the present invention aims to improve the quality of entities when constructing knowledge graphs in the power field, and proposes a method for entity screening based on recursive invariant rules. Compared with the traditional method of directly using a large language model to extract entities using prompts, this method can further filter high-quality entities and reduce the extraction of irrelevant and duplicate entities; (2) The embodiment of the present invention aims to improve the quality of user queries and proposes a self-reflection-based reverse prompting technology that can handle both clear and unclear user intentions. Compared with traditional methods that directly treat user input as query input, this method can lower the query threshold, effectively improve input quality, and reduce model perplexity. (3) The embodiment of the present invention aims to improve the retrieval quality of local corpus and proposes a hybrid retrieval strategy. Compared with the traditional method that only considers semantic retrieval, the embodiment of the present invention further considers the association path of the semi-automatically constructed power knowledge graph, combines semantic retrieval and graph retrieval to perform hybrid retrieval, which can improve the retrieval efficiency and the reliability of the generated results; (4) The embodiment of the present invention aims to improve the quality of generated answers and proposes an extended attribution mechanism during testing. Compared with traditional methods, it can further stimulate the reasoning ability of large language models and improve the accuracy and interpretability of generated results.

[0071] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A search enhancement generation method for a power system, characterized in that: include: Constructing an electric power knowledge graph based on the original corpus of the electric power system, and constructing a structural index and a semantic index based on the electric power knowledge graph; Optimize the original query content entered by the user to obtain professional query content; Performing neighbor sampling on the electric power knowledge graph according to the professional query content to obtain a query-related subgraph; Performing a mixed search of semantics and graphs based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain a query retrieval result; The query retrieval results are enhanced and generated based on the attribution mechanism to obtain the user query answer.

2. The search enhancement generation method for the power system according to claim 1, characterized in that: The construction of the power knowledge graph based on the original corpus of the power system specifically includes: Preprocess the original corpus of power system; Slice and vectorize the preprocessed original corpus, and store all the obtained vectors in the vector database; Based on the recursive invariant and large language model, cross-document entity relations are extracted from the preprocessed original corpus to obtain the power knowledge graph.

3. The search enhancement generation method for the power system according to claim 1, characterized in that: The step of constructing a structural index and a semantic index based on the electric power knowledge graph specifically includes: Using a graph neural network to extract structural information of the power knowledge graph and obtain a structural index; A large language model is used to extract entity semantic information of the power knowledge graph to obtain a semantic index.

4. The search enhancement generation method for the power system according to claim 1, characterized in that: The query optimization of the original query content input by the user to obtain professional query content specifically includes: Determine the intent of the original query content entered by the user; If the intention of the original query content is unclear, a reverse prompt will be performed until the intention is clear, and the query content with clear intention will be used as the professional query content.

5. The search enhancement generation method for the power system according to claim 1, characterized in that: The hybrid search of semantics and graphs is performed based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain query search results, specifically including: Performing entity semantic retrieval based on the professional query content and the query-related subgraph, and performing similarity calculation in combination with the semantic index to obtain semantic similarity; Performing a graph structure search based on the professional query content and the query-related subgraph, and performing similarity calculation in combination with the structure index to obtain graph path similarity; The query retrieval result is obtained by performing weighted fusion based on the semantic similarity and the graph path similarity.

6. The search enhancement generation method for the power system according to claim 2, characterized in that: The query retrieval results are enhanced and generated based on the attribution mechanism to obtain the user query answer, specifically including: Perform sentence semantic retrieval based on the professional query content and the vector database to obtain semantic retrieval results; Acquire entity enhancement content based on the query retrieval results and the large language model; Obtaining retrieval information based on the semantic retrieval results and the entity-enhanced content, and inputting the professional query content and the retrieval information into a large language model to obtain generated content; Based on the extended attribution mechanism during testing, a dynamic attention fusion method is used to modify the generated content to obtain the user query answer, and a contribution weight is assigned to each retrieved document involved in the user query answer.

7. The search enhancement generation method for the power system according to claim 6, characterized in that: Before modifying the generated content, it also includes: Obtaining a domain compliance score of the generated content according to the search information; The domain compliance score is compared with a preset threshold, and it is determined whether the generated content needs to be modified based on the comparison result.

8. A search enhancement generation device for a power system, characterized in that: include: A graph and index construction module is used to construct an electric power knowledge graph based on the original corpus of the electric power system, and to construct a structural index and a semantic index based on the electric power knowledge graph; The query optimization module is used to optimize the original query content entered by the user to obtain professional query content; A query subgraph acquisition module is used to perform neighbor sampling on the power knowledge graph according to the professional query content to obtain a query-related subgraph; A hybrid retrieval module, configured to perform a hybrid semantic and graph retrieval based on the professional query content, the query-related subgraph, the structural index, and the semantic index to obtain a query retrieval result; The retrieval enhancement generation module is used to enhance the query retrieval results based on the attribution mechanism to obtain the user query answer.

9. A computer-readable storage medium, characterized in that The invention comprises a stored computer program, which controls the device where the computer-readable storage medium is located to execute the search enhancement generation method for the power system according to any one of claims 1 to 7 when the computer program is run.

10. A terminal device, characterized in that: The system comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the search enhancement generation method for the power system according to any one of claims 1 to 7 when executing the computer program.

Citation Information

Patent Citations

  • Lightweight incremental question answering system based on graph structure index and double-layer retrieval

    CN120316214A

  • Question and answer method for graph-driven fusion retrieval in field of computer networks

    CN120336477A

Cited By

  • Power equipment information retrieval method and system

    CN120994704A

  • AI intelligent hardware matching APP customer service fault guiding type RAG interaction method, system and device and medium

    CN121032511A

  • An AI intelligent hardware matching APP customer service fault guidance type RAG interaction method, system, device and medium

    CN121032511B

  • Power knowledge base question answering method and system based on improved RAG

    CN121597792A