Retrieval method and device based on power regulation document
By constructing a standard terminology set to rewrite user queries and performing multi-dimensional similarity fusion matching, the problem of terminology mismatch in power regulation document retrieval was solved, improving the accuracy and security of retrieval and ensuring the professionalism and reliability of power operations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2026-03-13
AI Technical Summary
Existing methods for retrieving power regulations documents based on large language models cannot accurately match professional terms in the power field, leading to incorrect search results for users and potentially causing power safety accidents.
By constructing a set of standard terms, user queries are rewritten in a standardized manner to generate question text composed of multiple standard terms. This text is then matched with slices of power regulations documents using multi-dimensional similarity fusion. The most relevant regulations clauses are selected as the search results, and finally, the results are combined with a large language model to generate answers.
It significantly improves the accuracy and robustness of the recall of procedural clauses, ensures the professionalism and security of the generated target slices, and provides reliable technical support for intelligent question answering in the power industry.
Smart Images

Figure CN121658619A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data query technology, and in particular to a retrieval method, a retrieval device, a computer device, a computer-readable storage medium, and a computer program product based on power regulations documents. Background Technology
[0002] Large Language Models (LLMs) are deep learning-based artificial intelligence models that learn and master the statistical patterns, syntactic structures, and semantic knowledge of human language by being trained on extremely large-scale text datasets. This enables them to understand, generate, and process natural language. Retrieval-Augmented Generation (RAG) is a paradigm for improving the quality of content generated by Large Language Models. It uses a retrieval tool to retrieve the most relevant information fragments to a query in real time from a specified knowledge base. This information is then combined with the Large Language Model's internal parameterized knowledge as additional context and fed into the generator, ultimately producing information-rich, accurate, and citationable text.
[0003] Currently, question answering based on large language models and retrieval-enhanced generation mainly consists of two stages. Stage 1: Building a knowledge base. Relevant documents are collected and segmented into multiple text blocks according to the input length limit of the large language model. Each text block is then converted into vector form. An index is then created for these vector text blocks to form the knowledge base. Stage 2: Processing queries. For user-submitted questions, they are first converted into vectors. The vectorized questions are then matched with vectors in the knowledge base. The text blocks corresponding to the vectors with the highest similarity are selected and combined with the question to form an enhanced prompt input to the large language model. Based on its own understanding capabilities, the large language model outputs accurate, fluent, and logically sound final target slices.
[0004] However, power industry regulations and documents, as elements in knowledge base construction, differ from general text. Each clause in these documents contains specialized, mandatory technical instructions. When matching based on question vectors, similar text blocks may not be the correct target slice for the question. Users performing power-related operations using incorrect target slices could lead to power safety accidents. Therefore, providing a method for correctly querying questions based on power industry regulations is crucial for improving the safety of power operations. Summary of the Invention
[0005] The purpose of this application is to provide a method, device, computer equipment, computer-readable storage medium, and computer program product for retrieving power regulations documents, so as to improve the accuracy of power regulations document retrieval.
[0006] To address the aforementioned technical problems, this application provides the following technical solutions: The first aspect of this application provides a retrieval method based on power regulations documents. The method includes: obtaining input question text from a large language model; segmenting the question text into multiple question words; obtaining the standard terms involved in each question word in a knowledge graph, wherein the knowledge graph includes a standard-synonym set, a standard-abbreviation set, and a standard-hypernym / hypernym set, and the relationships between them. The standard-synonym set stores various power standard terms and their corresponding synonyms; the standard-abbreviation set stores various power standard terms and their corresponding abbreviations; and the hypernym / hypernym set stores various power standard terms and their corresponding hypernyms / hypernyms. The method further includes retrieving the relevant standard terms from a knowledge graph. The question segments corresponding to standard terms are combined with the standard terms corresponding to the question segments in the question text according to the order of the question segments in the question text to obtain multiple question texts. The similarity matching of the vector of each question text with the vector of each slice of the power regulations document is used to obtain the similarity of each slice with each question text. The similarity of each question text is aggregated to obtain the comprehensive similarity of each slice. Each slice is obtained by segmenting based on the clauses in the power regulations document. Based on the comprehensive similarity, a preset number of slices are selected as target slices of the question text, and the target slices and question texts are used as input to the large language model again.
[0007] Compared to existing technologies, the retrieval method based on power regulations documents provided in the first aspect of this application effectively solves the problem of terminology mismatch in the power field by standardizing and rewriting user queries through the construction of a standard terminology set. Through the generation and fusion retrieval of multiple versions of query text, the accuracy and robustness of regulation clause recall are significantly improved. Finally, the precise recall of segments is combined with a large language model to ensure the professionalism and security of the generated target segments, providing reliable technical support for intelligent question answering in the power industry.
[0008] In other embodiments provided in this application, before performing similarity matching between the vector of each query text and the vector of each slice of the power regulation document, the method further includes: determining a portion of the slices among all slices of the power regulation document, and determining the portion of the slices as multiple slice samples, wherein the portion of the slices is obtained based on sampling from all slices; calculating the average cosine similarity between the vector of each query text and the vector of each slice sample to obtain the average cosine similarity of each query text; selecting a specified number of query texts as target texts in descending order of average cosine similarity; and performing similarity matching between the vector of each query text and the vector of each slice of the power regulation document, including: performing similarity matching between the vector of each target text and the vector of each slice of the power regulation document.
[0009] By introducing a pre-screening mechanism based on slice samples, only a few rewritten versions with the highest semantic relevance to the procedure document are selected for full retrieval, effectively filtering out low-quality or redundant rewritten texts. While ensuring core semantic coverage, the computational load is significantly reduced, improving retrieval efficiency and the real-time response of the system.
[0010] In other embodiments provided in this application, similarity matching is performed between the vector of each query text and the vector of each slice of the power regulations document to obtain the similarity of each slice relative to each query text. This includes: calculating the semantic similarity between the vector of each query text and the vector of each slice of the power regulations document to obtain the semantic similarity of each slice relative to each query text; calculating the similarity between the vector of the structural label of each query text and the vector of the hierarchical label of each slice of the power regulations document to obtain the label similarity of each slice relative to each query text; determining the weight of each slice, wherein the weight is positively correlated with the importance and hierarchical depth of the slice; and performing a weighted calculation based on the semantic similarity of each slice relative to each query text, the label similarity of each slice relative to each query text, and the weight of each slice to obtain the similarity of each slice relative to each query text.
[0011] By integrating semantic similarity, hierarchical tag similarity, and slice weight for multi-dimensional comprehensive evaluation, this approach not only considers the semantic relevance of text content but also takes into account the unique hierarchical structure information and clause importance of the regulations, thereby achieving more accurate semantic matching and priority ranking that better conforms to the characteristics of power regulations, significantly improving the professionalism and accuracy of the search results.
[0012] In other embodiments provided in this application, the similarity of each question text is aggregated to obtain the comprehensive similarity of each slice, including: for each slice, selecting the highest similarity from the similarity of each corresponding question text, and calculating the average similarity of each question text; weighting the highest similarity and the average similarity to obtain the comprehensive similarity of each slice.
[0013] By comprehensively considering the highest matching degree of a single rewritten version and the average matching degree of all versions, the guiding role of optimal semantic alignment is fully utilized, and the collective wisdom of multiple rewritten versions is effectively leveraged. This enhances the robustness and anti-interference ability of the system while improving the relevance of search results.
[0014] In other embodiments provided in this application, a preset number of slices are selected as target slices of the problem text based on the comprehensive similarity, including: calculating the average and standard deviation of the comprehensive similarity of all slices; weighting the average and standard deviation to obtain an adaptive threshold; and selecting slices with comprehensive similarity greater than or equal to the adaptive threshold as target slices of the problem text.
[0015] By using a dynamic threshold based on the comprehensive similarity distribution to filter target slices instead of a fixed preset number, the system can adaptively adjust the recall range according to the actual quality of each search result, effectively balancing recall and precision, and avoiding the inclusion of irrelevant content or the omission of key terms.
[0016] In other embodiments provided in this application, before obtaining the input question text from the large language model, the method further includes: scanning the power regulation document line by line based on a predefined set of regular expressions, wherein the set of regular expressions is used to represent the hierarchical tags in the power regulation document; obtaining the hierarchical tags of each scanned line of content, and determining whether the depth of the hierarchical tags of the current line of content is less than the depth of the hierarchical tags of the previous line of content; if so, closing the current line of content and the unclosed line of content before it, and establishing a correspondence between the currently closed content and the hierarchical tags of the current line of content; if not, continuing to scan and determining whether the depth of the hierarchical tags of the next line of content is less than the depth of the hierarchical tags of the current line of content; determining each closed content and its corresponding hierarchical tag as a slice, and determining all slices as slices of the power regulation document.
[0017] By identifying the document's hierarchical structure based on regular expressions and dynamically closing slices according to changes in hierarchical depth, the independence of each semantic unit (such as a complete clause) and the complete preservation of structural information are ensured. This effectively avoids the semantic fragmentation problem caused by traditional fixed-length slices, laying a high-quality document foundation for subsequent accurate retrieval.
[0018] A second aspect of this application provides a retrieval device based on power regulations documents. The device includes: an acquisition module for acquiring input question text from a large language model; a word segmentation module for segmenting the question text to obtain multiple question words; a conversion module for acquiring the standard terms corresponding to each question word in a standard-synonym set, a standard-abbreviation set, and a standard-hypernym set, wherein the standard-synonym set stores various power standard terms and their corresponding synonyms, the standard-abbreviation set stores various power standard terms and their corresponding abbreviations, and the hypernym set stores various power standard terms and their corresponding hypernyms; and a combination module for combining terms without corresponding symbols. The quasi-term question segmentation and the corresponding standard terms are combined according to the order of the question segmentation words in the question text to obtain multiple question texts. The matching module is used to perform similarity matching between the vector of each question text and the vector of each slice of the power regulations document to obtain the similarity of each slice to each question text. The similarity of each question text is aggregated to obtain the comprehensive similarity of each slice. Each slice is obtained by segmenting based on the clauses in the power regulations document. The output module is used to select a preset number of slices as target slices of the question text based on the comprehensive similarity, and then use the target slices and question texts as input to the large language model again.
[0019] A third aspect of this application provides a computer device including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method of the first aspect.
[0020] The fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method of the first aspect.
[0021] The fifth aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the method of the first aspect.
[0022] The retrieval device based on power regulations documents provided in the second aspect of this application, the computer equipment provided in the third aspect, the computer-readable storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect have the same or similar beneficial effects as the retrieval method based on power regulations documents provided in the first aspect. Attached Figure Description
[0023] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, with the same or corresponding reference numerals denoteing the same or corresponding parts, wherein: Figure 1 This is a schematic diagram illustrating an application scenario of the retrieval method based on power regulations documents in this application embodiment; Figure 2 This is a flowchart illustrating the retrieval method based on power regulations documents in this application. Figure 1 ; Figure 3 This is a flowchart illustrating the retrieval method based on power regulations documents in this application. Figure 2 ; Figure 4 This is a schematic diagram of the structure of the retrieval device based on power regulations documents in the embodiments of this application. Figure 1 ; Figure 5 This is a schematic diagram of the structure of the retrieval device based on power regulations documents in the embodiments of this application. Figure 2 ; Figure 6 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0024] Exemplary embodiments of this application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.
[0025] It should be noted that, unless otherwise stated, the technical or scientific terms used in this application shall have the ordinary meaning as understood by one of ordinary skill in the art to which this application pertains.
[0026] Currently, there are three main problems with searching based on power regulations documents: First, the general text slicing method destroys the semantic integrity of power regulations clauses. Second, there is a serious semantic gap between users' colloquial queries and the standard terminology of the regulations. Third, traditional vector retrieval is not precise enough to meet the stringent accuracy requirements of power safety operations.
[0027] In view of this, embodiments of this application provide a retrieval method, a retrieval device, a computer device, a computer-readable storage medium, and a computer program product based on power regulations documents. This method involves constructing a dictionary of standard power terminology to rewrite user queries using multi-version semantic standardization, generating query text composed of multiple standard terms. Then, it performs multi-dimensional similarity fusion matching between these multiple query texts and regulation document slices segmented based on semantic integrity, selecting the most relevant regulation clauses as the retrieval results. Finally, it combines the accurate retrieval results with a large language model to generate reliable target slices, thereby solving the problem of insufficient retrieval accuracy caused by terminology mismatch and semantic fragmentation in the power field.
[0028] It should be noted that all components, data, and related processing methods involved in this application are authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0029] First, the application scenarios of the power regulation document retrieval method provided in the embodiments of this application will be described.
[0030] Figure 1 This is a schematic diagram illustrating the application scenario of the power regulation document retrieval method in this application embodiment. See [link / reference]. Figure 1 As shown, the scenario may include: System 11 (the execution entity in this application embodiment).
[0031] System 11 includes a large language model 111 and a knowledge base 112.
[0032] When a user needs to ask a question through the large language model 111, after the user inputs the question into the system 11, the system 11 first performs word segmentation and terminology standardization on the question, generating multiple standardized question texts. Then, the system 11 performs multi-dimensional similarity matching between these question texts and semantically segmented procedural documents in the knowledge base 112, filtering out the most relevant procedural clauses. The system 11 inputs the precisely retrieved clauses along with the original question into the large language model 111. The output of the large language model 111 is the answer to the question. Finally, the system 11 provides the answer to the user.
[0033] Next, the retrieval method based on power regulations documents provided in the embodiments of this application will be described in detail.
[0034] Figure 2 This is a flowchart illustrating the retrieval method based on power regulations documents in this application. Figure 1 See Figure 2 As shown, the method may include: S21: Obtain the input question text from the large language model.
[0035] Question text refers to the queries submitted by users to the large language model, expressed in natural language. These queries typically take the form of questions or instructions and express the user's specific information needs within power regulations documents. Examples include: "What should be checked first after a main transformer trips?" and "What precautions should be taken when inspecting a substation in rainy weather?"
[0036] After a user inputs question text into a large language model, in order to prevent the large language model from processing the question text directly, the question text needs to be intercepted before the large language model processes it.
[0037] In a system integrated with RAG, the LLM is not directly user-facing. The entire process is controlled by a RAG system or middleware. This system acts as the "scheduling center" between the user and the LLM. Therefore, the system architecture is designed to process the question text before the large language model. That is, the system is configured to receive the question text, perform rewriting and querying, and then send the query results and the question text to the large language model.
[0038] S22: Perform word segmentation on the question text to obtain multiple question segments.
[0039] The goal of word segmentation for question text is to break down continuous natural language sentences into the smallest semantically independent linguistic units (words or sub-words). First, emoticons, special markers, and extra spaces are filtered out from the question text, and full-width characters (such as Chinese punctuation) are converted to half-width characters, with consistent capitalization. Then, mature Chinese word segmentation tools (such as Jieba, HanLP, and LTP) can be used for basic text segmentation. During segmentation, a prepared dictionary of standard power terminology (containing terms like "main transformer," "circuit breaker," and "protection action") can be loaded into the word segmenter. The word segmenter is then guided to prioritize matching against a domain-specific dictionary, ensuring that specialized terms are recognized as complete word units.
[0040] For example, suppose the question text is: "After the main transformer switch trips, how do I interpret the protection signal?". First, the question text is already relatively standardized and requires no special cleanup. Then, using a basic word segmenter (without a domain dictionary loaded), it might obtain: main, transformer, switch, trip, after, , protection, signal, how, interpret, ?. Then, loading a power dictionary (containing: main transformer, switch, trip, protection signal), the word segmenter uses the dictionary to re-identify and segment, obtaining multiple question words: main transformer, switch, trip, after, , protection signal, how, interpret.
[0041] S23: Obtain the standard terms involved in each question segment in the knowledge graph. The knowledge graph includes a standard-synonym set, a standard-abbreviation set, and a standard-hypernym set, as well as the relationships between them. The standard-synonym set stores various power standard terms and their corresponding synonyms. The standard-abbreviation set stores various power standard terms and their corresponding abbreviations. The hypernym set stores various power standard terms and their corresponding hypernyms.
[0042] The standard-synonym set stores the mapping relationships between standard electrical terms and words that have the same semantics but different expressions. For example: the standard term circuit breaker is a synonym for switch or switching equipment; the standard term main transformer is a synonym for main transformer, and so on.
[0043] The standard-abbreviation set stores the mapping relationship between electrical standard terms and their abbreviations or codes. For example: standard term circuit breaker - abbreviation CB, standard term voltage transformer - abbreviation VT, etc.
[0044] The standard-hypernym set stores the mapping relationships between electrical standard terms and their hypernyms (more general) and hyponyms (more specific). For example: standard term transformer - hypernym power equipment - hyponyms oil-immersed transformer, dry-type transformer; standard term circuit breaker - hyponyms SF6 circuit breaker, vacuum circuit breaker, etc.
[0045] These three sets do not exist in isolation; together they constitute a structured knowledge graph of electrical engineering terminology. In the graph structure, nodes represent all standard terms, synonyms, abbreviations, and hypernyms / hypernyms. Edges represent relationships between nodes, and the relationship type is explicitly labeled as synonym, abbreviation, hypernym, or hyponym.
[0046] Searching for the corresponding words in a knowledge graph for a given segment is essentially a graph traversal process. The goal is not merely to find a directly corresponding word, but to identify all relevant standard terms connected to this segment through multiple relationships, providing material for generating multiple rewritten versions.
[0047] During the search, for each question segment, the question segment is used as the starting node. A set of visited nodes is created (to avoid circular searches) and a result set (to store all found standard terms). A search queue is created, and the starting node is added to the queue and the visited set. Then, graph traversal begins. The following steps are performed repeatedly until the search queue is empty. A node is removed from the queue and designated as the current node. All edges originating from the current node in the knowledge graph are examined (synonym relations, abbreviation / full name relations (bidirectional search), hyponym relations (bidirectional search)). Each relation is traversed to find the associated node at the other end of the relation. If the associated node has not been visited, it is added to the visited set and the search queue so that the search can continue from it. If the associated node is marked as a standard term, it is added to the result set. When the search queue is empty, the traversal ends. The result set is returned, which contains all standard terms and related words connected to the starting question segment through various paths.
[0048] S24: Combine the question segments without corresponding standard terms with the standard terms corresponding to the question segments with corresponding standard terms according to the order of the question segments in the question text to obtain multiple question texts.
[0049] Not all words in the query need or can find corresponding standard terms in the power terminology knowledge graph. For example: general words describing actions such as "check", "view", "how to handle", "record", "report", etc. do not belong to entity terms. Another example: words providing context such as "status", "reason", "step", "today", "site", etc. that do not involve specific power equipment or operations. Another example: function words such as prepositions and conjunctions like "of", "in", "after", "and", etc. Another example: a very specific station name, model number, or slang that has not been entered into the knowledge graph. None of these words have corresponding standard terms in the knowledge graph.
[0050] When specifically combining standard terms or problem word segments, for each problem word segment, construct its candidate word set. For a problem word segment with a standard term, its candidate word set is the problem word segment and the standard term. For a problem word segment without a standard term, its candidate word set is the problem word segment. Then, sequentially select one word from the candidate word set of each problem word segment. The selected words are combined in the order of the corresponding problem word segments in the problem text to obtain multiple query texts.
[0051] For example, assume the problem text is: Check the protection signal after the main transformer switch trips. The problem word segments and their corresponding standard terms are as follows: Check, without a standard term, that is: Check.
[0052] Main transformer, has a standard term. That is: Main transformer, Main power transformer.
[0053] Switch, has a standard term. That is: Switch, Circuit breaker, CB.
[0054] Trip, has a standard term. That is: Trip, Protection action.
[0055] After, without a standard term. That is: After.
[0056] Protection signal, has a standard term. That is: Protection signal, Protection action information.
[0057] For each problem word segment, after selecting one word from the candidate word set and splicing them, the following combinations are obtained, and then multiple query texts are obtained.
[0058] Combination 1: Check + Main transformer + Switch + Trip + After + Protection signal.
[0059] Query text 1: Check the protection signal after the main transformer switch trips.
[0060] Combination 2: Check + Main power transformer + Circuit breaker + Protection action + After + Protection action information.
[0061] Query text 2: Check the protection action information after the main power transformer circuit breaker's protection action.
[0062] Combination 3: Check + Main Transformer + CB + Trip + After + Protection Action Information.
[0063] Question text 3: Check the protection action information after the main transformer CB trips.
[0064] Combination 4: Check + Main Transformer + Switch + Protection Action + After + Protection Signal.
[0065] Question 4: Check the protection signal after the main transformer switch protection operates.
[0066] S25: Perform similarity matching between the vector of each question text and the vector of each slice of the power regulations document to obtain the similarity of each slice relative to each question text. Then, aggregate the similarity of each question text to obtain the comprehensive similarity of each slice. Each slice is obtained by segmenting based on the clauses in the power regulations document.
[0067] Electricity regulations and documents refer to standardized documents with mandatory and guiding nature developed by the power industry to regulate production activities such as equipment operation, maintenance, and safety management. Examples include: "Substation Operation Regulations," "Electricity Safety Work Regulations," "Transformer Operation and Maintenance Details," and "Dispatch Operation Manual," etc.
[0068] The slices here are not simple blocks of text of equal length, but rather the smallest independent units of clauses segmented based on semantic and structural integrity. Each slice contains two parts: the body content (the specific descriptive text of the clause) and a hierarchy label (describing the clause's position in the document structure).
[0069] For example, suppose the contents of the "Substation Operation Regulations" document are as follows: Chapter 3 Equipment Troubleshooting 3.1 Transformer Failure a) After the main transformer trips, the protection action signal should be checked immediately and the fault waveform recorded.
[0070] b) If the fault is determined to be internal, the transformer should be isolated and the dispatch center should be notified.
[0071] c) ... 3.2 Circuit breaker fault a) When a circuit breaker fails to operate, the operating power supply and control circuit should be checked.
[0072] b) ... After semantically preserving slicing, the following slices will be generated: Slice C1: Text T1: After the main transformer trips, the protection action signal should be checked immediately and the fault waveform recorded.
[0073] Hierarchical label L1: Chapter 3 Equipment Fault Handling, 3.1 Transformer Fault, a.
[0074] Slice C2: Text T2: If the fault is determined to be internal, the transformer should be isolated and the dispatching department should be notified.
[0075] Hierarchical label L2: Chapter 3 Equipment Fault Handling, 3.1 Transformer Fault, b.
[0076] Slice C3: Text T3: When a circuit breaker fails to operate, the operating power supply and control circuit should be checked.
[0077] Hierarchical label L3: Chapter 3 Equipment Fault Handling, 3.2 Circuit Breaker Faults, a.
[0078] When determining the final slice based on the question text, each question text and the main text of each procedure slice are converted into semantic vectors using the same text encoder. The similarity between each question text vector and each slice vector is calculated, resulting in a similarity matrix. This similarity calculation can be single-dimensional or multi-dimensional. These dimensions can include semantic similarity, tag similarity, metadata weights, etc. Then, for a slice, there will be multiple similarities relative to multiple question texts. These similarities are aggregated into a comprehensive similarity. All slices are sorted in descending order based on the comprehensive similarity. Finally, the final slice is selected directly or indirectly, either by a preset number. Indirect selection can refer to scenarios where the slice selection threshold automatically changes based on actual conditions. For example, real-time user configuration or calculation based on the comprehensive similarity of each slice.
[0079] S26: Based on comprehensive similarity, select a preset number of slices as target slices of the question text, and use the target slices and the question text as input to the large language model again.
[0080] The process of using the target slice and question text as input to a large language model is achieved by constructing structured cue words. Specifically, predefined cue word templates are used to integrate the target slice and the original question into a structured text, which then serves as the input to the large language model.
[0081] For example, suppose the problem text is: After the main transformer circuit breaker trips, how should the protection signals be interpreted? The target slices include: Slice 1: After the main transformer circuit breaker trips, the protection device's action signals should be checked immediately, and the fault waveform recorded (Chapter 3 Fault Handling, 3.1 Transformer Faults, a); Slice 2: Maintenance personnel should be proficient in the meaning of protection device signals and be able to preliminarily determine the fault type based on the signals (Chapter 2 Basic Requirements, 2.4 Personnel Skills, b). The input to the large language model is as follows: You are a professional power system expert assistant. Please answer user questions strictly according to the following excerpt from the "Substation Operation Procedures". If the provided excerpt does not contain the information required for the answer, please clearly state "This question cannot be answered according to the existing procedures," and do not fabricate answers.
[0082] [Relevant Procedures and Clauses]: 1. [Source: Chapter 3 Troubleshooting / 3.1 Transformer Faults / a] After the main transformer circuit breaker trips, the operation signal of the protection device should be checked immediately, and the fault waveform should be recorded.
[0083] 2. [Source: Chapter 2 Basic Requirements / 2.4 Personnel Skills / b] Maintenance personnel should be familiar with the meaning of protection device signals and be able to make a preliminary judgment on the fault type based on the signals.
[0084] [User Issues]: How do you interpret the protection signals after the main transformer switch trips? Please begin your answer: The above content can then be used as input to the large language model. The output of the large language model is the most accurate answer to the question text.
[0085] As described above, the retrieval method based on power regulations documents provided in this application effectively solves the problem of terminology mismatch in the power field by standardizing and rewriting user queries through the construction of a standard terminology set. The generation and fusion retrieval of multiple versions of question text significantly improves the accuracy and robustness of regulation clause recall. Finally, combining the precisely recalled segments with a large language model ensures the professionalism and security of the generated target segments, providing reliable technical support for intelligent question answering in the power industry.
[0086] Furthermore, as a response to Figure 2 In a refinement and extension of the method shown, this application embodiment also provides a retrieval method based on power regulations documents.
[0087] Figure 3 This is a flowchart illustrating the retrieval method based on power regulations documents in this application. Figure 2 See Figure 3 As shown, the method may include: S31: Construct power regulation document slices and construct a knowledge graph.
[0088] When constructing power regulation document slices, the slices are divided according to the inherent hierarchical structure and logical semantic boundaries of the document itself to ensure that each generated slice corresponds to a complete and independent minimum semantic unit (such as a complete clause or step) and retains its precise location information in the original document.
[0089] Specifically, step S31 above may include: Step A1: Scan the power regulations document line by line based on a predefined set of regular expressions, where the set of regular expressions is used to represent the hierarchical tags in the power regulations document.
[0090] The regular expression set is a set of pattern rules used to identify and match structural identifiers in electrical regulations documents.
[0091] The system uses predefined regular expressions to match the beginning of each line, identifying chapter numbers, bullet points, and other elements, and assigning them corresponding hierarchical labels. By systematically traversing each line of the document and identifying all structural elements, it provides the foundational data for subsequent hierarchical analysis and slice generation.
[0092] Step A2: Obtain the hierarchy tags of each scanned line of content and determine whether the depth of the hierarchy tags of the current line of content is less than the depth of the hierarchy tags of the previous line of content. If yes, proceed to step A3; otherwise, proceed to step A4.
[0093] Hierarchical tags are used to identify the position of a piece of content within the overall structure of a document.
[0094] Tag depth indicates the nesting level of hierarchical tags in the document's tree structure, and is usually determined by numbering or indentation level.
[0095] By comparing the tag depth of the current line with the previous line, it determines whether the structure is developing into a deeper level, retreating to a higher level, or moving to the same level. This is a key signal for detecting changes in the document's structural hierarchy and determining whether the current slice needs to be closed.
[0096] Step A3: Close the current line content and the unclosed line content before it, and establish the correspondence between the currently closed content and the hierarchical tags of the current line content.
[0097] Closure refers to identifying the currently accumulated unclosed line content as a complete semantic unit (slice) and assigning it a complete hierarchical path label.
[0098] Combine the previously accumulated unclosed line content into a complete slice and label it with a complete hierarchical path. When a hierarchical backtracking is detected, immediately save the current semantic unit to ensure that each slice ends at the correct structural boundary.
[0099] Step A4: Continue scanning and determine whether the depth of the hierarchical label of the next line content is less than the depth of the hierarchical label of the current line content.
[0100] Add the current line content to the unclosed content buffer and continue scanning the next line. When the hierarchy remains or develops to a deeper level, continue to collect the content belonging to the same semantic unit.
[0101] Step A5: Determine each closed content and its corresponding hierarchical label as a slice, and determine all the slices as the respective slices of the electrical code document.
[0102] This is to formally determine all the closed content as the final document slices, forming a set of structured knowledge units.
[0103] In practical applications, the above Steps A1 - A5 can be: Step B1: Document preprocessing.
[0104] Given a set of regulation documents: .
[0105] Perform line-level and paragraph-level normalization on the documents, and unify the formats of Chinese serial numbers (one, two), Roman serial numbers (I, II), bullet points (•), etc.
[0106] Step B2: Define and identify structural labels.
[0107] Define a regular set R: r H : Section number, = {^\d+(\.\d+)*}, identify digital sequences such as 1, 1.1, 1.1.1, etc.
[0108] r P : Bullet point, = {^[a - z]}, identify bullet points starting with lowercase letters such as a), b), c), etc.
[0109] r T : Project content, = the first sentence after the section number to the line break, match the first sentence content after the section number.
[0110] Scan each line of text x in the document. If it matches the above regular expressions, label it with the corresponding structural label H n 、P k or T m . That is: Step B3: Dynamically maintain the hierarchical path stack.
[0111] Create an empty chapter level stack HS. When a new chapter number H is encountered... n If its depth n is greater than the current stack depth |HS|, then push it onto the top of the stack (to a deeper level). If its depth n is less than or equal to the current stack depth, pop the top element until the stack depth is n-1, and then push H... n Push in (revert to a higher or same level). That is: For each line processed, the current stack HS is recorded and used as the context path ctx(x) for that line's content. That is: ctx(x) = ⟨H1,H2,…,H n >=HS Step B4: Slice generation based on semantic boundaries.
[0112] When the beginning of a line matches the bullet point r P A new slice begins when the context path ctx(x) of the current line differs from that of the previous line. If the next line is in the same context path (i.e., at the same level) as the current line, they are merged and treated as the contents of the same slice. The current slice closes when a new chapter number H is encountered. n' And its depth n' is less than or equal to the depth n of the current level (meaning chapter back or jump). Or, encounter a blank line.
[0113] Each closed slice is defined as a tuple C. i = (T i , L i ). Among them, T i It is the merged main text, L i It is its hierarchical path label.
[0114] When constructing a knowledge graph, discrete terms in the power industry with different expressions are organized into an interconnected structured network through semantic relationships, thereby transforming human domain knowledge into structured knowledge that machines can understand and process.
[0115] Specifically, step S31 above may include: Step C1: Data acquisition and terminology extraction.
[0116] First, collect various power regulations and documents, such as the "Substation Operation Regulations" and the "Power Safety Work Regulations." Refer to power industry standards, technical manuals, typical operation tickets, and fault reports. Invite field experts to provide common colloquial expressions, abbreviations, and business logic connections.
[0117] Then, natural language processing techniques (such as part-of-speech tagging and named entity recognition) are used to automatically extract candidate terms from the text. These are mainly noun phrases, such as equipment names (e.g., voltage transformers), operation names (e.g., switching operations), and status names (e.g., overload). Domain experts then review the candidate terms to determine the final standard terms to be included in the atlas. i std For example, use "circuit breaker" instead of "switch" consistently.
[0118] Step C2: Relationship definition and graph pattern design.
[0119] Node types are primarily defined using standard terminology.
[0120] The edge (relation) type explicitly defines four core semantic relations: synonym, abbreviation, is-a, and before / after.
[0121] Step C3: Knowledge Filling and Graph Construction.
[0122] All defined standard terms t1, t2, ..., t n As nodes in the knowledge graph, synonym and abbreviation relationships are labeled by experts based on their knowledge. For example, experts know that "PT" is an abbreviation for "voltage transformer". Hypernym / hypernym relationships are established by analyzing document structure (such as chapter titles) and combining expert review. Semantic relevance relationships rely on expert experience. For example, experts know that in business operations, "inspection" and "temperature measurement" are two operations that often occur consecutively, so a related_to relationship can be established. At this point, an initial knowledge graph G0(V, E) containing nodes and edges has been formed.
[0123] Step C4: Application and Export.
[0124] To facilitate efficient program use, the graph-structured data is exported as a dictionary structure (Dict). term .
[0125] Traverse the graph G0, for each standard term node t i Find all from t i Let Syn(t) be the set of nodes that each edge of type synonym points to. i(Synonyms set). Find all edges of type abbreviation_of to get Abbr(t) i (Set of abbreviations). Find all edges of type is_a or related_to, and get Rel(t) i (A collection of related terms). This ultimately forms a Dict. term = { t i std : (Syn(t i ), Abbr(t i ), Rel(t i ))}.Right now: Dict term ={ t i std :Syn(t i ),Abbr(t i ),Rel(t i )} in, Syn(t i )={ v j ∣(t i ,v j )∈E, type(e)=synonym} Abbr(t i )={ v j ∣(t i ,v j )∈E, type(e)=abbreviation_of} Rel(t i )={ v j ∣(t i ,v j )∈E, type(e)∈{is_a,related_to}} Among them, t i This is the i-th standard term. t i std Is with t i The content derived from the relevant terminology dictionary, std represents the standardized terminology that has been manually verified.
[0126] S32: Obtain the input question text from the large language model.
[0127] S33: Perform word segmentation on the question text to obtain multiple question segments.
[0128] S34: Obtain the standard terms involved in each question segmentation in the knowledge graph.
[0129] The knowledge graph includes a set of standard-synonyms, a set of standard-abbreviations, and a set of standard-hypernyms and their relationships. The set of standard-synonyms stores various power standard terms and their corresponding synonyms. The set of standard-abbreviations stores various power standard terms and their corresponding abbreviations. The set of hypernyms and hyponyms stores various power standard terms and their corresponding hypernyms and hyponyms.
[0130] For user natural language queries (Q raw The process involves word segmentation and word-by-word matching against a dictionary. That is: S35: Combine the question segments without corresponding standard terms with the standard terms corresponding to the question segments with corresponding standard terms according to the order of the question segments in the question text to obtain multiple question texts.
[0131] Steps S32-S35 here are implemented in the same way as steps S21-S24 in the aforementioned embodiments, and can be found in the relevant descriptions in the aforementioned embodiments, which will not be repeated here.
[0132] The large volume of query texts generated through term expansion and combination would be computationally intensive if all were matched with every slice in the knowledge base using full vector similarity. Furthermore, not all generated query texts are of high quality. Some overly generalized (using hypernyms) or overly specialized (using hyponyms) rewrites may have low semantic relevance to the overall document. Therefore, for both computational efficiency and retrieval effectiveness, it is necessary to filter through multiple query texts.
[0133] S36: Identify a subset of all segments in the electrical regulations document and determine the subset of segments as multiple segment samples.
[0134] Some slices are obtained by sampling from all slices.
[0135] By performing low-cost and rapid pre-matching on a small sample set, we can simulate and predict the retrieval potential of each question text in the full knowledge base, thereby selecting the question texts most likely to hit the correct answer.
[0136] When sampling from segments of power regulations documents, in addition to random sampling, criticality sampling can also be performed. That is, segments deemed more important are prioritized as samples. Criteria for determining criticality can include: hierarchical depth, frequency of occurrence (clauses that appear repeatedly in multiple related documents may be more critical), and expert annotations (a batch of core clauses are annotated in advance by domain experts), etc.
[0137] S37: Calculate the mean cosine similarity between the vector of each question text and the vector of each slice sample to obtain the mean cosine similarity of each question text.
[0138] For each question text Q k Using the text encoder f enc (e.g., BERT) converts it into a semantic vector q k This then outputs a set of question text vectors {q1,q2,...,q...}. m}
[0139] For the sample slice set S sample Each slice C in i Similarly, using encoder f enc Its main text content T i Convert to semantic vector v i This then outputs a set of sample slice vectors {v1, v2, ..., v...}. n}, where n=|S sample |
[0140] For each question text vector q k Calculate its relationship with each sample slice vector v i cosine similarity cos(q) k ,v i Then, these similarities are averaged to obtain the mean cosine similarity of the question text. That is: S38: Select a specified number of question texts as target texts in descending order of average cosine similarity.
[0141] You can directly select a specified number of question texts, or you can select a certain number of question texts based on a dynamic threshold.
[0142] When selecting the question text for the specific dynamic threshold, two strategies are adopted based on the relationship between the number of generated question texts m and the preset value K: Scenario 1: Sufficient question text (m ≥ K).
[0143] Directly based on score(Q) k Sort the questions in descending order and select the top K=3 questions.
[0144] Scenario 2: Insufficient question text (m <K) When there are few rewritten versions generated, directly selecting the top version may not be very meaningful, and may even result in selecting a low-quality version. Therefore, a more refined dynamic thresholding method is adopted.
[0145] Specifically calculate all scores (Q)k The mean μ S and standard deviation σ S Find the function α(m) based on the value of m to obtain the coefficients. For m < 3, α(m) = 0.3 (relatively lenient threshold, avoiding overly harsh filtering). For 4 ≤ m < 10, α(m) = 0.7 (moderate threshold). For m ≥ 10, α(m) = 1.0 (strict threshold, but this case rarely occurs). Calculate the dynamic threshold: τ = μ S +λ*σ S *α(m), where λ is the adjustment coefficient. Alternatively, all scores (Q) can be selected. k Question texts with scores ≥ τ. To compensate for the insufficient number of questions, the question text with the highest score is forcibly included. k Even if its score is below the threshold. That is: τ=μ S +λ⋅σ S ⋅α(m) Where, μ S Let σ be the mean of all rewritten scores. S λ is the standard deviation of the score, λ is the adjustment coefficient (empirical value 0.5 to 1.0), and α(m) is the quantity adaptive coefficient, used to adjust the threshold tightness according to m.
[0146] Filter out the target text Q=(Q text Q tag After that, the vector q=f of the target text is obtained. enc (Q text Q tag Furthermore, the vectors for each slice of the power regulations document have already been calculated. At this point, the preparatory work, as well as the rewriting and filtering of the problem text, are complete. Next, we can select similar slices.
[0147] S39: Calculate the semantic similarity between the vector of each target text and the vector of each slice of the power regulations document to obtain the semantic similarity of each slice relative to each query text.
[0148] For each selected target text, its semantic vector is compared one by one with the semantic vector of each slice in the knowledge base, and the cosine similarity is calculated for each. Finally, an independent semantic similarity score is calculated for each combination of (target text, procedure slice).
[0149] The specific calculation formula is as follows: S vec (Q text ,T i)=cos( f enc (Q text ),f enc (T i )) Among them, Q text This represents the main text content of the target text. (T) i f represents the main text content of the i-th procedure slice. enc This represents the text encoding function. enc (Q text f represents the semantic vector of the target text. enc (T i ) represents the semantic vector of the i-th procedure slice. cos represents the cosine similarity calculation function. S vec (Q tex t, T i () represents the semantic similarity score.
[0150] S310: Calculate the similarity between the vector of the structural label of each target text and the vector of the hierarchical label of each slice of the power regulations document to obtain the label similarity of each slice relative to each query text.
[0151] Structural tags refer to a collection of keywords or phrases extracted from target text that represent the query intent or topic category. For example: Target text: What to do after a transformer trips? Structural tag Q tag For: fault, handling.
[0152] Hierarchical tags refer to the path identifiers of the positions of slices in the original document of power regulations. For example: the hierarchical tag L of a slice. i :⟨"Chapter 3 Equipment Fault Handling", "3.1 Transformer Fault", "a">。 Another slice's hierarchical tag L_j:⟨"Chapter 4 Switching Operations", "4.2 Operation Procedures", "c">。
[0153] The set of structural tags parsed from a target text (e.g., {"fault", "handling"}) is compared with the set of hierarchical tags from a procedure slice (e.g., {"Chapter 3 Equipment Fault Handling", "3.1 Transformer Fault", "a"}). The comparison does not compare semantic vectors, but rather calculates the degree of overlap between the two sets. The specific calculation formula is as follows: Among them, Q tag This represents the set of structural tags parsed from the target text. L i Let Q represent the set of hierarchical labels for the i-th procedure slice. tag ∩ L i Describe the set Qtag and set L i The intersection of. | Q tag ∩ L i | indicates the cardinality of the intersection set, which is the number of elements in the set. Q tag ∪ L i Describe the set Q tag and set L i The union of . | Q tag ∪ L i | represents the cardinality of the union set, which is the total number of elements in the set. S tag (Q tag , L i () indicates label similarity.
[0154] Finally, a label similarity score between 0 and 1 is calculated for each combination of (target text, procedure slice). The higher the label similarity score, the more closely the user's query intent matches the topic of the chapter containing that slice.
[0155] S311: Determine the weight of each slice, where the weight is positively correlated with the slice's importance and level depth.
[0156] This involves layering a value assessment layer based on business rules and document structure on top of pure semantic matching, thereby guiding the system to prioritize the retrieval of procedural clauses that are not only relevant but also have greater operational guidance and safety criticality. This is one of the key design features that enables the retrieval enhancement generation system to go beyond being usable to being user-friendly and reliable.
[0157] Specifically as follows: S meta (Q,C i ) Among them, S meta This represents the slice weighting factor (such as chapter depth, document weight, etc.). Q represents a target text. C i Let i represent the i-th slice. (Q,C) i ) represents S meta It is query Q and slice C i The function.
[0158] S312: The similarity of each slice to each target text is calculated by weighting the semantic similarity of each slice to each target text, the label similarity of each slice to each target text, and the weight of each slice.
[0159] Right now: S(Q,C i )=β1⋅S vec (Q text ,T i )+β2⋅Stag (Q tag ,L i )+β3⋅S meta (Q,C i ) Wherein, β1, β2, and β3 are weighting coefficients, satisfying β1+β2+β3=1, with empirical values of β1=0.6, β2=0.3, and β3=0.1.
[0160] At this point, we have obtained the similarity score of each slice relative to each target text. Next, we need to generate a comprehensive score for each slice, i.e., a comprehensive similarity score, in order to select the slice as the answer.
[0161] S313: For each slice, select the highest similarity from the similarity of each corresponding target text, and calculate the average similarity of each target text.
[0162] S314: Weight the highest similarity score with the average similarity score to obtain the overall similarity score for each slice.
[0163] The specific calculation formula is as follows: Where, max k S (Q k C i The score represents the score of the best-matching rewritten version, i.e., the highest similarity. This represents the average score of all rewritten versions, i.e., the average similarity. γ is the fusion coefficient, with an empirical value range of γ∈[0.7,0.8].
[0164] By integrating the dual judgment mechanism of optimal matching and collective consensus, the robustness of the system is improved while ensuring high-precision recall.
[0165] S315: Calculate the mean and standard deviation of the overall similarity of all slices.
[0166] S316: Weight the mean and standard deviation to obtain an adaptive threshold.
[0167] The specific calculation formula is as follows: τ=μ S +λ⋅σ S Where, μ S σ represents the average of the fusion scores. S The standard deviation of the fusion score is represented by λ. λ is an adjustment parameter (empirical range 0.5~1.0).
[0168] S317: Select the slice corresponding to the comprehensive similarity greater than or equal to the adaptive threshold as the target slice of the question text, and use the target slice and the question text as input to the large language model again.
[0169] The specific formula is as follows: R * =TopK{ C i |S * (C i )≥τ} K defaults to 6.
[0170] The dynamic threshold τ automatically filters out low-relevance content based on the overall quality distribution of the search results, ensuring basic accuracy. The Top-K mechanism, on the other hand, guarantees a sufficient number of candidate slices even when there are many high-quality results, avoiding the omission of crucial information. This dual-protection mechanism allows the system to flexibly handle scenarios with varying query difficulty while providing sufficient and accurate contextual basis for subsequent large language model generation, achieving an adaptive balance between recall quantity and quality.
[0171] Finally, it should be noted that the target texts in steps S39-S317 can also be the question texts.
[0172] This concludes the description of the retrieval method based on power regulations documents provided in this application.
[0173] Based on the same inventive concept, embodiments of this application also provide a retrieval device based on power regulations documents.
[0174] Figure 4 This is a schematic diagram of the structure of the retrieval device based on power regulations documents in the embodiments of this application. Figure 1 See Figure 4 As shown, the device may include: Module 41 is used to obtain the input question text from the large language model.
[0175] The word segmentation module 42 is used to segment the question text into multiple question words.
[0176] The conversion module 43 is used to obtain the standard terms corresponding to each question word segment in the standard-synonym set, the standard-abbreviation set, and the standard-hypernym set. The standard-synonym set stores various power standard terms and their corresponding synonyms, the standard-abbreviation set stores various power standard terms and their corresponding abbreviations, and the hypernym set stores various power standard terms and their corresponding hypernyms.
[0177] The combination module 44 is used to combine the question segmentation words without corresponding standard terms with the standard terms corresponding to the question segmentation words with corresponding standard terms, according to the order of the question segmentation words in the question text, to obtain multiple question texts.
[0178] The matching module 45 is used to perform similarity matching between the vector of each query text and the vector of each slice of the power regulations document to obtain the similarity of each slice relative to each query text, and to aggregate the similarity of each query text to obtain the comprehensive similarity of each slice. Each slice is obtained by segmenting based on the clauses in the power regulations document.
[0179] Output module 46 is used to select a preset number of slices as target slices of the question text based on comprehensive similarity, and then use the target slices and the question text as input to the large language model again.
[0180] Furthermore, as a response to Figure 4 In a refinement and extension of the illustrated device, this application embodiment also provides a retrieval device based on power regulations documents.
[0181] Figure 5 This is a schematic diagram of the structure of the retrieval device based on power regulations documents in the embodiments of this application. Figure 2 See Figure 5 As shown, the device may include: Preparation module 51 is used to scan the power regulations document line by line based on a predefined set of regular expressions, where the set of regular expressions is used to represent the hierarchical tags in the power regulations document; obtain the hierarchical tags of each scanned line of content, and determine whether the depth of the hierarchical tags of the current line of content is less than the depth of the hierarchical tags of the previous line of content; if so, close the current line of content and the unclosed lines of content before it, and establish a correspondence between the currently closed content and the hierarchical tags of the current line of content; if not, continue scanning and determine whether the depth of the hierarchical tags of the next line of content is less than the depth of the hierarchical tags of the current line of content; determine each closed content and its corresponding hierarchical tag as a slice, and determine all slices as slices of the power regulations document.
[0182] Module 52 is used to obtain the input question text from the large language model.
[0183] The word segmentation module 53 is used to segment the question text into multiple question words.
[0184] The conversion module 54 is used to obtain the standard terms corresponding to each question word segment in the standard-synonym set, the standard-abbreviation set, and the standard-hypernym set. The standard-synonym set stores various power standard terms and their corresponding synonyms, the standard-abbreviation set stores various power standard terms and their corresponding abbreviations, and the hypernym set stores various power standard terms and their corresponding hypernyms.
[0185] The combination module 55 is used to combine the question segmentation words without corresponding standard terms with the standard terms corresponding to the question segmentation words with corresponding standard terms, according to the order of the question segmentation words in the question text, to obtain multiple question texts.
[0186] The filtering module 56 is used to determine a portion of the segments in all segments of the power regulations document, and to determine the portion of the segments as multiple segment samples, wherein the portion of the segments is obtained by sampling in all segments; the average cosine similarity is calculated between the vector of each question text and the vector of each segment sample to obtain the average cosine similarity of each question text; and a specified number of question texts are selected as target texts in order of average cosine similarity from high to low.
[0187] The matching module 57 is used to perform similarity matching between the vector of each query text and the vector of each slice of the power regulations document to obtain the similarity of each slice relative to each query text, and to aggregate the similarity of each query text to obtain the comprehensive similarity of each slice. Each slice is obtained by segmenting based on the clauses in the power regulations document.
[0188] Matching module 57 is specifically used to perform similarity matching between the vector of each target text and the vector of each slice of the power regulations document.
[0189] The matching module 57 is specifically used to calculate the semantic similarity between the vector of each query text and the vector of each slice of the power regulations document, to obtain the semantic similarity of each slice relative to each query text; to calculate the similarity between the vector of the structural label of each query text and the vector of the hierarchical label of each slice of the power regulations document, to obtain the label similarity of each slice relative to each query text; to determine the weight of each slice, wherein the weight is positively correlated with the importance and hierarchical depth of the slice; and to perform a weighted calculation based on the semantic similarity of each slice relative to each query text, the label similarity of each slice relative to each query text, and the weight of each slice, to obtain the similarity of each slice relative to each query text.
[0190] The matching module 57 is specifically used to select the highest similarity from the similarity of each corresponding question text for each slice, and to calculate the average similarity of each question text; the highest similarity and the average similarity are weighted to obtain the comprehensive similarity of each slice.
[0191] Output module 58 is used to calculate the mean and standard deviation of the comprehensive similarity of all slices based on the comprehensive similarity; weight the mean and standard deviation to obtain an adaptive threshold; select the slices with comprehensive similarity greater than or equal to the adaptive threshold as the target slices of the question text, and use the target slices and the question text as input to the large language model again.
[0192] It should be noted that the description of the above device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0193] Based on the same inventive concept, this application also provides a computer device.
[0194] Figure 6 This is a schematic diagram of the structure of the computer device in an embodiment of this application. See also... Figure 6 As shown, the computer device may include: a memory 61, a processor 62, and a computer program stored on the memory 61, wherein the processor 62 executes the computer program to implement the methods described in the foregoing embodiments.
[0195] It should be noted that the description of the above computer device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the computer device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0196] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the methods described in the foregoing embodiments.
[0197] It should be noted that the description of the above computer-readable storage medium embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the computer-readable storage medium embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0198] Based on the same inventive concept, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the methods described in the foregoing embodiments.
[0199] It should be noted that the descriptions of the above computer program product embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the computer program product embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0200] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A retrieval method based on power regulations documents, characterized in that, The method includes: Obtain the input question text from a large language model; The question text is segmented into multiple question segments. Obtain the standard terms involved in each question word segment in the knowledge graph, wherein the knowledge graph includes a standard-synonym set, a standard-abbreviation set, and a standard-hypernym set and the relationships between them. The standard-synonym set stores various power standard terms and their corresponding synonyms, the standard-abbreviation set stores various power standard terms and their corresponding abbreviations, and the hypernym set stores various power standard terms and their corresponding hypernyms. The question segments without corresponding standard terms are combined with the standard terms corresponding to the question segments with corresponding standard terms according to the order of the question segments in the question text to obtain multiple question texts; The similarity of each query text vector with the vector of each slice of the power regulations document is matched to obtain the similarity of each slice with respect to each query text. The similarity of each query text is then aggregated to obtain the comprehensive similarity of each slice. Each slice is obtained by segmenting the clauses in the power regulations document. Based on the comprehensive similarity, a preset number of slices are selected as target slices of the question text, and the target slices and the question text are used as input to the large language model again.
2. The method according to claim 1, characterized in that, The method further includes, prior to performing similarity matching between the vector of each query text and the vector of each slice of the power regulations document: A subset of slices is identified from all slices of the power regulation document, and the subset of slices is further defined as multiple slice samples, wherein the subset of slices is obtained based on sampling from all slices; The mean cosine similarity is calculated between the vector of each question text and the vector of each slice sample to obtain the mean cosine similarity of each question text. Select a specified number of question texts as target texts in descending order of average cosine similarity. The similarity matching process, which involves comparing the vector of each query text with the vector of each slice of the power regulations document, includes: The vector of each target text is used to perform similarity matching with the vector of each slice of the power regulations document.
3. The method according to claim 1, characterized in that, The method involves performing similarity matching between the vector of each query text and the vector of each slice in the power regulations document to obtain the similarity of each slice relative to each query text, including: Semantic similarity is calculated by comparing the vector of each query text with the vector of each slice of the power regulations document to obtain the semantic similarity of each slice relative to each query text. The similarity is calculated by comparing the vector of the structural label of each question text with the vector of the hierarchical label of each slice of the power regulations document, so as to obtain the label similarity of each slice with each question text. Determine the weight of each slice, where the weight is positively correlated with the slice's importance and layer depth; The similarity of each slice to each question text is calculated by weighting the semantic similarity of each slice to each question text, the label similarity of each slice to each question text, and the weight of each slice.
4. The method according to claim 1, characterized in that, The process of aggregating the similarity of each question text to obtain a comprehensive similarity for each slice includes: For each slice, select the highest similarity from the similarity of each corresponding question text, and calculate the average similarity of each question text; The highest similarity score is weighted by the average similarity score to obtain the overall similarity score for each slice.
5. The method according to claim 1, characterized in that, The step of selecting a preset number of slices as target slices of the question text based on the comprehensive similarity includes: Calculate the mean and standard deviation of the overall similarity of all slices; The average value and the standard deviation are weighted to obtain an adaptive threshold; Select the slice with a comprehensive similarity greater than or equal to the adaptive threshold as the target slice of the question text.
6. The method according to any one of claims 1 to 5, characterized in that, Before obtaining the input question text from a large language model, the method further includes: The power regulations document is scanned line by line based on a predefined set of regular expressions, wherein the set of regular expressions is used to represent the hierarchical tags in the power regulations document; Get the hierarchy tags of each scanned line of content and determine whether the depth of the hierarchy tags of the current line of content is less than the depth of the hierarchy tags of the previous line of content. If so, close the current line content and the unclosed line content before it, and establish a correspondence between the hierarchical tags of the currently closed content and the current line content; If not, continue scanning and determine whether the depth of the hierarchy tags of the next line of content is less than the depth of the hierarchy tags of the current line of content; Each closed content and its corresponding hierarchical label are identified as a slice, and all slices are identified as individual slices of the power regulations document.
7. A retrieval device based on power regulations documents, characterized in that, The device includes: The acquisition module is used to obtain the input question text from the large language model; The word segmentation module is used to segment the question text into multiple question words; The conversion module is used to obtain the standard terms corresponding to each question word segment in the standard-synonym set, the standard-abbreviation set, and the standard-hypernym set. The standard-synonym set stores various power standard terms and their corresponding synonyms, the standard-abbreviation set stores various power standard terms and their corresponding abbreviations, and the hypernym set stores various power standard terms and their corresponding hypernyms. The combination module is used to combine the question segments without corresponding standard terms with the standard terms corresponding to the question segments with corresponding standard terms, according to the order of the question segments in the question text, to obtain multiple question texts; The matching module is used to perform similarity matching between the vector of each query text and the vector of each slice of the power regulations document to obtain the similarity of each slice relative to each query text, and to aggregate the similarity of each query text to obtain the comprehensive similarity of each slice, wherein each slice is obtained by segmenting based on the clauses in the power regulations document; The output module is used to select a preset number of slices as target slices of the question text based on the comprehensive similarity, and to use the target slices and the question text as input to the large language model again.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Power grid operation rule knowledge graph construction system and method
CN113918512A
Power file question and answer type intelligent retrieval method and system
CN117171333A
Intelligent retrieval method for power grid service information
CN118760787A
Digital-intelligent power regulation and control question answering method and system based on large language model
CN119003742A
Power industry standard provisions search method and system based on semantic understanding
WO2025217971A1