# Safe dLLM Documentation

Welcome to Safe dLLM — a comprehensive framework for safety evaluation, training, and adversarial testing of LLaDA (Latent Diffusion Language Model).

https://img.shields.io/badge/Python-3.10+-blue.svg https://img.shields.io/badge/PyTorch-2.6.0-red.svg https://img.shields.io/badge/License-MIT-green.svg

Development

—

## What is Safe dLLM?

Safe dLLM is a research framework built on top of LLaDA (Latent Diffusion Language Model) for studying model safety, alignment, and adversarial robustness. It provides:

  • Training: SFT, CPT, and edit-based safety fine-tuning for LLaDA models

  • Evaluation: Integration with AISafetyLab scorers (LlamaGuard3, HarmBench, etc.)

  • Attacks: PAIR, ReNeLLM, and prefill attack methods

  • RLHF: Reward functions for math, code, and safety

Safe dLLM Architecture

System architecture overview

## Quick Example

Run a safety evaluation in 1 command:

python run_safety_benchmark.py \
    --model_path /path/to/llada_checkpoint \
    --dataset harmbench \
    --max_samples 10

Or train a model with Slurm:

sbatch scripts/submit_1_node_4_gpus_dpspd2_sft_llada.slurm

## Key Features

✅ Complete Training Pipeline - SFT, CPT, and edit-based fine-tuning ✅ Multiple Attack Methods - PAIR, ReNeLLM, prefill attacks ✅ Standard Evaluation - HarmBench, WildGuardMix with LlamaGuard3/HarmBench scorers ✅ Production Ready - Slurm scripts, multi-GPU support, checkpoint management ✅ Well Documented - Comprehensive guides and API references

## Documentation Structure

  • Quick Start - Get up and running in 5 minutes

  • User Guide - Detailed guides for training, evaluation, attacks

  • Configuration - Complete YAML configuration reference

  • API Reference - Python API documentation

  • Examples - Code examples for common tasks

## Getting Help

## Citation

If you use Safe dLLM in your research, please cite:

@article{safe_dllm2025,
  title={Safe dLLM: Safety Evaluation and Alignment for Latent Diffusion Language Models},
  author={Your Name},
  journal={arXiv preprint},
  year={2025}
}

—