Knowledge question and answer processing method and device, equipment and storage medium
By storing document information in external knowledge sources based on the knowledge tree of the document structure and matching the knowledge granularity of user questions, it solves the problem of misalignment between the knowledge granularity of external data sources and the knowledge granularity of user questions, and improves the accuracy of knowledge Q&A.
Patent Information
- Application Number
- CN202410660742.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-09-06
AI Technical Summary
In existing retrieval enhancement generation technology, the knowledge granularity of external data sources cannot be aligned with the knowledge granularity of user questions, resulting in inaccurate answers.
By using the nodes of the knowledge tree based on the document structure in the external knowledge source to store document information of different document structures, and based on the questions input by the user and the leaf nodes of the knowledge tree, background knowledge information including multiple knowledge granularities is determined to realize the problem and document Matching information granularity to improve answer accuracy.
By starting from the leaf node of the lowest level of granularity in the knowledge tree, the background knowledge information including document information of multiple retrieval granularities that matches the target question is determined, ensuring that the background knowledge information can cover the knowledge granularity corresponding to the target question and improving the target question. accuracy of the answer.
Smart Images

Figure CN118606445A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a knowledge question and answer processing method, device, equipment and storage medium. Background Art
[0002] Retrieval-augmented Generation (RAG) is a technology that uses information from private or proprietary data sources to assist text generation. It improves the output of a large language model by supplementing the original knowledge base of the large language model with background information from external data sources.
[0003] At present, knowledge from external data sources is usually stored in the form of blocks, that is, the knowledge is divided into several fixed-size blocks, each containing a certain amount of relevant data. After receiving the user's question, the knowledge from the external data source will be retrieved in a fixed-size, fixed-information granularity manner.
[0004] However, this approach may result in a situation where the knowledge granularity of the external data source cannot be aligned with the knowledge granularity of the user's question, resulting in inaccurate answers to user questions. Summary of the invention
[0005] The embodiments of the present application provide a knowledge question and answer processing method, device, equipment and storage medium to improve the accuracy of knowledge questions and answers.
[0006] In a first aspect, an embodiment of the present application provides a knowledge question answering processing method, including:
[0007] Receive target questions input by users;
[0008] According to the target question, a target knowledge tree corresponding to the target question is determined; the target knowledge tree is used to store document information based on the document structure; the target knowledge tree has leaf nodes, each of which is used to store sentence information of the document;
[0009] Determine the background knowledge information corresponding to the target question according to the target question and the leaf nodes of the target knowledge tree; the background knowledge information includes document information in the target knowledge tree of at least one retrieval granularity;
[0010] An answer to the target question is determined according to the target question and the background knowledge information.
[0011] In a possible implementation, the target knowledge tree has a root node, the root node includes M first intermediate nodes, each of the first intermediate nodes includes P second intermediate nodes; each of the second intermediate nodes includes N leaf nodes; wherein the root node is used to store the title information of the document; the first intermediate node is used to store the chapter information of the document; the second intermediate node is used to store the paragraph information of the document; each leaf node includes sentence information and a first feature vector of the sentence information; M is an integer greater than or equal to 0, and P and N are integers greater than or equal to 1.
[0012] In a possible implementation, determining background knowledge information corresponding to the target question according to the target question and a leaf node of the target knowledge tree includes:
[0013] According to the target problem, determining a second eigenvector of the target problem;
[0014] The background knowledge information corresponding to the target question is determined according to the first feature vector and the second feature vector of the leaf node of the target knowledge tree.
[0015] In a possible implementation, determining the background knowledge information corresponding to the target question according to the first feature vector and the second feature vector of the leaf node of the target knowledge tree includes:
[0016] Repeat the following steps until the background knowledge information corresponding to the target question is generated:
[0017] For the i-th leaf node of the j-th second intermediate node, if it is determined that the similarity value between the first feature vector of the i-th leaf node and the second feature vector is greater than or equal to a preset similarity threshold, the i-th leaf node is determined to be a marked leaf node;
[0018] Determine whether the number of marked leaf nodes included in the j-th second intermediate node is greater than or equal to a first preset number threshold;
[0019] If yes, determining the j-th second intermediate node as a marked second intermediate node, and generating background knowledge information corresponding to the target question according to the marked second intermediate node;
[0020] If not, the value of i is determined to be increased by one; until the value of i is determined to be greater than N, the value of j is determined to be increased by one.
[0021] In a possible implementation, the method further includes:
[0022] If it is determined that the value of j is greater than P, then the background knowledge information corresponding to the target problem is generated based on all marked leaf nodes.
[0023] In a possible implementation, generating background knowledge information corresponding to the target question according to the marked second intermediate node includes:
[0024] Repeat the following steps until the background knowledge information corresponding to the target question is generated:
[0025] For the j-th second intermediate node of the k-th first intermediate node, if it is determined that the j-th second intermediate node is a marked second intermediate node, determine whether the number of marked second intermediate nodes included in the k-th first intermediate node is greater than or equal to a second preset number threshold;
[0026] If yes, determining the kth first intermediate node as a marked first intermediate node, and generating background knowledge information corresponding to the target question according to the marked first intermediate node;
[0027] If not, the value of j is determined to be increased by one; until it is determined that the value of j is greater than P, the value of k is determined to be increased by one.
[0028] In a possible implementation, the method further includes:
[0029] If it is determined that the value of k is greater than M, the background knowledge information corresponding to the target problem is generated according to all marked second intermediate nodes.
[0030] In a possible implementation, generating background knowledge information corresponding to the target question according to the marked first intermediate node includes:
[0031] Repeat the following steps until the background knowledge information corresponding to the target question is generated:
[0032] For the kth first intermediate node of the root node, if it is determined that the kth first intermediate node is a marked first intermediate node, determining whether the number of marked first intermediate nodes included in the root node is greater than or equal to a third preset number threshold;
[0033] If yes, determining that the root node is a marked root node, and generating background knowledge information corresponding to the target question according to the marked root node;
[0034] If not, the value of k is determined to be increased by one; until the value of k is determined to be greater than M.
[0035] In a possible implementation, the method further includes:
[0036] If it is determined that the value of k is greater than M, the background knowledge information corresponding to the target problem is generated according to all the marked first intermediate nodes.
[0037] In a possible implementation, the target question has a target document, and the target document is used to indicate an answer to the target question; and according to the target question, determining a target knowledge tree corresponding to the target question includes:
[0038] A target knowledge tree corresponding to the target question is generated according to the target document of the target question.
[0039] In a possible implementation, determining a target knowledge tree corresponding to the target problem according to the target problem includes:
[0040] According to the target problem, determining a second eigenvector of the target problem;
[0041] According to the second feature vector, a target knowledge tree corresponding to the target problem is determined from a preset knowledge base; wherein the knowledge base includes a plurality of knowledge trees.
[0042] In a possible implementation, the knowledge tree has a root node; the root node includes title information and a third feature vector of the title information; and according to the second feature vector, determining a knowledge tree corresponding to the target question from a preset knowledge base includes:
[0043] Determine a similarity value between the second feature vector and a third feature vector of a root node of each knowledge tree in a preset knowledge base;
[0044] The similarity values are sorted, and the knowledge tree corresponding to the maximum similarity value is determined to be the knowledge tree corresponding to the target question.
[0045] In a second aspect, an embodiment of the present application provides a knowledge question and answer processing device, including:
[0046] A receiving module, used for receiving a target question input by a user;
[0047] A first determination module is used to determine a target knowledge tree corresponding to the target question according to the target question; the target knowledge tree is used to store document information based on the document structure; the target knowledge tree has leaf nodes, each of which is used to store sentence information of the document;
[0048] A second determination module is used to determine background knowledge information corresponding to the target question according to the target question and the leaf nodes of the target knowledge tree; the background knowledge information includes document information in the target knowledge tree of at least one retrieval granularity;
[0049] The third determination module is used to determine the answer to the target question according to the target question and the background knowledge information.
[0050] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0051] The memory stores computer-executable instructions;
[0052] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0053] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0054] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0055] The knowledge question and answer processing method, device, equipment and storage medium provided in the embodiment of the present application determine the target knowledge tree based on the document structure that stores document information corresponding to the target question through the target question, and determine the background knowledge information of the document information in the target knowledge tree including at least one retrieval granularity according to the leaf node of the target knowledge tree, so that the answer to the target question can be determined according to the target question and the background knowledge information. In this way, starting from the document information of the leaf node of the lowest level granularity in the knowledge tree, the background knowledge information including the document information of multiple retrieval granularities that matches the target question is determined, ensuring that the background knowledge information can cover the knowledge granularity corresponding to the target question, that is, aligning the knowledge granularity of the target question, and improving the accuracy of the answer to the target question. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0057] Figure 1 A schematic diagram of an application scenario provided for this application;
[0058] Figure 2 A schematic diagram of the structure of a knowledge tree provided for this application;
[0059] Figure 3 Schematic diagram of the process of the knowledge question answering method provided for this application Figure 1 ;
[0060] Figure 4 Schematic diagram of the process of the knowledge question answering method provided for this application Figure 2 ;
[0061] Figure 5 A schematic diagram of the structure of another knowledge tree provided for this application;
[0062] Figure 6 Schematic diagram of the process of the knowledge question answering method provided for this application Figure 3 ;
[0063] Figure 7 A schematic diagram of the structure of the knowledge question and answer processing device provided in this application;
[0064] Figure 8 A schematic diagram of the structure of the electronic device provided in this application.
[0065] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0066] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0067] First, the terms involved in this application are explained:
[0068] Large Language Model (LLM): A deep learning model trained on massive text data. It can not only generate natural language text, but also deeply understand the meaning of the text and handle various natural language tasks such as text summarization, question answering, translation, etc.
[0069] The large language model combined with retrieval enhancement generation technology can retrieve context information from external knowledge sources, so that the large language model can generate answers based on the context information of the external knowledge source to enhance the performance of the large language model.
[0070] At present, knowledge from external data sources is usually stored in the form of blocks, that is, the knowledge is divided into several fixed-size blocks, each containing a certain amount of relevant data. After receiving the user's question, the knowledge from the external data source will be retrieved in a fixed-size, fixed-information granularity manner.
[0071] However, this approach may result in a situation where the knowledge granularity of the external data source cannot be aligned with the knowledge granularity of the user's question, resulting in inaccurate answers to user questions.
[0072] In view of this, an embodiment of the present application provides a knowledge question and answer processing method, which is based on the document structure in an external knowledge source, uses the nodes of a knowledge tree to store document information of different document structures, and determines background knowledge information including multiple knowledge granularities based on the questions input by the user and the leaf nodes of the knowledge tree, thereby achieving a match between the granularity of the question and the document information and improving the accuracy of the answers to the questions.
[0073] Figure 1 A schematic diagram of an application scenario provided by this application. Figure 1 As shown, the knowledge question answering system includes a server and a client.
[0074] The above-mentioned knowledge question answering system can generate answers to questions based on questions input by users.
[0075] The above-mentioned server is used to generate answers to questions based on questions sent by the client. The server can be a server or a server cluster. The server can be deployed in any environment, such as a cloud environment, or it can be deployed in a distributed manner in different environments, such as partially deployed in an edge environment and partially deployed in a cloud environment. It should be noted that the embodiment of the present application does not limit the architecture of the server. The executor of the embodiment of the present application can be the server.
[0076] In a possible implementation, the server is deployed with a large language model. It should be noted that the embodiment of the present application does not limit the type of the large language model.
[0077] The client is used to display the front-end display interface of the knowledge question-answering system to the user, receive questions input by the user, and display the answers to the questions. The client can be a client of the World Wide Web (WEB) version or an application (APP) version, which is not limited in this application. The client can be deployed on electronic devices, such as mobile phones, computers, tablets, etc.
[0078] In a possible implementation, the above-mentioned knowledge question and answer system may include an external knowledge source. The external knowledge source may be integrated with the above-mentioned server, and the external knowledge source includes a plurality of documents, each of which stores document information in the form of a knowledge tree. In other words, the above-mentioned server includes a plurality of knowledge trees. The external knowledge source may also be separately provided in the above-mentioned knowledge question and answer system, for example, separately provided in the knowledge question and answer system in the form of a database. The database is used to store the external knowledge source, and the external knowledge source includes a plurality of documents, each of which stores document information in the form of a knowledge tree.
[0079] It should be noted that the embodiments of the present application do not limit the configuration method of the external knowledge source.
[0080] A knowledge tree is a conceptual model for representing a knowledge structure. Figure 2 As shown, Figure 2 A schematic diagram of the structure of a knowledge tree provided for this application. The above-mentioned knowledge tree is used to store document information based on the document structure. The document structure refers to the chapter structure of the document, for example, it may include titles, chapters, paragraphs and sentences, etc. It should be noted that the document structure of each document may be the same or different, and the embodiments of this application are not limited here. Document information refers to the content of the document, such as the information of a paragraph of the document or the information of a sentence, etc.
[0081] The above-mentioned knowledge tree has a root node, which includes M first intermediate nodes, each of which includes P second intermediate nodes; and each second intermediate node includes N leaf nodes.
[0082] The above M is an integer greater than or equal to 0, and P and N are integers greater than or equal to 1. It should be understood that a document may not have chapters, so the number of first intermediate nodes may be 0. The embodiment of the present application is described by taking the first intermediate node as an example. It should be noted that, Figure 2 It is only taken as an example that the root node includes two first intermediate nodes, and the number of second intermediate nodes included in each first intermediate node can be the same or different, that is, the P value corresponding to each first intermediate node can be the same or different; the number of leaf nodes included in each second intermediate node can be the same or different, that is, the N value corresponding to each first intermediate node can be the same or different, which is specifically related to the structure of the document information.
[0083] Exemplarily, the root node is used to store the title information of the document; the title information refers to the information of the entire document starting from the document title, that is, the root node includes the entire document information. The first intermediate node is used to store the chapter information of the document; the chapter information refers to the overall information of a chapter starting from the chapter title, that is, the first intermediate node includes the chapter title of the document and each paragraph of the chapter. The second intermediate node is used to store the paragraph information of the document; the paragraph information refers to all sentences in a paragraph of text, that is, the second intermediate node includes multiple sentences belonging to a paragraph. Each leaf node includes sentence information and a first feature vector of the sentence information; the sentence information refers to a sentence, and the first feature vector refers to the semantic feature vector of the sentence information.
[0084] It should be noted that, taking the knowledge tree including the first intermediate node as an example, the leaf node is a node without child nodes, that is, the lowest level of the knowledge tree, the parent node of the leaf node is the second intermediate node; the parent node of the second intermediate node is the first intermediate node; the parent node of the first intermediate node is the root node; the root node has no parent node, that is, the highest level of the knowledge tree. It should be noted that the structure of the target knowledge tree is consistent with the structure of the knowledge tree, and will not be repeated here.
[0085] Optionally, each node in the above knowledge tree has an identifier, and the identifier order of each node is arranged based on the order of the document structure. For example, the first paragraph of the document includes sentences 1 to 3, and the second paragraph includes sentences 4 and 5. The nodes of the obtained knowledge tree can be that the first intermediate node 1 includes leaf nodes 1 to 3, and the second intermediate node 2 includes leaf nodes 4 and 5.
[0086] Through the above-mentioned knowledge tree architecture, document information can be stored in the form of a knowledge tree based on the document structure, which is convenient for subsequent knowledge retrieval.
[0087] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0088] Figure 3 Schematic diagram of the process of the knowledge question answering method provided for this application Figure 1 .like Figure 3 As shown, the method includes:
[0089] S101, receiving a target question input by a user.
[0090] The target question is a question to be answered that is input by the user. It should be noted that the embodiment of the present application does not limit the content of the target question.
[0091] The target question is received by the client of the knowledge question answering system and sent to the server. It should be noted that the embodiment of the present application does not limit how the user inputs the target question on the client. For example, it can be input through the input device of the client device (such as a keyboard), or it can be input through the voice collection device of the client device (such as a microphone).
[0092] S102. Determine a target knowledge tree corresponding to the target problem according to the target problem.
[0093] Exemplarily, the above-mentioned target knowledge tree refers to a knowledge tree corresponding to the target question.
[0094] In a possible implementation, the target question may include an identifier of a knowledge tree, and the server identifies the identifier of the knowledge tree and then determines the target knowledge tree. In other words, the user may specify the target knowledge tree.
[0095] Another possible implementation is that the server is preset with a knowledge base, which includes multiple knowledge trees. According to the target question, the second feature vector of the target question can be determined, and then the knowledge tree matching the second feature vector can be determined from the knowledge base as the target knowledge tree. The second feature vector refers to the semantic vector of the target question.
[0096] Exemplarily, the server may first input the target question into a preset computing model and output the second feature vector of the target question. The preset computing model may be, for example, a BERT model, or other deep learning neural network models that can perform feature vector calculations, which is not limited in the embodiments of the present application. The root node of the above-mentioned knowledge tree may also include a third feature vector of the title information, which refers to the semantic feature vector of the title information. The server may determine the similarity value of the second feature vector and the third feature vector of the root node of each knowledge tree in the preset knowledge base; and sort the similarity values, and determine that the knowledge tree corresponding to the maximum similarity value is the knowledge tree corresponding to the target question.
[0097] In another possible implementation, the target question has a target document, and the target document is used to indicate the answer to the target question. After receiving the target question and the target document, the server generates a target knowledge tree according to the target document.
[0098] Exemplarily, the server can divide the target document into blocks according to a preset regular expression to obtain block information, which can be, for example, title information, chapter information, paragraph information or sentence information. The block information is input into a preset calculation model to determine the semantic feature vector corresponding to the block information, and the block information and its corresponding semantic feature vector are stored in the node corresponding to the block information to obtain the target knowledge tree.
[0099] S103: Determine background knowledge information corresponding to the target question according to the target question and the leaf nodes of the target knowledge tree.
[0100] Exemplarily, the above-mentioned background knowledge information includes document information in the target knowledge tree of at least one retrieval granularity. The background knowledge information may, for example, include sentence information included in the leaf node in the target knowledge tree. In this case, the background knowledge information includes document information of the lowest level of retrieval granularity. The background knowledge information may also include paragraph information included in the second intermediate node in the target knowledge tree. Since the second intermediate node also includes a leaf node, in this case, the background knowledge information includes document information of two retrieval granularities. The background knowledge information may also include chapter information included in the first intermediate node. Since the first intermediate node includes the second intermediate node, and the second intermediate node includes a leaf node, in this case, the background knowledge information includes document information of three retrieval granularities. Alternatively, the background knowledge information includes title information included in the root node in the target knowledge tree. In this case, the background knowledge information includes document information of four retrieval granularities.
[0101] In a possible implementation, the leaf node also includes the first feature vector of the sentence information. The server can first determine the second feature vector of the target question based on the target question, then match the second feature vector with the first feature vectors of all leaf nodes of the target knowledge tree, determine the leaf nodes whose similarity values are greater than or equal to a preset threshold to form a leaf node set, and finally form the background knowledge information corresponding to the target question based on the sentence information included in the leaf nodes in the leaf node set.
[0102] In this way, the background knowledge information can include document information in the target knowledge tree with the minimum retrieval granularity.
[0103] Another possible implementation method is to determine a leaf node of the target knowledge tree whose similarity value between the first feature vector and the second feature vector is greater than or equal to a preset threshold as the starting node, and according to the starting node, based on the principle of depth-first search, determine the highest-level node of the target knowledge tree that meets the preset conditions, and use the document information included in the highest-level node as the background knowledge information corresponding to the target question. The preset condition is that the number of child nodes that meet the preset condition is greater than or equal to the preset number threshold. For example, the preset condition for the parent node of the leaf node is that the number of leaf nodes that meet the similarity value between the first feature vector and the second feature vector is greater than or equal to the preset threshold is greater than or equal to the preset number threshold.
[0104] In this way, the background knowledge information may include document information included in the highest-level node in the target knowledge tree that matches the target question, that is, document information in the target knowledge tree including at least one retrieval granularity.
[0105] S104. Determine the answer to the target question based on the target question and background knowledge information.
[0106] For example, the target question and background knowledge information can be filled into a preset template to obtain a prompt, and the prompt information is input into a preset large language model to output the answer to the target question. The preset template can be, for example, "Please give the answer to [target question] based on [background knowledge information]." It should be noted that the present embodiment of the application does not limit the content of the template.
[0107] The knowledge question-answering processing method provided in the embodiment of the present application determines the target knowledge tree based on the document structure storing document information corresponding to the target question through the target question, and determines the background knowledge information of the document information in the target knowledge tree including at least one retrieval granularity according to the leaf nodes of the target knowledge tree, so that the answer to the target question can be determined according to the target question and the background knowledge information. In this way, starting from the document information of the leaf node of the lowest level granularity in the knowledge tree, the background knowledge information including the document information of multiple retrieval granularities matching the target question is determined, ensuring that the background knowledge information can cover the knowledge granularity corresponding to the target question, that is, aligning the knowledge granularity of the target question, and improving the accuracy of the answer to the target question.
[0108] Figure 4 Schematic diagram of the process of the knowledge question answering method provided for this application Figure 2 ,like Figure 4 As shown, in this embodiment Figure 2 Based on the embodiment, the knowledge question answering processing method is described in detail, and the method includes:
[0109] S201, receiving a target question input by a user.
[0110] It should be noted that this step is similar to the aforementioned step S101 and will not be described again here.
[0111] S202: According to the target problem, determine the target knowledge tree corresponding to the target problem.
[0112] It should be noted that this step is similar to the aforementioned step S102 and will not be repeated here.
[0113] S203: Determine a second eigenvector of the target problem according to the target problem.
[0114] The second feature vector refers to the semantic vector of the target question. The server may first input the target question into a preset computing model and output the second feature vector of the target question. The preset computing model may be, for example, a BERT model, or other deep learning neural network model that can perform feature vector calculation, which is not limited in the present application embodiment.
[0115] S204: Determine background knowledge information corresponding to the target question according to the first eigenvector and the second eigenvector of the leaf node of the target knowledge tree.
[0116] In one example, the following steps S301-S303 are repeatedly performed until background knowledge information corresponding to the target question is generated:
[0117] S301. For the i-th leaf node of the j-th second intermediate node, if it is determined that the similarity value between the first feature vector and the second feature vector of the i-th leaf node is greater than or equal to a preset similarity threshold, the i-th leaf node is determined to be a marked leaf node.
[0118] Exemplarily, the above-mentioned preset similarity threshold is artificially set, and the embodiment of the present application is not limited here, and can be set according to actual needs. The calculation method of the similarity value can be, for example, calculating the cosine similarity between the first eigenvector and the second eigenvector, or other similarity value calculation methods, which are not limited in the embodiment of the present application, and only need to keep the calculation method of the similarity value consistent.
[0119] In one possible implementation, the server can randomly determine a leaf node as the i-th leaf node, see Figure 2 As shown, for example, for leaf node 3, if it is determined that the similarity value between the first eigenvector and the second eigenvector of the leaf node 3 is greater than or equal to the preset similarity threshold, then the leaf node 3 is determined to be a marked leaf node; if it is determined that the similarity value between the first eigenvector and the second eigenvector of the leaf node 3 is less than the preset similarity threshold, then continue to randomly determine the similarity value of another leaf node until a leaf node is determined to be a marked leaf node.
[0120] As another possible implementation method, the server may also take the first leaf node as the i-th leaf node in the order of leaf nodes, for example, leaf node 1. If it is determined that the similarity value between the first eigenvector and the second eigenvector of leaf node 1 is greater than or equal to a preset similarity threshold, then leaf node 1 is determined to be a marked leaf node; if it is determined that the similarity value between the first eigenvector and the second eigenvector of leaf node 1 is less than the preset similarity threshold, the similarity value of leaf node 2 is continued to be determined until a leaf node is determined to be a marked leaf node.
[0121] Optionally, the server can set the leaf node as a marked leaf node by setting the attributes of the leaf node. Alternatively, the identifier of the leaf node whose similarity value between the first feature vector and the second feature vector is greater than or equal to the preset similarity threshold is added to the node set of the second intermediate node to which the leaf node belongs, and the leaf nodes included in the node set of the second intermediate node are all marked leaf nodes. It should be noted that the embodiment of the present application does not limit the method of marking nodes.
[0122] After determining that the i-th leaf node is a marked leaf node in the above manner, step S302 is executed.
[0123] S302: Determine whether the number of marked leaf nodes included in the j-th second intermediate node is greater than or equal to a first preset number threshold.
[0124] Exemplarily, the first preset number threshold may be a fixed value set manually, or may be dynamically determined according to the number of leaf nodes included in the j-th second intermediate node. For example, the first preset number threshold is half of the number of leaf nodes included in the j-th second intermediate node. Figure 2 As shown, taking the second intermediate node 1 as an example, the second intermediate node 1 includes 3 leaf nodes, so the first preset quantity threshold is 1.5.
[0125] In a possible implementation, the server determines whether the number of marked leaf nodes included in the second intermediate node is greater than or equal to a first preset number threshold by determining the attributes of the leaf nodes included in the second intermediate node. Alternatively, the server determines whether the number of marked leaf nodes included in the node set of the second intermediate node is greater than or equal to the first preset number threshold. This determination method is related to the aforementioned method of marking nodes.
[0126] If so, the server determines that the jth second intermediate node is a marked second intermediate node and executes step S303; if not, the value of i is determined to be increased by one; until it is determined that the value of i is greater than N, the value of j is determined to be increased by one.
[0127] It should be noted that the method of determining the second intermediate node as the marked second intermediate node can refer to the method of marking the leaf node in the aforementioned step S301. The two are similar and will not be repeated here.
[0128] Exemplarily, the value of i in this step is greater than N, where N refers to the number of leaf nodes N included in the j-th second intermediate node. After polling all leaf nodes included in the j-th second intermediate node, if the number of marked leaf nodes included in the j-th second intermediate node is still not greater than or equal to the first preset number threshold, it means that the j-th second intermediate node does not match the retrieval granularity of the target question, and the leaf node of the j+1-th second intermediate node of the first intermediate node to which the j-th second intermediate node belongs continues to be polled until the marked second intermediate node can be determined, and the background knowledge information corresponding to the target question is generated based on the marked second intermediate node.
[0129] Optionally, if it is determined that the value of j is greater than P, it means that the target knowledge tree has no marked second intermediate node. In other words, the highest level of retrieval granularity corresponding to the target question is the sentence information included in the leaf node, then the background knowledge information corresponding to the target question is generated based on the sentence information included in all marked leaf nodes. For example, the sentence information included in all marked leaf nodes is integrated in the order of the marked leaf node identifiers to form the background knowledge information.
[0130] S303: Generate background knowledge information corresponding to the target question according to the marked second intermediate node.
[0131] In one example, the server may repeatedly perform the following steps S3031-S3032 until background knowledge information corresponding to the target question is generated:
[0132] S3031. For the jth second intermediate node of the kth first intermediate node, if it is determined that the jth second intermediate node is a marked second intermediate node, determine whether the number of marked second intermediate nodes included in the kth first intermediate node is greater than or equal to a second preset number threshold;
[0133] If so, determine that the kth first intermediate node is a marked first intermediate node, and execute step S3032; if not, determine that the value of j is increased by one; until it is determined that the value of j is greater than P, determine that the value of k is increased by one.
[0134] Exemplarily, the second preset number threshold may be a fixed value set manually, or may be dynamically determined according to the number of marked second intermediate nodes included in the kth first intermediate node. For example, the second preset number threshold is half of the number of marked second intermediate nodes included in the kth first intermediate node. Figure 2 As shown, taking the first intermediate node 1 as an example, the first intermediate node 1 includes 2 second intermediate nodes, so the second preset number threshold is 1. In this step, the value of j is greater than P, and P refers to the number P of second intermediate nodes included in the kth first intermediate node. It should be noted that how to determine the number of marked second intermediate nodes included in the kth first intermediate node, and how to determine that the kth first intermediate node is a marked first intermediate node, are similar to the step description of the aforementioned embodiment, and will not be repeated here.
[0135] If it is determined that the number of marked second intermediate nodes included in the kth first intermediate node is less than the second preset number threshold, then continue to determine whether the j+1th second intermediate node included in the kth first intermediate node is a marked second intermediate node, until all second intermediate nodes included in the kth first intermediate node are polled. If it is still determined that the number of marked second intermediate nodes included in the kth first intermediate node is less than the second preset number threshold, it means that the kth first intermediate node does not match the retrieval granularity of the target question, and continue to poll whether the k+1th first intermediate node included in the root node is a marked first intermediate node, until the marked first intermediate node is determined, and based on the marked first intermediate node, generate background knowledge information corresponding to the target question.
[0136] Optionally, if it is determined that the value of k is greater than M, it means that the target knowledge tree has no marked first intermediate node. In other words, the highest level of retrieval granularity corresponding to the target question is the paragraph information included in the second intermediate node, then the background knowledge information corresponding to the target question is generated based on all marked second intermediate nodes. For example, in the order of marking the second intermediate node identifiers, the paragraph information included in all marked second intermediate nodes is integrated to form the background knowledge information.
[0137] S3032. Generate background knowledge information corresponding to the target question based on the marked first intermediate node.
[0138] In one example, the server may repeatedly perform the following steps S30321-S30322 until background knowledge information corresponding to the target question is generated:
[0139] S30321. For the kth first intermediate node of the root node, if it is determined that the kth first intermediate node is a marked first intermediate node, determine whether the number of marked first intermediate nodes included in the root node is greater than or equal to a third preset number threshold;
[0140] If so, determine that the root node is a marked root node, and execute step S30322; if not, determine that the value of k is increased by one; until it is determined that the value of k is greater than M.
[0141] Exemplarily, the third preset number threshold may be a fixed value set manually, or may be dynamically determined according to the number of first intermediate nodes included in the root node. For example, the third preset number threshold is half of the number of first intermediate nodes included in the root node. Figure 2As shown, the root node includes 2 first intermediate nodes, so the third preset number threshold is 1. In this step, the value of k is greater than M, in which M refers to the number of first intermediate nodes included in the root node. It should be noted that how to determine the number of marked first intermediate nodes included in the root node and how to determine that the root node is a marked root node are similar to the step description of the aforementioned embodiment and will not be repeated here.
[0142] If it is determined that the number of marked first intermediate nodes included in the root node is less than the third preset number threshold, continue to determine whether the k+1th first intermediate node included in the root node is a marked first intermediate node until all first intermediate nodes included in the root node are polled. If it is still determined that the number of marked first intermediate nodes included in the root node is less than the third preset number threshold, it means that the root node does not match the retrieval granularity of the target problem.
[0143] Optionally, if it is determined that the value of k is greater than M, it means that the target knowledge tree has no marked root node. In other words, the highest level of retrieval granularity corresponding to the target question is the chapter information included in the first intermediate node, and then the background knowledge information corresponding to the target question is generated based on all marked first intermediate nodes. For example, in the order of marking the first intermediate node identifiers, the chapter information included in all marked first intermediate nodes is integrated to form the background knowledge information.
[0144] S30322. Generate background knowledge information corresponding to the target question based on the marked root node.
[0145] Exemplarily, the title information included in the tag root node is used as the background knowledge information corresponding to the target question.
[0146] S205: Determine the answer to the target question based on the target question and background knowledge information.
[0147] The knowledge question and answer processing method provided in the embodiment of the present application matches the target question with the leaf nodes of the target knowledge tree, determines step by step whether the second intermediate node, the first intermediate node and the root node of the target knowledge tree match the target question, determines the highest level of document information matching the target question, and then generates background knowledge information based on the document information of the highest level of retrieval granularity matching the target question. The generated background knowledge information may include document information of multiple retrieval granularities matching the target question, and a more accurate answer to the target question can be obtained based on the background knowledge information.
[0148] refer to Figure 5 , Figure 5A schematic diagram of another knowledge tree structure provided by the present application. The following describes in detail how to determine the background knowledge information corresponding to the target question based on the first eigenvector and the second eigenvector of the leaf node of the target knowledge tree.
[0149] Rk represents the kth first intermediate node of the root node R, where k=1 or 2. Rkj represents the jth second intermediate node of the kth first intermediate node, where the value of j depends on the number of second intermediate nodes included in the kth first intermediate node. For example, if the first intermediate node R1 includes 2 second intermediate nodes, the value of j can be 1 or 2. Rkji represents the ith leaf node of the jth second intermediate node of the kth first intermediate node, where the value of i depends on the number of leaf nodes included in the jth second intermediate node of the kth first intermediate node.
[0150] Figure 6 Schematic diagram of the process of the knowledge question answering method provided for this application Figure 3 .like Figure 6 As shown, the method comprises the following steps:
[0151] A leaf node Rkji is randomly determined, and the following steps S401-S411 are repeatedly performed until the background knowledge information corresponding to the target question is generated:
[0152] S401 . For a leaf node Rkji , determine whether the similarity value between the first feature vector and the second feature vector of the leaf node Rkji is greater than or equal to a preset similarity threshold.
[0153] If yes, execute step S402; if no, execute step S404.
[0154] S402: Determine the leaf node Rkji as a marked leaf node.
[0155] S403: Determine whether the number of marked leaf nodes included in the second intermediate node Rkj is greater than or equal to a first preset number threshold.
[0156] If not, execute step S404; if so, execute step S406.
[0157] S404: Determine the value of i and add one.
[0158] S405 . Determine whether the value of i is greater than the number N of leaf nodes included in the second intermediate node Rkj.
[0159] If not, return to step S401; if yes, execute step S408.
[0160] Exemplarily, if it is determined that the value of j is plus one, it means that the second intermediate node Rkj does not meet the condition of becoming a marked second intermediate node, and it is continued to determine whether the other second intermediate nodes included in the first intermediate node Rk meet the condition. When determining whether the other second intermediate nodes included in the first intermediate node Rk meet the condition, it is necessary to re-execute steps S401-S406. If it is determined that none of the second intermediate nodes included in the first intermediate node Rk meet the condition of becoming a marked second intermediate node, then it is determined that the value of k is plus one, and it is determined whether the second intermediate nodes of the other first intermediate nodes of the root node meet the condition. If it is determined that all the second intermediate nodes of the target knowledge tree do not meet the condition of becoming a marked second intermediate node, then the background knowledge information corresponding to the target question is generated based on all the marked leaf nodes.
[0161] S406: Determine the second intermediate node Rkj as a marked second intermediate node.
[0162] Repeat the following steps S until the background knowledge information corresponding to the target question is generated:
[0163] S407: Determine whether the number of marked second intermediate nodes included in the first intermediate node Rk is greater than or equal to a second preset number threshold.
[0164] If not, execute step S408; if so, execute step S410.
[0165] S408. Determine the value of j and add one.
[0166] S409: Determine whether the value of j is greater than the number P of second intermediate nodes included in the first intermediate node Rk.
[0167] If not, return to step S403; if so, execute step S413.
[0168] Exemplarily, if it is determined that the value of k plus one indicates that the first intermediate node Rk does not meet the condition of becoming a marked first intermediate node, it is continued to determine whether other first intermediate nodes included in the root node R meet the condition. When determining whether other first intermediate nodes included in the root node R meet the condition, it is necessary to re-execute steps S401-S410. If it is determined that none of the first intermediate nodes included in the root node R meet the condition of becoming a marked first intermediate node, then the background knowledge information corresponding to the target question is generated based on all marked second intermediate nodes.
[0169] S410: Determine the first intermediate node Rk as the marked first intermediate node
[0170] Repeat the following steps until the background knowledge information corresponding to the target question is generated:
[0171] S411: Determine whether the number of marked first intermediate nodes included in the root node R is greater than or equal to a third preset number threshold.
[0172] If yes, execute step S412; if no, execute step S413.
[0173] S412: Determine the root node R as a marked root node, and generate background knowledge information corresponding to the target question based on the marked root node.
[0174] S413, determine the value of k plus one.
[0175] S414: Determine whether the value of k is greater than the number M of first intermediate nodes included in the root node R.
[0176] If not, return to step S407; if so, execute step S415.
[0177] S415: Generate background knowledge information corresponding to the target question based on all marked first intermediate nodes.
[0178] Exemplarily, if it is determined that the value of k plus one indicates that the root node R does not meet the condition of becoming a marked root node, it is further determined whether other first intermediate nodes included in the root node R are marked first intermediate nodes. If so, it is further determined whether the root node R meets the condition of becoming a marked root node. If not, it is determined that the value of k is increased by one until the value of k is greater than the number M of first intermediate nodes included in the root node R. If it is determined that the root node R does not meet the condition of becoming a marked root node, the background knowledge information corresponding to the target question is generated according to all marked first intermediate nodes.
[0179] Specifically, Figure 5 Taking the knowledge tree structure shown as an example, after determining that the leaf node R111 is a marked leaf node, determine whether the number of marked leaf nodes included in the second intermediate node R11 is greater than or equal to the first preset number threshold. At this time, determine that the number of marked leaf nodes included in the second intermediate node R11 is less than the first preset number threshold, then determine whether the leaf node R112 is a marked leaf node; if the leaf node R112 is determined to be a marked leaf node, return to determine whether the number of marked leaf nodes included in the second intermediate node R11 is greater than or equal to the first preset number threshold; at this time, it can be determined that the number of marked leaf nodes included in the second intermediate node R11 is greater than or equal to the first preset number threshold, then determine that the second intermediate node R11 is a marked second intermediate node. If the leaf nodes R111, R112 and R113 are not marked leaf nodes, then determine whether the second intermediate node R12 is a marked second intermediate node.
[0180] After determining that the second intermediate node R11 is a marked second intermediate node, continue to determine whether the number of marked second intermediate nodes included in the first intermediate leaf node R1 is greater than or equal to the second preset number threshold. At this time, it can be determined that the number of marked second intermediate nodes included in the first intermediate leaf node R1 is greater than or equal to the second preset number threshold, and the first intermediate leaf node R1 is determined to be a marked first intermediate node; and continue to determine whether the number of marked first intermediate nodes included in the root node R is greater than or equal to the third preset number threshold. At this time, it can be determined that the number of marked first intermediate nodes included in the root node R is greater than or equal to the third preset number threshold, and the root node R is determined to be a marked root node.
[0181] If it is determined that the number of marked second intermediate nodes included in the first intermediate leaf node R1 is less than the second preset number threshold, then continue to determine whether the second intermediate node R12 is a marked second intermediate node. If it is determined that both the second intermediate nodes R11 and R12 are not marked second intermediate nodes, then it is determined that the first intermediate node R1 is not a marked first intermediate node, and then determine whether the first intermediate node R2 is a marked first intermediate node.
[0182] According to the above method, the highest-level node among the marked nodes in the target knowledge tree can be determined, and the background knowledge information can be generated according to the highest-level marked node.
[0183] The knowledge question and answer processing method provided in the embodiment of the present application starts from the leaf node of the target knowledge tree, and based on the depth-first search principle, determines step by step whether the second intermediate node, the first intermediate node and the root node of the target knowledge tree match the target question, determines the highest-level document information matching the target question, and then generates background knowledge information based on the document information of the highest-level retrieval granularity matching the target question. The generated background knowledge information may include document information of multiple retrieval granularities matching the target question, and a more accurate answer to the target question can be obtained based on the background knowledge information.
[0184] Figure 7 A schematic diagram of the structure of the knowledge question answering processing device provided in this application, such as Figure 7 As shown, the knowledge question answering processing device 50 provided in this embodiment includes:
[0185] A receiving module 51 is used to receive a target question input by a user;
[0186] A first determination module 52 is used to determine a target knowledge tree corresponding to the target question according to the target question; the target knowledge tree is used to store document information based on the document structure; the target knowledge tree has leaf nodes, each of which is used to store sentence information of the document;
[0187] A second determination module 53 is used to determine background knowledge information corresponding to the target question according to the target question and the leaf nodes of the target knowledge tree; the background knowledge information includes document information in the target knowledge tree of at least one retrieval granularity;
[0188] The third determination module 54 is used to determine the answer to the target question according to the target question and the background knowledge information.
[0189] In a possible implementation, the target knowledge tree has a root node, the root node includes M first intermediate nodes, each of the first intermediate nodes includes P second intermediate nodes; each of the second intermediate nodes includes N leaf nodes; wherein the root node is used to store the title information of the document; the first intermediate node is used to store the chapter information of the document; the second intermediate node is used to store the paragraph information of the document; each leaf node includes sentence information and a first feature vector of the sentence information; M is an integer greater than or equal to 0, and P and N are integers greater than or equal to 1.
[0190] In a possible implementation, the second determination module 53 is used to determine a second eigenvector of the target problem according to the target problem; and determine background knowledge information corresponding to the target problem according to the first eigenvector and the second eigenvector of the leaf node of the target knowledge tree.
[0191] In a possible implementation, the second determining module 53 is specifically configured to repeatedly perform the following steps until background knowledge information corresponding to the target question is generated:
[0192] For the i-th leaf node of the j-th second intermediate node, if it is determined that the similarity value between the first feature vector of the i-th leaf node and the second feature vector is greater than or equal to a preset similarity threshold, the i-th leaf node is determined to be a marked leaf node;
[0193] Determine whether the number of marked leaf nodes included in the j-th second intermediate node is greater than or equal to a first preset number threshold;
[0194] If yes, determining the j-th second intermediate node as a marked second intermediate node, and generating background knowledge information corresponding to the target question according to the marked second intermediate node;
[0195] If not, the value of i is determined to be increased by one; until the value of i is determined to be greater than N, the value of j is determined to be increased by one.
[0196] In a possible implementation, the second determination module 53 may also be configured to generate background knowledge information corresponding to the target question based on all marked leaf nodes when it is determined that the value of j is greater than P.
[0197] In a possible implementation, the second determining module 53 is specifically configured to repeatedly perform the following steps until background knowledge information corresponding to the target question is generated:
[0198] For the j-th second intermediate node of the k-th first intermediate node, if it is determined that the j-th second intermediate node is a marked second intermediate node, determine whether the number of marked second intermediate nodes included in the k-th first intermediate node is greater than or equal to a second preset number threshold;
[0199] If yes, determining the kth first intermediate node as a marked first intermediate node, and generating background knowledge information corresponding to the target question according to the marked first intermediate node;
[0200] If not, the value of j is determined to be increased by one; until it is determined that the value of j is greater than P, the value of k is determined to be increased by one.
[0201] In a possible implementation, the second determination module 53 may also be configured to, when it is determined that the value of k is greater than M, generate background knowledge information corresponding to the target problem according to all marked second intermediate nodes.
[0202] In a possible implementation, the second determining module 53 is specifically configured to repeatedly perform the following steps until background knowledge information corresponding to the target question is generated:
[0203] For the kth first intermediate node of the root node, if it is determined that the kth first intermediate node is a marked first intermediate node, determining whether the number of marked first intermediate nodes included in the root node is greater than or equal to a third preset number threshold;
[0204] If yes, determining that the root node is a marked root node, and generating background knowledge information corresponding to the target question according to the marked root node;
[0205] If not, the value of k is determined to be increased by one; until the value of k is determined to be greater than M.
[0206] In a possible implementation, the second determination module 53 may also be configured to, when it is determined that the value of k is greater than M, generate background knowledge information corresponding to the target problem according to all marked first intermediate nodes.
[0207] In a possible implementation, the target question has a target document, and the target document is used to indicate the answer to the target question; the first determination module 52 is used to generate a target knowledge tree corresponding to the target question according to the target document of the target question.
[0208] In a possible implementation, the first determination module 52 is used to determine a second feature vector of the target problem based on the target problem; based on the second feature vector, determine a target knowledge tree corresponding to the target problem from a preset knowledge base; wherein the knowledge base includes multiple knowledge trees.
[0209] In one possible implementation, the knowledge tree has a root node; the root node includes title information and a third feature vector of the title information; a first determination module 52 is used to determine the similarity value between the second feature vector and the third feature vector of the root node of each knowledge tree in a preset knowledge base; sort the similarity values, and determine that the knowledge tree corresponding to the maximum similarity value is the knowledge tree corresponding to the target problem.
[0210] The knowledge question and answer processing device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0211] Figure 8 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 8 As shown, the electronic device 60 provided in this embodiment includes: at least one processor 601 and a memory 602. Optionally, the device 60 also includes a communication component 603. The processor 601, the memory 602 and the communication component 603 are connected via a bus 604.
[0212] In a specific implementation process, at least one processor 601 executes the computer execution instructions stored in the memory 602, so that at least one processor 601 executes the above method.
[0213] The specific implementation process of the processor 601 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0214] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0215] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0216] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0217] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0218] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0219] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0220] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0221] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0222] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0223] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0224] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0225] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0226] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A knowledge question answering method, It is characterized in that The method comprises: Receive target questions input by users; According to the target question, a target knowledge tree corresponding to the target question is determined; the target knowledge tree is used to store document information based on the document structure; the target knowledge tree has leaf nodes, each of which is used to store sentence information of the document; Determine the background knowledge information corresponding to the target question according to the target question and the leaf nodes of the target knowledge tree; the background knowledge information includes document information in the target knowledge tree of at least one retrieval granularity; An answer to the target question is determined according to the target question and the background knowledge information.
2. The method according to claim 1, It is characterized in that The target knowledge tree has a root node, the root node includes M first intermediate nodes, each of the first intermediate nodes includes P second intermediate nodes; each of the second intermediate nodes includes N leaf nodes; wherein the root node is used to store the title information of the document; the first intermediate node is used to store the chapter information of the document; the second intermediate node is used to store the paragraph information of the document; each leaf node includes sentence information and a first feature vector of the sentence information; M is an integer greater than or equal to 0, and P and N are integers greater than or equal to 1.
3. The method according to claim 2, It is characterized in that Determining background knowledge information corresponding to the target question according to the target question and the leaf nodes of the target knowledge tree includes: According to the target problem, determining a second eigenvector of the target problem; The background knowledge information corresponding to the target question is determined according to the first feature vector and the second feature vector of the leaf node of the target knowledge tree.
4. The method according to claim 3, It is characterized in that Determining background knowledge information corresponding to the target question according to the first feature vector and the second feature vector of the leaf node of the target knowledge tree includes: Repeat the following steps until the background knowledge information corresponding to the target question is generated: For the i-th leaf node of the j-th second intermediate node, if it is determined that the similarity value between the first feature vector of the i-th leaf node and the second feature vector is greater than or equal to a preset similarity threshold, the i-th leaf node is determined to be a marked leaf node; Determine whether the number of marked leaf nodes included in the j-th second intermediate node is greater than or equal to a first preset number threshold; If yes, determining the j-th second intermediate node as a marked second intermediate node, and generating background knowledge information corresponding to the target question according to the marked second intermediate node; If not, the value of i is determined to be increased by one; until the value of i is determined to be greater than N, the value of j is determined to be increased by one.
5. The method according to claim 4, It is characterized in that The method further comprises: If it is determined that the value of j is greater than P, then the background knowledge information corresponding to the target problem is generated based on all marked leaf nodes.
6. The method according to claim 4, It is characterized in that Generating background knowledge information corresponding to the target question according to the marked second intermediate node includes: Repeat the following steps until the background knowledge information corresponding to the target question is generated: For the j-th second intermediate node of the k-th first intermediate node, if it is determined that the j-th second intermediate node is a marked second intermediate node, determine whether the number of marked second intermediate nodes included in the k-th first intermediate node is greater than or equal to a second preset number threshold; If yes, determining the kth first intermediate node as a marked first intermediate node, and generating background knowledge information corresponding to the target question according to the marked first intermediate node; If not, the value of j is determined to be increased by one; until it is determined that the value of j is greater than P, the value of k is determined to be increased by one.
7. The method according to claim 6, It is characterized in that The method further comprises: If it is determined that the value of k is greater than M, the background knowledge information corresponding to the target problem is generated according to all marked second intermediate nodes.
8. The method according to claim 6, It is characterized in that Generating background knowledge information corresponding to the target question according to the marked first intermediate node includes: Repeat the following steps until the background knowledge information corresponding to the target question is generated: For the kth first intermediate node of the root node, if it is determined that the kth first intermediate node is a marked first intermediate node, determining whether the number of marked first intermediate nodes included in the root node is greater than or equal to a third preset number threshold; If yes, determining that the root node is a marked root node, and generating background knowledge information corresponding to the target question according to the marked root node; If not, the value of k is determined to be increased by one; until the value of k is determined to be greater than M.
9. The method according to claim 8, It is characterized in that The method further comprises: If it is determined that the value of k is greater than M, the background knowledge information corresponding to the target problem is generated according to all the marked first intermediate nodes.
10. The method according to any one of claims 1 to 9, It is characterized in that The target question has a target document, and the target document is used to indicate an answer to the target question; According to the target problem, determining a target knowledge tree corresponding to the target problem includes: A target knowledge tree corresponding to the target question is generated according to the target document of the target question.
11. The method according to any one of claims 1 to 9, It is characterized in that According to the target problem, determining a target knowledge tree corresponding to the target problem includes: According to the target problem, determining a second eigenvector of the target problem; According to the second feature vector, a target knowledge tree corresponding to the target problem is determined from a preset knowledge base; wherein the knowledge base includes a plurality of knowledge trees.
12. The method according to claim 11, It is characterized in that The knowledge tree has a root node; the root node includes title information and a third feature vector of the title information; according to the second feature vector, a knowledge tree corresponding to the target question is determined from a preset knowledge base, including: Determine a similarity value between the second feature vector and a third feature vector of a root node of each knowledge tree in a preset knowledge base; The similarity values are sorted, and the knowledge tree corresponding to the maximum similarity value is determined to be the knowledge tree corresponding to the target question.
13. A knowledge question and answer processing device, It is characterized in that The device comprises: A receiving module, used for receiving a target question input by a user; A first determination module is used to determine a target knowledge tree corresponding to the target question according to the target question; the target knowledge tree is used to store document information based on the document structure; the target knowledge tree has leaf nodes, each of which is used to store sentence information of the document; A second determination module is used to determine background knowledge information corresponding to the target question according to the target question and the leaf nodes of the target knowledge tree; the background knowledge information includes document information in the target knowledge tree of at least one retrieval granularity; The third determination module is used to determine the answer to the target question according to the target question and the background knowledge information.
14. An electronic device, It is characterized in that include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 12 when executed by a processor.
Citation Information
Patent Citations
Compact text extraction method based on text similarity relation
CN106202405A
Large model retrieval enhancement generation method and device
CN117891838A
Question and answer processing method and device
CN117972048A
Knowledge graph updating method and apparatus, and storage medium and electronic apparatus
WO2024021407A1
Cited By
Question and answer method and device, equipment, storage medium and program product
CN121144436A
