Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lazy Unlearner: Code & Results

This repository contains code and results accompanying the article Finding and Fighting the Lazy Unlearner: An Adversarial Approach. Our goal is to enable reproducibility of the main experiments and analyses presented in the article.


Repository Structure

  • rmu/ – Code for RMU training and producing model outputs.
  • sae/ – Code for analyzing RMU models using Sparse Autoencoders (SAE) and related probes.
  • notebooks/ – Example notebooks for analysis.

Each folder has its own environment setup (pyproject.toml) and scripts.


Setup

Clone the repository:

git clone https://github.com/vietfood/lazy-unlearer.git
cd lazy-unlearner

(Optional) On a fresh Ubuntu machine, run:

source setup.sh

This will update packages, install the latest CUDA, uv, nvtop, and other dependencies needed for GPU usage.


1. RMU Training

The rmu/ folder contains scripts for RMU training. To reproduce the results:

  1. Setup the environment:
cd rmu
make setup

This installs all dependencies via uv. You will need valid Hugging Face and Weights & Biases (wandb) keys.

  1. Run the training script:
  • Move run_test.py and run_base.sh outside the scripts/ folder.
  • Execute the main run script:
source run_base.sh

For multi-GPU training, launch with accelerate and set the process count to the number of GPUs you want to use. Example for 2 GPUs:

cd rmu
CUDA_VISIBLE_DEVICES=0,1 uv run accelerate launch --num_processes 2 run.py \
  --model_name_or_path "google/gemma-2-2b-it" \
  --steering_coeffs 750 750 \
  --alpha 300 300 \
  --layer_id 9 \
  --max_num_batches 300 \
  --batch_size 4 \
  --type "original" \
  --gradient_checkpointing \
  --gradient_accumulation_steps 1 \
  --noverbose

Scale --num_processes and CUDA_VISIBLE_DEVICES to match your available GPUs.

This produces the RMU-trained models used in the experiments.

For the split-GPU RMU setup where the trainable model stays on one GPU and the frozen reference model stays on a second GPU, you can use:

cd rmu
bash scripts/run_gemma3_4b_split.sh

For lower-fidelity hyperparameter search on the same split-GPU setup:

cd rmu
bash scripts/hp_search_gemma3_4b_split.sh

Both scripts accept environment variable overrides such as MODEL_NAME, LAYER_ID, BATCH_SIZE, MAX_NUM_BATCHES, SEARCH_N_TRIALS, and CUDA_VISIBLE_DEVICES.


2. RMU Analysis

The sae/ folder contains code for analyzing RMU models. To reproduce the analysis:

  1. Setup the environment:
cd sae
make setup

Same as above, requires Hugging Face and wandb keys.

  1. Run analysis notebooks:
  • Move the desired notebook from notebooks/ to the main folder.
  • Open and run it in your preferred environment (e.g., Jupyter or VSCode).

This will reproduce key figures and metrics from the article.


Citing This Work

If you use this work in your research, please cite:

@misc{ln2025rmu,
    author={Nguyen Le},
    title={Finding and Fighting the Lazy Unlearner: An Adversarial Approach},
    year={2025},
    url={https://lenguyen.vercel.app/note/rmu-improv}
}

Optional Notes / Tips:

  • Ensure your GPU drivers and CUDA toolkit are compatible with the version specified in pyproject.toml.
  • For large models, consider using nvtop to monitor GPU memory usage.
  • Keep run_test.py outside of scripts/ folder (for RMU) and notebooks outside of notebooks/ (for analysis) to avoid path issues.

About

No description or website provided.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages