Question answering method based on knowledge base and knowledge question answering system

By segmenting, encoding and classifying knowledge base entries and constructing a second knowledge base with a tree structure, the problem of incomplete answers given by the intelligent question-answering system is solved, and comprehensive and accurate answers are achieved.

CN120653750APending Publication Date: 2025-09-16SHANDONG CHAOYUE DATA CONTROL ELECTRONICS CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510804787.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-16
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

The intelligent question-answering system based on the knowledge base provides incomplete answers when answering user questions.

Method used

By segmenting and encoding the items in the first knowledge base, generating item vectors, and classifying the vectors, a second knowledge base with a tree structure is constructed, and the matching degree between the nodes and the question information is used to determine the answer information.

Benefits of technology

It achieves comprehensive and accurate answers to user questions, avoiding one-sided and redundant answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653750A_ABST
    Figure CN120653750A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of knowledge question answering, and discloses a question answering method based on a knowledge base and a knowledge question answering system. The knowledge base-based question and answer method provided by the invention comprises the following steps of: segmenting and coding a plurality of entries in a first knowledge base to obtain a plurality of entry vectors; classifying the plurality of entry vectors to obtain a plurality of classes; based on the plurality of classes and the entry vectors contained in each class, a second knowledge base of a tree structure is constructed, and nodes corresponding to the classes in the second knowledge base are father nodes of nodes corresponding to the entry vectors contained in the classes; and in response to the received question information, acquiring a node matched with the question information from the second knowledge base, and determining answer information based on the acquired node. Through the embodiment of the invention, the questions of the user can be comprehensively and accurately answered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of knowledge question answering, and in particular to a question answering method and a knowledge question answering system based on a knowledge base. Background Art

[0002] In recent years, with the advancement of deep learning, particularly large-scale pre-trained models based on deep learning architectures, such as OpenAI's GPT and Meta's Llama series, these models, trained on massive amounts of data, have developed powerful language understanding and generation capabilities, achieving remarkable results in various natural language processing tasks. Intelligent question-answering systems, based on large language models and combined with tools and plug-ins such as retrieval-augmented generation (RAG), local knowledge bases, and agents, have also seen rapid development.

[0003] Knowledge-based intelligent question-answering systems are widely used in fields such as equipment production, equipment manufacturing, and logistics and transportation, significantly improving the level of intelligence in these areas. Current knowledge-based intelligent question-answering systems, when receiving user questions, can match the corresponding answers from the knowledge base and return them to the user. However, these matching responses often fail to provide comprehensive answers. Summary of the Invention

[0004] In view of this, the present invention proposes a question-answering method and a knowledge question-answering system based on a knowledge base, which solves the problem that the intelligent question-answering system based on a knowledge base gives incomplete answers when answering user questions.

[0005] In one aspect, an embodiment of the present invention provides a question-answering method based on a knowledge base, the question-answering method based on a knowledge base comprising: Segmenting and encoding a plurality of entries in the first knowledge base to obtain a plurality of entry vectors; Classify several entry vectors to obtain several classes and the entry vectors contained in each class; Based on a plurality of classes and the entry vectors contained in each class, a second knowledge base having a tree structure is constructed, wherein the node corresponding to the class in the second knowledge base is the parent node of the node corresponding to the entry vector contained in the class; In response to receiving the question information, a node matching the question information is acquired from the second knowledge base, and answer information is determined based on the acquired node.

[0006] In some implementations, segmenting and encoding several entries in the first knowledge base to obtain several entry vectors includes: Segmenting a plurality of entries in the first knowledge base according to a first preset rule to obtain a plurality of segmented entries, wherein the first preset rule at least includes: a preset segmentation symbol; The segmented entries are encoded based on the text representation model to obtain entry vectors with spatial location information.

[0007] In some implementations, classifying the plurality of entry vectors includes: Classify several entry vectors according to a dimensionality reduction clustering function.

[0008] In some implementations, classifying the plurality of entry vectors according to the dimensionality reduction clustering function includes: Set the parameters of the dimensionality reduction clustering function based on the number of items and the preset item length; All entry vectors in the first knowledge base are classified according to the dimension reduction clustering function after parameter setting.

[0009] In some implementations, constructing a second knowledge base with a tree structure based on a number of classes and entry vectors contained in each class includes: A second knowledge base is constructed based on the several classes and the entry vectors contained in each class, and in combination with the number of the several entry vectors.

[0010] In some implementations, constructing the second knowledge base based on the plurality of classes and the entry vectors included in each class, and in combination with the number of the plurality of entry vectors, includes: In response to the number of the plurality of entry vectors being less than or equal to a first threshold, a second knowledge base having a three-layer tree structure is constructed based on the plurality of classes, the entry vectors included in each class, and a first tree structure construction factor.

[0011] In some implementations, constructing a second knowledge base having a three-layer tree structure based on the plurality of classes and the entry vectors contained in each class, and the first tree structure construction factor includes: Based on each entry vector in each of the classes, generating a plurality of nodes in the third layer of the tree structure, wherein the entry vectors correspond one-to-one to the nodes in the third layer; Based on the plurality of nodes in the third layer, the classes to which each node belongs, the number of nodes in the third layer, and the first tree structure construction factor, generating a plurality of nodes in the second layer of the tree structure, wherein the nodes in the second layer correspond one-to-one to the classes; Based on the plurality of nodes of the second layer, the number of the second layer nodes and the first tree structure construction factor, a plurality of nodes of the first layer of the tree structure are generated.

[0012] In some embodiments, after classifying several entry vectors to obtain several classes, the method further includes: inputting all entry vectors contained in a class into a language model to extract key information of the class, thereby generating a class vector.

[0013] Constructing a second knowledge base with a tree structure based on the several classes and the entry vectors contained in each class includes: constructing a second knowledge base with a tree structure based on the several classes and the entry vectors contained in each class and the class vectors corresponding to the class.

[0014] In some embodiments, in response to receiving the question information, obtaining a node matching the question information from the second knowledge base, and determining the answer information based on the obtained node includes: In response to receiving the question information, converting the question information into a question vector; Determining a matching degree between the question vector and each node in the second knowledge base to filter out nodes whose matching degrees meet preset conditions; Based on the filtered nodes, answer information corresponding to the question information is generated.

[0015] On the other hand, an embodiment of the present invention also provides a knowledge question and answer system, comprising: at least one processor; and a memory, the memory storing a computer program that can be run on the processor, characterized in that when the processor executes the program, it executes the steps of the method of any of the above embodiments.

[0016] The present invention has at least the following beneficial effects: The present invention provides a question-answering method and a knowledge question-answering system based on a knowledge base. The question-answering method based on a knowledge base provided by the present invention can obtain several classes and the entry vectors contained in each class by classifying several entry vectors of a first knowledge base. A class vector of the class can be generated through all the entry vectors contained in the class. A second knowledge base with a tree structure having multiple layers can be constructed through several classes and their class vectors and the entry vectors contained in each class. In an embodiment of the present invention, through the relationship between the class and each entry vector, it is ensured that the node of the upper layer in the second knowledge base can contain all the information of the corresponding node of the lower layer. Therefore, when question information is received, the content contained in the node that meets the matching requirements can be determined as answer information based on the matching degree of each node with the question information. Through the above scheme, the embodiment of the present invention can comprehensively and accurately answer the user's questions. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0018] Figure 1 A flowchart of a question-answering method based on a knowledge base provided in an embodiment of the present invention; Figure 2a A comparison diagram of several entry vectors before and after classification provided by an embodiment of the present invention; Figure 2b A schematic diagram of the structure of a second knowledge base generated by the knowledge base-based question-answering method provided in an embodiment of the present invention; Figure 3 A flowchart of a question-answering method based on a knowledge base provided in an embodiment of the present invention; Figure 4 A flowchart of a question-answering method based on a knowledge base provided in an embodiment of the present invention; Figure 5 A schematic diagram of question answering based on an open source knowledge base; Figure 6 A schematic diagram of question answering based on an open source knowledge base; Figure 7 A schematic diagram of question answering based on an open source knowledge base; Figure 8 A schematic diagram of the structure of a knowledge question-answering system provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0019] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.

[0020] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. Subsequent embodiments will not explain this one by one.

[0021] In related technologies, the storage structure of the knowledge base in the intelligent question-answering system is a linear storage structure. Therefore, when answering user questions based on the knowledge base, problems such as incomplete answers, high redundancy, and poor matching with the questions are often encountered.

[0022] In order to solve at least one of the above technical problems, the present invention provides a question-answering method and a knowledge question-answering system based on a knowledge base. The present invention is described in detail below with reference to embodiments and accompanying drawings.

[0023] The first aspect of the embodiment of the present invention provides a question-answering method based on a knowledge base, such as Figure 1 As shown, the method specifically includes steps S10 to S13.

[0024] S10. Segment and encode several entries in the first knowledge base to obtain several entry vectors.

[0025] The knowledge base-based question-answering method provided in the embodiment of the present invention can be applied to fields such as equipment production, equipment manufacturing, software information, etc., but is not limited thereto and can also be applied to other fields.

[0026] The first knowledge base in the embodiment of the present invention can be constructed based on the field to which the present invention is applied, and can be a data set covering any one or more of the production specifications, information security and other level requirements, equipment environment and other level requirements, fire safety specifications, etc. that should be complied with in the field, but is not limited to this, and can also be a first knowledge base containing other content.

[0027] In an embodiment of the present invention, each entry stored in the first knowledge base may be segmented according to a preset rule, and the segmented entries may be encoded to obtain a plurality of entry vectors.

[0028] S11. Classify several entry vectors to obtain several categories.

[0029] In the embodiment of the present invention, based on the similarity between each entry vector, the entry vectors with higher similarity can be classified into one category, thereby obtaining several categories, each of which contains at least one entry vector.

[0030] S12. Construct a second knowledge base with a tree structure based on several classes and the entry vectors contained in each class.

[0031] The second knowledge base has multiple layers, and the layer where the node corresponding to the entry vector is located is the next layer where the node corresponding to the class is located, wherein the node corresponding to the class is the parent node of the node corresponding to the entry vector contained in the class.

[0032] In this embodiment of the present invention, a tree-structured second knowledge base can be constructed using several classes and the entry vectors contained in each class. Each class corresponds to a node in the tree structure, and each entry vector corresponds to a node in the tree structure. The node corresponding to a class is the parent node of the node corresponding to the entry vector contained in it. This ensures that the node in the previous layer is a summary node of the corresponding node in the next layer, and the content contained in the node in the previous layer can cover the content contained in all nodes corresponding to the next layer.

[0033] It should be noted here that the content contained in the node is the content represented by the entry vector or the class vector. The class vector can be generated based on all the entry vectors contained in the class, and the class vector can include key information of these entry vectors.

[0034] S13. In response to receiving the question information, obtain nodes matching the question information from the second knowledge base, and determine answer information based on the obtained nodes.

[0035] In embodiments of the present invention, question information may be questions input by a user via a client interface. In some examples, the question information may be questions related to various stages of software development, design, testing, and delivery. For example, how to generate test cases to test software, how to verify the reliability of software products, etc. In some examples, the question information may also be questions related to various stages of equipment development, manufacturing, delivery, and after-sales service. For example, how to conduct feasibility analysis for equipment to be produced, how to avoid quality problems that are prone to occur during equipment manufacturing, etc. It should be understood that the above description of question information is only used to explain the present invention and is not used to limit the present invention.

[0036] In an embodiment of the present invention, if question information is received, a node matching the question can be obtained from the second knowledge base in a tree structure, and answer information corresponding to the question information can be generated based on the obtained node.

[0037] In some embodiments of the present invention, the answer information may be returned to the user who asked the question through the client interface.

[0038] According to an embodiment of the present invention, by classifying several entry vectors of the first knowledge base, several classes and the entry vectors contained in each class can be obtained. Through all the entry vectors contained in the class, the class vector of the class can be generated. Through several classes and their class vectors and the entry vectors contained in each class, a second knowledge base with a tree structure of multiple layers can be constructed. According to an embodiment of the present invention, through the relationship between the class and each entry vector, it is ensured that the node of the upper layer in the second knowledge base can contain all the information of the corresponding node of the lower layer. Therefore, when the question information is received, the content contained in the node that meets the matching degree can be determined as the answer information based on the matching degree of each node with the question information. Through the above scheme, the embodiment of the present invention ensures that the generated answer information can comprehensively and accurately answer the user's question.

[0039] In some embodiments of the present invention, step S10 (segmenting and encoding several entries in the first knowledge base to obtain several entry vectors) may include: segmenting several entries in the first knowledge base according to a first preset rule to obtain several segmented entries; encoding the segmented entries based on a text representation model to obtain entry vectors with spatial position information.

[0040] The first preset rule at least includes: a preset segmentation symbol.

[0041] In an embodiment of the present invention, a plurality of entries in a first knowledge base are segmented according to a first preset rule to obtain a plurality of segmented entries. The first preset rule may include: a preset segmentation symbol. The preset segmentation symbol includes, but is not limited to, ".", "!", etc. For example, the content of an entry is A1, B1, C1. A1, B1, C1, D1. A1, B1, C1, E1, F1. Then, after segmenting the entry, the entries obtained are: [A1, B1, C1], [A1, B1, C1, D1], [A1, B1, C1, E1, F1].

[0042] In some examples, the first preset rule may include a preset entry length in addition to a preset delimiter. If the length of an entry exceeds the preset entry length, the entry is split based on the preset entry length to obtain multiple sub-entries, each of which is within the preset entry length range.

[0043] In an embodiment of the present invention, the segmented entries can be encoded based on a text representation model to obtain an entry vector with spatial position information. The text representation model can be a text representation model such as bge-large-zh or chinese_roformer. For example, if the segmented entry is V1: [A1, B1, C1], then after encoding the segmented entry, the obtained entry vector can be represented as V1=[0.018314670771360397, 0.00942440889775753, -0.36294862627983093]. This entry vector is a vector of floating-point numbers generated according to the text representation model.

[0044] In some embodiments of the present invention, classifying the plurality of entry vectors in step S11 may include classifying the plurality of entry vectors according to a dimensionality reduction clustering function.

[0045] In the embodiment of the present invention, the parameters of the dimensionality reduction clustering function may be set according to the number of entries and the preset entry length, and all entry vectors in the first knowledge base may be classified according to the dimensionality reduction clustering function after the parameter setting.

[0046] Specifically, parameters such as the number of domain points and the distance threshold of the dimensionality reduction clustering function can be set based on the number of entries and the preset entry length. In some examples, the number of domain points can be set based on the number of entries, and the distance threshold can be set based on the preset entry length. An appropriate number of domain points can ensure the effectiveness of the generated clusters, while an appropriate distance threshold can effectively identify different clusters.

[0047] like Figure 2a As shown in FIG, a comparison diagram of several entry vectors before and after classification provided by an embodiment of the present invention. Figure 2a As can be seen on the left, before classification, the entry vectors are irregular. Figure 2a As can be seen on the right, after classification, the entry vectors are arranged according to certain rules, which is regular.

[0048] In some examples, the number of domain points can be the mth power of the number of entries, where m can be between 0.1 and 1, for example, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, or 0.9. In some examples, the number of domain points can be the preset entry length / n, where n can be between 500 and 2000, for example, 800, 1000, 1200, or 1500.

[0049] In a specific example, the number of entries is 100, the preset entry length is 200, m=0.5, n=1000, and the number of domain points is 100. 0.5=10, and the distance threshold is 200 / 1000=0.2, that is, the entries with a distance threshold greater than 0.2 are classified into 1 class.

[0050] The clustering effect of the dimensionality reduction clustering function is improved by using an appropriate number of domain points and an appropriate distance threshold.

[0051] In some examples, a distance measurement algorithm for the dimensionality reduction clustering function can also be set. Since the entry vector is a vector encoding generated based on the text representation model and is a multi-dimensional space vector, the distance measurement algorithm can adopt the angle-related cosine algorithm (cosine), Minkowski-related Euclidean distance (Euclidean) or Manhattan distance (Manhattan) algorithm.

[0052] In some embodiments of the present invention, step S12 (constructing a second knowledge base with a tree structure based on several classes and the entry vectors contained in each class) may include: constructing a second knowledge base based on several classes and the entry vectors contained in each class, and combined with the number of several entry vectors.

[0053] In some embodiments of the present invention, constructing a second knowledge base based on several classes and the entry vectors contained in each class, and combined with the number of several entry vectors, may include: in response to the number of said several entry vectors being less than or equal to a first threshold, based on said several classes and the entry vectors contained in each of said classes, and a first tree structure construction factor, constructing a second knowledge base having a three-layer tree structure.

[0054] In some embodiments of the present invention, constructing a second knowledge base based on several classes and entry vectors contained in each class, and combined with the number of several entry vectors, may include: in response to the number of several entry vectors being greater than a first threshold, based on several classes and entry vectors contained in each class, and a second tree structure construction factor, constructing a second knowledge base with an N-layer tree structure, wherein N>3, and the second tree structure construction factor is greater than or equal to the first tree structure construction factor.

[0055] Specifically, an embodiment of the present invention can set a first threshold and determine whether the number of all entries contained in the second knowledge base is greater than the first threshold. If the number of all entries contained in the second knowledge base is not greater than the first threshold, then a second knowledge base having a three-layer tree structure is generated by combining several classes and the entry vectors contained in each class, as well as a first tree structure construction factor. If the number of all entries contained in the second knowledge base is greater than the first threshold, then a second knowledge base having a tree structure with more than three layers is generated by combining several classes and the entry vectors contained in each class, as well as a second tree structure construction factor.

[0056] For example, the first threshold can be set to 10,000. If the number of all entries in the second knowledge base is not greater than 10,000, the following is generated: Figure 2b The second knowledge base has a 3-layer tree structure as shown.

[0057] like Figure 2b As shown, N1, N2...Nn, M1 are newly generated entry vectors (also called class vectors), N1 contains all the features of A1-F1, N2 contains all the features of A2-D2, Nn contains all the features of A3-F3, and M1 contains all the features of N1-Nn. M1 has a wider coverage.

[0058] In some embodiments of the present invention, Figure 3 As shown, based on several classes and the entry vectors contained in each class, and the first tree structure construction factor, constructing the second knowledge base with a three-layer tree structure may include steps S301 to S303.

[0059] S301 : Based on each entry vector in each class, generate several nodes in the third layer of the tree structure.

[0060] Among them, the entry vectors correspond one-to-one to the nodes in the third layer.

[0061] S302: Generate several nodes of the second layer of the tree structure based on several nodes of the third layer, the class to which each node belongs, the number of nodes of the third layer, and the first tree structure construction factor.

[0062] The nodes of the second layer correspond to the classes one by one. The first tree structure construction factor can be set according to the actual situation. In some examples, the first tree structure construction factor can be equal to m, and the number of nodes in the second layer can be the mth power of the number of nodes in the third layer.

[0063] S303: Generate several nodes of the first layer of the tree structure based on several nodes of the second layer, the number of nodes of the second layer, and the first tree structure construction factor.

[0064] For ease of understanding, embodiments of the present invention are described below with reference to specific examples. It should be understood that the following examples are used to explain the present invention but are not used to limit the present invention.

[0065] Assuming that the first threshold is 10,000, there are a total of 10,000 entry vectors in the second knowledge base, and m=0.5, then a second knowledge base with a three-layer tree structure is generated. The third layer of the tree structure has 10,000 nodes, the number of nodes in the second layer of the tree structure is 10,000 to the power of 0.5 = 100, and the number of nodes in the first layer of the tree structure is 100 to the power of 0.5 = 10.

[0066] Assuming that the first threshold is 10000, there are a total of 1000 entry vectors in the second knowledge base, and m=0.5, then a second knowledge base with a three-layer tree structure is generated. The third layer of the structure tree has 1000 nodes, the number of nodes in the second layer of the structure tree is 1000 to the power of 0.5 = 32, and the number of nodes in the first layer of the structure tree is 32 to the power of 0.5 = 6.

[0067] Assuming that the first threshold is 10,000, there are a total of 2,000 entry vectors in the second knowledge base, and m=0.5, then a second knowledge base with a three-layer tree structure is generated. The third layer of the tree structure has 2,000 nodes, the number of nodes in the second layer of the tree structure is 2,000 to the power of 0.5 = 45, and the number of nodes in the first layer of the tree structure is 45 to the power of 0.5 = 7.

[0068] In some embodiments of the present invention, Figure 4 As shown, based on several classes and the entry vectors contained in each class, and the second tree structure construction factor, constructing the second knowledge base with an N-layer tree structure may include steps S401 to S404.

[0069] S401 : Based on each entry vector in each class, generate several nodes of the Nth layer of the tree structure.

[0070] Among them, N>3, the entry vector corresponds one-to-one to the N-th layer node.

[0071] S402: Based on the plurality of N-th layer nodes and the class to which each N-th layer node belongs, and in combination with the number of the plurality of N-th layer nodes and the second tree structure construction factor, generate a plurality of N-1-th layer nodes of the tree structure.

[0072] The nodes in the N-1th layer correspond to the classes one by one. The second tree structure construction factor may be greater than or equal to the first tree structure construction factor.

[0073] In an embodiment of the present invention, all entry vectors included in a class can also be input into a language model to extract key information of the class, thereby generating a class vector. This class vector can then represent the content of its corresponding N-1th layer node. The key information can be entity words whose frequency of appearance in all entry vectors included in the class is greater than a third threshold.

[0074] In an embodiment of the present invention, for any two adjacent layers of nodes, the number of nodes in the upper layer can be determined by the number of nodes in the lower layer and the construction factor. In some examples, since each node in the N-1 layer corresponds one-to-one to a class, and the class is obtained based on the dimensionality reduction clustering algorithm and the entry vector, the number of nodes in the N-1 layer can be equal to the number of neighborhood points set in the dimensionality reduction clustering algorithm, that is, the number of nodes in the N-1 layer is equal to the mth power of the number of nodes in the N layer, that is, the second tree structure construction factor can be equal to m.

[0075] S403: Determine whether the number of nodes in the N-1th layer is greater than a second threshold.

[0076] The second threshold is used to limit the number of nodes at the top level of the tree structure. The second threshold can be set freely. For example, the second threshold can be 10, 12, 15 or 20, etc., and is not specifically limited here.

[0077] If the number of nodes in the N-1th layer is greater than the second threshold, step S404 is executed to generate nodes in the previous layer of the current layer.

[0078] If the number of nodes in the N-1th layer is not greater than the second threshold, the generation of nodes in the previous layer of the current layer is stopped.

[0079] S404. Replace the Nth layer nodes based on the N-1th layer nodes, replace the number of Nth layer nodes based on the number of N-1th layer nodes, and return to step S402.

[0080] If the number of nodes in the N-1th layer is greater than the second threshold, the nodes in the Nth layer are replaced based on the nodes in the N-1th layer, and the number of several nodes in the Nth layer is replaced based on the number of nodes in the N-1th layer, and steps S402 to S404 are repeated until the number of nodes in the Nith layer is not greater than the second threshold, and the final tree structure is obtained, where i=2,...,k, and k is a positive integer greater than 2.

[0081] When generating nodes of the Ni-th layer, the nodes of the N-i+1-th layer can be classified to obtain several classes corresponding to the nodes of the Ni-th layer. Based on the class corresponding to the node of the Ni-th layer and the number of nodes of the N-i+1-th layer and the N-i+1-th layer contained in the class, the nodes of the Ni-th layer can be generated.

[0082] For ease of understanding, embodiments of the present invention are described below with reference to specific examples. It should be understood that the following examples are used to explain the present invention but are not used to limit the present invention.

[0083] Assuming that there are a total of 20,000 entry vectors in the second knowledge base, m=0.5, and the second threshold is 10, then the bottom layer of the tree has 20,000 nodes, the number of nodes in the layer above the bottom layer is 20,000 to the power of 0.5 = 142, the number of nodes in the layer above that is 142 to the power of 0.5 = 12, and the number of nodes in the layer above that is 12 to the power of 0.5 = 4.

[0084] Assuming that there are a total of 20,000 entry vectors in the second knowledge base, and m=0.6, then the bottom layer of the tree has 20,000 nodes, the number of nodes in the layer above the bottom layer is 20,000 to the power of 0.6 = 381, the number of nodes in the layer above that is 381 to the power of 0.6 = 36, and the number of nodes in the layer above that is 36 to the power of 0.6 = 9.

[0085] Assuming that there are a total of 15,000 entry vectors in the second knowledge base, and m=0.6, then the bottom layer of the tree has 15,000 nodes, the number of nodes in the layer above the bottom layer is 15,000 to the power of 0.6 = 321, the number of nodes in the layer above that is 321 to the power of 0.6 = 32, and the number of nodes in the layer above that is 32 to the power of 0.6 = 8.

[0086] In some embodiments of the present invention, after classifying several entry vectors to obtain several classes, the method further includes: inputting all entry vectors contained in the class into a language model to extract key information of the class, thereby generating a class vector, wherein the key information includes: entity words whose appearance frequency in all entry vectors contained in the class is greater than a third threshold.

[0087] Constructing a second knowledge base with a tree structure based on the several classes and the entry vectors included in each class may include: constructing a second knowledge base with a tree structure based on the several classes and the entry vectors included in each class and the class vectors corresponding to the classes.

[0088] By inputting all the entry vectors contained in the class into the language model, the key information of the class can be extracted, and the redundant information can be removed, thereby generating a class vector that contains the key content of all the entry vectors contained in the class while removing their redundant information.

[0089] For example, if the entry vectors in a class are [A1, B1, C1], [A1, B1, C1, D1], and [A1, B1, C1, E1, F1], then the class vector N1 generated based on these entry vectors is [A1, B1, C1, D1, E1, F1]. If the class vector is generated based on a linear knowledge base, then it is [A1, A1, A1, B1, B1, C1, C1, C1, D1, E1, F1]. This shows that the class vectors generated by the embodiments of the present invention significantly reduce the bias of the vector set, thereby making the final answer clear, complete, and concise.

[0090] In some embodiments of the present invention, in response to receiving question information, obtaining nodes that match the question information from the second knowledge base, and determining answer information based on the obtained nodes may include: in response to receiving the question information, converting the question information into a question vector; determining the matching degree between the question vector and each node in the second knowledge base to screen out nodes whose matching degree meets preset conditions; and generating answer information corresponding to the question information based on the screened nodes.

[0091] The preset condition may be the highest matching degree. In an embodiment of the present invention, after receiving a question message sent by a user through a client interface, the question message may be converted into a question vector. Based on the question vector, the second knowledge base is traversed. For each node traversed, the distance (i.e., the matching degree) between the entry vectors or class vectors corresponding to the node is calculated. The node with the highest matching degree with the question vector is determined, and answer information corresponding to the question message is generated based on the vector corresponding to the node.

[0092] In related art, a first knowledge base based on a linear storage structure may find multiple answers when answering a user's question. These answers may or may not belong to the same category. In this case, the intelligent question-answering system will only select the one with the highest similarity as the answer. This answer is one-sided and may even deviate significantly from the user's question, making it difficult to satisfy the user. In contrast, the second knowledge base based on a tree structure in the embodiment of the present invention generates a more comprehensive answer that matches the question through classified nodes.

[0093] The following examples illustrate the concept of the present invention. The following examples are all applied to the field of software development technology, covering various stages such as software development and software testing. It should be understood that the examples described herein are only used to illustrate and explain the present invention and are not intended to limit the present invention.

[0094] Example 1 The question information entered by the user through the client interface is: combining the different requirements of autonomous and controllable review, document review, functional testing and security verification, analyzing how to ensure the integrity, correctness and security of the product during the software product verification process.

[0095] The answer information generated based on the question information in this embodiment of the present invention is: During the verification process of a software product, it is very important to ensure the integrity, correctness, and security of the product. The following are several key aspects and their verification methods: 1. Independent and Controllable Review: Ensure the software runs in an independently controllable hardware and software environment, that development and management documentation is complete, that the source code is executable, and that core functionality is independently developed. Use checklists to review documentation and verify source code integrity and functional consistency.

[0096] 2. Document review: Check the completeness, standardization, consistency and correctness of documents. Use checklists to review documents to ensure they meet standards and have been reviewed and confirmed.

[0097] 3. Functional testing: Test the functional completeness, correctness, suitability, and compliance of the software. Use functional testing, boundary testing, data processing testing, and other methods to test normal and abnormal values ​​and boundary values.

[0098] 4. Security testing: Verify the software's protection capabilities, restartability, repairability, and reliability compliance.

[0099] 5. Performance testing: Verify the software's behavior in the presence of various input errors and operations outside the limitations of the user documentation set.

[0100] 6. Failure mode testing: Test the software's failure modes (such as data out of range, deadlock, etc.), as well as the continuity and smoothness of multi-machine system failure switching.

[0101] 7. Reliability testing: Systematically analyze all possible dangerous states of the software system and ensure that each dangerous state and each preventive measure are covered by the test.

[0102] 8. Strength testing: Testing the software product’s ability to maintain its performance level under specified conditions, and whether it can withstand operations when various input errors occur.

[0103] 9. Functional testing: Verify the performance of the software when it is operated outside the limitations stated in the user documentation set.

[0104] 10. Standards compliance testing: Check whether the security, reliability, usability and compatibility of software products or systems comply with relevant standards, conventions or regulations.

[0105] These test items ensure the stability and reliability of the software product while complying with relevant standards and specifications. During the actual implementation process, additional test items can be added based on the characteristics of the software and the supplier's requirements.

[0106] Input the above question information into the open source langchain knowledge base, and the answer information obtained is as follows Figure 5 shown.

[0107] By comparing the embodiments of the present invention and the open source langchain knowledge base, it can be seen that the answers to the above questions in the embodiments of the present invention have 10 answers, the answer content is more comprehensive, and the reference value to users is greater.

[0108] Example 2 The question information entered by the user through the client interface is: Please combine the four methods of root cause analysis, statistical defect analysis, orthogonal defect analysis and data mining defect analysis to explain which method can be selected to carry out defect analysis more effectively when there is insufficient data.

[0109] The answer information generated based on the question information in this embodiment of the present invention is: When choosing an approach for defect analysis in the presence of insufficient data, consider the following: 1. Root cause analysis: This method qualitatively analyzes defects to identify their root causes and takes action to eliminate them. Although insufficient data may affect the accuracy of the analysis, this method still helps understand the root causes of defects and take appropriate preventive measures. Furthermore, root cause analysis generally does not require a large amount of data, so it can be effectively performed even in the absence of sufficient data.

[0110] 2. Orthogonal Defect Analysis: Orthogonal defect analysis combines the strengths of quantitative and qualitative analysis. By analyzing the causal relationship between defect information and the software process, it can provide key insights into defect data and help identify weaknesses in the software process. This approach has minimal requirements for team infrastructure and is suitable for small software organizations to conduct defect analysis agilely. It can also be effective even when data is insufficient.

[0111] 3. Statistical Defect Analysis: Statistical defect analysis focuses on predicting the number of defects likely to exist in software and the number of residual defects. Although statistical defect analysis relies on historical data, it may not provide accurate predictions when data is insufficient. Therefore, in cases of insufficient data, it is recommended to prioritize root cause analysis and orthogonal defect analysis.

[0112] 4. Data Mining Defect Analysis: Data mining defect analysis relies on massive amounts of data, so it may not be feasible if data is insufficient. If the data volume is sufficient, data mining defect analysis can be considered to discover potential correlations and empirical information, thereby generating meaningful statistical results.

[0113] In summary, when data is insufficient, it is recommended to prioritize root cause analysis and orthogonal defect analysis. These two methods have relatively low data requirements and can effectively perform defect analysis. If the amount of data is sufficient, data mining defect analysis can be considered.

[0114] Input the above question information into the open source langchain knowledge base, and the answer information obtained is as follows Figure 6 shown.

[0115] Comparing the answers to the above questions in the embodiment of the present invention and the open-source langchain knowledge base reveals that the answers in the embodiment of the present invention include root cause analysis and orthogonal defect analysis. Reading the content reveals that both root cause analysis and orthogonal defect analysis are applicable to situations with insufficient data. However, the open-source lanchain knowledge base only provides an orthogonal defect analysis answer.

[0116] Example 3 The question information entered by the user through the client interface is: Combining automated testing framework design, data-driven testing, and model-based testing technology, explain how to achieve centralized management and execution of test cases through an automated testing framework, and improve testing efficiency during test script generation and maintenance.

[0117] The answer information generated based on the question information in this embodiment of the present invention is: By combining automated test framework design, data-driven testing, and model-based testing techniques, we can achieve centralized management and execution of test cases and improve testing efficiency during test script generation and maintenance through the following methods: 1. Automated test framework design: The automated test framework design should consider the centralized management and execution of test cases. A modular design can be used to store and call test cases, test data, and test scripts separately. Configuration files can also be used to facilitate the configuration and management of test parameters.

[0118] 2. Data-driven testing: Data-driven testing is a technique that uses data to drive test case execution, effectively improving testing efficiency. By writing data-driven scripts, test data can be separated from test cases, improving test case reusability and maintainability.

[0119] 3. Model-based testing: Model-based testing uses software models to generate test cases, improving test coverage and efficiency. By writing model-driven scripts, test case generation and test execution can be separated, improving test case generation efficiency and maintainability.

[0120] Through the above methods, centralized management and execution of test cases can be achieved, and testing efficiency can be improved during test script generation and maintenance.

[0121] Input the above question information into the open source langchain knowledge base, and the answer information obtained is as follows Figure 7 shown.

[0122] By comparing the embodiments of the present invention and the open source langchain knowledge base, it can be seen that the answers to the above questions can be accurately answered based on the theme of "automated testing framework"; the open source langchain knowledge base answers the details of centralized management, execution, test script generation, maintenance, etc. of test cases as the theme, which is a typical data segmentation and fragmentation, and obviously deviates from the theme of the user's question.

[0123] Based on the same inventive concept, according to another aspect of the present invention, Figure 8 As shown, an embodiment of the present invention further provides a knowledge question answering system 800, which includes a processor 810 and a memory 820. The memory 820 stores a computer program 821 that can be run on the processor. When the processor 810 executes the program, the steps of the above method are performed.

[0124] The memory, as a non-volatile storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs, and modules, such as the program instructions / modules corresponding to the compression method in the embodiments of the present application. The processor executes the non-volatile software programs, instructions, and modules stored in the memory to execute various functional applications and data processing of the device, thereby implementing the compression method in the above method embodiments.

[0125] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the device, etc. In addition, the memory may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the local module via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0126] Finally, it should be noted that those skilled in the art will understand that all or part of the processes in the above-described method embodiments can be implemented using a computer program to instruct the relevant hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes in the above-described method embodiments. The program storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM). The above-described computer program embodiments can achieve the same or similar effects as any of the corresponding aforementioned method embodiments.

[0127] It will also be appreciated by those skilled in the art that the various exemplary logic blocks, modules, circuits and algorithmic steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given of the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.

[0128] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications can be made without departing from the scope of the disclosure of the embodiments of the present invention as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. The serial numbers of the embodiments disclosed in the above embodiments of the present invention are for description only and do not represent the advantages and disadvantages of the embodiments. In addition, although the elements disclosed in the embodiments of the present invention can be described or required in individual form, they can also be understood as multiple unless expressly limited to the singular.

[0129] It should be understood that, as used herein, the singular forms "a" and "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" is intended to include any and all possible combinations of one or more of the associated listed items.

[0130] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to limit the scope of the disclosure of the present invention (including the claims) to these examples. Within the spirit of the present invention, the technical features of the above embodiments or different embodiments may be combined, and many other variations exist in different aspects of the above embodiments, which are not provided in detail for the sake of clarity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A question-answering method based on a knowledge base, characterized in that: include: Segmenting and encoding a plurality of entries in the first knowledge base to obtain a plurality of entry vectors; Classifying the plurality of entry vectors to obtain a plurality of classes, wherein each class includes at least one entry vector; Based on the several classes and the entry vectors contained in each class, constructing a second knowledge base with a tree structure, wherein the node corresponding to the class in the second knowledge base is the parent node of the node corresponding to the entry vector contained in the class; In response to receiving the question information, a node matching the question information is acquired from the second knowledge base, and answer information is determined based on the acquired node.

2. The method according to claim 1, characterized in that The segmentation and encoding of the plurality of entries in the first knowledge base to obtain the plurality of entry vectors includes: Segmenting a plurality of entries in the first knowledge base according to a first preset rule to obtain a plurality of segmented entries, wherein the first preset rule at least includes: a preset segmentation symbol; The segmented entries are encoded based on a text representation model to obtain entry vectors with spatial position information.

3. The method according to claim 1, characterized in that The classifying the plurality of entry vectors comprises: The plurality of entry vectors are classified according to a dimensionality reduction clustering function.

4. The method according to claim 3, characterized in that Classifying the plurality of entry vectors according to the dimension reduction clustering function includes: Setting the parameters of the dimensionality reduction clustering function according to the number of entries and the preset entry length; All entry vectors in the first knowledge base are classified according to the dimension reduction clustering function after parameter setting.

5. The method according to claim 1, characterized in that Based on the plurality of classes and the entry vectors contained in each class, a second knowledge base in a tree structure is constructed, comprising: A second knowledge base is constructed based on the several classes and the entry vectors contained in each of the classes, and in combination with the number of the several entry vectors.

6. The method according to claim 5, characterized in that Based on the plurality of classes and the entry vectors contained in each class, and in combination with the number of the plurality of entry vectors, constructing a second knowledge base includes: In response to the number of the plurality of entry vectors being less than or equal to a first threshold, a second knowledge base having a three-layer tree structure is constructed based on the plurality of classes, the entry vectors included in each class, and a first tree structure construction factor.

7. The method according to claim 6, characterized in that Based on the plurality of classes and the entry vectors contained in each class, and the first tree structure construction factor, constructing a second knowledge base having a three-layer tree structure includes: Based on each entry vector in each of the classes, generating a plurality of nodes in the third layer of the tree structure, wherein the entry vectors correspond one-to-one to the nodes in the third layer; Based on the plurality of nodes in the third layer, the classes to which each node belongs, the number of nodes in the third layer, and the first tree structure construction factor, generating a plurality of nodes in the second layer of the tree structure, wherein the nodes in the second layer correspond one-to-one to the classes; Based on the plurality of nodes of the second layer, the number of the second layer nodes and the first tree structure construction factor, a plurality of nodes of the first layer of the tree structure are generated.

8. The method according to claim 1, characterized in that After classifying the plurality of item vectors to obtain a plurality of classes, the method further comprises: inputting all item vectors included in the class into a language model to extract key information of the class, thereby generating a class vector; Constructing a second knowledge base with a tree structure based on the several classes and the entry vectors contained in each class includes: constructing a second knowledge base with a tree structure based on the several classes and the entry vectors contained in each class and the class vectors corresponding to the class.

9. The method according to claim 1, characterized in that The step of acquiring, in response to receiving the question information, a node matching the question information from the second knowledge base, and determining answer information based on the acquired node includes: In response to receiving the question information, converting the question information into a question vector; Determining a matching degree between the question vector and each node in the second knowledge base to filter out nodes whose matching degrees meet preset conditions; Based on the filtered nodes, answer information corresponding to the question information is generated.

10. A knowledge question answering system, comprising: at least one processor; as well as A memory storing a computer program that can be run on the processor, wherein the processor performs the steps of the method according to any one of claims 1 to 9 when executing the program.

Citation Information

Patent Citations

  • Question and answer method, system and device and medium

    CN118093828A

  • Knowledge question-answering method based on natural language processing

    CN118673109A

  • Knowledge graph dynamic generation method, system, equipment and medium

    CN119168046A

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

    CN119669429A