{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/heterogeneous-graph-transformer","title":"Heterogeneous Graph Transformer","arxiv_id":"2003.01332","date":"2020-03-03","proceeding":null,"authors":["Ziniu Hu","Yuxiao Dong","Kuansan Wang","Yizhou Sun"],"abstract":"Recent years have witnessed the emerging success of graph neural networks (GNNs) for modeling structured data. However, most GNNs are designed for homogeneous graphs, in which all nodes and edges belong to the same types, making them infeasible to represent heterogeneous structures. In this paper, we present the Heterogeneous Graph Transformer (HGT) architecture for modeling Web-scale heterogeneous graphs. To model heterogeneity, we design node- and edge-type dependent parameters to characterize the heterogeneous attention over each edge, empowering HGT to maintain dedicated representations for different types of nodes and edges. To handle dynamic heterogeneous graphs, we introduce the relative temporal encoding technique into HGT, which is able to capture the dynamic structural dependency with arbitrary durations. To handle Web-scale graph data, we design the heterogeneous mini-batch graph sampling algorithm---HGSampling---for efficient and scalable training. Extensive experiments on the Open Academic Graph of 179 million nodes and 2 billion edges show that the proposed HGT model consistently outperforms all the state-of-the-art GNN baselines by 9%--21% on various downstream tasks.","url_abs":"https://arxiv.org/abs/2003.01332v1","url_pdf":"https://arxiv.org/pdf/2003.01332v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"heterogeneous-graph-transformer","repo_url":"https://github.com/acbull/pyHGT","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"heterogeneous-graph-transformer","repo_url":"https://github.com/acbull/pyHGT/tree/master/ogbn-mag","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"heterogeneous-graph-transformer","repo_url":"https://github.com/syyunn/node2vec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"heterogeneous-graph-transformer","repo_url":"https://github.com/dmlc/dgl/tree/master/examples/pytorch/hgt","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"graph-sampling","task_name":"Graph Sampling"},{"task_slug":"heterogeneous-node-classification","task_name":"Heterogeneous Node Classification"},{"task_slug":"node-property-prediction","task_name":"Node Property Prediction"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[{"slug":"oag-venue","name":"OAG-Venue","full_name":""}],"methods_introduced":[],"results":[{"leaderboard":"/sota/heterogeneous-node-classification-on-acm","task":"Heterogeneous Node Classification","dataset":"ACM (Heterogeneous Node Classification)","model":"HGT","rank_in_archive_order":8,"of":11,"metrics":{" Macro-F1":"91.12","Micro-F1":"91.00"},"uses_additional_data":false},{"leaderboard":"/sota/heterogeneous-node-classification-on-dblp-2","task":"Heterogeneous Node Classification","dataset":"DBLP (Heterogeneous Node Classification)","model":"HGT","rank_in_archive_order":6,"of":11,"metrics":{" Macro-F1":"93.01","Micro-F1":"93.49"},"uses_additional_data":false},{"leaderboard":"/sota/heterogeneous-node-classification-on-freebase","task":"Heterogeneous Node Classification","dataset":"Freebase (Heterogeneous Node Classification)","model":"HGT","rank_in_archive_order":6,"of":9,"metrics":{" Macro-F1":"29.28","Micro-F1":"60.51"},"uses_additional_data":false},{"leaderboard":"/sota/heterogeneous-node-classification-on-imdb","task":"Heterogeneous Node Classification","dataset":"IMDB (Heterogeneous Node Classification)","model":"HGT","rank_in_archive_order":5,"of":11,"metrics":{" Macro-F1":"63.00","Micro-F1":"67.20"},"uses_additional_data":false},{"leaderboard":"/sota/heterogeneous-node-classification-on-oag-l1","task":"Heterogeneous Node Classification","dataset":"OAG-L1-Field","model":"HGT","rank_in_archive_order":5,"of":5,"metrics":{"MRR":"82.16","NDCG":"84.13"},"uses_additional_data":false},{"leaderboard":"/sota/heterogeneous-node-classification-on-oag","task":"Heterogeneous Node Classification","dataset":"OAG-Venue","model":"HGT","rank_in_archive_order":4,"of":5,"metrics":{"MRR":"29.82","NDCG":"47.31"},"uses_additional_data":false},{"leaderboard":"/sota/node-property-prediction-on-ogbn-mag","task":"Node Property Prediction","dataset":"ogbn-mag","model":"HGT (TransE embs)","rank_in_archive_order":27,"of":39,"metrics":{"Ext. data":"No","Number of params":"26877657","Test Accuracy":"0.4982 ± 0.0013","Validation Accuracy":"0.5124 ± 0.0046"},"uses_additional_data":false},{"leaderboard":"/sota/node-property-prediction-on-ogbn-mag","task":"Node Property Prediction","dataset":"ogbn-mag","model":"HGT (LADIES Sample)","rank_in_archive_order":29,"of":39,"metrics":{"Ext. data":"No","Number of params":"21173389","Test Accuracy":"0.4927 ± 0.0061","Validation Accuracy":"0.4989 ± 0.0047"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2003.01332","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2003.01332"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/syyunn/node2vec","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/dmlc/dgl/tree/master/examples/pytorch/hgt","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/acbull/pyHGT","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/acbull/pyHGT/tree/master/ogbn-mag","reach":null}],"summary":{"ran":1,"unverified":5},"by_repo_kind":{"official":{"samples":6,"ran":1,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"c6acd3e400fc2676","entry":"get_n_params","repo":"acbull/pyHGT","repo_kind":"official","path":"ogbn-mag/pyHGT/utils.py","file_url":"https://github.com/acbull/pyHGT/blob/HEAD/ogbn-mag/pyHGT/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c6acd3e400fc2676"}},{"code_sha256_prefix":"98dab8054ae3ccee","entry":"dcg_at_k","repo":"acbull/pyHGT","repo_kind":"official","path":"pyHGT/utils.py","file_url":"https://github.com/acbull/pyHGT/blob/HEAD/pyHGT/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"98dab8054ae3ccee"}},{"code_sha256_prefix":"b7094768238a0bdb","entry":"mean_reciprocal_rank","repo":"acbull/pyHGT","repo_kind":"official","path":"pyHGT/utils.py","file_url":"https://github.com/acbull/pyHGT/blob/HEAD/pyHGT/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b7094768238a0bdb"}},{"code_sha256_prefix":"46e47a2c4cf98c1f","entry":"ndcg_at_k","repo":"acbull/pyHGT","repo_kind":"official","path":"pyHGT/utils.py","file_url":"https://github.com/acbull/pyHGT/blob/HEAD/pyHGT/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"46e47a2c4cf98c1f"}},{"code_sha256_prefix":"391651c3e47960ca","entry":"renamed_load","repo":"acbull/pyHGT","repo_kind":"official","path":"pyHGT/data.py","file_url":"https://github.com/acbull/pyHGT/blob/HEAD/pyHGT/data.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"391651c3e47960ca"}},{"code_sha256_prefix":"f8a36842e8bfa621","entry":"to_torch","repo":"acbull/pyHGT","repo_kind":"official","path":"pyHGT/data.py","file_url":"https://github.com/acbull/pyHGT/blob/HEAD/pyHGT/data.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f8a36842e8bfa621"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}