{"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/learned-thresholds-token-merging-and-pruning","title":"Learned Thresholds Token Merging and Pruning for Vision Transformers","arxiv_id":"2307.10780","date":"2023-07-20","proceeding":null,"authors":["Maxim Bonnaerens","Joni Dambre"],"abstract":"Vision transformers have demonstrated remarkable success in a wide range of computer vision tasks over the last years. However, their high computational costs remain a significant barrier to their practical deployment. In particular, the complexity of transformer models is quadratic with respect to the number of input tokens. Therefore techniques that reduce the number of input tokens that need to be processed have been proposed. This paper introduces Learned Thresholds token Merging and Pruning (LTMP), a novel approach that leverages the strengths of both token merging and token pruning. LTMP uses learned threshold masking modules that dynamically determine which tokens to merge and which to prune. We demonstrate our approach with extensive experiments on vision transformers on the ImageNet classification task. Our results demonstrate that LTMP achieves state-of-the-art accuracy across reduction rates while requiring only a single fine-tuning epoch, which is an order of magnitude faster than previous methods. Code is available at https://github.com/Mxbonn/ltmp .","url_abs":"https://arxiv.org/abs/2307.10780v2","url_pdf":"https://arxiv.org/pdf/2307.10780v2.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":"learned-thresholds-token-merging-and-pruning","repo_url":"https://github.com/mxbonn/ltmp","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"efficient-vits","task_name":"Efficient ViTs"}],"methods":[{"method_slug":"pruning","method_name":"Pruning"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/efficient-vits-on-imagenet-1k-with-deit-s","task":"Efficient ViTs","dataset":"ImageNet-1K (with DeiT-S)","model":"LTMP (80%)","rank_in_archive_order":8,"of":41,"metrics":{"GFLOPs":"3.8","Top 1 Accuracy":"79.8"},"uses_additional_data":false},{"leaderboard":"/sota/efficient-vits-on-imagenet-1k-with-deit-s","task":"Efficient ViTs","dataset":"ImageNet-1K (with DeiT-S)","model":"LTMP (60%)","rank_in_archive_order":18,"of":41,"metrics":{"GFLOPs":"3.0","Top 1 Accuracy":"79.6"},"uses_additional_data":false},{"leaderboard":"/sota/efficient-vits-on-imagenet-1k-with-deit-s","task":"Efficient ViTs","dataset":"ImageNet-1K (with DeiT-S)","model":"LTMP (45%)","rank_in_archive_order":35,"of":41,"metrics":{"GFLOPs":"2.3","Top 1 Accuracy":"78.6"},"uses_additional_data":false},{"leaderboard":"/sota/efficient-vits-on-imagenet-1k-with-deit-t","task":"Efficient ViTs","dataset":"ImageNet-1K (with DeiT-T)","model":"LTMP (80%)","rank_in_archive_order":13,"of":22,"metrics":{"GFLOPs":"1.0","Top 1 Accuracy":"72.0"},"uses_additional_data":false},{"leaderboard":"/sota/efficient-vits-on-imagenet-1k-with-deit-t","task":"Efficient ViTs","dataset":"ImageNet-1K (with DeiT-T)","model":"LTMP (60%)","rank_in_archive_order":15,"of":22,"metrics":{"GFLOPs":"0.8","Top 1 Accuracy":"71.5"},"uses_additional_data":false},{"leaderboard":"/sota/efficient-vits-on-imagenet-1k-with-deit-t","task":"Efficient ViTs","dataset":"ImageNet-1K (with DeiT-T)","model":"LTMP (45%)","rank_in_archive_order":21,"of":22,"metrics":{"GFLOPs":"0.7","Top 1 Accuracy":"69.8"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2307.10780","atlas_url":"https://app.syntology.ai/?focus=2307.10780","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2307.10780"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/mxbonn/ltmp","reach":{"status":"ok"}}],"summary":{"ran_fixture":1,"ran_honours":1,"ran":2,"unverified":1},"by_repo_kind":{"official":{"samples":5,"ran":4,"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":5,"samples":[{"code_sha256_prefix":"424049f15b90678d","entry":"bipartite_soft_matching","repo":"mxbonn/ltmp","repo_kind":"official","path":"ltmp/token_merging.py","file_url":"https://github.com/mxbonn/ltmp/blob/HEAD/ltmp/token_merging.py","link_basis":"harvester_set","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":"424049f15b90678d"}},{"code_sha256_prefix":"969e8250d805a154","entry":"do_nothing","repo":"mxbonn/ltmp","repo_kind":"official","path":"ltmp/token_merging.py","file_url":"https://github.com/mxbonn/ltmp/blob/HEAD/ltmp/token_merging.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"969e8250d805a154"}},{"code_sha256_prefix":"674be50d432e8846","entry":"kth_bipartite_soft_matching","repo":"mxbonn/ltmp","repo_kind":"official","path":"ltmp/token_merging.py","file_url":"https://github.com/mxbonn/ltmp/blob/HEAD/ltmp/token_merging.py","link_basis":"harvester_set","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":"674be50d432e8846"}},{"code_sha256_prefix":"94e8f254ce489a4b","entry":"parse_r","repo":"mxbonn/ltmp","repo_kind":"official","path":"ltmp/utils.py","file_url":"https://github.com/mxbonn/ltmp/blob/HEAD/ltmp/utils.py","link_basis":"harvester_set","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":"94e8f254ce489a4b"}},{"code_sha256_prefix":"61c0c3039d046800","entry":"make_visualization","repo":"mxbonn/ltmp","repo_kind":"official","path":"ltmp/vis.py","file_url":"https://github.com/mxbonn/ltmp/blob/HEAD/ltmp/vis.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":"61c0c3039d046800"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}