Knowledge base construction, knowledge question answering processing method and device

By hierarchically dividing the original documents and constructing vector data, the index path is optimized, which solves the problem of low retrieval efficiency in existing technologies, achieves faster information positioning and higher recall rate, and improves the accuracy and efficiency of the knowledge question-answering system.

CN120373439BActive Publication Date: 2025-10-03HEFEI ZHONGKE LEINAO INTELLIGENCE TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510842962.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2025-10-03
Estimated Expiration
2045-06-23

AI Technical Summary

Technical Problem

In existing knowledge question-answering systems, the retrieval efficiency based on retrieval enhancement generation technology needs to be improved, especially in the power industry, where target information cannot be quickly located and the recall rate of relevant documents is low.

Method used

By dividing the original documents into levels, constructing texts at different retrieval levels and building corresponding vector data, we can optimize the index path, implement hierarchical filtering, avoid full database scanning, and improve retrieval speed.

Benefits of technology

It improves the speed of knowledge retrieval and the efficiency of key document recall, enhances the system's ability to understand user intent, and improves the accuracy and credibility of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120373439B_ABST
    Figure CN120373439B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of retrieval optimization technology, and discloses a method and device for constructing a knowledge base and processing knowledge questions and answers. The method comprises: obtaining an original document; dividing the original document according to a preset hierarchical division method to obtain a first retrieval-level text and a second retrieval-level text; wherein the first retrieval-level text is retrieved before the second retrieval-level text; constructing first vector data based on the first retrieval-level text, and constructing second vector data based on the second retrieval-level text; and constructing a knowledge base based on the first vector data and the second vector data. Thus, by performing hierarchical division processing on the original document, the index path is optimized, effectively improving retrieval efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of retrieval optimization technology, and in particular to a method and device for constructing a knowledge base and processing knowledge questions and answers. Background Art

[0002] With the rapid development of intelligent equipment and large language models, knowledge question-answering systems based on information retrieval technology have been widely used, helping users improve problem-solving efficiency to a certain extent. Ensuring the accuracy of answers in knowledge question-answering systems is crucial for users to quickly and accurately solve problems.

[0003] In order to improve the accuracy of answers in knowledge question-answering systems, related technologies have been used to enhance the answering capabilities of language models. However, the retrieval efficiency of related technologies based on retrieval enhancement generation needs to be improved. Summary of the Invention

[0004] The present invention aims to solve, at least to some extent, one of the technical problems in the related art. To this end, the present invention proposes a method and apparatus for constructing a knowledge base and processing knowledge questions and answers, which optimizes the index path and improves retrieval efficiency by hierarchically dividing the original documents.

[0005] To achieve the above-mentioned purpose, the first aspect of the present invention proposes a knowledge base construction method, which includes: obtaining an original document; dividing the original document according to a preset hierarchical division method to obtain a first retrieval level text and a second retrieval level text; wherein the retrieval order of the first retrieval level text is before the second retrieval level text; constructing first vector data based on the first retrieval level text, and constructing second vector data based on the second retrieval level text; and constructing a knowledge base based on the first vector data and the second vector data.

[0006] According to one embodiment of the present invention, the original document is divided according to a preset hierarchical division method to obtain a first retrieval level text and a second retrieval level text, including: determining the first classification domain and the second classification domain corresponding to the original document according to the preset hierarchical division method; parsing the original document to determine the first retrieval level text under the first classification domain and the second retrieval level text under the second classification domain; wherein the granularity of the second retrieval level text is smaller than the granularity of the first retrieval level text.

[0007] According to one embodiment of the present invention, the first retrieval level text corresponds to a first position index, and / or the second retrieval level text corresponds to a second position index; the first position index is used to indicate the position of the original text content corresponding to the first retrieval level text in the original document; the second position index is used to indicate the position of the original text content corresponding to the second retrieval level text in the original document.

[0008] According to one embodiment of the present invention, there is a first mapping relationship between the first vector data and the second vector data; before constructing the knowledge base based on the first vector data and the second vector data, the knowledge base construction method also includes: determining the third classification domain corresponding to the original document according to the preset hierarchical division method; parsing the original document to obtain a third retrieval level text under the third classification domain; wherein the retrieval order of the second retrieval level text is before the third retrieval level text; the granularity of the third retrieval level text is smaller than the granularity of the second retrieval level text; constructing third vector data based on the third retrieval level text; wherein, there is a second mapping relationship between the second vector data and the third vector data; constructing the knowledge base based on the first vector data and the second vector data includes: constructing the knowledge base based on the first vector data, the second vector data, the first mapping relationship, the third vector data and the second mapping relationship.

[0009] According to one embodiment of the present invention, the preset hierarchical division method is determined according to the field to which the original document belongs; the first retrieval level text is determined according to the document-level content of the original document; the second retrieval level text is determined according to the chapter-level content of the original document; and the third retrieval level text is determined according to the paragraph-level content of the original document.

[0010] According to one embodiment of the present invention, the original document has corresponding value level information, and the value level information is used to determine the retrieval priority corresponding to the original document; the knowledge base contains the value level information corresponding to the original document.

[0011] According to one embodiment of the present invention, the original document also corresponds to a confidentiality level; constructing the knowledge base based on the first vector data and the second vector data includes: constructing the knowledge base based on the first vector data, the second vector data and the confidentiality level.

[0012] To achieve the above-mentioned purpose, the second aspect of the present invention proposes a knowledge question and answer processing method, which includes: obtaining question text data; in the knowledge base constructed according to the knowledge base construction method described in any of the aforementioned embodiments, searching the question text data according to the retrieval order of the retrieval hierarchical text to obtain a first retrieval result; generating a first answer text corresponding to the question text data based on the first retrieval result.

[0013] According to one embodiment of the present invention, the knowledge question and answer processing method further includes: determining the target original document corresponding to the first retrieval result based on the first retrieval result; and generating a text attachment corresponding to the first retrieval result based on the first retrieval result and the target original document.

[0014] According to one embodiment of the present invention, the first search result corresponds to a first search scope; the knowledge question and answer processing method also includes: evaluating the first answer text to obtain an evaluation result; if the evaluation result does not meet the preset conditions, determining a second search scope based on the first search scope; based on the second search scope, searching the question text data in the knowledge base to obtain a second search result, so as to generate a second answer text based on the second search result.

[0015] According to one embodiment of the present invention, the question text data is obtained by vectorizing original question data, and the original question data includes at least one of text data, image data, and voice data.

[0016] To achieve the above-mentioned purpose, the third aspect of the present invention proposes a knowledge base construction device, which includes: an original document acquisition module for acquiring original documents; a retrieval level text acquisition module for dividing the original documents according to a preset level division method to obtain a first retrieval level text and a second retrieval level text; wherein the retrieval order of the first retrieval level text is before the second retrieval level text; a vector data construction module for constructing first vector data based on the first retrieval level text, and constructing second vector data based on the second retrieval level text; a knowledge base construction module for constructing a knowledge base based on the first vector data and the second vector data.

[0017] To achieve the above-mentioned purpose, the fourth aspect of the present invention proposes a knowledge question and answer processing device, which includes: a question text acquisition module for acquiring question text data; a retrieval result acquisition module for searching the question text data in the knowledge base constructed according to the knowledge base construction method described in any of the above-mentioned embodiments according to the retrieval order of the retrieval hierarchical text to obtain a first retrieval result; and an answer text generation module for generating a first answer text corresponding to the question text data based on the first retrieval result.

[0018] According to multiple embodiments provided by the present invention, the original documents are hierarchically divided according to preset standards or rules, for example, the hierarchical division is performed according to the importance, authority or timeliness of the document, or the hierarchical division is performed according to the structure of the document itself, and different retrieval orders (or retrieval priorities) are assigned to texts at different retrieval levels. In this way, during the knowledge retrieval process, retrieval is performed according to the retrieval order of different retrieval levels, hierarchical filtering is achieved, full library scanning is avoided, the index path is optimized, and the most relevant information is located faster, thereby improving the retrieval speed and the efficiency of recalling key documents.

[0019] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 The present invention is a flowchart of a method for constructing a knowledge base according to an embodiment of the present invention.

[0021] Figure 2 The present invention provides a flowchart of dividing an original document according to an embodiment of the present invention.

[0022] Figure 3a A flowchart of another knowledge base construction method provided according to an embodiment of this specification.

[0023] Figure 3b A schematic diagram of a hierarchical structure of domain layers provided according to an embodiment of this specification.

[0024] Figure 4 A flowchart of a knowledge question and answer processing method provided according to an embodiment of this specification.

[0025] Figure 5 A flowchart of another knowledge question and answer processing method provided according to an embodiment of this specification.

[0026] Figure 6 This is a flowchart of another knowledge question and answer processing method provided according to the implementation method of this specification.

[0027] Figure 7a A schematic structural diagram of an improved power scenario RAG system provided according to an embodiment of this specification.

[0028] Figure 7b A schematic diagram of a scoring-expansion inspection process provided according to an embodiment of this specification.

[0029] Figure 7c A schematic diagram of a federated data processing method provided according to an implementation of this specification.

[0030] Figure 7d A flowchart of an improved power scenario RAG method provided according to an embodiment of this specification. DETAILED DESCRIPTION

[0031] The following describes embodiments of the present invention in detail, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and are not to be construed as limiting the present invention.

[0032] With the rapid development of artificial intelligence (AI), particularly the increasing maturity and widespread adoption of intelligent equipment and large language models, AI has gradually become ubiquitous across all industries and into our daily lives. In this context, AI has not only improved information processing efficiency but also significantly enhanced the ability to solve complex problems. For example, in industries such as electricity, transportation, healthcare, and finance, knowledge question-answering systems based on information retrieval technology have been used for decision support, intelligent question answering, and fault diagnosis, significantly improving work efficiency.

[0033] In the application of knowledge question answering systems, ensuring the accuracy of answers is of great significance for users to solve problems quickly and accurately. In related technologies, the answering ability of language models is enhanced by applying retrieval enhancement generation technology in knowledge question answering systems.

[0034] Retrieval-Augmented Generation (RAG) is an artificial intelligence technology framework that combines retrieval systems with generative models. Its core is to enhance the answering capabilities of language models through dynamic retrieval of external knowledge bases. It is suitable for scenarios that require processing large-scale unstructured data and generating accurate responses. The RAG system has many advantages. For example, it relies on vector databases or document retrieval systems to store external knowledge, supports the model to call real-time or historical data, and solves the problem that traditional large models cannot update dynamic information. It separates the "information retrieval" and "content generation" processes, first locating relevant document fragments through the retrieval module, and then the generative model integrates the information to form an answer. By retrieving real documents to support the answer, it reduces the illusion of large models and improves the accuracy and traceability of the results. It is compatible with multi-domain knowledge bases and supports specific adjustments to meet the needs of vertical industries. It has been initially applied in fields such as medicine, law, and finance.

[0035] Take the power industry as an example. Electricity is ubiquitous in modern life, and ensuring the safe and stable operation of power systems is crucial. Power workers face complex and diverse daily operations and maintenance tasks, requiring quick access to accurate technical support and troubleshooting guidance. Applying AI question-answering systems to the power industry can help frontline production personnel quickly resolve issues. Applying RAG automated text-enhanced dialogue to a large power industry model significantly improves the accuracy of answers, providing greater convenience for power industry workers and ultimately enhancing overall efficiency.

[0036] However, related RAG technologies typically employ a centralized knowledge base architecture and a flat vector retrieval method based on chunk embedding. This lacks refined hierarchical management and retrieval mechanisms, resulting in poor timeliness and limited coverage of knowledge retrieval. This inability to quickly locate target information during retrieval results in low recall rates for relevant documents. Therefore, the efficiency of knowledge retrieval based on retrieval-enhanced generation technology needs to be improved.

[0037] In order to improve the efficiency of knowledge retrieval, it is necessary to propose a knowledge base construction, knowledge question and answer processing method and device. In the knowledge base construction method provided in this specification, the original document is divided into the first retrieval level text and the second retrieval level text under different retrieval levels according to a preset hierarchical division method, and then the corresponding vector data are constructed based on the texts under different retrieval levels, that is, the corresponding first vector data is obtained based on the first retrieval level text, and the corresponding second vector data is obtained based on the second retrieval level text, so as to construct a knowledge base based on the first vector data and the second vector data. Among them, the retrieval order of the first retrieval level text is before the second retrieval level text, that is, the retrieval order of the first vector data is before the second vector data.

[0038] Therefore, by dividing the original documents into levels according to preset standards or rules, for example, dividing them into levels according to the importance, authority or timeliness of the documents, or dividing them into levels according to the structure of the documents themselves, and assigning different retrieval orders (or retrieval priorities) to texts at different retrieval levels, retrieval can be performed according to the retrieval order of different retrieval levels during the knowledge retrieval process, realizing hierarchical filtering, avoiding full database scanning, optimizing the index path, and facilitating faster location of the most relevant information, thereby improving retrieval speed and the efficiency of recalling key documents.

[0039] This specification provides a method for building a knowledge base. Figure 1 As shown, the knowledge base construction method may include the following steps.

[0040] S110: Obtain the original document.

[0041] S120 , dividing the original document according to a preset hierarchical division method to obtain a first retrieval level text and a second retrieval level text; wherein the retrieval order of the first retrieval level text is before the second retrieval level text.

[0042] S130 : Constructing first vector data based on the first retrieval level text, and constructing second vector data based on the second retrieval level text.

[0043] S140: Build a knowledge base based on the first vector data and the second vector data.

[0044] The first search level text is the text at the first search level, and the second search level text is the text at the second search level. The first search level text is searched before the second search level text, meaning that during the information retrieval process, the first search level text is searched first, followed by the second search level text.

[0045] The original documents can be divided according to a preset hierarchical division method. Different original documents can be divided into different retrieval levels, and the retrieval level text can be obtained based on the corresponding entire original document. Alternatively, the content of the same original document can be divided into different retrieval levels, and the retrieval level text can be obtained based on the content of the corresponding part in the original document.

[0046] Vector data is a data form used to represent text features and can describe the semantic information in the text.

[0047] Specifically, first collect and organize the original documents that need to be included in the knowledge base. These original documents can include various forms of text materials, such as operating manuals, technical documents, guides, papers, logs, etc. Divide the original documents according to the preset hierarchical division method to obtain texts at different retrieval levels, including the first retrieval level text under the first retrieval level and the second retrieval level text under the second retrieval level. The preset division method can be determined based on the importance, authority, frequency of use, update frequency, etc. of the document, or it can be determined based on the document structure, etc. Among them, the retrieval order of the first retrieval level text is before the second retrieval level text, which means that the first retrieval level text has a higher retrieval priority and will be retrieved before the second retrieval level text during the information retrieval process.

[0048] The first search level text is vectorized to construct first vector data, and the second search level text is vectorized to construct second vector data. The first and second vector data are used to construct a final knowledge base, which can serve as the foundation for functions such as information query and question answering in the knowledge question answering system.

[0049] In some embodiments, the preset division method can be determined based on the importance, authority, timeliness, frequency of use, update cycle, etc. of the document.

[0050] Exemplarily, a preset division method is determined based on authority, and corresponding documents with an authority level greater than or equal to a threshold are divided into a first retrieval level, and corresponding documents with an authority level less than the threshold are divided into a second retrieval level; a preset division method is determined based on importance and update frequency, and corresponding documents with an importance level greater than or equal to the importance level threshold and an update cycle less than or equal to the update cycle threshold are divided into the first retrieval level, and corresponding documents with an importance level less than the importance level threshold and an update cycle greater than the update cycle threshold are divided into the second retrieval level.

[0051] Furthermore, in some cases, any method such as a dynamic weight tree can be used to determine the importance of different documents, or any method such as a time decay model can be used to determine the timeliness of different documents, which can be used as the basis for hierarchical division, thereby realizing hierarchical division of original documents based on a dynamic weight tree or a time decay model.

[0052] In other embodiments, the preset division method may be determined based on the technical fields included in the document.

[0053] For example, a standard document for power transmission line inspection technology includes the following technical fields: equipment-related, operations-related, and safety-related. Each technical field can also include sub-fields at the next level. For example, the equipment-related field can further include equipment failure sub-fields and equipment maintenance sub-fields. Based on this field division, the original document can be divided, with corresponding first-level search text determined based on equipment-related, operations-related, and safety-related content. For example, for the equipment-related field, corresponding second-level search text can be determined based on equipment failure-related and equipment maintenance-related content.

[0054] It should be noted that by dividing the original document according to the preset hierarchical division method, a third search level text, a fourth search level text, and so on can also be obtained. The specific number of levels can be determined based on the actual application scenario or requirements, as long as the different search level texts have a retrieval order relationship. The specific preset hierarchical division method can be determined based on actual application requirements and is not specifically limited in this specification.

[0055] In the above-described embodiment, by hierarchically dividing the original document according to a preset hierarchical division method, texts at different retrieval levels are obtained, and the retrieval order of texts at different retrieval levels is different. This allows retrieval to be performed according to the retrieval order of the retrieval levels during the knowledge retrieval process, achieving hierarchical indexing of documents, facilitating faster location of the most relevant information, and thereby improving retrieval speed. At the same time, the hierarchical division method facilitates hierarchical data management, and the vector representation method helps the system more accurately understand the user's query intent and retrieve the most relevant answers from the knowledge base, thereby improving the quality and credibility of knowledge retrieval.

[0056] In some embodiments, reference Figure 2 As shown, dividing the original document according to a preset hierarchical division method to obtain a first retrieval level text and a second retrieval level text may include the following steps.

[0057] S210: Determine a first classification domain and a second classification domain corresponding to the original document according to a preset hierarchical division method.

[0058] S220: Parse the original document to determine a first retrieval level text under the first classification domain and a second retrieval level text under the second classification domain; wherein the granularity of the second retrieval level text is smaller than the granularity of the first retrieval level text.

[0059] The classification domain refers to the classification standard or the knowledge or data category divided according to specific rules, which can be used to semantically classify the document content.

[0060] The first classification domain corresponds to the first search level, and the second classification domain corresponds to the second search level.

[0061] Granularity refers to the level of sophistication of text content or the richness of detail it contains. The granularity of text at the second search level is smaller than that of text at the first search level, meaning that text at the second search level contains more details and finer content than text at the first search level. In other words, text at the first search level contains coarse-grained knowledge units, while text at the second search level contains fine-grained, specific knowledge content.

[0062] Specifically, for any original document, the first and second classification domains corresponding to the original document can first be determined based on a preset hierarchical division method. Next, the original document can be parsed to extract coarse-grained information related to the first classification domain as the first retrieval-level text corresponding to the original document, and fine-grained information (relatively finer than the granularity of the first retrieval-level text) related to the second classification domain can be extracted from the original document as the second retrieval-level text.

[0063] Furthermore, a first mapping relationship (i.e., an association relationship between content in the original document) exists between first vector data constructed based on the first search level text and second vector data constructed based on the second search level text. That is, corresponding data in the second vector data can be found from a certain first vector data. Constructing a knowledge base based on the first vector data and the second vector data further includes: constructing a knowledge base based on the first vector data, the second vector data, and the first mapping relationship.

[0064] In some embodiments, the preset division method can be determined according to the technical field to which the document belongs.

[0065] For example, for a transmission line detection technical standard document, the technical field to which it belongs is the transmission field, and the transmission field can be used as the first classification domain. The transmission field also includes sub-fields, such as the equipment sub-field, operation sub-field, safety sub-field, etc., and the equipment sub-field, operation sub-field, safety sub-field, etc. can be used as the second classification domain. When parsing the document, coarse-grained information can be extracted from at least one of the document title, introduction, abstract, etc. to obtain the corresponding first retrieval level text, and fine-grained information can be extracted from the equipment-related content, operation-related content, safety-related content, etc. in the document to obtain the corresponding second retrieval level text, or the equipment-related content, operation-related content, safety-related content, etc. in the document can be used as the second retrieval level text.

[0066] In other embodiments, the preset hierarchical division method can be to first perform a first retrieval hierarchical division based on the title in the original document or the field to which the original document belongs, and then perform a second hierarchical division based on the structure of the original document (chapter, paragraph, chart, formula, etc.). The first classification domain can be determined based on the document title of the original document or the field to which the original document belongs, and the second classification domain can be determined based on the chapter or paragraph of the original document.

[0067] For example, the original document is about an emergency plan for a substation main transformer trip. Based on the document title, a first-level search classification can be performed to determine the first classification domain as "emergency response." Alternatively, based on the document's field, a first-level search classification can be performed to determine the first classification domain as "substation." Parsing this document can extract coarse-grained information from at least one of the document's title, introduction, and abstract to obtain the corresponding first-level search text.

[0068] Assuming that the document contains chapters on accident handling principles and main transformer tripping handling procedures, it can be determined that the second classification domain includes "handling principles" and "handling procedures". By parsing the document, fine-grained information can be extracted from the content of the corresponding chapters to obtain the corresponding second retrieval level text, or the content in the chapter can be used as the corresponding second retrieval level text.

[0069] For example, the original document is a substation equipment maintenance manual, which includes content such as "Chapter 1, Transformer Maintenance Procedures," "Chapter 2, Circuit Breaker Operating Specifications," and "Chapter 3, Fault Emergency Handling Procedures." Based on the titles in the document, a first search level division can be performed to determine that the first classification domain includes "transformer," "circuit breaker," and "emergency handling." Assuming that the transformer maintenance procedures section in the document includes content such as "Insulating Oil Sampling Procedures" and "Bushing Infrared Temperature Measurement Standards," the second classification domain can be determined to include "Insulating Oil Sampling" and "Bushing Temperature Measurement."

[0070] In some other embodiments, the preset hierarchical division method can be to first perform a first retrieval hierarchical division based on the document type of the original document, and then perform a second hierarchical division based on the structure of the original document. The first classification domain can be determined based on the document type of the original document, and the second classification domain can be determined based on the chapter or paragraph of the original document.

[0071] For example, if the original document is a technical standard document, the first classification domain can be determined as the technical standard category, and the second classification domain can include general principles, technical requirements, test methods, etc.; if the original document is a journal article, the first classification domain can be determined as the article category, and the second classification domain can be obtained by chapter division; if the original document is a log document, the first classification domain can be determined as the log category, and the second classification domain can be obtained according to the specific event type or operation type recorded in the log.

[0072] It should be noted that the specific method for determining the first and second classification domains corresponding to the original document based on the preset hierarchical division method can be determined based on actual application scenarios or needs, and is not specifically limited in this specification. The parsing method can be implemented through methods such as title recognition and semantic segmentation, which are not specifically limited in this specification.

[0073] In the above implementation, by converting the original document into a hierarchical knowledge system, the system can first quickly locate relevant coarse-grained information at a high level, and then delve into the corresponding fine-grained information at a lower level. This reduces the performance loss caused by the flat, full-scale search in related technologies, enhances the system's ability to understand user intent and match correct answers, and thus helps improve the efficiency of knowledge retrieval and solve the problem of balancing retrieval accuracy and timeliness. At the same time, this hierarchical design makes the knowledge base content easy to expand, replace, and version control, which can meet different knowledge update needs.

[0074] In some embodiments, the first search-level text corresponds to a first position index, and / or the second search-level text corresponds to a second position index. The first position index is used to indicate the location of the original text content corresponding to the first search-level text in the original document; the second position index is used to indicate the location of the original text content corresponding to the second search-level text in the original document.

[0075] Among them, the position index records the physical or logical position of the retrieval level text in the corresponding original document, which is used to achieve rapid tracing from the retrieval results to the original text.

[0076] Specifically, for each first-level retrieval text, a corresponding first position index may be established to record the physical or logical position of the text at that level in the original document, such as page number, paragraph number, coordinates, etc. And / or, for each second-level retrieval text, a corresponding second position index may be established to record the physical or logical position of the text at that level in the original document.

[0077] If the first retrieval level text corresponds to a first position index, or the second retrieval level text corresponds to a second position index, then during knowledge retrieval, the retrieval results can be traced back to the position in the original document pointed to by the first position index or the second position index, thereby locating the corresponding original text.

[0078] If the first retrieval level text corresponds to a first position index, and the second retrieval level text corresponds to a second position index, then during knowledge retrieval, if the second retrieval level is retrieved, the position in the original document pointed to by the second position index can be traced back based on the retrieval results; if only the first retrieval level is retrieved, the position in the original document pointed to by the first position index can be traced back based on the retrieval results, thereby locating the corresponding original text.

[0079] Furthermore, in the knowledge question and answer system, based on the location index, the content of the original text in the original document pointed to by the location index can be returned to the user as part of the answer in the form of reference or attachment. For example, the content of the original text can be displayed in the form of screenshots or PDF (Portable Document Format).

[0080] In the above implementation, a traceability mechanism can be implemented by introducing a location index. When knowledge retrieval is performed using the constructed knowledge base, it supports rapid tracing and positioning of the source document content based on the retrieval results, and builds a trusted link from the original knowledge to the answer generation. Compared with the non-traceable solutions in related technologies that cannot locate the original documents, this is more credible.

[0081] In some embodiments, the first vector data and the second vector data have a first mapping relationship. Figure 3a As shown, before constructing the knowledge base according to the first vector data and the second vector data, the knowledge base construction method may further include:

[0082] S310: Determine a third classification domain corresponding to the original document according to a preset hierarchical division method.

[0083] S320. Parse the original document to obtain a third retrieval level text under a third classification domain; wherein the retrieval order of the second retrieval level text is before the third retrieval level text; and the granularity of the third retrieval level text is smaller than that of the second retrieval level text.

[0084] S330. Construct third vector data based on the third retrieval level text; wherein a second mapping relationship exists between the second vector data and the third vector data.

[0085] Accordingly, constructing a knowledge base based on the first vector data and the second vector data may include:

[0086] S340: Construct a knowledge base according to the first vector data, the second vector data, the first mapping relationship, the third vector data, and the second mapping relationship.

[0087] The first mapping relationship is used to indicate that there is an association between the first vector data and at least one second vector data, that is, at least one second vector data can be found from the specified first vector data.

[0088] The first mapping relationship may be determined according to the relationship between the first retrieval level text and the second retrieval level text in the document hierarchy (or the logical relationship in terms of content).

[0089] The third classification domain corresponds to the third search level.

[0090] The second mapping relationship is used to indicate that the second vector data is associated with at least one third vector data.

[0091] Specifically, for any original document, based on the aforementioned determination of the first and second classification domains corresponding to the original document according to the preset hierarchical division method, a third classification domain can be further determined. By parsing the original document, coarse-grained information related to the first classification domain can be extracted from the original document to serve as the first retrieval-level text corresponding to the original document, medium-grained information related to the second classification domain can be extracted to obtain the second retrieval-level text, and fine-grained information related to the third classification domain can be extracted to obtain the third retrieval-level text. It should be understood that the first retrieval-level text, the second retrieval-level text, and the third retrieval-level text have a logical relationship in terms of content.

[0092] The first vector data is constructed based on the first retrieval level text, the second vector data is constructed based on the second retrieval level text, and the third vector data is constructed based on the third retrieval level text. According to the logical relationship in content between the first retrieval level text, the second retrieval level text, and the third retrieval level text, a first mapping relationship between the first vector data and the second vector data, and a second mapping relationship between the second vector data and the third vector data can be determined. Then, the knowledge base can be constructed based on the first vector data, the second vector data, the first mapping relationship, the third vector data, and the second mapping relationship.

[0093] For example, the original document is a substation equipment maintenance manual, which includes "Chapter 1, Transformer Maintenance Procedures," "Chapter 2, Circuit Breaker Operating Specifications," and "Chapter 3, Fault Emergency Response Procedures." Based on the first classification domain being "Substation Operation and Maintenance," and the second classification domain including "Transformer," "Circuit Breaker," and "Fault Emergency," a third classification domain is further determined. Taking the "Transformer" classification domain as an example, assuming that this domain includes fine-grained subdomains for insulating oil sampling and bushing infrared temperature measurement, it can be determined that the third classification domain includes "insulating oil sampling" and "bushing temperature measurement."

[0094] When parsing the document, the document can be divided according to the document structure, and then coarse-grained information can be extracted from the title, abstract, or general provisions of the document to obtain the first retrieval level text under the first classification domain; taking "transformer" in the second classification domain as an example, medium-grained information can be extracted from the content of the chapter to obtain the second retrieval level text under the second classification domain; and taking "insulating oil sampling" in the third classification domain as an example, fine-grained information can be extracted from the paragraph content to obtain the third retrieval level text under the third classification domain, or the paragraph content can be used as the third retrieval level text.

[0095] For example, the original document is a technical standards document. Based on the first classification domain being the technical standards category and the second classification domain being the general principles, technical requirements, and test methods, a third classification domain is further defined. Taking technical requirements as an example, assuming that this section includes technical requirements for different devices, the third classification domain can include different device types. The description of parsing the document to obtain text at each search level is similar to that in the above example and will not be repeated in detail.

[0096] Furthermore, the first retrieval level text corresponds to a first position index, and / or the second retrieval level text corresponds to a second position index, and / or the third retrieval level text corresponds to a third position index. The first position index is used to indicate the location of the original text content corresponding to the first retrieval level text in the original document; the second position index is used to indicate the location of the original text content corresponding to the second retrieval level text in the original document; and the third position index is used to indicate the location of the original text content corresponding to the third retrieval level text in the original document.

[0097] It should be noted that the specific method of determining the first classification domain, second classification domain and third classification domain corresponding to the original document according to the preset hierarchical division method can be determined according to actual application scenarios or needs, and is not specifically limited in this specification.

[0098] In the above implementation, by dividing the original document into multiple levels, constructing multi-level vector data and mapping relationships, and forming a "pyramid-shaped" knowledge acquisition path, a knowledge base solution with both retrieval efficiency and depth is provided, which can effectively balance retrieval accuracy and timeliness. Compared with the flat knowledge base in related technologies, it can effectively solve the problems of poor retrieval timeliness and limited coverage, and effectively improve the efficiency of knowledge retrieval.

[0099] In some embodiments, the preset hierarchical division method is determined based on the field to which the original document belongs; the first search level text is determined based on the document-level content of the original document; the second search level text is determined based on the chapter-level content of the original document; and the third search level text is determined based on the paragraph-level content of the original document.

[0100] Among them, document-level content refers to content that can reflect the overall theme or purpose of the document, such as the abstract, document subject name, etc.

[0101] Chapter-level content refers to the content that reflects the main theme of a chapter after the document is structured by chapters. It has a more detailed description than document-level content, such as chapter titles, chapter text content, etc.

[0102] Paragraph-level content refers to the content of a paragraph after a document (or chapter in a document) is structurally divided into paragraphs, which can include paragraph text, charts, formulas, etc.

[0103] Specifically, a preset hierarchical division method is set based on the professional field or subject field involved in the original document. Then, the first classification domain, the second classification domain, and the third classification domain can be determined based on the professional field or subject field involved in the original document. The second classification domain is a subdomain of the first classification domain, and the third classification domain is a subdomain of the second classification domain.

[0104] For the same original document, structural segmentation can be performed to obtain document-level content (such as the document's subject title, abstract, table of contents, or overview chapter content), chapter-level content (such as chapter titles and specific chapter content), and paragraph-level content (such as specific paragraphs, sentences, charts, formulas, etc.). Information extraction based on document-level content can yield text at the first retrieval level; information extraction based on chapter-level content can yield text at the second retrieval level; and information extraction based on paragraph-level content can yield text at the third retrieval level.

[0105] Exemplarily, domain stratification and structuring are performed on documents to construct a knowledge base based on the knowledge base hierarchical structure. Domain segmentation rules are set, and a three-level domain system is established. Documents in the knowledge base are divided into first-level domains (corresponding to the first classification domain in this specification) according to major industry categories. This is then further refined into second-level subdomains (corresponding to the second classification domain in this specification) and third-level fine-grained domains (corresponding to the third classification domain in this specification), constructing a knowledge base with a pyramid-like structure in the form of a first-level directory, a second-level directory, and a third-level directory.

[0106] Taking the power industry as an example, the first-level fields can include the power transmission field and the power distribution field. Figure 3b As shown, this domain includes subdomains such as facilities and equipment, management and operations, and safety and risk. The facilities and equipment subdomain also includes the fine-grained domain of equipment failure, obsolescence, and maintenance. The management and operations subdomain also includes the fine-grained domain of project management and resource allocation. The safety and risk subdomain also includes the fine-grained domain of risk assessment. Therefore, based on this domain division, a three-tiered domain system can be established: "major professional domain - medium-grained subdomain - fine-grained domain."

[0107] Taking the equipment subdomain as an example, the corresponding medium-granularity subdomain can be defined as the equipment type subdomain, with equipment types such as insulators and conductors. Specifically, content related to equipment types such as insulators and conductors can be extracted from the original documents to obtain the search-level text under the equipment type subdomain. The corresponding fine-grained domain under the equipment type subdomain can be defined as the problem type fine-grained domain, with problem types such as corrosion detection and mechanical damage.

[0108] Long documents in the power transmission field are structured. For example, technical standards documents can be divided into chapters according to the "General Principles - Technical Requirements - Test Methods" structure. Research reports can also be automatically extracted into paragraph units according to the "Problem Description - Mathematical Model - Conclusion" structure. Information extraction is performed on the corresponding content of the structured sections to obtain search-level text for each of the aforementioned subdomains.

[0109] Based on the retrieved hierarchical text from each domain, a pyramid-like vector database is constructed using a multi-granularity vectorization strategy and a hierarchical indexing architecture. Specifically, the multi-granularity levels include document, chapter, and paragraph levels. The document-level vectorization targets the entire technical standard or research report (specifically, the first retrieval-level text obtained using the above method). The vector dimension can be set to 128, using BERT-CLS vector mean pooling. The chapter-level vectorization targets technical modules (such as the "insulation coordination" module in a technical standard document). The vector dimension can be set to 256, using BiLSTM-Attention (Bidirectional Long Short-Term Memory with Attention Mechanism) semantic encoding technology. The paragraph-level vectorization targets individual knowledge points, formulas, or charts within a paragraph. The vector dimension can be set to 512, using multimodal fusion (such as text semantic analysis, formula parsing, and graph convolution).

[0110] Some special content requires special processing. For example, for formulas, MathBERT can be used to extract symbolic logical relationship vectors; for graphs, ResNet-50 (Residual Network-50 layers) features and Graph Attention Network (GAT) encoding topology can be used. It should be noted that in the above vectorization process, the vector dimension and specific implementation technology can be determined based on the actual application scenario or requirements.

[0111] A pyramid vector database is constructed based on the vectorized data to implement a hierarchical index architecture. Specifically, the hierarchical index architecture includes a top layer, a middle layer, and a bottom layer. The top layer stores document-level vectors (corresponding to the first vector data in this manual), and the retrieval function is to achieve wide-area retrieval, which can achieve a recall rate of over 95%; the middle layer stores chapter-level vectors (corresponding to the second vector data in this manual), and the retrieval function is to achieve precise matching (top ten screening method); the bottom layer stores paragraph-level vectors and formulas or charts, etc., and the retrieval function is to achieve millimeter-level accuracy in answer positioning.

[0112] Each level in the vector database has an associative mapping relationship. For example, the top-level document-level vector is associated with all chapters in the corresponding medium-granularity subdomain (for example, for a technical standard document in the power transmission field, its corresponding top-level document-level vector is associated with all chapter-level vectors in the equipment type subdomain). Mid-level chapter-level vectors link to clusters of bottom-level paragraph vectors. Bottom-level paragraph-level vectors and formulas or charts are mapped back to their original document locations. This hierarchical model implements a cross-level retrieval path optimization algorithm, narrowing the task search scope layer by layer, resulting in faster searches and better results.

[0113] In this way, it is possible to perform domain-specific indexing based on document type (here, document type can refer to the field type to which the document belongs), and to perform hierarchical indexing on documents within the same large domain, thereby improving document recall rate, retrieval timeliness, and retrieval coverage.

[0114] In some implementations, the original document has corresponding value level information, and the value level information is used to determine the retrieval priority corresponding to the original document; the knowledge base contains the value level information corresponding to the original document.

[0115] The value rating information may be used to measure at least one of the following attributes of a document: importance, authority, timeliness, reliability, content quality, etc.

[0116] Specifically, for each original document, its corresponding value level information can be determined based on at least one of its importance, authority, timeliness, reliability, and content quality. The document can then be annotated based on this value level information, ensuring that the knowledge base includes this value level information. During knowledge retrieval, the value level information can be used to prioritize the retrieval of vector data corresponding to documents with higher value levels.

[0117] Furthermore, in knowledge retrieval, multiple search results may be obtained, and it is also possible to determine which results correspond to documents with higher value levels based on the value level information, thereby increasing the proportion of these results in answer generation.

[0118] For example, the value grade information corresponding to a document is determined based on its authority. Taking the electric power industry as an example, assuming that enterprise standard documents have the highest authority, industry specification documents have the second highest authority, paper documents have the third highest authority, and manual documents have the lowest authority, the weight coefficient of enterprise standard documents can be set to 0.6, and this can be used as the value grade information of enterprise standard documents; the weight coefficient of industry specification documents can be set to 0.5, and this can be used as the value grade information of industry specification documents; the weight coefficient of paper documents can be set to 0.3, and this can be used as the value grade information of paper documents; and the weight coefficient of manual documents can be set to 0.2, and this can be used as the value grade information of manual documents. Furthermore, taking paper documents as an example, the authority of SCI (Science Citation Index) papers is higher than that of general journal papers, so different value grades can be set for papers in different journals.

[0119] Exemplarily, the value level information corresponding to a document is determined based on the timeliness of the document. Taking real-time operation and maintenance log documents as an example, a time decay factor can be set (for example, the time decay factor can be set to 0.8 or 0.6, etc.), and the value level information of operation and maintenance log documents generated at different times can be calculated based on the time decay factor.

[0120] The description of determining the value level information corresponding to a document based on other attributes is similar to that in the above example and will not be repeated in detail.

[0121] It should be noted that the method for determining the value level information can be set according to actual application scenarios or needs, and is not specifically limited in this specification.

[0122] In some implementations, the original document further corresponds to a confidentiality level; constructing a knowledge base based on the first vector data and the second vector data may include: constructing a knowledge base based on the first vector data, the second vector data, and the confidentiality level.

[0123] The confidentiality level can be used to identify the sensitivity of a document or the level of access permission.

[0124] Specifically, for each original document, a confidentiality level corresponding to the document can be determined based on at least one of the document's sensitivity or access permission level, and the document can be labeled according to the confidentiality level. When constructing a knowledge base based on the first vector data, the second vector data, and the confidentiality level, the vector data corresponding to each original document can be treated as confidential or non-confidential based on the confidentiality level.

[0125] It should be noted that, for data subsequently updated to documents in the knowledge base, corresponding processing can be performed in the knowledge base according to the confidentiality level of the updated documents without rebuilding the knowledge base, thereby achieving incremental updates.

[0126] Furthermore, the first vector data and the second vector data have a first mapping relationship; before constructing a knowledge base based on the first vector data and the second vector data, the knowledge base construction method may further include: determining a third classification domain corresponding to the original document according to a preset hierarchical division method; parsing the original document to obtain a third retrieval level text under the third classification domain; and constructing third vector data based on the third retrieval level text; wherein the second vector data and the third vector data have a second mapping relationship. Accordingly, constructing a knowledge base based on the first vector data and the second vector data may include: constructing a knowledge base based on the first vector data, the second vector data, the first mapping relationship, the third vector data, the second mapping relationship, and the confidentiality level.

[0127] In some embodiments, original documents and their corresponding vector data whose confidentiality levels meet certain conditions can be stored in a private domain in the knowledge base, or corresponding access permissions can be set for original documents and their corresponding vector data whose confidentiality levels meet certain conditions, so that only users with access permissions can access and retrieve these data.

[0128] For example, a distinction can be made between public and private databases using the form of federated data. Taking the power industry as an example, considering the data privacy and security issues in the power industry, data can be divided into public and private domain data with reference to the federated data form. Public data is data that allows public access and query; private domain data, on the other hand, is the internal data of each enterprise, and private domain data between different companies is not accessible. Accordingly, a public database is set up to store public data, and a private database is set up to store private domain data. Public databases are databases that are normally accessible to the public and store information such as industry standards and industry knowledge. In contrast, private databases store private data within an enterprise, are inaccessible via the public network, and have a certain degree of confidentiality.

[0129] For documents with a defined confidentiality level, the confidentiality level can be directly assigned. For some unclassified documents or continuously generated internal company files, confidentiality levels can be dynamically assigned. Confidentiality levels are primarily used within an enterprise, where different departments or groups have access to different confidentiality levels. The answers returned to different users' questions must be secure and confidential, so private data must be stored securely.

[0130] For example, confidentiality levels can be divided into top secret, internal, and public. The confidentiality level can be determined based on the document content. For example, for top secret documents or documents with confidential file numbers, the confidentiality level can be set to top secret; for documents containing sensitive terms in the power industry (such as "load curve" and "relay protection value"), the confidentiality level can be set to internal; for documents containing temporary risk terms such as fault events (such as insulator ice flashover accidents), the confidentiality level can be set to internal; and for industry technical standards documents, the confidentiality level can be set to public.

[0131] Top-secret documents and their corresponding vector data can be stored using physical isolation and encryption using national security secrets (such as the SM4 symmetric encryption algorithm). Internal-level documents and their corresponding vector data can be transmitted using domain-wide access control and SSL (Secure Sockets Layer) protocols. Public-level documents and their corresponding vector data are stored in public databases using standard storage methods. Specific isolation storage methods, encrypted storage methods, and access control methods can be determined based on actual application scenarios and requirements.

[0132] Furthermore, methods such as automatic identification of sensitive words can be used to automatically calculate the risk value of documents, thereby automatically assigning confidentiality levels to documents, and determining the storage strategy for corresponding documents through methods such as confidentiality level hierarchical decision matrix. The hierarchical decision matrix can be specifically designed with reference to Table 1 below:

[0133]

[0134] In other embodiments, original documents whose confidentiality levels meet certain conditions and their corresponding vector data may be encrypted and stored in the knowledge base.

[0135] It should be noted that the method for determining the confidentiality level can be set according to actual application scenarios or needs, and is not specifically limited in this specification.

[0136] This specification provides a method for processing knowledge questions and answers. Figure 4 As shown, the knowledge question answering method may include the following steps.

[0137] S410: Obtain question text data.

[0138] S420. In the knowledge base constructed by the knowledge base construction method according to any of the aforementioned embodiments, the question text data is searched according to the search order of the search level text to obtain a first search result.

[0139] S430: Generate a first answer text corresponding to the question text data based on the first search result.

[0140] Specifically, the corresponding question text data is obtained based on the input content of the user's question. In the knowledge base constructed according to the knowledge base construction method in any of the aforementioned embodiments, the question text data is searched according to the search order of the search level text in the multi-level knowledge structure, that is, first search in the first vector data corresponding to the first search level text, and then continue to search in the second vector data corresponding to the second search level text after retrieving the relevant content. If there is a third search level text, then continue to search in the third vector data corresponding to the third search level text after retrieving the relevant content, and so on to obtain the first search result. The answer is generated according to the first search result to generate the first answer text corresponding to the question text data and return it to the user.

[0141] It can be understood that the first retrieval level text corresponds to the first retrieval level, the second retrieval level text corresponds to the second retrieval level, the retrieval order of the retrieval level text is the retrieval order of the retrieval level, and the question text data is retrieved according to the retrieval order of the retrieval level text, that is, the question text data is retrieved according to the retrieval order of the retrieval level text.

[0142] For example, a three-layer pyramidal vector database constructed using the aforementioned knowledge base construction method consists of a top layer storing document-level vectors, a middle layer storing chapter-level vectors, and a bottom layer storing paragraph-level vectors and formulas or charts. Within this database, question text data is searched in the order in which the text at each level is retrieved. This employs a progressive search mechanism, achieving precise three-stage positioning.

[0143] First, coarse-grained retrieval is performed to quickly lock relevant fields through document-level vectors. Second, medium-grained matching is performed to calculate the cosine similarity between the chapter vector and the question text data. Then, fine-grained positioning is performed to calculate the mixed similarity in the associated paragraphs to obtain the corresponding retrieval results whose similarity meets the conditions.

[0144] The response time of coarse-grained search is within 50 milliseconds. Based on the results of medium-grained matching, the search scope can be further limited to chapter vectors whose cosine similarity with the question text data is greater than a certain threshold. For example, the threshold can be 0.75, 0.85, 0.9, etc. In fine-grained positioning, the calculation method of the mixed similarity S_final can refer to the following formula:

[0145] S_final = 0.6 Text similarity +0.3 Formula structure similarity +0.1 Graph feature similarity

[0146] The calculation methods of text similarity, formula structure similarity, and chart feature similarity can be determined based on actual application scenarios or requirements, and are not specifically limited in this specification.

[0147] It should be noted that the similarity matching and retrieval methods at the above-mentioned different retrieval levels can be specifically determined according to actual application scenarios or requirements, and are not specifically limited in this specification.

[0148] Furthermore, the timeliness weight corresponding to each original document in the knowledge base can be dynamically calculated. When searching, for the retrieval level texts at the same retrieval level, the retrieval level texts for priority retrieval can be determined in the retrieval level according to the timeliness weight corresponding to the corresponding original document, thereby further improving the retrieval timeliness. The calculation method of the timeliness weight W can refer to the following formula:

[0149] W=α log(importance level)+β Time factor

[0150] Among them, the coefficients α and β can be set according to actual conditions; for the description of the importance level in the formula, please refer to the description of the authority level in this specification, and for the description of the timeliness factor, please refer to the description of the time attenuation factor in this specification.

[0151] Alternatively, the timeliness weight can be calculated by referring to the following formula:

[0152] W = 0.5 log2(importance level) + 0.3 (1+e^(-0.2 Δt)) + 0.2 update_frequency

[0153] Where Δt is the document update time difference, in months; update_frequency is the number of updates in the past six months.

[0154] In some cases, before searching the question text data according to the search order of the search level text, the knowledge question answering method may further include: determining a search depth based on the complexity of the question corresponding to the question text data; determining a target search level text in the knowledge base based on the search depth; and accordingly, searching the question text data according to the search order of the search level text to obtain a first search result, which may include: searching the question text data according to the search order of each search level text in the target search level text to obtain the first search result. The search depth is the number of search levels, starting with the first search level and including at least one search level. This method allows for dynamic depth adjustment during retrieval. For simple questions, only the top-level search can be triggered, such as "What are the standards for transmission lines?" For complex questions, the search can be automatically penetrated to the bottom level, performing a multi-layer sequential search, such as "Derivation of the calculation formula for the probability of ice flashover on ±800kV insulators." Regarding the method for determining question complexity, at least one of text feature analysis, grammatical structure analysis, and intent recognition can be used, and this specification does not specifically limit this.

[0155] In some embodiments, reference Figure 5 As shown, the knowledge question answering method may further include:

[0156] S510: Determine the target original document corresponding to the first search result according to the first search result.

[0157] S520: Generate a text attachment corresponding to the first search result according to the first search result and the target original document.

[0158] The target original document is a source document containing information of the first search result.

[0159] The text attachment may be used to return to the user along with the first answer text.

[0160] Specifically, the first search result may be associated with information about a corresponding original document. Based on the first search result, an original document containing the information about the first search result may be located and used as a target original document. Based on the first search result, content related to the first search result may be filtered from the target original document, and a text attachment corresponding to the first search result may be generated based on the filtered content.

[0161] In some embodiments, generating a text attachment corresponding to the first retrieval result based on the first retrieval result and the target original document can be achieved through the aforementioned position index. Specifically, the part closely related to the first retrieval result can be located in the target original document according to the position index corresponding to the first retrieval result, and then the text attachment can be generated based on the relevant part.

[0162] In other embodiments, a text attachment corresponding to the first search result is generated based on the first search result and the target original document. The corresponding text attachment can be generated by parsing and extracting the portion corresponding to the first search result from the target original document.

[0163] It should be noted that text attachments can be screenshots, PDF files, or editable electronic documents, etc.

[0164] In the above implementation, by generating a text attachment corresponding to the first search result, on the basis of the conventional output answer text, the material content of the original document on which the output answer content is based is added. The text attachment can be presented in the form of a screenshot or PDF, thereby realizing the traceability mechanism output and improving the credibility of the output results.

[0165] In some implementations, the first search result corresponds to a first search scope; Figure 6 As shown, the knowledge question answering method may further include:

[0166] S610: Evaluate the first answer text to obtain an evaluation result.

[0167] S620: If the evaluation result does not meet the preset condition, determine a second search scope based on the first search scope.

[0168] S630: Search the question text data in the knowledge base based on the second search scope to obtain a second search result, and generate a second answer text according to the second search result.

[0169] The search range is a vector search space, which can be determined based on the search depth and semantic radius. The first search range is smaller than the second search range.

[0170] If the evaluation result does not meet the preset conditions, it means that the quality of the first answer text does not meet the set quality standards. The evaluation result can be in the form of a score or grade.

[0171] Specifically, preset evaluation rules are set to evaluate whether the answer text generated based on the search results meets the requirements corresponding to the question input by the user. The first answer text obtained after searching based on the first search scope is evaluated according to the preset evaluation rules to obtain a corresponding evaluation result. If the evaluation result corresponding to the first answer text meets the preset conditions, indicating that the quality of the first answer text meets the user's requirements, the first answer text can be returned to the user.

[0172] If the evaluation result does not meet the preset conditions, indicating that the quality of the first answer text does not meet the user's needs, a larger second search range is determined based on the first search range, so as to re-search the question text data in the knowledge base based on the second search range, obtain a second search result, and generate a second answer text based on the second search result.

[0173] Furthermore, the second search result is evaluated according to preset evaluation rules to obtain its corresponding evaluation result. If the evaluation result corresponding to the second search result meets the preset conditions, the second answer text is returned to the user. If it does not meet the preset conditions, a third, larger search scope is determined based on the second search scope. The question text data is re-searched in the knowledge base based on the third search scope to obtain a third search result, and a third answer text is generated based on the third search result. This loopback verification mechanism (or self-reflection and error correction mechanism) is used in this way until an answer text that meets the user's needs is obtained, or until the number of loopback verifications reaches a preset threshold.

[0174] In some embodiments, the evaluation of the first answer text may be implemented using a reward scoring model, where the evaluation result is the score output by the model. Accordingly, the evaluation result may not meet the preset condition, specifically, the score corresponding to the first answer text may be less than a preset scoring threshold.

[0175] Exemplarily, a reward model scoring mechanism is introduced to score and evaluate the question-answering output results and the question-answering requirements input by the user, and a score range of 0-5 can be set. The training process of the reward model may include: inputting the question sample into the knowledge question-answering system, and obtaining the answer generated by the knowledge question-answering system as the answer sample. The answer sample is scored manually, and the scoring result is used as the annotation of the answer sample. This stage is recorded as the annotation process. The question text and the corresponding answer sample are input into the untrained initial model for scoring, so that the initial model outputs the initial scoring result corresponding to the answer sample. The initial model is trained according to the initial scoring result output by the model and the scoring annotation corresponding to the answer sample, and the model parameters are converged until the training stop condition is met, and the trained reward model is obtained, and the reward model is applied to the actual scoring scenario.

[0176] For the first answer text, if the reward model outputs a score of 3 or greater, the evaluation model determines that the output result is a good match for the question answer, and the answer text can be directly returned to the user. If the score is less than 3, the loop generation phase begins. Based on the first search scope, the search scope is expanded to determine the second search scope, automatically expanding the vector search space and enhancing the granularity of prompt content. In addition, a loop verification threshold can be set. For example, a default maximum of 3 (or 5, 6, etc.) loop verifications can be set to strike a balance between ensuring the accuracy and timeliness of the output content. The loop verification threshold can be determined based on the actual application scenario or requirements.

[0177] The scoring dimensions of different score levels can be referred to in Table 2 below:

[0178]

[0179] The search range can be determined according to the search depth (eg, the number of recalled texts or the search volume) and the semantic radius. The initial value D0 of the search depth can be set to 50, and the initial value R0 of the semantic radius can be set to 0.8.

[0180] When the reward score S is less than 3 points, the search range can be expanded according to the multi-level expansion parameter table shown in Table 3:

[0181]

[0182] For example, a user asked, "How do you calculate the annual failure rate of insulators?" The first round of answers was, "Based on operating experience, the insulator failure rate is usually between 0.1% and 0.3%." The reward score was 2.1 (lacking a calculation formula and standard basis).

[0183] The first round of answers scored less than 3 points, so the first expansion check was conducted. Parameter adjustments were made: the search depth was adjusted from 50 to 75, the semantic radius was adjusted from 0.8 to 0.9, and the prompt enhancement strategy was to add "the calculation formula in the DL / T436 standard must be included." Based on this, the second round of answers was obtained: "According to Article 5.3.2 of DL / T436-2018, the annual failure rate λ is calculated as λ=N_fault / (N_total L), where N_fault is the number of faulty chips, N_total is the total number, and L is the operating life. A value of 0.05% to 0.2% is recommended. At this point, the reward score is 4.3, which is considered to meet the user's needs. The answer for this round is returned to the user.

[0184] In some cases, the search depth may also be defined as D = log2(N) × 0.8, where the initial value of N is 50 and N is expanded by multiples of 1.5, 2.2, and 3.0 as described above.

[0185] Furthermore, the search scope can be determined based on the search depth, semantic radius, and timeliness. The timeliness indicates the time range within which documents are published or updated. For example, a timeliness range of 6 months indicates that documents within the search scope are those published or updated within the past 6 months. The timeliness range can be defined as T = min(1, Δt / 36), where the initial value of Δt is 6 months.

[0186] By introducing this self-reflection and error correction mechanism, the hallucination rate is less than 1.2%, the average number of response iterations is 1.8, and the knowledge base update delay is less than 2 hours (from the release of a new standard to its entry into the database), effectively improving the overall performance of the system. Furthermore, optimization mechanisms can be set up. For example, if the same issue triggers expanded inspection three times in a row, a special knowledge base review can be automatically initiated. Standard timeliness warnings can also be established, providing a six-month advance notice of upcoming regulatory documents.

[0187] Therefore, through a loopback verification mechanism and a scoring-expansion process, we enhance the system's self-reflection and continuous improvement capabilities. Through error pattern recognition, user feedback learning, and performance monitoring and analysis, we continuously optimize model performance and knowledge base quality. This mechanism ensures high accuracy in answering professional questions in relevant fields, effectively reduces the risk of hallucinations within specialized fields, and provides users with reliable and authoritative professional support.

[0188] In some implementations, the question text data is obtained by vectorizing the original question data, where the original question data includes at least one of text data, image data, and voice data.

[0189] In this embodiment, the question text data is the standard input text ultimately used for knowledge base retrieval.

[0190] The original problem data can be multimodal data.

[0191] Specifically, the original question data input by the user can be in at least one of several modalities, such as text, image, or voice. Vectorizing the original question data can convert it into question text data in a standard format for knowledge base retrieval. This solves the problem in related technologies where the single text input interaction mode does not support multimodal input, increasing operational complexity for frontline personnel and lowering the interaction threshold.

[0192] For example, taking the power industry as an example, this specification provides an improved power scenario RAG method and system, referring to Figure 7aAs shown in FIG, it is the structural diagram of the system, which mainly includes an input module, a data hierarchical vectorization module, a base model, a loop generation module and an output module.

[0193] The input module supports multiple input modalities, including text, images, and voice. Image formats include color drawings (designs), infrared images (equipment thermal imaging), and text images (scanned documents), as well as conventional on-site images. Voice input supports spoken languages ​​such as Mandarin, English, Cantonese, and Sichuanese. This module utilizes image recognition (such as OCR + infrared feature extraction) and dialect speech-to-text conversion technologies to enable natural interaction in frontline work scenarios.

[0194] The data hierarchical vectorization module is mainly used to realize the vectorization of the hierarchical structure of the knowledge base, divide the knowledge base according to the major industry categories, and further refine it to build a pyramid-like structure in the form of first-level directory, second-level directory, third-level directory, etc. For a detailed description, please refer to the description of knowledge base construction in this manual. In addition, considering the data privacy and security issues in the power industry, refer to Figure 7b As shown, the knowledge base refers to the federated data format and performs federated data processing. Specifically, the data is divided into public data and private domain data. Public data is used to build a shared vector library, which allows public access and query; private domain data is used to build a private domain vector library, and private domain data and private domain vector libraries between different departments are not allowed to be accessed (for example, Figure 7b In this example, only unit A has access to the unit A vector library built based on unit A's private data, and only unit B has access to the unit B vector library built based on unit B's private data. This allows for a cross-domain access control protocol based on a zero-knowledge proof verification process.

[0195] The foundational model primarily uses the DeepSeek large model to generate question-answer output, utilizing this model to implement input-output mapping. The main process includes multimodal input, joint feature space mapping, vector search results, and prompt word engineering optimization. Output formats include text answers (which can include references to papers, books, and regulatory documents) and source attachments in the form of PDFs or screenshots.

[0196] Implement the scoring-expansion process based on the loop generation module. Figure 7cAs shown, the scoring and expansion process primarily involves: Reward scoring is performed based on the answer text output by the DeepSeek large model. If the score is 3 or higher, the system outputs the text and a traceability attachment in the form of a PDF or screenshot. If the score is less than 3, the vector search space is expanded, the prompt granularity is increased, and the answer is re-searched and generated. The scoring model can implement a hybrid evaluation based on semantic similarity (e.g., using the BERTScore metric) and domain rules (e.g., matching of power terminology). This scoring and expansion mechanism can also be referred to as an agent verification loop.

[0197] refer to Figure 7d As shown in the figure, the main process of the RAG method for power scenarios includes: first, modality recognition is performed based on user input data. If text data is recognized, semantic parsing is performed; if image data is recognized, visual feature extraction is performed; if voice data is recognized, voice recognition is performed. Second, joint vector retrieval is performed. Through hierarchical indexing, document-level vector retrieval is performed in the first-level index (i.e., the first retrieval level), chapter-level vector retrieval is performed in the second-level index (i.e., the second retrieval level), and paragraph-level vector retrieval is performed in the third-level index (i.e., the third retrieval level). Answers are generated based on the retrieval results, and then enter the agent verification loop, ultimately outputting the answer and a traceable PDF or screenshot.

[0198] The power scenario RAG method and system provided in this specification have the following advantages: (1) It adopts federated data to solve the problem that the centralized knowledge base architecture in related technologies mixes private domain data with public data and is easily accessed by unauthorized users, thereby resolving the contradiction between data privacy and sharing requirements in the power industry and reducing the risk of cross-unit leakage of private domain data; (2) Through hierarchical vectorization and pyramid indexing, it solves the problem of balancing retrieval accuracy and timeliness and improves the recall rate of relevant documents; (3) It supports multimodal input. In view of the problem that the interaction form in related technologies is single and cannot meet the needs of scenarios such as infrared image recognition and multilingual voice input for front-line personnel, it can improve the usability of multimodal interaction in complex field environments; (4) It introduces agent loop verification to evaluate the generated answers and adaptively increase the search range. Compared with the lack of self-reflection and optimization mechanisms in related technologies, it can effectively improve the quality of answers; (5) It realizes a traceability mechanism. By returning the original document PDF / image fragment function, it is closer to the needs of industrial scenarios and increases the interactive experience. Compared with the method in related technologies that cannot return the original document for users to quickly review, it reduces users' doubts about the returned results and improves the credibility of the answers.

[0199] The power scenario RAG method and system provided in this manual comprehensively considers the data privacy, authority, traceability, multimodal input and other characteristics of the power industry itself, and provides targeted and unique innovative solutions with great promotion and application value.

[0200] The embodiments of this specification provide a knowledge base construction device, which may include: an original document acquisition module, a retrieval level text acquisition module, a vector data construction module, and a knowledge base construction module.

[0201] The original document acquisition module is used to obtain the original document.

[0202] The retrieval level text acquisition module is used to divide the original document according to a preset level division method to obtain a first retrieval level text and a second retrieval level text; wherein the retrieval order of the first retrieval level text is before the second retrieval level text.

[0203] The vector data construction module is used to construct first vector data based on the first retrieval level text and to construct second vector data based on the second retrieval level text.

[0204] The knowledge base construction module is used to construct a knowledge base according to the first vector data and the second vector data.

[0205] The embodiment of this specification also provides a knowledge question and answer processing device, which may include: a question text acquisition module, a search result acquisition module, and an answer text generation module.

[0206] The question text acquisition module is used to obtain question text data.

[0207] The retrieval result acquisition module is used to search the question text data in the knowledge base constructed according to the knowledge base construction method described in any of the above embodiments according to the retrieval order of the retrieval level text to obtain the first retrieval result.

[0208] The answer text generation module is used to generate a first answer text corresponding to the question text data based on the first search result.

[0209] For the specific limitations of the knowledge base construction device, please refer to the limitations of the knowledge base construction method above. For the specific limitations of the knowledge question and answer processing device, please refer to the limitations of the knowledge question and answer processing method above, and no further details will be given here. The various modules in the above-mentioned knowledge base construction device and knowledge question and answer processing device can be implemented in whole or in part through software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0210] An embodiment of this specification also provides a computer device, which may include a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the knowledge base construction method or knowledge question and answer processing method in any of the aforementioned embodiments.

[0211] The embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the knowledge base construction method or the knowledge question and answer processing method in any of the aforementioned embodiments is implemented.

[0212] It should be noted that the logic and / or steps represented in flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing it in another suitable manner if necessary, and then storing it in a computer memory.

[0213] It should be understood that various components of the present invention may be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods may be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof may be used: a discrete logic circuit having logic gate circuits for implementing logic functions on data signals, an application-specific integrated circuit having suitable combinational logic gate circuits, a programmable gate array (PGA), a field-programmable gate array (FPGA), etc.

[0214] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

[0215] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0216] In the present invention, unless otherwise specified or limited, the terms "installed," "connected," "connect," "fixed," etc. should be understood in a broad sense. For example, they can refer to fixed connection, detachable connection, or integration; mechanical connection, electrical connection; direct connection, or indirect connection through an intermediate medium; internal communication between two components, or interaction between two components, unless otherwise specified. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.

[0217] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.

Claims

1. A knowledge base construction method, characterized in that: The method comprises: Obtain original documents; Determine a first classification domain and a second classification domain corresponding to the original document according to a preset hierarchical division method; wherein the preset hierarchical division method is determined according to the field to which the original document belongs; and the second classification domain is a subdomain of the first classification domain; Parsing the original document to determine a first retrieval level text under the first classification domain and a second retrieval level text under the second classification domain; wherein the granularity of the second retrieval level text is smaller than the granularity of the first retrieval level text; and the retrieval order of the first retrieval level text is before the second retrieval level text; Constructing first vector data based on the first search level text, and constructing second vector data based on the second search level text; A knowledge base is constructed based on the first vector data and the second vector data.

2. The knowledge base construction method according to claim 1, characterized in that: The first search level text corresponds to a first position index, and / or the second search level text corresponds to a second position index; The first position index is used to indicate the position of the original text content corresponding to the first retrieval level text in the original document; The second position index is used to indicate the location of the original text content corresponding to the second retrieval level text in the original document.

3. The knowledge base construction method according to claim 1, characterized in that: There is a first mapping relationship between the first vector data and the second vector data; Before constructing a knowledge base according to the first vector data and the second vector data, the method further includes: Determining a third classification domain corresponding to the original document according to the preset hierarchical division method; Parsing the original document to obtain a third retrieval level text under the third classification domain; wherein the retrieval order of the second retrieval level text is before the third retrieval level text; and the granularity of the third retrieval level text is smaller than the granularity of the second retrieval level text; Constructing third vector data based on the third search level text; wherein a second mapping relationship exists between the second vector data and the third vector data; The constructing a knowledge base according to the first vector data and the second vector data includes: The knowledge base is constructed according to the first vector data, the second vector data, the first mapping relationship, the third vector data and the second mapping relationship.

4. The knowledge base construction method according to claim 3, characterized in that: The first search level text is determined based on the document level content of the original document; The second search level text is determined based on the chapter-level content of the original document; The third retrieval level text is determined according to the paragraph-level content of the original document.

5. The knowledge base construction method according to any one of claims 1 to 4, characterized in that: The original document has corresponding value level information, and the value level information is used to determine the retrieval priority corresponding to the original document; The knowledge base contains the value level information corresponding to the original document.

6. The knowledge base construction method according to any one of claims 1 to 4, characterized in that: The original document also corresponds to a confidentiality level; and constructing a knowledge base based on the first vector data and the second vector data includes: The knowledge base is constructed according to the first vector data, the second vector data and the confidentiality level.

7. A knowledge question answering method, characterized in that: The method comprises: Get question text data; In the knowledge base constructed by the knowledge base construction method according to any one of claims 1 to 6, searching the question text data according to the search order of the search level text to obtain a first search result; A first answer text corresponding to the question text data is generated based on the first search result.

8. The knowledge question answering method according to claim 7, characterized in that: The method further comprises: Determining a target original document corresponding to the first search result according to the first search result; A text attachment corresponding to the first search result is generated according to the first search result and the target original document.

9. The knowledge question answering method according to claim 7, characterized in that: The first search result corresponds to a first search scope; the method further includes: Evaluating the first answer text to obtain an evaluation result; If the evaluation result does not meet the preset condition, determining a second search scope based on the first search scope; The question text data is searched in the knowledge base based on the second search scope to obtain a second search result, so as to generate a second answer text according to the second search result.

10. The knowledge question answering method according to any one of claims 7 to 9, characterized in that: The question text data is obtained by vectorizing original question data, and the original question data includes at least one of text data, image data, and voice data.

11. A knowledge base construction device, characterized in that: The device comprises: An original document acquisition module, used to acquire original documents; A retrieval level text acquisition module is used to determine the first classification domain and the second classification domain corresponding to the original document according to a preset hierarchical division method, and to parse the original document to determine the first retrieval level text under the first classification domain and the second retrieval level text under the second classification domain; wherein the preset hierarchical division method is determined according to the field to which the original document belongs; the granularity of the second retrieval level text is smaller than the granularity of the first retrieval level text; the retrieval order of the first retrieval level text is located before the second retrieval level text; the second classification domain is a subdomain under the first classification domain; A vector data construction module, configured to construct first vector data based on the first search level text, and to construct second vector data based on the second search level text; A knowledge base construction module is used to construct a knowledge base based on the first vector data and the second vector data.

12. A knowledge question answering processing device, characterized in that: The device comprises: Question text acquisition module, used to obtain question text data; a search result acquisition module, configured to search the question text data in the knowledge base constructed by the knowledge base construction method according to any one of claims 1 to 6 according to a search order of the search hierarchical texts to obtain a first search result; An answer text generating module is used to generate a first answer text corresponding to the question text data based on the first search result.

Citation Information

Patent Citations

  • Text data processing method and device, electronic equipment and nonvolatile storage medium

    CN118797011A

  • Large model knowledge base construction method based on multi-granularity retrieval

    CN119647581A

  • Rag-based search system and method using document-specific permissions of meta information

    KR102732205B1