{"id":29248886,"url":"https://github.com/hkuds/gformer","last_synced_at":"2025-07-04T00:09:24.820Z","repository":{"id":159164522,"uuid":"634403685","full_name":"HKUDS/GFormer","owner":"HKUDS","description":"[SIGIR'2023] \"GFormer: Graph Transformer for Recommendation\"","archived":false,"fork":false,"pushed_at":"2024-06-10T06:41:40.000Z","size":7793,"stargazers_count":50,"open_issues_count":2,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-10T08:38:56.122Z","etag":null,"topics":["collaborative-filtering","graph-neural-networks","graph-representation-learning","graph-transformer","recommender-systems"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2306.02330","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","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":"LICENSE.txt","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-04-30T02:12:26.000Z","updated_at":"2024-06-10T06:41:44.000Z","dependencies_parsed_at":"2023-11-08T05:46:47.860Z","dependency_job_id":"8f51ebb2-6d85-48c1-8d6b-927cf56d8011","html_url":"https://github.com/HKUDS/GFormer","commit_stats":null,"previous_names":["hkuds/gformer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HKUDS/GFormer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FGFormer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FGFormer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FGFormer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FGFormer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HKUDS","download_url":"https://codeload.github.com/HKUDS/GFormer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HKUDS%2FGFormer/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-neural-networks","graph-representation-learning","graph-transformer","recommender-systems"],"created_at":"2025-07-04T00:09:17.522Z","updated_at":"2025-07-04T00:09:24.705Z","avatar_url":"https://github.com/HKUDS.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graph Transformer for Recommendation\nThis is the PyTorch implementation for GFormer model proposed in this paper:\n\n \u003e**Graph Transformer for Recommendation**  \n \u003e Chaoliu Li, Lianghao Xia, Xubin Ren, Yaowen Ye, Yong Xu, Chao Huang*\\\n \u003e*SIGIR 2023*\n \n## Introduction\nThis paper presents a novel approach to representation learning in recommender systems by integrating generative self-supervised learning with graph transformer architecture. We highlight the importance of high-quality data augmentation with relevant self-supervised pretext tasks for improving performance. Towards this end, we propose a new approach that automates the self-supervision augmentation process through a rationale-aware generative SSL that distills informative user-item interaction patterns. The proposed recommender with Graph Transformer (GFormer) that offers parameterized collaborative rationale discovery for selective augmentation while preserving global-aware user-item relationships. In GFormer, we allow the rationale-aware SSL to inspire graph collaborative filtering with task-adaptive invariant rationalization in graph transformer. The experimental results reveal that our GFormer has the capability to consistently improve the performance over baselines on different datasets. Several in-depth experiments further investigate the invariant rationale-aware augmentation from various aspects.\n\n\u003cimg src='fig/framework.jpg'\u003e\n\n## Environment\nThe codes of GFormer are implemented and tested under the following development environment:\n  \n\u003cp\u003ePyTorch:\n\n\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003epython=3.8.13\u003c/li\u003e\n\u003cli\u003etorch=1.9.1\u003c/li\u003e\n\u003cli\u003enumpy=1.19.2\u003c/li\u003e\n\u003cli\u003escipy=1.9.0\u003c/li\u003e\n\u003cli\u003enetworkx = 2.8.6\u003c/li\u003e\n\u003c/ul\u003e\n  \n## Datasets\nWe utilize three datasets for evaluating GFormer: \u003ci\u003eYelp, Ifashion, \u003c/i\u003eand \u003ci\u003eLastfm\u003c/i\u003e. Note that compared to the data used in our previous works, in this work we utilize a more sparse version of the three datasets, to increase the difficulty of recommendation task. Our evaluation follows the common implicit feedback paradigm. The datasets are divided into training set, validation set and test set by 70:5:25.\n| Dataset | \\# Users | \\# Items | \\# Interactions | Interaction Density |\n|:-------:|:--------:|:--------:|:---------------:|:-------:|\n|Yelp   |$42,712$|$26,822$|$182,357$|$1.6\\times 10^{-4}$|\n|Ifashion|$31,668$|$38,048$|$618,629$|$5.1\\times 10^{-4}$|\n|LastFm |$1,889$|$15,376$|$51,987$|$1.8\\times 10^{-3}$|\n\n\n## How to Run the Code\nPlease unzip the datasets first. Also you need to create the \u003ccode\u003eHistory/\u003c/code\u003e and the \u003ccode\u003eModels/\u003c/code\u003e directories. The command to train GFormer on the Yelp/Ifashion/Lastfm dataset is as follows. The commands specify the hyperparameter settings that generate the reported results in the paper.\n\n\u003cul\u003e\n\u003cli\u003eYelp\u003cpre\u003e\u003ccode\u003epython Main.py --data yelp --reg 1e-4 --ssl_reg 1 --gcn 3 --ctra 1e-3 --b2 1 --pnn 1\u003c/code\u003e\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003eIfashion\u003cpre\u003e\u003ccode\u003epython Main.py --data ifashion --reg 1e-5 --ssl_reg 1 --gcn 2 --ctra 1e-3 --b2 1 --pnn 1\u003c/code\u003e\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003eLastfm\u003cpre\u003e\u003ccode\u003epython Main.py --data lastfm --reg 1e-4 --ssl_reg 1 --gcn 2 --ctra 1e-3 --b2 1e-6 --pnn2\u003c/code\u003e\u003c/pre\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/body\u003e\u003c/html\u003e\n\n## Citing our paper\nPlease kindly cite our paper if you find this paper and the codes helpful.\n```\n@inproceedings{Li_2023, series={SIGIR ’23},\n   title={Graph Transformer for Recommendation},\n   url={http://dx.doi.org/10.1145/3539618.3591723},\n   DOI={10.1145/3539618.3591723},\n   booktitle={Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval},\n   publisher={ACM},\n   author={Li, Chaoliu and Xia, Lianghao and Ren, Xubin and Ye, Yaowen and Xu, Yong and Huang, Chao},\n   year={2023},\n   month=jul, collection={SIGIR ’23} }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkuds%2Fgformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkuds%2Fgformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkuds%2Fgformer/lists"}