SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2211.07349 · EMNLP · 2022

Finding Skill Neurons in Pre-trained Transformer-based Language Models

Zhiyuan Liu, Kaiyue Wen, Juanzi Li, Lei Hou, Xiaozhi Wang, Zhengyan Zhang

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 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 5 have no contract verdict; 1 failure of our instrument; 1 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/2211.07349.json · badge: /api/ran/2211.07349.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
THU-KEG/Skill-Neuron canonical (classifier label)
classifier basis not recorded on the link
6 ran · 1 no recorded run
FunctionStatusWhere it lives
balance Ran
ran on a synthesized input
THU-KEG/Skill-Neuron/src/helper/binarize.py
code served (permissive licence) · get_code("2f2b3f9b9b9bf7c0")
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 Dataset. The image it ran in was not recorded. If your copy returns the same type 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 datasets import Dataset

torch.manual_seed(0)

# Create a simple dataset with labels
data_dict = {
    'label': [0, 1, 0, 1, 0, 1],
    'feature': ['a', 'b', 'c', 'd', 'e', 'f']
}

# Convert to Hugging Face Dataset which has a .filter() method
data = Dataset.from_dict(data_dict)

ARGS = {
    'data': data
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Dataset — a Dataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Dataset output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
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
cut Ran
ran on a synthesized input
THU-KEG/Skill-Neuron/src/mask.py
code served (permissive licence) · get_code("3ac2d952980db18f")
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 dict. The image it ran in was not recorded. If your copy returns the same type 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)

# The function `cut` takes a dict `data` and an integer `len`
# It returns a new dict where each value is sliced to the first `len` elements
# The function iterates over keys in data and slices data[key][:len]

# Create sample data with various types of values that support slicing
data = {
    'tensor1': torch.randn(10, 4),
    'tensor2': torch.randn(8, 3),
    'list1': list(range(15)),
    'array1': np.arange(12).reshape(6, 2),
}

len_param = 3

ARGS = {
    'data': data,
    'len': len_param,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
cut Ran
ran on a synthesized input
THU-KEG/Skill-Neuron/src/prune.py
code served (permissive licence) · get_code("21b0ff446cbe51ea")
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 dict. The image it ran in was not recorded. If your copy returns the same type 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)

# Construct a data dict with list values that can be sliced
data = {
    "feature_a": [1, 2, 3, 4, 5],
    "feature_b": [10, 20, 30, 40, 50],
    "feature_c": [100, 200, 300, 400, 500]
}

newsize = 3

ARGS = {
    "data": data,
    "newsize": newsize
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
getDataset Ran
ran on a synthesized input
THU-KEG/Skill-Neuron/src/dataset.py
code served (permissive licence) · get_code("4e7df67a92029962")
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. The image it ran in was not recorded. If your copy returns the same type 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 tempfile
import os
import csv
from torch.utils.data import random_split as split

# Create temporary CSV files for testing
temp_dir = tempfile.mkdtemp()

# Create a dummy train.csv for DbpediaDataset
train_csv_path = os.path.join(temp_dir, 'train.csv')
with open(train_csv_path, 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['0', 'dummy', 'This is a test sentence'])
    writer.writerow(['1', 'dummy', 'Another test sentence'])
    writer.writerow(['0', 'dummy', 'Third test sentence'])
    writer.writerow(['1', 'dummy', 'Fourth test sentence'])
    writer.writerow(['0', 'dummy', 'Fifth test sentence'])

# Create a dummy test.csv for DbpediaDataset
test_csv_path = os.path.join(temp_dir, 'test.csv')
with open(test_csv_path, 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['0', 'dummy', 'Test sentence one'])
    writer.writerow(['1', 'dummy', 'Test sentence two'])

ARGS = {
    'taskName': 'dpbedia',
    'path': temp_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
datasets, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
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_agg_accs Ran
ran on a synthesized input
THU-KEG/Skill-Neuron/src/skillneuron.py
code served (permissive licence) · get_code("5a8f0ac4c2e69022")
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 2, dtype family float, shape (3, 4) 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 tempfile
import os

torch.manual_seed(0)

# Create temporary directory and save some dummy tensor files
temp_dir = tempfile.mkdtemp()

# Create a few dummy accuracy tensor files
path1 = os.path.join(temp_dir, "acc1.pt")
path2 = os.path.join(temp_dir, "acc2.pt")
path3 = os.path.join(temp_dir, "acc3.pt")

acc_tensor1 = torch.tensor([0.85, 0.90, 0.92, 0.88])
acc_tensor2 = torch.tensor([0.91, 0.89, 0.87, 0.93])
acc_tensor3 = torch.tensor([0.88, 0.91, 0.89, 0.90])

torch.save(acc_tensor1, path1)
torch.save(acc_tensor2, path2)
torch.save(acc_tensor3, path3)

# Create list of paths to pass to the function
paths = [path1, path2, path3]

ARGS = {
    "name": paths
}
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 2, dtype family float, shape (3, 4) — shape (3, 4) 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_logger Ran
ran; our contract draft was wrong, not the code
THU-KEG/Skill-Neuron/src/log.py
code served (permissive licence) · get_code("e9d1721da5040dcc")
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 Logger. The image it ran in was not recorded. If your copy returns the same type 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 logging
import tempfile
import os

# Create a temporary directory for log files to avoid cluttering the filesystem
temp_dir = tempfile.mkdtemp()
original_cwd = os.getcwd()
os.chdir(temp_dir)

# The function takes a single parameter: name (str)
# It uses this name to:
# 1. Add it to a set
# 2. Create a file handler with filename "{name}.txt"
# 3. Get/create a logger with that name

name_value = "test_logger"

ARGS = {
    "name": name_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Logger — a Logger output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Logger output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
finfo Not yet run
unverified (harvested, no recorded run)
THU-KEG/Skill-Neuron/src/skillneuron.py
code served (permissive licence) · get_code("51fb53c251b46836")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 6 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.

FunctionAlso present inEarliest-datedOthers named
get_logger 4 other papers
2 dated earlier, 2 later
1904.01617 (2019-04)
Attentive Mimicking: Better Word Embeddings by Attending to Informative Contexts
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2212.09651 (2022-12)
Cross-Lingual Retrieval Augmented Prompt for Low-Resource Languages
and 1 more not named here

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

Transformer-based pre-trained language models have demonstrated superior performance on various natural language processing tasks. However, it remains unclear how the skills required to handle these tasks distribute among model parameters. In this paper, we find that after prompt tuning for specific tasks, the activations of some neurons within pre-trained Transformers 1 are highly predictive of the task labels. We dub these neurons skill neurons and confirm they encode task-specific skills by finding that: (1) Skill neurons are crucial for handling tasks. Performances of pre-trained Transformers on a task significantly drop when corresponding skill neurons are perturbed. (2) Skill neurons are task-specific. Similar tasks tend to have similar distributions of skill neurons. Furthermore, we demonstrate the skill neurons are most likely generated in pre-training rather than finetuning by showing that the skill neurons found with prompt tuning are also crucial for other fine-tuning methods freezing neuron weights, such as the adapter-based tuning and BitFit. We also explore the applications of skill neurons, including accelerating Transformers with network pruning and building better transferability indicators. These findings may promote further research on understanding Transformers. The source code can be obtained from https: //github.com/THU-KEG/Skill-Neuron. * indicates equal contribution.

For agents

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

get_harvested_code_for_paper("2211.07349")
get_code_for_paper("2211.07349")
have("2211.07349")

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

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

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

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

Connect an agent — have() is free.