{"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/structure-aware-transformer-for-graph","title":"Structure-Aware Transformer for Graph Representation Learning","arxiv_id":"2202.03036","date":"2022-02-07","proceeding":null,"authors":["Dexiong Chen","Leslie O'Bray","Karsten Borgwardt"],"abstract":"The Transformer architecture has gained growing attention in graph representation learning recently, as it naturally overcomes several limitations of graph neural networks (GNNs) by avoiding their strict structural inductive biases and instead only encoding the graph structure via positional encoding. Here, we show that the node representations generated by the Transformer with positional encoding do not necessarily capture structural similarity between them. To address this issue, we propose the Structure-Aware Transformer, a class of simple and flexible graph Transformers built upon a new self-attention mechanism. This new self-attention incorporates structural information into the original self-attention by extracting a subgraph representation rooted at each node before computing the attention. We propose several methods for automatically generating the subgraph representation and show theoretically that the resulting representations are at least as expressive as the subgraph representations. Empirically, our method achieves state-of-the-art performance on five graph prediction benchmarks. Our structure-aware framework can leverage any existing GNN to extract the subgraph representation, and we show that it systematically improves performance relative to the base GNN model, successfully combining the advantages of GNNs and Transformers. Our code is available at https://github.com/BorgwardtLab/SAT.","url_abs":"https://arxiv.org/abs/2202.03036v3","url_pdf":"https://arxiv.org/pdf/2202.03036v3.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":"structure-aware-transformer-for-graph","repo_url":"https://github.com/borgwardtlab/sat","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"paper_slug":"structure-aware-transformer-for-graph","repo_url":"https://github.com/BorgwardtLab/SAT","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"paper_slug":"structure-aware-transformer-for-graph","repo_url":"https://github.com/borgwardtlab/pst","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"tasks":[{"task_slug":"emotion-recognition-in-conversation","task_name":"Emotion Recognition in Conversation"},{"task_slug":"graph-representation-learning","task_name":"Graph Representation Learning"},{"task_slug":"representation-learning","task_name":"Representation Learning"}],"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":"base","method_name":"BASE"},{"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":[{"leaderboard":"/sota/emotion-recognition-in-conversation-on","task":"Emotion Recognition in Conversation","dataset":"IEMOCAP","model":"SAMGN","rank_in_archive_order":10,"of":59,"metrics":{"Weighted-F1":"71.11"},"uses_additional_data":false},{"leaderboard":"/sota/graph-property-prediction-on-ogbg-code2","task":"Graph Property Prediction","dataset":"ogbg-code2","model":"SAT","rank_in_archive_order":4,"of":21,"metrics":{"Ext. data":"No","Number of params":"15734000","Test F1 score":"0.1937 ± 0.0028","Validation F1 score":"0.1773 ± 0.0023"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2202.03036","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2202.03036"}},"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/BorgwardtLab/SAT","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/borgwardtlab/sat","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/borgwardtlab/pst","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"summary":{"ran":1,"ran_honours":3,"unverified":5},"by_repo_kind":{"official":{"samples":2,"ran":2,"repositories":1},"listed":{"samples":7,"ran":2,"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":"2a127d3ae372d7bd","entry":"apply_rotary_pos_emb","repo":"borgwardtlab/pst","repo_kind":"listed","path":"pst/rotary_embedding.py","file_url":"https://github.com/borgwardtlab/pst/blob/HEAD/pst/rotary_embedding.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"2a127d3ae372d7bd"}},{"code_sha256_prefix":"324691a9739115fa","entry":"eval_epoch","repo":"borgwardtlab/sat","repo_kind":"official","path":"experiments/train_zinc.py","file_url":"https://github.com/borgwardtlab/sat/blob/HEAD/experiments/train_zinc.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"324691a9739115fa"}},{"code_sha256_prefix":"437c7011506995a3","entry":"rotate_half","repo":"borgwardtlab/pst","repo_kind":"listed","path":"pst/rotary_embedding.py","file_url":"https://github.com/borgwardtlab/pst/blob/HEAD/pst/rotary_embedding.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"437c7011506995a3"}},{"code_sha256_prefix":"ab698930f5477224","entry":"train_epoch","repo":"borgwardtlab/sat","repo_kind":"official","path":"experiments/train_zinc.py","file_url":"https://github.com/borgwardtlab/sat/blob/HEAD/experiments/train_zinc.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"ab698930f5477224"}},{"code_sha256_prefix":"e6346ac266435823","entry":"accuracy","repo":"borgwardtlab/pst","repo_kind":"listed","path":"pst/downstream/mlp.py","file_url":"https://github.com/borgwardtlab/pst/blob/HEAD/pst/downstream/mlp.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"e6346ac266435823"}},{"code_sha256_prefix":"a86103fee746fce2","entry":"get_model","repo":"borgwardtlab/pst","repo_kind":"listed","path":"pst/esm2.py","file_url":"https://github.com/borgwardtlab/pst/blob/HEAD/pst/esm2.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a86103fee746fce2"}},{"code_sha256_prefix":"34890f3c2b8599f9","entry":"to_dense_batch","repo":"borgwardtlab/pst","repo_kind":"listed","path":"pst/utils.py","file_url":"https://github.com/borgwardtlab/pst/blob/HEAD/pst/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"34890f3c2b8599f9"}},{"code_sha256_prefix":"59c49da00f1bc1d8","entry":"train_and_eval_linear","repo":"borgwardtlab/pst","repo_kind":"listed","path":"pst/downstream/mlp.py","file_url":"https://github.com/borgwardtlab/pst/blob/HEAD/pst/downstream/mlp.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"59c49da00f1bc1d8"}},{"code_sha256_prefix":"94a8734c22d5fd0f","entry":"unpad_dense_batch","repo":"borgwardtlab/pst","repo_kind":"listed","path":"pst/utils.py","file_url":"https://github.com/borgwardtlab/pst/blob/HEAD/pst/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"94a8734c22d5fd0f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}