SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.02421 · ICLR · 2024

What does the Knowledge Neuron Thesis Have to do with Knowledge?

Andrew Liu, Jingcheng Niu, Gerald Penn

arXiv · PDF · Open in the Atlas

Code that ran

17 of 23 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; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 15 failures of our instrument; 6 no recorded run), measured 2026-11-22; 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/2405.02421.json · badge: /api/ran/2405.02421.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
frankniujc/kn_thesis canonical (classifier label)
classifier basis: census
17 ran · 6 no recorded run
FunctionStatusWhere it lives
anaphor_gender_agreement_func Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/blimp.py
code served (permissive licence) · get_code("b52190ed343f222d")
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

torch.manual_seed(0)

# The function anaphor_gender_agreement_func is a decorated function that:
# - Takes parameters: p (string), t (string), get_item (bool, optional)
# - Strips 'Ġ' prefix from p and t if present
# - Checks if t equals 'herself', 'himself', or 'itself'
# - Returns a tuple of (gender_code, token)

# Valid test cases for the function
ARGS = {
    'p': 'Ġword',
    't': 'herself',
    'get_item': False
}
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 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
determiner_noun_agreement_2_func Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/blimp.py
code served (permissive licence) · get_code("f7bb8a394624ac94")
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

torch.manual_seed(0)

ARGS = {
    'p': 'Ġthis [MASK] cat .',
    't': 'Ġthis',
    'get_item': False
}
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 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
detok Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/blimp.py
code served (permissive licence) · get_code("374edd244d8abc18")
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 function. 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 torch.nn as nn

torch.manual_seed(0)

def sample_func(p, t, get_item=False):
    """A sample function that detok will wrap"""
    result = f"p={p}, t={t}, get_item={get_item}"
    if get_item:
        return result[0]
    return result

ARGS = {
    'func': sample_func
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
find_fact_lookup_idx Ran
ran, honoured the contract we drafted
frankniujc/kn_thesis/kn_code/rome/compute_v.py
code served (permissive licence) · get_code("dfe7a59e7269bd44")
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 int, ndim 0, dtype family int, 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
from transformers import AutoTokenizer

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MockTokenizer:
    def __init__(self):
        self.vocab_size = 1000
        self.pad_token_id = 0
    
    def encode(self, text):
        # Simple mock: return a list of token ids based on text length
        return [i % self.vocab_size for i in range(len(text.split()) + 5)]
    
    def decode(self, token_ids):
        return " ".join([str(i) for i in token_ids])

# Create a minimal repr_tools module stand-in
class MockReprTools:
    @staticmethod
    def get_words_idxs_in_templates(tok, context_templates, words, subtoken):
        # Return a list of lists with indices
        # Structure: [[[idx1, idx2, ...], ...], ...]
        return [[[2, 3]]]  # Mock return value

# Inject the mock into the function's namespace
import sys
import types
repr_tools = MockReprTools()

# Define the tokenizer
tok = MockTokenizer()

# Define arguments
ARGS = {
    "prompt": "The subject is {}",
    "subject": "Paris",
    "tok": tok,
    "fact_token_strategy": "last",
    "verbose": True,
    "input_prompt": "The subject is Paris"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, 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
fix_p_neuron Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/knowledge_neurons.py
code served (permissive licence) · get_code("4a0aa407f834f3d9")
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 2, 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
import collections

torch.manual_seed(0)

# Create sample scores - a list of tensors
# Each tensor represents scores for different neurons
# We need tensors with some variation so that thresholding produces nonzero results
scores = [
    torch.tensor([[0.5, 0.8, 0.2, 0.9],
                   [0.1, 0.7, 0.3, 0.6]], dtype=torch.float32),
    torch.tensor([[0.4, 0.9, 0.1, 0.8],
                   [0.2, 0.6, 0.4, 0.7]], dtype=torch.float32)
]

ARGS = {
    "scores": scores,
    "threshold": 0.2,
    "p": 0.7
}
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 2, 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_attributes Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/patch.py
pointer only (licence: MIT); the stored copy get_code serves, from JP-25/KnowBias, is pointer only (licence: NONE) · get_code("44b3ed63235aa487")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from JP-25/KnowBias, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_ff_layer Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/patch.py
code served (permissive licence) · get_code("98b536c6d2cf8aa6")
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 FeedForwardBlock. 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 torch.nn as nn

torch.manual_seed(0)

# Build a minimal model structure that matches what get_ff_layer expects
# It needs:
# - bert.encoder.layer as a ModuleList (indexable)
# - Each layer should have an 'intermediate' attribute (or whatever ff_attrs specifies)

class FeedForwardBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.dense = nn.Linear(4, 8)
    
    def forward(self, x):
        return self.dense(x)

class TransformerLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.intermediate = FeedForwardBlock()
        self.output = nn.Linear(8, 4)
    
    def forward(self, x):
        x = self.intermediate(x)
        x = self.output(x)
        return x

class BertEncoder(nn.Module):
    def __init__(self, num_layers=3):
        super().__init__()
        self.layer = nn.ModuleList([TransformerLayer() for _ in range(num_layers)])
    
    def forward(self, x):
        for layer in self.layer:
            x = layer(x)
        return x

class BertModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder = BertEncoder(num_layers=3)
    
    def forward(self, x):
        return self.encoder(x)

class FullModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.bert = BertModel()
    
    def forward(self, x):
        return self.bert(x)

# Construct the arguments
model = FullModel()
layer_idx = 1
transformer_layers_attr = 'bert.encoder.layer'
ff_attrs = 'intermediate'

ARGS = {
    'model': model,
    'layer_idx': layer_idx,
    'transformer_layers_attr': transformer_layers_attr,
    'ff_attrs': ff_attrs
}
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 FeedForwardBlock — a FeedForwardBlock output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a FeedForwardBlock 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
get_inv_cov Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
frankniujc/kn_thesis/kn_code/rome/compute_u.py
code served (permissive licence) · get_code("d265047cc27fa57f")
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; 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 torch.nn as nn
from transformers import AutoModelForCausalLM, AutoTokenizer

torch.manual_seed(0)

# Stand-in classes for model components
class MockConfig:
    def __init__(self):
        self._name_or_path = "gpt2"

class MockMoment:
    def __init__(self, tensor):
        self.tensor = tensor
    
    def moment(self):
        return self.tensor
    
    def to(self, device):
        self.tensor = self.tensor.to(device)
        return self

class MockStat:
    def __init__(self):
        # Create a small invertible matrix (4x4)
        base = torch.randn(4, 4)
        self.mom2 = MockMoment(base @ base.T + torch.eye(4))

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MockConfig()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(x)

class MockTokenizer:
    def __call__(self, text, return_tensors=None):
        return {"input_ids": torch.randint(0, 1000, (1, 5))}

class MockHparams:
    def __init__(self):
        self.stats_dir = "/tmp/stats"
        self.device = 0

# Create mock layer_stats function
def layer_stats(model, tok, layer_name, stats_dir, mom2_dataset, to_collect, sample_size, precision, hparams):
    return MockStat()

# Inject the mock function into the module where it's used
import sys
current_module = sys.modules[__name__]
current_module.layer_stats = layer_stats

# Construct arguments
model = MockModel()
tokenizer = MockTokenizer()
layer_name = "transformer.h.0.attn"
mom2_dataset = "wikitext"
mom2_n_samples = 1000
mom2_dtype = "float32"
hparams = MockHparams()

ARGS = {
    "model": model,
    "tok": tokenizer,
    "layer_name": layer_name,
    "mom2_dataset": mom2_dataset,
    "mom2_n_samples": mom2_n_samples,
    "mom2_dtype": mom2_dtype,
    "hparams": hparams
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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 — no output shape is stated: observe_signature.py could not observe it (fixture:KeyError)
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_refined_neurons Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/knowledge_neurons.py
code served (permissive licence) · get_code("d7207b7f0d4ca645")
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 2, 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
import numpy as np
import collections

# Analyzing the function:
# - coarse_neurons: iterable of iterables of neuron representations
#   - Each neuron is converted to tuple (so it's hashable)
#   - Each neuron appears to be a sequence/array-like
# - p: float/numeric, used in multiplication to create threshold t

# Setting up test data
torch.manual_seed(0)

# Create coarse_neurons as a list of lists of arrays
# Each "neuron" will be a small array/list that can be converted to tuple
neuron_1 = [1, 2]
neuron_2 = [1, 2]
neuron_3 = [3, 4]
neuron_4 = [1, 2]
neuron_5 = [5, 6]

# Group neurons into batches (coarse_neurons structure)
coarse_neurons = [
    [neuron_1, neuron_2, neuron_3],
    [neuron_4, neuron_5, neuron_2]
]

# p is a threshold parameter - 0.5 means count must be > 0.5 * len(coarse_neurons)
# With 2 groups and p=0.4, threshold t = 0.8, so count must be > 0.8 (i.e., >= 1)
# Neuron (1,2) appears 3 times, (3,4) appears 1 time, (5,6) appears 1 time
p = 0.4

ARGS = {
    "coarse_neurons": coarse_neurons,
    "p": p
}
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 list, ndim 2, 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
hierarchical_subsequence Ran
ran on a synthesized input
frankniujc/kn_thesis/kn_code/util/nethook.py
code served (permissive licence) · get_code("920b394e7ad80c53")
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 Sequential. 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 torch.nn as nn
from collections import OrderedDict

torch.manual_seed(0)

# Create a nested Sequential model to test hierarchical_subsequence
layer1 = nn.Linear(4, 3)
layer2 = nn.Linear(3, 2)
layer3 = nn.Linear(2, 5)

nested_seq = nn.Sequential(
    OrderedDict([
        ('linear1', layer1),
        ('linear2', layer2),
        ('linear3', layer3)
    ])
)

# Test case 1: No parameters (should return full sequential)
ARGS = {
    'sequential': nested_seq,
    'first': None,
    'last': None,
    'after': None,
    'upto': None,
    'share_weights': False,
    'depth': 0
}
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 Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential 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
plot Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/plot.py
code served (permissive licence) · get_code("bd095a141719ae5d")
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 Figure. 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)

# Create small tensors for pre_probs and post_probs
# Shape: (batch_size=2, n_tokens=4)
pre_probs = torch.rand(2, 4)
post_probs = torch.rand(2, 4)

# Ensure they're positive and reasonable for probability-like values
pre_probs = pre_probs * 0.5 + 0.1
post_probs = post_probs * 0.5 + 0.1

# Create token list with 4 tokens
tokens = ['token_a', 'token_b', 'token_c', 'token_d']

# Figure size
figsize = (10, 6)

# Suptitle
suptitle = 'Probability Change Analysis'

# Optional parameters
suptitle_y = 1.05
ttest = True
pvalue_threshold = 0.05
grey_vlines = [0.5, 2.5]
tick_range = [-0.5, 0.0, 0.5, 1.0]
bar_width = 0.4
y_label = 'Probability Change'
save_path = None

ARGS = {
    'pre_probs': pre_probs,
    'post_probs': post_probs,
    'tokens': tokens,
    'figsize': figsize,
    'suptitle': suptitle,
    'suptitle_y': suptitle_y,
    'ttest': ttest,
    'pvalue_threshold': pvalue_threshold,
    'grey_vlines': grey_vlines,
    'tick_range': tick_range,
    'bar_width': bar_width,
    'y_label': y_label,
    'save_path': save_path,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Figure — a Figure output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Figure 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
recursive_copy Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/util/nethook.py
pointer only (licence: MIT); the stored copy get_code serves, from TrustedLLM/UnKE, is pointer only (licence: NONE) · get_code("70f6ab8bde55420e")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from TrustedLLM/UnKE, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

register_hook Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/patch.py
code served (permissive licence) · get_code("c10dba9c17ddf3cd")
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 RemovableHandle. 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 torch.nn as nn

torch.manual_seed(0)

# Build a minimal transformer-like model structure
class FeedForwardLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.dense = nn.Linear(4, 8)
    
    def forward(self, x):
        return self.dense(x)

class TransformerLayer(nn.Module):
    def __init__(self):
        super().__init__()
        self.intermediate = FeedForwardLayer()
    
    def forward(self, x):
        return self.intermediate(x)

class BertEncoder(nn.Module):
    def __init__(self, num_layers=3):
        super().__init__()
        self.layer = nn.ModuleList([TransformerLayer() for _ in range(num_layers)])
    
    def forward(self, x):
        for layer in self.layer:
            x = layer(x)
        return x

class BertModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder = BertEncoder(num_layers=3)
    
    def forward(self, x):
        return self.encoder(x)

class SimpleBert(nn.Module):
    def __init__(self):
        super().__init__()
        self.bert = BertModel()
    
    def forward(self, x):
        return self.bert(x)

# Create model instance
model = SimpleBert()

# Create a simple hook function that captures output
hook_outputs = []
def hook_function(output):
    hook_outputs.append(output)

# Define arguments for register_hook
ARGS = {
    'model': model,
    'layer_idx': 1,
    'f': hook_function,
    'transformer_layers_attr': 'bert.encoder.layer',
    'ff_attrs': 'intermediate'
}
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 RemovableHandle — a RemovableHandle output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a RemovableHandle 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
run_kn_alg Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/knowledge_neurons.py
code served (permissive licence) · get_code("2b2c1c3cf73fd88d")
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 torch
import collections

torch.manual_seed(0)

# Create small score tensors for the algorithm
# scores is a list of tensors where each tensor contains scores
# The function calls score.max().item() and torch.nonzero(score > threshold)
scores = [
    torch.tensor([[0.5, 0.8, 0.3, 0.9],
                   [0.7, 0.2, 0.6, 0.4]]),
    torch.tensor([[0.9, 0.1, 0.5, 0.8],
                   [0.3, 0.6, 0.7, 0.2]])
]

ARGS = {
    "scores": scores,
    "kn_num_min": 2,
    "kn_num_max": 5,
    "adaptive_threshold": 0.2,
    "p": 0.7
}
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 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
slice_list Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
frankniujc/kn_thesis/kn_code/evaluate.py
pointer only (licence: MIT); the stored copy get_code serves, from xinhaoyi/edit_bio_long_tail, is pointer only (licence: NONE) · get_code("5db4cdd5b51f6ed4")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from xinhaoyi/edit_bio_long_tail, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

subsequence Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/util/nethook.py
code served (permissive licence) · get_code("440ff98c2b1ae1aa")
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 Sequential. 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 torch.nn as nn
import copy
from collections import OrderedDict

torch.manual_seed(0)

# Build a nested Sequential model with multiple layers
sequential = nn.Sequential(
    OrderedDict([
        ('layer1', nn.Linear(4, 3)),
        ('layer2', nn.ReLU()),
        ('layer3', nn.Linear(3, 2)),
        ('nested', nn.Sequential(
            OrderedDict([
                ('sublayer1', nn.Linear(2, 2)),
                ('sublayer2', nn.ReLU()),
            ])
        )),
        ('layer4', nn.Linear(2, 1)),
    ])
)

ARGS = {
    'sequential': sequential,
    'first_layer': None,
    'last_layer': None,
    'after_layer': None,
    'upto_layer': None,
    'single_layer': None,
    'share_weights': False,
}
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 Sequential — a Sequential 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
to_percent Ran
ran; our contract draft was wrong, not the code
frankniujc/kn_thesis/kn_code/plot.py
code served (permissive licence) · get_code("407c255c5fd63c76")
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 str. 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 matplotlib.pyplot as plt

# The function to_percent takes two parameters:
# - y: a numeric value (float or int) that gets converted to a percentage
# - position: a position value (used by matplotlib formatters, typically a number)

# Looking at the function body:
# - y is used in arithmetic: int(100 * y)
# - position is not used in the function body at all
# - The function uses plt.rcParams which is already available

ARGS = {
    'y': 0.42,
    'position': 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
generate_symmetry Not yet run
unverified (harvested, no recorded run)
frankniujc/kn_thesis/kn_code/data.py
code served (permissive licence) · get_code("94ccd51944d2fec4")
How it ran

no invocation recorded.

generate_synonym Not yet run
unverified (harvested, no recorded run)
frankniujc/kn_thesis/kn_code/data.py
code served (permissive licence) · get_code("7721312b15ad67eb")
How it ran

no invocation recorded.

get_module_input_output_at_word Not yet run
unverified (harvested, no recorded run)
frankniujc/kn_thesis/kn_code/rome/compute_v.py
code served (permissive licence) · get_code("3b97843e6bca23a9")
How it ran

no invocation recorded.

load_pararel Not yet run
unverified (harvested, no recorded run)
frankniujc/kn_thesis/kn_code/data.py
code served (permissive licence) · get_code("3df6877291666386")
How it ran

no invocation recorded.

pre_post_edit_probs Not yet run
unverified (harvested, no recorded run)
frankniujc/kn_thesis/kn_code/plot.py
code served (permissive licence) · get_code("7f798a12b14dbf4c")
How it ran

no invocation recorded.

test_prediction_acc Not yet run
unverified (harvested, no recorded run)
frankniujc/kn_thesis/kn_code/evaluate.py
code served (permissive licence) · get_code("15ba6a8654411eae")
How it ran

no invocation recorded.

Also present in other papers' code

Of 23 samples lifted from this paper's linked repositories, 23 carry a function identity and 0 do not. Of the 23 distinct functions with an identity, 7 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 3 the same month, 7 later) and 16 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
subsequence 49 other papers
19 dated earlier, 3 the same month, 26 later, 1 same year, order not determinable
2007.15646 (2020-07)
Rewriting a Deep Generative Model
2009.05041 (2020-09)
Understanding the Role of Individual Units in a Deep Neural Network
2110.04292 (2021-10)
Toward a Visual Concept Vocabulary for GAN Latent Space
and 46 more not named here
recursive_copy 48 other papers
17 dated earlier, 4 the same month, 26 later, 1 same year, order not determinable
2207.02774 (2022-07)
Local Relighting of Real Scenes
2210.07229 (2022-10)
Mass-Editing Memory in a Transformer
2302.12461 (2023-02)
Analyzing And Editing Inner Mechanisms Of Backdoored Language Models
and 45 more not named here
hierarchical_subsequence 46 other papers
16 dated earlier, 3 the same month, 26 later, 1 same year, order not determinable
2210.07229 (2022-10)
Mass-Editing Memory in a Transformer
2302.12461 (2023-02)
Analyzing And Editing Inner Mechanisms Of Backdoored Language Models
2311.09053 (2023-11)
Assessing Knowledge Editing in Language Models via Relation Perspective
and 43 more not named here
get_attributes 6 other papers
3 dated earlier, 2 later, 1 same year, order not determinable · 1 only as an assembly brick
2202.05262 (2022-02)
Locating and Editing Factual Associations in GPT
2311.09053 (2023-11)
Assessing Knowledge Editing in Language Models via Relation Perspective
2311.09060 (2023-11)
Do Localization Methods Actually Localize Memorized Data in LLMs? A Tale of Two Benchmarks
and 3 more not named here
get_ff_layer 2 other papers
1 dated earlier, 1 later
2311.09053 (2023-11)
Assessing Knowledge Editing in Language Models via Relation Perspective
2406.10868 (2024-06)
Identifying Query-Relevant Neurons in Large Language Models for Long-Form Texts
register_hook 2 other papers
1 dated earlier, 1 later
2311.09053 (2023-11)
Assessing Knowledge Editing in Language Models via Relation Perspective
2406.10868 (2024-06)
Identifying Query-Relevant Neurons in Large Language Models for Long-Form Texts
slice_list 2 other papers
2 later
2409.07497 (2024-09)
OneEdit: A Neural-Symbolic Collaboratively Knowledge Editing System
2504.10421 (2025-04)
Can We Edit LLMs for Long-Tail Biomedical Knowledge?

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-22.

Repositories linked to this paper

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

Abstract

We reassess the Knowledge Neuron (KN) Thesis: an interpretation of the mechanism underlying the ability of large language models to recall facts from a training corpus. This nascent thesis proposes that facts are recalled from the training corpus through the MLP weights in a manner resembling key-value memory, implying in effect that "knowledge" is stored in the network. Furthermore, by modifying the MLP modules, one can control the language model's generation of factual information. The plausibility of the KN thesis has been demonstrated by the success of KN-inspired model editing methods (Dai et al., 2022;Meng et al., 2022). We find that this thesis is, at best, an oversimplification. Not only have we found that we can edit the expression of certain linguistic phenomena using the same model editing methods but, through a more comprehensive evaluation, we have found that the KN thesis does not adequately explain the process of factual expression. While it is possible to argue that the MLP weights store complex patterns that are interpretable both syntactically and semantically, these patterns do not constitute "knowledge." To gain a more comprehensive understanding of the knowledge representation process, we must look beyond the MLP weights and explore recent models' complex layer structures and attention mechanisms.

For agents

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

get_harvested_code_for_paper("2405.02421")
get_code_for_paper("2405.02421")
have("2405.02421")

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

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

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

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

Connect an agent — have() is free.