Answer generation method and device based on knowledge graph, medium, equipment and product
By extracting entities and relationships related to the question from the knowledge graph to generate answer information, the problem of poor answer generation in intelligent question answering by large language models is solved, and more accurate and logical answer generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING VOLCANO ENGINE TECH CO LTD
- Filing Date
- 2026-01-14
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies, when using large language models to achieve intelligent question answering, have poor answer generation performance, struggle to form logical contexts, and have limited retrieval scope.
By identifying entities and relationships related to the question from the knowledge graph, candidate subgraphs are obtained, target entities are filtered, knowledge triples are determined, and relevant knowledge triples are extracted to generate answer information.
It improves the accuracy and depth of answer generation, and provides more precise and logical contextual information.
Smart Images

Figure CN121935348A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of intelligent question answering, specifically to a method, apparatus, medium, device, and product for generating answers based on knowledge graphs. Background Technology
[0002] When using Large Language Models (LLMs) to implement intelligent question answering, knowledge bases or knowledge graphs are typically combined to generate answers in order to improve accuracy. Currently, this is generally achieved by searching for relevant text fragments from the knowledge base using text retrieval methods and providing them to the large language model to generate the answer, or by retrieving triples directly related to the question from the knowledge graph and providing them to the large language model to generate the answer. However, the retrieval scope of these methods is very limited, making it difficult to form logical context, resulting in large language models having difficulty understanding and generating answers effectively. Summary of the Invention
[0003] This summary section is provided to briefly introduce the concepts, which will be described in detail in the detailed description section below. This summary section is not intended to identify key or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] Firstly, this disclosure provides a knowledge graph-based answer generation method, the method comprising: In response to receiving question information, at least one first entity related to the question information is identified from the knowledge graph, and relation information in the question information is determined; Based on the first entity, candidate subgraphs are obtained from the knowledge graph, the candidate subgraphs containing the first entity and other entities associated with the first entity through relationships; The entities contained in the candidate subgraph are filtered to obtain the target entity, and a first knowledge triple is determined based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one of the target entities; Based on the relationship information, extract the second knowledge triplet from the knowledge graph; Answer information is generated based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
[0005] Secondly, this disclosure provides a knowledge graph-based answer generation device, the device comprising: The first determining module is configured to, in response to receiving question information, determine at least one first entity related to the question information from a knowledge graph, and determine the relationship information in the question information; The acquisition module is configured to acquire candidate subgraphs from the knowledge graph based on the first entity, wherein the candidate subgraphs include the first entity and other entities associated with the first entity through relationships; The second determining module is used to filter the entities contained in the candidate subgraph to obtain the target entity, and to determine the first knowledge triple based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one of the target entities; The first extraction module is used to extract the second knowledge triplet from the knowledge graph based on the relationship information; The first generation module is used to generate answer information based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
[0006] Thirdly, this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect of this disclosure.
[0007] Fourthly, this disclosure provides an electronic device, comprising: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the steps of the method described in the first aspect of this disclosure.
[0008] Fifthly, this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect of this disclosure.
[0009] The above technical solution, upon receiving the question information, firstly identifies at least one first entity related to the question information from the knowledge graph. Based on the first entity, candidate subgraphs are obtained from the knowledge graph. These candidate subgraphs contain the first entity and other entities associated with it through relationships. This leverages the graph structure characteristics of the knowledge graph to extract the associated content of question-related entities, providing rich information for subsequent answer generation. Next, the entities in the candidate subgraphs are filtered to obtain target entities. Based on the target entities and candidate subgraphs, first knowledge triples are determined. This further refines the selection of target entities more important to the question information by filtering entities in the candidate subgraphs, effectively filtering noise interference and forming first knowledge triples with inherent logic from scattered target entities, creating contextual information related to the entities in the question information. Furthermore, upon receiving the question information, the relational information within it is also identified. Based on this relational information, second knowledge triples are extracted from the knowledge graph. This effectively identifies the relational intent within the question information and extracts relevant second knowledge triples from the knowledge graph, forming contextual information related to the relationships within the question information. Subsequently, answer information is generated based on at least the question information, the first knowledge triplet, and the second knowledge triplet. This fully utilizes the information provided by the knowledge graph and provides complete relevant information about the question information in both entity and relational dimensions through the first and second knowledge triplets. This helps to provide a more accurate and logical context for the question information, thereby improving the accuracy and depth of the generated answer as a whole.
[0010] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0011] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 This is a flowchart of a knowledge graph-based answer generation method provided according to one embodiment of the present disclosure; Figure 2 This is an exemplary flowchart of generating a knowledge graph according to the knowledge graph-based answer generation method provided in this disclosure; Figure 3 This is a block diagram of a knowledge graph-based answer generation apparatus provided according to one embodiment of the present disclosure; Figure 4 A schematic diagram of the structure of an electronic device suitable for implementing embodiments of the present disclosure is shown. Detailed Implementation
[0012] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0013] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0014] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0015] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0016] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0017] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0018] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0019] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0020] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0021] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0022] Meanwhile, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0023] Figure 1 This is a flowchart of a knowledge graph-based answer generation method provided according to one embodiment of this disclosure. Figure 1 As shown, the method provided in this disclosure may include steps 11 to 15.
[0024] In step 11, in response to receiving the question information, at least one first entity related to the question information is identified from the knowledge graph, and relational information in the question information is determined.
[0025] Optionally, the question information may be a user query or an input parameter provided when other services call the knowledge graph-based answer generation method provided in this disclosure.
[0026] The knowledge graph provided in this disclosure can be pre-generated and can include multiple entities and relationships between them. The source entity (i.e., head entity), the relationship, and the target entity (i.e., tail entity) can constitute a knowledge triple. Entities and relationships in the knowledge graph can be represented by a graph structure, which can include entity nodes and relationship edges connecting them. Optionally, an existing knowledge graph can be directly used as the knowledge graph in this disclosure; alternatively, a knowledge graph can be constructed on demand according to actual needs to obtain the knowledge graph used in this disclosure.
[0027] In one possible implementation, such as Figure 2As shown, the knowledge graph provided in this disclosure can be generated through steps 21 to 24: In step 21, an initial knowledge triplet connecting two entities with a relation is extracted from the original text; In step 22, the initial knowledge triples are filtered according to the pre-stored entity types and relation types to obtain filtered knowledge triples. In step 23, a knowledge graph with a graph structure is generated based on the filtered knowledge triples; In step 24, an entity semantic vector is generated for each entity in the knowledge graph, and a relation semantic vector is generated for each relation in the knowledge graph. The entity semantic vector and the relation semantic vector are then stored in the knowledge graph.
[0028] The original text can be relevant text collected in the early stages for building the knowledge graph, or it can be unstructured text.
[0029] Based on the original text, entities and relations can be extracted, and initial knowledge triples can be formed based on two entities with a relation. For example, a large language model can be used for multi-round information extraction to extract initial knowledge triples from the original text.
[0030] After obtaining the initial knowledge triples, they can be filtered based on pre-stored entity types and relation types to obtain filtered knowledge triples. The pre-stored entity types and relation types can be set according to actual needs, typically those relevant to the current and subsequent dialogue scenarios. This allows filtering to retain only the necessary knowledge triples. For example, entity types can be pre-set to include food, names, and locations. If an initial knowledge triple contains an entity of type animal, that initial knowledge triple will be filtered out.
[0031] After obtaining the filtered knowledge triples, a knowledge graph with a graph structure can be further generated.
[0032] In one possible implementation, a knowledge graph with a graph structure can be generated directly from the entity relationships represented by the filtered knowledge triples. In a knowledge triple, two entities can be used as two nodes in the graph structure, and the relationship between the two entities can be used as the relationship edge between the two nodes in the graph structure. Thus, the filtered knowledge triples can be used to form a corresponding complete graph structure to constitute a knowledge graph.
[0033] In another possible implementation, after obtaining the filtered knowledge triples, the filtered knowledge triples can be further optimized to improve their quality before generating a graph-structured knowledge graph.
[0034] Optionally, for the filtered knowledge triples, entities with the same name can be merged based on the source entity, relation, and target entity of each triple, and relations with the same source and target entities can be merged to obtain merged knowledge triples, thus avoiding data redundancy. Furthermore, a graph-structured knowledge graph can be generated based on the merged knowledge triples. The method for generating a graph-structured knowledge graph based on triples has been described earlier, and the principle is the same here, so it will not be repeated.
[0035] After generating the knowledge graph, each node (i.e., entity) in the knowledge graph can be vectorized (i.e., the embedding vector is calculated) as an entity semantic vector. Similarly, each edge (i.e., relation) in the knowledge graph can be vectorized as a relation semantic vector. Optionally, when pre-storing relation types, descriptive information can be provided for each relation type. When generating relation semantic vectors for relations, the descriptive information of the corresponding relation type can also be added to enhance the semantic expressiveness of relation semantic vectors by utilizing both relation and descriptive information, thus avoiding semantic ambiguity caused by overly concise relation names.
[0036] Furthermore, entity semantic vectors and relation semantic vectors can be stored in the knowledge graph. When storing, entity semantic vectors (or relation semantic vectors) can be associated with their corresponding entity nodes (or relation nodes).
[0037] Optionally, after generating the knowledge graph using the above method, the knowledge graph can be further optimized to obtain the final knowledge graph. For example, a preset graph algorithm can be used to merge entities with high vector similarity, fusing related relationships along with the merged entities. For instance, if two nodes of the same entity exist in the knowledge graph, such as node 1 corresponding to the abbreviation and node 2 corresponding to the full name, they will be merged into the same entity in this process (e.g., retaining the relationships of both nodes in node 1 and deleting node 2). The preset graph algorithm can employ the K-nearest neighbor algorithm, and the similarity threshold and the number of neighbors can be flexibly configured according to actual needs. This solves the node redundancy problem caused by entities with the same name or near-synonyms, and ensures graph consistency through relationship fusion.
[0038] Back Figure 1 After receiving the question information, at least one first entity related to the question information can be identified from the knowledge graph to find content in the knowledge graph that is highly relevant to the question information.
[0039] In one possible implementation, step 11 may include the following steps: Named text recognition is performed on the problem information to obtain the recognition results; Based on the recognition results, the entity that matches the recognition results is identified in the knowledge graph and designated as the first entity.
[0040] By performing named entity recognition on the question information, entities within the question information can be identified as recognition results. Furthermore, based on these entities, corresponding entities can be determined in the knowledge graph. Optionally, the entities in the recognition results can be matched with entities in the knowledge graph by determining the degree of matching between entity names (e.g., through similarity representation), and entities that successfully match (e.g., similarity higher than a set threshold, complete identity, etc.) are identified as the first entity.
[0041] In another possible implementation, step 11 may include the following steps: Determine the first semantic vector corresponding to the question information; Based on the first semantic vector, similarity matching is performed with the entity semantic vectors of each entity in the knowledge graph to determine the first entity.
[0042] As mentioned earlier, each entity in a knowledge graph can have its own corresponding entity semantic vector.
[0043] Based on the question information, it can be vectorized to obtain the first semantic vector corresponding to the question information. Then, based on the entity semantic vector of each entity in the knowledge graph, the entity that matches the first semantic vector (e.g., the similarity between vectors is higher than a set threshold, or the similarity ranking between vectors is within a specified range) is determined by similarity matching and is taken as the first entity. For example, the similarity between vectors can be measured by cosine similarity.
[0044] In another possible implementation, the first entities determined by the two implementations described above can be merged to obtain a richer set of first entities.
[0045] After receiving the question information, the relational information within the question information can also be determined. Optionally, a large language model can be used to process the question information. By setting prompt words for extracting implicit relationships, the relational information within the question information can be determined through the output of the large language model.
[0046] In step 12, candidate subgraphs are obtained from the knowledge graph based on the first entity. The candidate subgraphs contain the first entity and other entities associated with the first entity through relationships.
[0047] As mentioned earlier, entities and relations in a knowledge graph can be represented by a graph structure, which can include entity nodes and relation edges used to connect entity nodes.
[0048] Alternatively, candidate subgraphs can be obtained from the knowledge graph in the following ways: Starting from the entity node corresponding to the first entity, obtain entity nodes and relation edges within a preset number of hops in the knowledge graph to obtain candidate subgraphs.
[0049] In other words, for each first entity, starting from the entity node corresponding to the first entity in the knowledge graph, and according to a preset hop count range, we can obtain the relational edges connected to that entity node and other entity nodes. For example, suppose the structure of entity node A1 in the knowledge graph is B2-B1-A1-A2-C1-C2, where "-" represents a relational edge, the entity corresponding to A1 is the first entity, and the preset hop count range is 2. Then, starting from node A1, we can obtain the entities and relations within two hops, thus obtaining B2-B1-A1-A2-C1. C2 is not selected because it exceeds the preset hop count range.
[0050] Therefore, the local parts of the knowledge graph that are related to the first entity (i.e., related to the question information) can be extracted to form candidate subgraphs.
[0051] In step 13, the entities contained in the candidate subgraphs are filtered to obtain the target entities, and the first knowledge triples are determined based on the target entities and the candidate subgraphs. Each first knowledge triple includes at least one target entity.
[0052] As mentioned earlier, the candidate subgraph is a local graph structure in the knowledge graph that is related to the first entity. Therefore, it also includes multiple entity nodes and relation edges used to connect multiple entity nodes, among which the multiple entity nodes include the first entity node corresponding to the first entity.
[0053] In one possible implementation, all entities contained in the candidate subgraph can be directly identified as the target entity.
[0054] In another possible implementation, filtering the entities contained in the candidate subgraph to obtain the target entity may include the following steps: Based on the first entity node, the importance score of each entity node in the candidate subgraph is determined by a preset importance evaluation method. The importance score is used to characterize the degree of association between each entity node in the candidate subgraph and the first entity node. Based on the importance score, target entity nodes are selected from the candidate subgraph to obtain the target entities corresponding to the target entity nodes.
[0055] Optionally, the preset importance assessment method can be configured with assessment rules based on actual needs, or existing importance assessment algorithms can be directly adopted.
[0056] For example, the evaluation rules can be set to establish a negative correlation between the number of hops between the entity node to be evaluated and the first entity node and the importance score, that is, the fewer the hops between the entity node and the first entity node, the higher the importance score.
[0057] For example, the evaluation rules can be set to establish a positive correlation between the number of first entity nodes covered by the entity node to be evaluated within a specified number of hops and the importance score, that is, the more first entity nodes covered within a specified number of hops, the higher the importance score.
[0058] For example, the Personalized PageRank (PPR) algorithm can be used. It's an extension of the traditional PageRank algorithm used to calculate the relevance of a node to a specific object. By simulating random walks, it evaluates the importance of a node and its relevance to a specific object. Therefore, by starting with the first entity node and running the PPR algorithm, each walk either stops and returns to the first entity node with a certain probability, or continues to an adjacent node with another probability. Through multiple iterations, the visit probabilities of nodes gradually converge, eventually forming a stable ranking, thus obtaining the importance score of each entity node in the candidate subgraph.
[0059] Furthermore, based on the importance score of each entity node in the candidate subgraph, the target entity node can be selected from them, and the corresponding entity is the target entity.
[0060] For example, an importance score can be used to form a ranking, and a preset number of entity nodes with the highest ranking can be extracted to identify the target entity.
[0061] For example, a scoring threshold can be set, and entity nodes whose importance scores exceed the scoring threshold can be extracted to identify the target entity.
[0062] Therefore, by filtering target entities, noise can be effectively reduced, which helps to focus on the knowledge area most relevant to the problem information.
[0063] After identifying the target entity, the first knowledge triple can be determined based on the target entity and the candidate subgraph.
[0064] In one possible implementation, for each target entity, based on the target entity, a one-hop entity that has a relationship with the target entity can be found in the candidate subgraph starting from the target entity, and a first knowledge triple can be formed based on the target entity, the one-hop entity and the relationship between the two.
[0065] In another possible implementation, determining the first knowledge triple based on the target entity and candidate subgraphs may include the following steps: In the candidate subgraph, a connected path is determined that connects at least two second entity nodes, where the second entity node is the entity node in the candidate subgraph that corresponds to the target entity. Extract the knowledge triples associated with the connected paths to obtain the first knowledge triple.
[0066] In other words, based on the second entity node corresponding to the target entity and the structural position of the second entity node in the candidate subgraph, a connecting path that can connect the two second entity nodes is retrieved. The first and last nodes of the connecting path can be second entity nodes, and the nodes in the middle of the connecting path can include second entity nodes as well as ordinary entity nodes that are not second entity nodes in the candidate subgraph. For example, the above connecting path can be determined by depth-first search (DFS).
[0067] This method identifies all connected paths in the candidate subgraph. Then, based on these connected paths, a first knowledge triple can be generated according to the nodes and relations along those paths. For example, if a connected path contains node K1, relation P1, node K2, relation P2, and node K3 in that order, the first knowledge triple can be determined to include: <Node K1, Relation P1, Node K2>; <Node K2, relation P2, node K3>.
[0068] In another possible implementation, determining the first knowledge triplet based on the target entity and candidate subgraphs may further include the following steps: Determine whether a single entity node exists in the candidate subgraph. A single entity node is a second entity node that is not connected to any other second entity node. If a single entity node exists, for that single entity node, obtain the knowledge triple associated with that single entity node in the candidate subgraph to obtain the first knowledge triple.
[0069] In some cases, there may be some second entity nodes in the candidate subgraph that fail to form a connected path with any other second entity node, that is, there may be a single entity node in the candidate subgraph. In this case, in order to avoid losing the information of the single entity node and causing information loss, the first knowledge triplet can be generated based on the single entity node.
[0070] For a single entity node, we can start from the single entity node in the candidate subgraph, determine the one-hop neighbor node of the single entity node, and obtain the first knowledge triple based on the single entity node, the one-hop neighbor node of the single entity node, and the relationship between the two.
[0071] In step 14, the second knowledge triple is extracted from the knowledge graph based on the relational information.
[0072] After determining the relational information in the problem information in step 11, the relational information can be vectorized to obtain the second semantic vector corresponding to the relational information. Furthermore, based on the relational semantic vector of each relation in the knowledge graph, a similarity matching method is used to determine the relations that match the second semantic vector (e.g., the similarity between vectors is higher than a set threshold, or the similarity ranking between vectors is within a specified range), and these are used as target relations. For example, the similarity between vectors can be measured using cosine similarity.
[0073] Furthermore, based on the target relationship, knowledge triples associated with the target relationship can be extracted from the knowledge graph as the second knowledge triple.
[0074] In step 15, answer information is generated based on at least the question information, the first knowledge triplet, and the second knowledge triplet.
[0075] After obtaining the first knowledge triplet and the second knowledge triplet, the answer information corresponding to the question information can be generated by using the context of the question information they reflect.
[0076] In one possible implementation, step 15 may include the following steps: Identify the first text segment in the question information that corresponds to the first knowledge triplet; Identify the second text segment in the question information that corresponds to the second knowledge triplet; Generate answer information based on the question information, the first knowledge triplet, the second knowledge triplet, the first text fragment, and the second text fragment.
[0077] Based on the first knowledge triplet, a text segment related to the question information can be identified as the first text frequency band, and based on the second knowledge triplet, a text segment related to the question information can be identified as the second text segment.
[0078] Based on this, the first and second knowledge triples are treated as structured information related to the question information, while the first and second text fragments are treated as unstructured information related to the question information, forming contextual information related to the question information. Then, based on the question information and this contextual information, the input information for the large language model is generated. For example, based on a preset prompt word template, the question information and contextual information are added to a specified position in the prompt word template to generate input prompt words. Afterward, the input information is fed into the large language model to obtain the answer corresponding to the question information.
[0079] In another possible implementation, step 15 may include the following steps: Based on the first knowledge triplet and the second knowledge triplet, filter the target knowledge triplet; Identify the target text fragments in the problem information that correspond to the target knowledge triples; The answer information is generated based on the question information, the target knowledge triple, and the target text fragment.
[0080] Optionally, the first and second knowledge triples can be ranked in relation to the question information (e.g., based on vector similarity), and a specified number of knowledge triples with the highest relevance ranking can be selected as target knowledge triples. This ensures that the final target knowledge triples have a high relevance to the question information and effectively avoids information redundancy.
[0081] Based on target knowledge triples, relevant text fragments can be identified within the question information and designated as target text fragments. Then, the target knowledge triples are treated as structured information related to the question information, and the target text fragments are treated as unstructured information related to the question information, forming contextual information relevant to the question information. Finally, based on the question information and this contextual information, input information for the large language model is generated. For example, based on a preset prompt word template, the question information and contextual information are added to designated positions in the prompt word template to generate input prompt words. Finally, the input information is fed into the large language model to obtain the answer corresponding to the question information.
[0082] The above technical solution, upon receiving the question information, firstly identifies at least one first entity related to the question information from the knowledge graph. Based on the first entity, candidate subgraphs are obtained from the knowledge graph. These candidate subgraphs contain the first entity and other entities associated with it through relationships. This leverages the graph structure characteristics of the knowledge graph to extract the associated content of question-related entities, providing rich information for subsequent answer generation. Next, the entities in the candidate subgraphs are filtered to obtain target entities. Based on the target entities and candidate subgraphs, first knowledge triples are determined. This further refines the selection of target entities more important to the question information by filtering entities in the candidate subgraphs, effectively filtering noise interference and forming first knowledge triples with inherent logic from scattered target entities, creating contextual information related to the entities in the question information. Furthermore, upon receiving the question information, the relational information within it is also identified. Based on this relational information, second knowledge triples are extracted from the knowledge graph. This effectively identifies the relational intent within the question information and extracts relevant second knowledge triples from the knowledge graph, forming contextual information related to the relationships within the question information. Subsequently, answer information is generated based on at least the question information, the first knowledge triplet, and the second knowledge triplet. This fully utilizes the information provided by the knowledge graph and provides complete relevant information about the question information in both entity and relational dimensions through the first and second knowledge triplets. This helps to provide a more accurate and logical context for the question information, thereby improving the accuracy and depth of the generated answer as a whole.
[0083] Figure 3 This is a block diagram of a knowledge graph-based answer generation apparatus provided according to one embodiment of the present disclosure. Figure 3 As shown, the device 30 may include: The first determining module 31 is configured to, in response to receiving question information, determine at least one first entity related to the question information from a knowledge graph, and determine the relationship information in the question information; The acquisition module 32 is configured to acquire candidate subgraphs from the knowledge graph based on the first entity, wherein the candidate subgraphs include the first entity and other entities associated with the first entity through relationships; The second determining module 33 is used to filter the entities contained in the candidate subgraph to obtain the target entity, and to determine the first knowledge triple based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one target entity. The first extraction module 34 is used to extract the second knowledge triplet from the knowledge graph based on the relationship information; The first generation module 35 is used to generate answer information based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
[0084] Optionally, the first determining module 31 includes: The identification submodule is used to perform named body recognition on the problem information and obtain the identification result; The first determining submodule is used to determine, based on the recognition result, an entity in the knowledge graph that matches the recognition result as the first entity.
[0085] Optionally, each entity in the knowledge graph corresponds to an entity semantic vector; The first determining module 31 includes: The second determining submodule is used to determine the first semantic vector corresponding to the problem information; The matching submodule is used to perform similarity matching between the first semantic vector and the entity semantic vectors of each entity in the knowledge graph to determine the first entity.
[0086] Optionally, the entities and relations of the knowledge graph are represented by a graph structure, which includes entity nodes and relation edges for connecting the entity nodes. The acquisition module 32 includes: The first acquisition submodule is used to acquire entity nodes and relation edges within a preset number of hops in the knowledge graph, starting from the entity node corresponding to the first entity, so as to obtain the candidate subgraph.
[0087] Optionally, the candidate subgraph includes multiple entity nodes and relational edges for connecting the multiple entity nodes, wherein the multiple entity nodes include the first entity node corresponding to the first entity; The second determining module 33 includes: The third determination submodule is used to determine the importance score of each entity node in the candidate subgraph based on the first entity node using a preset importance evaluation method. The importance score is used to characterize the degree of association between each entity node in the candidate subgraph and the first entity node. The selection submodule is used to select target entity nodes from the candidate subgraph based on the importance score, so as to obtain the target entity corresponding to the target entity node.
[0088] Optionally, the second determining module 33 includes: The fourth determining submodule is used to determine, in the candidate subgraph, a connected path that connects at least two second entity nodes, wherein the second entity nodes are the entity nodes in the candidate subgraph that correspond to the target entity; The extraction submodule is used to extract the knowledge triples associated with the connected path to obtain the first knowledge triple.
[0089] Optionally, the second determining module 33 further includes: The fifth determining submodule is used to determine whether there is a single entity node in the candidate subgraph, wherein the single entity node is a second entity node that is not connected to any other second entity node; The second acquisition submodule is used to, if the single entity node exists, acquire the knowledge triple associated with the single entity node in the candidate subgraph to obtain the first knowledge triple.
[0090] Optionally, the first generation module 35 includes: The filtering submodule is used to filter target knowledge triples based on the first knowledge triple and the second knowledge triple; The sixth determination submodule is used to determine the target text fragment in the question information that corresponds to the target knowledge triple; The generation submodule is used to generate the answer information based on the question information, the target knowledge triple, and the target text fragment.
[0091] Optionally, the knowledge graph is generated through the following modules: The second extraction module is used to extract initial knowledge triples that connect two entities in relation from the original text; The initial knowledge triples are filtered based on the pre-stored entity types and relation types to obtain filtered knowledge triples. The second generation module is used to generate a graph-structured knowledge graph based on the filtered knowledge triples. The storage module is used to generate an entity semantic vector for each entity in the knowledge graph and a relation semantic vector for each relation in the knowledge graph, and to store the entity semantic vector and the relation semantic vector in the knowledge graph.
[0092] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0093] The following is for reference. Figure 4The diagram illustrates a structural schematic of an electronic device 600 suitable for implementing embodiments of the present disclosure. Terminal devices in embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0094] like Figure 4 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0095] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0096] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.
[0097] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0098] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0099] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0100] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: In response to receiving question information, at least one first entity related to the question information is identified from the knowledge graph, and relation information in the question information is determined; Based on the first entity, candidate subgraphs are obtained from the knowledge graph, the candidate subgraphs containing the first entity and other entities associated with the first entity through relationships; The entities contained in the candidate subgraph are filtered to obtain the target entity, and a first knowledge triple is determined based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one of the target entities; Based on the relationship information, extract the second knowledge triplet from the knowledge graph; Answer information is generated based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
[0101] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0102] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0103] The modules described in the embodiments of this disclosure can be implemented in software or in hardware. The names of the modules do not necessarily limit the module itself; for example, the first determining module can also be described as "a module that, in response to receiving question information, determines at least one first entity related to the question information from a knowledge graph and determines relational information in the question information."
[0104] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0105] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0106] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, the method comprising: In response to receiving question information, at least one first entity related to the question information is identified from the knowledge graph, and relation information in the question information is determined; Based on the first entity, candidate subgraphs are obtained from the knowledge graph, the candidate subgraphs containing the first entity and other entities associated with the first entity through relationships; The entities contained in the candidate subgraph are filtered to obtain the target entity, and a first knowledge triple is determined based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one of the target entities; Based on the relationship information, extract the second knowledge triplet from the knowledge graph; Answer information is generated based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
[0107] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein determining at least one first entity related to the question information from the knowledge graph includes: Named body recognition is performed on the problem information to obtain the recognition result; Based on the identification result, an entity that matches the identification result is determined in the knowledge graph and designated as the first entity.
[0108] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein each entity in the knowledge graph corresponds to an entity semantic vector; The step of determining at least one first entity related to the question information from the knowledge graph includes: Determine the first semantic vector corresponding to the problem information; Based on the first semantic vector, a similarity match is performed with the entity semantic vectors of each entity in the knowledge graph to determine the first entity.
[0109] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein the entities and relations of the knowledge graph are represented by a graph structure, and the graph structure of the knowledge graph includes entity nodes and relation edges for connecting the entity nodes; The step of obtaining candidate subgraphs from the knowledge graph based on the first entity includes: Starting from the entity node corresponding to the first entity, obtain entity nodes and relation edges within a preset number of hops in the knowledge graph to obtain the candidate subgraph.
[0110] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein the candidate subgraph includes multiple entity nodes and relation edges for connecting the multiple entity nodes, and the multiple entity nodes include a first entity node corresponding to the first entity; The step of filtering the entities contained in the candidate subgraph to obtain the target entity includes: Based on the first entity node, the importance score of each entity node in the candidate subgraph is determined by a preset importance assessment method. The importance score is used to characterize the degree of association between each entity node in the candidate subgraph and the first entity node. Based on the importance score, target entity nodes are selected from the candidate subgraph to obtain the target entity corresponding to the target entity node.
[0111] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein determining a first knowledge triple based on the target entity and the candidate subgraph includes: In the candidate subgraph, a connecting path is determined that connects at least two second entity nodes, where the second entity node is the entity node in the candidate subgraph that corresponds to the target entity; Extract the knowledge triples associated with the connected paths to obtain the first knowledge triple.
[0112] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein determining a first knowledge triplet based on the target entity and the candidate subgraph further includes: Determine whether a single entity node exists in the candidate subgraph, wherein the single entity node is a second entity node that is not connected to any other second entity node; If the single entity node exists, for the single entity node, obtain the knowledge triple associated with the single entity node in the candidate subgraph to obtain the first knowledge triple.
[0113] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein generating answer information based at least on the question information, the first knowledge triplet, and the second knowledge triplet includes: Based on the first knowledge triplet and the second knowledge triplet, filter the target knowledge triplet; Identify the target text segment in the question information that corresponds to the target knowledge triple; The answer information is generated based on the question information, the target knowledge triple, and the target text fragment.
[0114] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation method is provided, wherein the knowledge graph is generated in the following manner: Extract initial knowledge triples that connect two entities in relation from the original text; The initial knowledge triples are filtered based on the pre-stored entity types and relation types to obtain filtered knowledge triples. Based on the filtered knowledge triples, a graph-structured knowledge graph is generated. An entity semantic vector is generated for each entity in the knowledge graph, and a relation semantic vector is generated for each relation in the knowledge graph. The entity semantic vector and the relation semantic vector are then stored in the knowledge graph.
[0115] According to one or more embodiments of this disclosure, a knowledge graph-based answer generation apparatus is provided, the apparatus comprising: The first determining module is configured to, in response to receiving question information, determine at least one first entity related to the question information from a knowledge graph, and determine the relationship information in the question information; The acquisition module is configured to acquire candidate subgraphs from the knowledge graph based on the first entity, wherein the candidate subgraphs include the first entity and other entities associated with the first entity through relationships; The second determining module is used to filter the entities contained in the candidate subgraph to obtain the target entity, and to determine the first knowledge triple based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one of the target entities; The first extraction module is used to extract the second knowledge triplet from the knowledge graph based on the relationship information; The first generation module is used to generate answer information based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
[0116] According to one or more embodiments of the present disclosure, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processing device, implements the steps of the knowledge graph-based answer generation method provided in any embodiment of the present disclosure.
[0117] According to one or more embodiments of this disclosure, an electronic device is provided, comprising: A storage device on which computer programs are stored; A processing device is configured to execute the computer program in the storage device to implement the steps of the knowledge graph-based answer generation method provided in any embodiment of the present disclosure.
[0118] According to one or more embodiments of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the knowledge graph-based answer generation method provided in any embodiment of the present disclosure.
[0119] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0120] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0121] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which the various modules perform their operations has been described in detail in the embodiments relating to the method, and will not be elaborated upon here.
Claims
1. A knowledge graph-based answer generation method, characterized in that, The method includes: In response to receiving question information, at least one first entity related to the question information is identified from the knowledge graph, and relation information in the question information is determined; Based on the first entity, candidate subgraphs are obtained from the knowledge graph, the candidate subgraphs containing the first entity and other entities associated with the first entity through relationships; The entities contained in the candidate subgraph are filtered to obtain the target entity, and a first knowledge triple is determined based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one of the target entities; Based on the relationship information, extract the second knowledge triplet from the knowledge graph; Answer information is generated based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
2. The method according to claim 1, characterized in that, The step of determining at least one first entity related to the question information from the knowledge graph includes: Named body recognition is performed on the problem information to obtain the recognition result; Based on the identification result, an entity that matches the identification result is determined in the knowledge graph and designated as the first entity.
3. The method according to claim 1, characterized in that, Each entity in the knowledge graph has its own semantic vector; The step of determining at least one first entity related to the question information from the knowledge graph includes: Determine the first semantic vector corresponding to the problem information; Based on the first semantic vector, a similarity match is performed with the entity semantic vectors of each entity in the knowledge graph to determine the first entity.
4. The method according to claim 1, characterized in that, The entities and relations of the knowledge graph are represented by a graph structure, which includes entity nodes and relation edges for connecting the entity nodes. The step of obtaining candidate subgraphs from the knowledge graph based on the first entity includes: Starting from the entity node corresponding to the first entity, obtain entity nodes and relation edges within a preset number of hops in the knowledge graph to obtain the candidate subgraph.
5. The method according to claim 1, characterized in that, The candidate subgraph includes multiple entity nodes and relation edges for connecting the multiple entity nodes, wherein the multiple entity nodes include the first entity node corresponding to the first entity; The step of filtering the entities contained in the candidate subgraph to obtain the target entity includes: Based on the first entity node, the importance score of each entity node in the candidate subgraph is determined by a preset importance assessment method. The importance score is used to characterize the degree of association between each entity node in the candidate subgraph and the first entity node. Based on the importance score, target entity nodes are selected from the candidate subgraph to obtain the target entity corresponding to the target entity node.
6. The method according to claim 1, characterized in that, The step of determining the first knowledge triple based on the target entity and the candidate subgraph includes: In the candidate subgraph, a connecting path is determined that connects at least two second entity nodes, where the second entity node is the entity node in the candidate subgraph that corresponds to the target entity; Extract the knowledge triples associated with the connected paths to obtain the first knowledge triple.
7. The method according to claim 6, characterized in that, The step of determining the first knowledge triplet based on the target entity and the candidate subgraph further includes: Determine whether a single entity node exists in the candidate subgraph, wherein the single entity node is a second entity node that is not connected to any other second entity node; If the single entity node exists, for the single entity node, obtain the knowledge triple associated with the single entity node in the candidate subgraph to obtain the first knowledge triple.
8. The method according to claim 1, characterized in that, The step of generating answer information based at least on the question information, the first knowledge triplet, and the second knowledge triplet includes: Based on the first knowledge triplet and the second knowledge triplet, filter the target knowledge triplet; Identify the target text segment in the question information that corresponds to the target knowledge triple; The answer information is generated based on the question information, the target knowledge triple, and the target text fragment.
9. The method according to any one of claims 1-8, characterized in that, The knowledge graph is generated in the following way: Extract initial knowledge triples that connect two entities in relation from the original text; The initial knowledge triples are filtered based on the pre-stored entity types and relation types to obtain filtered knowledge triples. Based on the filtered knowledge triples, a graph-structured knowledge graph is generated. An entity semantic vector is generated for each entity in the knowledge graph, and a relation semantic vector is generated for each relation in the knowledge graph. The entity semantic vector and the relation semantic vector are then stored in the knowledge graph.
10. A knowledge graph-based answer generation device, characterized in that, The device includes: The first determining module is configured to, in response to receiving question information, determine at least one first entity related to the question information from a knowledge graph, and determine the relationship information in the question information; The acquisition module is configured to acquire candidate subgraphs from the knowledge graph based on the first entity, wherein the candidate subgraphs include the first entity and other entities associated with the first entity through relationships; The second determining module is used to filter the entities contained in the candidate subgraph to obtain the target entity, and to determine the first knowledge triple based on the target entity and the candidate subgraph, wherein each first knowledge triple includes at least one of the target entities; The first extraction module is used to extract the second knowledge triplet from the knowledge graph based on the relationship information; The first generation module is used to generate answer information based at least on the question information, the first knowledge triplet, and the second knowledge triplet.
11. A computer-readable medium having a computer program stored thereon, characterized in that, When executed by a processing device, the computer program performs the steps of the method according to any one of claims 1-9.
12. An electronic device, characterized in that, include: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the steps of the method according to any one of claims 1-9.
13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-9.