{"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/the-need-for-speed-pruning-transformers-with","title":"The Need for Speed: Pruning Transformers with One Recipe","arxiv_id":"2403.17921","date":"2024-03-26","proceeding":null,"authors":["Samir Khaki","Konstantinos N. Plataniotis"],"abstract":"We introduce the $\\textbf{O}$ne-shot $\\textbf{P}$runing $\\textbf{T}$echnique for $\\textbf{I}$nterchangeable $\\textbf{N}$etworks ($\\textbf{OPTIN}$) framework as a tool to increase the efficiency of pre-trained transformer architectures $\\textit{without requiring re-training}$. Recent works have explored improving transformer efficiency, however often incur computationally expensive re-training procedures or depend on architecture-specific characteristics, thus impeding practical wide-scale adoption. To address these shortcomings, the OPTIN framework leverages intermediate feature distillation, capturing the long-range dependencies of model parameters (coined $\\textit{trajectory}$), to produce state-of-the-art results on natural language, image classification, transfer learning, and semantic segmentation tasks $\\textit{without re-training}$. Given a FLOP constraint, the OPTIN framework will compress the network while maintaining competitive accuracy performance and improved throughput. Particularly, we show a $\\leq 2$% accuracy degradation from NLP baselines and a $0.5$% improvement from state-of-the-art methods on image classification at competitive FLOPs reductions. We further demonstrate the generalization of tasks and architecture with comparative performance using Mask2Former for semantic segmentation and cnn-style networks. OPTIN presents one of the first one-shot efficient frameworks for compressing transformer architectures that generalizes well across different class domains, in particular: natural language and image-related tasks, without $\\textit{re-training}$.","url_abs":"https://arxiv.org/abs/2403.17921v1","url_pdf":"https://arxiv.org/pdf/2403.17921v1.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":"the-need-for-speed-pruning-transformers-with","repo_url":"https://github.com/skhaki18/optin-transformer-pruning","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"},{"task_slug":"transfer-learning","task_name":"Transfer Learning"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2403.17921","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.17921"}},"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/Skhaki18/optin-transformer-pruning","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/skhaki18/optin-transformer-pruning","reach":null}],"summary":{"ran_honours":8,"ran_draft_wrong":6,"ran_violates":1,"unverified":8},"by_repo_kind":{"official":{"samples":23,"ran":15,"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":"027ae849d003750b","entry":"KLDiv","repo":"Skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/loss_components.py","file_url":"https://github.com/Skhaki18/optin-transformer-pruning/blob/HEAD/prune/loss_components.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"027ae849d003750b"}},{"code_sha256_prefix":"da78ffebac4be236","entry":"KLDiv","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"da78ffebac4be236"}},{"code_sha256_prefix":"3e6b8dd06f26bd2e","entry":"calculateComplexity","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3e6b8dd06f26bd2e"}},{"code_sha256_prefix":"b8a3e26f899df98f","entry":"compute_base_mac","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b8a3e26f899df98f"}},{"code_sha256_prefix":"b9d5144329aa001b","entry":"compute_mac","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b9d5144329aa001b"}},{"code_sha256_prefix":"18b585baff750730","entry":"compute_patch_mac","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"18b585baff750730"}},{"code_sha256_prefix":"57a2ac87aeb75bf5","entry":"compute_pruned_mac","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"57a2ac87aeb75bf5"}},{"code_sha256_prefix":"8addab3b55f6f68e","entry":"get_mac_details","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8addab3b55f6f68e"}},{"code_sha256_prefix":"fa816ac012e18bee","entry":"globalRankingLanguage","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fa816ac012e18bee"}},{"code_sha256_prefix":"77c8d1bcdfe79662","entry":"mac_per_head","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"77c8d1bcdfe79662"}},{"code_sha256_prefix":"159b80cd46f12b30","entry":"mac_per_neuron","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"159b80cd46f12b30"}},{"code_sha256_prefix":"82a7f6c6a07d3234","entry":"manifold_Distillation","repo":"Skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/loss_components.py","file_url":"https://github.com/Skhaki18/optin-transformer-pruning/blob/HEAD/prune/loss_components.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"82a7f6c6a07d3234"}},{"code_sha256_prefix":"93b2e14d2ed2e49d","entry":"manifold_Distillation","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"93b2e14d2ed2e49d"}},{"code_sha256_prefix":"dda1ad56be460a00","entry":"process_patch_mask","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dda1ad56be460a00"}},{"code_sha256_prefix":"4cabaf97a1cafcd2","entry":"query_conv_mac","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4cabaf97a1cafcd2"}},{"code_sha256_prefix":"72a06dbfb15610ae","entry":"ModelHooking","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"72a06dbfb15610ae"}},{"code_sha256_prefix":"cb63f4eebf8926c2","entry":"Prune","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"cb63f4eebf8926c2"}},{"code_sha256_prefix":"fb4f698a0e53c90a","entry":"cnn_mmd","repo":"Skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/loss_components.py","file_url":"https://github.com/Skhaki18/optin-transformer-pruning/blob/HEAD/prune/loss_components.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":"fb4f698a0e53c90a"}},{"code_sha256_prefix":"a7ccc4f26fd33e50","entry":"globalRankingVision","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"a7ccc4f26fd33e50"}},{"code_sha256_prefix":"053bf2646cdcfa75","entry":"pruneHead","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"053bf2646cdcfa75"}},{"code_sha256_prefix":"c07e8573b3785e73","entry":"pruneLanguageNeurons","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"c07e8573b3785e73"}},{"code_sha256_prefix":"76238266383a6956","entry":"pruneModel","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"76238266383a6956"}},{"code_sha256_prefix":"cd869fbca8ce1494","entry":"pruneVisionNeurons","repo":"skhaki18/optin-transformer-pruning","repo_kind":"official","path":"prune/main_prune.py","file_url":"https://github.com/skhaki18/optin-transformer-pruning/blob/HEAD/prune/main_prune.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":"cd869fbca8ce1494"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}