Recommendation system knowledge graph completion method and system based on relation perception negative sampling
By using a relation-aware negative sampling method and an adaptive curriculum learning controller, high-quality negative samples are generated, which solves the problems of unstable model training and poor recommendation performance in existing technologies, and achieves efficient training and improved recommendation quality in recommendation systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TIANJIN UNIV
- Filing Date
- 2025-12-05
- Publication Date
- 2026-04-24
AI Technical Summary
Existing static negative sampling methods struggle to automatically mine structural and semantic patterns and construct high-quality negative samples in recommendation systems without relying on external ontology constraints. Furthermore, they are difficult to implement progressive learning from easy to difficult during training, leading to unstable model training and poor recommendation performance.
A relation-aware negative sampling method is adopted to generate high-quality negative samples through linear weight decay and relation co-occurrence graph. An adaptive course learning controller is introduced to dynamically adjust the proportion of negative samples and train them in combination with knowledge graph embedding model or graph neural network.
It improves the model's generalization ability and training stability in scenarios with new users, new items, and new relationships, and enhances the accuracy and interpretability of the recommendation system, especially in cold start and inductive recommendation scenarios.
Smart Images

Figure CN121921081A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of recommender systems and knowledge graph representation learning technology, and proposes a method and system for knowledge graph completion in recommender systems based on relation-aware negative sampling. Background Technology
[0002] With the rapid growth of user and item scale in internet applications, recommender systems need to continuously provide high-quality personalized recommendations to users in an environment where user-item interactions are sparse and dynamically changing. In recent years, knowledge graphs have been widely introduced into recommender systems to improve the accuracy and interpretability of recommendation results, due to their ability to integrate user, item, and various auxiliary information and explicitly model rich semantic relationships.
[0003] In knowledge graph-based recommendation methods, the recommendation task is typically transformed into a link prediction task on the knowledge graph. Specifically, by using a knowledge graph embedding model or a graph neural network model, the triples (h,r,t) in the knowledge graph are encoded and scored to learn representations of entities and relations, thereby predicting potential interaction relationships between users and items during the inference stage.
[0004] In this type of training, negative sampling plays a crucial role: given a true triplet as a positive sample, several negative triplets need to be constructed so that the model can learn to distinguish between real and fabricated facts. The quality of negative sampling directly affects the model's training efficiency and final performance.
[0005] In existing technologies, the most common approach is uniform random negative sampling: randomly selecting an entity from the entity set of the knowledge graph to replace the head or tail entity, resulting in a negative triplet. However, in large-scale graphs, random sampling often produces a large number of "obviously false" negative samples. These negative samples have extremely low scores and contribute very little to the loss function, resulting in sparse gradient information and difficulty in effectively guiding model learning.
[0006] To improve the quality of negative samples, some methods introduce type constraints or utilize external ontology information to limit the candidate range of replacement entities. However, this usually requires manual maintenance of domain and value information and has poor adaptability to dynamically changing business scenarios.
[0007] On the other hand, existing research has shown that structural patterns (such as domain and value co-occurrence of relations) and semantic patterns (such as co-occurrence and similarity between relations) are crucial for constructing high-quality negative samples. Based on this, the Linear Weight Decay (L-WD) method generates structurally feasible but factually false negative samples by statistically analyzing the domain and value co-occurrence patterns of relations in the training data; the relation co-occurrence graph method, on the other hand, characterizes the semantic similarity of relations through co-occurrence information, mining difficult negative samples from semantically adjacent relations. However, most of these methods are still static strategies, meaning the negative sampling rules remain fixed throughout the training process.
[0008] In the context of recommendation systems, the training process often has the following characteristics: 1) The training phases are obvious: the model starts with initial random parameters and has no knowledge of graph structure and semantics. If a large number of hard negative samples are used at the beginning, it is easy to cause unstable optimization or even divergence. 2) Inductive and cold start scenarios are common: new users, new items and new relationships are constantly emerging. There are significant differences between the entity set and the relationship set in the training phase and the inference phase. The model needs to have the ability to generalize on unseen local structures and relationship patterns. 3) Recommendation metrics are more sensitive: For example, mean reciprocal ranking (MRR), hit rate (Hit@K), normalized depreciation cumulative gain (NDCG), etc., directly affect the online performance in recommendation business.
[0009] Therefore, existing static negative sampling methods struggle to achieve the following objectives simultaneously: On the one hand, it is necessary to automatically mine structural and semantic patterns from training data and construct high-quality negative samples without relying on external ontology; on the other hand, it is necessary to adaptively control the difficulty of negative samples according to the performance of the model at different training stages, so as to realize the learning process from easy to difficult, which not only ensures the stability in the early stage of training, but also gives full play to the advantages of structural and semantically difficult negative samples.
[0010] Based on the above problems, it is necessary to design an adaptive relation-aware negative sampling method for recommendation system scenarios, so that it can effectively serve the knowledge graph training task in recommendation systems without deviating from the original ARNS algorithm framework. Summary of the Invention
[0011] To address the problems existing in the prior art, the purpose of this invention is to provide a method and system for knowledge graph completion in recommendation systems based on relation-aware negative sampling.
[0012] In the training process of the recommendation model, this invention constructs three types of negative samples based on the target triplet: First, it uses the linear weight decay (L-WD) method to generate structurally feasible but factually false high-quality negative samples from the domain / value co-occurrence patterns of relations; second, it aggregates head / tail candidate entities from relations semantically similar to the target relation based on the relation co-occurrence graph to generate relation-aware semantic negative samples; and third, it uses uniform random sampling to generate basic random negative samples.
[0013] This invention introduces an adaptive curriculum learning controller that monitors changes in metrics such as the mean reciprocal rank (MRR) of the validation set. It dynamically adjusts the mixing ratio of the three types of negative samples based on the training phase, achieving a progressively increasing negative sampling curriculum from "easy" to "medium" to "difficult". The corresponding system includes a structural negative sample generation module, a relation co-occurrence graph negative sample generation module, an adaptive curriculum control module, a random negative sample generation module, a recommendation model training module, and a recommendation inference module. This invention improves the generalization ability and training stability of knowledge graph models in recommendation systems under inductive scenarios without relying on external ontology constraints, making it suitable for complex recommendation businesses where new users, new items, and new relationships constantly emerge.
[0014] The knowledge graph completion method for recommendation systems based on relation-aware negative sampling in this invention includes: In training tasks for inductive knowledge graph completeness or link prediction, a scoring function is constructed using a knowledge graph embedding model or a graph neural network model to output the authenticity score of any triple, and comparative learning training is performed based on observed triples as positive samples. For each positive triplet, a candidate negative sample set is generated, including the following three categories of negative samples: The structural negative sample generation step is based on linear weight decay. In this step, the co-occurrence information of each relation in the domain and value in the statistical training data is used to obtain the correlation degree result representing the structural compatibility between the entity and the relation. The head entity or tail entity in the positive sample is selected from the entities with high correlation degree to replace the head entity or tail entity in the positive sample. The structurally feasible but actually false negative triplet is constructed to form a set of structural negative samples. The relationship-aware negative sample generation step is based on the relationship co-occurrence graph. In this step, a relationship co-occurrence graph representing the co-occurrence strength between each relationship is constructed. According to the adjacency relationship of the target relationship in the relationship co-occurrence graph, the head entities and tail entities that appear frequently under several neighbor relationships with high co-occurrence with the target relationship are aggregated as candidate head entity set and candidate tail entity set. The relationship-aware negative sample set is constructed by replacing the head entity or tail entity in the target triple from the candidate set. The random negative sample generation step is based on uniform random sampling. In this step, entities are selected from the entity set using a uniform random strategy to replace the head or tail entity in the positive sample triplet, thereby obtaining a random negative sample set. Construct an adaptive course learning controller to dynamically combine the three types of negative sample sets, specifically including: The basic sampling ratios of the three types of negative samples are preset according to the training rounds, so that as the training rounds increase, the basic sampling ratios of structural negative samples and relation-aware negative samples gradually increase, while the basic sampling ratios of random negative samples gradually decrease. At the end of each training round, the average reciprocal ranking index is calculated on the validation set to obtain the performance change compared with the previous round, and an adaptive factor reflecting the performance change trend is calculated accordingly. The basic sampling ratio of the three types of negative samples is corrected using the adaptive factor to obtain the actual sampling ratio under the current training round, and the change of the sampling ratio is controlled in a smooth manner. During training, based on the actual sampling ratio corresponding to the current training round, a corresponding number of negative samples are sampled from the structured negative sample set, the relation-aware negative sample set, and the random negative sample set for each positive sample to form the final negative sample set, which is then used together with the positive samples to update the model parameters. The parameters of the scoring function are optimized by using an objective function based on marginal loss or cross-entropy loss, so that the score of the true triplet is higher than the score of the negative sample, thereby completing the training of the knowledge graph model in the recommendation system. The trained model is then used for link prediction or candidate generation in recommendation tasks to complete the knowledge graph.
[0015] Preferably, the knowledge graph training task in the recommendation system is an inductive knowledge graph completion task, and the knowledge graph used in the training phase and the knowledge graph used in the reasoning phase satisfy at least one of the following conditions in terms of entity set and / or relation set: (1) The entity sets of the two do not intersect; (2) The sets of relations between the two sets do not intersect; This enables cold start recommendation scenarios, including new users, new items, and new relationships.
[0016] Preferably, the entity set in the recommendation system includes at least user entities, item entities, session entities, context feature entities, tag entities, and category entities, and the relationship set includes at least user-item interaction relationships, user-tag relationships, item-tag relationships, item-category relationships, user-user similarity relationships, and item-item similarity relationships.
[0017] Preferably, in addition to using the average reciprocal ranking index, the adaptive factor can also be calculated in conjunction with recommendation indices such as hit rate and normalized loss cumulative gain in the recommendation system to comprehensively measure the performance changes during the training process, so as to further stabilize the course progress.
[0018] This invention also provides an item recommendation method, characterized in that, for a target user and its candidate items, the target user entity, each candidate item entity, and the corresponding relationship are constructed into a candidate triplet to be predicted, and this triplet is input into a trained scoring function. In the process, a score is obtained for each candidate triplet; the candidate items are sorted according to the scores to obtain a recommendation list.
[0019] This invention also provides an adaptive relation-aware negative sampling knowledge graph training system for recommendation systems, comprising: The scoring function construction module is used to construct scoring functions in inductive knowledge graph completeness or link prediction training tasks of recommendation systems. ;in, For the triples of the recommendation system, Indicates the head entity. Indicates a relationship. Indicates the tail entity. Represents a triplet The score is based on the true facts; The negative sample generation module is used to generate a candidate negative sample set for each positive sample triple in the recommendation system. The candidate negative sample set includes three types of negative samples: 1) structurally feasible but factually false structural negative samples generated from the domain / value co-occurrence patterns of relations using the linear weight decay (L-WD) method; 2) relation-aware semantic negative samples generated by aggregating head / tail candidate entities from relations semantically similar to the target relation based on the relation co-occurrence graph; and 3) random negative samples generated using uniform random sampling. The adaptive course learning control module is used to calculate the actual sampling ratio of each type of negative sample according to the training rounds and validation set performance indicators, following the adaptive course learning steps described above, and to mix the three types of negative samples. The recommendation model training module is used to train positive samples and mixed negative samples by comparing them using a knowledge graph embedding model or a graph neural network model, and output the trained recommendation model parameters. The completion module is used to apply the trained knowledge graph model to link prediction or candidate generation in recommendation tasks, thereby completing the knowledge graph.
[0020] The recommendation inference module is used in recommendation scenarios to score and rank the user-item or other target triplet to be predicted, thereby realizing item recommendation or related content recommendation.
[0021] The negative sample generation module includes a structured negative sample generation module, a relation-aware negative sample generation module, and a random negative sample generation module. The structural negative sample generation module is used to generate a set of structural negative samples based on the linear weight decay method, following the above structural negative sample generation steps, and utilizing the domain and value co-occurrence information of the relation. The relation-aware negative sample generation module is used to construct a relation co-occurrence graph and, following the relation-aware negative sample generation steps described above, aggregate candidate entities from neighboring relations that are semantically similar to the target relation to generate a relation-aware negative sample set. The random negative sample generation module is used to generate a random negative sample set from the entity set using a uniform random strategy, following the random negative sample generation steps described above. Preferably, the recommendation model training module adopts a graph neural network architecture to perform message passing and aggregation on local subgraphs, thereby updating the representations of user entities and item entities.
[0022] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is used to implement the steps of the above-described method.
[0023] The present invention also provides a server, characterized in that it includes a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the above-described methods.
[0024] The advantages of this invention are as follows: 1. This invention is based on the L-WD method to automatically mine domain / value co-occurrence patterns of relationships from training data. Without relying on external ontology constraints, it generates high-quality negative samples with reasonable structure but false facts, effectively improving the model's ability to distinguish structural patterns.
[0025] 2. This invention constructs a relation co-occurrence graph, uses the co-occurrence weights between relations to select semantic neighbor relations, aggregates candidate entities from it to generate relation-aware negative samples, so that negative samples are close to positive samples in the relation semantic space, thereby enhancing the model's ability to represent fine-grained semantic differences.
[0026] 3. This invention introduces an adaptive course learning controller, which automatically adjusts the mixing ratio of three types of negative samples by combining the training rounds and the performance changes of the validation set: in the early stage of training, random negative samples are used as the main sample to reduce the risk of training instability; in the later stage of training, the ratio of structural negative samples and relation-aware negative samples is gradually increased to fully explore the value of difficult negative samples and realize the course learning process from easy to difficult.
[0027] 4. This invention is particularly applicable to inductive and cold-start recommendation scenarios. Even when there are differences between the entity set and the relation set during the training and inference phases, it can still generalize through structural patterns and relation co-occurrence patterns, thereby maintaining high recommendation quality in complex recommendation environments where new users, new items, and new relations are constantly emerging.
[0028] 5. In typical inductive knowledge graph completion tasks and their recommendation system applications, the method of this invention can achieve significant improvements in evaluation metrics such as mean reciprocal ranking (MRR), hit rate (Hit@K), and normalized depreciation cumulative gain (NDCG), while the training process is more stable and the gradient utilization efficiency is higher. Attached Figure Description
[0029] Figure 1 This is the overall flowchart of the present invention. Detailed Implementation
[0030] The present invention will now be described in further detail with reference to the accompanying drawings. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.
[0031] The technical solution of this invention is summarized as follows.
[0032] 1. Scoring function and training task In this invention, for the knowledge graph training task in recommendation scenarios, a knowledge graph embedding model or a graph neural network model is used to construct a scoring function. in, Indicates the head entity. Indicates a relationship. Indicates the tail entity. Output the score for a triplet that is true.
[0033] Set of observed triples As a set of positive samples, for each positive sample Constructing a negative sample set through a negative sampling strategy The scoring function parameters are trained based on positive and negative samples.
[0034] 2. Construction of three types of negative samples For each positive sample This invention constructs the following three types of negative samples: 1) Random negative sample: Uniformly random sampling of entities from the entity set. Replace the head or tail entity to get Form a random negative sample set These negative samples are easy to generate and relatively easy to obtain, which helps the model quickly learn basic discrimination capabilities in the early stages of training.
[0035] 2) Structural Negative Samples: Based on the L-WD method, this involves mining domain and / or value co-occurrence patterns of relationships in the training data. This is achieved by constructing an entity-domain value matrix. Calculate the co-occurrence matrix of relations After normalization, the entity-relationship association matrix is obtained.
[0036] For a given relation ,matrix Zhongyu The entities with the highest relevance constitute a candidate entity set, which is used to replace the entities in the positive samples. or Generate a set of negative samples that are structurally feasible but do not appear in the real set of triples. .
[0037] 3) Relationship-aware negative samples: Constructing a relationship co-occurrence graph in For a set of relations, These are co-occurrence edges between relationships in space. Co-occurrence weights.
[0038] For a given relation According to weight Select the one with the highest co-occurrence weight. Each neighbor relationship forms a semantic neighbor relationship set. Then, candidate head entity sets are aggregated from the head and tail entities connected by these neighbor relationships, respectively. and candidate tail entity set By replacing with candidate entities or To obtain a set of relation-aware negative samples These negative samples are close to the target triples in the relational semantic space, providing more challenging contrast samples.
[0039] 3. Adaptive Course Learning Controller To avoid instability caused by introducing too many hard-to-bear samples in the early stages of training, and to fully utilize structurally hard-to-bear samples and relation-aware hard-to-bear samples in the later stages of training, this invention introduces an adaptive curriculum learning controller. This controller, in each training round... In the process, the mixing ratio of the three types of negative samples is dynamically adjusted based on the training progress and the performance on the validation set.
[0040] First, define the training rounds. Corresponding base sampling ratio: in, and Follow Increase and increase, Follow The increase and decrease are used to advance the course from "mainly random" to "mainly structured and relationally complex".
[0041] Then, after each round of training, the reciprocal rank metric is calculated on the validation set. And compare it with the results of the previous round to obtain the performance increment.
[0042] according to Constructing adaptive factors For example, when When the value is positive and greater than the set threshold, the base sampling ratio of structural negative samples and relation-aware negative samples will be increased to appropriately accelerate the course progress; when When the value is close to zero or negative, slow down the increase in the proportion of high-difficulty negative samples.
[0043] Finally, the actual sampling ratio is updated using an exponential moving average method: in, This is the momentum coefficient.
[0044] In training rounds In the process, for each positive sample, from... , , According to proportion Sample negative samples to form the final negative sample set.
[0045] 4. Training Objectives and Recommendation Reasoning This invention can employ either a loss function based on marginal loss or cross-entropy for training. Taking marginal loss as an example, for a given set of positive samples... and corresponding negative sample set , can be defined as: in, This is a marginal hyperparameter.
[0046] By minimizing the aforementioned loss function and optimizing the parameters of the scoring function, the scores of true triples are significantly higher than those of negative samples. After training, the resulting entity and relation representations, along with the scoring function, are used for link prediction, candidate generation, or ranking tasks in recommendation scenarios.
[0047] Example 1: Structural Negative Sample Generation Module Based on L-WD In this embodiment, for the knowledge graph training task in the recommender system, the specific steps of the negative sample generation module include: 1. Entity-Domain Value Matrix Construction Based on the domain and value information of each relation in the training data, construct an entity-domain value binary vector matrix. .matrix Each row corresponds to an entity, and each column corresponds to a field value or a combination of "relation-field / value". Matrix elements Indicates the first The entity in the first Whether it appears on a field value.
[0048] 2. Calculation of the co-occurrence matrix of relations Using matrices Calculate the co-occurrence matrix of relationships:
[0049] matrix elements Reflects the first The domain value and the first The number or intensity of co-occurrence of each domain value. For a matrix Normalize the data row by row so that the sum of the elements in each row is 1, thus obtaining the standardized co-occurrence intensity.
[0050] 3. Entity-Relationship Association Matrix Calculation pass Obtain the entity-relationship association score matrix .matrix Each row corresponds to an entity, each column corresponds to a relation or domain value dimension, and elements Representing entities With Relationship The strength of association on domain / value information.
[0051] 4. Construction of candidate entity set For the target triplet in training From the entity-relationship association matrix Selection and Relationship Entities with high association scores are divided into a candidate head entity set and a candidate tail entity set. They can be sorted according to their association scores, and the top few entities can be selected as candidates to control the size of the candidate set.
[0052] 5. Generation of structural negative samples Sample head or tail entities from the above candidate entity set, and then sample the head entities from the positive sample triples. or tail entity By performing the substitution, we obtain a structurally feasible but factually false negative triplet, for example... or The negative triples generated in this round of training are then categorized into the structural negative sample set. .
[0053] The L-WD structure negative samples generated through the above steps not only conform to the domain / value patterns summarized in the training data, but also do not appear in the observed triplet set. They can provide the model with contrasting samples that are "close to the truth" in structure but false in semantics, thereby enhancing the model's ability to learn structural patterns.
[0054] Example 2: Relationship-Aware Negative Sample Generation Module Based on Relationship Co-occurrence Graph In this embodiment, the process of the relation-aware negative sample generation module includes: 1. Construction of Relationship Co-occurrence Graph Construct a relation co-occurrence graph based on the co-occurrence of relations on the same entity pair in the training data.
[0055] in, For a set of relations, Let f(x) be the set of edges between relation pairs. When two relations coexist on some entity pairs, an edge is drawn between them. Let be the edge weight matrix, and let the edge weights be... Representing relations and The intensity of co-occurrence on the same entity pair.
[0056] 2. Semantic Neighbor Relationship Selection For the current target relationship Obtain its set of adjacency relations in the co-occurrence graph. And according to the border rights right Sort the relationships in descending order. Select the top co-occurrence weights. Each adjacency relationship forms a semantic neighbor relationship set. :
[0057] 3. Aggregation of candidate entity sets For each semantic neighbor relationship Collect the head entity set and tail entity set of this relation from the training data. Perform a union operation on the head entity sets of all semantic neighbor relations to obtain the current relation. Candidate Head Entity Set Perform a union operation on the tail entity sets of all semantic neighbor relationships to obtain the current relationship. Candidate tail entity set .
[0058] 4. Relationship-aware negative sample generation For the target triplet ,from or Entities are randomly sampled or selected according to a certain weighting strategy to replace the header entity. or tail entity Generate relation-aware negative sample triples or The negative samples generated in this round of training constitute the relation-aware negative sample set. .
[0059] The relation-aware negative samples generated through the above process are close to the target triples in the relation semantic space, enabling the model to learn more fine-grained semantic discrimination ability during training, which is beneficial for fine modeling of similar relations in recommendation tasks.
[0060] Example 3: Adaptive Curriculum Learning Control Module This embodiment illustrates how the adaptive course learning control module dynamically adjusts the proportion of three types of negative samples based on training progress.
[0061] 1. Setting the basic sampling ratio Suppose the training process consists of several rounds, and the current training round is denoted as . The baseline sampling ratios for the three classes of negative samples are predefined for each round of training: in, and This represents the basic proportion of structure-aware negative samples and relation-aware negative samples. This represents the base proportion of random negative samples. The base proportion is designed to be random. Increase , Monotonous rise, The monotonous decrease reflects the progression of the course from "easy samples" to "difficult samples".
[0062] 2. Performance Increment and Adaptive Factor Calculation In each round of training After completion, the reciprocal rank metric is calculated on the validation set. And compare it with the previous round of indicators to obtain the performance increment:
[0063] according to The size and sign of the adaptive factor are used to construct the adaptive factor. :when When it is large and positive, A larger value is chosen to speed up the course progress; when When it is close to zero or negative, The value is set to be relatively small to slow down the pace of the course and avoid introducing a large number of high-difficulty negative samples too early, which could cause training oscillations.
[0064] 3. Updated actual sampling ratio Based on adaptive factors and basic sampling ratio , , Update the actual sampling ratio for the current round using an exponential moving average: in, The momentum coefficient has a range of values of 1000. It is used to smooth out changes in proportions and avoid overly drastic fluctuations.
[0065] 4. Negative Sample Mixing and Training In training rounds In this process, for each positive sample, the negative sample set is structured separately. Relationship-aware negative sample set and random negative sample set In proportion Sample several negative samples and mix them to form the final negative sample set. Subsequently, the loss function is calculated using the positive and negative sample sets, and the model parameters are updated using gradient descent-like methods.
[0066] Through the aforementioned adaptive course learning control module, this invention can dynamically adjust the proportion of different types of negative samples based on the model's training progress and validation set performance. While ensuring training stability, it gradually increases the difficulty of negative samples, thereby improving the model's final performance in recommendation tasks.
[0067] Example 4: Training Process and Recommendation Inference This embodiment illustrates how to comprehensively utilize the above modules to complete the training and inference processes in a recommendation system.
[0068] 1. Training Phase Step S401: Initialize the scoring function The parameters, such as the embedding vector parameters of entities and relations, or the weight parameters in a graph neural network.
[0069] Step S402: In each training round In the process, the set of positive sample triples is traversed. For each positive sample... First, the structural negative sample generation module is called to obtain the structural negative sample set. The relation-aware negative sample generation module is called to obtain the relation-aware negative sample set. The random negative sample generation module is called to obtain a set of random negative samples. .
[0070] Step S403: Utilize the adaptive course learning control module to determine the actual sampling ratio for the current round. , , A certain number of negative samples are sampled from the above three sets to form the final negative sample set. .
[0071] Step S404: Perform forward computation on the positive samples and their corresponding negative samples to obtain the output value of the scoring function, calculate the training objective based on marginal loss or cross-entropy loss, and update the model parameters through backpropagation and gradient descent optimization methods.
[0072] Step S405: After each round of training, calculate metrics such as MRR on the validation set and submit them to the adaptive course learning control module to update the negative sample sampling ratio for the next round of training.
[0073] Repeat the above steps until the preset training rounds or convergence conditions are reached.
[0074] 2. Recommendation Reasoning Stage In the online recommendation phase, for a target user and its candidate items, the target user entity, each candidate item entity, and their corresponding relationships can be constructed as candidate triples to be predicted, which are then input into a trained scoring function. In this process, a score is obtained for each candidate triplet. The candidate items are then sorted according to their scores to obtain a recommended list.
[0075] For scenarios that require consideration of multiple relationships and contextual information, relevant auxiliary entities and relationships can be incorporated into the knowledge graph, and the trained model can perform unified modeling and reasoning.
[0076] Although specific embodiments of the invention have been disclosed for illustrative purposes to aid in understanding and implementing the invention, those skilled in the art will understand that various substitutions, variations, and modifications are possible without departing from the spirit and scope of the invention and the appended claims. Therefore, the invention should not be limited to the content disclosed in the preferred embodiments, and the scope of protection claimed by the invention is defined by the claims.
Claims
1. A knowledge graph completion method for recommendation systems based on relation-aware negative sampling, comprising the following steps: In the inductive knowledge graph completion or link prediction training tasks of recommendation systems, a scoring function is constructed. ;in, For the triples of the recommendation system, Indicates the head entity. Indicates a relationship. Indicates the tail entity. Represents a triplet The score is based on the true facts; For each positive sample triple in the recommendation system, a candidate negative sample set is generated. The candidate negative sample set includes three types of negative samples: 1) structurally feasible but factually false structural negative samples generated from the domain / value co-occurrence patterns of relations using the linear weight decay (L-WD) method; 2) relation-aware semantic negative samples generated by aggregating head / tail candidate entities from relations semantically similar to the target relation based on the relation co-occurrence graph; and 3) random negative samples generated using uniform random sampling. An adaptive course learning controller is constructed to dynamically combine the three types of negative samples in the candidate negative sample set to generate a negative sample set. The method is as follows: First, the basic sampling ratio of the three types of negative samples is preset according to the training rounds; then, as the training rounds increase, the basic sampling ratio of structural negative samples and relation-aware negative samples is gradually increased, while the basic sampling ratio of random negative samples is gradually decreased; sampling is performed from the corresponding structural negative sample set, relation-aware negative sample set, and random negative sample set according to the updated basic sampling ratio to obtain a dynamically updated negative sample set. The current set of negative samples and the set of positive samples are combined to form a training set. The knowledge graph model in the recommendation system is trained using the training set. At the end of each training round, the performance change of the trained knowledge graph model is detected using the validation set, and an adaptive factor reflecting the performance change trend is calculated accordingly. The basic sampling ratio of the three types of negative samples is corrected using the adaptive factor to obtain the actual sampling ratio under the current training round, and the change of the sampling ratio is controlled in a smooth manner. The parameters of the scoring function are optimized by using an objective function based on marginal loss or cross-entropy loss, so that the score of the true triplet is higher than the score of the negative sample, thereby completing the training of the knowledge graph model in the recommendation system. The trained knowledge graph model can be used for link prediction or candidate generation in recommendation tasks to complete the knowledge graph.
2. The method according to claim 1, characterized in that, The knowledge graph training task in the recommendation system is an inductive knowledge graph completion task. The knowledge graph used in the training phase and the knowledge graph used in the reasoning phase must satisfy at least one of the following conditions in terms of entity set and / or relation set: (1) the entity sets of the two are disjoint; (2) the relation sets of the two are disjoint.
3. The method according to claim 1, characterized in that, The entity set in the recommendation system includes at least user entities, item entities, session entities, context feature entities, tag entities, and category entities. The relationship set in the recommendation system includes at least user-item interaction relationships, user-tag relationships, item-tag relationships, item-category relationships, user-user similarity relationships, and item-item similarity relationships.
4. The method according to claim 1, 2, or 3, characterized in that, The method for generating structural negative samples is as follows: by statistically analyzing the co-occurrence information of each relation in the training data in terms of domain and value, the correlation degree result representing the structural compatibility between entities and relations is obtained. From the correlation result, one entity is selected from several entities with the highest correlation degree to replace the head entity or tail entity in the positive sample, constructing a structurally feasible but actually false negative triplet as a structural negative sample. The method for generating relation-aware negative samples is as follows: a relation co-occurrence graph representing the co-occurrence strength between relations is constructed. Based on the adjacency relationship of the target relation in the relation co-occurrence graph, the head entities and tail entities with high frequency of occurrence under several neighbor relations with high co-occurrence degree with the target relation are aggregated as candidate head entity set and candidate tail entity set. The relation-aware negative sample is constructed by replacing the head entity or tail entity in the target triplet from the candidate set. The method for generating random negative samples is as follows: entities are selected from the entity set using a uniform random strategy to replace the head entity or tail entity in the positive sample triplet to obtain random negative samples.
5. The method according to claim 1, 2, or 3, characterized in that, The method for constructing the adaptive factor is as follows: after each round of training, calculate the average reciprocal ranking index on the validation set. And compare it with the average bottom ranking indicator of the previous round. Comparison yields performance increments. Then according to Constructing adaptive factors ;when When the value is positive and greater than the set threshold, accelerate the increase in the base sampling ratio of structure-aware negative samples and relation-aware negative samples; when When the value is close to zero or negative, reduce the base sampling ratio of structural negative samples and relation-aware negative samples.
6. A method for recommending items, characterized in that, For a target user and its candidate items, the target user entity, each candidate item entity, and their corresponding relationships are constructed into candidate triples to be predicted, and these triples are input into the scoring function trained by the method described in claim 1. In the process, a score is obtained for each candidate triplet; the candidate items are sorted according to the scores to obtain a recommendation list.
7. A knowledge graph completion system for recommendation systems based on relation-aware negative sampling, characterized in that, include The scoring function construction module is used to construct scoring functions in inductive knowledge graph completeness or link prediction training tasks of recommendation systems. ;in, For the triples of the recommendation system, Indicates the head entity. Indicates a relationship. Indicates the tail entity. Represents a triplet The score is based on the true facts; The negative sample generation module is used to generate a candidate negative sample set for each positive sample triple in the recommendation system. The candidate negative sample set includes three types of negative samples: 1) structurally feasible but factually false structural negative samples generated from the domain / value co-occurrence patterns of relations using the linear weight decay (L-WD) method; 2) relation-aware semantic negative samples generated by aggregating head / tail candidate entities from relations semantically similar to the target relation based on the relation co-occurrence graph; and 3) random negative samples generated using uniform random sampling. The adaptive course learning control module is used to dynamically combine the three types of negative samples in the candidate negative sample set to generate a negative sample set. The method is as follows: First, the basic sampling ratio of the three types of negative samples is preset according to the training rounds; then, as the training rounds increase, the basic sampling ratio of structural negative samples and relation-aware negative samples is gradually increased, while the basic sampling ratio of random negative samples is gradually decreased; sampling is performed from the corresponding structural negative sample set, relation-aware negative sample set, and random negative sample set according to the updated basic sampling ratio to obtain a dynamically updated negative sample set. The recommendation model training module is used to combine the current negative sample set and positive sample set to form a training set. This training set is then used to train the knowledge graph model in the recommendation system. At the end of each training round, the performance changes of the trained knowledge graph model are detected using a validation set, and an adaptive factor reflecting the performance trend is calculated accordingly. This adaptive factor is used to correct the basic sampling ratio of the three types of negative samples to obtain the actual sampling ratio in the current training round, thus controlling the change in the sampling ratio smoothly. The parameters of the scoring function are optimized using an objective function based on marginal loss or cross-entropy loss, ensuring that the score of the true triplet is higher than the score of the negative sample, thereby completing the training of the knowledge graph model in the recommendation system. The completion module is used to apply the trained knowledge graph model to link prediction or candidate generation in recommendation tasks, thereby completing the knowledge graph.
8. The system according to claim 7, characterized in that, It also includes a recommendation reasoning module, which uses a trained scoring function to score and rank the user-item or other target triplet to be predicted in the recommendation scenario, thereby realizing item recommendation or related content recommendation.
9. A server, characterized in that, It includes a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the method of any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.