Document knowledge question-answering method, document knowledge storage method and document knowledge question-answering device

By constructing a multi-level knowledge tree structure and combining text retrieval and semantic search methods, the problem of difficult to capture complex query intentions in traditional knowledge questions and answers is solved, and more efficient information retrieval and better user experience is achieved.

CN119669429AInactive Publication Date: 2025-03-21CHENGDU CELIS TECH CO LTD

Patent Information

Application Number
CN202510179644.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-19
Publication Date
2025-03-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional knowledge Q&A methods are difficult to capture multi-level semantic relationships in user complex query intentions, resulting in low information recall, poor correlation and poor user experience.

Method used

Build a multi-level knowledge tree structure, perform multi-dimensional semantic representation of the document content from knowledge points and paragraphs to the full text, and traverse the nodes of each layer of the knowledge tree through a combination of text retrieval and semantic retrieval, and integrate query results to generate answers.

Benefits of technology

Improves the relevance of knowledge recall and answers, enhances the user experience, and enables users to obtain more comprehensive and accurate answers in complex queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119669429A_ABST
    Figure CN119669429A_ABST
Patent Text Reader

Abstract

The invention provides a document knowledge questioning and answering method, a document knowledge storage method and a document knowledge questioning and answering device, and relates to the technical field of intelligent questioning and answering. All layers of nodes of a knowledge tree are traversed according to a target retrieval mode on the basis of the query statement to obtain a query result, the knowledge tree comprises multiple layers of nodes, the multiple layers of nodes at least comprise first-layer nodes, second-layer nodes and third-layer nodes, semantics of the first-layer nodes are semantics of text contents of knowledge point levels in the document, and semantics of the third-layer nodes are semantics of text contents of knowledge point levels in the document; the semantics of the second-layer nodes are the semantics of the paragraph-level text content in the document, and the semantics of the third-layer nodes are the semantics of the full-text-level text content in the document; and outputting an answer text corresponding to the query statement based on the query result. The method provided by the invention not only improves the recall rate of knowledge and the correlation of answers, but also enhances the overall experience of the user, so that the user can obtain more comprehensive and accurate answers in complex queries.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent question answering technology, and in particular to a document knowledge question answering method, a document knowledge storage method and a document knowledge question answering device. Background Art

[0002] With the rapid development of information technology, knowledge question answering is increasingly used in various fields. In the traditional knowledge question answering process, information retrieval technology is widely used. Whether in customer service, education, medical care or technical support, users hope to obtain the required information quickly and accurately.

[0003] Traditional methods usually rely on keyword-based retrieval mechanisms or simple character matching. However, users' query intentions are often complex and involve information at multiple levels, and traditional methods have difficulty capturing these complex semantic relationships. When processing user queries, only query-related fragments or knowledge points can be extracted from the document. When a user asks a question involving multiple topics, only fragments related to a specific keyword are returned, which often makes users confused or dissatisfied when obtaining information, which not only reduces the user experience, but also affects the overall effectiveness of knowledge quizzes. Summary of the invention

[0004] The present invention provides a document knowledge question and answer method, a document knowledge storage method and a document knowledge question and answer device, aiming to solve the problems existing in the above-mentioned background technology.

[0005] In order to solve the above-mentioned technical problems, the present invention is achieved as follows: In a first aspect, the present invention provides a document knowledge question answering method, the method comprising: Get the query statement; Based on the query statement, the nodes of each layer of the knowledge tree are traversed in a target retrieval manner to obtain a query result, wherein the knowledge tree includes multiple layers of nodes, and the multiple layers of nodes include at least: first-layer nodes, second-layer nodes, and third-layer nodes, wherein the semantics of the first-layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second-layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third-layer nodes are the semantics of the text content at the full-text level in the document; Based on the query result, an answer text corresponding to the query statement is output.

[0006] Optionally, based on the query statement, nodes at each level of the knowledge tree are traversed in a target retrieval manner to obtain query results, including: Determining the type of the target retrieval method according to the query statement; When the target search method is a text search method, traverse the text content of nodes at each level in the knowledge tree, filter out the text content of nodes matching the query statement and use it as a text query result; In the case where the target search method is a semantic search method, the query statement is vectorized to obtain a vectorized representation of the query statement; the vectorized representation of the query statement is similarly calculated with the semantic representation of each layer of the nodes in the knowledge tree, and the text content of the nodes whose similarity is greater than a preset similarity threshold is screened out as a semantic query result; The text query result and the semantic query result are integrated to obtain a final query result.

[0007] Optionally, the text query result and the semantic query result are merged to obtain a final query result, including: Sorting the scores of the text query results and the scores of the semantic query results in descending order respectively; updating the score of the query result according to the first order value of the same query result in the text query result and the second order value in the semantic query result; The updated scores of the query results are sorted in descending order, and the query results ranked in the top M positions are used as the final query results, where M is an integer greater than or equal to 1.

[0008] In a second aspect, the present invention provides a document knowledge storage method, the method comprising: Splitting the document into multiple original text blocks, and using the multiple original text blocks as first-level nodes of the knowledge tree respectively; According to the semantics of each of the multiple original text blocks, the multiple original text blocks are clustered to obtain multiple text blocks after the first clustering, and the multiple text blocks after the first clustering are used as the second-layer nodes of the knowledge tree, wherein the semantics of each text block after the first clustering is generated according to the text content of each original text block clustered into the same class; Taking the plurality of text blocks after the first clustering as the plurality of original text blocks, performing iterative clustering until an iteration stop condition is met; The clustered text blocks obtained in the clustering process are stored in the database as nodes of each layer of the knowledge tree, wherein each node is used to represent its own semantics and text content; Each layer of nodes in the knowledge tree includes at least the first layer nodes, the second layer nodes and the third layer nodes. The semantics of the first layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third layer nodes are the semantics of the text content at the full-text level in the document. The knowledge tree is applied to the document knowledge question and answer method as described in the first aspect.

[0009] Optionally, the topmost node in the knowledge tree is the multiple original text blocks, each layer of nodes except the topmost node is obtained by clustering text blocks corresponding to the nodes in the previous layer, and the semantics of the text blocks corresponding to each layer of nodes except the topmost node are obtained according to the text contents of each text block clustered into the same category; according to the respective semantics of the multiple original text blocks, the multiple original text blocks are clustered to obtain multiple text blocks after the first clustering, including: Clustering the multiple original text blocks according to the semantics of each of the multiple original text blocks to obtain N clustering results, where N is an integer greater than 1; Generate an nth summary according to the text content of each original text block clustered into the nth category, and use the nth summary as the text content of the nth text block after the first clustering, where n is an integer from 1 to N; According to the nth summary, the semantics of the nth text block after the first clustering is obtained.

[0010] Optionally, an nth summary is generated according to the text content of each original text block clustered into the nth category, including: Replacing the target text in the prompt text of the large language model with the text content of each original text block clustered into the nth category, the large language model is used to generate a corresponding summary according to the target text; The replaced prompt text is input into the large language model to obtain the nth summary.

[0011] Optionally, clustering the multiple original text blocks according to the semantics of each of the multiple original text blocks to obtain N clustering results, including: Inputting the plurality of original text blocks into a pre-trained semantic model to obtain vectorized representations of the plurality of original text blocks, wherein the vectorized representations are used to represent semantics; Determining similarities between the vectorized representations of the plurality of original text blocks; A group of original text blocks whose similarity is greater than the target similarity are clustered into one category to obtain the N clustering results.

[0012] Optionally, obtaining the semantics of the nth text block after the first clustering according to the nth summary includes: The nth summary is input into the pre-trained semantic model to obtain the semantics of the nth text block after the first clustering, wherein the training samples of the pre-trained semantic model are question-answer text pairs, wherein the question text in the question-answer text pair is the text of the question asked about the document, and the answer text in the question-answer text pair is the text content of the nodes at different levels of the knowledge tree.

[0013] Optionally, split the document into chunks of raw text, including: Based on the multiple identifiers, split the document into multiple paragraphs; In the case where the number of characters in a paragraph is less than the target threshold, the paragraph is regarded as an original text block; When the number of characters in a paragraph is not less than the target threshold, the paragraph is split according to the sentence end symbol, and each sub-paragraph obtained by the split is used as an original text block.

[0014] In a third aspect, the present invention provides a document knowledge question-answering device, the device comprising: The acquisition module is used to obtain the query statement; A query module, used to traverse the nodes of each layer of the knowledge tree according to the target retrieval method based on the query statement to obtain the query result, the knowledge tree includes multiple layers of nodes, and the multiple layers of nodes include at least: first-layer nodes, second-layer nodes and third-layer nodes, the semantics of the first-layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second-layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third-layer nodes are the semantics of the text content at the full-text level in the document; The output module is used to output the answer text corresponding to the query statement based on the query result.

[0015] Optionally, the query module includes: A type determination submodule, used to determine the type of the target retrieval method according to the query statement; A traversal submodule, for traversing the text content of nodes at each level in the knowledge tree when the target search method is a text search method, and screening out the text content of nodes matching the query statement as a text query result; A semantic model input submodule is used to vectorize the query statement to obtain a vectorized representation of the query statement when the target search method is a semantic search method; perform similarity calculation between the vectorized representation of the query statement and the semantic representation of each layer of nodes in the knowledge tree, and select the text content of the node whose similarity is greater than a preset similarity threshold as the semantic query result; The fusion submodule is used to fuse the text query result and the semantic query result to obtain the final query result.

[0016] Optionally, the fusion submodule includes: A first sorting unit, used to sort the scores of the text query results and the scores of the semantic query results in order from high to low; A score updating unit, configured to update the score of the query result according to the first sequence value of the same query result in the text query result and the second sequence value in the semantic query result; The second sorting unit is used to sort the updated scores of the query results in descending order, and use the query results ranked in the top M positions as the final query results, where M is an integer greater than or equal to 1.

[0017] The technical solution provided by the present invention brings at least the following beneficial effects: The present invention constructs a multi-level knowledge tree structure, traverses nodes at each level of the knowledge tree, and extracts answer text from the multi-level knowledge point level, ensuring that users can not only obtain specific knowledge points when obtaining answers, but also understand their meaning in a broader context. The method described in the present invention provides multi-level information integration capabilities, which not only improves the recall rate of knowledge and the relevance of answers, but also enhances the overall experience of users, allowing them to obtain more comprehensive and accurate answers in complex queries. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 It is a schematic diagram of the steps of a document knowledge question answering method provided by an embodiment of the present invention; Figure 2 is a schematic diagram of a knowledge tree hierarchical architecture provided by an embodiment of the present invention; Figure 3 It is an overall flow chart of a document knowledge question answering method provided by an embodiment of the present invention; Figure 4 It is a structural block diagram of a document knowledge question and answer device provided by an embodiment of the present invention.

[0020] Reference numerals: 201-acquisition module, 202-query module, 203-output module. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0022] With the rapid development of the information age, the generation of massive documents and data has made users face huge challenges in obtaining the required information. Traditional knowledge retrieval often relies on simple keyword matching or character retrieval, which is difficult to effectively understand the user's query intention, resulting in low information recall rate and poor relevance, and cannot meet the user's demand for accurate and comprehensive information. In order to solve the above problems, the present invention proposes to construct a multi-level knowledge tree structure to perform multi-dimensional semantic representation of document content from knowledge points, paragraphs to full text, so as to achieve more accurate knowledge retrieval and question and answer. Not only can the text retrieval or semantic retrieval method be flexibly selected according to the user's query statement, but the results of the two can also be effectively integrated to ensure that the final output answer text is both accurate and contextually complete. The present invention forms a structured knowledge tree by intelligently splitting and clustering documents, so that the semantics of nodes at each layer are clearly distinguishable, which is convenient for subsequent retrieval and question and answer. In this way, users can quickly find the required knowledge in a complex information environment and improve the efficiency and accuracy of information acquisition.

[0023] Figure 1 FIG. 1 is a schematic diagram of steps of a document knowledge question answering method provided by an embodiment of the present invention. Figure 1 As shown, the method includes: Step S101, obtaining a query statement; Step S102, based on the query statement, traverse the nodes of each layer of the knowledge tree in accordance with the target retrieval method to obtain the query result, the knowledge tree includes multiple layers of nodes, the multiple layers of nodes include at least: first layer nodes, second layer nodes and third layer nodes, the semantics of the first layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third layer nodes are the semantics of the text content at the full text level in the document; Step S103: outputting the answer text corresponding to the query statement based on the query result.

[0024] In step S101, the query statement is a statement generated based on the question statement input by the user, and is a statement used to indicate which retrieval method is used to query and specify the query return results. The question statement is an expression of the information that the user wants to obtain from the knowledge base, and is input in the form of natural language. For example, the user may enter "How to improve work efficiency?" as a question statement. Optionally, the question statement input by the user can be obtained through a user-oriented query interface, and the query interface can be a text box in which the user can enter their question statement. After the user submits the question statement, basic input verification can also be performed to ensure that the input is not empty and conforms to a predetermined format (such as character restrictions, prohibition of special characters, etc.). If the user input does not meet the requirements, corresponding prompt information can be provided to guide the user to make correct input. After submitting the question statement, a confirmation page can also be generated accordingly to display the question statement entered by the user for confirmation, and then generate the corresponding query statement.

[0025] Involving step S102, according to the query statement, each layer of nodes in the knowledge tree is traversed in the target retrieval mode to obtain relevant query results. Specifically, before starting to traverse the knowledge tree, the corresponding query statement is determined according to the target retrieval mode. In an embodiment of the present invention, the target retrieval mode includes text retrieval and semantic retrieval. Text retrieval is based on keyword matching, which is used to quickly find knowledge points related to the keywords in the query statement. Semantic retrieval is based on semantic understanding, and is used to obtain knowledge content that is consistent with the overall meaning of the query statement. The knowledge tree is composed of multiple layers of nodes, and each layer of nodes represents knowledge content at a different level. Among them, the first layer nodes contain text content at the knowledge point level, which is specific information or facts. The second layer nodes contain paragraph-level text content, which is a summary or explanation of multiple knowledge points. The third layer nodes contain full-text level text content, which is an overview of the entire document or topic.

[0026] Figure 2 is a schematic diagram of a knowledge tree hierarchical architecture provided by an embodiment of the present invention, such as Figure 2 As shown, level A (knowledge point level) belongs to the first layer of nodes, including six nodes ( Figure 2 1, 2, 3, 4, 5, 6 in the figure), each node represents a specific knowledge point. For example, the topic of air ticket booking is node 1 ( Figure 2 Node 1) is about the basic process of air ticket booking, including how to select a flight and input personal information. Figure 2 Node 2) is information about "common air ticket booking platforms". Figure 2 3) in the figure is information about "air ticket price comparison", and the text content includes how to compare air ticket prices on different platforms. Figure 2Node 4) is information about "visa requirements", and the text content includes the entry visa policies of different countries. Figure 2 Node 5) is information about "Baggage Regulations", and the text content includes the restrictions and requirements of each airline on luggage. Figure 2 6) in the figure is information about "payment methods", and the text content includes supported payment methods and notes. Level B (paragraph level) belongs to the second-level node and includes three nodes ( Figure 2 7, 8, and 9 in the figure), these nodes are paragraph-level knowledge blocks formed by aggregating the contents of the first-level nodes. For example, node 7 ( Figure 2 Node 7 in ( ) is aggregated from nodes 5 and 6 and contains information about “how to compare airfares, understand baggage regulations, and choose the right payment method.” Node 8 ( Figure 2 Node 8 in ( ) is aggregated from nodes 1 and 3 and contains information about “the basic process of air ticket booking and the importance of price comparison”. Node 9 ( Figure 2 9) is aggregated from nodes 2 and 4 and contains information about “common air ticket booking platforms and their visa requirements”. Level C (paragraph level) also belongs to the second-level nodes and includes two nodes ( Figure 2 10 and 11) are higher-level paragraph-level knowledge blocks formed by aggregating the content of the second-level nodes. Figure 2 Node 10) is aggregated from nodes 7 and 8 and contains comprehensive information about “the comprehensive process of air ticket booking, including how to choose a platform, compare prices, understand baggage regulations and payment methods”. Node 11 ( Figure 2 11) is aggregated from nodes 7 and 10, and contains more extensive content about "strategies and precautions for air ticket booking". Level D (full text level) is node 12 ( Figure 2 12 in the figure), which is obtained by aggregating nodes 10 and 11. Level D belongs to the third-level node, representing the top-level summary of the entire knowledge tree, and contains comprehensive information about "comprehensive strategies and best practices for air ticket booking". Node 12 is the node that brings together the essence of all lower-level nodes. Users can obtain the most comprehensive knowledge by querying node 12.

[0027] Involving step S103, after obtaining the relevant query results, the query results are integrated and processed to generate the final answer text. According to the relevance and importance of the query results, the content that best matches the user's question is screened out. This can be done by analyzing the score of each result, relevance indicators, etc. Finally, the generated answer text is output to the user. This can be achieved in a variety of ways, for example, the generated answer text is directly displayed on the user's query interface, or a confirmation page can be generated to display the answer text for the user to confirm.

[0028] The present invention constructs a multi-level knowledge tree structure and traverses nodes at each level of the knowledge tree, and can extract answer texts from the multi-level knowledge point level, ensuring that users can not only obtain specific knowledge points when obtaining answers, but also understand their meaning in a broader context. The method described in the present invention provides multi-level information integration capabilities, which not only improves the recall rate of knowledge and the relevance of answers, but also enhances the overall experience of users, allowing them to obtain more comprehensive and accurate answers in complex queries, thereby effectively solving the problems of missing information and incomplete understanding in related technologies.

[0029] In an optional embodiment, based on the query statement, each layer of nodes in the knowledge tree is traversed according to the target retrieval method to obtain a query result, including: determining the type of the target retrieval method according to the query statement; when the type of the target retrieval method is a text retrieval method, traversing the text content of each layer of nodes in the knowledge tree, screening out the text content of the nodes matching the query statement and using it as a text query result; when the type of the target retrieval method is a semantic retrieval method, vectorizing the query statement to obtain a vectorized representation of the query statement; calculating the similarity between the vectorized representation of the query statement and the semantic representation of each layer of nodes in the knowledge tree, screening out the text content of the nodes whose similarity is greater than a preset similarity threshold and using it as a semantic query result; fusing the text query result and the semantic query result to obtain a final query result.

[0030] In an embodiment of the present invention, the query statement includes a first query statement and a second query statement, which correspond to different types of target retrieval methods respectively. The type of the target retrieval method corresponding to the query statement can be determined. The types of target retrieval methods include text retrieval methods and semantic retrieval methods. The first query statement corresponds to the text retrieval method, and the second query statement corresponds to the semantic retrieval method. First, obtain the question statement input by the user, such as "How to book a flight?". When the target retrieval method is a text retrieval method, fill the question statement into the first query statement template to generate the first query statement. The first query statement is explained below with examples.

[0031] {"query":{"match":{"text":"How to book a flight?"}},"size":20}; In the first query statement, "query" defines the search conditions. "match" means using a matching query, which is a text-based query method. ES will analyze the input text and look for related text blocks. "text": is the field name to be queried. In this example, the field name is "text", which indicates the content to be searched in the knowledge tree, which is "How to book a flight?", which is the text of the question statement entered by the user, that is, the information the user wants to retrieve. "size": 20 specifies the number of text query results returned. In this example, a maximum of 20 text blocks that match the query statement will be returned.

[0032] Submit the first query statement to the text retrieval engine, traverse the nodes at each level in the knowledge tree, and select the nodes that match the query statement as the text query result. Assume that in the first-level nodes of the knowledge tree, node 1 is about the "basic process of air ticket booking", node 2 is about the "common air ticket booking platform", node 3 is about "air ticket price comparison", node 4 is about "visa requirements", node 5 is about "baggage regulations", and node 6 is about "payment method". During the text retrieval process, the text content of node 1 and node 2 is related to the text field in the query statement, so the match is successful, while the text content of node 3 is irrelevant to the text field in the query statement, so node 3 does not match the query statement. Finally, the text query result will return node 1 and node 2.

[0033] For the query of semantic retrieval mode, specifically, the question statement is submitted to the pre-trained semantic model to generate a vectorized representation of the question statement. In the embodiment of the present invention, the vectorized representation is a vectorized representation of the semantic vector. For example, assuming that the vectorized representation result of the question statement is: [0.4, 0.6, 0.1, 0.3, 0.5]. The second query statement of KNN is generated according to the vectorized result. The second query statement is explained below with examples.

[0034] {"knn":{"field":"dense_vector","query_vector":[0.4,0.6,0.1,0.3,0.5],"k":5,"num_candidates":50}}; In the second query statement, "knn" indicates that this query behavior is a KNN query, which aims to find the text block that is closest to the query vector based on vector similarity.

[0035] "field":"dense_vector" specifies the field name for KNN search. In this example, the field name is "dense_vector", which means that the vectorized representation of the text block is stored in this field for calculating similarity.

[0036] "query_vector":[0.4,0.6,0.1,0.3,0.5] is the vectorized representation of the question sentence provided by the user, which represents the semantic vector of the content that the user wants to retrieve. It is generated by a semantic model (such as the SBERT model) and can capture the semantic information of the text. "k":5: specifies the number of nearest neighbor text blocks to be returned. In this example, setting it to 5 means that the 5 text blocks that are most similar to the semantic vector of the question sentence will be returned. "num_candidates":50 indicates the number of candidate text blocks that will be considered when performing KNN retrieval. In this example, the similarity with the query vector is calculated from the 50 candidate text blocks, and then the 5 most similar text blocks are selected and returned.

[0037] Assume that the node content of the knowledge tree and its corresponding vectorized representation are as follows: the vector of node 1 is [0.5, 0.7, 0.2, 0.3, 0.4], the vector of node 2 is [0.4, 0.5, 0.3, 0.4, 0.2], and the vector of node 3 is [0.3, 0.6, 0.4, 0.5, 0.1]. When calculating the similarity, assume that the cosine similarity between the vector of node 1 and the query vector is 0.78, the similarity of node 2 is 0.65, and the similarity of node 3 is 0.55. According to the set similarity threshold (for example, 0.7), node 1 will be returned as the semantic query result.

[0038] Through the above steps, the present invention can traverse the knowledge tree according to the user's query statement, adopt the two methods of text retrieval and semantic retrieval, filter out relevant node content, and finally integrate these results to generate the answer text required by the user. This not only improves the accuracy of information retrieval, but also better meets the needs of users.

[0039] In an optional implementation, the text query result and the semantic query result are integrated to obtain a final query result, including: sorting the scores of the text query result and the scores of the semantic query result in descending order respectively; updating the score of the query result according to the first sequence value of the same query result in the text query result and the second sequence value in the semantic query result; sorting the updated scores of each query result in descending order, and taking the query results ranked in the top M positions as the final query result, where M is an integer greater than or equal to 1.

[0040] After performing text search and semantic search, two result sets are obtained, namely text query results and semantic query results. For example, the text query results include text query results: node 1 and node 2. The semantic query results only include node 1. Among them, for the text query results, the order value of node 1 is 1, and the order value of node 2 is 2. For the semantic query results, the order value of node 1 is 1, and node 2 is not in the semantic query results, so it is not scored. For the same query result, the first order value in the text query result is and the second order value in the semantic query results , the score can be updated using the following formula:

[0041] In the above formula, is the experience value (default is 60), is the first order value in the text query result, is the second-order value in the semantic query result, is the updated score. Assuming the use =60, then the updated score for node 1 is calculated as follows:

[0042] The updated score for node 2 is calculated as follows:

[0043] Therefore, the updated scores are as follows: Node 1: 0.01639, Node 2: 0.00806. Sorting from high to low results in Node 1 and Node 2. Assuming M=1, the final query result is: Node 1: "Basic process of air ticket booking".

[0044] Through the above steps, the text query results and semantic query results are merged, the scores are updated based on their respective order values, and finally the query result with the highest score is selected as the user's answer. This effectively combines the advantages of the two retrieval methods to ensure that the answers obtained by users are both accurate and relevant.

[0045] The embodiment of the present invention also provides a document knowledge storage method, the method comprising: splitting a document into a plurality of original text blocks, and using the plurality of original text blocks as first-layer nodes of a knowledge tree respectively; clustering the plurality of original text blocks according to their respective semantics to obtain a plurality of text blocks after first clustering, and using the plurality of text blocks after first clustering as second-layer nodes of the knowledge tree, wherein the semantics of each text block after first clustering is generated according to the text content of each original text block clustered into the same class; taking the plurality of text blocks after first clustering as the plurality of original text blocks, iterating Clustering until the iteration stopping condition is met; the clustered text blocks obtained in the clustering process are stored in the database as nodes of each layer of the knowledge tree, wherein each node is used to represent its own semantics and text content; the nodes of each layer of the knowledge tree include at least the first layer nodes, the second layer nodes and the third layer nodes, the semantics of the first layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second layer nodes are the semantics of the text content at the paragraph level in the document, the semantics of the third layer nodes are the semantics of the text content at the full text level in the document, and the knowledge tree is applied to the document knowledge question and answer method as described above.

[0046] First, the input document is split into multiple original text blocks. The original text blocks contain dozens to hundreds of characters and are small enough to facilitate subsequent processing and clustering. Each original text block can be a sentence, a paragraph or other logically complete text unit, and each original text block is a text block with distinct main body. The multiple original text blocks generated above are used as the first-level nodes of the knowledge tree. Each node represents a specific knowledge point in the document and contains specific information or facts. According to the semantic features of each original text block, these text blocks are clustered. The goal of clustering is to classify text blocks with similar semantics into one category to form a new text block. The clustered text blocks are used as the second-level nodes of the knowledge tree. The semantics of each second-level node is generated by analyzing and summarizing the content of the same type of original text blocks, which can better reflect the theme of this type of text. Based on the text blocks after the first clustering, iterative clustering is continued. This process will be repeated until the preset iteration stop condition is met. In the embodiment of the present invention, the iteration stop condition can be until the node can no longer continue to cluster. The final clustering result will form the third-level node of the knowledge tree, representing a higher-level concept or theme.

[0047] In an embodiment of the present invention, each layer of nodes of the knowledge tree includes at least a first layer of nodes, representing the text content at the knowledge point level in the document, and each node corresponds to a specific knowledge point; a second layer of nodes, representing the text content at the paragraph level, is a summary or explanation of multiple knowledge points; and a third layer of nodes, representing the text content at the full text level, summarizing the theme or core idea of ​​the entire document. Each node generated during the clustering process, including its semantics and text content, will be stored in the database for subsequent knowledge retrieval. It can be understood that the knowledge tree, as a carrier for document knowledge storage, is the relationship between input and implementation basis with the document knowledge question and answer method as described above, and constructing a knowledge tree is a prerequisite and basis for implementing document knowledge question and answer. The knowledge tree constructed in this embodiment organizes the content of the document into hierarchical nodes to support multi-scale retrieval operations based on nodes at different levels. In an embodiment of the present invention, the database is a storage carrier equipped with an ElasticSearch engine. Optionally, each layer of nodes is generated, and the nodes of the layer are stored layer by layer, and the nodes of all layers can also be uniformly saved after the clustering is completed.

[0048] The document knowledge storage method of the embodiment of the present invention constructs a structured knowledge tree by splitting, clustering and hierarchical storage of documents. It not only improves the efficiency of knowledge organization and storage, but also provides a good foundation for subsequent knowledge retrieval and question-answering, ensuring that users can quickly obtain the required information. As a result, the knowledge content in the document is effectively managed and utilized, improving the overall user experience.

[0049] In an optional embodiment, the top-level node in the knowledge tree is the multiple original text blocks, and each layer of nodes except the top-level node is obtained by clustering the text blocks corresponding to the nodes in the previous layer, and the semantics of the text blocks corresponding to each layer of nodes except the top-level node are obtained according to the text content of each text block clustered into the same category; according to the respective semantics of the multiple original text blocks, the multiple original text blocks are clustered to obtain multiple text blocks after the first clustering, including: according to the respective semantics of the multiple original text blocks, the multiple original text blocks are clustered to obtain N clustering results, where N is an integer greater than 1; according to the text content of each original text block clustered into the nth category, an nth summary is generated, and the nth summary is used as the text content of the nth text block after the first clustering, where n is an integer from 1 to N; according to the nth summary, the semantics of the nth text block after the first clustering is obtained.

[0050] In the knowledge tree structure constructed by the present invention, the top-level node contains multiple original text blocks. Each layer of nodes except the top-level node is a node of the upper layer that is grouped by a clustering algorithm, and a summary of each group is generated to form a new text block. The clustering algorithm can be a clustering algorithm of a Gaussian mixture model. The semantic information of each layer of nodes is defined by the summary generated by clustering the upper layer nodes. For the original text block (top-level node), similar to the example described above, for the multiple text blocks obtained by document splitting, it is assumed that text block 1 is about "the basic process of air ticket booking", and the text content includes how to select a flight, enter personal information, etc. Text block 2 is about "common air ticket booking platforms". Text block 3 is about "air ticket price comparison", and the text content includes how to compare prices on different platforms. Text block 4 is about "visa requirements", and the text content includes entry visa policies of different countries. Text block 5 is about "baggage regulations", and the text content includes baggage restrictions and requirements of each airline. Text block 6 is about "payment method", and the text content includes payment method and precautions. The semantics of these text blocks are analyzed using a semantic model, and clustered according to semantic similarity. Assume that the clustering algorithm divides these original text blocks into two clustering results: Cluster 1: Text Block 1 (Basic Process of Air Ticket Booking), Text Block 3 (Air Ticket Price Comparison), Text Block 6 (Payment Method). Cluster 2: Text Block 2 (Common Air Ticket Booking Platform), Text Block 4 (Visa Requirements), Text Block 5 (Baggage Regulations). Each clustering result generates a summary, which is used as the content of the clustered text block. The first clustered text block contains "content about the importance of air ticket booking process and price comparison and how to choose a payment method". The second clustered text block contains "content about common air ticket booking platforms, baggage regulations and visa requirements". At this point, the second-level node of the knowledge tree consists of two clustered text blocks. The content of each text block is the semantic content defined by the summary generated in the previous step. The text blocks after the first clustering are further clustered. Assume that the clustering algorithm further aggregates the two text blocks in the second-level node into a high-level clustering result, which contains "comprehensive information about the process of air ticket booking, common booking platforms, baggage regulations, payment methods and visa requirements". The summary content of the clustering result is the content of the top-level node, which becomes a comprehensive summary of air ticket booking, including the booking process, platform selection, baggage requirements, payment methods and visa matters.

[0051] The initial raw text blocks are clustered to form higher-level knowledge nodes. Through layer-by-layer abstraction, the detailed content of the lower-level nodes is integrated into higher-level summary nodes. The top-level node contains a comprehensive semantic summary of the topic of "air ticket booking" in the entire knowledge tree, so that users can not only obtain specific information when querying, but also understand the complete background through high-level nodes.

[0052] In an optional implementation, generating an nth summary based on the text content of each original text block clustered into the nth category includes: replacing the target text in the prompt text of the large language model with the text content of each original text block clustered into the nth category, the large language model being used to generate a corresponding summary based on the target text; and inputting the replaced prompt text into the large language model to obtain the nth summary.

[0053] After clustering a set of raw text blocks, the contents of the raw text blocks belonging to the same cluster (nth category) are integrated and the corresponding summaries are generated using the large language model. Specifically, all raw text blocks are clustered first. For example, assuming that all text blocks belong to the same topic (such as "ticket booking"), they are divided into several cluster categories according to the similarity of the content, such as category 1, category 2, etc. The text block content in each category has a certain semantic similarity, for example, category 1 can be "booking process", category 2 can be "payment method", etc. In order to generate a summary for each category (nth category), a pre-trained large language model (for example, a Generative Pre-trained Transformer (GPT) model) is selected for natural language processing. A prompt text template (Prompt Template) is required to pass instructions for generating summaries to the large language model. The prompt text template contains general instructions for instructing the model to generate summaries, such as: "Please generate a summary based on the following content." Assuming that the nth cluster contains multiple related text blocks, the contents of these text blocks are spliced ​​or combined into a whole input. The general instruction part in the prompt text template is retained, and the target text part is replaced with the content of these text blocks to guide the large language model to generate an accurate cluster summary. For example, the template prompt can be: "Please generate a summary based on the following content: <text content>", where the <text content> part is replaced by the text block content of the nth category. The processed prompt text (including the replaced text block content of the nth category) is input into the large language model. The large language model analyzes and summarizes the input text content according to the prompt instructions and outputs a concise summary. This summary is generated through the semantic understanding ability of the model to extract the core information in the category. Finally, the large language model returns the summary of the nth category. This summary content represents the core information of all the original text blocks in the category and is a high-level summary of the clustering results.

[0054] The present invention utilizes the text generation capability of a large language model to generate a summary for each cluster of a knowledge tree, making the structure of the knowledge tree more compact and easier to query, thereby helping users to quickly obtain high-quality information in a complex knowledge system.

[0055] In an optional embodiment, the multiple original text blocks are clustered according to their respective semantics to obtain N clustering results, including: inputting the multiple original text blocks into a pre-trained semantic model to obtain vectorized representations of the multiple original text blocks, wherein the vectorized representations are used to represent the semantics; determining the similarity between the vectorized representations of the multiple original text blocks; and clustering a group of original text blocks having similarities greater than a target similarity into one category to obtain the N clustering results.

[0056] The present invention uses vectorized representation and similarity calculation to divide text blocks with similar semantics into several categories. First, multiple original text blocks are processed, with the goal of dividing them into different categories based on semantic features. As mentioned above, each original text block is an independent content, involving different details of the same topic, or different information fragments in a certain field. In order to capture the semantic information of the text blocks, they are input into a pre-trained semantic model, and the semantic model can use a natural language processing model based on deep learning, such as an SBERT model. The semantic model generates a vectorized representation based on the semantic information of the input text, that is, a vectorized representation of the text. The vectorized representation is a numerical vector used to represent the semantic content of the text block. The vector dimension depends on the architecture of the model, for example, BERT may generate a 768-dimensional vector. The vectorized representation of the text block maps each text block to a high-dimensional space, in which texts with similar semantics are closer in space, while texts with greater semantic differences are farther away. Through the vectorized representation, the semantic similarity of different text blocks can be measured. In the embodiment of the present invention, cosine similarity is used to calculate the similarity between vectors. The value of cosine similarity is between -1 and 1, where 1 means completely similar, 0 means irrelevant, and -1 means completely opposite. By calculating the cosine similarity of each pair of text block vectors, the degree of similarity between them can be obtained. The target similarity (for example, 0.8 or 0.9) is set in advance to control the clustering criteria of text blocks. Only when the similarity of two text blocks is greater than this threshold will they be classified into the same category. Using the target similarity, the semantic model will gradually classify similar text blocks to form several semantically similar clusters, and the similarity between text blocks in each cluster is above the threshold. The final number of clusters is recorded as N, that is, N clustering results are obtained. The text blocks in each category of these clustering results are highly semantically related, reflecting similar topics or information.

[0057] The present invention semantically clusters text blocks through vectorized representation and similarity calculation, is suitable for applications such as large-scale text analysis, information extraction and knowledge management, and can automatically form a text category structure with semantic consistency.

[0058] In an optional embodiment, the semantics of the nth text block after the first clustering is obtained according to the nth summary, including: inputting the nth summary into the pre-trained semantic model to obtain the semantics of the nth text block after the first clustering, the training samples of the pre-trained semantic model are question-answer text pairs, the question text in the question-answer text pair is the text of the question asked about the document, and the answer text in the question-answer text pair is the text content of the nodes at different levels of the knowledge tree.

[0059] Based on the nth summary, extract the core information related to the content of the cluster. The nth summary refers to a summarized text that describes the main theme or core information of all the text blocks contained in the nth cluster. The summary represents the overall semantics of this group of text blocks and is used to further analyze the deep meaning of this group of clusters. The summary is passed as input to the pre-trained semantic model to generate a semantic vector related to the nth cluster. The semantic model generates a specific vectorized representation for the summary, reflecting the overall semantics of the cluster. The vectorized representation captures the core information of the cluster and further accurately represents its position and characteristics in the semantic space.

[0060] It should be noted that the semantic model is not trained with ordinary text, but pre-trained with question-answer text pairs. The question-answer text pairs here refer to paired questions and answers, so that the model can understand the way information is asked and answered. The question text is the content of the question asked about the document, which is mainly used to guide the model to focus on a certain aspect of knowledge points or details. The answer text comes from different levels of nodes in the knowledge tree, that is, different levels or subject content in the knowledge system. The knowledge tree organizes information hierarchically so that answers can cover a wide range of topics and levels of detail. During the training process, the answer texts at different nodes help the model understand the hierarchical organization of information, such as different levels of knowledge such as "concept definition", "basic information", and "detailed process". Through the cooperation of question-answer pairs and knowledge tree nodes, the semantic model can capture the logical relationship between questions and answers and the semantic structure of knowledge content.

[0061] By training a semantic model based on question-answer pairs and combining the hierarchical knowledge in the knowledge tree, a more accurate semantic representation is generated for text block clustering. The document knowledge storage method of the present invention can not only realize the semantic clustering of text, but also deeply understand and organize complex knowledge structures, which is convenient for various knowledge management and question-answer applications.

[0062] In an optional embodiment, a document is split into multiple original text blocks, including: based on multiple identifiers, the document is split into multiple paragraphs; when the number of characters in a paragraph is less than a target threshold, the paragraph is regarded as an original text block; when the number of characters in a paragraph is not less than the target threshold, the paragraph is split according to sentence end symbols, and each sub-paragraph obtained by the split is regarded as an original text block.

[0063] In order to ensure that the text blocks after being split have more semantic integrity and clarity in content, the present invention first divides the document into multiple paragraphs according to identifiers in the document (such as titles, paragraph marks, line breaks, etc.).

[0064] Each paragraph covers a topic or semantic unit, which is the basis for subsequent splitting and processing. For example, the original document is as follows: “Business trip application-document change: 1. Employees fill out a business trip application form before going on a business trip, but the business trip itinerary often needs to be changed temporarily.

[0065] 2. Business travel is connected to a certain platform, and the itinerary in the application form is needed to book air tickets and hotels, etc. If the actual itinerary changes, the itinerary information in the application form needs to be changed at the same time to book tickets.

[0066] 3. In the scenarios of attendance and business travel, it is necessary to be able to accurately maintain the schedule of each employee to facilitate the statistics of working hours and intelligent verification of itinerary duplication.

[0067] 4. After the application form is changed, it may not be necessary due to various factors, and the change can be cancelled. The split text block consists of two paragraphs, the first half is: “Business trip application-document change: 1. Employees fill out a business trip application form before going on a business trip, but the business trip itinerary often needs to be changed temporarily.

[0068] 2. Business travel is connected to a certain platform, and you need to use the itinerary in the application form to book air tickets and hotels. If the actual itinerary changes, you need to change the itinerary information in the application form to book tickets. " The second half is: “3. In the scenarios of attendance and business travel, it is necessary to accurately maintain the schedule of each employee, so as to facilitate the statistics of working hours and intelligent verification of itinerary duplication.

[0069] After the application form is changed, it may not be necessary due to various factors, and the change can be canceled. "The sentences are roughly divided by identifiers (such as the numbers "1.", "2.", etc.) to keep the information in each paragraph relatively independent. In order to realize the automatic recognition and segmentation of paragraphs, regular expressions are introduced in text processing. These regular expressions are used to match specific identifiers to help accurately identify paragraph or sentence boundaries for better text segmentation. The rules include line breaks ("\n\n" and "\n"), Chinese periods, exclamation marks and question marks (".|!|?"), English periods, exclamation marks and question marks (followed by a space) (".\s|!\s|?\s"), semicolons (";|;\s"), and commas (",|,\s"). The above regular expressions can be used to intelligently identify text. The text is divided into semantically independent blocks according to the sentence or paragraph boundaries of the text. When splitting paragraphs, if the number of characters in a paragraph is less than a certain target threshold (for example, 500 words), there is no need to split it further and it can be directly treated as an original text block. If the number of characters in a paragraph exceeds the target threshold, it needs to be further split to keep the semantics of the text block clear and avoid information redundancy or inconvenience when processing too long content. When a paragraph exceeds the target threshold, it is split twice according to the sentence end identifier (such as period, question mark, exclamation mark). In this way, the paragraph can be broken down into multiple semantically complete sub-paragraphs, ensuring that the information of each text block is easier to parse and process.

[0070] The document splitting method based on regular expression rules proposed in the present invention can effectively split a document into multiple independent text blocks, maintain the semantic integrity and clarity of each text block, and is suitable for various tasks that require long document parsing. At the same time, reasonable splitting methods and character restrictions help improve the quality of text blocks and provide strong support for subsequent natural language processing tasks (such as information retrieval, text clustering, etc.).

[0071] Before splitting the document, the present invention proposes a method for parsing the document, which supports users to upload documents in different formats, such as TXT, PDF, DOCX, etc. Due to the different document structures and encoding methods of different formats, the parsing methods are also different. Through the file name parser, the format of the file uploaded by the user is identified. The format is judged by checking the suffix of the file name (such as .pdf, .txt, etc.) to select the corresponding parsing method. Specifically, the file name is split into multiple parts by using the "." in the file name as a separator. For example, the file name "Travel Reimbursement Manual.pdf" will be split into ["Travel Reimbursement Manual", "pdf"].

[0072] Take the last element of the array, i.e. "pdf", as the file format. Determine whether the file format is in the supported format list (such as pdf, docx, txt). If the format is not supported, the user will be prompted to change the file format and re-upload. The document parsing method of the present invention is simple and efficient, and can quickly extract the file suffix and perform format verification to ensure that the document uploaded by the user can be correctly parsed.

[0073] After the file format is identified, the corresponding parser is selected according to the file suffix. This process is completed by a pre-configured router, and the router will point to different parsers according to the suffix. The files uploaded by the user are saved locally and a file path is generated. The corresponding parser is found in the routing configuration according to the file suffix. For example, for the ".pdf" suffix, the router will point to the pdfParser parser. The router is configured with parser mappings for different file suffixes, for example: {"pdf": pdfParser, "txt": txtParser, "docx": docxParser}. In this way, the present invention can flexibly respond to document inputs of different formats, extract file content through a suitable parser, and improve the efficiency and compatibility of document parsing.

[0074] Figure 3 is an overall flow chart of a document knowledge question answering method provided by an embodiment of the present invention. Figure 3 As shown, the document content is initially divided into blocks (i.e. Figure 3 Text chunking in : Split the document content into smaller raw text chunks based on preset identifiers (such as paragraphs, titles, etc.). Next, cluster these raw text chunks (i.e. Figure 3 Text aggregation in ): This process classifies text blocks with high similarity into the same category based on the semantic features of each text block. For the clustered text blocks, it will be further determined whether they can be further aggregated. If they can (i.e. Figure 3 ), the existing clustering results are iteratively clustered to continue to aggregate larger semantic units. Each iteration generates a higher level of text block hierarchy, gradually forming multiple clustering layers. When clustering can no longer proceed (i.e. Figure 3 The constructed knowledge tree is stored in the database (i.e. Figure 3 The multi-layer node structure of the knowledge tree is retained in the database, including the text content and semantic information of each node, which facilitates efficient query at different levels.

[0075] The user inputs a question statement and starts the retrieval process by understanding the content and semantics of the question statement. After the query statement is processed, a query statement is generated to match the nodes in the knowledge tree. Based on the query statement, text query and semantic query (i.e. Figure 3 The text query and semantic query results are merged to obtain the final query result. The results of the text query and semantic query are scored and sorted from high to low according to the scores. The content with higher scores in both the text query and semantic query is ranked higher. Finally, the top M query results with the highest scores are selected as the output query results. According to the merged query results (i.e. Figure 3 The fusion search results in the output are the most matching content (i.e. Figure 3 The output content is the output knowledge content in the knowledge tree). These results are extracted from nodes at each level in the knowledge tree to ensure the accuracy and semantic integrity of the answer content. The output content provides knowledge answers related to the query statement, providing users with intuitive and accurate answers.

[0076] Figure 4 is a structural block diagram of a document knowledge question-answering device provided by an embodiment of the present invention. Figure 4 As shown, the device comprises: The acquisition module 201 is used to acquire a query statement; The query module 202 is used to traverse the nodes of each layer of the knowledge tree according to the target retrieval method based on the query statement to obtain the query result, wherein the knowledge tree includes multiple layers of nodes, and the multiple layers of nodes include at least: first-layer nodes, second-layer nodes, and third-layer nodes, wherein the semantics of the first-layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second-layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third-layer nodes are the semantics of the text content at the full-text level in the document; The output module 203 is used to output the answer text corresponding to the query statement based on the query result.

[0077] In an optional implementation, the query module includes: A type determination submodule, used to determine the type of the target retrieval method according to the query statement; A traversal submodule, for traversing the text content of nodes at each level in the knowledge tree when the target search method is a text search method, and screening out the text content of nodes matching the query statement as a text query result; A semantic model input submodule is used to vectorize the query statement to obtain a vectorized representation of the query statement when the target search method is a semantic search method; perform similarity calculation between the vectorized representation of the query statement and the semantic representation of each layer of nodes in the knowledge tree, and select the text content of the node whose similarity is greater than a preset similarity threshold as the semantic query result; The fusion submodule is used to fuse the text query result and the semantic query result to obtain the final query result.

[0078] In an optional embodiment, the fusion submodule includes: A first sorting unit, used to sort the scores of the text query results and the scores of the semantic query results in order from high to low; A score updating unit, configured to update the score of the query result according to the first sequence value of the same query result in the text query result and the second sequence value in the semantic query result; The second sorting unit is used to sort the updated scores of the query results in descending order, and use the query results ranked in the top M positions as the final query results, where M is an integer greater than or equal to 1.

[0079] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, electronic devices and storage media. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0080] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods and apparatuses according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing terminal device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded into a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable terminal device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0081] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0082] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0083] The above is a detailed introduction to a document knowledge question and answer method, a document knowledge storage method and a document knowledge question and answer device provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A document knowledge question answering method, characterized in that: The method comprises: Get the query statement; Based on the query statement, the nodes of each layer of the knowledge tree are traversed in a target retrieval manner to obtain a query result, wherein the knowledge tree includes multiple layers of nodes, and the multiple layers of nodes include at least: first-layer nodes, second-layer nodes, and third-layer nodes, wherein the semantics of the first-layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second-layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third-layer nodes are the semantics of the text content at the full-text level in the document; Based on the query result, an answer text corresponding to the query statement is output.

2. The document knowledge question answering method according to claim 1, characterized in that: Based on the query statement, the nodes at each level of the knowledge tree are traversed according to the target retrieval method to obtain the query results, including: Determining the type of the target retrieval method according to the query statement; When the target search method is a text search method, traverse the text content of nodes at each level in the knowledge tree, filter out the text content of nodes matching the query statement and use it as a text query result; In the case where the target search method is a semantic search method, the query statement is vectorized to obtain a vectorized representation of the query statement; the vectorized representation of the query statement is similarly calculated with the semantic representation of each layer of the nodes in the knowledge tree, and the text content of the nodes whose similarity is greater than a preset similarity threshold is screened out as a semantic query result; The text query result and the semantic query result are integrated to obtain a final query result.

3. The document knowledge question answering method according to claim 2, characterized in that: The text query result and the semantic query result are integrated to obtain a final query result, including: Sorting the scores of the text query results and the scores of the semantic query results in descending order respectively; updating the score of the query result according to the first order value of the same query result in the text query result and the second order value in the semantic query result; The updated scores of the query results are sorted in descending order, and the query results ranked in the top M positions are used as the final query results, where M is an integer greater than or equal to 1.

4. A document knowledge storage method, characterized in that: The method comprises: Splitting the document into multiple original text blocks, and using the multiple original text blocks as first-level nodes of the knowledge tree respectively; According to the semantics of each of the multiple original text blocks, the multiple original text blocks are clustered to obtain multiple text blocks after the first clustering, and the multiple text blocks after the first clustering are used as the second-layer nodes of the knowledge tree, wherein the semantics of each text block after the first clustering is generated according to the text content of each original text block clustered into the same class; Taking the plurality of text blocks after the first clustering as the plurality of original text blocks, performing iterative clustering until an iteration stop condition is met; The clustered text blocks obtained in the clustering process are stored in the database as nodes of each layer of the knowledge tree, wherein each node is used to represent its own semantics and text content; Each layer of nodes in the knowledge tree includes at least the first layer nodes, the second layer nodes and the third layer nodes. The semantics of the first layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third layer nodes are the semantics of the text content at the full-text level in the document. The knowledge tree is applied to the document knowledge question and answer method as described in any one of claims 1 to 3.

5. The document knowledge storage method according to claim 4, characterized in that: The topmost node in the knowledge tree is the multiple original text blocks, and each layer of nodes except the topmost node is obtained by clustering the text blocks corresponding to the nodes in the previous layer, and the semantics of the text blocks corresponding to each layer of nodes except the topmost node are obtained according to the text contents of each text block clustered into the same category; Clustering the multiple original text blocks according to the semantics of each of the multiple original text blocks to obtain multiple text blocks after the first clustering, including: Clustering the multiple original text blocks according to the semantics of each of the multiple original text blocks to obtain N clustering results, where N is an integer greater than 1; Generate an nth summary according to the text content of each original text block clustered into the nth category, and use the nth summary as the text content of the nth text block after the first clustering, where n is an integer from 1 to N; According to the nth summary, the semantics of the nth text block after the first clustering is obtained.

6. The document knowledge storage method according to claim 5, characterized in that: According to the text content of each original text block clustered into the nth category, generate the nth summary, including: Replacing the target text in the prompt text of the large language model with the text content of each original text block clustered into the nth category, the large language model is used to generate a corresponding summary according to the target text; The replaced prompt text is input into the large language model to obtain the nth summary.

7. The document knowledge storage method according to claim 5, characterized in that: Clustering the multiple original text blocks according to the respective semantics of the multiple original text blocks to obtain N clustering results, including: Inputting the plurality of original text blocks into a pre-trained semantic model to obtain vectorized representations of the plurality of original text blocks, wherein the vectorized representations are used to represent semantics; Determining similarities between the vectorized representations of the plurality of original text blocks; A group of original text blocks whose similarity is greater than the target similarity are clustered into one category to obtain the N clustering results.

8. The document knowledge storage method according to claim 7, characterized in that: According to the nth summary, the semantics of the nth text block after the first clustering is obtained, including: The nth summary is input into the pre-trained semantic model to obtain the semantics of the nth text block after the first clustering, wherein the training samples of the pre-trained semantic model are question-answer text pairs, wherein the question text in the question-answer text pair is the text of the question asked about the document, and the answer text in the question-answer text pair is the text content of the nodes at different levels of the knowledge tree.

9. The document knowledge storage method according to claim 4, characterized in that: Split the document into chunks of raw text, consisting of: Based on the multiple identifiers, split the document into multiple paragraphs; When the number of characters in a paragraph is less than the target threshold, the paragraph is regarded as an original text block; When the number of characters in a paragraph is not less than the target threshold, the paragraph is split according to the sentence end symbol, and each sub-paragraph obtained by the split is used as an original text block.

10. A document knowledge question-answering device, characterized in that: The device comprises: The acquisition module is used to obtain the query statement; A query module, used to traverse the nodes of each layer of the knowledge tree according to the target retrieval method based on the query statement to obtain the query result, the knowledge tree includes multiple layers of nodes, and the multiple layers of nodes include at least: first-layer nodes, second-layer nodes and third-layer nodes, the semantics of the first-layer nodes are the semantics of the text content at the knowledge point level in the document, the semantics of the second-layer nodes are the semantics of the text content at the paragraph level in the document, and the semantics of the third-layer nodes are the semantics of the text content at the full-text level in the document; The output module is used to output the answer text corresponding to the query statement based on the query result.

Citation Information

Patent Citations

  • Intelligent question answering method and device based on medical knowledge graph

    CN113505243A

  • Medical auxiliary question and answer method and system based on knowledge calibration and retrieval enhancement

    CN117573843A

  • Short text query expansion enhancement retrieval method based on knowledge base hierarchical tree structure

    CN118861088A

Cited By

  • Document benchmarking method and device, equipment, storage medium and program product

    CN120087353A

  • RAG-based memory enhanced script generation agent system

    CN120337981A

  • A memory-enhanced script generation agent system based on RAG

    CN120337981B

  • Professional report generation system and method, electronic equipment and storage medium

    CN120371989A

  • Coding specification-based domain knowledge chain retrieval method

    CN120523928A