Skip to main content
QUICK REVIEW

[Paper Review] Inspecting and Editing Knowledge Representations in Language Models

Evan Hernandez, Belinda Z. Li|arXiv (Cornell University)|Apr 3, 2023
Topic ModelingComputer Science16 citations
TL;DR

remedi learns affine edits to LM entity representations to insert or modify factual attributes, enabling controlled generation and probing of knowledge in language models without global weight changes.

ABSTRACT

Neural language models (LMs) represent facts about the world described by text. Sometimes these facts derive from training data (in most LMs, a representation of the word "banana" encodes the fact that bananas are fruits). Sometimes facts derive from input text itself (a representation of the sentence "I poured out the bottle" encodes the fact that the bottle became empty). We describe REMEDI, a method for learning to map statements in natural language to fact encodings in an LM's internal representation system. REMEDI encodings can be used as knowledge editors: when added to LM hidden representations, they modify downstream generation to be consistent with new facts. REMEDI encodings may also be used as probes: when compared to LM representations, they reveal which properties LMs already attribute to mentioned entities, in some cases making it possible to predict when LMs will generate outputs that conflict with background knowledge or input text. REMEDI thus links work on probing, prompting, and LM editing, and offers steps toward general tools for fine-grained inspection and control of knowledge in LMs.

Motivation & Objective

  • Motivate the need for controllable and interpretable knowledge in LMs due to context integration failures and outdated or biased training data.
  • Propose remedi to intervene in LM representation spaces to encode desired attributes for entities.
  • Demonstrate that remedi edits can patch context-incoherent outputs and insert new facts while preserving fluency.
  • Show that remedi can also function as a probe to interpret LM representations and predict when outputs may contradict background knowledge.

Proposed method

  • Learn an affine editor F that transforms an entity representation h_entity using an attribute representation h_attr: z = h_entity + W h_attr + b.
  • Obtain h_attr by averaging the LM's encoding of the textual attribute t_attr.
  • Train F to maximize the probability of a target generation t_tgt after editing the entity representation, using a loss that directly optimizes generation outcomes: L_tgt(z) = - p_LM(x_n = t_tgt | x_1:n-1, h_entity = z).
  • In addition, include a prior loss to discourage re-asserting old facts (L_prior) and a KL-divergence loss (L_KL) to minimize undesired shifts in intermediate token distributions, yielding a combined objective L(z) = L_tgt(z) + λ1 L_prior(z) + λ2 L_KL(z).
  • Train remedi on out-of-context data (entity names only) and test its effects in-context and out-of-context.
  • Evaluate both control of LM output (efficacy, fluency, etc.) and interpretability of representations (probabilistic changes to feature associations).

Experimental results

Research questions

  • RQ1Can remedi reliably edit an LM's internal representations to encode new factual attributes for entities?
  • RQ2Do remedi edits patch incoherent context integration and override background knowledge without harming fluency?
  • RQ3Can remedi serve as a probe to reveal what attributes LMs already encode and to anticipate when outputs may conflict with knowledge or text prompts?
  • RQ4How do remedi edits compare to prompt-based prompting, model editing methods, and fine-tuning in terms of effectiveness and locality of edits?
  • RQ5Do edits to generic concepts (e.g., olives, airplanes) propagate to related features in a human-aligned way?

Key findings

  • remedi increases accuracy of occupation predictions for named entities in-context from 0.55 to 0.71 and preserves fluency; out-of-context, remedi raises accuracy from near chance to fluent, correct generations.
  • remedi can overwrite background knowledge (e.g., Versace HQ in London) with new facts while maintaining fluency and limiting unintended changes to related entities (less destructive than fine-tuning).
  • on CounterFact, remedi achieves high efficacy (≈98.2) and maintains neighborhood and fluency, performing comparably to model-editing methods and better than prompt-based baselines for targeted edits.
  • remedi edits produce strong, targeted changes in feature associations for concepts (e.g., adding is made of metal to olives increases correlated features and human-aligned co-occurrence), while preserving most original feature relations and exhibiting manageable shifts in essence.
  • remedi demonstrates that entity representations can be edited from context without global parameter changes, enabling controlled generation and interpretability of knowledge in LMs.
  • remedi yields substantial improvements in prompting vs. editing baselines, with less collateral impact on unrelated entities compared to weight-space editing methods like ROME or fine-tuning.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.