An ablation study comparing an autoregressive language model and a masked diffusion language model (MDLM) on the task of zero-shot text restoration: filling in masked/corrupted spans of a document without any task-specific fine-tuning.
Autoregressive (AR) language models generate text left-to-right, which makes controlled infilling awkward: they rely on Fill-in-the-Middle (FIM) prompting tricks to condition on both a prefix and a suffix. Masked diffusion language models instead generate all tokens jointly through iterative denoising, making bidirectional infilling a native operation rather than a prompting workaround.
This project asks: does that structural advantage translate into better zero-shot restoration quality, and how do the two paradigms trade off against corruption type, corruption severity, and inference cost?
Text is corrupted with two strategies, then restored by each model and scored against the original:
RandomTokenMasking — independently masks a random subset of individual words.SpanMasking — masks a single contiguous run of words (a structured gap).QwenFIMRestorer — Qwen2.5-Coder via Fill-in-the-Middle prompting (AR baseline).MDLMRestorer — kuleshov-group/mdlm-owt, a masked diffusion LM restored via iterative denoising (src/mdlm_utils.py), with the number of denoising steps as an ablation axis.The full ablation grid varies masking ratio (0.1 / 0.3 / 0.5), corruption type (span / random token), and — for MDLM — the number of denoising timesteps, over a sample of WikiText-103.
src/
data.py # dataset loading + corruption strategies
models.py # Restorer wrappers (Qwen FIM, MDLM)
mdlm_utils.py # MDLM denoising loop, mask-token/token-alignment helpers
flash_attn_shim.py # pure-PyTorch stand-in for flash-attn (T4-compatible)
eval.py # ROUGE-L / BERTScore / perplexity computation
tests/ # unit tests, run entirely against mock/toy data
run_experiment.ipynb # Colab entrypoint: runs the full ablation study with real models
data/experiment_results/ # exported results (CSV, JSON) and plots from the ablation run
pip install -r requirements.txt
pytest
The test suite and all local development run exclusively against dummy/mock inference and a small in-memory toy dataset — no model weights or datasets are downloaded. Real inference (Qwen2.5-Coder, MDLM, real WikiText-103, real BERTScore/perplexity) only happens inside run_experiment.ipynb, intended to run on Colab with a GPU (use_mock=False).
Aggregated results from the full ablation run (2,400 restoration/evaluation records, spanning both models, both corruption types, and three masking ratios) are in data/experiment_results/:
ablation_results.csv / ablation_results.json — per-record scores (ROUGE-L, BERTScore, perplexity, latency) and configuration.model_headline_summary.png — overall AR vs. MDLM comparison.corruption_type_comparison.png — span vs. random-token masking.rouge_l_f1_vs_ratio.png, bertscore_f1_vs_ratio.png — quality degradation as masking ratio increases.mdlm_timesteps_tradeoff.png — MDLM quality vs. number of denoising steps (inference-cost trade-off).perplexity_distribution.png — fluency of restored text.Released under the MIT License.
35 commits
Python
85.0%
Jupyter Notebook
15.0%
An ablation study comparing an autoregressive language model and a masked diffusion language model (MDLM) on the task of zero-shot text restoration: filling in masked/corrupted spans of a document without any task-specific fine-tuning.
Autoregressive (AR) language models generate text left-to-right, which makes controlled infilling awkward: they rely on Fill-in-the-Middle (FIM) prompting tricks to condition on both a prefix and a suffix. Masked diffusion language models instead generate all tokens jointly through iterative denoising, making bidirectional infilling a native operation rather than a prompting workaround.
This project asks: does that structural advantage translate into better zero-shot restoration quality, and how do the two paradigms trade off against corruption type, corruption severity, and inference cost?
Text is corrupted with two strategies, then restored by each model and scored against the original:
RandomTokenMasking — independently masks a random subset of individual words.SpanMasking — masks a single contiguous run of words (a structured gap).QwenFIMRestorer — Qwen2.5-Coder via Fill-in-the-Middle prompting (AR baseline).MDLMRestorer — kuleshov-group/mdlm-owt, a masked diffusion LM restored via iterative denoising (src/mdlm_utils.py), with the number of denoising steps as an ablation axis.The full ablation grid varies masking ratio (0.1 / 0.3 / 0.5), corruption type (span / random token), and — for MDLM — the number of denoising timesteps, over a sample of WikiText-103.
src/
data.py # dataset loading + corruption strategies
models.py # Restorer wrappers (Qwen FIM, MDLM)
mdlm_utils.py # MDLM denoising loop, mask-token/token-alignment helpers
flash_attn_shim.py # pure-PyTorch stand-in for flash-attn (T4-compatible)
eval.py # ROUGE-L / BERTScore / perplexity computation
tests/ # unit tests, run entirely against mock/toy data
run_experiment.ipynb # Colab entrypoint: runs the full ablation study with real models
data/experiment_results/ # exported results (CSV, JSON) and plots from the ablation run
pip install -r requirements.txt
pytest
The test suite and all local development run exclusively against dummy/mock inference and a small in-memory toy dataset — no model weights or datasets are downloaded. Real inference (Qwen2.5-Coder, MDLM, real WikiText-103, real BERTScore/perplexity) only happens inside run_experiment.ipynb, intended to run on Colab with a GPU (use_mock=False).
Aggregated results from the full ablation run (2,400 restoration/evaluation records, spanning both models, both corruption types, and three masking ratios) are in data/experiment_results/:
ablation_results.csv / ablation_results.json — per-record scores (ROUGE-L, BERTScore, perplexity, latency) and configuration.model_headline_summary.png — overall AR vs. MDLM comparison.corruption_type_comparison.png — span vs. random-token masking.rouge_l_f1_vs_ratio.png, bertscore_f1_vs_ratio.png — quality degradation as masking ratio increases.mdlm_timesteps_tradeoff.png — MDLM quality vs. number of denoising steps (inference-cost trade-off).perplexity_distribution.png — fluency of restored text.Released under the MIT License.
35 commits
Python
85.0%
Jupyter Notebook
15.0%