Machine Unlearning for Masked Diffusion Language Models

May 19, 2026 ยท View on GitHub

[arXiv preprint, 2026] ๐Ÿ“„ Paper (arXiv)


Updates

  • 05-19-2026: arXiv preprint online (arXiv:2605.18253).
  • 05-15-2026: Code released.

๐Ÿ” Framework Overview

MDU Framework Overview

MDU (Masked Diffusion Unlearning) is the first unlearning objective designed for masked diffusion language models (MDLMs) such as LLaDA and Dream. Treating unlearning as the structural inverse of MDLM fine-tuning, MDU pulls the prompt-conditional prediction back toward the prompt-masked unconditional prediction at every masked response position.


Getting Started

๐Ÿ› ๏ธ Environment Setup

git clone https://github.com/leegeoru/MDU.git
cd MDU

# Linux + CUDA 12.x (recommended)
conda create -n mdu python=3.10 -y && conda activate mdu
pip install -r requirements.txt

Tested with Python 3.10, PyTorch 2.7.0+cu128, transformers 4.57.0, NVIDIA H200 (141 GB HBM3e).


๐Ÿ“‚ Data and Backbones

All experiments use only public assets.

Dataset / ModelSourceLicense
TOFU (forget10)TOFU releaseMIT
RWKU (10 entities)RWKU releaseCC-BY-4.0
GSAI-ML/LLaDA-8B-InstructHuggingFaceMIT
Dream-org/Dream-v0-Instruct-7BHuggingFaceApache-2.0

For TOFU we additionally fine-tune each backbone on the full TOFU corpus to instil the target knowledge (LLaDA: 1000 epoch, Dream: 300 epoch). The SFT code itself is not part of this release; the resulting Base SFT checkpoint is consumed by run_main.sh via the LLADA_BASE_SFT / DREAM_BASE_SFT paths.


๐Ÿš€ MDU Training

Edit the paths at the top of run_main.sh first, then pass ฯ„โˆˆ{0,0.25,0.5,0.75,1}\tau \in \{0, 0.25, 0.5, 0.75, 1\} to set the anchor temperature.

# TOFU forget10 โ€” LLaDA-8B-Instruct
LR=1e-5 EPO=9 bash run_main.sh tofu_llada 0.5 ./outputs/llada_tofu_tau0p5

# TOFU forget10 โ€” Dream-7B-Instruct
LR=1e-5 EPO=5 bash run_main.sh tofu_dream 0.5 ./outputs/dream_tofu_tau0p5

# RWKU per-entity โ€” Dream-7B-Instruct
SUBJECT=1_Stephen_King
LR=1e-5 EPO=3 bash run_main.sh rwku_dream 0.5 \
    ./outputs/dream_rwku_${SUBJECT}_tau0p5 ${SUBJECT}

For the full RWKU sweep (10 entities), wrap run_main.sh rwku_dream in a loop over the canonical subject names listed in the paper.


๐Ÿ“Š Evaluation

# TOFU โ€” 4 splits (forget, retain, real_authors, world_facts)
python scripts/eval_tofu_llada.py --model ./outputs/llada_tofu_tau0p5/checkpoint-final
python scripts/eval_tofu_dream.py --model ./outputs/dream_tofu_tau0p5/checkpoint-final

# RWKU โ€” 8 metrics (F-L1/L2/L3, N-L1/L2, MMLU, TruthfulQA, TriviaQA)
TARGET="Stephen King"
python scripts/eval_rwku_dream.py \
    --model ./outputs/dream_rwku_${SUBJECT}_tau0p5/checkpoint-final \
    --target_subject "${TARGET}" \
    --output_dir ./outputs/dream_rwku_${SUBJECT}_tau0p5/eval

๐Ÿ“ Repository Layout

MDU/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ run_main.sh                  # MDU runner (TOFU / RWKU, both backbones)
โ”œโ”€โ”€ configs/
โ”‚   โ”œโ”€โ”€ mdu_tofu.yaml             # MDU hyperparameters used on TOFU
โ”‚   โ””โ”€โ”€ mdu_rwku.yaml             # MDU hyperparameters used on RWKU
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ unlearn_mdu_llada.py      # MDU loss for LLaDA-8B-Instruct
โ”‚   โ””โ”€โ”€ unlearn_mdu_dream.py      # MDU loss for Dream-7B-Instruct
โ””โ”€โ”€ scripts/
    โ”œโ”€โ”€ eval_tofu_llada.py
    โ”œโ”€โ”€ eval_tofu_dream.py
    โ”œโ”€โ”€ eval_rwku_dream.py        # 8 metrics
    โ”œโ”€โ”€ convert_rwku_to_tofu.py
    โ””โ”€โ”€ convert_rwku_dream_to_tofu.py

The MDU step itself is implemented in src/unlearn_mdu_{llada,dream}.py (search for null_anchor_tau, null_anchor_eta, null_anchor_kl_dir).


๐Ÿ“œ Citation

@misc{lee2026mdu,
      title={Machine Unlearning for Masked Diffusion Language Models}, 
      author={Georu Lee and Seungwon Jeong and Hoki Kim and Jinseong Park and Woojin Lee},
      year={2026},
      eprint={2605.18253},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2605.18253}, 
}

๐Ÿ“„ License

This repository is released under the MIT License (see LICENSE). External assets retain their original licenses: TOFU (MIT), RWKU (CC-BY-4.0), LLaDA-8B-Instruct (MIT), Dream-v0-Instruct-7B (Apache-2.0).