{"id":29248816,"url":"https://github.com/hkuds/diffkg","last_synced_at":"2025-07-04T00:09:13.917Z","repository":{"id":209049137,"uuid":"723052394","full_name":"HKUDS/DiffKG","owner":"HKUDS","description":"[WSDM'2024 Oral] \"DiffKG: Knowledge Graph Diffusion Model for Recommendation\"","archived":false,"fork":false,"pushed_at":"2024-10-24T11:26:44.000Z","size":21698,"stargazers_count":87,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-15T15:48:00.435Z","etag":null,"topics":["collaborative-filtering","diffusion-models","graph-neural-networks","knowledge-graph","recommendation"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2312.16890","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HKUDS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-24T15:06:59.000Z","updated_at":"2024-11-06T16:52:53.000Z","dependencies_parsed_at":"2024-01-02T08:47:02.595Z","dependency_job_id":"5b07084a-55be-45bc-b07d-2dc4f29caec0","html_url":"https://github.com/HKUDS/DiffKG","commit_stats":null,"previous_names":["hkuds/diffkg"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HKUDS/DiffKG","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FDiffKG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FDiffKG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FDiffKG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FDiffKG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HKUDS","download_url":"https://codeload.github.com/HKUDS/DiffKG/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FDiffKG/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421915,"owners_count":23464052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborative-filtering","diffusion-models","graph-neural-networks","knowledge-graph","recommendation"],"created_at":"2025-07-04T00:09:12.329Z","updated_at":"2025-07-04T00:09:13.717Z","avatar_url":"https://github.com/HKUDS.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DiffKG: Knowledge Graph Diffusion Model for Recommendation\n\nThis is the PyTorch implementation for **DiffKG** proposed in the paper [**DiffKG: Knowledge Graph Diffusion Model for Recommendation**](https://arxiv.org/pdf/2312.16890.pdf), which is accepted by WSDM 2024 Oral. \n\n\u003e Yangqin Jiang, Yuhao Yang, Lianghao Xia, and Chao Huang. 2024. DiffKG: Knowledge Graph Diffusion Model for Recommendation. In Proceedings of the 17th ACM International Conference on Web Search and Data Mining (WSDM ’24), March 4–8, 2024, Merida, Mexico. ACM, New York, NY, USA, 9 pages.\n\n\u003cimg src=\"./DiffKG.png\" style=\"zoom:30%;\" /\u003e\n\nIn this paper, we propose a novel knowledge graph diffusion model for recommendation, referred to as DiffKG. Our framework integrates a generative diffusion model with a data augmentation paradigm, enabling robust knowledge graph representation learning. This integration facilitates a better alignment between knowledge-aware item semantics and collaborative relation modeling. Moreover, we introduce a collaborative knowledge graph convolution mechanism that incorporates collaborative signals reflecting user-item interaction patterns, guiding the knowledge graph diffusion process.\n\n## 📝 Environment\n\nWe develop our codes in the following environment:\n\n- python==3.9.13\n- numpy==1.23.1\n- torch==1.11.0\n- scipy==1.9.1\n\n## 📚 Datasets\n\n| Statistics          | Last-FM         | MIND            | Alibaba-iFashion |\n| ------------------- | --------------- | --------------- | ---------------- |\n| # Users             | 23,566          | 100,000         | 114,737          |\n| # Items             | 48,123          | 30,577          | 30,040           |\n| # Interactions      | 3,034,796       | 2,975,319       | 1,781,093        |\n| # Density           | 2.7 × $10^{-3}$ | 9.7 × $10^{-4}$ | 5.2 × $10^{-4}$  |\n| **Knowledge Graph** |                 |                 |                  |\n| # Entities          | 58,266          | 24,733          | 59,156           |\n| # Relations         | 9               | 512             | 51               |\n| # Triplets          | 464,567         | 148,568         | 279,155          |\n\n## 🚀 How to run the codes\n\nThe command lines to train DiffKG on the three datasets are as below. The un-specified hyperparameters in the commands are set as default.\n\n- Last-FM\n\n```python\npython Main.py --data lastfm --reg 1e-5 --mess_dropout_rate 0.2 --layer_num_kg 2 --res_lambda 0 --triplet_num -1 --cl_pattern 1 --keepRate 0.1 --e_loss 0.01\n```\n\n- MIND\n\n```python\npython Main.py --data mind --e_loss 0.1 --temp 1 --ssl_reg 1 --mess_dropout_rate 0.2 --res_lambda 1\n```\n\n- Alibaba-iFashion\n\n```python\npython Main.py --data alibaba --reg 1e-6 --epoch 50 --ssl_reg 1 --temp 1\n```\n\n## 🚀 Run DiffKG via SSLRec\n\nDiffKG has been integrated into [SSLRec](https://github.com/HKUDS/SSLRec)! SSLRec is a PyTorch-based open-source deep learning framework for recommender systems enhanced by self-supervised learning techniques. With SSLRec, you can easily compare our DiffKG with other research works in the field of KG-enhanced recommendation systems.\n\n## 👉 Code Structure\n\n```\n.\n├── README.md\n├── DiffKG.png\n├── performance.png\n├── Main.py\n├── Model.py\n├── Params.py\n├── DataHandler.py\n├── Utils\n│   ├── TimeLogger.py\n│   └── Utils.py\n└── Datasets\n    ├── alibaba\n    │   ├── trnMat.pkl\n    │   ├── tstMat.pkl\n    │   └── kg.txt\n    ├── lastFM\n    │   ├── trnMat.pkl\n    │   ├── tstMat.pkl\n    │   └── kg.txt\n    └── mind\n        ├── trnMat.pkl\n        ├── tstMat.pkl\n        └── kg.txt\n```\n\n## 🎯 Experimental Results\n\nPerformance comparison of baselines on different datasets in terms of Recall@20 and NDCG@20:\n\n![](./performance.png)\n\n## 🌟 Citation\n\nIf you find this work helpful to your research, please kindly consider citing our paper.\n\n```\n@inproceedings{jiang2024diffkg,\n  title={Diffkg: Knowledge graph diffusion model for recommendation},\n  author={Jiang, Yangqin and Yang, Yuhao and Xia, Lianghao and Huang, Chao},\n  booktitle={Proceedings of the 17th ACM International Conference on Web Search and Data Mining},\n  pages={313--321},\n  year={2024}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkuds%2Fdiffkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkuds%2Fdiffkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkuds%2Fdiffkg/lists"}