Knowledge graph recommendation method, system and device based on contrast learning and collaborative signal

CN116776003BActive Publication Date: 2026-08-07CHONGQING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHONGQING UNIV
Filing Date
2023-07-07
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

本发明基于对比学习和协同信号的知识图推荐方法,通过基于协同指导信号提取知识信息、多视角学习用户和项目的嵌入和对比学习任务对数据进行增强,在推荐方法中引入对比学习任务,从而从根源上解决了现有的推荐方法准确性低、用户满意度低的问题

Benefits of technology

本发明的基于对比学习和协同信号的知识图推荐方法,通过基于协同指导信号提取知识信息、多视角学习用户和项目的嵌入和对比学习任务对数据进行增强,在推荐方法中引入对比学习任务,提升了推荐方法的准确性和鲁棒性,进而提升了用户体验。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116776003B_ABST
    Figure CN116776003B_ABST
Patent Text Reader

Abstract

The application provides a knowledge graph recommendation method, system and device based on contrast learning and collaborative signals, and the method comprises the following steps: constructing a knowledge graph recommendation model based on contrast learning and collaborative signals; training the knowledge graph recommendation model by using the historical interaction sequence of the user in the obtained data set and the knowledge information of the item and the knowledge entity, obtaining the trained knowledge graph recommendation model based on contrast learning and collaborative signals, inputting the historical interaction sequence of the user to be recommended and the knowledge information of the item and the knowledge entity into the trained knowledge graph recommendation model based on contrast learning and collaborative signals, obtaining a target recommendation list, and recommending the target recommendation list to the user. The knowledge graph recommendation method based on contrast learning and collaborative signals is adopted, the knowledge information is extracted based on the collaborative signals, the data is enhanced through multi-perspective learning of the embedding of the user and the item and a contrast learning task, and therefore the problem of low accuracy of the existing recommendation method is solved from the root.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of personalized recommendation, specifically relating to a knowledge graph recommendation method, system, and device based on contrastive learning and collaborative signals. Background Technology

[0002] With the rapid development of the internet, information technology has brought great convenience to people, but at the same time, it has also created many problems in people's lives, the most significant of which is information overload. Information overload makes it difficult for users to quickly and efficiently filter out content that interests them or is meaningful to them from a vast amount of information. For example, when people buy goods on shopping websites, they are often overwhelmed by the complex and varied product information, resulting in spending more time finding the items they want. Recommendation systems can be seen as a type of information filtering system. Their main purpose is to present personalized information to users and recommend products that users may be interested in, thus optimizing the user experience. Simultaneously, it can connect users and merchants, allowing merchants to better and more comprehensively showcase their products, and making it more convenient for users to purchase goods.

[0003] User-item interaction data is typically sparse, leading to poor model performance. Introducing auxiliary information into recommendation models can alleviate this problem. Knowledge graphs (KGs), due to their rich semantic knowledge, are often used as auxiliary information in recommendation systems. In recent years, contrastive learning has achieved significant results in image recognition and natural language processing; however, research on contrastive learning in recommendation systems is still in its early stages. Existing knowledge graph-based recommendation methods rarely involve data augmentation using contrastive learning tasks. Previous knowledge graph-based methods heavily rely on the quality of knowledge graph information, making it difficult to learn high-quality embedding representations, facing two challenges: 1) the long-tailed distribution of entities leads to sparse supervision signals for KG-enhanced item representations; 2) real-world knowledge graphs often contain noisy information, resulting in topic-irrelevant relationships between items and entities. The sparsity and noise of KGs cause item-entity dependencies to deviate from the reflection of real features, hindering accurate representation of user preferences. In other words, current knowledge graph-based recommendation methods suffer from low information recommendation accuracy and low user satisfaction.

[0004] Therefore, improving the accuracy of information recommendations and enhancing user satisfaction are urgent problems to be solved in this field. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies by providing a knowledge graph recommendation method, system, and device based on contrastive learning and collaborative signals. This invention's knowledge graph recommendation method, based on contrastive learning and collaborative signals, enhances data by extracting knowledge information based on collaborative guidance signals, learning user and item embeddings from multiple perspectives, and employing contrastive learning tasks. By introducing contrastive learning tasks into the recommendation method, it fundamentally solves the problems of low accuracy and low user satisfaction in existing recommendation methods.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: This invention proposes a knowledge graph recommendation method based on contrastive learning and collaborative signals, characterized by the following steps: S1. Construct a knowledge graph recommendation model based on contrastive learning and collaborative signals; S2. Using the historical interaction sequences of users and the knowledge information of items and knowledge entities in the acquired dataset, train the knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain a trained knowledge graph recommendation model based on contrastive learning and collaborative signals; step S2 specifically includes the following: Step (1): Obtain the historical interaction sequence between users and projects and the knowledge information of projects and knowledge entities from the dataset, construct the adjacency matrix between users and projects based on the historical interaction sequence, and construct the knowledge graph based on the knowledge information of projects and knowledge entities. The projects are movies or books. Step (2): Construct initial embeddings of users and items based on user and item attribute information; and input the adjacency matrix and initial embeddings of users and items into a two-layer GCN network to obtain user embeddings. and project embedding ; Step (3): Embedding the user and project embedding Perform information fusion to extract collaborative guidance signals; Step (4): Extract the item embedding, relation embedding and entity embedding from the knowledge graph in step (1), perform a dot product operation between the relation embedding and the collaborative guidance signal to obtain a new relation embedding with a collaborative signal; and calculate the importance score from item to entity based on the new relation embedding using the softmax function and attention mechanism. Step (5): Input the importance score, item embedding, and entity embedding from step (4) into the collaborative knowledge neighborhood aggregation module to obtain a new item embedding. ; Step (6): Integrate the historical interaction sequence between the user and the project and the knowledge information of the project and knowledge entities obtained in step (1) to construct a collaborative knowledge graph. The form of the collaborative knowledge graph is as follows: Where h represents the head entity, t represents the tail entity, and r represents the relation. , Where R represents the set of relations in the knowledge graph, and Interact represents the interaction relationship between users and items in the adjacency matrix of users and items; Step (7): Based on the collaborative knowledge graph, calculate the normalized attention weights; Step (8): Multiply all the neighbor embeddings t of h by their corresponding normalized attention weights, aggregate the neighborhood of h, and sum them to obtain the result. Then embed h with Linear addition yields a new h-embedding; Step (9): Based on the collaborative knowledge graph, multiple attention embedding propagation layers are stacked, and the entity embeddings obtained from each layer are concatted to obtain each node in the collaborative knowledge graph. The final embedding representation, and the user embedding extracted from the collaborative knowledge graph. and project embedding ; Step (10): Embed the project and project embedding Add them together to get the local item embedding. Embedding users of the same user and user embedding As the opposite, user embedding for different users and user embedding As a negative pair; embedding items from the same project and project embedding As a counterpart, project embedding in different projects and project embedding As a negative pair, a contrastive learning task is performed, and the InfoNCE function is used as the loss function for training. Step (11): Embed the project Embedded with project Perform concat to obtain the final project embedding; embed the user. With user embedding Perform concat to obtain the final user embedding; use the final item embedding and the final user embedding to perform an inner product to obtain the final prediction score; generate the final item recommendation list based on the prediction score, wherein the BPR function is selected as the loss function for model training; and integrate the BPR loss function and the InfoNCE loss function to obtain the final loss function L.

[0007] S3. Obtain the historical interaction sequence of the user to be recommended and the knowledge information of items and knowledge entities, and input the historical interaction sequence of the user to be recommended and the knowledge information of items and knowledge entities into the trained knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain the target recommendation list, and recommend the target recommendation list to the user.

[0008] Furthermore, in step (2), the GCN network is a LightGCN network structure, including a message propagation module and a layer information fusion module. Message dissemination: ,

[0009] Layer information fusion: , ; in, Let v and u represent the neighbor sets of item v and user u, respectively, obtained from the adjacency matrices of users and items. For the user's initial embedding vector, This is the initial embedding vector for the project; This represents the user embedding vector at layer k. This represents the user embedding vector at layer k+1. This represents the item embedding vector at layer k. This represents the item embedding vector at layer k+1; K represents the number of layers in the GCN network, K=2. These are the learnable weight coefficients.

[0010] Further, in step (4), the relationship embedding is subjected to a dot product operation with the cooperative guidance signal to obtain a new relationship embedding with a cooperative signal, specifically as follows: ; in, This represents the relation embeddings learned from the knowledge graph. This indicates a coordinated guidance signal. This indicates a new relation embedding. Let v be the set of neighbors of item v in the adjacency matrix of users and items; The method for calculating the importance score from item to entity based on the new relation embedding, using the softmax function and attention mechanism, is as follows:

[0011] in, Let v be the set of neighbors of project v in the project-entity graph, where the project-entity graph consists of projects and entities.

[0012] A bipartite graph of a body is a subset of a knowledge graph. The LeakyReLU function is the activation function, and || represents...

[0013] The `concat` operation, where W represents the learnable parameter matrix, is used to unify the dimension of the vector embeddings. The importance score represents the importance of entity t to item v.

[0014] Furthermore, in step (5), the importance score, item embedding, and entity embedding from step (4) are input into the collaborative knowledge neighborhood aggregation module to obtain a new item embedding. Specifically: ; in, Embedded in the project, For entity embedding, For importance scores, Let v be the set of neighbors of project v in the project-entity graph.

[0015] Further, in step (7), based on the collaborative knowledge graph, the normalized attention weights are calculated, specifically as follows: Using learnable parameter matrices Map the h-embedded and t-embedded to the same dimension as the relational embedding r; Adding the mapped h-embeds and r-embeds together, and then adding them together with the mapped t-embeds, yields the attention score for h→t. : ; in, For a learnable parameter matrix, Indicates h embedding, Indicates t embedding, Indicates r-embedding; The attention score Perform a normalization operation to obtain normalized attention weights. : ; in, This represents the set of neighbors embedded in h.

[0016] Further, in step (9), based on the collaborative knowledge graph, multiple attention embedding propagation layers are stacked, and the entity embeddings obtained from each layer are concatted to obtain the final embedding representation of each node in the collaborative knowledge graph, specifically: ; ; in, It is the set of neighbors embedded in h. , They represent the first , layer h embedding, Indicates the first Layer t embedding; This is for the concat concatenation operation.

[0017] Furthermore, the InfoNCE function is specifically as follows: ; in Let cosine similarity function be used. Represents the correct direction. Represents a negative pair, where n indicates user embedding or item embedding. This is the temperature coefficient.

[0018] Further, in step (11), the final item embedding and the final user embedding are multiplied by an inner product to obtain the final predicted score, specifically: ; in, For predicted scores; The BPR function is specifically: ; in It is an activation function, where U is the set of users. A collection of items that user u has interacted with. The predicted score represents the number of interactions between u and v in the dataset. This indicates the predicted score where there is no interaction between u and v' in the dataset; The final loss function is as follows:

[0019] in, These are weighting coefficients used to control the influence of the two loss functions.

[0020] This invention also proposes a knowledge graph recommendation system based on contrastive learning and collaborative signals, characterized in that the knowledge graph recommendation system executes the knowledge graph recommendation method based on contrastive learning and collaborative signals, including: a knowledge graph recommendation model construction module, a knowledge graph recommendation model training module, and an item recommendation module; The knowledge graph recommendation model building module constructs a knowledge graph recommendation model based on contrastive learning and collaborative signals. The knowledge graph recommendation model training module uses the historical interaction sequences of users and the knowledge information of items and knowledge entities in the acquired dataset to train the knowledge graph recommendation model based on contrastive learning and collaborative signals, thereby obtaining a trained knowledge graph recommendation model based on contrastive learning and collaborative signals. The project recommendation module obtains the historical interaction sequence of the user to be recommended and the knowledge information of the project and knowledge entities, and inputs the historical interaction sequence of the user to be recommended and the knowledge information of the project and knowledge entities into the trained knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain a target recommendation list, and recommends the target recommendation list to the user.

[0021] The present invention also proposes a computer device, the device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.

[0022] Compared with existing technologies, it has the following beneficial effects: The knowledge graph recommendation method based on contrastive learning and collaborative signals of the present invention enhances the data by extracting knowledge information based on collaborative guidance signals, learning the embedding of users and items from multiple perspectives, and performing contrastive learning tasks. By introducing contrastive learning tasks into the recommendation method, the accuracy and robustness of the recommendation method are improved, thereby enhancing the user experience. Attached Figure Description

[0023] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a schematic diagram of a knowledge graph recommendation method based on contrastive learning and collaborative signals provided in an embodiment of the present invention.

[0025] Figure 2 This is a schematic diagram of a knowledge graph recommendation model based on contrastive learning and collaborative signals provided in an embodiment of the present invention.

[0026] Figure 3 This is a schematic diagram of collaborative knowledge neighborhood aggregation provided in an embodiment of the present invention.

[0027] Figure 4 This is a schematic diagram of the knowledge extraction layer provided in an embodiment of the present invention.

[0028] Figure 5 This is a schematic diagram of a comparative learning task provided in an embodiment of the present invention.

[0029] Figure 6 This is a schematic diagram of a knowledge graph recommendation system based on contrastive learning and collaborative signals, provided in an embodiment of the present invention. Detailed Implementation

[0030] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0031] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0032] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but this is not intended to limit the scope of the invention.

[0033] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0034] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0035] This invention provides a knowledge graph recommendation method based on contrastive learning and collaborative signals. For example... Figure 1 As shown, the knowledge graph recommendation method based on contrastive learning and collaborative signals includes the following steps S1 to S3.

[0036] S1. Construct a knowledge graph recommendation model based on contrastive learning and collaborative signals, wherein the knowledge graph recommendation model based on contrastive learning and collaborative signals is as follows: Figure 2 As shown; S2. Using the historical interaction sequences of users and the knowledge information of items and knowledge entities in the acquired dataset, train the knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain a trained knowledge graph recommendation model based on contrastive learning and collaborative signals; step S2 specifically includes the following: Step (1): Obtain the historical interaction sequence between users and projects and the knowledge information of projects and knowledge entities from the dataset, construct the adjacency matrix between users and projects based on the historical interaction sequence, and construct the knowledge graph based on the knowledge information of projects and knowledge entities. The projects are movies or books.

[0037] Specifically, for the historical interaction sequence between users and items, let U be the set of users and V be the set of items, where , Adjacency matrix of users and projects , This indicates that user u has interacted with item v. This indicates that user u has not interacted with item v.

[0038] For knowledge graph construction, triples are used. To represent knowledge graph information, where , , , Represents a set of entities. Represents a set of relations.

[0039] Step (2): Construct initial embeddings of users and items based on user and item attribute information; and input the adjacency matrix and initial embeddings of users and items into a two-layer GCN network to obtain user embeddings. and project embedding .

[0040] In one embodiment, an initial embedding of users and items with an embedding dimension of d is constructed based on information such as the ID attributes of users and items. The lookup operation is used to find the specific user and item embeddings. The initial user and item embeddings E and the interaction matrix Y are then input into a two-layer GCN network.

[0041] Furthermore, the GCN network is a LightGCN network structure, including a message propagation module and a layer information fusion module. Message dissemination: ,

[0042] Layer information fusion: , ; in, Let v and u represent the neighbor sets of item v and user u, respectively, obtained from the adjacency matrices of users and items. For the user's initial embedding vector, This is the initial embedding vector for the project; This represents the user embedding vector at layer k. This represents the user embedding vector at layer k+1. This represents the item embedding vector at layer k. This represents the item embedding vector at layer k+1; K represents the number of layers in the GCN network, K=2. These are the learnable weight coefficients.

[0043] It is important to note that the input user and project are initially embedded at GCN level 0, represented as... , After passing through two layers of GCN, the user embedding is obtained. and project embedding .

[0044] Step (3): Embedding the user and project embedding Information fusion is performed to extract collaborative guidance signals.

[0045] Specifically, embedding users and project embedding Information integration forms collaborative guidance signals This is used for subsequent knowledge and information extraction, making the extraction of knowledge and information more personalized;

[0046] Where f is the information fusion function, and the options are linear addition and taking the maximum value of each element in the two embeddings.

[0047] Step (4): Extract the item embedding, relation embedding and entity embedding from the knowledge graph in step (1), perform a dot product operation between the relation embedding and the collaborative guidance signal to obtain a new relation embedding with a collaborative signal; and calculate the importance score from item to entity based on the new relation embedding using the softmax function and attention mechanism.

[0048] Specifically, representation learning is performed based on the ID information of projects, entities, and relationships to obtain embedded representations of projects, entities, and relationships. , and The three are mapped to the same dimension, indicating that item v and entity t have a relationship r, where the embedding of the item is the head embedding and the embedding of the entity is the tail embedding.

[0049] Further, in step (4), the relationship embedding is subjected to a dot product operation with the cooperative guidance signal to obtain a new relationship embedding with a cooperative signal, specifically as follows: ; in, This represents the relation embeddings learned from the knowledge graph. This indicates a coordinated guidance signal. This indicates a new relation embedding. Let v be the set of neighbors of item v in the adjacency matrix of users and items; in, Figure 2 The user-item graph in the diagram is stored as an adjacency matrix of the users and items, and the two are equivalent.

[0050] The method for calculating the importance score from item to entity based on the new relation embedding, using the softmax function and attention mechanism, is as follows:

[0051] in, Let be the set of neighbors of item v in the project-entity graph, where the project-entity graph is a bipartite graph of projects and entities, a subset of the knowledge graph. The LeakyReLU function is the activation function, and || represents .

[0052] The `concat` operation, where W represents the learnable parameter matrix, is used to unify the dimension of the vector embeddings. The importance score represents the importance of entity t to item v.

[0053] Furthermore, the project-entity graph can be understood as a bipartite graph of projects and entities, and can be regarded as a subset of a knowledge graph; all nodes in the knowledge graph are represented in the form of entities, such as the head entity and tail entity mentioned above.

[0054] Step (5): Input the importance score, item embedding, and entity embedding from step (4) into the collaborative knowledge neighborhood aggregation module to obtain a new item embedding. The schematic diagram of the collaborative knowledge neighborhood aggregation module is shown below. Figure 3 As shown.

[0055] Furthermore, in step (5), the importance score from step (4) is... Project Embedding and entity embedding input The new project is embedded in the collaborative knowledge neighborhood aggregation module. Specifically: ; in, Embedded in the project, For entity embedding, For importance scores, Let v be the set of neighbors of project v in the project-entity graph.

[0056] Steps (4) and (5) above can be considered as a knowledge extraction layer, such asFigure 4 As shown.

[0057] Step (6): Integrate the historical interaction sequence between the user and the project and the knowledge information of the project and knowledge entities obtained in step (1) to construct a collaborative knowledge graph. The form of the collaborative knowledge graph is as follows: Where h represents the head entity, t represents the tail entity, and r represents the relation. , Where R represents the set of relations in the knowledge graph, and Interact represents the interaction relationship between users and items in the adjacency matrix of users and items.

[0058] Step (7): Based on the collaborative knowledge graph, calculate the normalized attention weights. Specifically: Using learnable parameter matrices Map the h-embedded and t-embedded to the same dimension as the relational embedding r; Adding the mapped h-embeds and r-embeds together, and then adding them together with the mapped t-embeds, yields the attention score for h→t. : ; in, Let be a learnable parameter matrix. Indicates h embedding, Indicates t embedding, Indicates r-embedding; The attention score Perform a normalization operation to obtain normalized attention weights. : ; in, This represents the set of neighbors of the h-embedding. Normalized attention weights. The value of t ranges from 0 to 1. The larger the score, the greater the influence of t on h.

[0059] Step (8): Multiply all the neighbor embeddings t of h by their corresponding normalized attention weights, aggregate the neighborhood of h, and sum them to obtain the result. Then embed h with Linear addition yields a new h embedding.

[0060] Specifically, in step (8), the neighborhood information in the knowledge embedding propagation layer is aggregated, and the embedding representation of the entity is updated, which specifically includes the following steps: The process of multiplying the embeddings of all neighbors 'h' with their corresponding normalized attention weights and aggregating the neighborhood of 'h' is called information aggregation. Then, this aggregated neighborhood is linearly added to the embedding of 'h' itself to obtain the updated head embedding. .

[0061]

[0062]

[0063] in This represents the set of neighbors embedded in h.

[0064] Specifically, steps (8) to (9) above can be regarded as an attention embedding propagation layer.

[0065] Step (9): Based on the collaborative knowledge graph, multiple attention embedding propagation layers are stacked, and the entity embeddings obtained from each layer are concatted to obtain each node in the collaborative knowledge graph.

[0066] The final embedding representation, and the user embedding extracted from the collaborative knowledge graph. and project embedding .

[0067] Shallow neighborhood information is often insufficient, so in order to mine higher-order neighborhood information, multiple attention embedding propagation layers are stacked, and each layer can obtain a completely new entity embedding.

[0068] Further, in step (9), based on the collaborative knowledge graph, multiple attention embedding propagation layers are stacked, and the entity embeddings obtained from each layer are concatted to obtain the final embedding representation of each node in the collaborative knowledge graph, specifically: ; ; in, It is the set of neighbors embedded in h. , They represent the first , layer h embedding, Indicates the first Layer t embedding; This is for the concat concatenation operation.

[0069] Extracting user embeddings from collaborative knowledge graphs Project Embedding .

[0070]

[0071] in This indicates the extraction of user and project embeddings from the collaborative knowledge graph.

[0072] Step (10): Embed the project and project embedding Add them together to get the local item embedding. Embedding users of the same user and user embedding As the opposite, user embedding for different users and user embedding As a negative pair; embedding items from the same project and project embedding As a counterpart, project embedding in different projects and project embedding As a negative pair, a contrastive learning task is performed, and the InfoNCE function is used as the loss function in the training.

[0073] Contrastive learning is used for data augmentation to improve recommendation accuracy. A key challenge in contrastive learning tasks lies in constructing positive and negative contrastive entities. The process of constructing positive and negative pairs in contrastive learning tasks is as follows: Figure 5 As shown. Furthermore, the contrastive learning task only participates in training, not prediction. The contrastive learning task is equivalent to data augmentation and is only effective during the training phase.

[0074] In one embodiment, the InfoNCE function is specifically: ; in Let cosine similarity function be used. Represents the correct direction. Represents a negative pair, where n indicates user embedding or item embedding. This is the temperature coefficient.

[0075] The purpose of the InfoNCE function is to increase the similarity between positive pairs and decrease the similarity between negative pairs. , It can represent user embedding and project embedding, according to Figure 5 To determine.

[0076] The InfoNCE function is used as a loss function in training to achieve the purpose of data augmentation.

[0077] Step (11): Embed the project Embedded with project Perform concat to obtain the final project embedding; embed the user. With user embedding Perform concat to obtain the final user embedding; perform an inner product of the final item embedding and the final user embedding to obtain the final prediction score; generate the final item recommendation list based on the prediction score, wherein the BPR function is selected as the loss function for model training; and the BPR loss function and the InfoNCE loss function are integrated to obtain the final loss function L. Specifically, the steps include the following: First, embed the project Embedded with project Perform concat to obtain the final project embedding. Embedding users With user embedding Perform concat to obtain the final user embedding. :

[0078]

[0079] in It is a concat concatenation operation.

[0080] Secondly, the final item embedding and the final user embedding are multiplied by an inner product to obtain the final prediction score, specifically: ; in, For predicted scores; The BPR loss function is specifically as follows: ; in It is an activation function, where U is the set of users. A collection of items that user u has interacted with. The predicted score represents the number of interactions between u and v in the dataset. This indicates a predicted score where there is no interaction between u and v' in the dataset.

[0081] The BPR function is selected as the loss function for model training to make the results more accurate.

[0082] Furthermore, in order to combine the recommendation task with the contrastive learning task, a multi-task learning strategy is used to jointly train the recommendation task and the contrastive learning task, and the BPR loss function and the InfoNCE loss function are merged to obtain the final loss function L.

[0083]

[0084] in These are weighting coefficients used to control the influence of the two loss functions.

[0085] Specifically, the entire training process of the knowledge graph recommendation model based on contrastive learning and collaborative signals uses this final loss function L; the loss function L has two parts, the first part is the loss function for the recommendation task, and the second part is the loss function for the contrastive learning task.

[0086] S3. Obtain the historical interaction sequence of the user to be recommended and the knowledge information of items and knowledge entities, and input the historical interaction sequence of the user to be recommended and the knowledge information of items and knowledge entities into the trained knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain the target recommendation list, and recommend the target recommendation list to the user.

[0087] Specifically, the historical interaction sequence of the user to be recommended and the knowledge information of items and knowledge entities are input into the trained knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain predicted scores. The predicted scores are then sorted, and a final item recommendation list is generated based on the sorting results. In one embodiment, the predicted scores are sorted from high to low, and the top ten items are used to generate an item recommendation list, which is then recommended to the user.

[0088] Figure 6 This is a knowledge graph recommendation system based on contrastive learning and collaborative signals provided in an embodiment of the present invention. For example... Figure 6 As shown, the knowledge graph recommendation system based on contrastive learning and collaborative signals includes a knowledge graph recommendation model construction module, a knowledge graph recommendation model training module, and an item recommendation module.

[0089] The knowledge graph recommendation model building module constructs a knowledge graph recommendation model based on contrastive learning and collaborative signals. The knowledge graph recommendation model training module uses the historical interaction sequences of users and the knowledge information of items and knowledge entities in the acquired dataset to train the knowledge graph recommendation model based on contrastive learning and collaborative signals, thereby obtaining a trained knowledge graph recommendation model based on contrastive learning and collaborative signals. The project recommendation module obtains the historical interaction sequence of the user to be recommended and the knowledge information of the project and knowledge entities, and inputs the historical interaction sequence of the user to be recommended and the knowledge information of the project and knowledge entities into the trained knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain a target recommendation list, and recommends the target recommendation list to the user.

[0090] The aforementioned knowledge graph recommendation system based on contrastive learning and collaborative signals can be implemented as a computer program that can run on a computer device.

[0091] The computer device can be a server, which can be a standalone server or a server cluster consisting of multiple servers.

[0092] Computer devices include processors, memory, and network interfaces connected via a system bus, wherein the memory may include non-volatile storage media and internal memory.

[0093] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions that, when executed, cause the processor to perform a knowledge graph recommendation method based on contrastive learning and cooperative signals.

[0094] This processor provides computing and control capabilities to support the operation of the entire computer device.

[0095] This internal memory provides an environment for the execution of computer programs in non-volatile storage media. When executed by a processor, the computer program enables the processor to perform a knowledge graph recommendation method based on contrastive learning and cooperative signals.

[0096] This network interface is used for network communication with other devices. Those skilled in the art will understand that the above-described computer device structure is only a partial structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements.

[0097] The processor is used to run a computer program stored in the memory, which implements the knowledge graph recommendation method based on contrastive learning and cooperative signals as described in Embodiment 1.

[0098] It should be understood that, in the embodiments of this application, the processor may be a Central Processing Unit (CPU), but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0099] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.

[0100] The present invention also provides a storage medium. This storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when executed by a processor, the computer program causes the processor to perform the knowledge graph recommendation method based on contrastive learning and cooperative signals described in Embodiment 1.

[0101] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.

[0102] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0103] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0104] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the device of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0105] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0106] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A knowledge graph recommendation method based on contrastive learning and collaborative signals, characterized in that, Including the following steps: S1. Construct a knowledge graph recommendation model based on contrastive learning and collaborative signals; S2. Using the historical interaction sequences of users and the knowledge information of items and knowledge entities in the acquired dataset, train the knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain a trained knowledge graph recommendation model based on contrastive learning and collaborative signals; step S2 specifically includes the following: Step (1): Obtain the historical interaction sequence between users and projects and the knowledge information of projects and knowledge entities from the dataset, construct the adjacency matrix between users and projects based on the historical interaction sequence, and construct the knowledge graph based on the knowledge information of projects and knowledge entities. The projects are movies or books. Step (2): Construct initial embeddings of users and items based on user and item attribute information; and input the adjacency matrix and initial embeddings of users and items into a two-layer GCN network to obtain user embeddings. and project embedding ; Step (3): Embedding the user and project embedding Perform information fusion to extract collaborative guidance signals; Step (4): Extract the item embedding, relation embedding and entity embedding from the knowledge graph in step (1), perform a dot product operation between the relation embedding and the collaborative guidance signal to obtain a new relation embedding with a collaborative signal; and calculate the importance score from item to entity based on the new relation embedding using the softmax function and attention mechanism. Step (5): Input the importance score, item embedding, and entity embedding from step (4) into the collaborative knowledge neighborhood aggregation module to obtain a new item embedding. ; Step (6): Integrate the historical interaction sequence between the user and the project and the knowledge information of the project and knowledge entities obtained in step (1) to construct a collaborative knowledge graph. The form of the collaborative knowledge graph is as follows: Where h represents the head entity, t represents the tail entity, and r represents the relation. , Where R represents the set of relations in the knowledge graph, and Interact represents the interaction relationship between users and items in the adjacency matrix of users and items; Step (7): Based on the collaborative knowledge graph, calculate the normalized attention weights; Step (8): Multiply all the neighbor embeddings t of h by their corresponding normalized attention weights, aggregate the neighborhood of h, and sum them to obtain the result. Then embed h with Linear addition yields a new h-embedding; Step (9): Based on the collaborative knowledge graph, multiple attention embedding propagation layers are stacked, and the entity embeddings obtained from each layer are concatted to obtain each node in the collaborative knowledge graph. The final embedding representation, and the user embedding extracted from the collaborative knowledge graph. and project embedding ; Step (10): Embed the project and project embedding Add them together to get the local item embedding. Embedding users of the same user and user embedding As the opposite, user embedding for different users and user embedding As a negative pair; embedding items from the same project and project embedding As a counterpart, project embedding in different projects and project embedding As a negative pair, a contrastive learning task is performed, and the InfoNCE function is used as the loss function for training. Step (11): Embed the project Embedded with project Perform concat to obtain the final project embedding; embed the user. With user embedding Perform concat to obtain the final user embedding; use the final item embedding and the final user embedding to perform an inner product to obtain the final prediction score; generate the final item recommendation list based on the prediction score, wherein the BPR function is selected as the loss function for model training; and integrate the BPR loss function and the InfoNCE loss function to obtain the final loss function L. S3. Obtain the historical interaction sequence of the user to be recommended and the knowledge information of items and knowledge entities, and input the historical interaction sequence of the user to be recommended and the knowledge information of items and knowledge entities into the trained knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain the target recommendation list, and recommend the target recommendation list to the user.

2. The method according to claim 1, characterized in that, In step (2), the GCN network is a LightGCN network structure, including a message propagation module and a layer information fusion module. Message dissemination: , Layer information fusion: , ; in, Let v and u represent the neighbor sets of item v and user u, respectively, obtained from the adjacency matrices of users and items. For the user's initial embedding vector, This is the initial embedding vector for the project; This represents the user embedding vector at layer k. This represents the user embedding vector at layer k+1. This represents the item embedding vector at layer k. This represents the item embedding vector at layer k+1; K represents the number of layers in the GCN network, K=2. These are the learnable weight coefficients.

3. The method according to claim 2, characterized in that, In step (4), the relation embedding is multiplied by the cooperative guidance signal to obtain a new relation embedding with a cooperative signal, specifically as follows: ; in, This represents the relation embeddings learned from the knowledge graph. This indicates a coordinated guidance signal. This indicates a new relation embedding. Let v be the set of neighbors of item v in the adjacency matrix of users and items; The method for calculating the importance score from item to entity based on the new relation embedding, using the softmax function and attention mechanism, is as follows: in, Let be the set of neighbors of item v in the project-entity graph, where the project-entity graph is a bipartite graph of projects and entities, a subset of the knowledge graph. The LeakyReLU function is the activation function, and || represents . The `concat` operation, where W represents the learnable parameter matrix, is used to unify the dimension of the vector embeddings. The importance score represents the importance of entity t to item v.

4. The method according to claim 3, characterized in that, In step (5), the importance score, item embedding, and entity embedding from step (4) are input into the collaborative knowledge neighborhood aggregation module to obtain a new item embedding. Specifically: ; in, Embedded in the project, For entity embedding, For importance scores, Let v be the set of neighbors of project v in the project-entity graph.

5. The method according to claim 4, characterized in that, In step (7), based on the collaborative knowledge graph, the normalized attention weights are calculated, specifically as follows: Using learnable parameter matrices Map the h-embedded and t-embedded to the same dimension as the relational embedding r; Adding the mapped h-embeds and r-embeds together, and then adding them together with the mapped t-embeds, yields the attention score for h→t. : ; in, For a learnable parameter matrix, Indicates h embedding, Indicates t embedding, Indicates r-embedding; The attention score Perform a normalization operation to obtain normalized attention weights. : ; in, This represents the set of neighbors embedded in h.

6. The method according to claim 5, characterized in that, In step (9), based on the collaborative knowledge graph, multiple attention embedding propagation layers are stacked, and the entity embeddings obtained from each layer are concatted to obtain the final embedding representation of each node in the collaborative knowledge graph, specifically: ; ; in, It is the set of neighbors embedded in h. , They represent the first , layer h embedding, Indicates the first Layer t embedding; This is for the concat concatenation operation.

7. The method according to claim 6, characterized in that, In step (10), the InfoNCE function is specifically as follows: ; in Let cosine similarity function be used. Represents the correct direction. Represents a negative pair, where n indicates user embedding or item embedding. This is the temperature coefficient.

8. The method according to claim 7, characterized in that, In step (11), the final item embedding and the final user embedding are multiplied by an inner product to obtain the final prediction score, specifically: ; in, For predicted scores; The BPR loss function is specifically as follows: ; in It is an activation function, where U is the set of users. A collection of items that user u has interacted with. The predicted score represents the number of interactions between u and v in the dataset. This indicates the predicted score where there is no interaction between u and v' in the dataset; The final loss function is as follows: in, These are weighting coefficients used to control the influence of the two loss functions.

9. A knowledge graph recommendation system based on contrastive learning and collaborative signals, characterized in that, The knowledge graph recommendation system executes the knowledge graph recommendation method based on contrastive learning and collaborative signals as described in claim 1, including: a knowledge graph recommendation model construction module, a knowledge graph recommendation model training module, and an item recommendation module; The knowledge graph recommendation model building module constructs a knowledge graph recommendation model based on contrastive learning and collaborative signals. The knowledge graph recommendation model training module uses the historical interaction sequences of users and the knowledge information of items and knowledge entities in the acquired dataset to train the knowledge graph recommendation model based on contrastive learning and collaborative signals, thereby obtaining a trained knowledge graph recommendation model based on contrastive learning and collaborative signals. The project recommendation module obtains the historical interaction sequence of the user to be recommended and the knowledge information of the project and knowledge entities, and inputs the historical interaction sequence of the user to be recommended and the knowledge information of the project and knowledge entities into the trained knowledge graph recommendation model based on contrastive learning and collaborative signals to obtain a target recommendation list, and recommends the target recommendation list to the user.

10. A computer device, characterized in that, The device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any one of claims 1 to 8.