{"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/sg-former-self-guided-transformer-with","title":"SG-Former: Self-guided Transformer with Evolving Token Reallocation","arxiv_id":"2308.12216","date":"2023-08-23","proceeding":"ICCV 2023 1","authors":["Sucheng Ren","Xingyi Yang","Songhua Liu","Xinchao Wang"],"abstract":"Vision Transformer has demonstrated impressive success across various vision tasks. However, its heavy computation cost, which grows quadratically with respect to the token sequence length, largely limits its power in handling large feature maps. To alleviate the computation cost, previous works rely on either fine-grained self-attentions restricted to local small regions, or global self-attentions but to shorten the sequence length resulting in coarse granularity. In this paper, we propose a novel model, termed as Self-guided Transformer~(SG-Former), towards effective global self-attention with adaptive fine granularity. At the heart of our approach is to utilize a significance map, which is estimated through hybrid-scale self-attention and evolves itself during training, to reallocate tokens based on the significance of each region. Intuitively, we assign more tokens to the salient regions for achieving fine-grained attention, while allocating fewer tokens to the minor regions in exchange for efficiency and global receptive fields. The proposed SG-Former achieves performance superior to state of the art: our base size model achieves \\textbf{84.7\\%} Top-1 accuracy on ImageNet-1K, \\textbf{51.2mAP} bbAP on CoCo, \\textbf{52.7mIoU} on ADE20K surpassing the Swin Transformer by \\textbf{+1.3\\% / +2.7 mAP/ +3 mIoU}, with lower computation costs and fewer parameters. The code is available at \\href{https://github.com/OliverRensu/SG-Former}{https://github.com/OliverRensu/SG-Former}","url_abs":"https://arxiv.org/abs/2308.12216v1","url_pdf":"https://arxiv.org/pdf/2308.12216v1.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":"sg-former-self-guided-transformer-with","repo_url":"https://github.com/oliverrensu/sg-former","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[],"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":"stochastic-depth","method_name":"Stochastic Depth"},{"method_slug":"swin-transformer","method_name":"Swin Transformer"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2308.12216","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2308.12216"}},"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/OliverRensu/SG-Former","reach":null}],"summary":{"ran":5,"ran_draft_wrong":2,"ran_fixture":1,"unverified":2},"by_repo_kind":{"official":{"samples":10,"ran":8,"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":10,"samples":[{"code_sha256_prefix":"62dc7968a3bc8849","entry":"Attention","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"62dc7968a3bc8849"}},{"code_sha256_prefix":"689238f2aa0bc8af","entry":"Conv2d_BN","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"689238f2aa0bc8af"}},{"code_sha256_prefix":"69320a69582cce14","entry":"Head","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"69320a69582cce14"}},{"code_sha256_prefix":"394b5fd507e86c97","entry":"Mlp","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"394b5fd507e86c97"}},{"code_sha256_prefix":"ce0a0df3d2b72b58","entry":"PatchMerging","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ce0a0df3d2b72b58"}},{"code_sha256_prefix":"9bf2ac43b6a4f1fb","entry":"local_conv","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9bf2ac43b6a4f1fb"}},{"code_sha256_prefix":"73a0abb2c65e5346","entry":"window_partition","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"73a0abb2c65e5346"}},{"code_sha256_prefix":"5e5efb3fe6c564ee","entry":"window_reverse","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5e5efb3fe6c564ee"}},{"code_sha256_prefix":"217841cd4c280b17","entry":"Block","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"217841cd4c280b17"}},{"code_sha256_prefix":"dc99d4b51744c543","entry":"SGFormer","repo":"OliverRensu/SG-Former","repo_kind":"official","path":"sgformer.py","file_url":"https://github.com/OliverRensu/SG-Former/blob/HEAD/sgformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dc99d4b51744c543"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}