Minimal-scale research project comparing discrete diffusion language models against autoregressive (AR) transformers on IMDB. The core question:
How many denoising steps does a PLM-initialized diffusion LM actually need to match an equally sized AR baseline?
One-sentence summary: We implement matched ~55 M parameter AR, diffusion, and LLaDA-style hybrids on IMDB to map quality, diversity, and latency as we reduce diffusion/refinement steps down to the smallest count that still matches the AR baseline.
Artifacts at a glance
- 📄 Full LaTeX paper with AI-generated disclaimer:
docs/paper.tex - 📊 Executive summary + tables:
docs/results_summary.md/.pdf - 📁 Raw metrics + samples:
results/ablation_results.{json,csv,md} - 🖼 Plots ready for publication:
results/plots/*.pdf
python -m venv venv
.\venv\Scripts\activate # PowerShell on Windows
pip install -r requirements.txt
pip install -e .python -c "from data.prepare_dataset import prepare_dataset; prepare_dataset()"First run tokenizes IMDB and saves to data/cache/. Reuses cached tensors afterward.
python train.py --model arSaves checkpoints/ar_model.pt after 10 epochs (config: configs/ar_lm.yaml). Current settings use CPU-friendly batch 8 + gradient accumulation 4.
python train.py --model diffusionSaves checkpoints/diffusion_model.pt (config: configs/diffusion_lm.yaml). Trains once with 1000-step cosine schedule; inference later sweeps smaller step counts.
python train.py --model bothpython -m pytest tests/ -vSpecific suites:
python -m pytest tests/test_ar_model.py -v
python -m pytest tests/test_diffusion_model.py -v
python -m pytest tests/test_metrics.py -vpython evaluate.py --num-samples 10Outputs results/evaluation.json with samples plus BLEU/ROUGE/self-BLEU/distinct-$n$ and throughput statistics. Mirrors the metrics used in the paper.
python experiments/run_ablations.pyWill produce JSON/CSV tables covering diffusion steps {1,5,10,50,100,500,1000} plus sanity-check logging (flag if trends violate PRD expectations).
evaluation/plots.py renders:
- Quality vs. diffusion steps
- Diversity vs. diffusion steps
- Inference time vs. diffusion steps
- Diffusion vs. AR trade-off curve
All saved as .pdf in results/plots/ for paper inclusion.
diffusion-step-efficiency/
├── README.md
├── configs/
├── data/
├── docs/
│ └── research_paper.md
├── evaluation/
├── experiments/
├── inference/
├── models/
├── tests/
├── training/
├── train.py
├── evaluate.py
└── checkpoints/ (runtime)
| Model / Setting | BLEU | ROUGE-L | Distinct-2 | Tokens/sec |
|---|---|---|---|---|
| AR baseline | 0.021 | 0.062 | 0.293 | 13.5 |
| Diffusion (100 steps) | 0.030 | 0.082 | 0.983 | 14.6 |
| Diffusion (500 steps) | 0.058 | 0.149 | 0.726 | 4.0 |
| LLaDA (8 iterations) | 0.042 | 0.121 | 0.260 | 334.4 |
| LLaDA (12 iterations) | 0.043 | 0.121 | 0.249 | 240.1 |
See docs/results_summary.md or the LaTeX paper for complete tables (all step counts/iterations, latency, self-BLEU).
- ✅ AR model trained on CPU (
checkpoints/ar_model.pt) - ✅ Diffusion model trained + step-count ablations logged (
results/ablation_results.*) - ✅ Evaluation scripts report BLEU/ROUGE/distinct/self-BLEU/tokens-sec with sanity checks
- ✅ Plotting module + CSV/Markdown export finished (
results/plots/,results/ablation_results.md) - 📝 Research paper + summary docs at
docs/paper.tex,docs/results_summary.md
- Works on CPU (16 GB RAM) albeit slowly (~12–16 h per model)
- GPU configs available (set
hardware.device: cuda, adjust batch size) - Cached dataset occupies ~3 GB under
data/cache/
- Ho et al., Denoising Diffusion Probabilistic Models
- Li et al., Diffusion-LM
- LLaDA: Latent Language Diffusion for Autoregressive Decoding
- GPT-style AR transformers for baseline matching
