SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.14956 · EMNLP · 2023

Editing Common Sense in Transformers

Sarah Wiegreffe, Lorraine Li, Wenlong Zhao, Niket Tandon, Xiang, Anshita Gupta, Debanjan Mondal, Krishna Akshay, Sheshadri

arXiv · PDF · Open in the Atlas

Code that ran

6 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 6 have no contract verdict; 0 failures of our instrument; 4 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.14956.json · badge: /api/ran/2305.14956.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
anshitag/memit_csk canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
FunctionStatusWhere it lives
calculate_metrics Ran
ran on a synthesized input
anshitag/memit_csk/base_finetune_experiments/fine_tune_gpt.py
code served (permissive licence) · get_code("41346355360705b1")
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 numpy as np
from sklearn import metrics

torch_seed = 0

# Define the arguments for calculate_metrics
orig_label = np.array([0, 1, 0, 1, 2, 2, 1, 0])
pred_label = np.array([0, 1, 0, 0, 2, 1, 1, 0])
split = "validation"
labels = np.array([0, 1, 2])

ARGS = {
    "orig_label": orig_label,
    "pred_label": pred_label,
    "split": split,
    "labels": labels
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — 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
calculate_metrics Ran
ran on a synthesized input
anshitag/memit_csk/repair_finetune_experiments/evaluate_affected_finetune_model.py
code served (permissive licence) · get_code("cfa19d05d0870261")
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 numpy as np
from sklearn import metrics

# Set seed for reproducibility
np.random.seed(0)

# Create small sample data for a multi-class classification problem
# 10 samples, 3 classes
orig_label = np.array([0, 1, 2, 0, 1, 2, 0, 1, 2, 0])
pred_label = np.array([0, 1, 2, 0, 1, 1, 0, 2, 2, 0])

# Define the labels that can appear in the dataset
labels = np.array([0, 1, 2])

# Evaluation type string
eval_type = "Test"

ARGS = {
    "orig_label": orig_label,
    "pred_label": pred_label,
    "eval_type": eval_type,
    "labels": labels
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — 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
compress_obj_text Ran
ran on a synthesized input
anshitag/memit_csk/memit_csk_dataset_script/data_creation_prompts.py
code served (permissive licence) · get_code("9a7df3cdd958346b")
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 torch

torch.manual_seed(0)

x = "the quick brown fox and a lazy dog with an apple"

ARGS = {
    "x": x
}
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 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
next_word_prediction Ran
ran on a synthesized input
anshitag/memit_csk/memit_csk_experiment/py/eval_utils_csk.py
code served (permissive licence) · get_code("21a7ebe6d0b7e62c")
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 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 torch.utils.data import DataLoader, Dataset

torch.manual_seed(0)

# Minimal model that satisfies the function's usage
class MinimalCausalLM(nn.Module):
    def __init__(self, vocab_size=100, hidden_size=4):
        super().__init__()
        self.embed = nn.Embedding(vocab_size, hidden_size)
        self.lm_head = nn.Linear(hidden_size, vocab_size)
    
    def forward(self, input_ids, attention_mask):
        x = self.embed(input_ids)
        logits = self.lm_head(x)
        return type('Output', (), {'logits': logits})()

# Minimal tokenizer stand-in
class MinimalTokenizer:
    def batch_decode(self, token_ids):
        # Convert tensor to list of strings
        if isinstance(token_ids, torch.Tensor):
            token_ids = token_ids.squeeze().tolist()
        if not isinstance(token_ids, list):
            token_ids = [token_ids]
        return [f"token_{tid}" for tid in token_ids]

# Minimal dataset
class MinimalDataset(Dataset):
    def __init__(self, num_samples=2, seq_len=5, vocab_size=100):
        self.num_samples = num_samples
        self.seq_len = seq_len
        self.vocab_size = vocab_size
    
    def __len__(self):
        return self.num_samples
    
    def __getitem__(self, idx):
        input_ids = torch.randint(0, self.vocab_size, (self.seq_len,))
        attention_mask = torch.ones(self.seq_len, dtype=torch.long)
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }

# Create instances
model = MinimalCausalLM(vocab_size=100, hidden_size=4)
tok = MinimalTokenizer()
dataset = MinimalDataset(num_samples=2, seq_len=5, vocab_size=100)
dataloader = DataLoader(dataset, batch_size=2, collate_fn=lambda batch: {
    'input_ids': torch.stack([b['input_ids'] for b in batch]),
    'attention_mask': torch.stack([b['attention_mask'] for b in batch])
})
device = 'cpu'

ARGS = {
    'model': model,
    'dataloader': dataloader,
    'tok': tok,
    'device': device
}
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 list, ndim 1, dtype family float — 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
parse_contracted_list_of_spo Ran
ran on a synthesized input
anshitag/memit_csk/memit_csk_dataset_script/data_creation_prompts.py
code served (permissive licence) · get_code("4584de7bb4670aff")
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 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

def parse_contracted_list_of_spo(q1s):
    q1s_new = []
    if len(q1s) < 3:
        for q1 in q1s:
            for q in q1.split('\n' if '\n' in q1 else ';' if ';' in q1 else ','):
                q1s_new.append(q)
    else:
        for q1 in q1s:
            q1s_new.append(q1)
    return [x.replace('Q ', '') for x in q1s_new if len(x) > 5]

# The function expects q1s to be a list of strings
# It handles two cases:
# 1. If len(q1s) < 3: splits each string by '\n', ';', or ','
# 2. Otherwise: uses strings as-is
# Then filters by length > 5 and replaces 'Q ' with ''

# Test case 1: short list with delimited strings
q1s_short = [
    "Q apple,Q banana,Q cherry",
    "Q dog;Q elephant"
]

# Test case 2: longer list with individual strings
q1s_long = [
    "Q apple",
    "Q banana",
    "Q cherry"
]

ARGS = {
    "q1s": q1s_short
}
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 1, dtype family float — 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
parse_enumerated Ran
ran on a synthesized input
anshitag/memit_csk/memit_csk_dataset_script/data_creation_prompts.py
code served (permissive licence) · get_code("bf7140fb644ca878")
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 re

def parse_enumerated(s: str) -> str:
    return re.sub('\\d\\.', '', s.strip()).split(':')[-1].split('. ')[-1].strip()

ARGS = {
    's': '1. First item: Some text. More text'
}
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 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
compute_rewrite_quality_csk Not yet run
unverified (harvested, no recorded run)
anshitag/memit_csk/memit_csk_experiment/py/eval_utils_csk.py
code served (permissive licence) · get_code("fe0ae44744a98f0c")
How it ran

no invocation recorded.

next_word_prediction Not yet run
unverified (harvested, no recorded run)
anshitag/memit_csk/base_finetune_experiments/fine_tune_gpt.py
code served (permissive licence) · get_code("4cc3d82d9e5710eb")
How it ran

no invocation recorded.

next_word_prediction Not yet run
unverified (harvested, no recorded run)
anshitag/memit_csk/repair_finetune_experiments/evaluate_affected_finetune_model.py
code served (permissive licence) · get_code("5919a0ddf3624795")
How it ran

no invocation recorded.

test_batch_prediction Not yet run
unverified (harvested, no recorded run)
anshitag/memit_csk/memit_csk_experiment/py/eval_utils_csk.py
code served (permissive licence) · get_code("a3c87c896ecd5bbb")
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 10 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 10 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

Transformers makes updating open-source transformer-based models possible without re-training (Meng et al., 2023). However, these editing methods have only been evaluated on statements about encyclopedic knowledge with a single correct answer. Commonsense knowledge with multiple correct answers, e.g., an apple can be green or red but not transparent, has not been studied but is as essential for enhancing transformers' reliability and usefulness. In this paper, we investigate whether commonsense judgments are causally associated with localized, editable parameters in Transformers, and we provide an affirmative answer. We find that directly applying the MEMIT editing algorithm results in sub-par performance, and propose to improve it for the commonsense domain by varying edit tokens and improving the layer selection strategy, i.e., MEMIT CSK . GPT-2 Large and XL models edited using MEMIT CSK outperform best-fine-tuned baselines by 10.97% and 10.73% F1 scores on PEP3k and 20Q datasets. In addition, we propose a novel evaluation dataset, PROBE SET, that contains unaffected and affected neighborhoods, affected paraphrases, and affected reasoning challenges. MEMIT CSK performs well across the metrics while fine-tuning baselines show significant trade-offs between unaffected and affected metrics. These results suggest a compelling future direction for incorporating feedback about common sense into Transformers through direct model editing. 1

For agents

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

get_harvested_code_for_paper("2305.14956")
get_code_for_paper("2305.14956")
have("2305.14956")

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

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

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

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

Connect an agent — have() is free.