MCCLK¶
- Reference:
Ding Zou et al. “Multi-level Cross-view Contrastive Learning for Knowledge-aware Recommender System.” in SIGIR 2022.
- Reference code:
- class recbole.model.knowledge_aware_recommender.mcclk.Aggregator(item_only=False, attention=True)[source]¶
Bases:
torch.nn.modules.module.Module
- calculate_sim_hrt(entity_emb_head, entity_emb_tail, relation_emb)[source]¶
The calculation method of attention weight here follows the code implementation of the author, which is slightly different from that described in the paper.
- forward(entity_emb, user_emb, relation_emb, edge_index, edge_type, inter_matrix)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool¶
- class recbole.model.knowledge_aware_recommender.mcclk.GraphConv(config, embedding_size, n_relations, edge_index, edge_type, inter_matrix, device)[source]¶
Bases:
torch.nn.modules.module.Module
Graph Convolutional Network
- build_adj(context, topk)[source]¶
Construct a k-Nearest-Neighbor item-item semantic graph.
- Returns
Sparse tensor of the normalized item-item matrix.
- forward(user_emb, entity_emb)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool¶
- class recbole.model.knowledge_aware_recommender.mcclk.MCCLK(config, dataset)[source]¶
Bases:
recbole.model.abstract_recommender.KnowledgeRecommender
MCCLK is a knowledge-based recommendation model. It focuses on the contrastive learning in KG-aware recommendation and proposes a novel multi-level cross-view contrastive learning mechanism. This model comprehensively considers three different graph views for KG-aware recommendation, including global-level structural view, local-level collaborative and semantic views. It hence performs contrastive learning across three views on both local and global levels, mining comprehensive graph feature and structure information in a self-supervised manner.
- calculate_loss(interaction)[source]¶
Calculate the training loss for a batch data.
- Parameters
interaction (Interaction) – Interaction class of the batch.
- Returns
Training loss, shape: []
- Return type
torch.Tensor
- forward()[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- full_sort_predict(interaction)[source]¶
full sort prediction function. Given users, calculate the scores between users and all candidate items.
- Parameters
interaction (Interaction) – Interaction class of the batch.
- Returns
Predicted scores for given users and all candidate items, shape: [n_batch_users * n_candidate_items]
- Return type
torch.Tensor
- input_type = 2¶
- predict(interaction)[source]¶
Predict the scores between users and items.
- Parameters
interaction (Interaction) – Interaction class of the batch.
- Returns
Predicted scores for given users and items, shape: [batch_size]
- Return type
torch.Tensor
- training: bool¶