Learning Intents behind Interactions with Knowledge Graph for Recommendation, WWW2021

Overview

Learning Intents behind Interactions with Knowledge Graph for Recommendation

This is our PyTorch implementation for the paper:

Xiang Wang, Tinglin Huang, Dingxian Wang, Yancheng Yuan, Zhenguang Liu, Xiangnan He and Tat-Seng Chua (2021). Learning Intents behind Interactions with Knowledge Graph for Recommendation. Paper in arXiv. In WWW'2021, Ljubljana, Slovenia, April 19-23, 2021.

Author: Dr. Xiang Wang (xiangwang at u.nus.edu) and Mr. Tinglin Huang (tinglin.huang at zju.edu.cn)

Introduction

Knowledge Graph-based Intent Network (KGIN) is a recommendation framework, which consists of three components: (1)user Intent modeling, (2)relational path-aware aggregation, (3)indepedence modeling.

Citation

If you want to use our codes and datasets in your research, please cite:

@inproceedings{KGIN2020,
  author    = {Xiang Wang and
              Tinglin Huang and 
              Dingxian Wang and
              Yancheng Yuan and
              Zhenguang Liu and
              Xiangnan He and
              Tat{-}Seng Chua},
  title     = {Learning Intents behind Interactions with Knowledge Graph for Recommendation},
  booktitle = {{WWW}},
  year      = {2021}
}

Environment Requirement

The code has been tested running under Python 3.6.5. The required packages are as follows:

  • pytorch == 1.5.0
  • numpy == 1.15.4
  • scipy == 1.1.0
  • sklearn == 0.20.0
  • torch_scatter == 2.0.5
  • networkx == 2.5

Reproducibility & Example to Run the Codes

To demonstrate the reproducibility of the best performance reported in our paper and faciliate researchers to track whether the model status is consistent with ours, we provide the best parameter settings (might be different for the custormized datasets) in the scripts, and provide the log for our trainings.

The instruction of commands has been clearly stated in the codes (see the parser function in utils/parser.py).

  • Last-fm dataset
python main.py --dataset last-fm --dim 64 --lr 0.0001 --sim_regularity 0.0001 --batch_size 1024 --node_dropout True --node_dropout_rate 0.5 --mess_dropout True --mess_dropout_rate 0.1 --gpu_id 0 --context_hops 3
  • Amazon-book dataset
python main.py --dataset amazon-book --dim 64 --lr 0.0001 --sim_regularity 0.00001 --batch_size 1024 --node_dropout True --node_dropout_rate 0.5 --mess_dropout True --mess_dropout_rate 0.1 --gpu_id 0 --context_hops 3
  • Alibaba-iFashion dataset
python main.py --dataset alibaba-fashion --dim 64 --lr 0.0001 --sim_regularity 0.0001 --batch_size 1024 --node_dropout True --node_dropout_rate 0.5 --mess_dropout True --mess_dropout_rate 0.1 --gpu_id 0 --context_hops 3

Important argument:

  • sim_regularity
    • It indicates the weight to control the independence loss.
    • 1e-4(by default), which uses 0.0001 to control the strengths of correlation.

Dataset

We provide three processed datasets: Amazon-book, Last-FM, and Alibaba-iFashion.

  • You can find the full version of recommendation datasets via Amazon-book, Last-FM, and Alibaba-iFashion.
  • We follow KB4Rec to preprocess Amazon-book and Last-FM datasets, mapping items into Freebase entities via title matching if there is a mapping available.
Amazon-book Last-FM Alibaba-ifashion
User-Item Interaction #Users 70,679 23,566 114,737
#Items 24,915 48,123 30,040
#Interactions 847,733 3,034,796 1,781,093
Knowledge Graph #Entities 88,572 58,266 59,156
#Relations 39 9 51
#Triplets 2,557,746 464,567 279,155
  • train.txt
    • Train file.
    • Each line is a user with her/his positive interactions with items: (userID and a list of itemID).
  • test.txt
    • Test file (positive instances).
    • Each line is a user with her/his positive interactions with items: (userID and a list of itemID).
    • Note that here we treat all unobserved interactions as the negative instances when reporting performance.
  • user_list.txt
    • User file.
    • Each line is a triplet (org_id, remap_id) for one user, where org_id and remap_id represent the ID of such user in the original and our datasets, respectively.
  • item_list.txt
    • Item file.
    • Each line is a triplet (org_id, remap_id, freebase_id) for one item, where org_id, remap_id, and freebase_id represent the ID of such item in the original, our datasets, and freebase, respectively.
  • entity_list.txt
    • Entity file.
    • Each line is a triplet (freebase_id, remap_id) for one entity in knowledge graph, where freebase_id and remap_id represent the ID of such entity in freebase and our datasets, respectively.
  • relation_list.txt
    • Relation file.
    • Each line is a triplet (freebase_id, remap_id) for one relation in knowledge graph, where freebase_id and remap_id represent the ID of such relation in freebase and our datasets, respectively.

Acknowledgement

Any scientific publications that use our datasets should cite the following paper as the reference:

@inproceedings{KGIN2020,
  author    = {Xiang Wang and
              Tinglin Huang and 
              Dingxian Wang and
              Yancheng Yuan and
              Zhenguang Liu and
              Xiangnan He and
              Tat{-}Seng Chua},
  title     = {Learning Intents behind Interactions with Knowledge Graph for Recommendation},
  booktitle = {{WWW}},
  year      = {2021}
}

Nobody guarantees the correctness of the data, its suitability for any particular purpose, or the validity of results based on the use of the data set. The data set may be used for any research purposes under the following conditions:

  • The user must acknowledge the use of the data set in publications resulting from the use of the data set.
  • The user may not redistribute the data without separate permission.
  • The user may not try to deanonymise the data.
  • The user may not use this information for any commercial or revenue-bearing purposes without first obtaining permission from us.
Comments
  • intent的embedding以及意图独立性时的参数等问题

    intent的embedding以及意图独立性时的参数等问题

    你好!感谢你们团队能提供代码供大家学习!这里有两个问题想问一下: ① 在论文中的ep,即意图的嵌入,应该是由关系嵌入计算得出的,但是在代码中是直接定义了一个latent_emb并直接使用,好像与文中不符(或者意图向量不是latent_emb?)。 ② 在计算意图独立性时,论文中是用已经得到的ep进行计算,但是代码里用来计算的是参数是disen_weight_att,我理解这个参数是wrp,即关系r到意图p的一个可训练参数,这里也和原文中有些不同。

    opened by 945168786 6
  • Two questions about sparse relational graph construction and IG aggregation

    Two questions about sparse relational graph construction and IG aggregation

    一、 我注意到在代码: adj = sp.coo_matrix((vals, (np_mat[:, 0], np_mat[:, 1])), shape=(n_nodes, n_nodes))中, np_mat[:, 0]np_mat[:, 1]是否也应当如处理cf图那样,需要加上n_users。users并未被remap到entities中去,稀疏矩阵的前n_users行与n_users列应当为users预留。 对比之前KGAT中数据预处理的实现K, K_inv = _np_mat2sp_adj(np.array(self.relation_dict[r_id]), row_pre=self.n_users, col_pre=self.n_users)

    不知道是否有理解错。

    二、 我注意到在代码 user_agg = user_agg * (disen_weight * score).sum(dim=1) + user_agg # [n_users, channel]中, user_embedding的计算公式是否与论文中的Eq[7]有所出入。 image 论文中描述的是user所对应的item与intent加权求和,而在代码中的实现,是否可以理解为先求和再加权。 以及最后+ user_agg是什么用意。 我理解的聚合应当在代码 entity_res_emb = torch.add(entity_res_emb, entity_emb) user_res_emb = torch.add(user_res_emb, user_emb)中实现了。

    希望得到您的解答与纠正。谢谢!

    opened by HuaYZhao 5
  • negative cor

    negative cor

    i run your code several times and always get negative cor num start training ... using time 496.1616, training loss at epoch 0: 298.6853, cor: -103918.234375 or ` start training ... using time 636.8174, training loss at epoch 0: 299.3976, cor: -103918.351562 +-------+-------------------+--------------------+--------------------+----------------------------------------------------------+----------------------------------------------------------+----------------------------------------------------------+----------------------------------------------------------+ | Epoch | training time | tesing time | Loss | recall | ndcg | precision | hit_ratio | +-------+-------------------+--------------------+--------------------+----------------------------------------------------------+----------------------------------------------------------+----------------------------------------------------------+----------------------------------------------------------+ | 1 | 636.8162143230438 | 137.00747871398926 | 194.09571838378906 | [0.07513288 0.09760893 0.11306548 0.12481185 0.13517161] | [0.06848064 0.07576022 0.08097082 0.08491058 0.08831252] | [0.02926674 0.02149495 0.01776641 0.01546985 0.01389799] | [0.26474582 0.34498854 0.39756429 0.43486379 0.46601035] | +-------+-------------------+--------------------+--------------------+----------------------------------------------------------+----------------------------------------------------------+----------------------------------------------------------+----------------------------------------------------------+

    using time 636.9025, training loss at epoch 2: 170.9751, cor: -113220.000000 using time 636.6866, training loss at epoch 3: 157.5762, cor: -113220.000000 using time 637.4699, training loss at epoch 4: 149.2337, cor: -113220.000000 `

    it seems something has error?

    opened by FloatingMaple 5
  • How to realize the equation (12) in your paper?

    How to realize the equation (12) in your paper?

    Hi, Huang. The process of Relational Path-aware Aggregation realized on line 25-50 in your code (KGIN.py), and then sum representations of user and item up as the final representations(equtation(13) in your paper) on line 202-203 in your code (KGIN.py). But I can't find the process of Capturing Relational Paths(the quation(12) in your paper). Where is this process implemented in your code?

    Thank you very much for reading my questions. Your paper is very helpful to me. I look forward to your reply.

    @huangtinglin

    opened by BlueGhostZ 4
  • Could you tell me the hardware information for the experiment?

    Could you tell me the hardware information for the experiment?

    Thank you very much for openning source. I'd like to ask about the hardware of your experiment (GPU, memory size, etc.). Looking forward to your reply.

    opened by BlueGhostZ 4
  • Questions for raw data to data

    Questions for raw data to data

    Thank you for adding the knowledge map to the original data, but I wonder if all the sequences of the test set and training set are sorted by timestamp? Can you provide code to process raw data or a timestamp for each interaction?

    opened by unknowed-ER 2
  • 怎么恢复保存的模型的参数

    怎么恢复保存的模型的参数

    您好!非常感谢您分享的代码 我注意到您的代码中有save的相关代码 """save weight""" if ret['recall'][0] == cur_best_pre_0 and args.save: torch.save(model.state_dict(), args.out_dir + 'model_' + args.dataset + '.ckpt') 但是我发现下一次训练的时候并没有加载保存的参数,请问您的代码中实现恢复模型的相关代码了吗?

    opened by XUPT-guoruihan 2
  • 实验结果

    实验结果

    想问一下作者,为什么实验的数据集是一样的,结果会如此不同,请问作者知道是什么原因吗?Knowledge graph convolutional networks for recommender systems,19年的文章,通常采取所有的items去除训练集的方式,实验的结果不在同一个量纲范围内。

    opened by data-ming-and-application 2
  • in the code latent_emb embedding has two ways?

    in the code latent_emb embedding has two ways?

    hi, when i see the code, i have Puzzled image in the paper, formula 7 and formula 8, ep why is not same in the code, why cal user intent att use a new init embedding?

    opened by wgchen 1
  • About user representation aggregation

    About user representation aggregation

    In the paper, user representation get from the Intenet Graph. Is IG just compose by user,intent,item (without entity about item)?

    And how to calculate high-order representation of user, like e_u^(3) ? First calculate high-order representation of item e_i_(_2), Then got e_u^(3) by equation (6)(7)(8) in paper?

    Thx reply .

    opened by FloatingMaple 1
  • Some questions about Lastfm datasets

    Some questions about Lastfm datasets

    I'm sorry to bother you! Could you please tell me which particular Last-FM data set you used in your paper? Is it the LFM-1B UGPdata set in the website link you gave? PS: The KGAT paper provides lastfm dataset address is https://grouplens.org/datasets/hetrec-2011/ Can the data of these two addresses be used?

    opened by HUE96yhz 1
  • Questions about the latent_emb.

    Questions about the latent_emb.

    What is the latent_emb used for? It is the user intent embedding? But shouldn't the user intent embedding be the disen_weight according to the defination in the paper? Look forward to your answer. Thank you!

    opened by Jill5 1
  • 训练过程报错“name 'test_user_set' is not defined”

    训练过程报错“name 'test_user_set' is not defined”

    您好,最近在学习该工作的代码,通过调用给出的命令行参数,训练过程中evaluate.py文件的test_one_user(x)函数,在“user_pos_test = test_user_set[u]”处报错“name 'test_user_set' is not defined”。调试了一段时间没有找到出错的原因,想请问一下您是否知道原因?

    opened by HFUTZWJ 8
Owner
A postgraduate student
null
Neural Magic Eye: Learning to See and Understand the Scene Behind an Autostereogram, arXiv:2012.15692.

Neural Magic Eye Preprint | Project Page | Colab Runtime Official PyTorch implementation of the preprint paper "NeuralMagicEye: Learning to See and Un

Zhengxia Zou 56 Jul 15, 2022
Behind the Curtain: Learning Occluded Shapes for 3D Object Detection

Behind the Curtain: Learning Occluded Shapes for 3D Object Detection Acknowledgement We implement our model, BtcDet, based on [OpenPcdet 0.3.0]. Insta

Qiangeng Xu 163 Dec 19, 2022
Recommendationsystem - Movie-recommendation - matrixfactorization colloborative filtering recommendation system user

recommendationsystem matrixfactorization colloborative filtering recommendation

kunal jagdish madavi 1 Jan 1, 2022
[CIKM 2019] Code and dataset for "Fi-GNN: Modeling Feature Interactions via Graph Neural Networks for CTR Prediction"

FiGNN for CTR prediction The code and data for our paper in CIKM2019: Fi-GNN: Modeling Feature Interactions via Graph Neural Networks for CTR Predicti

Big Data and Multi-modal Computing Group, CRIPAC 75 Dec 30, 2022
SkipGNN: Predicting Molecular Interactions with Skip-Graph Networks (Scientific Reports)

SkipGNN: Predicting Molecular Interactions with Skip-Graph Networks Molecular interaction networks are powerful resources for the discovery. While dee

Kexin Huang 49 Oct 15, 2022
A graph neural network (GNN) model to predict protein-protein interactions (PPI) with no sample features

A graph neural network (GNN) model to predict protein-protein interactions (PPI) with no sample features

null 2 Jul 25, 2022
Predicting lncRNA–protein interactions based on graph autoencoders and collaborative training

Predicting lncRNA–protein interactions based on graph autoencoders and collaborative training Code for our paper "Predicting lncRNA–protein interactio

zhanglabNKU 1 Nov 29, 2022
A PoC Corporation Relationship Knowledge Graph System on top of Nebula Graph.

Corp-Rel is a PoC of Corpartion Relationship Knowledge Graph System. It's built on top of the Open Source Graph Database: Nebula Graph with a dataset

Wey Gu 20 Dec 11, 2022
Codes for SIGIR'22 Paper 'On-Device Next-Item Recommendation with Self-Supervised Knowledge Distillation'

OD-Rec Codes for SIGIR'22 Paper 'On-Device Next-Item Recommendation with Self-Supervised Knowledge Distillation' Paper, saved teacher models and Andro

Xin Xia 11 Nov 22, 2022
Tensorflow implementation for Self-supervised Graph Learning for Recommendation

If the compilation is successful, the evaluator of cpp implementation will be called automatically. Otherwise, the evaluator of python implementation will be called.

null 152 Jan 7, 2023
[IJCAI-2021] A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation"

DataFree A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation" Authors: Gongfa

ZJU-VIPA 47 Jan 9, 2023
TF2 implementation of knowledge distillation using the "function matching" hypothesis from the paper Knowledge distillation: A good teacher is patient and consistent by Beyer et al.

FunMatch-Distillation TF2 implementation of knowledge distillation using the "function matching" hypothesis from the paper Knowledge distillation: A g

Sayak Paul 67 Dec 20, 2022
Source Code for our paper: Understand me, if you refer to Aspect Knowledge: Knowledge-aware Gated Recurrent Memory Network

KaGRMN-DSG_ABSA This repository contains the PyTorch source Code for our paper: Understand me, if you refer to Aspect Knowledge: Knowledge-aware Gated

XingBowen 4 May 20, 2022
A sample pytorch Implementation of ACL 2021 research paper "Learning Span-Level Interactions for Aspect Sentiment Triplet Extraction".

Span-ASTE-Pytorch This repository is a pytorch version that implements Ali's ACL 2021 research paper Learning Span-Level Interactions for Aspect Senti

来自丹麦的天籁 10 Dec 6, 2022
Leveraging Two Types of Global Graph for Sequential Fashion Recommendation, ICMR 2021

This is the repo for the paper: Leveraging Two Types of Global Graph for Sequential Fashion Recommendation Requirements OS: Ubuntu 16.04 or higher ver

Yujuan Ding 10 Oct 10, 2022
Code for KDD'20 "An Efficient Neighborhood-based Interaction Model for Recommendation on Heterogeneous Graph"

Heterogeneous INteract and aggreGatE (GraphHINGE) This is a pytorch implementation of GraphHINGE model. This is the experiment code in the following w

Jinjiarui 69 Nov 24, 2022
Codes for CIKM'21 paper 'Self-Supervised Graph Co-Training for Session-based Recommendation'.

COTREC Codes for CIKM'21 paper 'Self-Supervised Graph Co-Training for Session-based Recommendation'. Requirements: Python 3.7, Pytorch 1.6.0 Best Hype

Xin Xia 42 Dec 9, 2022
Python Implementation of algorithms in Graph Mining, e.g., Recommendation, Collaborative Filtering, Community Detection, Spectral Clustering, Modularity Maximization, co-authorship networks.

Graph Mining Author: Jiayi Chen Time: April 2021 Implemented Algorithms: Network: Scrabing Data, Network Construbtion and Network Measurement (e.g., P

Jiayi Chen 3 Mar 3, 2022
This is the official Pytorch-version code of FlatGCN (Flattened Graph Convolutional Networks for Recommendation).

FlatGCN This is the official Pytorch-version code of FlatGCN (Flattened Graph Convolutional Networks for Recommendation, submitted to ICASSP2022). Req

Dreamer 2 Aug 9, 2022