{"id":29248830,"url":"https://github.com/hkuds/hgcl","last_synced_at":"2025-07-04T00:09:14.810Z","repository":{"id":141205059,"uuid":"582364740","full_name":"HKUDS/HGCL","owner":"HKUDS","description":"[WSDM'2023] \"HGCL: Heterogeneous Graph Contrastive Learning for Recommendation\"","archived":false,"fork":false,"pushed_at":"2024-11-04T12:27:10.000Z","size":35321,"stargazers_count":92,"open_issues_count":5,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-04T13:25:46.352Z","etag":null,"topics":["collaborative-filtering","graph-contrastive-learning","graph-neural-networks","heterogeneous-graph-learning","recommendation","self-supervised-learning"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2303.00995","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":"2022-12-26T15:38:15.000Z","updated_at":"2024-11-04T12:27:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"89fee835-b01a-48e9-a265-8e6a72c22d9b","html_url":"https://github.com/HKUDS/HGCL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HKUDS/HGCL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FHGCL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FHGCL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FHGCL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FHGCL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HKUDS","download_url":"https://codeload.github.com/HKUDS/HGCL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FHGCL/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","graph-contrastive-learning","graph-neural-networks","heterogeneous-graph-learning","recommendation","self-supervised-learning"],"created_at":"2025-07-04T00:09:12.564Z","updated_at":"2025-07-04T00:09:14.601Z","avatar_url":"https://github.com/HKUDS.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HGCL\n ![image](https://user-images.githubusercontent.com/63046458/218037666-720fd450-bdbd-496d-b9e6-fd382eb58073.png)\n\n\nTorch version is available now!\nThis repository contains pyTorch code and datasets for the paper: **Heterogeneous Graph Contrastive Learning for Recommendation**, *Paper in arXiv, Paper in ACM. In WSDM'23, Singapore, 2023\n\n### Inroduction  \n**Heterogeneous Graph Contrastive Learning for Recommendation (HGCL)** advances the recommender system with heterogeneous graph contrastive learning. HGCL integrates meta network with contrastive learning for adaptive augmentation to enable user-specific and item-specific knowledge transfer. It advances graph contrastive learning with customized cross-view augmentation.\n\n### Environment\nThe codes of HGCL are implemented and tested under the following development environment: \npyTorch:\n\tPython=3.7.10\n\tTorch=1.8.1\n\tNumpy=1.20.3\n\tScipy=1.6.2\n### Datasets\nWe utilized three datasets to evaluate HGCL: *Yelp*, *Epinions*, and *CiaoDVD*. Following the common settings of implicit feedback, if user u_ihas rated item v_j, then the element (u_i,v_j) is set as 1, otherwise 0. We filtered out users and items with too few interactions. The datasets are divided into training set and testing set by 1: (n-1).\n\nYou can download all three datasets from [Google Drive](https://drive.google.com/drive/folders/1s6LGibPnal6gMld5t63aK4J7hnVkNeDs?usp=sharing). \nFeel free to fire an issue if this link doesn't work.\n\n### How to Run the Code\nPlease unzip the datasets first. Also you need to create the History/ and the Models/ directories. The command to train HGCL on the Yelp/Epinions/CiaoDVD dataset is as follows. The commands specify the hyperparameter settings that generate the reported results in the paper.\n* Yelp\n```\npython main.py --dataset Yelp --ssl_temp 0.5 --ssl_ureg 0.06 --ssl_ireg 0.07 --lr 0.058 --reg 0.05 --ssl_beta 0.45 --rank 3\n```\n* Epinions\n```\npython main.py --dataset Epinions --ssl_temp 0.5 --ssl_ureg 0.04 --ssl_ireg 0.05 --lr 0.055 --reg 0.043 --ssl_beta 0.32 --rank 3\n```\n* CiaoDVD\n```\npython main.py --dataset CiaoDVD --ssl_temp 0.6 --ssl_ureg 0.04 --ssl_ireg 0.05 --lr 0.055 --reg 0.065 --ssl_beta 0.3 --rank 3\n```\n\n\n### Important arguments\n* `--ssl_temp` It is the temperature factor in the InfoNCE loss in our contrastive learning. The value is selected from {0.1, 0.3, 0.45, 0.5, 0.55,0.6, 0.65}.\n* `--ssl_ureg, ssl_ireg` They are the weights for the contrastive learning loss of user’s and item’s aspect respectively. The value of this pair are tuned from \n{(3e-2,4e-2),( 4e-2,5e-2),( 5e-2,6e-2), (6e-2,7e-2),( 7e-2,8e-2)}.\n* `--lr` The learning rate of the mode. We tuned it from\n{1e-2, 3e-2, 4e-2, 4.5e-2, 5e-2, 5.5e-2, 6e-2}.\n* `--Reg` It is the weight for weight-decay regularization. We tune this hyperparameter from the set {1e-2, 3e-2, 4.3e-2, 5e-2, 6e-2, 6.5e-2, 6.8e-2}.\n* `--ssl_beta` This is the balance cofficient of the total contrastive loss , which is tuned from{0.2, 0.27, 0.3, 0.32, 0.4, 0.45, 0.48, 0.5}.\n* `--rank` A hyperparameter of the dimension of low rank matrix decomposition, This parameter is recommended to tune from{1, 2, 3, 4, 5}.\n### Experimental Results\nPerformance comparison of all methods on different datasets in terms of *NDCG* and *HR*:\n\u003cp\u003e\n  \u003cimg src=\"imgs/results.jpg\" width=\"1000\"\u003e\n  \u003cbr /\u003e\n\u003c/p\u003e\n\n## Citation\nIf you find this work helpful to your research, please kindly consider citing our paper.\n```\n@inproceedings{chen2023heterogeneous,\n  title={Heterogeneous graph contrastive learning for recommendation},\n  author={Chen, Mengru and Huang, Chao and Xia, Lianghao and Wei, Wei and Xu, Yong and Luo, Ronghua},\n  booktitle={Proceedings of the Sixteenth ACM International Conference on Web Search and Data Mining},\n  pages={544--552},\n  year={2023}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkuds%2Fhgcl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkuds%2Fhgcl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkuds%2Fhgcl/lists"}