Papers › Emergent Modularity in Pre-trained Transformers

Emergent Modularity in Pre-trained Transformers

28 May 2023arXiv:2305.18390archive 2025-07-28

Zhengyan Zhang, Zhiyuan Zeng, Yankai Lin, Chaojun Xiao, Xiaozhi Wang, Xu Han, Zhiyuan Liu, Ruobing Xie, Maosong Sun, Jie zhou

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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2305.18390")

Code

Syntology Ran 0 of 10 code samples harvested from 1 repository linked to this paper; 10 have no recorded run.

By repository: official repository: 10 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

thunlp/modularity-analysis officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 0 ran; 0 honoured the contract we drafted; 10 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

10unverified

Licence: 0 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from thunlp/modularity-analysis. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: 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. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

binom_hypothesis_testing thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting.py official repository unverified MIT (permissive) · 5519a08ebdb9ff1f · report
get_TopK thunlp/modularity-analysis/FunctionalExpert/TopK_neurons.py official repository unverified MIT (permissive) · 8306a018292a7872 · report
get_counting thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting.py official repository unverified MIT (permissive) · e0168a836e0e2061 · report
get_counting thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting4RandomPartitioning.py official repository unverified MIT (permissive) · 6eafb817b3f2461f · report
hypergeom_hypothesis_testing thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting.py official repository unverified MIT (permissive) · 8e5860a7cc71c303 · report
knowledge_CalAP thunlp/modularity-analysis/NeuronPredictivity/ap_calculation.py official repository unverified MIT (permissive) · b9209b6e9d6f65bd · report
semantic_CalAP thunlp/modularity-analysis/NeuronPredictivity/ap_calculation.py official repository unverified MIT (permissive) · b5e5c9b52368bd08 · report
sim_topk thunlp/modularity-analysis/NeuronFunctionalSpecialization/Figure1Right_maker.py official repository unverified MIT (permissive) · 39eb7a4fd06a4d3b · report
sum_tool thunlp/modularity-analysis/FunctionalExpert/Table1and4_maker.py official repository unverified MIT (permissive) · ab802339bdf17ca9 · report
task_CalAP thunlp/modularity-analysis/NeuronPredictivity/ap_calculation.py official repository unverified MIT (permissive) · e2262290cd2baca5 · report

Tasks

Mixture-of-Experts

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Focus

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections