{"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/representing-long-range-context-for-graph-1","title":"Representing Long-Range Context for Graph Neural Networks with Global Attention","arxiv_id":"2201.08821","date":"2022-01-21","proceeding":"NeurIPS 2021 12","authors":["Zhanghao Wu","Paras Jain","Matthew A. Wright","Azalia Mirhoseini","Joseph E. Gonzalez","Ion Stoica"],"abstract":"Graph neural networks are powerful architectures for structured datasets. However, current methods struggle to represent long-range dependencies. Scaling the depth or width of GNNs is insufficient to broaden receptive fields as larger GNNs encounter optimization instabilities such as vanishing gradients and representation oversmoothing, while pooling-based approaches have yet to become as universally useful as in computer vision. In this work, we propose the use of Transformer-based self-attention to learn long-range pairwise relationships, with a novel \"readout\" mechanism to obtain a global graph embedding. Inspired by recent computer vision results that find position-invariant attention performant in learning long-range relationships, our method, which we call GraphTrans, applies a permutation-invariant Transformer module after a standard GNN module. This simple architecture leads to state-of-the-art results on several graph classification tasks, outperforming methods that explicitly encode graph structure. Our results suggest that purely-learning-based approaches without graph structure may be suitable for learning high-level, long-range relationships on graphs. Code for GraphTrans is available at https://github.com/ucbrise/graphtrans.","url_abs":"https://arxiv.org/abs/2201.08821v1","url_pdf":"https://arxiv.org/pdf/2201.08821v1.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":"representing-long-range-context-for-graph-1","repo_url":"https://github.com/ucbrise/graphtrans","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"graph-classification","task_name":"Graph Classification"},{"task_slug":"graph-embedding","task_name":"Graph Embedding"}],"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":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2201.08821","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2201.08821"}},"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":"deterministic:regex_extraction","url":"https://github.com/ucbrise/graphtrans","reach":null}],"summary":{"ran":6,"ran_draft_wrong":1,"unverified":7},"by_repo_kind":{"official":{"samples":14,"ran":7,"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":"5e621bc325bada93","entry":"Block","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5e621bc325bada93"}},{"code_sha256_prefix":"54f4034695672c97","entry":"CausalSelfAttention","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"54f4034695672c97"}},{"code_sha256_prefix":"47a9110e2ff3cb6d","entry":"MaskedOnlyTransformerEncoder","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"47a9110e2ff3cb6d"}},{"code_sha256_prefix":"a24d2e60a5f1edb0","entry":"MaskedTransformerBlock","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a24d2e60a5f1edb0"}},{"code_sha256_prefix":"44450c1a1d39195f","entry":"PositionalEncoding","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"44450c1a1d39195f"}},{"code_sha256_prefix":"a4bc443f49dd810c","entry":"TransformerNodeEncoder","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a4bc443f49dd810c"}},{"code_sha256_prefix":"cec619dc729ca927","entry":"pad_batch","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"cec619dc729ca927"}},{"code_sha256_prefix":"dff37bf121adcf54","entry":"BaseModel","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"dff37bf121adcf54"}},{"code_sha256_prefix":"de1fa9d2896a253e","entry":"GCNConv","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"de1fa9d2896a253e"}},{"code_sha256_prefix":"ca2f5cd1f82b9713","entry":"GINConv","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ca2f5cd1f82b9713"}},{"code_sha256_prefix":"4ac493315fba009f","entry":"GNNNodeEmbedding","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4ac493315fba009f"}},{"code_sha256_prefix":"58d376fe82ba1dc2","entry":"GNNTransformer","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"58d376fe82ba1dc2"}},{"code_sha256_prefix":"e6ce121697c42f5e","entry":"GNN_node","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e6ce121697c42f5e"}},{"code_sha256_prefix":"e4c5152d3248ee46","entry":"GNN_node_Virtualnode","repo":"ucbrise/graphtrans","repo_kind":"official","path":"models/gnn_transformer.py","file_url":"https://github.com/ucbrise/graphtrans/blob/HEAD/models/gnn_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e4c5152d3248ee46"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}