{"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/emergent-modularity-in-pre-trained","title":"Emergent Modularity in Pre-trained Transformers","arxiv_id":"2305.18390","date":"2023-05-28","proceeding":null,"authors":["Zhengyan Zhang","Zhiyuan Zeng","Yankai Lin","Chaojun Xiao","Xiaozhi Wang","Xu Han","Zhiyuan Liu","Ruobing Xie","Maosong Sun","Jie zhou"],"abstract":"This work examines the presence of modularity in pre-trained Transformers, a feature commonly found in human brains and thought to be vital for general intelligence. In analogy to human brains, we consider two main characteristics of modularity: (1) functional specialization of neurons: we evaluate whether each neuron is mainly specialized in a certain function, and find that the answer is yes. (2) function-based neuron grouping: we explore finding a structure that groups neurons into modules by function, and each module works for its corresponding function. Given the enormous amount of possible structures, we focus on Mixture-of-Experts as a promising candidate, which partitions neurons into experts and usually activates different experts for different inputs. Experimental results show that there are functional experts, where clustered are the neurons specialized in a certain function. Moreover, perturbing the activations of functional experts significantly affects the corresponding function. Finally, we study how modularity emerges during pre-training, and find that the modular structure is stabilized at the early stage, which is faster than neuron stabilization. It suggests that Transformers first construct the modular structure and then learn fine-grained neuron functions. Our code and data are available at https://github.com/THUNLP/modularity-analysis.","url_abs":"https://arxiv.org/abs/2305.18390v2","url_pdf":"https://arxiv.org/pdf/2305.18390v2.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":"emergent-modularity-in-pre-trained","repo_url":"https://github.com/thunlp/modularity-analysis","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"mixture-of-experts","task_name":"Mixture-of-Experts"}],"methods":[{"method_slug":"focus","method_name":"Focus"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2305.18390","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2305.18390"}},"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/thunlp/modularity-analysis","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":10},"by_repo_kind":{"official":{"samples":10,"ran":0,"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":"5519a08ebdb9ff1f","entry":"binom_hypothesis_testing","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"FunctionalExpert/HypothesisTesting.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/FunctionalExpert/HypothesisTesting.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":"5519a08ebdb9ff1f"}},{"code_sha256_prefix":"8306a018292a7872","entry":"get_TopK","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"FunctionalExpert/TopK_neurons.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/FunctionalExpert/TopK_neurons.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":"8306a018292a7872"}},{"code_sha256_prefix":"e0168a836e0e2061","entry":"get_counting","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"FunctionalExpert/HypothesisTesting.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/FunctionalExpert/HypothesisTesting.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":"e0168a836e0e2061"}},{"code_sha256_prefix":"6eafb817b3f2461f","entry":"get_counting","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"FunctionalExpert/HypothesisTesting4RandomPartitioning.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/FunctionalExpert/HypothesisTesting4RandomPartitioning.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":"6eafb817b3f2461f"}},{"code_sha256_prefix":"8e5860a7cc71c303","entry":"hypergeom_hypothesis_testing","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"FunctionalExpert/HypothesisTesting.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/FunctionalExpert/HypothesisTesting.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":"8e5860a7cc71c303"}},{"code_sha256_prefix":"b9209b6e9d6f65bd","entry":"knowledge_CalAP","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"NeuronPredictivity/ap_calculation.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/NeuronPredictivity/ap_calculation.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":"b9209b6e9d6f65bd"}},{"code_sha256_prefix":"b5e5c9b52368bd08","entry":"semantic_CalAP","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"NeuronPredictivity/ap_calculation.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/NeuronPredictivity/ap_calculation.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":"b5e5c9b52368bd08"}},{"code_sha256_prefix":"39eb7a4fd06a4d3b","entry":"sim_topk","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"NeuronFunctionalSpecialization/Figure1Right_maker.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/NeuronFunctionalSpecialization/Figure1Right_maker.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":"39eb7a4fd06a4d3b"}},{"code_sha256_prefix":"ab802339bdf17ca9","entry":"sum_tool","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"FunctionalExpert/Table1and4_maker.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/FunctionalExpert/Table1and4_maker.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":"ab802339bdf17ca9"}},{"code_sha256_prefix":"e2262290cd2baca5","entry":"task_CalAP","repo":"thunlp/modularity-analysis","repo_kind":"official","path":"NeuronPredictivity/ap_calculation.py","file_url":"https://github.com/thunlp/modularity-analysis/blob/HEAD/NeuronPredictivity/ap_calculation.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":"e2262290cd2baca5"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}