Geographic knowledge graph link prediction method based on entity semantic similarity and clustering combined negative sampling
By combining entity semantic similarity and clustering technology, high-quality negative samples are dynamically generated, which solves the problem of the lack of semantic relationships in the generation of negative example triplets by random sampling methods, and significantly improves the expression ability and link prediction performance of geographical knowledge graphs.
Patent Information
- Application Number
- CN202410872124.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-07-01
AI Technical Summary
In the existing geographical knowledge graph representation learning, the negative example triplets generated by the random sampling method lack reasonable semantic relationships, resulting in low quality of negative example triplets and reducing the distinction ability of the knowledge graph embedding model.
Using a negative sampling method based on entity semantic similarity and clustering, the semantic information of geographic entity in triplets is extracted by constructing a geographic knowledge fusion device, and the negative samples are dynamically generated using the K-Means algorithm to ensure the negative example triplets. Semantic correlation.
It improves the expression ability and link prediction performance of geographical knowledge graphs, significantly improves the diversity and quality of negative samples, and enhances the semantic capture ability of the model.
Smart Images

Figure CN118966326A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of geographic knowledge graphs, and in particular to a geographic knowledge graph link prediction method based on negative sampling combined with entity semantic similarity and clustering. Background Art
[0002] In geographic information science, geographic knowledge is usually represented based on the characteristics of places and the relationships between places. With the development of big data and geographic intelligence, the generation of massive spatiotemporal information is accompanied by a higher degree of complexity and diversity, which in turn leads to the sparsity and incompleteness of geographic knowledge, posing new challenges to the representation of places. As an emerging large-scale structured knowledge modeling method, geographic knowledge graphs provide a new way to formally organize geographic knowledge, and the common form of expression is triples. The knowledge graph embedding representation model maps entities and relationships in the knowledge graph to a low-dimensional continuous numerical vector space. This representation method makes high-dimensional, sparse graph structured data more suitable for machine learning algorithm processing, and promotes tasks such as representation learning and link prediction.
[0003] Geographic knowledge graphs are organized in the form of triplets based only on known facts, that is, the dataset contains only positive samples, so it is necessary to generate negative samples corresponding to each positive sample in order to measure the model loss in the knowledge graph representation learning and training. Negative sampling is a key step in the knowledge graph embedding representation model. It generates negative example triplets to improve the model's ability to distinguish, so that the knowledge graph embedding model can better capture the semantic associations of entities and relationships.
[0004] The random sampling method is currently the most widely used method in geographic knowledge graph representation learning. Its core idea is to delete the head entity or the tail entity in the positive triple, and then uniformly randomly select an entity from the entity set to replace the deleted entity, thereby constructing a negative triple. However, the negative triples generated by the random sampling method are not ideal, because the replacement entity selected by the random sampling method often has no obvious association with another entity in the positive triple, which causes the generated negative triples to lack reasonable semantic relationships in the geographic knowledge graph, thereby reducing the quality of the negative triples. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a geographic knowledge graph link prediction method based on entity semantic similarity and clustering combined with negative sampling. The present invention creatively proposes how to extract triple data that conforms to the geographic knowledge tuple representation framework from the geographic vector map, and optimizes the TransE model to form a geographic knowledge graph embedded GKTransE model. The GKTransE model constructs a geographic knowledge aggregator, extracts the semantic information of geographic entities in the triples, completes the entity vector initialization of the model, and calls the K-Means algorithm in the negative sampling part to implement a dynamic negative sample generation strategy, effectively expanding the expression ability of the geographic knowledge graph.
[0006] The technical solution adopted by the present invention is:
[0007] The method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering includes the following steps:
[0008] Step 1: Propose a geographic knowledge tuple representation framework to achieve structured representation of geographic entities, their attributes, and relationships between entities;
[0009] Step 2: Obtain geographic vector maps, perform structured extraction of geographic data from the geographic vector maps through the ArcGIS platform, and import the geographic data into the Neo4j graph database. Export the geographic data in the form of triples and clean them up to obtain geographic triple data, also known as positive triples.
[0010] Step 3: Build a knowledge aggregator to extract the semantic information of geographic entities in triples and complete the entity vector initialization of the geographic knowledge graph embedded in the GKTransE model;
[0011] Step 4: Call the K-Means algorithm to divide the entity into multiple clusters according to the entity semantic information. During negative sampling, other entities in the same cluster as the replaced entity will be randomly selected as negative entities to construct negative example triples;
[0012] Step 5: Combine the knowledge aggregator and perform batch training on positive and negative triples to achieve vector update, thereby improving the expressive power of geographic knowledge graph embedding;
[0013] Step 6: Predict missing entities based on known entity information in the triples to complete the link prediction task in the geographic knowledge graph embedding GKTransE model. Specifically, predict the missing entity h for the triple (k, r, t); predict the missing entity t for the triple (h, r, k).
[0014] In step 1, the geographical knowledge tuple representation framework is as follows:
[0015] GKG1=(E,S,V)
[0016] GKG2=(E1,R,E2)
[0017] Among them: GKG1 = (E, S, V) represents the knowledge tuple expression model of geographic entities and their attributes; E represents the geographic entity; S represents the entity attribute; V represents the attribute value; GKG2 = (E1, R, E2) represents the knowledge tuple expression model of two different geographic entities, E1 represents the geographic head entity, E2 represents the geographic tail entity, and R represents the relationship between the two entities.
[0018] The step 2 comprises the following steps:
[0019] S21. Open the geographic vector map in the ArcGIS platform, represent the place name in the form of points or lines, and view the multiple attributes of the place name and its corresponding attribute values. Figure 6 As shown, a water system vector diagram is displayed;
[0020] S22. Calculate the distance relationship between points in the geographic vector map. The Euclidean distance between two points can be calculated and the corresponding threshold is given to determine the distance between the two points. The expression is:
[0021]
[0022] Among them, (x1, y1) and (x2, y2) represent the latitude and longitude coordinates of two place names respectively. According to the size of the Euclidean distance and multiple thresholds, the distance relationship is obtained, where the distance relationship includes: very close within the city, close within the city, very far within the city, very close between cities, close between cities, far between cities and very far between cities. Some of the data are shown in Table 1:
[0023] Table 1 Distance relationship data table
[0024] Beijing-Dongcheng District Beijing-Dongcheng District 0.0km Very close to the city Beijing-Dongcheng District Beijing-Xicheng District 4.62km Near the city Beijing-Dongcheng District Beijing-Fengtai District 17.4km Very far from the city Tianjin-Daxing District Langfang City-Guangyang District 15.16km Very close to the city Beijing-Dongcheng District Tianjin-Heping District 110.81km Intercity Beijing-Dongcheng District Xingtai City-Guangzong County 332.91km Intercity Changsha-Ningxiang Kunming City-Xishan District 1041.83km Very far from the city
[0025] Among them, taking the first row of data as an example, it can be constructed as follows: Beijing-Dongcheng District, Beijing-Dongcheng District, very close within the city, such a geographic triplet data about spatial relationship.
[0026] S23. According to the azimuth value between point A (x1, y1) and point B (x2, y2) in the geographic vector map, determine the azimuth relationship between the place names represented by the two points. There are 8 azimuth relationships, namely east, northeast, north, northwest, west, southwest, south and southeast. Figure 2 As shown. And the distance relationship and the orientation relationship together constitute the spatial relationship between entities;
[0027] Among them, the angle range for the north direction is 337.5-22.5, and the center angle is 0; the angle range for the northeast direction is 22.5-67.5, and the angle is 45, and the same applies to other directions.
[0028] delta_x=x2-x1
[0029] delta_y=y2-y1
[0030] angle=math.atan2(delta_y-delta_x)
[0031]
[0032] The above formula first calculates the difference between the longitude and latitude of the two points, represented by delta_x and delta_y respectively, then calculates the radians by calling the mathematical atan2 built-in function, and then converts the radians to degrees and ensures that the result is between 0 and 360 degrees.
[0033] directions = ["North", "Northeast", "East", "Southeast", "South", "Southwest", "West", "Northwest"]
[0034] index=int((bearing+22.5) / / 45)%8
[0035] According to directions[index], we can get the direction of point A at point B. Since the range of each direction is 48 degrees, to ensure that the angle can be correctly mapped to the direction, add an offset of 22.5 degrees so that the center angle of each direction falls in the middle of the range. Divide the adjusted angle by 45 and round it, which will map each 45-degree range to an integer between 0 and 7, and then use the modulus operation to get the index of the direction and determine the direction.
[0036] S24. Export the attribute information of each entity and the spatial information with other entities in a table, where each column in the table is an attribute relationship or a spatial relationship. Part of the data is shown in Table 2.
[0037] Table 2 Attribute relationship and relationship data table
[0038] Water body name County Code county Province City Code city South County Southeast County Qiaotang Reservoir 450422 Teng County Guangxi Zhuang Autonomous Region 450400 Wuzhou City Cenxi City Cenxi City Guijiang 451121 Shaoping County Guangxi Zhuang Autonomous Region 451100 Hezhou City Teng County Fangxiu District Qinglian Lake 441202 Duanzhou District Guangdong Province 441200 Zhaoqing City Gaoyao District Gaoyao District Cheung Chau Reservoir 450421 Cangwu County Guangxi Zhuang Autonomous Region 450400 Wuzhou City Longxu District Fengkai County
[0039] According to Table 2, we can know that Qiaotang Reservoir is located in Teng County. The code of Teng County is 450422. Teng County belongs to Wuzhou City, and Wuzhou City belongs to Guangxi Zhuang Autonomous Region. The south and southeast of Teng County are connected to Cenxi City.
[0040] S25. Call the Py2neo package to store the table in the graph database Neo4j, and then read the entities and relationships from the graph database Neo4j and convert them into geographic triple data. Figure 3 As shown, Figure 3 A Neo4j visualization of some of the data is shown in Figure 3 The left side shows the labels and relationship types corresponding to the entities, and the middle shows the graph formed by connecting multiple entities through relationships. Since there are many entities in the middle, in order to further display them, Figure 4 and Figure 5 , Figure 4 A visualization of the administrative regions where water entities are located is shown. Figure 5 A visualization of the location relationships of administrative districts is shown.
[0041] In step 3,
[0042] For the entities in the triple, call the FastText model to obtain the entity vector and complete the entity vector initialization;
[0043] For the relations in the triples, the FastText model is called to obtain the relation vector and complete the relation vector initialization.
[0044] In step 4, K objects are randomly selected from the N entity data sets as initial cluster centers, the distance from each entity point to the cluster center is calculated respectively, and they are assigned to the nearest cluster one by one. After all entities are assigned, the positions of the K cluster centers are updated.
[0045] Compare the K cluster centers calculated in the previous step with the current cluster center. If the cluster center changes, return to the step of calculating the distance from each entity point to the cluster center. Otherwise, output the clustering result.
[0046] Call the K-means algorithm to divide N entities into K clusters to minimize the Euclidean distance between each entity and the center of its cluster, expressed as:
[0047]
[0048] Among them, K represents the number of clusters, e represents the entity vector, c i represents the center vector of the i-th cluster, C i represents the aggregation of entity e in the i-th cluster, L2 is the second norm Euclidean distance;
[0049] In step 4, when the geographic knowledge graph embedding model GKTransE performs negative sampling operations, it randomly selects other entities in the cluster where the replaced entity is located as negative examples to generate negative triples. For example, a positive triple (Shijiazhuang City, located in the province, Hebei Province) in the constructed geographic triple data describes that the province where Shijiazhuang City is located is Hebei Province. When generating negative samples, we choose to replace the tail entity "Hebei Province" and use a random sampling method to uniformly extract an entity from the entity set. Assuming that the extracted entity is Shahe Reservoir, the type of the entity is water system, the resulting negative sample is not very reasonable (Shijiazhuang, located in the province, Shahe water system). On the contrary, if Henan Province is extracted, the generated negative sample is (Shijiazhuang City, located in the province, Henan Province). From the perspective of entity semantics, the similarity between Hebei Province and Henan Province is much higher than the similarity between Hebei Province and Shahe Reservoir.
[0050] The step 5 comprises the following steps:
[0051] S51, read the entity and relationship information in the constructed geographic triple data, call the knowledge fusion device to assign initial values to the entity tensor and the relationship tensor, and then perform L2 normalization on each row of the tensor;
[0052] S52. Batch training is used when training the GKTransE model. K-means partitioning is called in each training to divide the entities into multiple clusters. During negative sampling, the random function is called. If the value is less than 0.5, the head entity of the positive triple is replaced to generate a negative triple; otherwise, the tail entity is replaced.
[0053] S53. The GKTransE model calls the function to calculate the loss based on the tensors corresponding to the positive and negative triples, and then backpropagates the loss function, updates the parameters, and minimizes the loss function.
[0054] The GKTransE model training process algorithm is as follows:
[0055]
[0056]
[0057] The step 6 comprises the following steps:
[0058] S61, the missing entity h or t in the triple (h, r, t) in the test set is called the correct entity, and the other entities are called candidate entities. The candidate entities are used to replace the entity h or t in the test triple in turn to form a set of candidate triples;
[0059] S62. Calculate the score of each candidate triple and the correct triple through the scoring function; the GKTransE model adopts the translation principle of h+r≈t to embed entities and relations into the same vector space, so the scoring function is defined as:
[0060]
[0061] Here, f(h,r,t) represents the score of the triple (h,r,t), which is calculated by adding the head entity vector h to the relation vector r and subtracting the L1 norm of the tail entity vector t.
[0062] S63. Call the sorting function sort to record the order of the correct triples. According to the order values of the correct triples in each test set, calculate the GKTransE model evaluation index to give a quantitative analysis of the model performance.
[0063] Specifically, in the evaluation process of the link prediction task, for each test tuple x in the test set T i , replace the head entity with the remaining entities of the entity set in turn, and generate And calculate the score dist 2 , or replace the tail entity in turn to generate Calculate the score dist 3 ; The score ranking of the correct samples in all test samples after replacing the head entity And the score ranking of the correct samples in all test samples after replacing the tail entity It is defined as follows:
[0064]
[0065] Among them, Ⅱ(·) is the indicator function. If the condition is true, the function value is 1, otherwise it is 0; T represents the test set, x i represents the triples in the test set, Indicates replacement of x i Negative triples generated by the head entity, dist 2 (x i ) represents x calculated using the score function i The score, Indicates the score calculated using the score function Similarly, Indicates replacement of x i Negative triples generated by mid-tail entities.
[0066] The most commonly used evaluation indicators for knowledge graph embedding model performance are:
[0067] Mean Reciprocal Ranking (MRR), Mean Rank (MR), and Hits@n. The three indicators are defined as follows:
[0068]
[0069] Where T is the test triple set, i is the number of triple sets, is the link prediction ranking of the i-th triple generated by replacing the head entity, is the link prediction ranking of the ith triple generated by replacing the tail entity. MRR is the average of the last predicted positive example tuple score rankings in the test triple set. The larger the indicator value, the better, indicating that the ranking is consistent with the facts. MR is the average of the predicted positive example tuple score rankings. The smaller the indicator value, the better. The smaller the predicted value, the higher the model accuracy. Hits@n refers to the average proportion of triples ranked less than or equal to n in link prediction. The larger the Hit@n indicator, the better. It is most common for n to be 10.
[0070] The present invention provides a geographic knowledge graph link prediction method based on negative sampling combined with entity semantic similarity and clustering, and the technical effects are as follows:
[0071] 1) The present invention proposes how to extract triple data that conforms to the geographic knowledge tuple representation framework from the geographic vector map and construct a geographic triple data set;
[0072] 2) This paper proposes a knowledge aggregator to extract semantic information of entity and relationship data in geographic triples and complete the entity relationship vector initialization of the geographic knowledge graph embedding model GKTransE, thereby improving the expressiveness of the model;
[0073] 3) The present invention proposes a negative sampling method based on semantic similarity, and calls the K-Means algorithm in the negative sampling part, which can more accurately capture entities with similar semantics and effectively improve the diversity and quality of negative samples.
[0074] 4) The present invention introduces entity semantic information and integrates entity semantic information into the geographic knowledge graph embedding task for the first time. By utilizing the semantic features of entities, the expressive power of the geographic knowledge graph is effectively expanded, and significant performance improvement is achieved in the link prediction task. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The present invention will be further described below in conjunction with the accompanying drawings and examples;
[0076] Figure 1 The figure is a flow chart of the prediction method of the present invention.
[0077] Figure 2 This is a schematic diagram of the orientation relationship.
[0078] Figure 3 A visualization diagram for Neo4j.
[0079] Figure 4 Visualization of water system entities located in administrative areas
[0080] Figure 5 A visualization of the location relationship of administrative regions
[0081] Figure 6 This is a vector diagram of the water system. DETAILED DESCRIPTION
[0082] like Figure 1 As shown, the present invention provides a geographical knowledge graph link prediction method based on negative sampling combined with entity semantic similarity and clustering, comprising the following steps:
[0083] S1: Propose a geographic knowledge tuple representation framework to achieve structured representation of geographic entities, their attributes, and relationships between entities;
[0084] Specifically, the geographic knowledge tuple representation framework is mainly used to structure and represent geographic information in order to better store geographic data. Geographic entities are the basic components of geographic knowledge tuples. Common geographic entities include cities, roads, rivers, etc. Each geographic entity has a set of attribute information that describes the specific characteristics of the entity, such as name, coordinates, category, etc. Geographic relations describe the spatial relationship between geographic entities. Common geographic relations mainly include topological relations, directional relations, and distance relations. Therefore, the knowledge tuple representation framework considers two aspects, namely, the triple representation of geographic entities and their attributes and the triple representation of the relationship between entities.
[0085] Furthermore, the knowledge tuple representation framework describing geographic entities, their attributes, and the relationships between entities is as follows:
[0086] GKG1=(E,S,V)
[0087] GKG2=(E1,R,E2)
[0088] Among them, GKG1 = (E, S, V) represents the knowledge tuple expression model of geographic entities and their attributes, E represents the geographic entity, S represents the entity attribute, and V represents the attribute value. GKG2 = (E1, R, E2) represents the knowledge tuple expression model of two different geographic entities, E1 represents the geographic head entity, E2 represents the geographic tail entity, and R represents the relationship between the two entities.
[0089] S2: Obtain geographic vector maps, perform structured extraction of geographic data through the ArcGIS platform, import the data into the Neo4j graph database, export the data in the form of triples and clean them up to obtain geographic triple data;
[0090] Specifically, geographic vector maps are a commonly used data representation method in geographic information systems (GIS), which contain rich geographic information. Vector maps represent geographic entities and their attribute information by collecting shape points and lines. The spatial relationship between entities can be determined in ArcGIS.
[0091] As a preferred implementation method, step S2 is specifically as follows:
[0092] S21. Open the geographic vector map in ArcGIS, where the place names are represented by points, and view multiple attributes of the place names and their corresponding attribute values;
[0093] S22. Calculate the distance relationship between points in the geographic vector map. The Euclidean distance between two points can be calculated and the corresponding threshold is given to determine the distance between the two points. The expression is:
[0094]
[0095] Among them, (x1, y1) and (x2, y2) represent the longitude and latitude coordinates of two place names respectively. The distance relationship is obtained by comparing the size of the Euclidean distance with multiple thresholds;
[0096] S23, according to the azimuth values between the points in the vector map, determine the azimuth relationship between the place names represented by the two points, and combine the distance relationship and the azimuth relationship to form the spatial relationship between the entities;
[0097] S24, exporting the attribute information of each entity and the spatial information with other entities in a table, where each column in the table is an attribute relationship or a spatial relationship;
[0098] S25. Call the Py2neo package to store the table in the graph database Neo4j, and then read the nodes and relationships from the graph database and convert them into geographic triples.
[0099] S3: Build a knowledge aggregator to extract the semantic information of geographic entities in triples and complete the entity vector initialization of the geographic knowledge graph embedding model GKTransE;
[0100] Specifically, in the knowledge graph embedding model, the entity vectorization is initialized by calling the Embedding function, which accepts two hyperparameters: the number of entities and the length of the embedding vector, to generate a fixed-length vector for each entity. However, the pre-trained word embedding model learns richer representations through large-scale corpus, not only focusing on the surface meaning of entity vocabulary, but also deeply mining the rich semantic structures hidden in the language, giving the model a higher level of language understanding ability, which is crucial for the complex semantic relationships between entities in the knowledge graph.
[0101] Furthermore, the FastText model itself has low complexity, which speeds up training while maintaining high accuracy. At the same time, the model performs well in processing low-frequency generated word vectors, and effectively deals with the situation where the cleaned dataset still contains scattered entities.
[0102] As a preferred implementation method, step S3 is specifically as follows:
[0103] S31. For the entity in the triple, call the FastText model to obtain the entity vector and complete the entity vector initialization;
[0104] S32. For the relationship in the triple, call the FastText model to obtain the relationship vector and complete the relationship vector initialization.
[0105] S4: Call the K-Means algorithm to divide the entity into multiple clusters based on semantic information. During negative sampling, other entities in the same cluster as the replaced entity will be randomly selected as negative entities to construct negative example triplets.
[0106] As a preferred implementation method, step S4 is specifically as follows:
[0107] S41. Randomly select K objects from the N entity data sets as the initial cluster centers, calculate the distance from each entity point to the cluster center, and assign them to the nearest cluster one by one. After all entities are assigned, update the positions of the K cluster centers. Compare the K cluster centers calculated in the previous step with the current cluster center. If the cluster center changes, return to the step of calculating the distance from each entity point to the cluster center, otherwise output the clustering result.
[0108] The goal is to divide N entities into K clusters to minimize the Euclidean distance between each entity and the center of its cluster, expressed as:
[0109]
[0110] Among them, K represents the number of clusters, e represents the entity vector, c i represents the center vector of the i-th cluster, Ci represents the aggregation of entity e in the i-th cluster, L2 is the second norm Euclidean distance;
[0111] S42. When the geographic knowledge graph embedding model GKTransE performs negative sampling operations, it randomly selects other entities in the cluster where the replaced entity is located as negative examples to generate negative example triplets.
[0112] S5: By combining the knowledge fuser and performing batch training on positive and negative triples, vector updates are achieved to improve the expressiveness of knowledge graph embedding;
[0113] Specifically, given a geographic knowledge graph G = {(h,r,t)|(h,r,t)∈E×R×E}, where E = {e1,e2,…,e N} represents the entity set containing N entities in the geographic knowledge graph, R = {r1, r2, …, r M} represents a relation set containing M relations in the geographic knowledge graph, (h, r, t) represents a triple in the geographic knowledge graph, h is the head entity, r is the relation, and t is the tail entity. The GKTransE model uses the translation principle of h+r≈t to embed entities and relations into the same vector space, so the score function is defined as:
[0114]
[0115] Among them, f(h,r,t) represents the score of the triple (h,r,t). The score function evaluates the rationality of the triple by calculating the L1 norm of the head entity vector h plus the relationship vector r minus the tail entity vector t. If the score is smaller, it means that the triple is more reasonable. The optimization goal is to minimize the score of the positive triple and maximize the score of the negative triple. Therefore, the loss function can be obtained as:
[0116]
[0117] The above formula L represents the loss of the entire model, (h, r, t) represents the positive triple, (h′, r, t′) represents the negative triple, S is the set of positive triples, S - is a set of negative triples. Negative triples are obtained by replacing the head entity h or the tail entity t in the positive triple. γ represents a hyperparameter, which is used to set the minimum difference between the score of the positive triple and the score of the negative triple. At the same time, the Adam optimizer is used to update the parameters of the model during the training process.
[0118] Furthermore, the GKTransE algorithm first reads data from the dataset and defines some hyperparameters to input into the model, then calls the FastText model to initialize the entity and relationship vectors, and then regularizes the vectors to prevent overfitting. Batch processing is used in the loop part, and each time a number of triplets of size b are extracted from the dataset S for training, and then the K-Means algorithm is called to create an entity dictionary, associate the entity ID with the cluster label to which it belongs, generate negative example triplets by replacing other entities in the same cluster, and update the set. After the loop ends, the loss is calculated and the entity and relationship vectors are updated.
[0119] As a preferred implementation method, step S5 is specifically as follows:
[0120] S51, read the entity and relationship information in the data set, call the knowledge fusion device to assign initial values to the entity tensor and the relationship tensor, and then perform L2 normalization on each row of the tensor;
[0121] S52. Batch training is used when training the GKTransE model. K-means partitioning is called in each training to divide the entities into multiple clusters. When negative sampling is performed, the random function is called. If the value is less than 0.5, the head entity of the positive triple is replaced to generate a negative triple; otherwise, the tail entity is replaced;
[0122] S53. The model calls the function to calculate the model loss based on the tensors corresponding to the positive example triples and the negative example triples, and then backpropagates the loss function to update the model parameters and minimize the loss function.
[0123] S6: Predict missing entities based on known entity information in the triples to complete the link prediction task in the knowledge graph embedding model.
[0124] As a preferred implementation method, step S6 is specifically as follows:
[0125] S61. The missing entity h (or t) in the triple (h, r, t) in the test set is called the correct entity, and the other entities are called candidate entities. The candidate entities are used to replace the entity h or t in the test triple in turn to form a set of candidate triples;
[0126] S62. Calculate the scores of each candidate triple and the correct triple by using a score function.
[0127] S63. Call the sort function sort to record the order of the correct triples, and calculate the model evaluation index according to the order of the correct triples in each test set, so as to give a quantitative analysis of the model performance.
[0128] Specifically, in the evaluation process of the link prediction task, for each test tuple x in the test set Ti , replace the head entity with the remaining entities of the entity set in turn, and generate And calculate the score dist 2 , or replace the tail entity in turn to generate Calculate the score dist 3 ; The score ranking of the correct samples in all test samples after replacing the head entity And the score ranking of the correct samples in all test samples after replacing the tail entity It is defined as follows:
[0129]
[0130] Among them, Ⅱ(·) is the indicator function. If the condition is true, the function value is 1, otherwise it is 0.
[0131] The most commonly used evaluation indicators for the performance of knowledge graph embedding models are: Mean Reciprocal Ranking (MRR), Mean Rank (MR), and Hits@n, which are less than n rankings. The three indicators are defined as follows:
[0132]
[0133] Where T is the test triple set, i is the number of triple sets, is the link prediction ranking of the i-th triple generated by replacing the head entity, is the link prediction ranking of the ith triple generated by replacing the tail entity. MRR is the average of the last predicted positive example tuple score rankings in the test triple set. The larger the indicator value, the better, indicating that the ranking is consistent with the facts. MR is the average of the predicted positive example tuple score rankings. The smaller the indicator value, the better. The smaller the predicted value, the higher the model accuracy. Hits@n refers to the average proportion of triples ranked less than or equal to n in link prediction. The larger the Hit@n indicator, the better. It is most common for n to be 10.
Claims
1. A geographic knowledge graph link prediction method based on entity semantic similarity and clustering combined with negative sampling, characterized by The following steps are involved: Step 1: Propose a geographic knowledge tuple representation framework to achieve structured representation of geographic entities, their attributes, and relationships between entities; Step 2: Obtain a geographic vector map, perform structured extraction on the geographic data of the geographic vector map, import the geographic data into a graph database, export the geographic data in the form of triples and clean them up to obtain geographic triple data, also known as positive triples; Step 3: Build a knowledge aggregator to extract the semantic information of geographic entities in triples and complete the entity vector initialization of the geographic knowledge graph embedded in the GKTransE model; Step 4: Call the K-Means algorithm to divide the entity into multiple clusters according to the entity semantic information. During negative sampling, other entities in the same cluster as the replaced entity will be randomly selected as negative entities to construct negative example triples; Step 5: Combine the knowledge fuser and perform batch training on positive and negative triples; Step 6: Predict missing entities based on known entity information in the triples to complete the link prediction task in the geographic knowledge graph embedding GKTransE model.
2. According to claim 1, the method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering is characterized by: In step 1, the geographical knowledge tuple representation framework is as follows: GKG1=(E,S,V) GKG2=(E1,R,E2) Among them: GKG1 = (E, S, V) represents the knowledge tuple expression model of geographic entities and their attributes; E represents the geographic entity; S represents the entity attribute; V represents the attribute value; GKG2 = (E1, R, E2) represents the knowledge tuple expression model of two different geographic entities, E1 represents the geographic head entity, E2 represents the geographic tail entity, and R represents the relationship between the two entities.
3. According to claim 1, the method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering is characterized by: The step 2 comprises the following steps: S21. Open the geographic vector map in the ArcGIS platform, represent the place name in the form of points or lines, and view multiple attributes of the place name and its corresponding attribute values; S22. Calculate the distance relationship between points in the geographic vector map. By calculating the Euclidean distance between two points and giving a corresponding threshold, the distance between the two points can be judged. The expression is: Among them, (x1, y1) and (x2, y2) represent the latitude and longitude coordinates of two place names respectively. According to the size of the Euclidean distance, the distance relationship is compared with multiple thresholds to obtain the distance relationship, where the distance relationship includes: very close within the city, close within the city, very far within the city, very close between cities, close between cities, far between cities and very far between cities; S23. According to the azimuth value between point A (x1, y1) and point B (x2, y2) in the geographic vector map, determine the azimuth relationship between the place names represented by the two points; the azimuth relationship includes 8 types, namely east, northeast, north, northwest, west, southwest, south and southeast, and the distance relationship and the azimuth relationship together constitute the spatial relationship between the entities; S24, exporting the attribute information of each entity and the spatial information with other entities in a table, where each column in the table is an attribute relationship or a spatial relationship; S25. Call the Py2neo package to store the table in the graph database Neo4j, and then read the entities and relationships from the graph database Neo4j and convert them into geographic triple data.
4. According to claim 1, the method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering is characterized by: In step 3, For the entities in the triple, call the FastText model to obtain the entity vector and complete the entity vector initialization; For the relations in the triples, the FastText model is called to obtain the relation vector and complete the relation vector initialization.
5. According to claim 1, the method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering is characterized by: In step 4, K objects are randomly selected from the N entity data sets as initial cluster centers, the distance from each entity point to the cluster center is calculated respectively, and they are assigned to the nearest cluster one by one. After all entities are assigned, the positions of the K cluster centers are updated; Compare the K cluster centers calculated in the previous step with the current cluster center. If the cluster center changes, return to the step of calculating the distance from each entity point to the cluster center. Otherwise, output the clustering result. Call the K-means algorithm to divide N entities into K clusters to minimize the Euclidean distance between each entity and the center of its cluster, expressed as: Among them, K represents the number of clusters, e represents the entity vector, c i represents the center vector of the i-th cluster, C i represents the aggregation of entity e in the i-th cluster, and L2 is the second norm Euclidean distance.
6. According to claim 5, the method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering is characterized by: In step 4, when the geographic knowledge graph embedding model GKTransE performs a negative sampling operation, other entities in the cluster where the replaced entity is located are randomly selected as negative examples to generate negative example triplets.
7. The method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering according to claim 1, characterized in that: The step 5 comprises the following steps: S51, read the entity and relationship information in the constructed geographic triple data, call the knowledge fusion device to assign initial values to the entity tensor and relationship tensor, and then perform L on each row of the tensor. , Normalization; S52. Batch training is used when training the GKTransE model. K-means partitioning is called in each training to divide the entities into multiple clusters. During negative sampling, the random function is called. If the value is less than 0.5, the head entity of the positive triple is replaced to generate a negative triple; otherwise, the tail entity is replaced. S53. The GKTransE model calls the function to calculate the loss based on the tensors corresponding to the positive and negative triples, and then backpropagates the loss function, updates the parameters, and minimizes the loss function.
8. The method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering according to claim 1, characterized in that: The step 6 comprises the following steps: S61, the missing entity h or t in the triple (h, r, t) in the test set is called the correct entity, and the other entities are called candidate entities, and the candidate entities are used to replace the entity h or t in the test triple in turn to form a set of candidate triples; S62. Calculate the score of each candidate triple and the correct triple through the scoring function; the GKTransE model adopts the translation principle of h+r≈t to embed entities and relations into the same vector space, so the scoring function is defined as: Where f(h, r, t) represents the score of the triple (h, r, t), which is calculated by adding the head entity vector h to the relation vector r and subtracting the L1 norm of the tail entity vector t; S63, calling the sort function sort to record the order of the correct triples, and calculating the GKTransE model evaluation index according to the order value of the correct triples in each test set, so as to give a quantitative analysis of the model performance; Specifically, in the evaluation process of the link prediction task, for each test tuple x in the test set T i , replace the head entity with the remaining entities of the entity set in turn, and generate And calculate the score dist h , or replace the tail entity in turn to generate Calculate the score dist t ; The score ranking of the correct samples in all test samples after replacing the head entity And the score ranking of the correct samples in all test samples after replacing the tail entity It is defined as follows: Where II(·) is the indicator function. If the condition is true, the function value is 1, otherwise it is 0; T represents the test set, x i represents the triples in the test set, Indicates replacement of x i Negative triples generated by the head entity, dist h (x i ) represents x calculated using the score function i The score, Indicates the score calculated using the score function The score of Indicates replacement of x i Negative triples generated by middle-tail entities; 9. The method for link prediction of geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering according to claim 8, characterized in that: The evaluation indicators include: Mean Reciprocal Ranking (MRR), Mean Rank (MR), and Hits@n. The three indicators are defined as follows: Where T is the test triple set, i is the number of triple sets, is the link prediction ranking of the i-th triple generated by replacing the head entity, is the link prediction ranking of the i-th triple generated by replacing the tail entity; MRR is the average of the last predicted positive example tuple score ranking in the test triple set. The larger the indicator value, the better, indicating that the ranking is consistent with the facts; MR is the average of the predicted positive example tuple score ranking. The smaller the indicator value, the better. The smaller the prediction value, the higher the model accuracy; Hits@n refers to the average proportion of triples ranked less than or equal to n in link prediction. The larger the Hit@n indicator, the better.
Citation Information
Patent Citations
A knowledge map embedding method based on adaptive negative sampling
CN109376249A
Spatial relationship semantic analysis method based on knowledge graph
CN114564966A
Multi-source geographic information knowledge graph automatic construction method based on deep learning
CN115129894A
Interest point recommendation method based on knowledge graph and graph attention convolutional network
CN117349544A
