{"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/sheared-llama-accelerating-language-model-pre","title":"Sheared LLaMA: Accelerating Language Model Pre-training via Structured Pruning","arxiv_id":"2310.06694","date":"2023-10-10","proceeding":null,"authors":["Mengzhou Xia","Tianyu Gao","Zhiyuan Zeng","Danqi Chen"],"abstract":"The popularity of LLaMA (Touvron et al., 2023a;b) and other recently emerged moderate-sized large language models (LLMs) highlights the potential of building smaller yet powerful LLMs. Regardless, the cost of training such models from scratch on trillions of tokens remains high. In this work, we study structured pruning as an effective means to develop smaller LLMs from pre-trained, larger models. Our approach employs two key techniques: (1) targeted structured pruning, which prunes a larger model to a specified target shape by removing layers, heads, and intermediate and hidden dimensions in an end-to-end manner, and (2) dynamic batch loading, which dynamically updates the composition of sampled data in each training batch based on varying losses across different domains. We demonstrate the efficacy of our approach by presenting the Sheared-LLaMA series, pruning the LLaMA2-7B model down to 1.3B and 2.7B parameters. Sheared-LLaMA models outperform state-of-the-art open-source models of equivalent sizes, such as Pythia, INCITE, OpenLLaMA and the concurrent TinyLlama models, on a wide range of downstream and instruction tuning evaluations, while requiring only 3% of compute compared to training such models from scratch. This work provides compelling evidence that leveraging existing LLMs with structured pruning is a far more cost-effective approach for building competitive small-scale LLMs","url_abs":"https://arxiv.org/abs/2310.06694v2","url_pdf":"https://arxiv.org/pdf/2310.06694v2.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":"sheared-llama-accelerating-language-model-pre","repo_url":"https://github.com/princeton-nlp/llm-shearing","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"sheared-llama-accelerating-language-model-pre","repo_url":"https://github.com/hexuandeng/drpruning","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"question-answering","task_name":"Question Answering"},{"task_slug":"sentence-completion","task_name":"Sentence Completion"}],"methods":[{"method_slug":"pruning","method_name":"Pruning"},{"method_slug":"pythia","method_name":"Pythia"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/question-answering-on-piqa","task":"Question Answering","dataset":"PIQA","model":"Open-LLaMA-3B-v2","rank_in_archive_order":45,"of":67,"metrics":{"Accuracy":"76.2"},"uses_additional_data":false},{"leaderboard":"/sota/question-answering-on-piqa","task":"Question Answering","dataset":"PIQA","model":"Sheared-LLaMA-2.7B","rank_in_archive_order":47,"of":67,"metrics":{"Accuracy":"75.8"},"uses_additional_data":false},{"leaderboard":"/sota/question-answering-on-piqa","task":"Question Answering","dataset":"PIQA","model":"Sheared-LLaMA-1.3B","rank_in_archive_order":50,"of":67,"metrics":{"Accuracy":"73.4"},"uses_additional_data":false},{"leaderboard":"/sota/sentence-completion-on-hellaswag","task":"Sentence Completion","dataset":"HellaSwag","model":"Sheared-LLaMA-2.7B (50B)","rank_in_archive_order":55,"of":89,"metrics":{"Accuracy":"70.8"},"uses_additional_data":false},{"leaderboard":"/sota/sentence-completion-on-hellaswag","task":"Sentence Completion","dataset":"HellaSwag","model":"Open-LLaMA-3B-v2","rank_in_archive_order":57,"of":89,"metrics":{"Accuracy":"67.6"},"uses_additional_data":false},{"leaderboard":"/sota/sentence-completion-on-hellaswag","task":"Sentence Completion","dataset":"HellaSwag","model":"Sheared-LLaMA-1.3B (50B)","rank_in_archive_order":59,"of":89,"metrics":{"Accuracy":"60.7"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2310.06694","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2310.06694"}},"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/hexuandeng/drpruning","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/princeton-nlp/llm-shearing","reach":null}],"summary":{"ran_draft_wrong":2,"ran_honours":1},"by_repo_kind":{"official":{"samples":3,"ran":3,"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":"b3a5939a8b60c512","entry":"get_key_map_from_composer_to_hf","repo":"princeton-nlp/llm-shearing","repo_kind":"official","path":"llmshearing/utils/composer_to_hf.py","file_url":"https://github.com/princeton-nlp/llm-shearing/blob/HEAD/llmshearing/utils/composer_to_hf.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b3a5939a8b60c512"}},{"code_sha256_prefix":"bc8e0de8fcbc7160","entry":"get_key_map_from_hf_to_composer","repo":"princeton-nlp/llm-shearing","repo_kind":"official","path":"llmshearing/utils/composer_to_hf.py","file_url":"https://github.com/princeton-nlp/llm-shearing/blob/HEAD/llmshearing/utils/composer_to_hf.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bc8e0de8fcbc7160"}},{"code_sha256_prefix":"2042eae985ac71b1","entry":"get_layer_num_from_weights","repo":"princeton-nlp/llm-shearing","repo_kind":"official","path":"llmshearing/utils/composer_to_hf.py","file_url":"https://github.com/princeton-nlp/llm-shearing/blob/HEAD/llmshearing/utils/composer_to_hf.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":"2042eae985ac71b1"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}