Latent Knowledge Scalpel: Precise and Massive Knowledge Editing for Large Language Models

Xin Liu, Qiyang Song, Shaowen Xu, Kerou Zhou, Wenbo Jiang, Xiaoqi Jia, Weijuan Zhang, Heqing Huang, Yakai Li

TL;DR

Latent Knowledge Scalpel (LKS) is a model editing framework that updates factual knowledge in large language models (LLMs) without altering their underlying weights. By training a lightweight hypernetwork (a single linear layer occupying just 64MB) to surgically replace internal entity representations at inference time, LKS scales up to 10,000 simultaneous factual edits while maintaining high generalization and leaving the model’s core reasoning capabilities completely intact.

What Problem Does This Paper Address?

Pre-trained LLMs inevitably memorize incorrect, biased, or outdated information. While retraining or fine-tuning is computationally prohibitive, existing parameter-modifying editing techniques (such as ROME, MEMIT, and AlphaEdit) suffer from two major flaws:

  1. Capacity collapse: Their performance degrades rapidly when tasked with editing thousands of facts simultaneously.
  2. Side-effect damage: Modifying model weights often leads to severe overfitting, harming general reasoning, math, and comprehension abilities.

Retrieval-augmented generation (RAG) and prompting can circumvent weight modification, but they face strict context length limitations and prompt misalignment. Meanwhile, existing representation-swapping methods struggle to generalize to paraphrased queries. LKS addresses the challenge of making massive, targeted updates to LLM knowledge without breaking the underlying model.

Methods

Rather than modifying weight matrices, LKS treats internal hidden states as modular natural language representations:

Input Prompt ──> [ Edit Scope Indicator ] ──(If Target Entity Found)──> [ New KB Generator ]
                        │                                                     │ (Generates new KB)
                        │ (If Not Found)                                      ▼
                        └───────────────> [ Standard Inference ] <─── [ KB Replacer (Layer l) ]
  1. Empirical Grounding: The authors discover that an entity’s internal hidden state acts as an interpretable Knowledge Block (KB) that retains semantic and syntactic structure. Swapping an entity's KB mid-network behaves much like swapping a subject word in a natural language prompt.
  2. Three-Component Architecture:
  3. Edit Scope Indicator: Detects whether an input prompt mentions a target entity using fuzzy matching and Levenshtein distance.
  4. New KB Generator: A tiny hypernetwork (a single linear or MLP layer) trained on self-supervised extraction data ($D_{train}$) to output the replacement representation $\tilde{R}_\phi^l(E)$.
  5. KB Replacer: Hooks into a specific intermediate layer (determined via information-theoretic analysis to be Layer 16 for Llama-2-7B and Layer 18 for Mistral-7B) to substitute the entity’s hidden states during forward propagation.
  6. Training Objective: The hypernetwork is trained using a composite loss: $$\mathcal{L}(\phi) = \lambda_{edit} (\mathcal{L}_{edit} + \mathcal{L}_{eq}) + \mathcal{L}_{locality}$$ This optimizes accuracy on the edit target ($\mathcal{L}_{edit}$), generalizes to equivalent paraphrases ($\mathcal{L}_{eq}$), and bounds logits via KL-divergence on unrelated entity features ($\mathcal{L}_{locality}$).

Datasets

  • Factual Knowledge Editing:
  • zsRE (Zero-Shot Relation Extraction): Augmented with 10,000 GPT-4o-mini-generated related-locality prompts.
  • Counterfact: Augmented with 10,000 generality prompts and 10,000 related-locality prompts generated using GPT-4o-mini.
  • General Capabilities (Unrelated-Locality):
  • GSM8K: Mathematical word problem solving.
  • RTE (Recognizing Textual Entailment): Natural language inference.
  • SST2: Binary sentiment classification.

Key Insights and Ideas

  • Internal Representations Mirror Language Syntax: Swapping entity hidden states shifts downstream token probabilities toward the replacement entity just as cleanly as textual substitution, confirming that transformer activations maintain modular compositional syntax.
  • Intermediate Layers Provide Maximum Information Gain: Using Shannon information theory to calculate entropy differences ($\Delta I_f(\tilde{R} \to Y)$), the authors show that intermediate layers achieve the highest efficiency for knowledge injection. Earlier layers are too malleable, while late layers are overly fixed on specific output tokens.
  • Separation of Knowledge from Weights: Freezing the LLM weights and offloading factual changes to an external 64MB linear layer creates a clean firewall between base reasoning abilities and dynamic factual updates.

Key Results

  • Massive Simultaneous Editing ($T = 10,000$):
  • On Llama-2-7B, LKS achieved an 88.5% Edit Performance (EP) (97.9% Reliability, 93.8% Generality, 73.7% Locality). Competitors collapsed: MEMIT achieved 29.1% EP, WISE achieved 53.5% EP, and AlphaEdit dropped to 7.82% EP.
  • On Mistral-7B, LKS maintained a 77.9% EP at 10,000 edits, whereas MEMIT and AlphaEdit plummeted to 31.0% and 0.62% EP, respectively.
  • Preservation of General Intelligence: Across GSM8K, RTE, and SST2, base model accuracy was virtually unchanged with LKS after 10,000 edits, whereas MEMIT and AlphaEdit experienced near-complete degradation of general reasoning.
  • Fluency: LKS preserved natural generation fluency (measured by n-gram entropy), matching or slightly exceeding unedited models (5.65 vs. 5.36 on Llama-2-7B).

Limitations and Future Work

  • Scope Indicator Overhead: String matching and Levenshtein distance add computational latency before inference. Future iterations could adopt vector similarity search or entity alias dictionaries.
  • Tested Limits: Experiments stopped at 10,000 simultaneous edits due to the extreme GPU time required by baseline models; the actual upper capacity bound of LKS remains unexplored.
  • Safety Concerns: As with all model editing tools, the approach could theoretically be repurposed to inject malicious disinformation or backdoor triggers.

Summary updated

BibTeX
@inproceedings{liu2025latent,
  author = {Xin Liu and Qiyang Song and Shaowen Xu and Kerou Zhou and Wenbo Jiang and Xiaoqi Jia and Weijuan Zhang and Heqing Huang and Yakai Li},
  title = {{Latent Knowledge Scalpel: Precise and Massive Knowledge Editing for Large Language Models}},
  booktitle = {KnowFM @ ACL},
  year = {2025},
  url = {https://openreview.net/forum?id=ku6abNA5U5},
}
Figure