SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.16356 · EMNLP · 2025

CaKE: Circuit-aware Editing Enables Generalizable Knowledge Learners

Nanyun Peng, Ningyu Zhang, Shumin Deng, Huajun Chen, Yunzhi Yao, Jia-Chen Gu, Jizhan Fang, Washington London

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; 1 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 1 failure 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/2503.16356.json · badge: /api/ran/2503.16356.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
zjunlp/CaKE canonical (classifier label)
classifier basis not recorded on the link
6 ran · 4 no recorded run
FunctionStatusWhere it lives
check_answer_in_pred Ran
ran on a synthesized input
zjunlp/CaKE/edit_utils.py
code served (permissive licence) · get_code("945b25058773f916")
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 bool, 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

def check_answer_in_pred(pred, answers):
    pred = pred.lower()
    return any([a.lower() in pred for a in answers])

ARGS = {
    "pred": "The capital of France is Paris",
    "answers": ["Paris", "PARIS", "paris"]
}
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 bool, 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
create_source_prompt Ran
ran on a synthesized input
zjunlp/CaKE/Analysis/patch_entity_relation.py
code served (permissive licence) · get_code("1d3e75561037af36")
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 Series. 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 pandas as pd
import torch

# Create a minimal dataset with the required columns
dataset = pd.DataFrame({
    'r2_template': [
        'The capital of {} is',
        'The founder of {} was'
    ],
    'patch_e': [
        'France',
        'Apple'
    ],
    'patch_r_template': [
        'The location of {} is',
        'The CEO of {} is'
    ],
    'e2_label': [
        'Paris',
        'Tim Cook'
    ]
})

source = 'patch_e'

ARGS = {
    'dataset': dataset,
    'source': source
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Series — a Series output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Series 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
create_target_prompt Ran
ran on a synthesized input
zjunlp/CaKE/Analysis/patch_activations.py
code served (permissive licence) · get_code("b4056caf852d83d8")
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 Series. 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 pandas as pd
import numpy as np

# Create a minimal DataFrame that satisfies the function's requirements
# The function uses .apply() with lambda functions accessing specific columns
# and direct column access with ['source_prompt']

data = {
    'source_prompt': [
        'The capital of France is Paris',
        'The largest planet is Jupiter'
    ],
    'e1_label': ['France', 'Jupiter'],
    'r2_template': ['The continent of {}', 'The type of {}'],
    'r1_template': ['The country {}', 'The planet {}']
}

dataset = pd.DataFrame(data)

ARGS = {
    'dataset': dataset,
    'source': 'e1',
    'target': 'composition'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Series — a Series output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Series 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
find_layers_by_classification Ran
ran, honoured the contract we drafted
zjunlp/CaKE/Analysis/classify_results.py
code served (permissive licence) · get_code("3820700493cb2dd1")
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 DataFrame. 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 pandas as pd
import numpy as np

# Create a sample DataFrame that matches the expected structure
# The function expects a DataFrame with columns: 'id', 'classification', and either 'layer' or 'source_layer'
classified_generations = pd.DataFrame({
    'id': [1, 1, 1, 2, 2, 2],
    'classification': ['typeA', 'typeA', 'typeB', 'typeA', 'typeB', 'typeB'],
    'layer': [0, 1, 2, 0, 1, 2]
})

ARGS = {
    'classified_generations': classified_generations,
    'classification': 'typeA',
    'col_name': 'min_layer',
    'apply_min': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family int 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_layer_names Ran
ran on a synthesized input
zjunlp/CaKE/Analysis/utils.py
code served (permissive licence) · get_code("c18c0c86a00c6eee")
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
from transformers import GPT2LMHeadModel, LlamaForCausalLM, GemmaForCausalLM, Qwen2ForCausalLM
from transformers.models.gpt2.configuration_gpt2 import GPT2Config
from transformers.models.llama.configuration_llama import LlamaConfig

torch.manual_seed(0)

class MinimalConfig:
    def __init__(self, num_hidden_layers):
        self.num_hidden_layers = num_hidden_layers

gpt2_config = GPT2Config(n_embd=64, n_layer=3, n_head=2, vocab_size=256)
gpt2_model = GPT2LMHeadModel(gpt2_config)

ARGS = {
    'model': gpt2_model
}
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
mean_pooling Ran
ran; our contract draft was wrong, not the code
zjunlp/CaKE/edit_utils.py
pointer only (licence: MIT); the stored copy get_code serves, from chenyiqun/MMOA-RAG, is pointer only (licence: NONE) · get_code("fe0e2df4d9cb5edd")
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 chenyiqun/MMOA-RAG, 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.

find_tokens Not yet run
unverified (harvested, no recorded run)
zjunlp/CaKE/Analysis/patched_generation.py
code served (permissive licence) · get_code("5c1337c4e1ef4149")
How it ran

no invocation recorded.

get_sent_embeddings Not yet run
unverified (harvested, no recorded run)
zjunlp/CaKE/edit_utils.py
code served (permissive licence) · get_code("f66e21558e4c092b")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
zjunlp/CaKE/Analysis/utils.py
code served (permissive licence) · get_code("bb42f5ad478b4dbf")
How it ran

no invocation recorded.

load_tokenizer Not yet run
unverified (harvested, no recorded run)
zjunlp/CaKE/Analysis/utils.py
code served (permissive licence) · get_code("91a41852736ee2f5")
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, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 1 later) and 5 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
mean_pooling 15 other papers
10 dated earlier, 4 later, 1 same year, order not determinable
2304.11406 (2023-04)
LaMP: When Large Language Models Meet Personalization
2305.18395 (2023-05)
Knowledge-Augmented Reasoning Distillation for Small Language Models in Knowledge-Intensive Tasks
2308.04275 (2023-08)
In-Context Alignment: Chat with Vanilla Language Models Before Fine-Tuning
and 12 more not named here
find_layers_by_classification 1 other paper
1 dated earlier
2406.12775 (2024-06)
Hopping Too Late: Exploring the Limitations of Large Language Models on Multi-Hop Queries
find_tokens 1 other paper
1 dated earlier
2406.12775 (2024-06)
Hopping Too Late: Exploring the Limitations of Large Language Models on Multi-Hop Queries
load_model 1 other paper
1 dated earlier
2406.12775 (2024-06)
Hopping Too Late: Exploring the Limitations of Large Language Models on Multi-Hop Queries
load_tokenizer 1 other paper
1 dated earlier
2406.12775 (2024-06)
Hopping Too Late: Exploring the Limitations of Large Language Models on Multi-Hop Queries

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

Knowledge Editing (KE) enables the modification of outdated or incorrect information in large language models (LLMs). While existing KE methods can update isolated facts, they often fail to generalize these updates to multihop reasoning tasks that rely on the modified knowledge. Through an analysis of reasoning circuits-the neural pathways LLMs use for knowledge-based inference, we find that current layer-localized KE approaches (e.g., MEMIT, WISE), which edit only single or a few model layers, inadequately integrate updated knowledge into these reasoning pathways. To address this limitation, we present CaKE (Circuit-aware Knowledge Editing), a novel method that enhances the effective integration of updated knowledge in LLMs. By only leveraging a few curated data samples guided by our circuit-based analysis, CaKE stimulates the model to develop appropriate reasoning circuits for newly incorporated knowledge. Experiments show that CaKE enables more accurate and consistent use of edited knowledge across related reasoning tasks, achieving an average improvement of 20% in multi-hop reasoning accuracy on the MQuAKE dataset while requiring less memory than existing KE methods. We release the code and data in https://github.com/zjunlp/CaKE.

For agents

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

get_harvested_code_for_paper("2503.16356")
get_code_for_paper("2503.16356")
have("2503.16356")

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

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

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

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

Connect an agent — have() is free.