rome-model-editing

Edit factual associations in GPT models using ROME and causal tracing.

75|7|Updated May 2, 2026
One-click install
npx skills add https://github.com/zjunlp/Mechanist --skill rome-model-editing-zjunlp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rome-model-editing
Source: https://github.com/zjunlp/Mechanist/tree/main/skills/mechanism-skills/causal-attribution/patching
Command: npx skills add https://github.com/zjunlp/Mechanist --skill rome-model-editing-zjunlp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, transformers, numpy, matplotlib, rome, and includes scripts (resource) and references (resource) components.

What problem does it solve? Modifying factual knowledge inside large language models like GPT-2 XL or GPT-J normally requires expensive retraining, and understanding where a model stores a specific fact requires manual probing. This Skill provides working scripts for causal tracing and Rank-One Model Editing (ROME) so you can locate critical layers and rewrite specific factual associations directly. ## Core Features & Use Cases - Causal Tracing: Trace information flow through transformer layers to identify which layers are critical for a given factual association, with visualization of layer effects. - ROME Model Editing: Apply rank-one weight updates to MLP layers to change what a model believes about a subject (e.g., change "LeBron James plays basketball" to "football") without retraining. - API Reference: Includes a detailed reference for ROME hyperparameters, baseline methods (fine-tuning, Knowledge Neurons), and evaluation utilities. - Use Case: A researcher studying mechanistic interpretability wants to verify that factual recall localizes to specific MLP layers, then surgically edit one fact and measure efficacy, generalization, and specificity of the edit. ## Quick Start Run the ROME editing example script to load GPT-2 XL, apply a factual edit to a subject like LeBron James, and compare model completions before and after the edit.

Frequently Asked Questions about rome-model-editing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I edit factual knowledge in GPT-2 without retraining?

Use Rank-One Model Editing (ROME) to apply a rank-one update to a specific MLP layer's weights. You provide an edit request with a subject, prompt template, and new target, and the method modifies the factual association while preserving other model behavior.

What is causal tracing in transformer models?

Causal tracing measures how restoring clean activations at each layer affects the model's output probability for a factual statement. It identifies which layers are critical for storing a given fact, typically revealing mid-layer MLPs as key storage sites.

Which models does ROME model editing support?

The scripts target GPT-2 XL and GPT-J (EleutherAI/gpt-j-6B), with architecture handling for both GPT-2 style transformer.h blocks and GPT-J style blocks. A CUDA-enabled GPU is required for editing, and float32 precision is recommended for tracing.

How does ROME compare to fine-tuning or Knowledge Neurons?

The reference documents fine-tuning (FT) and Knowledge Neurons (KN) as baseline editing methods with their own hyperparameters. ROME uses second-moment statistics and constrained optimization for more localized edits, while FT fine-tunes layers directly and KN modifies individual knowledge neurons.

Why does my ROME edit not change the model output?

Edits can fail if the target layer does not store the fact, hyperparameters like v_lr or v_num_grad_steps are misconfigured, or second-moment statistics were not computed for the layer. Run causal tracing first to confirm the critical layer before editing.