Knowledge graph multi-hop reasoning question and answer method based on attention mechanism and time constraint
By introducing attention mechanism and time-constrained knowledge graph multi-hop reasoning method, the problem of insufficient relevance and consistency of time-constrained logical relationship and consistency in the existing technology is solved, and more efficient timing knowledge graph question-and-answer accuracy is achieved.
Patent Information
- Application Number
- CN202510554610.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-08-15
AI Technical Summary
The existing timing knowledge graph question and answer methods fail to fully understand the logical correlation of time constraints, fail to ensure time consistency in multi-hop reasoning, and perform unstable in dealing with different types of time constraint problems.
The multi-hop reasoning method of knowledge graph based on attention mechanism and time constraints is adopted, explicit and implicit time information is recognized through a time parser, structured representation is combined with the time sequence knowledge graph, and relationship importance is calculated using the multi-headed attention mechanism, specific time activation functions and constraint clipping mechanisms are designed, and answer scores are performed.
It improves the accuracy of time-series knowledge graph questions and answers, and can capture the time sensitivity differences between relationships more accurately, enhancing the temporal consistency and question-answer accuracy of the model.
Smart Images

Figure CN120492504A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a knowledge graph multi-hop reasoning question-answering method based on attention mechanism and time constraints. It is a multi-hop reasoning method for temporal knowledge graph question-answering and belongs to the intersection of engineering application and information science. Background Art
[0002] Temporal knowledge graph question answering (KGQA) involves answering natural language questions based on a structured knowledge graph with temporal information. The primary goal of KGQA is to accurately understand the temporal constraints in a question and find the correct answer that satisfies these temporal constraints within the knowledge graph. Existing mainstream KGQA methods primarily rely on semantic matching, temporal information processing, and reasoning path search.
[0003] Methods based on semantic matching rely on calculating the similarity between the question text and the entity relationships in the knowledge graph. They first map the question and knowledge graph content into the same vector space using a pre-trained language model, and then search for answers based on similarity matching. Methods based on semantic matching rely on surface features of the text and focus on calculating semantic similarity. However, these methods fail to fully understand complex temporal constraints and therefore cannot properly handle problems involving temporal reasoning.
[0004] Methods based on temporal information processing parse and model the explicit or implicit temporal information in the problem. They use techniques such as time normalization and time interval calculation to process temporal expressions in the problem. This approach can capture explicit temporal information in the problem and can be used for simple time point matching. However, it is affected by the diversity of temporal expressions and has limited performance when processing complex temporal logic (such as "before," "after," and "during").
[0005] Methods based on reasoning path search leverage relational paths in knowledge graphs for multi-hop reasoning, using reinforcement learning or graph search algorithms to find paths connecting question entities and answer entities. These methods are currently the mainstream and achieve relatively good results, but they fail to fully consider time constraints during the path search process, potentially leading to incorrect paths that violate temporal logic.
[0006] Hybrid approaches combine multiple techniques for question answering, such as semantic matching, temporal processing, and path search. This is essentially an integrated approach. By integrating the strengths of each approach, they improve the performance of question answering systems on different types of questions. However, this approach requires careful design of the interaction between modules and is computationally complex, limiting its applicability in scenarios requiring real-time responses.
[0007] In existing research, these methods fail to model temporal constraints in a fine-grained manner, ignoring the critical role of temporal information in multi-hop reasoning. For example, in real-world situations, facts in knowledge graphs are often time-sensitive (e.g., a person's position is only valid for a specific time period), yet existing methods fail to strictly guarantee temporal consistency during reasoning. Furthermore, existing models fail to fully account for the specialized processing requirements of different temporal constraint types (e.g., time intervals, sequential relationships, and extreme value queries), which is crucial for the accuracy of question answering in temporal knowledge graphs. Summary of the Invention
[0008] Purpose of the invention: To address some problems existing in traditional temporal knowledge graph question-answering methods: First, existing models usually only perform simple matching processing on time information, and do not deeply explore the logical correlation between different time constraints, nor further analyze the deep connection between time constraints and question semantics. Second, the structural features of temporal knowledge graphs are not sufficiently mined. Past models often only focus on single-hop or simple multi-hop reasoning, and do not fully consider that temporal knowledge graph reasoning is a dynamic process subject to time constraints, which involves multiple time-sensitive relationship paths. Third, most existing methods only focus on one aspect of time information or graph structure, and therefore are unstable on different types of time constraint problems. The purpose of the present invention is to provide a knowledge graph multi-hop reasoning question-answering method based on attention mechanism and time constraints, which is used to solve these problems existing in current temporal knowledge graph question-answering methods.
[0009] Technical solution: To achieve the above-mentioned purpose, the present invention proposes a knowledge graph multi-hop reasoning question-answering method based on attention mechanism and time constraints. This paper proposes a new time constraint modeling method, which uses a time parser to perform a structured representation of the time expression in the question, and integrates the time predicate in the temporal knowledge graph as the final time constraint condition. On this basis, a multi-hop reasoning algorithm based on the attention mechanism is used to simulate the complex reasoning path in the temporal knowledge graph. In addition, in order to capture the impact of time constraints on the reasoning process, a time activation function and a constraint clipping mechanism are introduced, and reasoning strategies for different types of time constraints are proposed. At the same time, in order to enhance the discriminability of relational representation, a relation-level attention mechanism is proposed, and the Transformer framework is used to encode the relation embedding, and the attention weight is used to calculate the correlation between relations. Finally, based on the above features, the reasoning scoring function is used to rank and screen the candidate answers. Its specific technical solution includes the following steps:
[0010] Step 1: Time information analysis.
[0011] (1) Temporal information extraction: Use a pre-trained temporal parser to identify explicit temporal expressions in the question, and retrieve implicit temporal information through the temporal knowledge graph and perform structured transformation.
[0012] (2) Time information encoding: Use the encoder to process absolute time and relative time information separately, and then construct a time constraint knowledge graph to model time points, intervals and logical relationships.
[0013] Step 2: Fact retrieval.
[0014] (1) Question embedding: Use the existing pre-trained language model RoBERTa to extract the semantic information of natural language questions, and replace the entities and timestamps in the questions with the corresponding pre-trained temporal knowledge graph embedding representations.
[0015] (2) Time decomposition: decompose the timestamp into three independent parts: year, month, and day for vector representation to reduce the parameter dimension.
[0016] (3) Relational attention: Construct a multi-head attention mechanism at the relational level to calculate the importance weights of different relations in temporal reasoning.
[0017] Step 3: Temporal reasoning.
[0018] (1) Constrained pattern matching: Identify high-frequency relational patterns from the knowledge graph and instantiate them into specific graph patterns.
[0019] (2) Confidence evaluation: Through the entity-level confidence calculation method, candidate constraints are screened and high-confidence time constraints are retained. For constraints that do not meet the strict confidence threshold but are higher than the loose threshold, their scope is limited to a specific entity category combination.
[0020] (3) Local graph construction: Extract related entities and relationships based on the L-hop neighborhood of the central entity to construct a local knowledge graph.
[0021] (4) Answer scoring: For different types of time-constrained problems (joint, maximum, sequential, matching), a specific time activation function is designed for scoring. Finally, the temporal reasoning score is integrated with the fact retrieval score to obtain the final answer score.
[0022] Beneficial Effects: This paper proposes a knowledge graph multi-hop reasoning question-answering method based on an attention mechanism and time constraints for the problem of time-series knowledge graph question-answering. This method not only focuses on the explicit expression of temporal information, but also deeply explores the complex interactive relationship between time constraints and knowledge graph structures, solving problems such as insufficient expression of the time dimension and poor temporal consistency of reasoning paths in existing methods. In addition, the innovative application of the attention mechanism at the relationship level enables the model to more accurately capture the differences in time sensitivity between relationships, thereby improving the accuracy of question-answering. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 The overall flow chart of the knowledge graph multi-hop reasoning question answering method based on attention mechanism and time constraints.
[0024] Figure 2 It is a method flow chart.
[0025] Figure 3 It is a graph of the relation-oriented attention mechanism. DETAILED DESCRIPTION
[0026] The present invention will be further described below with reference to the accompanying drawings.
[0027] The present invention is a knowledge graph multi-hop reasoning question answering method based on attention mechanism and time constraint. The overall flow chart is shown in the attached figure. Figure 1 As shown. First, a pre-trained time parser is used to identify and structure the time information in the question, and the parsing results are fused with the time predicates in the knowledge graph. On this basis, the RoBERTa model is used to extract the semantic features of the question, and the vector representation of entities and timestamps is obtained in combination with the temporal knowledge graph embedding. Then, by constructing a multi-head attention mechanism at the relationship level, the importance weights of different relationships in temporal reasoning are calculated. In addition, in order to enhance the temporal consistency of reasoning, local graph cropping and temporal activation functions are used to score the candidate answers. Finally, the optimal answer is output through the answer fusion mechanism. A knowledge graph multi-hop reasoning question answering method based on attention mechanism and time constraints mainly includes three parts: 1) temporal information parsing; 2) fact retrieval; 3) temporal reasoning. The specific architecture of the model is shown in the attached Figure 2 , the specific implementation steps are as follows.
[0028] 1. Time information analysis module
[0029] (1) Display knowledge extraction
[0030] In many natural problems, the names of well-known events are used as implicit temporal constraints. For example, "Who was the head coach of the Chinese women's volleyball team after the Beijing Olympics?" While the Beijing Olympics have no direct relationship to the head coach of the Chinese women's volleyball team, it can be considered an implicit temporal constraint. Due to a lack of contextual knowledge, existing models often miss this temporal information. Therefore, we use the event knowledge in TKG to explicitly express the temporal information (i.e., 2008) instead of the implicit temporal constraint expressed by the event.
[0031] For each event entity identified in the question, a search query is proposed against the Temporal Knowledge Graph (TKG) to retrieve the start event T1 and end time T2 of that event. Then, the question q is transformed into text Event text in qevent Replace with display time expressions T1 and T2.
[0032] (2) Implicit knowledge extraction
[0033] Besides well-known events, other types of implicit temporal information can also appear in complex questions. For example, "Before A, who was the head coach of the Chinese national men's football team?" Directly querying the TKG for A will not yield explicit temporal information. Instead, we need to query the knowledge base using the joint information (head coach of the national football team, A) to obtain the corresponding temporal information.
[0034] For multiple entities e1, e2 in a question, first extract the relevant tuples G corresponding to (e1, e2) in TKG through joint query of knowledge edge graph r , the calculation process is shown in formula (1).
[0035] G r ={(e h ,r,e t ,t1,t2)|e h ∈[e1, e2], e t ∈[e1,e2]} (1)
[0036] Then, G r All t1 and t2 in are merged and sorted by their values, where the minimum value is marked as the start time t1 and the maximum value is marked as the end time t2. Finally, a regular expression is used to convert the natural language question q text The entity text q in entity Replace with display time expressions T1 and T2.
[0037] The obtained T1 and T2 are passed to the following modules for further reasoning.
[0038] 2. Fact Retrieval Module
[0039] (1) Question Embedding
[0040] 1) Natural language semantics: The semantic information of natural language questions is extracted using a pre-trained language model. Specifically, the natural language form of the question is converted into a semantic matrix using the pre-trained RoBERTa model. The calculation process is shown in formula (2).
[0041] Q R =W R RoBERTa(q text ) (2)
[0042] in is a D×N semantic embedding matrix. N is the number of tags, q textis the symbolic representation of the problem, and D is the dimension of TKG embedding. R It is a D×D roberta The projection matrix, where D roberta is the dimension of the RoBERTa embedding.
[0043] 2) Entity semantics: In order to effectively capture the declarative knowledge about entities in natural language questions, the entities and timestamps Q in the question are R The token embeddings of are replaced with their corresponding pre-trained temporal knowledge graph embedding representations. The calculation process is shown in Formula (3). Specifically, when processing a question, the entities and time information involved in the question are first identified. Then, by searching the pre-trained TKG embedding model, the vector representation of each entity and timestamp is obtained. These vectors capture the semantic features of the entities and timestamps in the temporal knowledge graph, enabling the model to more accurately understand the knowledge requirements in the question, thereby improving the effectiveness and accuracy of reasoning.
[0044]
[0045] Where W E is the projection of D×D, e ε and t τ is the TKG pre-trained embedding, This enriches the question representation with entity information in TKG.
[0046] 3) Semantics of time: In the implicit knowledge perception module, the time information in the question is explicitly converted. After converting the time information in the question, the time information is further processed to enhance the model's understanding and prediction capabilities of event sequences. First, in order to reduce the parameters of the timestamp, the traditional approach is to treat the complete timestamp (such as "year, month, day") as a single numerical value, which may lead to an explosive growth of model parameters. To solve this problem, this paper adopts a novel splitting strategy to decompose each timestamp into three independent parts: year, month, and day. This splitting method can model the three dimensions of time separately without adding too many parameters. Then, t is concatenated using vector splicing. y , t m , and t d ∈R k Combined together as a timestamp vector, as shown in formula (4).
[0047]
[0048] where t y t m and t d Vectors representing year, month, and day respectively.
[0049] This article uses v s and T t Calculate the transformation matrix W and construct the mapping space, as shown in formula (5).
[0050]
[0051] where v s , t t ∈R k are the vectors of entity s and timestamp t respectively, and T represents the transpose operation.
[0052] Considering that only the information of s is known, the relationships related to s are clustered into A e Then each relationship vector Mapping to the constructed space W∈R k×k , the calculation process is shown in formula (6).
[0053]
[0054] in It is the relationship i vector, W∈R k×k is a linear transformation matrix based on the entity and timestamp vectors.
[0055] In order to enhance the perception of time information, the time in the extracted temporal knowledge graph is embedded into the question representation, as shown in formula (7).
[0056]
[0057] in, T1 and T2 are the time frames of the questions obtained from the implicit knowledge perception module.
[0058] 4) Relation Embedding: We propose a relation-oriented attention layer, in which the attention between relations is calculated using the “Scaled DotProduct Attention” and “Multihead Attention” techniques proposed by Vaswani et al. In fact, the query consists of the vector v′ of the relation r r Indicates that the keys and values of the attention mechanism are based on chain A e Embedded into matrix and The output of the attention layer is represented as v″ r , the calculation formula is shown in formula (8), Figure 3 The overall framework of the relation-oriented attention mechanism is presented.
[0059]
[0060] Where attn() is the calculation process of the attention mechanism as follows.
[0061] Figure 3 Medium v e represents the entity embedding vector, v r Represents the relation embedding vector, v t W represents the timestamp embedding vector. er It is a matrix space consisting of vectors of entities and timestamps.
[0062] Refer to "Scaled Dot Product Attention", for each r i ∈A e Using v′ r and v′ i The attention of the relationship is calculated by multiplying between them and dividing the value by Scaling is performed, where n′ is the dimension of time embedding, and the calculation formula is shown in formula (9).
[0063]
[0064] The attention value represents each relation r i ∈A e For the importance of source relation r, use α i Relative attention λ i It is calculated by the Softmax function on all attention values, as shown in formula (10).
[0065]
[0066] where v′ r and Represent r and r respectively i The mapping vector.
[0067] Furthermore, as suggested by Busbridge et al., “multi-head attention” is used to encapsulate more information about the relationships in the learning process. H independent attention heads are used to compute embeddings, which are then concatenated into the following representation (Equation (11)).
[0068]
[0069] Where П represents a concatenation operation.
[0070] 5) Semantic Fusion: The next information fusion layer fuses the information into a single question representation q. Building on previous approaches, this layer uses a dedicated learnable encoder, the Transformer (·). This encoder, consisting of two Transformer encoding layers, can simultaneously process contextual, entity, temporal, and relational information. Through a relation-aware attention mechanism, the encoder dynamically adjusts the weights of each relation during the fusion process, effectively incorporating inter-entity relational information into the question representation.
[0071] (2) Semantic scoring function
[0072] The semantic score of entity ε∈E as the answer is shown in formula (12),
[0073] max(φ(e s , P E q, e ε , t τ ),φ(e o , P E q, e ε , t τ )) (12)
[0074] where s, o and τ are the subject, object and timestamp of the annotation respectively, and P E is a D×D learnable matrix specific to entity prediction. The labeled subjects and objects are treated interchangeably, and the max(·) function ensures that the scores are ignored when s or o is a virtual entity.
[0075] Furthermore, the score of the timestamp τ∈T as the answer is given by formula (13),
[0076] max(φ(e s , P T q,e o ,t τ ), f sentity (P T q,t τ )) (13)
[0077] Where s, o are entities with attributes in the problem, P T is a D×D learnable matrix specific to temporal prediction.
[0078] f sensity It is a function used to measure the sensitivity of the problem representation to the timestamp. The calculation process is as shown in formula (14).
[0079] f sensity (P T q,t τ )=P T q·tτ (14)
[0080] Among them, P T is a D×D learnable matrix specific to temporal prediction.
[0081] Finally, the semantic score of the candidate answer is obtained, which consists of the entity candidate answer and the timestamp candidate answer. The specific calculation process is shown in formula (15-17).
[0082] score entity =max(φ(e s , P E q, e ε , t τ ),φ(e o , P E q, e ε , t τ )) (15)
[0083] The score entity is the entity candidate answer score.
[0084] score time =max(φ(e s , P T q,e o , t τ ), f sentity (P T q,t τ )) (16)
[0085] The score time is the score of the candidate answer.
[0086]
[0087] The score semantic is the semantic score of the candidate answer, Represents vector concatenation.
[0088] 3. Temporal Reasoning Module
[0089] (1) Constraint pattern matching
[0090] The constraint extraction algorithm starts from a predefined structural pattern (SP) and instantiates it into a graph pattern (GP) that actually appears in the KG. This process includes two key steps: first, all entities in the KG are matched as potential topics in the SP; second, relevant attribute values are searched in the entity's neighborhood local graph to fill the attribute slots in the SP, thereby generating the actual graph pattern (GP). Subsequently, the algorithm attaches a temporal predicate to the generated graph pattern to construct a temporal constraint. Only if the support s satisfies s≥θfreg Only the patterns that match the given constraint will enter the subsequent steps as frequent candidate constraints.
[0091] (2) Confidence Assessment
[0092] The quality of a temporal constraint tc on a given knowledge graph (KG) can be evaluated based on the fact of pattern matching in the corresponding graph. The quality of the constraint is measured by the entity-level confidence, as shown in formula (18):
[0093]
[0094] Among them pos and entities neg It is a subset of the subject entity in the graph schema.
[0095] The logical value is calculated based on the time interval T = (ts, te), where ts and te represent the start and end times of the event. For cases where the time value is ambiguous or missing, the logical value may be "unknown". Such entities are excluded from the confidence calculation, and the calculation result is set to unknown instead of a negative number.
[0096] In addition, to deal with the uncertainty in the time dimension, the algorithm refines the constraints by enumerating the categories to which the entities belong. When the confidence c of a constraint does not meet the strict threshold θ c1 But above the relaxed threshold θ c2 When , we will try to limit its scope to a specific entity category combination. Finally, satisfy the support s≥θ freg And the confidence c ≥ θ c1 The refined constraints will be added to the final result set.
[0097] (3) Local graph construction
[0098] In the process of local graph construction, we first extract the local graph related to the problem from the temporal knowledge graph. Assume that the knowledge graph is G = (V, R), where V is the set of nodes and R is the set of edges r. The central entity in the problem is represented as v center , starting from this central entity, construct a local graph containing L-hop neighborhood, denoted as N L (v center ). L-hop neighborhood means the distance from the central entity v center Starting from , all neighboring nodes and their connected edges that can be reached through at most L steps.
[0099] For the central entity v in the problem center, the entities that can be reached in one hop from the central entity, and the entities that can be reached in two hops from the central entity through the intermediate entity. Query all its related facts in TKG and extract its related entities and time information to construct a temporal local graph. Let N L (v center ) is v in KG center The set of L-hop (undirected) neighboring nodes, R L (v center ) are the corresponding edges, and the local graph is represented as shown in formula (19).
[0100] G L (v center )={(e,r)|e∈N L (v center ), r∈R L (v center )} (19)
[0101] where v center is the central node, G L (v center ) is v center The corresponding L-hop local graph. For each edge r∈G L (v center ), which contains the corresponding time information t r .
[0102] After constructing the L-hop neighborhood local graph containing time information, we next need to filter the local graph based on the time constraints in the problem. Because the temporal local graph contains a large amount of useless neighbor information, we use the time constraints in the problem to filter the temporal local graph. In the implicit expression parsing module, we already have the time range [T1, T2] for each problem, so we check whether all paths on the local graph meet the time constraints.
[0103] First, all paths P from adjacent nodes to the central node are extracted. Path P is a sequence consisting of a series of nodes and edges, expressed as formula (20).
[0104] P={v0,e1,v1,e2,v2,…,e k , v k} (20)
[0105] where v0 = v center is the central node, v1, v2, ..., v k are neighbor nodes starting from the central node, e1, e2, ..., e k It is the connection edge between these nodes, each edge carries the corresponding time information T ek .
[0106] For each edge e in the path k , check whether its time information meets the time constraint. If the time information of the edge does not meet the requirements, the edge is pruned and the path is updated. In the end, only those paths in which the time information of all edges in the path meets the time constraint will be retained. If some nodes become isolated nodes after pruning, these isolated nodes will also be deleted from the local graph. Finally, the remaining part is the local graph G that meets the time constraint. f .
[0107] (4) Answer scoring
[0108] In time-constrained assessments, specific scoring mechanisms are used to measure the relevance of entities to a given time range, Time, for different question types. These question types include time matching, time precedence, time maximum, and time union. The following is a detailed scoring method for each type:
[0109] 1) Time union type
[0110] For the time joint problem, the goal is to assign positive scores to entities whose time lies between the specified interval Time1 and Time2, while other entities are scored as 0. e Satisfy Time1<time e If Time<Time2, a positive score is assigned; otherwise, the score is 0. The specific calculation process is shown in formula (21).
[0111]
[0112] Where C is a positive constant.
[0113] 2) Time maximum value type
[0114] When the question type is first or last, the score is assigned based on the relative early or late time: for first, the earlier the entity, the higher the score; for last, the later the entity, the higher the score. The specific calculation process is shown in formula (22).
[0115]
[0116] 3) Time sequence type
[0117] When the question type is "before" or "after," the score is inversely proportional to the temporal proximity of the entity. Specifically, for "before," the closer the time to T1, the higher the score; for "after," the closer the time to T2, the higher the score. The specific calculation process is shown in formula (23).
[0118]
[0119] 4) Time matching type
[0120] When the question type is matching, entities whose corresponding time is exactly equal to Time are assigned a high score, while other entities are scored as 0. Specifically, if the entity's time exactly matches Time, a positive score is assigned; for entities that do not match, the score is 0. The specific calculation process is shown in formula (24).
[0121]
[0122] Where M is a positive constant.
[0123] In order to combine the scores of the above four time activation functions, a comprehensive scoring formula is used to dynamically assign scores according to the type of question. i , e i ) is the problem q i type.
[0124] Finally, the score obtained by temporal local graph inference is fused with the score obtained by the fact retrieval module to obtain the final score, as shown in formula (25).
[0125] score fusing =μ*score sematic +(1-μ)*score resonin g (25)
[0126] Where μ∈(0,1).
[0127] Through the above scoring mechanism, the relevance between entities and time constraints can be dynamically evaluated, and the rationality and accuracy of the final score can be ensured.
Claims
1. A knowledge graph multi-hop reasoning question answering method based on attention mechanism and time constraints, characterized by: The following steps are involved: (1) Time information parsing: First, identify and parse the explicit and implicit time information in the question, calculate the corresponding time points or time intervals, and then rewrite the question based on the temporal knowledge graph; (2) Fact retrieval: The existing pre-trained model RoBERTa is used to segment the question into words, and then a time decomposition strategy is used to encode the time. Semantic fusion is performed based on the transformation matrix to obtain the semantic vector representation of the question, and the scoring function of the temporal knowledge graph is combined to screen candidate entities. (3) Temporal reasoning: Mining high-frequency candidate constraints from the knowledge graph and calculating confidence to construct an accurate set of temporal constraints. Then, based on the L-hop neighborhood of the central entity, extracting related entities and relationships, constructing a local knowledge graph, and integrating temporal constraints to screen the optimal answer.
2. The knowledge graph multi-hop reasoning question answering method based on attention mechanism and time constraint according to claim 1 is characterized in that: The time information analysis in step (1) includes: (1-1) Extract explicit time knowledge from natural language questions by identifying event entities, retrieving their associated start and end times using the temporal knowledge graph, and replacing fuzzy time expressions with structured timestamps to achieve explicit rewriting of the temporal semantics of the question. (1-2) For implicit time knowledge that is not directly related to time expression in the problem, a joint query method is used to combine the attribute information of the entity and its contextual association to infer the possible time interval, and the optimal time range is screened through the confidence evaluation mechanism to structure the implicit time information into explicit time constraints.
3. The knowledge graph multi-hop reasoning question answering method based on attention mechanism and time constraint according to claim 1 is characterized in that: The fact retrieval in step (2) includes: (2-1) Use the pre-trained language model RoBERTa to segment and encode the input natural language questions, extract the contextual semantic information of the questions through a multi-layer Transformer structure, and generate an embedding vector corresponding to each segmentation; (2-2) Using a time decomposition strategy, the time information is split into independent vectors of year, month, and day, and semantic fusion is performed based on the transformation matrix. Then, a relationship-oriented attention mechanism is used to calculate the weight of the relationship vector in temporal reasoning. (2-3) Combined with temporal knowledge graph embedding, the original entity, relationship and time encoding in the question are converted into corresponding pre-trained vector representations; (2-4) Use the information fusion layer to encode the contextual semantic vector, structured entity embedding, relation embedding, and time vector to fuse the information into a single question representation.
4. The knowledge graph multi-hop reasoning question answering method based on attention mechanism and time constraint according to claim 1 is characterized in that: The temporal reasoning in step (3) includes: (3-1) Identify high-frequency relationship patterns in the knowledge graph and instantiate them into specific graph patterns. Then, use a pattern matching algorithm to extract time constraint patterns that match the current problem from the knowledge graph, calculate the frequency of occurrence of these patterns in historical queries, and prioritize high-frequency patterns. (3-2) Using the confidence calculation method, candidate time constraints are screened and only high-confidence time constraints are retained. The joint probability between entities, relations, and time is calculated. For constraints with low confidence but still potentially relevant, a soft matching strategy is used to adjust them. (3-3) Refine the candidate constraints, and limit the scope of application of constraints that do not meet the strict confidence threshold but are above the loose threshold to only apply to specific entity categories. Classify different types of time constraints and adjust their application methods. Use a dynamic adjustment strategy to select the optimal constraint set based on the complexity of the problem. (3-4) Based on the multi-hop neighborhood of the central entity, relevant entities and relationships are extracted to construct a local knowledge graph. Then, time constraints are used for cropping and filtering of edges and nodes that meet the time conditions. On this basis, specific time activation functions are designed for scoring according to different types of time constraint problems. The temporal reasoning score is integrated with the fact retrieval score to obtain the final answer.
Citation Information
Cited By
Automatic testing method and system for electric energy meter
CN121454441A
Agricultural pest diagnosis and prevention method and device, electronic equipment and storage medium
CN121640072A