A method for constructing an implicit reasoning model of geographic knowledge graph considering time characteristics
By introducing time feature encoder and entity encoder into the geographical knowledge graph, combining projection operators and intersection operators, the problem of poor utilization of time features in the geographical knowledge graph is solved, and more accurate geographic query questions and answers are achieved, which has improved the The query efficiency and accuracy of the model.
Patent Information
- Application Number
- CN202411379623.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-09-30
AI Technical Summary
When using time features to conduct geographic knowledge graph logic query, the prior art cannot effectively extract and utilize time information, resulting in inaccurate model prediction and reasoning, and it is difficult to balance the weight and influence of time features in the knowledge graph.
A geographic knowledge graph implicit reasoning model that takes into account time characteristics is proposed. The time information is encoded into numerical features through entity encoder and time feature encoder, and combined with entity features is used to model using projection operators and intersection operators. Training and query processing, building the maximum boundary loss function to improve model performance.
It effectively improves the accuracy and efficiency of geographic query questions and answers in the geographical knowledge graph. Through experimental verification of the geographic logic query model that integrates time characteristics can provide more accurate query results, and the weight configuration of balanced time characteristics has a positive impact on model performance.
Smart Images

Figure CN118917402B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph embedding technology, and in particular to a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics. Background Art
[0002] Logical query in knowledge graph is a core task in the field of artificial intelligence, which enables users to retrieve and query complex information in knowledge graph. Knowledge graph embedding technology maps entities and relationships in knowledge graph to low-dimensional vector space through deep learning or other machine learning algorithms. By embedding the query graph of the knowledge graph into the vector space, the prediction vector of the target node is obtained by calculation, and then the required target node is effectively searched. Knowledge graph embedding not only helps to overcome the scalability and flexibility problems faced by traditional symbolic logic methods in processing large-scale data, but also enhances the model's ability to grasp the potential semantics of the knowledge graph.
[0003] However, despite the significant progress in knowledge graph embedding technology, the effective use of temporal features remains a challenge in the study of geographic knowledge graph logical queries. Current temporal encoding models often fail to effectively extract and utilize the features of temporal information when processing time point information, resulting in inaccuracies or biases in model prediction and reasoning. In addition, how to design effective encoding and fusion mechanisms to integrate temporal features into geographic knowledge graph embedding, and how to balance the weight and influence of temporal features in the embedded representation, are issues that need to be addressed urgently. Summary of the invention
[0004] The purpose of the present invention is to provide a method for constructing an implicit reasoning model of a geographic knowledge graph that takes time characteristics into account, and solves the problem of how to effectively encode and utilize time information in a geographic logical query and answering system to enhance the expressive power of the geographic knowledge graph and improve the accuracy and efficiency of queries; by encoding time points, the information of the time dimension can be converted into numerical features that are easy for machines to process, thereby realizing query processing of time-sensitive tasks under the framework of the geographic knowledge graph.
[0005] To achieve the above object, the present invention provides a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics, comprising the following steps:
[0006] S1. Using the physical encoder Embed any knowledge graph containing time information into d dimensional vector space;
[0007] S2, the projection operator performs the link prediction operation, calculating the entities and relations in space to obtain the prediction vector;
[0008] S3. Use the intersection operator to process the logical AND operation in the logical query and find common entities among multiple entity sets.
[0009] S4, construct the maximum boundary loss function for model training;
[0010] S5. Develop evaluation indicators to evaluate model performance;
[0011] S6, model training and parameter setting;
[0012] In step S1, the physical encoder Entity Feature Encoder and temporal feature encoder , the entity feature encoder Any entity in the geographic knowledge graph Embed in dimensional vector space;
[0013] For any entity , entity feature encoder The entity will be calculated by embedding the lookup method Embedding:
[0014]
[0015] in, is the embedding matrix of all entity types in the geographic knowledge graph, Representing Entities One-hot vector in geographic knowledge graph, therefore, An embedded lookup operation will be performed to obtain the corresponding columns Entity embedding, represents the L2 norm;
[0016] The temporal feature encoder Any entity The time is embedded in In the vector space, the time information includes two scales: time point and time period. The time feature encoder is used to process information of different time scales:
[0017] If the time information contained in a geographic entity is a time point, its modern standard time is used as Input;
[0018] If the time information contained in a geographic entity is a time period, the dimensionality reduction method is used to reduce the two-dimensional time period into a one-dimensional time point. Input;
[0019] For non-geographic entities in the geographic knowledge graph or geographic entities that lack time information, the time feature will be padded with a zero vector;
[0020] Therefore, for any geographic entity in the geographic knowledge graph, the temporal feature encoder Geographic Entity The time information is encoded as , expressed as the following formula:
[0021]
[0022] in, Indicates a point in time, represents the time point after the time period is reduced in dimension, and ∈( );
[0023] The dimensionality reduction method includes head-end sampling, tail-end sampling and random sampling. The head-end sampling means using the start time of the time period to represent the time period, the tail-end sampling means using the end time of the time period to represent the time period, and the random sampling means randomly selecting a time point in the time period to represent the time period. After the time period is reduced in dimension, the time point encoding method is used to encode and represent the reduced time point.
[0024] The entity encoder Entity Feature Encoder and temporal feature encoder , then in step S1, the entity encoder Any entity in the geographic knowledge graph Embed in It is expressed in a dimensional vector space as:
[0025]
[0026] Among them, [;] represents the concatenation of feature vectors, ;
[0027] In step S2, for a given geographic knowledge graph , projection operator Perform link prediction operations to calculate entities and relationships in space to obtain prediction vectors. Depending on the input object, the projection operator is divided into two types: and ;
[0028] The input processed is a triple header entity and relationship , predict the tail entity; Processing logical queries Basic graph query model in , is bounded by existential quantifiers vector embedding to predict The vector embedding of
[0029]
[0030] in, and is a trainable relationship matrix, and The functions of are feature embedding and time embedding respectively;
[0031] In step S3, the intersection operator based on the self-attention mechanism is used From multiple Perform intersection operation on embedding to obtain query embedding A single target node in Embed , expressed as:
[0032]
[0033] The intersection operator uses the average value, minimum value and maximum value of the elements in the vector or the neural network structure with the invariant arrangement of Deep Sets;
[0034] In step S4, the model training includes geographic knowledge graph The training phase and geographic knowledge graph question answering training;
[0035] In the Geographic Knowledge Graph In the training phase, the data source for training is the structure of the geographic knowledge graph G itself. , any node : First, get the node from the triple of the geographic knowledge graph All first-degree neighbor nodes, from the negative sample set Sample n groups of negative samples , the model training strategy at this stage is to predict the node The embedding is closest to the positive sample Embedding, and stay away from the negative sample set Each negative sample in The embedding of the predicted node is as close to the positive sample as possible, and as far away from the negative sample as possible, thereby constructing the maximum boundary loss function:
[0036]
[0037] in Indicates the distance between calculated vectors;
[0038] Question-answering in geographic knowledge graph In the training phase, the data source for training is the manually constructed geographic knowledge graph question-answer pairs. ,for , any question-answer pair All follow the basic query subgraph pattern. The model training goal at this stage is to embed the correct answer node into the predicted embedding closest to the question and away from all negative sample sets. All negative samples in The embedding of the node, therefore, the training loss function at this stage adopts the following maximum boundary loss:
[0039] .
[0040] Preferably, in step S5, the evaluation indicators include the area under the ROC curve AUC and the average percentile ranking APR;
[0041] The AUC measures the model's ability to distinguish between correct answers and random negative samples by calculating the ROC curve and finding the area under the curve;
[0042] The APR measures the relative ranking of the correct answers given by the model across all queries by calculating the average percentile rank of the correct answers in the model's predictions.
[0043] Therefore, the present invention adopts the above-mentioned method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics, and the beneficial effects are as follows:
[0044] (1) This paper deeply analyzes the existing geographic knowledge graph embedding technology and proposes an implicit reasoning model that takes time features into account. It solves the problem of how to improve the accuracy and efficiency of geographic query and answering in geographic knowledge graphs by effectively extracting time features.
[0045] (2) Based on the logical query basis in the geographic knowledge graph and the characteristics of geographic logical query tasks, this paper introduces a time feature encoder to encode time information into a numerical vector, which is then integrated with the entity embedding of the geographic knowledge graph, thereby clarifying the importance of time information in the logical query of the geographic knowledge graph.
[0046] (3) Through a series of experiments, this paper verifies that the geographic logical query model integrating temporal features can provide more accurate query results. Through comparative experiments, the effects of different temporal encoders and weight configurations on model performance are analyzed. The results show the ability of temporal encoders to extract temporal features and their effectiveness in geographic logical query answering.
[0047] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is an overall flow chart of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0049] Figure 2 It is a structural diagram of a method for enhancing geographic entity features according to an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time features of the present invention;
[0050] Figure 3 It is a schematic diagram of the structure of an implicit reasoning model of a geographic knowledge graph taking into account time characteristics in an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0051] Figure 4 It is a schematic diagram of the model structure of an intersection operator based on a self-attention mechanism in an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0052] Figure 5 It is a schematic diagram of the structure of a direct time coding model of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0053] Figure 6 It is a schematic diagram of the structure of a feedforward neural network time coding model of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0054] Figure 7 It is a schematic diagram of the Date2vec time coding model structure of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0055] Figure 8 It is the time data distribution of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0056] Fig. 9 It is a schematic diagram of entity types and quantities in the Yago15k dataset geographic knowledge graph of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0057] Fig.10 It is a schematic diagram of a unified time expression framework of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention;
[0058] Fig.11It is a schematic diagram of a query subgraph pattern of an embodiment of a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics of the present invention. DETAILED DESCRIPTION
[0059] The technical solution of the present invention is further described below through the accompanying drawings and embodiments.
[0060] Unless otherwise defined, technical or scientific terms used in the present invention shall have the common meanings understood by one having ordinary skills in the field to which the present invention belongs.
[0061] The Graph Query Embedding (GQE) model is a vectorized embedding technology in the knowledge graph, which is used to convert logical queries in the network into vector representations in a low-dimensional space. The core idea of this method is to embed network nodes into a low-dimensional space and represent logical operators by learning geometric operations, so that complex logical queries can be predicted and analyzed efficiently. Among them, the logical query question answering model mainly consists of three parts: entity encoder, projection operator and intersection operator.
[0062] In actual geographic problems, the answers to many geographic questions rely on time information and time reasoning. When performing geographic knowledge graph entity query and reasoning, the present invention uses time features as part of the geographic entity features of the geographic knowledge graph to enhance the time semantics of geographic entities. By integrating time features and performing time reasoning, the accuracy of query results is enhanced. Integrating time information into the encoding of geographic entities is called temporal geographic entities.
[0063] The temporal geographic entity is divided into geographic entity and geographic time. The geographic entity and geographic time need to be encoded separately. The time encoding is divided into entity feature encoding and time feature encoding. The feature aggregation is performed in the form of splicing and sent to the downstream task for training. The structure diagram of the geographic entity feature enhancement method taking into account the time feature is shown in the figure. Figure 2 As shown in Figure 1, we propose a geographic knowledge graph implicit reasoning model TFKGE that takes into account temporal characteristics. The model structure is as follows: Figure 3 shown.
[0064] Take an example query to illustrate the workflow of the implicit reasoning model TFKGE of the geographic knowledge graph that takes into account time features. Query historical events that occurred in a certain historical period and are derivative events caused by a certain important event. This query can be regarded as an intersection query consisting of two triples, represented as (a certain historical period, occurred,?) and (a certain important event, caused,?), and the intersection of the two triples is the target node to be queried. For the entities and relations in the geographic knowledge graph, the entity feature encoder is used to embed them into the vector space, and the time encoder is used to embed the time information of the entity into the vector space. The projection operator is responsible for calculating the projection of the geographic entity vector of "a certain historical period" on the "occurrence" relationship vector to obtain the result vector of the triple query, and the projection of the geographic entity vector of "a certain important event" on the "cause" relationship to obtain the result vector of the triple query. The intersection operator uses methods such as minimum value or mean to calculate multiple result vectors to obtain the target vector of the intersection of the two triple queries. Finally, the nearest neighbor search method is used to calculate the cosine similarity with all geographic entity vectors containing time features in the geographic knowledge graph to obtain the target node to be queried.
[0065] like Figure 1 As shown, a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics includes the following steps:
[0066] S1. For a given geographic knowledge graph G, entity encoder Ability to embed any geographic knowledge graph into d dimensional vector space, the entity encoder Entity Feature Encoder and temporal feature encoder .
[0067] Solid Feature Encoder Any entity in the geographic knowledge graph Embed in In a vector space of dimension , for any entity , entity feature encoder The entity will be calculated by embedding the lookup method Embedding:
[0068]
[0069] in, is the embedding matrix of all entity types in the geographic knowledge graph, Representing Entities One-hot vector in geographic knowledge graph, therefore, An embedded lookup operation will be performed to obtain the corresponding columns Entity embedding, represents the L2 norm.
[0070] Temporal Feature Encoder Any entity The time is embedded in In vector space,
[0071] Temporal information includes two scales: time point and time period. The temporal feature encoder is used to process information of different time scales, such as:
[0072] (1) If the time information contained in a geographic entity is a time point, such as the establishment time of a theater in 1985, its modern standard time is used as Input;
[0073] (2) If the time information contained in a geographic entity is a time period, such as the time of an important international event from August 8, 2008 to August 24, 2008, then the dimensionality reduction method is used to reduce the two-dimensional time period into a one-dimensional time point as Input;
[0074] (3) For non-geographic entities or geographic entities in the geographic knowledge graph that lack time information, the time feature will be padded with a zero vector;
[0075] Therefore, for any geographic entity in the geographic knowledge graph, the temporal feature encoder Geographic entities can be The time information is encoded as , which can be expressed as the following formula:
[0076]
[0077] in, Indicates a point in time, represents the time point after the time period is reduced in dimension, and ∈( ).
[0078] Since the entity encoder Entity Feature Encoder and temporal feature encoder , then in step S1, the entity encoder Any entity in the geographic knowledge graph Embed in In the vector space of dimension, the formula in step S1 can be expressed as:
[0079]
[0080] Among them, [;] represents the concatenation of feature vectors, .
[0081] The dimensionality reduction method can reduce the dimensionality of a two-dimensional time period into a one-dimensional time point, thereby unifying the encoding of the time point and the time period. The dimensionality reduction methods include head sampling, tail sampling, and random sampling. Head sampling means using the start time of the time period to represent the time period, tail sampling means using the end time of the time period to represent the time period, and random sampling means randomly selecting a time point in the time period to represent the time period. After the time period is reduced in dimensionality, the time point encoding method is used to encode and represent the reduced time point.
[0082] The present invention combines the entity feature encoder and the time feature encoder to form a geographic knowledge graph reasoning model TFKGE that takes time features into account, and integrates time features into the geographic knowledge graph embedding, thereby realizing logical query of geographic knowledge graph query in time.
[0083] Among them, the temporal feature encoder embeds the temporal information of geographic entities into the vector space. In this embodiment, direct encoding, feedforward neural network and Date2Vec are used as temporal feature encoders respectively to verify the ability of different temporal encoders to extract temporal features and their role in improving downstream tasks.
[0084] As a preferred technical solution of the present invention, the temporal feature encoder in step S1 includes a direct encoding method, a feedforward neural network and Date2vec.
[0085] Direct Encoding Method
[0086] The direct encoding method performs simple preprocessing on the time information as the subsequent time feature input. Preprocessing methods include conversion and normalization. Conversion refers to the uniform conversion of various units of modern time expression into years. Since there is a conversion relationship between different time granularities, it means that they are related. For example, June can be expressed as 0.5 years. The semantic information of time can be explicitly represented through time unit conversion, which helps the model to better extract time features. Normalization refers to dividing each unit of time data by the largest year in the data set and normalizing them to (-1, 1). The direct encoding method can be used to fuse with the deep learning model as a reference model to verify the effectiveness of time fusion. The model structure is as follows Figure 5 shown.
[0087] Feedforward Neural Network
[0088] Feedforward Neural Networks (FNN) is one of the earliest artificial neural networks. Its characteristic is that the signal in the network propagates in only one direction: from the input layer through multiple hidden layers to the output layer without any feedback loop. Each layer of the network consists of multiple neurons, each of which is connected to each neuron in the next layer through weighted connections.
[0089] The feedforward neural network mainly consists of three parts: input layer, hidden layer and output layer. The input layer is responsible for receiving external data, the hidden layer extracts the features of the data, and then the output layer outputs the calculation results. The skip connection structure was introduced in the residual network (ResNet) architecture proposed by He et al. in 2015, which can effectively enhance network performance. The skip connection jumps the layer in the neural network and uses the output of this layer as the input of the next layer, thereby retaining the details and semantic information of the original input data and making it easier to pass information to deeper layers of the network. The skip connection can effectively alleviate the gradient vanishing problem, accelerate network training, and improve the depth and performance of the network.
[0090] Therefore, this embodiment designs a time encoder based on a feedforward neural network, and the model structure is as follows: Figure 6 As shown in the figure, the input time information is a 6-dimensional vector in the form of year, month, day, hour, minute, and second. A single hidden layer unit includes a linear layer, a LeakyRelu activation layer, and a normalization layer. After multiple hidden layers, the time features are extracted to form the final time feature vector.
[0091] Date2vec
[0092] Date2vec uses an auto encoder (AE) structure, which consists of an encoder and a decoder. The encoder is responsible for extracting time features, and then the decoder is used to restore the time. By calculating the loss, the decoded time is kept as consistent as possible with the input time. After the model is trained, the pre-trained weights are obtained, and the encoder module is used to extract time features to obtain the time encoding vector. The Date2vec method uses the trigonometric function activation layer in Time2vec to capture time periodicity. The network structure model is shown in Figure 6.
[0093] In the encoder part of Date2vec, the time value is first input into the model, and the feature vector is obtained through the processing of the fully connected layer, and the trigonometric function activation layer is used to obtain the periodicity of time. Through the jump connection structure, a vector representation with the characteristics and periodicity of time itself is obtained, and then the time features are extracted through the fully connected layer. In the decoder part, for the time feature vector, the decoder module uses two layers of fully connected layers to decode the time value to obtain the restored time value. By calculating the mean square error loss of the real time value and the restored time value, the model parameters are optimized so that the restored time value is close to the real time value.
[0094]
[0095] Therefore, the encoder and decoder structure used by Date2Vec can effectively extract temporal features and can be easily embedded in downstream tasks.
[0096] S2. For a given geographic knowledge graph , projection operator Perform link prediction operations to calculate entities and relationships in space to obtain prediction vectors. Depending on the input object, the projection operator is divided into two types: and ;
[0097] The input processed is a triple header entity and relationship , predict the tail entity; Processing logical queries Basic graph query model in , is bounded by existential quantifiers vector embedding to predict The vector embedding of
[0098]
[0099] in, and is a trainable relationship matrix, and The functions of are feature embedding and time embedding respectively.
[0100] Logical query is also called Conjunctive Graph Query (CGQ). For any query statement , the query statement can be expressed by the following formula:
[0101]
[0102] in , , , , In the Geographic Knowledge Graph The set of all conjunction graph queries on , Represents a query statement The target node to replace the answer entity, is the existence quantifier ( ) constrained nodes. Yes Query The set of anchor nodes in It is the basic graph mode in CGQ.
[0103] Logical query It is represented by the computation sequence between entities and relationships in the geographic knowledge graph, which is usually assumed to be a directed acyclic graph (DAG), and is the starting node and the target node This restriction can make the logical query question answering task consistent with the traditional question answering problem setting such as semantic analysis.
[0104] If a logical query The answer entity in corresponds to the target entity is a geographic entity, then this query It is called geographic logical query. Geographic entities refer to entities related to geographic space, geographic time or geographic concepts, such as cities, events, etc. Geographic logical query involves not only basic logical query operations, but also logical operations in time and space. If two events are close in both time and space dimensions, their distance after embedding in the vector space should also be close. Correcting or optimizing the embedded geographic entities through time and space dimensions is the core of geographic logical query.
[0105] S3, using the intersection operator to process the logical AND operation in the geographic logical query and find common entities between multiple entity sets;
[0106] Intersection Operator From multiple Perform intersection operation on embedding to obtain query embedding A single target node in Embed , which can be expressed as:
[0107]
[0108] The intersection operator can use the average value, minimum value, and maximum value of the elements in the vector, or a permutation-invariant neural network structure such as DeepSets.
[0109] The GQE model uses the element-wise minimum method and a feedforward network as the intersection operator. , the CGA model uses an intersection operator based on the self-attention mechanism .
[0110] In the GQE framework, each query is represented as its directed acyclic graph (DAG) structure, and then an algorithm is used to generate the embedding of the query based on this DAG. This process starts with the anchor node embedding of the query and generates an embedding corresponding to the query by iteratively applying geometric operations.
[0111] Mai borrowed the idea of graph attention mechanism and proposed an intersection operator based on attention mechanism, and proved that the intersection operator based on self-attention mechanism proposed in CGA model The performance is better than Therefore, the present invention adopts As the intersection operator of the TFKGE model, the intersection operator based on the self-attention mechanism The model structure is as follows Figure 4 shown.
[0112] S4. Construct a maximum loss function for model training, which includes geographic knowledge graphs The training phase and geographic knowledge graph question answering training;
[0113] In the Geographic Knowledge Graph In the training phase, the data source for training is the structure of the geographic knowledge graph G itself. , any node : First, get the node from the triple of the geographic knowledge graph All first-degree neighbor nodes, from the negative sample set Sample n groups of negative samples The model training strategy at this stage is to predict the node The embedding of embedding, and should be far away from the negative sample set Each negative sample in The embedding of the predicted node is as close to the positive sample as possible, and as far away from the negative sample as possible, thereby constructing the maximum boundary loss function:
[0114]
[0115] in Indicates the distance between calculated vectors;
[0116] Question-answering in geographic knowledge graph In the training phase, the data source for training is the manually constructed geographic knowledge graph question-answer pairs. ,for , any question-answer pair All follow the basic query subgraph pattern. The model training goal at this stage is to embed the correct answer node into the predicted embedding closest to the question and away from all negative sample sets. All negative samples in The embedding of the node, therefore, the training loss function at this stage adopts the following maximum boundary loss:
[0117] .
[0118] In order to quantitatively evaluate the performance of TFKGE in the geographic question answering task, the dataset used in this embodiment is based on Yago15k and adds numerical time information and geographic location information.
[0119] The Yago15K dataset is aimed at geographic knowledge graph query reasoning problems, which contains 15,404 entities, 122,886 triples, and 32 types of relationships. After expanding the time information, the number of geographic entities with time information is 14,588, the number of non-geographic entities without time information is 816, the number of time triples is 37,123, and the number of time relationship types is 5. The Yago15k dataset, time information, and geographic location information are shown in Table 1:
[0120] Table 1 Yago15k dataset and extended data examples
[0121]
[0122] The dataset consists of triplets (Head, Relation, Tail), where the types of time information include time points and time periods. Each time relationship can constitute a time point, such as the creation date of a place. Paired time relations constitute time periods, such as a person's date of birth and date of death. The types and quantities of time relations are shown in Table 2:
[0123] Table 2 Types and quantities of time relations
[0124]
[0125] Figure 8The time distribution range and frequency are shown. As can be seen from the figure, the time range of the data set is from 100 to 2018, and most of them are concentrated around 1900. The Yago15k_Numerical data set is a public data set that supports geographic logical query and answering, and can support the model to perform logical queries on geographic issues. Therefore, this embodiment trains TFKGE on the Yago15k geographic knowledge graph. full Compared with GQE and other models, TFKGE introduces a temporal feature encoder, which makes full The model has temporal characteristics and can perform logical reasoning over a certain period of time when performing calculations in vector space.
[0126] Entity type is an abstraction of a set of entities with the same characteristics or attributes in the geographic knowledge graph. The edges in the geographic knowledge graph can be represented by (entity type, relationship, entity type). For example, the edge (event, occurred, location) is used for an event to occur at a certain location. This embodiment divides the relationships in the data set into six types: location, person, movie, event, organization, and others. In order to determine the type of entity in the geographic knowledge graph, the present invention filters the types of the previous and next entities through the relationship in the triple and classifies each node. The pattern diagram of the data set is as follows: Fig. 9 shown.
[0127] The time information in the data set is converted into the expression form of year, month, day, hour, minute, and second through the unified time expression framework, such as Fig.10 As shown. Since there is a many-to-one relationship in the graph, in order to ensure that each edge in the geographic knowledge graph dataset has a reverse edge, this embodiment explicitly specifies the bidirectional relationship of the edge. For example, if there is an edge in the network , explicitly add a new edge in the opposite direction By explicitly specifying the reverse edge, better performance can be achieved in the path query task.
[0128] Construction of query subgraph
[0129] In an actual geographic query problem, the query problem can be decomposed into different entities and edges to form a query subgraph. Geographic knowledge graph queries usually involve finding subgraphs of nodes and edges that meet specific conditions. The present invention considers multiple node query subgraphs consisting of four nodes or less, which contain a target node and query nodes of less than three nodes, and each query subgraph is a directed acyclic graph structure. For query problems with four nodes or less, the following ten basic query subgraphs can be formed:
[0130] Two-node chain query: Indicated by 2-chain, the query problem consists of two nodes and a single edge. This type of query is used to find the target node pointed to by the node after the chain query between two entities. For example, "query the river that flows through the capital of a certain country". In this query, "a certain country" is a node, "capital" is another node, and "flows through" is the relationship edge connecting the river and the capital. The query first finds the "capital" of "a certain country", and then queries the "river" node connected to the "capital" and the "flows through" relationship.
[0131] Two-node intersection query: Indicated by 2-inter, the query problem consists of two nodes and two sides. This query involves two nodes and two edges, and both sides point to the same node. For example, the query "Which places are both world heritage sites and national parks" where the query target is "Grand Canyon National Park", one edge indicates that it is a "world heritage site" and the other edge indicates that it is a "national park".
[0132] Three-node chain query: Indicated by 3-chain, the query problem consists of three nodes and three edges. They are connected in sequence through three edges to form a linear chain subgraph. For example, the query "a river originating from a certain plateau, flowing through a certain country, and flowing into a certain sea at a certain place". This query involves four nodes: mountains, countries, cities, and oceans, as well as three relationships between them. The mountains are the starting point, which is the origin of the river; the country is the area through which the river flows; the city is the last place the river passes before flowing into the ocean; the ocean is the end point of the river.
[0133] Three-node star query: Indicated by 3-inter, the query consists of three nodes and three edges. The three nodes are connected to the fourth node in the center through edges to form a star structure. For example, "find a country in Asia that has a temperate monsoon climate and a population of more than 200 million". Here, Asia, temperate monsoon climate, and population are interconnected through the central node of the country.
[0134] Three-node chain intersection query: Indicated by 3-chain-inter, the query problem consists of three nodes and three edges. First, two nodes form a two-node chain structure subgraph, and then the subgraph forms an intersection structure with the third independent node. For example, the query "Query a country with lakes below 40 degrees latitude and a central park". The lake and latitude form a subgraph, and the country is an independent node directly associated with the central park.
[0135] Three-node intersecting chain query: Indicated by 3-inter-chain, the query question consists of three nodes and three edges. The three nodes first form a two-node intersecting structure subgraph, and then the intersecting node and the query answer form a chain structure subgraph. For example: query "all cities in a specific country that are both near the sea and near mountains, list the average temperature of these cities." This query consists of a chain query (city-country), an intersection query (city-seaside-mountain) and a single-node query (average temperature of the city).
[0136] The sampling methods of negative samples include standard negative sample sampling method and hard negative sample sampling. Standard negative sample sampling is to randomly sample from the incorrect node subset. The hard negative sample sampling method obtains negative samples of the same type as the positive samples. For the basic query subgraph pattern introduced above, the standard negative sample sampling method is used. For queries involving intersection operations, the hard negative sample sampling method is used to form a hard negative query subgraph, including Hard-2-inter, Hard-3-inter, Hard-3-chain-inter, and Hard3-inter-chain. The query subgraph pattern is as follows: Fig.11 As shown in Figure 1, the black box indicates that the query subgraph is obtained by the hard negative sample sampling method. For the model, it is more difficult to identify hard negative samples than standard negative samples.
[0137] Question answering dataset construction
[0138] When constructing the question-answering dataset, the sampling rule follows the basic query subgraph pattern, sampling a fixed number n of example queries for each query subgraph. , where E represents the subgraph mode There are E edges. The following steps are used to sample the edges:
[0139] (1) First, sample the target nodes of the query;
[0140] (2) From this node, follow Sample the next node and add it to the queue;
[0141] (3) Iteratively pop nodes from the queue, starting from the A sampling of popped nodes neighbor nodes, and so on;
[0142] (4) When the remaining nodes cannot meet the sampling requirements of the current query subgraph pattern, sampling will be terminated to ensure that the sampled query subgraph pattern meets the requirements.
[0143] In order to construct a question-answering dataset for training, the present invention randomly removes 10% of the edges from the entire network, and constructs a training set of the question-answering dataset according to the above method. When constructing the test set and validation set of the question-answering dataset, sampling is performed directly on the original network. At least one query edge that is removed during the training phase is selected to ensure that the queries in the test set cannot be directly solved by the information already available in the training set. If the model relies solely on the patterns learned in the training set to answer queries in the test set, the effect will not be better than random guessing, which helps to improve the generalization ability and robustness of the model. The model cannot correctly answer questions in the test set only by memorizing specific patterns in the training data, so that the model learns deeper features and rules, thereby improving its generalization performance on new data.
[0144] The triplets in the geographic knowledge graph are divided into training set, test set and validation set in a ratio of 90:9:1 to ensure that every entity and relationship appears in the training set. , the basic query subgraph patterns were sampled respectively. The number of samples of each query subgraph in the training set is 1,000,000. For the test set and validation set, the number of samples of each query subgraph pattern is 1,000. The Yago15k geographic knowledge graph and the number of constructed geographic logical queries are shown in Table 3.
[0145] Table 3 Statistics of Yago15k and geographic logic queries
[0146]
[0147] This embodiment sets up three baseline models and three models that integrate different time encoding methods to test the contribution of the implicit reasoning model of the geographic knowledge graph that takes into account time characteristics proposed in the present invention to the geographic logic question answering task.
[0148] (1) CGA; and TFKGE full In contrast, CGA uses a different entity feature encoder and different projection operators When the CGA model is used as a baseline model, it does not consider the temporal features, but only the features of the geographic knowledge graph entities themselves. CGA is used to verify that the proposed implicit reasoning model taking into account the temporal features is superior to other models in the geographic logical query answering task.
[0149] (2) GQE and GQE diag . GQE and GQE diag The difference between them is that they use different projection operators: and . With TFKGE full Compared with GQE diagOnly physical feature encoders are used and intersection operator . GQE and GQE diag The training target is only the manually constructed geographic knowledge graph question-answer pairs. . GQE and GQE diag As a baseline model, it does not consider the time feature, just the features of the geographic knowledge graph entity itself, just like CGA. diag The role of the model is to compare the model operation effects before and after the fusion of temporal features, so as to verify the effectiveness of the temporal encoder in extracting temporal features.
[0150] (3) TFKGE direct . With TFKGE full In comparison, TFKGE direct The temporal feature encoder in TFKGE adopts a direct encoding method, normalizing and transforming the time as the temporal feature input and fusing it with the entity feature. direct The model is used to determine the improvement effect of directly integrating temporal information on downstream tasks, and is also used as a baseline model to compare the extraction effects of different temporal feature encoders on temporal features.
[0151] (4) TFKGE fnn . With TFKGE full In comparison, TFKGE fnn A feedforward neural network is used as the temporal feature encoder. fnn The role of the model is to compare the extraction effects of different time encoders on temporal features and the improvement effects on downstream tasks.
[0152] (5) TFKGE full TFKGE full Date2vec is used as the time encoder. The purpose of this model is to verify the effect of Date2vec on extracting time features and the impact of different pre-trained model weights on downstream tasks.
[0153] Experimental results and analysis
[0154] Experimental platform configuration
[0155] The experimental CPU environment for this embodiment is 11th Gen Intel(R) Core(TM) i9-11900K @3.50GHz, the GPU environment is NVIDIA GeForce RTX 3080 Ti, the video memory size is 28GB, the memory is 32G RAM, and the overall experiment is carried out in a Windows environment. The implementation code environment is Python3.7, PyTorch=1.12.1.
[0156] S5. Evaluate model performance based on evaluation indicators. When evaluating on the Yago15k question-answering dataset, the similarity between the predicted query embedding and the correct answer embedding is measured by the cosine similarity score, and the negative sample answer embedding is also scored. The evaluation goal is to rank first in the cosine similarity between the correct answer and the query embedding in both the negative sample set and the positive sample set. In this embodiment, two evaluation indicators used in geographic knowledge graph question-answering reasoning include the area under the ROC curve AUC and the average percentile ranking APR;
[0157] (1) AUC measures the model's ability to distinguish between correct answers and random negative samples by calculating the ROC curve and finding the area under the curve;
[0158] The ROC (Receiver Operating Characteristic) curve is a graphical performance measurement method that shows the relationship between the True Positive Rate (TPR) and the False Positive Rate (FPR) at different threshold settings. AUC represents the area under the ROC curve and can quantify the ability of a classifier to distinguish between two categories.
[0159] In the geographic query answering task, AUC is used to measure the model's ability to distinguish between the correct answer and random negative samples. AUC provides a performance indicator of the model's ability to distinguish between positive and negative samples by comparing the cosine similarity score between the correct answer and a randomly sampled negative sample for each query. Based on the model performance of all queries, the ROC curve is calculated and the area under the curve is calculated. The closer the AUC value is to 1, the stronger the model's ability to distinguish between the correct answer and the negative sample. A value of 0.5 means that the model has no ability to distinguish, which is equivalent to random guessing.
[0160] (2) APR measures the relative ranking of the correct answers given by the model across all queries by calculating the average percentile rank of the correct answers in the model's predictions.
[0161] APR calculates the average percentile ranking of the correct answer in the model prediction, that is, the average position of the positive sample score among all negative sample scores. In geographic knowledge graph geographic logic query question answering, APR measures the relative ranking of the correct answers given by the model in all queries. The higher the ranking, the higher the APR value, indicating better model performance.
[0162] The AUC metric focuses more on the overall ability of the model to distinguish between positive and negative samples, while the APR metric focuses more on the accuracy of the model in ranking the correct answers. Unlike AUC, APR considers all negative samples for each query, rather than just one random negative sample. Therefore, APR is a more comprehensive performance metric and a more robust evaluation metric that can better reflect the performance of the model in practical applications, especially its ranking ability when faced with a large number of potential answers.
[0163] S6, model training and parameter setting;
[0164] This embodiment adopts multiple strategies to regulate the training process to ensure that the model can effectively learn and have good generalization ability during the training process. Therefore, the validate_every parameter is introduced to reduce the model's dependence on the training set and improve the generalization of the model by performing cross-validation at a certain frequency during the training process.
[0165] The tolerance threshold parameter is used to prevent the model from overfitting. When the performance change is less than the tolerance threshold, the model is considered to have converged and the training is terminated in advance. The learning rate is the step size for updating parameters during model training, which has a significant impact on the performance of the model. If the learning rate is too large, the model loss may decrease too quickly, resulting in oscillation. If the learning rate is set too small, the decrease rate may be too slow, resulting in low convergence efficiency.
[0166] This example tests the learning rate and finds that TFKGE full The model works best when the learning rate is 0.001, and the Adam optimizer is selected. Through the training strategy and parameter setting, the model can achieve the best performance while ensuring the training efficiency. Table 4 lists the main parameters used in the model training process and their setting values.
[0167] Table 4 Experimental parameter settings of each model
[0168]
[0169] Geographic logical query answering based on different baseline models
[0170] This example experiments on ten basic query subgraph modes. Table 5 shows the experimental results of different base models on query subgraphs. From a vertical perspective, DAG Type is the basic query type. CGA, GQE and GQE diag It is the experimental result of the base model for the query type. Horizontally, it is the experimental results of the validation set and the test set. Full Val and Full Test represent the average results of various query modes. AUC and APR are used to evaluate the performance of the model.
[0171] Table 5 CGA, GQE and GQE diag Model Experiment Results
[0172]
[0173] As can be seen from the above table, GQE diag It performs better than CGA and GQE on most query types. diag The overall performance of the model is significantly better than that of CGA and GQE. This shows that GQE diag The decoder of the model is Bilinear diag The structure can more accurately retrieve relevant information when processing these specific types of geographic logical queries.
[0174] In specific tasks, for simple query types such as 2-chain and 2-inter, most models can achieve high AUC and APR values. However, for complex query types such as Hard-3-chain-inter and 3-chain, the performance of the models generally decreases, which shows that in geographic logical queries, the complexity of the query problem will affect the accuracy of the query results.
[0175] Since the hard negative sample sampling method is used to select negative samples that have the same type or features as the positive samples but do not actually meet the query conditions, this makes the negative samples semantically closer to the positive samples, thereby increasing the difficulty of distinguishing them. As can be seen from the table, CGA, GQE, and GQE diag The performance of the baseline models generally degrades when dealing with hard negative queries. This is consistent with the difficulty of hard negative sampling methods, which requires the model to be able to make fine distinctions between very similar pairs of samples. diag The model performs more robustly on hard negative queries.
[0176] Geographic logical query answering based on different time encoders
[0177] The experimental results of the TFKGE model based on different time encoders are compared with the experimental results of the base model to study the performance of the fusion model in geographic logical query answering and the ability of the time encoder to extract time features. Table 6 shows the TFKGE direct TFKGE fnn and TFKGE full Model experiment results.
[0178] Table 6 TFKGE direct TFKGE fnn and TFKGE full Model Experiment Results
[0179]
[0180] From Tables 5 and 6, we can see that in most query subgraph patterns on the test set, TFKGE direct Model relative to CGA, GQE and GQE diag The AUC and APR of the base model are improved. However, in the 3-chain-inter query mode, GQE achieves the best results in both AUC and APR indicators, while TFKGE direct Compared with GQE diag For the base model, the AUC is improved by 0.0068 and the APR is reduced by 0.2%, indicating that in this query subgraph mode, the query accuracy is not significantly improved by directly fusing time information.
[0181] The above analysis shows that introducing time information is helpful to improve the performance of geographic logical query and answering tasks of geographic knowledge graphs, and combining time information with entity features can improve the accuracy of geographic query and answering.
[0182] TFKGE fnn Model and TFKGE direct By comparing the model results, we can find that in different query subgraph modes, except for the 3-chain-inter query subgraph mode, TFKGE fnn The recognition accuracy is generally better than TFKGE direct This shows that the feedforward neural network is better than the direct time coding model in extracting temporal information features.
[0183] By TFKGE full Compared with other base models, we can find that TFKGE full The model achieved the best results in most indicators. full GQE relative to unfused time diag The model's AUC increased by 0.0161 and APR increased by 1.26%. full Compared with TFKGE which uses FNN to extract temporal features fnn The model's AUC increased by 0.0141 and APR increased by 0.56%. Therefore, in the downstream task of geographic knowledge graph and geographic logical query, Date2Vec can effectively extract time features, and its ability to extract time features is better than FNN and direct time encoding.
[0184] From the query patterns of the validation set and the test set, in all experimental models, the performance of 2-chain and 3-chain geo-logical queries is significantly lower than that of 2-inter and 3-inter, with AUC reduced by 0.1 and APR reduced by about 10%. In chain queries, the projection operator calculates the embedding of the head node and the embedding of the relationship to obtain the embedding of the predicted tail node, and the predicted tail node continues to be projected with the subsequent relationship to finally obtain the predicted target node embedding. Therefore, this may cause the distance between the embedding of the predicted entity and the embedding of the positive sample to be too large, resulting in a decrease in the performance of geo-logical query reasoning.
[0185] Example Analysis
[0186] Next, the present invention uses a query example to illustrate the effectiveness of time coding. Take the two-node intersection query mode 2-inter as an example:
[0187]
[0188] Depend on and composition. Check which events a country participated in. Query what events occurred in a certain place, and the result of their intersection is the query entity. Date2Vec time encoder results based on different weights
[0189] The Date2Vec model can convert time information into vector representation so that it can be effectively integrated with the entity and relationship features of the geographic knowledge graph. Date2Vec adopts the Auto Encoder (AE) structure, which is divided into an encoder and a decoder. After training, the encoder's weight is used to extract time information as a time feature vector. By configuring different weight distributions for the time feature vector encoded by the Date2Vec time encoder, the influence of the time feature vector on the geographic logical query reasoning results is studied.
[0190] Table 7 shows the impact of adjusting the weight parameter of the time vector (1, 0.1, 0.02, and 0.01, respectively) on the model performance when fusing the time feature vector with the entity feature vector.
[0191] Table 7 Logical query results of different time feature weights
[0192]
[0193] As can be seen from Table 7 and Table 6, without scaling the temporal feature vector, the query accuracy decreases in most query subgraph patterns. As the weight coefficient of the temporal vector decreases, the AUC and APR values of the model for the query subgraph pattern increase. This may be because time and entities come from different source domains, and the spatial distribution of the encoded feature vector values is also different. If the value of the temporal feature vector is much larger than that of the feature vectors of entities and relations, the model may rely too much on the temporal feature and ignore other important semantic information. However, when the weight parameter drops to 0.01, it can be found that the AUC and APR drop by 0.002 and 0.08% respectively. This shows that when the weight of the temporal feature is reduced to a certain extent, the contribution of temporal information may be too weak, resulting in the model being unable to fully utilize the temporal information to improve the accuracy and relevance of the query.
[0194] Therefore, reasonably controlling the scale of the time vector through weight parameters helps improve the overall performance of the model, balance the contribution of time information, avoid excessive reliance on a single feature, and enable the time encoder to be better integrated with downstream tasks.
[0195] Therefore, the present invention adopts the above-mentioned method for constructing an implicit reasoning model of geographic knowledge graph that takes into account time features, and verifies through a series of experiments that the geographic logic query model that integrates time features can provide more accurate query results. The effects of different time encoders and weight configurations on model performance are analyzed through comparative experiments, and the results show the ability of the time encoder to extract time features and its effectiveness in geographic logic query and answering.
[0196] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics, comprising the following steps: S1. Using the physical encoder Embed any knowledge graph containing time information into d dimensional vector space; S2, the projection operator performs the link prediction operation, calculating the entities and relations in space to obtain the prediction vector; S3. Use the intersection operator to process the logical AND operation in the logical query and find common entities among multiple entity sets. S4, construct the maximum boundary loss function for model training; S5. Develop evaluation indicators to evaluate model performance; S6, model training and parameter setting; In step S1, the physical encoder Entity Feature Encoder and temporal feature encoder , the entity feature encoder Any entity in the geographic knowledge graph Embed in dimensional vector space; For any entity , entity feature encoder The entity will be calculated by embedding the lookup method Embedding: in, is the embedding matrix of all entity types in the geographic knowledge graph, Representing Entities One-hot vector in geographic knowledge graph, therefore, An embedded lookup operation will be performed to obtain the corresponding columns Entity embedding, represents the L2 norm; The temporal feature encoder Any entity The time is embedded in In the vector space, the time information includes two scales: time point and time period. The time feature encoder is used to process information of different time scales: If the time information contained in a geographic entity is a time point, its modern standard time is used as Input; If the time information contained in a geographic entity is a time period, the dimensionality reduction method is used to reduce the two-dimensional time period into a one-dimensional time point. Input; For non-geographic entities in the geographic knowledge graph or geographic entities that lack time information, the time feature will be padded with a zero vector; Therefore, for any geographic entity in the geographic knowledge graph, the temporal feature encoder Geographic Entity The time information is encoded as , expressed as the following formula: in, Indicates a point in time, represents the time point after the time period is reduced in dimension, and ∈( ); The dimensionality reduction method includes head-end sampling, tail-end sampling and random sampling. The head-end sampling means using the start time of the time period to represent the time period, the tail-end sampling means using the end time of the time period to represent the time period, and the random sampling means randomly selecting a time point in the time period to represent the time period. After the time period is reduced in dimension, the time point encoding method is used to encode and represent the reduced time point. The entity encoder Entity Feature Encoder and temporal feature encoder , then in step S1, the entity encoder Any entity in the geographic knowledge graph Embed in It is expressed in a dimensional vector space as: Among them, [;] represents the concatenation of feature vectors, ; In step S2, for a given geographic knowledge graph , projection operator Perform link prediction operations to calculate entities and relationships in space to obtain prediction vectors. Depending on the input object, the projection operator is divided into two types: and ; The input processed is a triple header entity and relationship , predict the tail entity; Processing logical queries Basic graph query model in , is bounded by existential quantifiers vector embedding to predict The vector embedding of in, and is a trainable relationship matrix, and The functions of are feature embedding and time embedding respectively; In step S3, the intersection operator based on the self-attention mechanism is used From multiple Perform intersection operation on embedding to obtain query embedding A single target node in Embed , expressed as: The intersection operator uses the average value, minimum value and maximum value of the elements in the vector or the neural network structure with the invariant arrangement of Deep Sets; In step S4, the model training includes geographic knowledge graph The training phase and geographic knowledge graph question answering training; In the Geographic Knowledge Graph In the training phase, the data source for training is the structure of the geographic knowledge graph G itself. , any node : First, get the node from the triple of the geographic knowledge graph All first-degree neighbor nodes, from the negative sample set Sample n groups of negative samples , the model training strategy at this stage is to predict the node The embedding is closest to the positive sample Embedding, and stay away from negative sample sets Each negative sample in The embedding of the predicted node is as close to the positive sample as possible, and as far away from the negative sample as possible, thereby constructing the maximum boundary loss function: in Indicates the distance between calculated vectors; Question-answering in geographic knowledge graph The training data source is the manually constructed geographic knowledge graph question-answer pairs. ,for , any question-answer pair All follow the basic query subgraph pattern. The model training goal at this stage is to embed the correct answer node into the predicted embedding closest to the question and away from all negative sample sets. All negative samples in The embedding of the node, therefore, the training loss function at this stage adopts the following maximum boundary loss: 。 2. According to claim 1, a method for constructing an implicit reasoning model of a geographic knowledge graph taking into account time characteristics is characterized in that: In step S5, the evaluation indicators include the area under the ROC curve AUC and the average percentile ranking APR; The AUC measures the model's ability to distinguish between correct answers and random negative samples by calculating the ROC curve and finding the area under the curve; The APR measures the relative ranking of the correct answers given by the model across all queries by calculating the average percentile rank of the correct answers in the model's predictions.
Citation Information
Patent Citations
Geographic knowledge graph representation learning method of SubGNN injection spatial features
CN117688121A
Time knowledge graph completion method based on multi-strategy network
CN117910554A
Question and answer method for multi-granularity time sequence knowledge graph
CN118093956A
Knowledge graph embedding method based on knowledge distillation and pre-training model
CN118194972A
Evolution perception time sequence knowledge graph completion method based on message aggregation
CN118427364A
