{"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/poor-man-s-bert-smaller-and-faster","title":"On the Effect of Dropping Layers of Pre-trained Transformer Models","arxiv_id":"2004.03844","date":"2020-04-08","proceeding":null,"authors":["Hassan Sajjad","Fahim Dalvi","Nadir Durrani","Preslav Nakov"],"abstract":"Transformer-based NLP models are trained using hundreds of millions or even billions of parameters, limiting their applicability in computationally constrained environments. While the number of parameters generally correlates with performance, it is not clear whether the entire network is required for a downstream task. Motivated by the recent work on pruning and distilling pre-trained models, we explore strategies to drop layers in pre-trained models, and observe the effect of pruning on downstream GLUE tasks. We were able to prune BERT, RoBERTa and XLNet models up to 40%, while maintaining up to 98% of their original performance. Additionally we show that our pruned models are on par with those built using knowledge distillation, both in terms of size and performance. Our experiments yield interesting observations such as, (i) the lower layers are most critical to maintain downstream task performance, (ii) some tasks such as paraphrase detection and sentence similarity are more robust to the dropping of layers, and (iii) models trained using a different objective function exhibit different learning patterns and w.r.t the layer dropping.","url_abs":"https://arxiv.org/abs/2004.03844v3","url_pdf":"https://arxiv.org/pdf/2004.03844v3.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":"poor-man-s-bert-smaller-and-faster","repo_url":"https://github.com/hsajjad/transformers","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"poor-man-s-bert-smaller-and-faster","repo_url":"https://github.com/MahmoudWahdan/dialog-nlu","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":null},{"paper_slug":"poor-man-s-bert-smaller-and-faster","repo_url":"https://github.com/dsindex/iclassifier","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"poor-man-s-bert-smaller-and-faster","repo_url":"https://github.com/thousandvoices/ok_ml_cup","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"knowledge-distillation","task_name":"Knowledge Distillation"},{"task_slug":"sentence","task_name":"Sentence"},{"task_slug":"sentence-similarity","task_name":"Sentence Similarity"}],"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":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bert","method_name":"BERT"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"distilbert","method_name":"DistilBERT"},{"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":"linear-warmup-with-linear-decay","method_name":"Linear Warmup With Linear Decay"},{"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":"pruning","method_name":"Pruning"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"roberta","method_name":"RoBERTa"},{"method_slug":"sentencepiece","method_name":"SentencePiece"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"},{"method_slug":"xlnet","method_name":"XLNet"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2004.03844","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2004.03844"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/dsindex/iclassifier","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MahmoudWahdan/dialog-nlu","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hsajjad/transformers","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/thousandvoices/ok_ml_cup","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":2,"ran_honours":1,"ran_fixture":1,"unverified":4},"by_repo_kind":{"official":{"samples":5,"ran":2,"repositories":1},"listed":{"samples":3,"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":"0f786c407fb1ee4c","entry":"swish","repo":"hsajjad/transformers","repo_kind":"official","path":"src/transformers/activations.py","file_url":"https://github.com/hsajjad/transformers/blob/HEAD/src/transformers/activations.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":2,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0f786c407fb1ee4c"}},{"code_sha256_prefix":"77601724cad03f95","entry":"gelu_new","repo":"hsajjad/transformers","repo_kind":"official","path":"src/transformers/activations.py","file_url":"https://github.com/hsajjad/transformers/blob/HEAD/src/transformers/activations.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"77601724cad03f95"}},{"code_sha256_prefix":"65008bf5a39ab4a8","entry":"modify_num_of_layers","repo":"MahmoudWahdan/dialog-nlu","repo_kind":"listed","path":"src/dialognlu/compression/layer_pruning.py","file_url":"https://github.com/MahmoudWahdan/dialog-nlu/blob/HEAD/src/dialognlu/compression/layer_pruning.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"65008bf5a39ab4a8"}},{"code_sha256_prefix":"d1b8e324937c693a","entry":"rename_layers","repo":"MahmoudWahdan/dialog-nlu","repo_kind":"listed","path":"src/dialognlu/compression/layer_pruning.py","file_url":"https://github.com/MahmoudWahdan/dialog-nlu/blob/HEAD/src/dialognlu/compression/layer_pruning.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d1b8e324937c693a"}},{"code_sha256_prefix":"5754b33f19af70d1","entry":"bytes_to_human_readable","repo":"hsajjad/transformers","repo_kind":"official","path":"src/transformers/benchmark_utils.py","file_url":"https://github.com/hsajjad/transformers/blob/HEAD/src/transformers/benchmark_utils.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":"5754b33f19af70d1"}},{"code_sha256_prefix":"c284da449b6828d1","entry":"rename_layers_in_strategy","repo":"MahmoudWahdan/dialog-nlu","repo_kind":"listed","path":"src/dialognlu/compression/layer_pruning.py","file_url":"https://github.com/MahmoudWahdan/dialog-nlu/blob/HEAD/src/dialognlu/compression/layer_pruning.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":"c284da449b6828d1"}},{"code_sha256_prefix":"5187b190d98b3a8c","entry":"start_memory_tracing","repo":"hsajjad/transformers","repo_kind":"official","path":"src/transformers/benchmark_utils.py","file_url":"https://github.com/hsajjad/transformers/blob/HEAD/src/transformers/benchmark_utils.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":"5187b190d98b3a8c"}},{"code_sha256_prefix":"8e9fd1c6c1189834","entry":"stop_memory_tracing","repo":"hsajjad/transformers","repo_kind":"official","path":"src/transformers/benchmark_utils.py","file_url":"https://github.com/hsajjad/transformers/blob/HEAD/src/transformers/benchmark_utils.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":"8e9fd1c6c1189834"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}