SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.18390 · 2023

Emergent Modularity in Pre-trained Transformers

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2305.18390.json · badge: /api/ran/2305.18390.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
thunlp/modularity-analysis canonical (classifier label)
classifier basis: census
7 ran · 3 no recorded run
FunctionStatusWhere it lives
binom_hypothesis_testing Ran
ran on a synthesized input
thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting.py
code served (permissive licence) · get_code("5519a08ebdb9ff1f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from scipy import stats

torch.manual_seed(0)

# The function expects a torch.Tensor of countings
# It sums the tensor, uses it with scipy.stats.binom
# It indexes into the tensor with a boolean mask
# It calculates lengths and means
# So we need a 1D tensor of integers representing counts

countings = torch.tensor([5, 12, 8, 3, 7, 9, 11, 4, 6, 10, 2, 8, 9, 7, 5, 6], dtype=torch.long)

ARGS = {
    "countings": countings
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_TopK Ran
ran on a synthesized input
thunlp/modularity-analysis/FunctionalExpert/TopK_neurons.py
code served (permissive licence) · get_code("8306a018292a7872")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small tensor with at least 100 elements so topk(1%) works
# Using shape (128,) to have enough elements for 1% to be meaningful
ap = torch.randn(128)

ARGS = {
    "ap": ap
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_counting Ran
ran on a synthesized input
thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting.py
code served (permissive licence) · get_code("e0168a836e0e2061")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (16,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# ap: iterable of neuron indices
ap = [0, 1, 2, 3, 5, 7, 10, 15]

# expert_belong: dict-like mapping neuron indices to expert indices (0-15)
expert_belong = {
    0: 0,
    1: 1,
    2: 2,
    3: 3,
    4: 4,
    5: 5,
    6: 6,
    7: 7,
    8: 8,
    9: 9,
    10: 10,
    11: 11,
    12: 12,
    13: 13,
    14: 14,
    15: 15,
}

ARGS = {
    "ap": ap,
    "expert_belong": expert_belong,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (16,) — shape (16,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_counting Ran
ran on a synthesized input
thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting4RandomPartitioning.py
code served (permissive licence) · get_code("6eafb817b3f2461f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (16,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function iterates over 'ap' (which should be indexable/iterable)
# and uses each element as an index into 'expert_belong' to get a value
# that is then used as an index into res (which has size 16)
# So expert_belong[neuron] must return a value in range [0, 15]

# ap: list of neuron indices
ap = [0, 1, 2, 3, 5, 7, 1, 0]

# expert_belong: list/tensor where expert_belong[neuron] gives the expert index (0-15)
expert_belong = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

ARGS = {
    "ap": ap,
    "expert_belong": expert_belong,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (16,) — shape (16,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sim_topk Ran
ran on a synthesized input
thunlp/modularity-analysis/NeuronFunctionalSpecialization/Figure1Right_maker.py
code served (permissive licence) · get_code("39eb7a4fd06a4d3b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create small tensor arguments
a = torch.randn(5, dtype=torch.float32)  # 1D tensor with 5 elements
b = torch.randn(5, dtype=torch.float32)  # 1D tensor with 5 elements
k = 2  # integer for top-k

ARGS = {
    "a": a,
    "b": b,
    "k": k
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sum_tool Ran
ran on a synthesized input
thunlp/modularity-analysis/FunctionalExpert/Table1and4_maker.py
code served (permissive licence) · get_code("ab802339bdf17ca9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Analyze the function:
# - sum_tool takes a dict and an index
# - It iterates over data.values() and accesses item_data[index]
# - This means each value in the dict must be indexable (list, tuple, array, tensor)
# - It returns the average sum across all items at that index

# Create a dict where values are indexable (lists or arrays)
data = {
    "item_1": [1.0, 2.0, 3.0, 4.0],
    "item_2": [5.0, 6.0, 7.0, 8.0],
    "item_3": [9.0, 10.0, 11.0, 12.0]
}

index = 1

ARGS = {
    "data": data,
    "index": index
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
task_CalAP Ran
ran on a synthesized input
thunlp/modularity-analysis/NeuronPredictivity/ap_calculation.py
code served (permissive licence) · get_code("e2262290cd2baca5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from sklearn.metrics import average_precision_score
from sklearn import preprocessing

torch.manual_seed(0)

# Create a small dataset dictionary
# Keys are label strings, values are lists of dicts with 'idx' fields
dataset = {
    '0': [
        {'idx': 0},
        {'idx': 1},
    ],
    '1': [
        {'idx': 2},
        {'idx': 3},
    ],
    '2': [
        {'idx': 4},
        {'idx': 5},
    ],
}

# Create activation vectors for each instance index
# Shape: (6 instances, 4 feature dimensions)
acts = {
    0: torch.randn(4),
    1: torch.randn(4),
    2: torch.randn(4),
    3: torch.randn(4),
    4: torch.randn(4),
    5: torch.randn(4),
}

# Task name
task = 'cola'

ARGS = {
    'dataset': dataset,
    'task': task,
    'acts': acts,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
hypergeom_hypothesis_testing Not yet run
unverified (harvested, no recorded run)
thunlp/modularity-analysis/FunctionalExpert/HypothesisTesting.py
code served (permissive licence) · get_code("8e5860a7cc71c303")
How it ran

no invocation recorded.

knowledge_CalAP Not yet run
unverified (harvested, no recorded run)
thunlp/modularity-analysis/NeuronPredictivity/ap_calculation.py
code served (permissive licence) · get_code("b9209b6e9d6f65bd")
How it ran

no invocation recorded.

semantic_CalAP Not yet run
unverified (harvested, no recorded run)
thunlp/modularity-analysis/NeuronPredictivity/ap_calculation.py
code served (permissive licence) · get_code("b5e5c9b52368bd08")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2305.18390")
get_code_for_paper("2305.18390")
have("2305.18390")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2305.18390.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2305.18390.svg)](https://syntology.ai/paper/2305.18390)

Connect an agent — have() is free.