Power document intelligent question and answer method and system based on large language model

Through the intelligent question-and-answer method of power documents based on large language model, the problem of low information retrieval efficiency and accuracy in the power industry is solved, and multiple rounds of question-and-answer and context understanding are achieved, which significantly improves the accuracy of user experience and information retrieval.

CN119577082APending Publication Date: 2025-03-07DATANG HYDROPOWER SCI & TECH RES INST CO LTD +2
View PDF 0 Cites 24 Cited by

Patent Information

Application Number
CN202411602465.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

The information retrieval efficiency, accuracy and intelligence of the existing technology in the power industry are low, and cannot meet the growing demand for intelligent question and answers.

Method used

The intelligent question-and-answer method of power documents based on large language models is adopted, and a vector search library is constructed by preprocessing document data, a user query question is obtained, and a search is conducted by combining vector similarity and keyword search methods. The large language model is used to generate preliminary answers and correct them through a self-reflection mechanism to finally generate the final intelligent answer.

Benefits of technology

Multiple rounds of question-and-answer and context understanding are achieved, the efficiency and accuracy of information retrieval is improved, the user experience is significantly improved, and context consistency can be maintained in continuous queries of complex technical problems, ensuring that users' multiple rounds of questions are accurately responded to.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119577082A_ABST
    Figure CN119577082A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence, and relates to a power document intelligent question and answer method and system based on a large language model. The method comprises the steps of obtaining document data according to a preset period; preprocessing the document data to obtain an adaptive document; constructing a vector retrieval library through an embedded model according to the adaptive document; obtaining a user query question, inputting the user query question into a vector retrieval library, performing retrieval based on a vector similarity retrieval method and a keyword retrieval method to obtain related text blocks, and screening out the most related text block from the related text blocks through a two-stage rearrangement technology; a user queries the question and the most relevant text block and inputs the question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; and correcting the preliminary intelligent answer information based on a preset self-provincial inversion mechanism to obtain final intelligent answer information. Multiple rounds of questions and answers and context understanding are supported based on a correction mechanism, context consistency can be kept in continuous query of complex technical questions, and the accuracy of multiple rounds of questions and responses is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of artificial intelligence and relates to an intelligent question-answering method and system for electric power documents based on a large language model. Background Art

[0002] With the digital transformation and intelligent development of the power industry, power companies have accumulated a large amount of document data, including design drawings, equipment manuals, operating procedures, maintenance records, etc. These documents are rich in content and cover all aspects of the power system. However, how to efficiently obtain the required information from these massive documents has become a major challenge facing the power industry. Traditional document retrieval methods mainly rely on keyword search. Although this method can meet the needs of users to a certain extent, due to the professionalism and complexity of power documents, users often need to have a high level of domain knowledge to accurately construct search queries, and the relevance and accuracy of search results are often unsatisfactory. With the advancement of natural language processing technology, especially the development of large language models, intelligent question answering through language models, automatic processing and understanding of a large number of complex documents, and efficient information retrieval have shown great application prospects.

[0003] At present, traditional keyword-based retrieval systems have obvious limitations when processing professional documents in the power industry. First, it is difficult for traditional retrieval methods to accurately understand the user's intentions, especially when faced with complex technical problems. Users need to spend a lot of time adjusting keywords or browsing search results one by one to find truly relevant information. Secondly, the information in power documents often exists in the form of professional terms, charts and formulas. It is difficult for traditional retrieval systems to effectively parse and utilize these unstructured data, resulting in search results that are not comprehensive and accurate enough. In addition, the existing system has limited support for multi-round question and answer and context understanding, and cannot meet the needs of users for continuous queries. Especially in the case of complex technical problems, users' multi-round questions often do not receive accurate responses. Overall, the existing technology still has major deficiencies in information retrieval efficiency, accuracy and intelligence, and cannot fully meet the growing demand for intelligent question and answer in the power industry. This is exactly the problem that the present invention is intended to solve. Summary of the invention

[0004] The purpose of the present invention is to provide a method and system for intelligent question answering of power documents based on a large language model to solve the technical problems of the prior art in terms of low information retrieval efficiency, accuracy and intelligence.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions: In a first aspect, the present application discloses an intelligent question-answering method for electric power documents based on a large language model, comprising: Acquire document data according to a preset cycle; pre-process the document data to obtain an adaptive document; build a vector retrieval library based on the adaptive document through an embedding model; Obtain user query questions, input the user query questions into a vector retrieval library, search the vector retrieval library based on a vector similarity retrieval method and a keyword retrieval method, obtain relevant text blocks, and select the most relevant text blocks from the relevant text blocks through a two-stage rearrangement technology; The user query question and the most relevant text block are input into the large language model to obtain preliminary intelligent answer information; the preliminary intelligent answer information is corrected based on a preset self-reflection mechanism to obtain the final intelligent answer information.

[0006] Preferably, the acquiring of document data according to a preset period specifically includes: acquiring the latest document according to a preset period, and adding the latest document to the original document to form the document data; The preprocessing includes: document data parsing, document content extraction, document content denoising and document content word segmentation processing.

[0007] Preferably, the step of constructing a vector retrieval library based on the adaptive document by using an embedding model specifically includes: Perform fixed-length block division and hierarchical block division on the adaptive document to obtain corresponding text blocks; Using a text embedding model fine-tuned with the power field corpus, each text block is converted into a semantic vector to obtain a vector retrieval library.

[0008] Preferably, the obtaining of the user query question, inputting the user query question into a preset vector search library, searching the vector search library based on vector similarity and keyword search methods to obtain a set of related text blocks, and screening out the most relevant text block from the set of related text blocks by a two-stage rearrangement technology, specifically includes: S101: Obtain a user query question, and rewrite the user query question to obtain a rewritten query question; S102: Based on the vector similarity and keyword-based retrieval method, the rewritten query question is input into a preset vector retrieval library for preliminary retrieval to obtain a set of related text blocks; S103: reordering the set of related text blocks based on the two-stage reordering technology to obtain reordered related text blocks, and screening the reordered related text blocks to obtain the most relevant text blocks.

[0009] Preferably, the retrieval method based on vector similarity in S102 specifically includes: Use the text embedding model to convert the rewritten query question into a user query vector :

[0010] Based on the efficient vector retrieval algorithm, in the preset vector retrieval library, for the set of text blocks divided by length, k related text blocks divided by length are queried:

[0011] Based on the efficient vector retrieval algorithm, in the preset vector retrieval library, for the hierarchical and block-based text block set, m chapters are queried:

[0012] In each chapter, based on an efficient vector retrieval algorithm, k hierarchical blocks of relevant text are obtained by query:

[0013] Summarize search results:

[0014] in, Query vector for user; For text embedding models; To rewrite the query question; A collection of related text blocks divided into length blocks, The relevant text block for the k-th length block; is the mth chapter; The relevant text block for the k-th hierarchical segmentation; is a set of text blocks related by vector similarity.

[0015] Preferably, the keyword-based search method in S102 specifically includes: Using the BM25 algorithm, the BM25 score is obtained by calculating the match between the query term and the text block. The formula is as follows:

[0016] Based on the calculated BM25 score, k keyword-related text blocks are obtained, denoted as:

[0017] in: is a word in the user query vector; is a block of text, Expressive words In the text block The frequency of words in ; Indicates the length of the text block, is the average length of the set of text blocks; Words The inverse document frequency of and is the adjustment parameter; A collection of keyword-related text blocks; is the k-th keyword related text block.

[0018] Preferably, the step of inputting the user query question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; and correcting the preliminary intelligent answer information based on a preset self-reflection mechanism to obtain final intelligent answer information specifically includes: 201: Fill the user query question and the most relevant text block into the large language model prompt word template In the example above, the large language model is used as the input to obtain preliminary intelligent answer information. 202: Fill the user query question, the most relevant text block, the preliminary intelligent answer information and the preset self-reflection mechanism into the large language model prompt word template In the example above, the word “information” is used as the input of the large language model to obtain the final intelligent answer information.

[0019] In a second aspect, the present application discloses an intelligent question-answering system for electric power documents based on a large language model, comprising: A retrieval library construction unit is used to obtain document data according to a preset period; pre-process the document data to obtain an adaptive document; and construct a vector retrieval library based on the adaptive document through an embedding model; A retrieval unit is used to obtain a user query question, input the user query question into a preset vector retrieval library, search the vector retrieval library based on vector similarity and keyword retrieval methods, obtain relevant text blocks, and select the most relevant text block from the relevant text blocks through a two-stage rearrangement technology; The intelligent generation unit is used to input the user query question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; the preliminary intelligent answer information is corrected based on a preset self-reflection mechanism to obtain final intelligent answer information.

[0020] In a third aspect, the present application discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned methods for intelligent question-answering of electric power documents based on a large language model when executing the computer program.

[0021] In a fourth aspect, the present application discloses a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the method for intelligent question and answer of power documents based on a large language model as described above.

[0022] Compared with the prior art, the present invention has the following beneficial effects: 1) Multi-round question and answer support: The system supports multi-round question and answer and context understanding, and can maintain context consistency in continuous queries of complex technical issues, ensuring that users' multi-round questions are accurately responded to. Existing systems have difficulty maintaining context consistency in multi-round question and answer, especially when users make continuous queries. The system cannot effectively understand the context, resulting in incoherent question and answer results, or even contradictions with the previous query. The preliminary intelligent answer information is corrected based on a preset self-reflection mechanism, so that the present invention can track and understand user intentions in multi-round conversations through the context understanding ability of a large language model. Even if the user omits some background information in the process of continuous questioning, it can be supplemented and inferred based on the context to maintain consistency of the answer. This improvement eliminates the need for users to repeatedly enter background information when dealing with complex technical issues, greatly improving the convenience of queries and the usability of the system.

[0023] 2) Continuous system optimization: By introducing user feedback mechanisms and regular data updates, the system can be continuously improved and expanded to adapt to technological developments and document updates in the power industry, ensuring that the system maintains high efficiency and accuracy in the long term. Traditional systems often lack effective optimization mechanisms during long-term use and are unable to adapt to the constantly updated technical information and document content in the power industry, resulting in a gradual decline in system performance. To this end, the present invention regularly updates document data sets to ensure that the system always answers questions based on the latest technical information. At the same time, the user feedback mechanism can not only help the system identify incorrect answers, but also optimize the model training process through feedback information, thereby enhancing the system's ability to understand specific problem areas. Through this mechanism, the system can continuously evolve and optimize, maintain long-term efficiency and accuracy, and ultimately improve user satisfaction.

[0024] 3) Improve user experience: The present invention reduces the time users spend manually searching for information through automated and intelligent information retrieval and question-and-answer functions, improves the convenience and accuracy of information acquisition, and significantly improves the user experience. Existing systems often require users to have high professional knowledge in order to accurately construct keyword queries, and when encountering complex technical problems, users often need to spend a lot of time adjusting query content or repeatedly browsing results. Through the improvements of the present invention, users do not need to have deep professional knowledge to ask natural language questions. The system can automatically process user queries and generate accurate answers based on large language models. In addition, the system supports multiple rounds of contextual questions and answers, and users do not have to repeatedly enter background information, which greatly simplifies the process of information acquisition. Through efficient retrieval and intelligent answer generation, users can quickly and accurately obtain the required information, significantly improving the user experience.

[0025] 4) Efficient document retrieval: The present invention combines vector retrieval and keyword retrieval methods to quickly and accurately locate the power document information required by user queries, thereby significantly improving retrieval efficiency. Existing traditional keyword-based retrieval systems have difficulty accurately understanding the user's query intent when processing power documents, and for complex technical issues, accurate search results are often not obtained, and users need to spend a lot of time adjusting keywords or browsing results one by one. Through vectorization processing, the present invention can convert both user queries and document content into high-dimensional semantic vectors, and perform retrieval based on vector similarity, which can better capture the correlation between semantics, rather than relying solely on the surface matching of keywords. At the same time, combined with keyword retrieval, the comprehensiveness of the retrieval is further improved to ensure that important information is not missed. Through this dual retrieval mechanism, the present invention significantly improves retrieval efficiency and accuracy, and users can obtain required information more quickly. 5) Intelligent question and answer generation: By utilizing the powerful semantic understanding capabilities of the large language model, the system can automatically generate intelligent answers based on the document content to help users quickly obtain the required information. Existing question and answer systems often perform poorly on complex technical issues in the power industry, and the generated answers may be inaccurate or irrelevant to the user's query. By introducing a large language model, the present invention can fully understand the user's natural language query and generate accurate and relevant answers based on the semantic information in the power document. The large language model has a powerful semantic understanding capability and can handle professional terminology and complex technical issues in the power industry. In addition, in order to avoid the large language model from generating "hallucinatory" wrong answers (i.e., generating content that does not match the facts), the present invention introduces a self-reflection mechanism to correct the generated answers to ensure that the answers are consistent with the reference information and avoid introducing irrelevant or erroneous content. This improvement significantly improves the accuracy and relevance of the answers, ensuring that the answers obtained by the user can truly solve the problem. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 is a flow chart of the method of the present invention; Figure 2 It is a system block diagram of the present invention. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0029] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0031] In the description of the embodiments of the present invention, it should be noted that if the terms "upper", "lower", "horizontal", "inner", etc. indicate an orientation or positional relationship based on the orientation or positional relationship shown in the drawings, or the orientation or positional relationship in which the product of the invention is usually placed when in use, it is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.

[0032] In addition, if the term "horizontal" appears, it does not mean that the component must be absolutely horizontal, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", which does not mean that the structure must be completely horizontal, but can be slightly tilted.

[0033] In the description of the embodiments of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal connection of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0034] The present invention is further described in detail below in conjunction with the accompanying drawings: This paper proposes an intelligent question-answering method for power documents based on a large language model, aiming to improve the efficiency of document retrieval and the accuracy of question-answering in the power industry, and to solve the shortcomings of the existing technology in terms of information retrieval accuracy, professionalism, and multi-round question-answering support. Through the semantic understanding ability of the large language model, the present invention can automatically extract relevant information from massive power documents and generate intelligent answers, thereby meeting the complex query needs of users. Figure 1 , an intelligent question-answering method for power documents based on a large language model, comprising: S1: Obtain document data according to a preset cycle; pre-process the document data to obtain an adaptive document; and construct a vector retrieval library based on the adaptive document through an embedding model; S2: Obtaining a user query question, inputting the user query question into a preset vector retrieval library, searching the vector retrieval library based on a vector similarity retrieval method and a keyword retrieval method, obtaining relevant text blocks, and filtering out the most relevant text blocks from the relevant text blocks through a two-stage rearrangement technology; S3: Input the user query question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; correct the preliminary intelligent answer information based on a preset self-reflection mechanism to obtain the final intelligent answer information.

[0035] By combining vector retrieval and keyword retrieval methods, the present invention can quickly and accurately locate the power document information required by the user's query, significantly improving the retrieval efficiency. Utilizing the powerful semantic understanding ability of the large language model, the system can automatically generate intelligent answers based on the document content to help users quickly obtain the required information. Through the preset self-reflection mechanism, it supports multiple rounds of question and answer and context understanding, and can maintain context consistency in continuous queries of complex technical issues, ensuring that multiple rounds of user questions are accurately responded to. Through automated and intelligent information retrieval and question and answer functions, the present invention reduces the time users spend manually searching for information, improves the convenience and accuracy of information acquisition, and significantly improves the user experience.

[0036] In some embodiments, the acquiring of document data according to a preset period specifically includes: acquiring the latest document according to a preset period, and adding the latest document to the original document to form the document data; The preprocessing includes: document data parsing, document content extraction, document content denoising and document content word segmentation processing.

[0037] Further preferably, the preset periodic acquisition of document data is to regularly update and expand the document data set. The technical documents and teaching materials of the power industry are frequently updated. In order to keep the vector retrieval library up to date, the vector retrieval library needs to regularly obtain the latest documents from the authoritative data source and add them to the document library. The addition of new documents needs to go through the same preprocessing and vectorization process as above to ensure that they can be smoothly integrated into the existing vector retrieval library; In some embodiments, the present application continuously optimizes the performance of the large language model through a user feedback mechanism. User feedback information will be used for subsequent large language model training and improvement to ensure the long-term effectiveness of the system in practical applications. Specifically, the user's query log and feedback information are used for continuous training and optimization of the model. By analyzing the user's query behavior, the system can identify common query patterns and problem areas, so as to perform special fine-tuning on the large language model. For example, if the system finds that the query frequency of a certain type of technical problem is high, but the accuracy of the answer is not ideal, the system can focus on optimizing this problem area, adjust the model parameters or introduce specialized domain knowledge to improve the accuracy of the answer.

[0038] By introducing a user feedback mechanism and regular data updates, the present application can be continuously improved and expanded to adapt to technological developments and document updates in the electric power industry, ensuring that the present application maintains high efficiency and accuracy over the long term. Traditional methods often lack effective optimization mechanisms in long-term use and are unable to adapt to the constantly updated technical information and document content in the electric power industry, resulting in a gradual decline in system performance. To this end, the present invention regularly updates document data sets to ensure that the system always answers questions based on the latest technical information. At the same time, the user feedback mechanism can not only help identify incorrect answers, but also optimize the large language model training process through feedback information, thereby enhancing the present application's ability to understand specific problem areas. Through this mechanism, the present application can continue to evolve and optimize, maintain long-term efficiency and accuracy, and ultimately improve user satisfaction.

[0039] In some embodiments, constructing a vector retrieval library based on the adaptive document by using an embedding model specifically includes: Perform fixed-length block division and hierarchical block division on the adaptive document to obtain corresponding text blocks; Using a text embedding model fine-tuned with the power field corpus, each text block is converted into a semantic vector to obtain a vector retrieval library.

[0040] In some embodiments, the obtaining of the user query question, inputting the user query question into a preset vector search library, searching the vector search library based on vector similarity and keyword search methods to obtain a set of related text blocks, and screening out the most relevant text block from the set of related text blocks by a two-stage rearrangement technology, specifically includes: S101: Obtain a user query question, and rewrite the user query question to obtain a rewritten query question; S102: Based on the vector similarity and keyword-based retrieval method, the rewritten query question is input into a preset vector retrieval library for preliminary retrieval to obtain a set of related text blocks; S103: reordering the set of related text blocks based on the two-stage reordering technology to obtain reordered related text blocks, and screening the reordered related text blocks to obtain the most relevant text blocks.

[0041] In some embodiments, the retrieval method based on vector similarity in S102 specifically includes: Use the text embedding model to convert the rewritten query question into a user query vector :

[0042] Based on the efficient vector retrieval algorithm, in the preset vector retrieval library, for the set of text blocks divided by length, k related text blocks divided by length are queried:

[0043] Based on the efficient vector retrieval algorithm, in the preset vector retrieval library, for the hierarchical and block-based text block set, m chapters are queried:

[0044] In each chapter, based on an efficient vector retrieval algorithm, k hierarchical blocks of relevant text are obtained by query:

[0045] Summarize the search results:

[0046] in, Query vector for user; For text embedding models; To rewrite the query question; A collection of related text blocks divided into length chunks, The relevant text block for the k-th length block; is the mth chapter; The relevant text block for the k-th hierarchical segmentation; is a set of text blocks related by vector similarity.

[0047] In some embodiments, the keyword-based search method in S102 specifically includes: Using the BM25 algorithm, the BM25 score is obtained by calculating the match between the query term and the text block. The formula is as follows:

[0048] Based on the calculated BM25 score, k keyword-related text blocks are obtained, denoted as:

[0049] in: is a word in the user query vector; is a block of text, Expressive words In the text block The frequency of words in ; Indicates the length of the text block, is the average length of the set of text blocks; Words The inverse document frequency of and is the adjustment parameter; A collection of keyword-related text blocks; is the k-th keyword related text block.

[0050] In some embodiments, the step of inputting the user query question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; and correcting the preliminary intelligent answer information based on a preset self-reflection mechanism to obtain final intelligent answer information specifically includes: 201: Fill the user query question and the most relevant text block into the large language model prompt word template In the example above, the large language model is used as the input to obtain preliminary intelligent answer information. 202: Fill the user query question, the most relevant text block, the preliminary intelligent answer information and the preset self-reflection mechanism into the large language model prompt word template In the example above, the word “information” is used as the input of the large language model to obtain the final intelligent answer information.

[0051] In some embodiments, a method for intelligent question answering of electric power documents based on a large language model comprises: S1, document data preprocessing: parse and standardize various types of documents in the power industry (such as PDF, Word, Excel, drawings, etc.), extract text, charts and other content, and perform denoising and word segmentation to ensure that the document content can adapt to subsequent vectorization and retrieval needs.

[0052] S2, vector retrieval library construction: The preprocessed document content is divided into blocks, and each text block is converted into a high-dimensional semantic vector through a deep learning embedding model to build an efficient vector retrieval library to quickly match relevant content when users query.

[0053] S201, text segmentation: the document is segmented into fixed-length segments or hierarchical segments to ensure the semantic integrity of the text segments.

[0054] S202, text vectorization processing: Use a text embedding model that has been fine-tuned with the power field corpus to convert each text block into a semantic vector to ensure the semantic consistency of the vector.

[0055] The above two steps are the preliminary stage of presetting the vector retrieval library, and the content disclosed in this application includes regularly updating and optimizing the vector retrieval library. Specifically, regularly updating the document data set to ensure the construction of the latest vector retrieval library, thereby ensuring the accuracy and scientificity of the questions and answers.

[0056] S3, Reference Information Retrieval: When a user asks a question, the system first rephrases the user’s query question, then retrieves the text blocks most relevant to the question based on vector similarity and keyword retrieval methods, and selects the most relevant content through a two-stage re-ranking technique.

[0057] S301, user query question rewriting: use a large language model to rewrite the user query question to make it more contextual and improve the retrieval recall rate.

[0058] S302, multi-way hierarchical retrieval: using both vector similarity and keyword-based retrieval methods to ensure that all relevant information in the document can be retrieved.

[0059] S303, second-stage re-ranking: re-rank the preliminary search results, filter out the most relevant text blocks, and ensure the accuracy of the search.

[0060] S4, intelligent answer generation based on large language model: taking the user's query and the retrieved related text information as input, generating intelligent answers through the large language model, and using the self-reflection mechanism to correct the answers to ensure the accuracy and consistency of the answers.

[0061] S401, intelligent answer generation: Based on user queries and reference information, a preliminary answer is generated using a large language model.

[0062] S402, answer correction: Correct the initial answer through the preset self-reflection mechanism of the large language model to ensure that the answer is consistent with the reference information and avoid hallucinations in the answer.

[0063] Preferably, the preset self-reflection mechanism will continuously optimize the performance of the large language model through user feedback. Specifically, user feedback information is used for large language model training and improvement to ensure the long-term effectiveness of the system in practical applications. Use the user's query log and feedback information to continuously train and optimize the large language model. By analyzing the user's query behavior, common query patterns and problem areas are identified, so that the large language model can be specially fine-tuned through the preset self-reflection mechanism. For example, if the system finds that the query frequency of a certain type of technical problem is high, but the accuracy of the answer is not ideal, the system can focus on optimizing this problem area, adjust the large language model parameters, or introduce special domain knowledge settings in the self-reflection mechanism to improve the accuracy of the answer.

[0064] [Example] The present invention provides an intelligent question-answering method for power documents based on a large language model, which aims to accurately and quickly obtain required information from massive power documents and generate intelligent answers through a large language model. The method mainly includes the following steps: 1. Preset vector search library 1.1 Document Data Preprocessing Document data preprocessing is the basic step in building a vector retrieval library, which aims to standardize the original power documents so that they can be effectively used by subsequent models and algorithms. Power documents are in various formats, including PDF, Word, Excel, drawings and other types. In order to make these documents meet the needs of the intelligent question-answering system, they first need to be converted into a unified processable text format. This process includes document parsing, text extraction, chart parsing and denoising.

[0065] In the document parsing process, optical character recognition technology is first used to convert the scanned document image into editable text. For documents that are already in text format, their content is directly parsed to extract the text information. For charts in the document, special image processing algorithms and table recognition tools are applied to convert the data in the charts into text or structured data for subsequent processing. Next, the extracted text is denoised to eliminate noise data in the document, such as watermarks, headers and footers, page numbers and other irrelevant information. Then, through natural language processing technologies such as word segmentation and part-of-speech tagging, the text is subjected to preliminary semantic analysis to extract key terms and sentence structures, laying the foundation for subsequent vectorization processing and retrieval.

[0066] During the preprocessing process, the documents also need to be classified and annotated. According to the different types and contents of power documents, machine learning algorithms are used to automatically classify the documents, such as operating procedures, maintenance manuals, design drawings, etc. For each document, the important entities in it are further annotated through named entity recognition technology, such as equipment name, parameter value, date, unit, etc., so as to enhance the semantic information of the document.

[0067] 1.2 Construction of vector retrieval library The construction of the vector retrieval library aims to convert the preprocessed document content into high-dimensional vectors and store them in an efficient retrieval library so that relevant content can be quickly matched when users make queries. This process includes text segmentation, text vectorization processing, and the construction and storage of the vector retrieval library.

[0068] First, the preprocessed text is divided into blocks. For documents without hierarchical structure, the fixed-length block method is adopted: the text is broken into parts of uniform size according to the predefined number of characters. In order to ensure the semantic integrity of the text block, one sentence overlap is allowed between adjacent text blocks, that is, the last sentence of the current text block is used as the first sentence of the next text block.

[0069]

[0070] in is the i-th text block. For hierarchical documents, the hierarchical segmentation method is adopted. According to the directory structure of the document, all the contents under a chapter (first-level directory) are summarized into a paragraph using the large language model, and then the text of the chapter is segmented into fixed-length blocks.

[0071]

[0072] in, , is the summary of chapter i obtained by the large language model, is the jth text block in the i-th chapter.

[0073] Therefore, the text library after segmentation can be expressed as

[0074] Next, the divided text blocks are vectorized. Each text block is converted into a high-dimensional semantic vector using a text embedding model based on deep learning:

[0075] in, is the i-th text block, is a text embedding model, is the obtained semantic vector. In order to ensure the semantic consistency of the vector, the embedding model needs to be trained on the power field text data through self-supervision, so as to make a more accurate overall semantic modeling representation of the power field text data.

[0076] After vectorization is completed, the vectors of all text blocks are stored in a vector retrieval library to form a vector retrieval library.

[0077] 2. Reference Information Retrieval Obtaining user query questions, inputting the user query questions into a preset vector retrieval library, searching the vector retrieval library based on a vector similarity retrieval method and a keyword retrieval method, obtaining relevant text blocks, and filtering out the most relevant text blocks from the relevant text blocks through a two-stage rearrangement technology; When a user asks a question, the text embedding model is used to convert the user input question into a vector, calculate the similarity between the embedding vector of the question and the embedding vector of the text block in the corpus, and select the top k text blocks with the highest similarity as the reference information for the current question. This process includes query rewriting, multi-way hierarchical retrieval, and two-stage rearrangement.

[0078] Query Rewrite The user's input may just be a combination of some keywords, rather than a standardized question. Therefore, in order to improve the recall rate in the retrieval stage, the user's query input needs to be rewritten to convert it into a more complete and clear query statement. This usually involves understanding the user's intention, supplementing the missing context information, and correcting possible grammatical or spelling errors. This method uses a large language model to implement query rewriting. By designing appropriate prompt words, it guides the model to generate query expressions that are more in line with the context and needs.

[0079] Multi-level hierarchical search Based on the rewritten query, multi-way hierarchical retrieval is performed: In order to improve the recall rate, a hierarchical retrieval method based on vector similarity and a keyword-based retrieval method are used simultaneously to search in the vector retrieval library (or text block library).

[0080] The process of hierarchical retrieval method based on vector similarity is as follows: 1. Using the aforementioned text embedding model, convert the rewritten query into an embedding vector:

[0081] 2. The process of hierarchical retrieval method based on vector similarity is as follows: First, based on efficient vector retrieval algorithms (such as FAISS) In the query, we get The k most similar text blocks are denoted as:

[0082] Among them, the user query vector and text block vector The similarity is calculated by cosine similarity:

[0083] Then, based on efficient vector retrieval algorithms (such as FAISS) In the query, we get The m most similar chapters are recorded as:

[0084] Among them, the user query vector and chapters The similarity is measured through and Summary The semantic vector , and vector The similarity is calculated by cosine similarity:

[0085] Then, in each chapter, we query the results based on an efficient vector retrieval algorithm (such as FAISS) and The k most similar text blocks, and summarize:

[0086] Finally, the summary is and Search results in:

[0087] The keyword-based search method process is as follows: The BM25 algorithm is used for keyword-based retrieval, and the relevance of text blocks is evaluated by calculating the match between the query term and the text block.

[0088] The BM25 score between the query and the text block is calculated as follows:

[0089] in: is a query, is a word in the query; is a block of text, Expressive words In the text block The frequency of words in ; Indicates the length of the text block, is the average length of the set of text blocks; Words The inverse document frequency of and is a tuning parameter, usually taken as and .

[0090] Based on the calculated BM25 score, get and query The k most similar text blocks are recorded as:

[0091] The total search result is the union of the search results obtained by the above two methods, namely:

[0092] Two-stage rearrangement The similarity between the query and the text block cannot be directly equated with the relevance (the text block contains the answer to the query). Therefore, the search results obtained in the previous step need to be re-ranked to filter out text blocks with stronger relevance.

[0093] Using the reranking model, we calculate the query and Relevance scores of candidate text blocks in :

[0094] in, The re-ranking model is usually a Cross-Encoder model with a Transformer architecture, which allows the query and candidate text blocks to interact through the self-attention mechanism in each layer of the model, thereby calculating the relevance score between the two.

[0095] According to the calculated relevance scores, the first k text blocks with the highest relevance scores are selected as the final retrieval results:

[0096] 3. Intelligent Answers Based on Large Language Model Retrieval Enhancement Input the user query question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; correct the preliminary intelligent answer information based on the preset self-reflection mechanism to obtain the final intelligent answer information; The rewritten user query and search results Fill in the following prompt word template , as the input of the large language model.

[0097] Please answer the questions based on the following reference information. Note: Answer based only on the following information and do not add any additional assumptions or knowledge.

[0098] Reference Information: 1. [c1] 2. [c2] … n. [c n ] question: [query]” Therefore, the input of the large language model is

[0099] The answer generated by the large language model is

[0100] Although the large language model has the search results as factual references when generating answers, there may still be "hallucinations" in the answers, that is, the factual content that does not appear in the reference information appears in the answer, or the factual content that contradicts the reference information appears in the answer. Therefore, the present invention proposes "answer correction based on self-reflection mechanism" to correct the answers generated by the large language model. The specific process is as follows.

[0101] The rewritten user query , Search Results , preset self-reflection mechanism and answers generated by large language models Fill in the following prompt word template , as the input of the large language model.

[0102] "Please correct your answer based on the following reference information and questions. Requirements: 1. Accuracy: Ensure that the corrected answer is consistent with the facts in the reference information and avoid introducing any content that does not appear in the reference information.

[0103] 2. Consistency: Check your answer for any inconsistencies with the reference information and make necessary adjustments.

[0104] 3. Completeness: If there are important facts in the reference information that are not mentioned in your answer, please provide relevant information to ensure the comprehensiveness of your answer.

[0105] 4. Clarity: Make sure the corrected answer is logically clear and easy to understand. Avoid using vague or complex expressions.

[0106] 5. Simplicity: While keeping the information complete, try to simplify the answer and remove redundant information to make it more concise and clear.

[0107] 6. Objectivity: Keep your answers objective and avoid subjective judgments or emotional expressions.

[0108] Reference Information: 1. [c1] 2. [c2] … n. [c n ] question: [query] answer: [response] Please directly output the corrected answer" At this time, the input of the large language model is

[0109] The final answer generated by the large language model is

[0110] The system displays the final answer to the user , do not display the output of the intermediate process .

[0111] In order to facilitate users to fact-check the content in the answer and enhance the persuasiveness and credibility of the answer, the source of the reference information is added as a citation after the final answer, and the following content is output: “The reference information sources are as follows: 1. d(c1) 2. d(c2) … n. d(c n )” Among them, d(c i ) is the text block c i The name of the document to which it belongs.

[0112] As a preferred implementation, in order to continuously improve and optimize this method, especially the accuracy of answers and user satisfaction, the present invention introduces a system optimization and user feedback mechanism. This mechanism is not only for long-term maintenance and improvement of the system, but also the key to ensure that the system can continue to evolve and optimize in practical applications.

[0113] According to the present invention, the system is optimized to obtain document data at a preset period, that is, to regularly update and expand the document data set. The technical documents and teaching materials in the power industry are frequently updated. In order to keep the system up to date, the system needs to regularly obtain the latest documents from authoritative data sources and add them to the document library. The addition of new documents needs to go through the same preprocessing and vectorization process as above to ensure that they can be smoothly integrated into the existing vector retrieval library.

[0114] Furthermore, the user feedback mechanism: uses the user's query log and feedback information to continuously train and optimize the large language model. By analyzing the user's query behavior, common query patterns and problem areas are identified, and thus, the large language model is specifically fine-tuned through a preset self-reflection mechanism. For example, if the system finds that the query frequency of a certain type of technical problem is high, but the accuracy of the answer is not ideal, the system can focus on optimizing this problem area, adjust the large language model parameters, or introduce specialized domain knowledge settings in the self-reflection mechanism to improve the accuracy of the answer.

[0115] According to the present invention, the user feedback mechanism is an important component of the continuous improvement of the system. After receiving the system answer, the user can evaluate the quality of the answer and provide detailed feedback. If the user thinks that the answer is not accurate or incomplete, the error information can be submitted through feedback. This method will mark the areas that need improvement based on these feedbacks and correct them in the subsequent large language model training. In addition, the application also introduces an expert review mechanism to manually review the error information marked in the user feedback to ensure that the model is updated in the correct direction.

[0116] See also Figure 2 , the application also discloses an intelligent question-answering system for electric power documents based on a large language model, including: A retrieval library construction unit is used to obtain document data according to a preset period; pre-process the document data to obtain an adaptive document; and construct a vector retrieval library based on the adaptive document through an embedding model; A retrieval unit is used to obtain a user query question, input the user query question into a preset vector retrieval library, search the vector retrieval library based on vector similarity and keyword retrieval methods, obtain relevant text blocks, and select the most relevant text block from the relevant text blocks through a two-stage rearrangement technology; The intelligent generation unit is used to input the user query question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; the preliminary intelligent answer information is corrected based on a preset self-reflection mechanism to obtain final intelligent answer information.

[0117] The present application also discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for intelligent question and answer of electric power documents based on a large language model are implemented in any one of the above-mentioned items.

[0118] The present application also discloses a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the method for intelligent question and answer of electric power documents based on a large language model are implemented.

[0119] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0120] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0121] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. An intelligent question-answering method for power documents based on a large language model, characterized in that: include: Acquire document data according to a preset cycle; pre-process the document data to obtain an adaptive document; build a vector retrieval library based on the adaptive document through an embedding model; Obtain user query questions, input the user query questions into a vector retrieval library, search the vector retrieval library based on a vector similarity retrieval method and a keyword retrieval method, obtain relevant text blocks, and select the most relevant text blocks from the relevant text blocks through a two-stage rearrangement technology; Input the user query and the most relevant text block into the large language model to obtain preliminary intelligent answer information; The preliminary intelligent answer information is corrected based on a preset self-reflection mechanism to obtain the final intelligent answer information.

2. According to claim 1, a method for intelligent question answering of electric power documents based on a large language model is characterized in that: The acquiring of document data according to a preset period specifically includes: acquiring the latest document according to a preset period, and adding the latest document to the original document to form the document data; The preprocessing includes: document data parsing, document content extraction, document content denoising and document content word segmentation processing.

3. According to claim 1, a method for intelligent question answering of electric power documents based on a large language model is characterized in that: The step of constructing a vector retrieval library based on the adaptive document through an embedding model specifically includes: Perform fixed-length block division and hierarchical block division on the adaptive document to obtain corresponding text blocks; Using a text embedding model fine-tuned with the power field corpus, each text block is converted into a semantic vector to obtain a vector retrieval library.

4. The method for intelligent question answering of electric power documents based on a large language model according to claim 1, characterized in that: The step of obtaining a user query question, inputting the user query question into a preset vector search library, searching the vector search library based on vector similarity and keyword search methods to obtain a set of related text blocks, and screening out the most relevant text block from the set of related text blocks through a two-stage rearrangement technology specifically includes: S101: Obtain a user query question, and rewrite the user query question to obtain a rewritten query question; S102: Based on the vector similarity and keyword-based retrieval method, the rewritten query question is input into a preset vector retrieval library for preliminary retrieval to obtain a set of related text blocks; S103: reordering the set of related text blocks based on the two-stage reordering technology to obtain reordered related text blocks, and screening the reordered related text blocks to obtain the most relevant text blocks.

5. The method for intelligent question answering of electric power documents based on a large language model according to claim 4, characterized in that: The retrieval method based on vector similarity in S102 specifically includes: Use the text embedding model to convert the rewritten query question into a user query vector : Based on the efficient vector retrieval algorithm, in the preset vector retrieval library, for the set of text blocks divided by length, k related text blocks divided by length are queried: Based on the efficient vector retrieval algorithm, in the preset vector retrieval library, for the hierarchical and block-based text block set, m chapters are queried: In each chapter, based on an efficient vector retrieval algorithm, k hierarchical blocks of relevant text are obtained by query: Summarize the search results: in, Query vector for user; For text embedding models; To rewrite the query question; A collection of related text blocks divided into length blocks, The relevant text block for the k-th length block; is the mth chapter; The relevant text block for the k-th hierarchical segmentation; is a set of text blocks related by vector similarity.

6. The method for intelligent question answering of electric power documents based on a large language model according to claim 4, characterized in that: The keyword-based search method in S102 specifically includes: Using the BM25 algorithm, the BM25 score is obtained by calculating the match between the query term and the text block. The formula is as follows: Based on the calculated BM25 score, k keyword-related text blocks are obtained, denoted as: in: is a word in the user query vector; is a block of text, Expressive words In the text block The frequency of words in ; Indicates the length of the text block, is the average length of the set of text blocks; Words The inverse document frequency of and is the adjustment parameter; A collection of keyword-related text blocks; is the k-th keyword related text block.

7. The method for intelligent question answering of electric power documents based on a large language model according to claim 1, characterized in that: The user query question and the most relevant text block are input into the large language model to obtain preliminary intelligent answer information; The preliminary intelligent answer information is corrected based on the preset self-reflection mechanism to obtain the final intelligent answer information, which specifically includes: 201: Fill the user query question and the most relevant text block into the large language model prompt word template In the example above, the large language model is used as the input to obtain preliminary intelligent answer information. 202: Fill the user query question, the most relevant text block, the preliminary intelligent answer information and the preset self-reflection mechanism into the large language model prompt word template In the example above, the word “intelligent” is used as the input of the large language model to obtain the final intelligent answer information.

8. An intelligent question-answering system for power documents based on a large language model, characterized in that: include: A retrieval library construction unit is used to obtain document data according to a preset period; pre-process the document data to obtain an adaptive document; and construct a vector retrieval library based on the adaptive document through an embedding model; A retrieval unit is used to obtain a user query question, input the user query question into a preset vector retrieval library, search the vector retrieval library based on vector similarity and keyword retrieval methods, obtain relevant text blocks, and select the most relevant text block from the relevant text blocks through a two-stage rearrangement technology; An intelligent generation unit, which is used to input the user query question and the most relevant text block into the large language model to obtain preliminary intelligent answer information; The preliminary intelligent answer information is corrected based on a preset self-reflection mechanism to obtain the final intelligent answer information.

9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for intelligent question and answer of electric power documents based on a large language model as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method for intelligent question answering of electric power documents based on a large language model as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Intelligent question answering method, device and equipment based on combination of large model and knowledge graph

    CN119807386A

  • IFC data analysis method and device, equipment, storage medium and program product

    CN119962521A

  • Intelligent question and answer method and system, electronic equipment and intelligent question and answer big model

    CN119988573A

  • Rice disease and insect pest question-answering method based on circular retrieval

    CN120196727A

  • RAG-based electric power communication management file assisted compilation method and system

    CN120234405A