MKR

Reference:

Hongwei Wang et al. “Multi-Task Feature Learning for Knowledge Graph Enhanced Recommendation.” in WWW 2019.

Reference code:

https://github.com/hsientzucheng/MKR.PyTorch

class recbole.model.knowledge_aware_recommender.mkr.CrossCompressUnit(dim)[source]

Bases: torch.nn.modules.module.Module

This is Cross&Compress Unit for MKR model to model feature interactions between items and entities.

forward(inputs)[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.mkr.MKR(config, dataset)[source]

Bases: recbole.model.abstract_recommender.KnowledgeRecommender

MKR is a Multi-task feature learning approach for Knowledge graph enhanced Recommendation. It is a deep end-to-end framework that utilizes knowledge graph embedding task to assist recommendation task. The two tasks are associated by cross&compress units, which automatically share latent features and learn high-order interactions between items in recommender systems and entities in the knowledge graph.

calculate_kg_loss(interaction)[source]

Calculate the training loss for a batch data of KG.

calculate_rs_loss(interaction)[source]

Calculate the training loss for a batch data of RS.

forward(user_indices=None, item_indices=None, head_indices=None, relation_indices=None, tail_indices=None)[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.

input_type = 1
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