Atmogram recommendation method based on multi-hop path enhancement and adaptive graph structure optimization

Through the methods of multi-hop path enhancement and adaptive graph structure optimization, the entity-relationship path matrix is ​​constructed and the graph structure is optimized, which solves the data sparsity and cold start problems in the knowledge graph recommendation system and achieves more accurate and efficient personalized recommendations.

CN120632222AActive Publication Date: 2025-09-12HUAQIAO UNIVERSITY

Patent Information

Application Number
CN202511120114.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-12
Publication Date
2025-09-12
Estimated Expiration
2045-08-12

AI Technical Summary

Technical Problem

Existing recommendation systems based on knowledge graphs have deficiencies in graph structure integrity, semantic path modeling depth, and dynamic optimization capabilities. They are unable to effectively solve data sparsity and cold start problems, affecting the accuracy and robustness of recommendations.

Method used

The method of multi-hop path enhancement and adaptive graph structure optimization is adopted. By constructing an entity-relationship path matrix, dynamically adding pseudo edges and discarding low-frequency noise edges, and combining with a cross-attention aggregation network, the graph structure is optimized to improve the accuracy and efficiency of the recommendation model.

Benefits of technology

It significantly improves the accuracy and robustness of the recommendation system, can better capture user interests, alleviate data sparsity and cold start problems, and improve the accuracy and efficiency of recommendations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632222A_ABST
    Figure CN120632222A_ABST
Patent Text Reader

Abstract

The invention provides a graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization, and relates to the technical field of artificial intelligence, the method comprises the following steps: extracting user, entity and relation information from a recommendation data set to construct a knowledge graph, and initializing a corresponding embedded layer; constructing an entity-relation multi-hop path matrix to capture high-order semantic association; a positive and negative sample interaction table is generated in combination with user-article interaction records, and differentiated data is provided for model training; in the training stage, an adaptive graph structure optimization mechanism is introduced, a pseudo-edge extension graph structure is dynamically added by utilizing entity embedding similarity, a low-frequency noise edge is discarded in a probability mode, data sparsity is relieved, and robustness is improved, and in the prediction stage, an original graph structure is reserved to ensure reasoning efficiency; a cross attention convergence network is further designed, and a user-relation attention mechanism and multi-hop neighbor information are fused; by constructing a quaternary combination loss function, the generalization ability and convergence efficiency of the model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization. Background Art

[0002] With the explosive growth of information on the Internet, how to accurately capture users' personalized needs and push products or services that match their interests to them has become a core challenge in improving user experience and platform value. Traditional recommendation systems mainly rely on collaborative filtering technology, which is based on the assumption that "similar users prefer similar items" and constructs latent embedding representations through historical interaction data between users and items, and has achieved good results in multiple application scenarios. In recent years, with the introduction of deep learning technology, collaborative filtering methods have gradually integrated advanced models such as variational autoencoders, attention mechanisms, and graph neural networks, significantly improving recommendation accuracy. However, the interaction data between users and items is naturally sparse. Especially in cold start scenarios, it is difficult for the model to effectively learn the representation of users or items, which seriously restricts the improvement of recommendation performance.

[0003] To alleviate the problem of data sparsity, knowledge graphs, as structured semantic networks, are gradually being introduced into recommendation systems due to their powerful knowledge integration and association capabilities. By integrating user behavior data with the rich entity and relationship information in knowledge graphs, recommendation systems can leverage the high-order semantic connections between entities in the graph to explore users' potential interests, thereby improving the accuracy and interpretability of recommendations. For example, on e-commerce platforms, knowledge graphs not only contain product attribute information but also build deep connections between products and user preferences through relationship chains such as "brand-manufacturer-origin."

[0004] Although knowledge graphs have brought new development opportunities to recommendation systems, in practical applications, problems such as incompleteness, lack of structure, and sparse relationships in graph data are still prominent, which directly affects the recommendation effect. The current mainstream knowledge graph enhancement methods mainly include two categories: data generation and graph completion. On the one hand, generative models can mine potential entities and relationships based on existing graph patterns, such as generating new product associations through analogical reasoning; on the other hand, external knowledge fusion technology uses multi-source heterogeneous data such as encyclopedias and industry reports to complete entity attributes and relationships. However, these methods still have significant bottlenecks in terms of credibility verification of generated data, the complexity of multi-source information fusion, and the accuracy of long-tail relationship completion. In particular, when faced with complex semantic paths or long-tail entities, the graph completion effect is limited and it is difficult to meet the needs of high-order semantic reasoning.

[0005] Furthermore, existing knowledge graph-based recommendation methods primarily focus on extracting structured information from graphs, lacking dynamic optimization mechanisms for the graph structure itself. Redundant, low-frequency, or even erroneous edges in the graph can introduce noise, interfering with the model's ability to model user interests. Missing potential connections in the graph can also limit the model's in-depth understanding of user preferences. Therefore, dynamically adjusting the graph structure during training, while preserving high-value connections while removing noisy paths, is a key issue in improving the robustness and generalization capabilities of recommendation systems.

[0006] In summary, although existing technologies have attempted to alleviate the data sparsity and cold start problems in recommendation systems through knowledge graphs, there are still significant deficiencies in terms of graph structure integrity, semantic path modeling depth, and graph dynamic optimization capabilities. There is an urgent need for a recommendation method that can take into account both high-order semantic association mining and graph structure adaptive optimization to achieve more accurate, efficient, and robust personalized recommendations.

[0007] In view of this, this application is filed. Summary of the Invention

[0008] The present invention provides a graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization, which can at least partially improve the above problems.

[0009] To achieve the above object, the present invention adopts the following technical solutions: A graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization, comprising: Obtain an information dataset, extract user data, entity data, and relationship data from the information dataset, determine their quantity, initialize the user embedding layer, entity embedding layer, and relationship embedding layer, obtain the corresponding continuous embedding vector representation, and construct a knowledge graph adjacency dictionary; Based on the knowledge graph adjacency dictionary, a three-layer loop process is performed to traverse all entities, preset the number of paths and path lengths, and construct the entity-relationship path matrix; Based on the entity-relationship path matrix, construct positive sample interaction tables and negative sample interaction tables according to user data, entity data, and corresponding interaction records, and combine them to obtain a complete interaction table; Based on the complete interaction table, the recommendation model is trained and predicted by the adaptive graph structure optimization module. The training process includes pseudo-edge enhancement, and the prediction process includes original graph structure preservation. After the processing is completed, the relationship embedding vector and the user embedding vector are fused through the linear layer of the attention mechanism, the attention score is calculated, the score is converted into a weight, and the neighbor entity embedding vectors are weighted and summed according to the weight to obtain the final output.

[0010] In summary, the core of the method is to use the dual-wheel drive of "multi-hop path enhancement" and "adaptive graph structure optimization" to systematically alleviate the stubborn problems of data sparsity, cold start and long-tail coverage. First, the user-item interaction records and external knowledge are uniformly abstracted into a triple knowledge graph, and the entity-relationship multi-hop path matrix is ​​constructed through stratified sampling to explicitly model high-order semantic associations; then, in the training phase, the adaptive graph optimization strategy of "pseudo-edge addition + probabilistic edge discarding" is dynamically executed, and the entity embedding similarity is used to introduce credible pseudo-edges in the non-neighboring area, while randomly shielding the low-frequency noise edges, which not only expands the effective connection but also suppresses redundant interference. In the prediction phase, it falls back to the original graph structure to ensure inference efficiency. In order to accurately characterize user preferences, the solution further designs a cross-attention aggregation network to perform joint attention calculation on the user embedding and the relationship embedding of multi-hop neighbors, realizing personalized weight allocation and deep information fusion. At the model training level, a four-element combined objective function consisting of basic cross-entropy loss, label smoothing, embedding regularization, and BPR ranking loss is adopted, combined with a phased strategy of graph structure pre-optimization, main network training, and dynamic attenuation of edge drop rate, supplemented by an early stopping mechanism, to balance accuracy, robustness, and convergence speed.

[0011] In simple terms, the graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization provides structured and diverse data support for the model during the data preprocessing stage by constructing basic information of the knowledge graph, a multi-hop path matrix, an interaction table, and negative samples. In the construction of the core modules, the adaptive graph structure optimization module uses pseudo-edges to expand the graph during training to alleviate data sparsity, and retains the original structure during prediction to ensure efficiency; the multi-hop path dynamic enhancement module filters noise through dynamic path discarding, improving the model's ability to capture effective information; the cross-attention aggregation network module focuses on user preferences and deeply integrates multi-hop neighbor information to achieve personalized and accurate recommendations. In the model training and optimization stage, the combination of quaternion loss functions and gradient optimization strategies ensures the balance and improvement of the model's performance in multiple aspects such as accuracy and generalization. It is particularly suitable for solving data sparsity and cold start problems, capturing high-order semantic associations through multi-hop path relationship propagation, and using a dynamic graph structure optimization mechanism to improve recommendation accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 1 is a flow chart of a graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization provided by an embodiment of the present invention; Figure 2 Schematic diagram of a framework of a graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization provided by an embodiment of the present invention; Figure 3 This is a schematic diagram of the edge discard process provided by an embodiment of the present invention; Figure 4This is a schematic diagram of the process of adding pseudo edges provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0013] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0014] refer to Figures 1 - 4 As shown, the first embodiment of the present invention discloses a graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization, which can be executed by a graph recommendation device based on multi-hop path enhancement and adaptive graph structure optimization (hereinafter referred to as a graph recommendation device), and in particular, executed by one or more processors in the graph recommendation device to implement the following method: S1: Obtain an information dataset (taking a common recommendation system dataset as an example), extract user data, entity data (also called items), and relationship data from the information dataset, determine their quantity, initialize the user embedding layer, entity embedding layer, and relationship embedding layer, obtain the corresponding continuous embedding vector representation, and construct a knowledge graph adjacency dictionary; Specifically, step S1 further includes: extracting user data, entity data and relationship data from the information data set, and traversing the information data set to count the number of users , number of entities and the number of relationships ,wherein, the information data set includes: a user ID set, an entity ID set, and a relationship data set embodied by the user-item interaction records; User embedding layer by ID , entity embedding layer and relation embedding layer Initialize and map the discrete user ID data, entity ID data, and relationship ID data into low-dimensional continuous embedding vector representations with a dimension of d; Among them, for the user ID set , user embedding layer The mathematical expression is , for the entity ID set , entity embedding layer The mathematical expression is , for relational data sets , relation embedding layer The mathematical expression is , For users The embedding vector of For Entity Embedded vector, For the relationship Embedded vector, is the set of all d-dimensional real vectors; Traverse each triple in the information dataset , build a knowledge graph adjacency dictionary , the graph structure information is stored in the form of triples, where h is the head entity ID, t is the tail entity ID, and r is the relationship ID; For each head entity ID, its corresponding tail entity ID and relationship ID are added to the knowledge graph adjacency dictionary Under the corresponding header entity list in , the formula is For each tail entity ID, add its corresponding head entity ID and relationship ID to the knowledge graph adjacency dictionary Under the corresponding tail entity list in , the formula is , is the list of neighbor entities and relationships corresponding to the head entity IDh in the knowledge graph adjacency dictionary, It is the list of neighbor entities and relationships corresponding to the tail entity IDt in the knowledge graph adjacency dictionary.

[0015] In this embodiment, all records are first sequentially pulled from this type of information dataset, and then parsed line by line to extract user IDs, item IDs (corresponding to entities in the knowledge graph), and the various relationship IDs implied by the various behaviors between them. Simultaneously, the total number of users, items (i.e., entities), and relationship types is cumulatively calculated in real time, laying the dimensional foundation for subsequent tensor pre-allocation and embedding layer initialization. After obtaining the precise scale of these three, the system calls a unified initializer to randomly generate a low-dimensional continuous vector of dimension d for each user ID, entity ID, and relationship ID. This mapping process is completed in one go, transforming the original high-dimensional sparse representation into a dense, learnable embedding, providing the basic vector representation for subsequent model calculations, significantly reducing storage overhead and improving the efficiency of subsequent matrix operations.

[0016] Then, at the same time, in order to facilitate the subsequent rapid query of the relationship between entities, the information data set is scanned again in sequence in units of triples to build a directly addressable knowledge graph adjacency dictionary; for each triple, not only the tail entity and relationship are appended to the list with the head entity as the key, but also the head entity and relationship are appended to the list with the tail entity as the key, forming a bidirectional index. The dictionary resides in the memory and is compactly arranged in the form of a linked list or continuous memory block, so that the subsequent model can locate all the first-order neighbors of any entity and their corresponding relationships in time at any time, providing millisecond-level high-speed access capabilities for subsequent multi-hop path sampling, pseudo-edge expansion and attention aggregation. Through this initialization-construction Figure OneThrough the integrated process, discrete raw data is efficiently converted into a differentiable and scalable graph structure representation, which not only ensures the full mining of high-order relationships in the training phase, but also takes into account the low-latency requirements of online reasoning, thus laying the foundation for the accuracy and performance of the entire knowledge graph recommendation framework at the source.

[0017] S2, based on the knowledge graph adjacency dictionary, performs three-layer loop processing, traverses all entities, presets the number of paths and path lengths, and constructs the entity-relationship path matrix; Specifically, step S2 further includes: based on the knowledge graph adjacency dictionary, determining three key parameters, namely the number of entities , preset number of paths num_paths , and path length path_length , and create two three-dimensional arrays path_entities and path_relations , where the array Used to store entity ID, array Used to store relationship IDs. The initial values ​​of relationship IDs and array elements are both 0. Perform three-layer loop processing based on three key parameters, randomly select the next entity and its corresponding relationship from the neighbor nodes of the current entity, and store them in the array path_entities and path_relations To update the three-dimensional array path_entities and path_relations The data in the,entity-relationship path matrix is ​​constructed, and the three-layer loop processing includes,entity loop, path loop and path length loop.

[0018] Perform three-layer loop processing based on three key parameters to update the three-dimensional array path_entities and path_ relations The data in the ,construct the entity-relationship path matrix, specifically: The entity loop is the outer loop, and its steps include: traversing all entities, whose indexes are marked as , ,For each entity, multiple paths starting from the entity are generated; The path loop is a middle-level loop, which includes the following steps: determining the number of paths generated by each entity, whose index is marked as , ,For each path of each entity, the path nodes and relationships are sampled independently; The path length loop is the inner loop, and its steps include: determining each step of the path, whose index is marked as , , at the start of the path At, the current entity amplitude is added to the array and from Initially, at each step, determine whether there is a neighbor entity; If so, from the array Randomly select a neighbor entity from the neighbor node set next_entity and their corresponding relationships next_relation , according to the formula , Update the array; If not, fill the entity to the subsequent position of the path, and set the corresponding relationship with the time array to 0. The formula is: , ; After all loops are processed, the array path_entities and path_relations Convert it into a PyTorch tensor, form a structured multi-hop path representation based on the tensor, and construct the entity-relationship path matrix.

[0019] In this example, a stratified sampling algorithm is used to construct an entity-relationship path matrix through the path construction function. The stratified sampling algorithm is implemented through the construct_path_adj function to capture the multi-hop relationships between entities in the knowledge graph, providing a data foundation for subsequent recommendation models to mine high-order semantic associations.

[0020] Read the total number of entities, the number of preset paths, and the semantic depth expected to be captured, and then continuously open two three-dimensional arrays path_entities (dimension: number of entities) in the video memory or main memory. Number of paths The initial values ​​of path_length and path_relations (of the same dimension) are all set to zero, which not only facilitates subsequent vectorized calculations but also avoids time jitter caused by dynamic expansion.

[0021] Then, three nested loops are started: the outermost layer traverses all entities in the order of their entity index to ensure that no entity is missed; the middle layer initiates multiple independent random walks for each entity, thereby providing a multi-angle, redundant contextual description of the same entity in a single training iteration; the innermost layer gradually extends along each path, with the number of steps strictly limited by a preset value. At each extension step, all neighbors of the current entity are instantly located through the adjacency dictionary. If the neighbors are not empty, the next entity and its corresponding relationship are extracted in a uniformly random manner and written to the array immediately; if the entity unfortunately becomes an isolated node, the entity itself is looped back and the relationship is set to 0, thus ensuring that the tensor shape is constant and that subsequent GPU kernels do not require additional branch judgment. When all three loops are completed, the two three-dimensional arrays are converted to PyTorch FloatTensor on-site and directly bound to the GPU for subsequent calculations, eliminating additional memory copies and greatly reducing I / O bottlenecks. The entity-relationship path matrix obtained in this way not only fully records the multi-hop semantic trajectory starting from any entity, but also naturally has a data enhancement effect through random sampling, enabling subsequent graph neural networks to perceive richer high-order associations without increasing the labeling cost; at the same time, the structured tensor representation allows the framework to fully utilize the parallelism of CUDA during the training phase, completing batch path aggregation at millisecond speeds, significantly shortening the overall training cycle and improving the real-time response capability of online reasoning.

[0022] For entities without neighbors, it fills in the path with itself to ensure the integrity of the path, thus forming a structured multi-hop path representation and laying the foundation for subsequent analysis of complex relationships between entities. These two tensors constitute a structured multi-hop path representation, clearly recording the multiple path information for each entity, laying the foundation for the model to perform semantic reasoning and recommendation calculations based on path relationships. Subsequent operations such as adding pseudo-edges and discarding edges further enhance the effectiveness of the path, filter out noisy paths, and make the path information more consistent with user needs and entity semantic associations, thus laying a solid foundation for the recommendation model to deeply explore the potential connection between user interests and item characteristics.

[0023] S3, based on the entity-relationship path matrix, constructs positive sample interaction tables and negative sample interaction tables according to user data, entity data, and corresponding interaction records, and combines them to obtain a complete interaction table; Specifically, step S3 further includes: using The function constructs a positive sample interaction table, specifically: obtains the user ID set, entity ID set and corresponding interaction records, and defines an offset offset , whose value is , this offset is used to combine the user ID data and the entity ID into a unique key; Based on the offset, each set of user ID data and entity ID data is calculated to generate the positive sample composite key value , and combine the positive sample key value with the interaction label y to form a positive sample key value pair ,in, is the ith user ID data, is the j-th entity ID data. In the positive sample, y=1, indicating that there is interaction between the user and the item; Construct a positive sample interaction table and store all key-value pairs of positive samples in the positive sample interaction table The formula is , A collection of interaction records between users and entities; use The function randomly generates negative samples, where the number of negative samples and the number of positive samples The same is as follows: randomly select user ID data and entity ID data in a loop and calculate the negative sample combination key , For the User ID data, For the entity ID data, and determine whether the negative sample combination key exists in the list; If not, combine the negative sample key with the interaction label y to form a negative sample key-value pair ,In the positive sample, y=0, indicating that there is no interaction between the user and the item; Construct a negative sample interaction table and store all the key-value pairs of negative samples in the negative sample interaction table of the knowledge graph adjacency dictionary The formula is: ; Merged positive sample interaction table and negative sample interaction table , get the complete interaction table ,Among them, the complete interaction table covers the positive and negative interaction information,between users and entities.

[0024] In this example, user-item interaction information is extracted from a dataset. Positive samples are constructed by extracting items with which users have actually interacted, and negative samples are randomly generated from items with which users have not interacted. This provides positive and negative sample data for model training, which is used to learn the associations between users and items. The goal is to provide balanced and highly discriminative training signals for subsequent ranking models with zero additional annotation cost.

[0025] During implementation, user-item interaction data is first read from the dataset. To losslessly map any user-entity interaction to a unique integer key, an offset is introduced to compress the two-dimensional index into a one-dimensional one. This avoids string concatenation overhead while inherently ensuring key-value uniqueness. For each real interaction, a positive key-value pair is generated and stored, where label 1 explicitly informs the model that the user has performed a positive action on this entity. Once all positive examples have been written, their number is counted and a negative sampling loop is initiated: each time, a user or entity is randomly sampled and a candidate key is calculated. If a candidate key does not appear in the positive sample table, it is immediately written to the negative sample table. This loop continues until the number of negative examples equals the number of positive examples. Finally, the table is concatenated with the sequence to obtain a complete interaction table covering all positive and negative interactions. This strict balance between the number of positive and negative examples ensures a more stable gradient distribution during model training, effectively mitigating the risk of overfitting caused by class imbalance. Furthermore, the key-value sharing mechanism enables subsequent sampling, shuffling, and batch splitting to be performed using simple integer slicing, significantly improving GPU utilization and training throughput.

[0026] The complete interaction table covers the positive and negative interaction information between users and items, providing rich and discriminative data for subsequent model training, enabling the model to effectively learn users' interests and preferences as well as the characteristics of items, thereby achieving accurate recommendations.

[0027] S4, based on the complete interaction table, the recommendation model is trained and predicted by the adaptive graph structure optimization module, wherein the training process includes pseudo-edge enhancement and the prediction process includes original graph structure preservation. Specifically, step S4 further includes: using the complete interaction table as positive and negative sample data for model training, using The function calculates the similarity between entities, where the entity embedding vector matrix is , normalize it and get the normalized embedding vector matrix , the normalized formula is: , is the normalized entity embedding vector matrix Rank Elements of the column, is the corresponding element of the original matrix, It is the entity embedding vector matrix, which is used to store the low-dimensional continuous embedding vectors of all entities. Each row of the matrix corresponds to the embedding vector of an entity. It is the result of mapping the discrete entity ID into a computable continuous vector. is the total number of knowledge graph entities, is the dimension of the entity embedding vector, The square of the embedding value of the a-th entity in the entity embedding matrix E in the K-th dimension, which is used to calculate the L2 norm of the entity embedding vector (the denominator during normalization); Calculate entity similarity matrix , the formula is: , is the entity similarity matrix, which is used to measure the similarity between any two entities. is transposed; The normalized matrix is ​​masked, where when the jth entity is judged There is a set of neighbor entities in the knowledge graph adjacency dictionary When , let the elements of the entity similarity matrix be is the minimum value, and its formula is: ; Select the preset number of entities with the highest similarity from the masked entity similarity matrix row by row fake_edge_num The entity index is stored in the array fake_edges_cache The formula is: ,in, Indicates selecting the index corresponding to the first u maximum values ​​from the vector; exist get_neighbors In the function, based on the array fake_edges_cach , add a pseudo edge to each entity edge, where for a specific entity , from the array fake_edges_cache [ ] to get the entity set corresponding to the edge , and create the corresponding pseudo-relationship ID set , It is the preset pseudo relation ID; The entities and relationships corresponding to these pseudo edges are spliced ​​with the original one-hop neighbor entities and relationships to expand the knowledge graph structure.

[0028] Introducing a probabilistic edge discarding mechanism to remove noise edges that interfere with the learning of the recommendation model. get_neighbors When the function obtains neighbor nodes, it calls the edge discard function to filter the paths based on user preferences; The formula for processing the relationship ID is: , , using the embedding vector of the effective relationship relations_ embs Combined with user embedding vector user_emb Calculating user-relationship scores ,in, is the path dimension, To represent the element value of the relation embedding vector corresponding to the w-th path in the effective relation embedding matrix on the d-th dimension, is the element value of the user embedding vector in the dth dimension, is the validity mask, is the original input relation ID set, It is a relation embedding layer, a module for mapping discrete relation IDs into low-dimensional continuous embedding vectors. is the number of embeddings in the relation embedding layer, It is the security relationship ID after validity screening; Transform the user-relationship score to obtain , combined with the preset drop probability drop_rate Calculate path retention probability , where, during the training process, the retention mask is generated using the Bernoulli distribution , during the prediction processing stage, the mask will be retained Set to all True to keep all paths; exist aggregate In the function, according to the retention mask To neighbor entities neighbor_ents and relationships neighbor_rels Filter according to the rules , to update.

[0029] In this embodiment, step S4 aims to solve the data sparsity problem by dynamically adjusting the knowledge graph structure, and improve the reasoning efficiency in the prediction stage while ensuring the model training effect. This process is mainly divided into pseudo-edge enhancement in the training stage and retention of the original graph structure in the prediction stage. In the training stage, the dual strategy of edge discarding and pseudo-edge addition is implemented through the adaptive graph structure optimization module. First, the similarity matrix is ​​calculated using the normalized embedding vector of the entity. After shielding itself and the real neighbor relationship, the entities with high similarity are selected as pseudo-edge connection objects, stored, and the pseudo-edge addition operation is completed; at the same time, a probabilistic edge discarding mechanism is introduced to randomly discard low-frequency connection edges in the original graph with a certain probability to reduce redundant relationship interference. Pseudo-edges are added to each entity based on the pseudo-edge cache, and the knowledge graph structure is dynamically expanded to effectively alleviate the data sparsity problem. In the prediction stage, the original graph structure is retained to avoid additional computing overhead and ensure reasoning efficiency.

[0030] Specifically, the adaptive graph structure optimization process begins by calculating a similarity matrix using the normalized entity embedding vectors. After obtaining the similarity matrix, a masking operation is performed to avoid "connecting itself" or duplicating existing edges, that is, to avoid selecting existing connected neighbors as pseudo-edges. The index of the most similar entity is taken row by row and written into an array. This array resides in video memory and can be directly indexed. The entities and relationships corresponding to these pseudo-edges are then concatenated with the original one-hop neighboring entities and relationships, expanding the knowledge graph structure and effectively alleviating data sparsity.

[0031] At the same time, a probabilistic edge drop mechanism is enabled. Dynamic edge drop is used to further optimize the graph structure. To ensure the validity of relationship IDs, they are processed according to a preset formula to calculate user-relationship scores. To increase the probability of dropping low-scoring relationships, the scores are transformed, and a retention mask is generated using a Bernoulli distribution. During the prediction phase, the original graph structure is preserved to avoid additional computational overhead and ensure inference efficiency. This series of operations, including sampling multiple paths, adding pseudo edges, and dropping edges, achieves dynamic enhancement of multiple paths, enriching path information while filtering out noisy paths. This lays a solid foundation for subsequent models to accurately mine semantic associations between users and items, improving recommendation performance.

[0032] S5, after the processing is completed, the relationship embedding vector and the user embedding vector are fused through the linear layer of the attention mechanism, the attention score is calculated, the score is converted into a weight, and the neighbor entity embedding vector is weighted and summed according to the weight to obtain the final output.

[0033] Specifically, step S5 further includes: after the training process and prediction process are completed, obtaining the original item embedding item_emb and one-hop neighbor entities neighbor_ents and relationships neighbor_rels , for neighbor entities neighbor_ ents and relationships neighbor_rels Perform filtering to obtain safe neighbor entity embedding based on valid masks neighbor_ent_emb and relation embedding neighbor_rel_emb ; User embedding vector user_embeddings Expand it so that its dimension matches the neighbor relationship embedding to form a vector user_embeded , whose dimensions are [ batch_size, num_paths, emb_dim ]; Constructing attention input attention_input , the expanded user vector user_embeded Embedding with neighbor relations neighbor_rel_emb Splice and get the dimension Tensor ; use attention_layer Linear layer on tensor Calculate and get the attention score , whose dimensions are [ batch_size, num_paths ], It is a tensor operation function, which means removing the dimension of the tensor; The fraction corresponding to the invalid relationship is set to negative infinity, and the formula is: , and use the softmax function to convert the attention score into the attention weight ; Perform multi-hop information fusion based on the calculated attention weights , embedding neighbor entities neighbor_ent_emb Perform weighted summation to obtain the aggregated result tensor ; Configuration-based aggregator_class Parameters, embed the original item item_emb with the aggregation result tensor The combination is performed by addition, and the formula is: ; Through the linear layer self.linear_layers[0] Combined results Transformed and processed by Tanh activation function to obtain the final output output .

[0034] In this embodiment, a user-relation attention mechanism is designed in the aggregate function. The linear layer of the attention mechanism fuses the relationship embedding vector and the user embedding vector, calculates the attention score, sets the invalid relationship score to negative infinity, and then uses The function is converted into attention weights. The neighbor entity embedding vectors are weighted and summed according to the weights to achieve dynamic fusion and focus on user preferences, so that the model can give different attention levels to different neighbor entities and relationships according to user interests, thereby improving the personalization of recommendations. At the same time, the one-hop and two-hop neighbor information are integrated, and the neighbor labels are weighted and aggregated through the user-relationship score to deeply explore the complex relationships between entities and provide users with more comprehensive and accurate recommendation content. This step aims to deeply integrate the interest preferences of multi-hop neighbor information by constructing a cross-attention aggregation network, provide users with more comprehensive and accurate recommendation content, and effectively improve the personalization and relevance of recommendations. This network mainly relies on aggregate and label_ smoothness_predict Function implementation.

[0035] The user-relation attention mechanism is a core operation. To ensure the validity of subsequent computations, neighboring entities and relations are screened. For example, after edge discarding, secure neighboring entity and relationship embeddings are obtained based on valid masks. To align the user embeddings along the batch dimension, the user embeddings are first expanded and then concatenated with the relationship embeddings in the last dimension. Next, the attention_layer linear layer projects each row using a weighted sharing scheme, outputting an attention score. To prevent invalid relations from interfering with the attention calculation, the scores corresponding to invalid relations (including discarded edges) are set to negative infinity. The softmax function is then used to convert the attention scores into attention weights. These weights reflect the model's attention to different neighboring relations, enabling the model to dynamically focus on relevant neighboring information based on user preferences. Next, a multi-hop information fusion operation is performed, where the neighboring entity embeddings are weighted summed based on the calculated attention weights to aggregate the neighboring information into a tensor. Finally, a parameter determines whether to add the aggregated result to the original entity embeddings. The summed result undergoes a learnable linear transformation and Tanh activation, leaving the output dimension unchanged.

[0036] In addition, label_smoothness_predict This function also involves multi-hop information fusion. During the calculation process, neighbor labels are weighted and aggregated using user-relationship scores to deeply explore the complex relationships between entities. Specifically, during label propagation, user-relationship scores are calculated using user and relationship embeddings. Neighbor labels of different hops are weighted, and entity labels are gradually updated. This effectively utilizes multi-hop information and provides richer semantic information support for recommendation decisions.

[0037] Through the construction and operation of the above-mentioned cross-attention aggregation network, the model can deeply integrate multi-hop neighbor information, accurately capture user preferences, effectively mine the complex semantic associations between entities, generate recommended content that is more in line with users' interests, and significantly improve the performance of the recommendation system and user experience.

[0038] Preferably, it also includes: calculate_loss In the function, a function combination containing four losses is constructed, namely the basic recommendation loss rec_loss , label smoothing regularization loss ls_loss , embedding vector regularization loss l2_loss and ranking optimization loss rank_loss , and their mathematical expressions are: ,in, is the total number of samples, is the sigmoid function, is the label before smoothing, indicating that user i interacts with entity or relationship j. is the smoothed label; , , is the smoothing parameter; , is the regularization coefficient, , is the total number of user-positive sample pairs, is a positive sample entity, is a negative sample entity, To represent the user Positive samples The predicted interaction score of is a user Entities that have actually interacted are positive samples. To represent the user For negative samples The predicted interaction score of is a user Entities that have not interacted (generated by negative sampling) are negative samples; Based on the above four loss functions, the total loss function is obtained , is the basic recommendation loss weight, is the label smoothing regularization loss weight, is the embedding vector regularization loss weight, Optimize loss weights for ranking.

[0039] In this embodiment, by designing a combined loss function and adopting a phased training and gradient optimization strategy, the aim is to balance the performance of the model in terms of recommendation accuracy, generalization ability, etc., to ensure efficient model convergence and avoid overfitting, thereby improving the overall recommendation effect. BCEWithLogitsLoss Calculate the basic recommendation loss to measure the difference between the model's predictions and the true labels. Then, perform label smoothing and regularization to prevent model overfitting. Regularize the embedding vectors to improve model generalization. Optimize the sorting of recommendation lists based on BPR. By properly weighting each loss term, balance the model's performance across different performance metrics.

[0040] Specifically, the binary cross entropy logarithmic loss function is used BCEWithLogitsLoss Calculate the basic recommendation loss to measure the difference between the model prediction results and the true label. Assume that the user-item interaction score matrix predicted by the model is , the true interaction label matrix is ; After getting the basic recommendation loss rec_loss After the calculation formula, the original score output by the model is mapped to the probability interval [0,1]. This loss function enables the model to accurately predict whether there is an interactive relationship between users and items.

[0041] pass calculate_ls_loss The function calculates the label smoothing regularization loss to alleviate the overfitting problem of the model. Assume that the 1 label after smoothing the true label y is , where label smoothing regularization loss ls_loss Also based on the binary cross entropy loss calculation, the label smoothing operation makes the model prediction more generalizable and avoids over-reliance on training data.

[0042] In order to improve the generalization ability of the model, L2 regularization is performed on the user embedding vector, entity embedding vector, and relationship embedding vector. By constraining the size of the embedding vector, it prevents the model parameters from being too large and causing overfitting. Finally, the ranking optimization loss is involved based on the Bayesian personalized ranking (BPR) principle. rank_loss , optimizes the ranking quality of the recommendation list. This loss function encourages the model to learn more reasonable item ranking and improve the relevance of the recommendation list.

[0043] Furthermore, this method employs a phased training approach: first, graph structure pre-optimization is performed to construct a pseudo-edge-enhanced knowledge graph; then, the main network is trained to learn the representation of entities and relationships. During training, the edge drop rate is dynamically attenuated to further optimize model performance. An early stopping mechanism is also introduced to monitor validation set performance, avoid model overfitting, improve training efficiency, and accelerate model convergence.

[0044] A phased training method is used to optimize model performance. First, precompute_fake_edges The function performs graph structure pre-optimization, calculates entity similarity and adds pseudo edges to enhance the knowledge graph structure; then enters the main network training phase, uses the combined loss function to learn the embedded representation of entities and relationships, and adjusts the model parameters; in the fine-tuning phase, the edge drop rate is dynamically attenuated drop_rate , gradually decreases from the initial value to close to 0, so that the model can utilize more path information in the later stage of training and further optimize the model performance.

[0045] In addition, this method introduces an early stopping mechanism to avoid model overfitting. During the training process, the model performance is regularly evaluated on the validation set, and key evaluation indicators (such as AUC, Recall, etc.) are recorded. If the performance of the model on the validation set does not improve (or the improvement is less than the threshold) within T consecutive training cycles, ), training stops and the current optimal model parameters are retained. This mechanism effectively reduces training time, improves training efficiency, and ensures that the model achieves a good balance between generalization ability and training effect. Through the above loss function design and gradient optimization strategy, the model can effectively learn the complex relationship between users and items during training, balance multiple performance indicators, improve recommendation accuracy and generalization ability, and provide reliable recommendation services for practical applications.

[0046] In order to further comprehensively and objectively verify the effectiveness of this method from multiple dimensions such as recommendation accuracy, training efficiency, cold start adaptability and long-tail product coverage, a variety of classic recommendation evaluation indicators are used to comprehensively evaluate the model, including recall rate , average reciprocal ranking ( ), normalized discounted cumulative gain ( ), hit rate ( ) and accuracy ( Furthermore, the area under the curve (AUC) is introduced to measure cold-start performance, and the long-tail product coverage ratio is used to evaluate long-tail product coverage. Experiments on the MovieLens-1M dataset comprehensively validate the effectiveness and superiority of this method across multiple dimensions, including recommendation accuracy, training efficiency, cold-start adaptability, and long-tail product coverage.

[0047] The experimental indicators include: recall rate, which is calculated as the proportion of items that the user has actually interacted with in the first K items in the recommendation list. Let R(u) be the first K recommended items generated by the model for user u, and T(u) be the set of items that user u has actually interacted with. This metric measures the model’s ability to retrieve items of interest to the user.

[0048] For user u, if the item he is actually interested in is ranked in the recommendation list, the formula is: , where U is the user set. This metric reflects the ranking of related items in the recommendation list.

[0049] Normalized Discounted Cumulative Gain: In order to take into account the relevance and ranking of items in the recommendation list, the Discounted Cumulative Gain IDCG of the ideal recommendation list is first calculated, and then the Discounted Cumulative Gain DCG of the actual recommendation list is calculated. The formula is: , ,in, Indicates the first The relevance score between an item and a user.

[0050] Hit rate: Determine whether there are items in the first K items in the recommendation list that the user has actually interacted with. The formula is: , [] are Iverson brackets, which are 1 if the condition is met, otherwise 0. Accuracy: Calculates the proportion of items that the user has actually interacted with in the first K items in the recommendation list. The formula is: .

[0051] The model developed in this method was compared with KGIN. During the experiments, model hyperparameters were fixed, including an embedding vector dimension of 64, a multi-hop path length of 3, a preset number of paths of 10, a learning rate of 0.00075, and a batch size of 4096. Each experiment was repeated five times, and the average result was taken as the final result to reduce errors caused by experimental randomness. The other models were run at their optimal parameter configurations.

[0052] Experimental results show that this model outperforms the other three models in multiple metrics on the lastfm and book-crs datasets. It can more accurately capture user interests and generate high-quality recommendation lists. The experimental results are shown in Table 1.

[0053] Table 1

[0054] In summary, rigorous experiments and analysis on the lastfm and book-crs datasets demonstrate that this model significantly outperforms the other three models across multiple key evaluation metrics. In terms of user interest mining, this model leverages a unique multi-hop path enhancement mechanism to penetrate the data surface and deeply analyze users' underlying preferences. In the recommendation list generation phase, leveraging the structured information transfer of the knowledge graph, it effectively improves the relevance and diversity of recommended content. These experimental results demonstrate that this model is capable of more accurately capturing user interests and consistently producing high-quality recommendation lists, providing a new and viable direction for technical optimization in the field of personalized recommendations.

[0055] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization, characterized in that: include: Obtain an information dataset, extract user data, entity data, and relationship data from the information dataset, determine their quantity, initialize the user embedding layer, entity embedding layer, and relationship embedding layer, obtain the corresponding continuous embedding vector representation, and construct a knowledge graph adjacency dictionary; Based on the knowledge graph adjacency dictionary, a three-layer loop process is performed to traverse all entities, preset the number of paths and path lengths, and construct the entity-relationship path matrix; Based on the entity-relationship path matrix, construct positive sample interaction tables and negative sample interaction tables according to user data, entity data, and corresponding interaction records, and combine them to obtain a complete interaction table; Based on the complete interaction table, the recommendation model is trained and predicted by the adaptive graph structure optimization module. The training process includes pseudo-edge enhancement, and the prediction process includes original graph structure preservation. After the processing is completed, the relationship embedding vector and the user embedding vector are fused through the linear layer of the attention mechanism, the attention score is calculated, the score is converted into a weight, and the neighbor entity embedding vectors are weighted and summed according to the weight to obtain the final output.

2. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 1, characterized in that: Obtain an information dataset, extract user data, entity data, and relationship data from the information dataset, determine their quantity, initialize the user embedding layer, entity embedding layer, and relationship embedding layer, obtain the corresponding continuous embedding vector representation, and construct a knowledge graph adjacency dictionary, specifically: Extract user data, entity data and relationship data from the information dataset, and traverse the information dataset to count the number of users , number of entities and the number of relationships ,wherein, the information data set includes: a user ID set, an entity ID set, and a relationship data set embodied by the user-item interaction records; User embedding layer by ID , entity embedding layer and relation embedding layer Initialize and map the discrete user ID data, entity ID data, and relationship ID data into low-dimensional continuous embedding vector representations with a dimension of d; Among them, for the user ID set , user embedding layer The mathematical expression is , for the entity ID set , entity embedding layer The mathematical expression is , for relational data sets , relation embedding layer The mathematical expression is , For users The embedding vector of For Entity Embedded vector, For the relationship Embedded vector, is the set of all d-dimensional real vectors; Traverse each triple in the information dataset , build a knowledge graph adjacency dictionary , the graph structure information is stored in the form of triples, where h is the entity ID, t is the tail entity ID, and r is the relationship ID; For each head entity ID, its corresponding tail entity ID and relationship ID are added to the knowledge graph adjacency dictionary Under the corresponding header entity list in , the formula is For each tail entity ID, add its corresponding head entity ID and relationship ID to the knowledge graph adjacency dictionary Under the corresponding tail entity list in , the formula is , is the head entity in the knowledge graph adjacency dictionary The corresponding neighbor entity and relationship list, The tail entity in the knowledge graph adjacency dictionary The corresponding list of neighbor entities and relations.

3. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 2 is characterized in that: Based on the knowledge graph adjacency dictionary, a three-layer loop process is performed to traverse all entities, preset the number of paths and path lengths, and construct the entity-relationship path matrix, specifically: Based on the knowledge graph adjacency dictionary, three key parameters are determined, namely the number of entities , preset number of paths num_paths , and path length path_length , and create two three-dimensional arrays path_entities and path_ relations , where the array Used to store entity ID, array Used to store relationship IDs. The initial values ​​of relationship IDs and array elements are both 0. Perform three-layer loop processing based on three key parameters, randomly select the next entity and its corresponding relationship from the neighbor nodes of the current entity, and store them in the array path_entities and path_relations To update the three-dimensional array path_ entities and path_relations The data in the,entity-relationship path matrix is ​​constructed, and the three-layer loop processing includes,entity loop, path loop and path length loop.

4. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 3 is characterized in that: Perform three-layer loop processing based on three key parameters to update the three-dimensional array path_entities and path_ relations The data in the ,construct the entity-relationship path matrix, specifically: The entity loop is the outer loop, and its steps include: traversing all entities, whose indexes are marked as , ,For each entity, multiple paths starting from the entity are generated; The path loop is a middle-level loop, which includes the following steps: determining the number of paths generated by each entity, whose index is marked as , ,For each path of each entity, the path nodes and relationships are sampled independently; The path length loop is the inner loop, and its steps include: determining each step of the path, whose index is marked as , , at the start of the path At, the current entity amplitude is added to the array and from Initially, at each step, determine whether there is a neighbor entity; If so, from the array Randomly select a neighbor entity from the neighbor node set next_entity and their corresponding relationships next_relation , according to the formula , Update the array; If not, fill the entity to the subsequent position of the path, and set the corresponding relationship with the time array to 0. The formula is: , ; After all loops are processed, the array path_entities and path_relations Convert it into a PyTorch tensor, form a structured multi-hop path representation based on the tensor, and construct the entity-relationship path matrix.

5. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 4 is characterized in that: Based on the entity-relationship path matrix, we construct a positive sample interaction table and a negative sample interaction table according to user data, entity data, and corresponding interaction records. The complete interaction table is obtained by combining them. Specifically: use The function constructs a positive sample interaction table, specifically: Get the user ID set, entity ID set and corresponding interaction records, and define an offset offset , whose value is , this offset is used to combine the user ID data and the entity ID into a unique key; Based on the offset, each set of user ID data and entity ID data is calculated to generate the positive sample composite key value , and combine the positive sample key value with the interaction label y to form a positive sample key value pair ,in, is the ith user ID data, is the j-th entity ID data. In the positive sample, y=1, indicating that there is interaction between the user and the item; Construct a positive sample interaction table and store all key-value pairs of positive samples in the positive sample interaction table The formula is , A collection of interaction records between users and entities; use The function randomly generates negative samples, where the number of negative samples and the number of positive samples The same, specifically: Calculate the negative sample combination key by randomly selecting user ID data and entity ID data in a loop , For the User ID data, For the entity ID data, and determine whether the negative sample combination key exists in the list; If not, combine the negative sample key with the interaction label y to form a negative sample key-value pair ,In the positive sample, y=0, indicating that there is no interaction between the user and the item; Construct a negative sample interaction table and store all the key-value pairs of negative samples in the negative sample interaction table of the knowledge graph adjacency dictionary The formula is: ; Merged positive sample interaction table and negative sample interaction table , get the complete interaction table ,Among them, the complete interaction table covers the positive and negative interaction information,between users and entities.

6. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 5, characterized in that: Based on the complete interaction table, the recommendation model is trained and predicted. The training process includes pseudo-edge enhancement, and the prediction process includes original graph structure preservation. Specifically, Use the complete interaction table as positive and negative sample data for model training. The function calculates the similarity between entities, where the entity embedding vector matrix is , normalize it and get the normalized embedding vector matrix , the normalized formula is: , is the normalized entity embedding vector matrix Rank Elements of the column, is the corresponding element of the original matrix, It is the entity embedding vector matrix, which is used to store the low-dimensional continuous embedding vectors of all entities. Each row of the matrix corresponds to the embedding vector of an entity. It is the result of mapping the discrete entity ID into a computable continuous vector. is the total number of knowledge graph entities, is the dimension of the entity embedding vector, is the square of the embedding value of the a-th entity in the entity embedding matrix E in the K-th dimension; Calculate entity similarity matrix , the formula is: , is the entity similarity matrix, which is used to measure the similarity between any two entities. is transposed; The normalized matrix is ​​masked, where when the jth entity is judged There is a set of neighbor entities in the knowledge graph adjacency dictionary When , let the elements of the entity similarity matrix be is the minimum value, and its formula is: ; Select the preset number of entities with the highest similarity from the masked entity similarity matrix row by row fake_edge_num The entity index is stored in the array fake_edges_cache The formula is: ,in, Indicates selecting the index corresponding to the first u maximum values ​​from the vector; exist get_neighbors In the function, based on the array fake_edges_cach , add a pseudo edge to each entity edge, where for a specific entity , from the array fake_edges_cache [ ] to get the entity set corresponding to the edge , and create the corresponding pseudo-relationship ID set , It is the preset pseudo relation ID; The entities and relationships corresponding to these pseudo edges are spliced ​​with the original one-hop neighbor entities and relationships to expand the knowledge graph structure.

7. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 6, characterized in that: Also includes: Introducing a probabilistic edge discarding mechanism to remove noise edges that interfere with the learning of the recommendation model. get_neighbors When the function obtains neighbor nodes, it calls the edge discard function to filter the paths based on user preferences; The formula for processing the relationship ID is: , , using the embedding vector of the effective relationship relations_ embs Combined with user embedding vector user_emb Calculating user-relationship scores ,in, is the path dimension, To represent the element value of the relation embedding vector corresponding to the w-th path in the effective relation embedding matrix on the d-th dimension, is the element value of the user embedding vector in the dth dimension, is the validity mask, is the original input relation ID set, It is a relation embedding layer, a module for mapping discrete relation IDs into low-dimensional continuous embedding vectors. is the number of embeddings in the relation embedding layer, It is the security relationship ID after validity screening; Transform the user-relationship score to obtain , combined with the preset drop probability drop_rate Calculate path retention probability , where, during the training process, the retention mask is generated using the Bernoulli distribution , during the prediction processing stage, the mask will be retained Set to all True to keep all paths; exist aggregate In the function, according to the retention mask To neighbor entities neighbor_ents and relationships neighbor_rels Filter according to the rules , to update.

8. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 7, characterized in that: After processing is completed, the relationship embedding vector and the user embedding vector are fused through the linear layer of the attention mechanism to calculate the attention score, convert the score into a weight, and then perform a weighted sum of the neighbor entity embedding vectors according to the weight to obtain the final output, which is: After the training and prediction processes are completed, get the original item embeddings item_emb and one-hop neighbor entities neighbor_ents and relationships neighbor_rels , for neighbor entities neighbor_ents and relationships neighbor_rels Perform filtering to obtain safe neighbor entity embedding based on valid masks neighbor_ent_emb and relation embedding neighbor_rel_emb ; User embedding vector user_embeddings Expand it so that its dimension matches the neighbor relationship embedding to form a vector user_embeded , whose dimensions are [ batch_size,num_paths,emb_dim ]; Constructing attention input attention_input , the expanded user vector user_embeded Embedding with neighbor relations neighbor_rel_emb Splice and get the dimension Tensor ; use attention_layer Linear layer on tensor Calculate and get the attention score , whose dimensions are [ batch_size,num_paths ], It is a tensor operation function, which means removing the dimension of the tensor; The fraction corresponding to the invalid relationship is set to negative infinity, and the formula is: , and use the softmax function to convert the attention score into the attention weight ; Perform multi-hop information fusion based on the calculated attention weights , embedding neighbor entities neighbor_ent_emb Perform weighted summation to obtain the aggregated result tensor ; Configuration-based aggregator_class Parameters, embed the original item item_emb with the aggregation result tensor The combination is performed by addition, and the formula is: ; Through the linear layer self.linear_layers[0] Combined results Transformed and processed by Tanh activation function to obtain the final output output .

9. The graph recommendation method based on multi-hop path enhancement and adaptive graph structure optimization according to claim 8, characterized in that: Also includes: exist calculate_loss In the function, a function combination containing four losses is constructed, namely the basic recommendation loss rec_loss , label smoothing regularization loss ls_loss , embedding vector regularization loss l2_loss and ranking optimization loss rank_loss , and their mathematical expressions are: ,in, is the total number of samples, is the sigmoid function, is the label before smoothing, indicating that user i interacts with entity or relationship j. is the smoothed label; , , is the smoothing parameter; , is the regularization coefficient, , is the total number of user-positive sample pairs, is a positive sample entity, is a negative sample entity, To represent the user Positive samples The predicted interaction score of is a user Entities that have actually interacted are positive samples. To represent the user For negative samples The predicted interaction score of is a user Entities that have not been interacted with are generated by negative sampling and belong to negative samples; Based on the above four loss functions, the total loss function is obtained , is the basic recommendation loss weight, is the label smoothing regularization loss weight, is the embedding vector regularization loss weight, Optimize loss weights for ranking.

Citation Information

Patent Citations

  • Personalized recommendation method based on knowledge graph convolution algorithm

    CN112488791A

  • Recommendation system-oriented attention network architecture and optimization method thereof

    CN119761415A

  • Knowledge graph construction and product recommendation method and system based on user data

    CN120338924A

  • Accurate and personalized recommendation method based on knowledge graph

    US20220245488A1

Cited By

  • Atlas optimization method, electronic equipment, storage medium and program product

    CN121257667A