This repository contains the official implementation of our CVPR 2026 paper:
Test-Time Alignment of Text-to-Image Diffusion Models via Null-Text Embedding Optimisation (Null-TTA)
Taehoon Kim, Henry Gouk, Timothy Hospedales
arXiv: https://arxiv.org/abs/2511.20889
Null-TTA is a training-free, test-time alignment method for text-to-image diffusion models.
Instead of fine-tuning model parameters, Null-TTA optimizes the null-text (unconditional) embedding during sampling to improve a target objective, while preserving prior structure via regularization.
- Training-free alignment (no model fine-tuning)
- Null-text embedding optimisation at inference time
- Compatible with:
- Stable Diffusion v1.5
- Stable Diffusion XL (SDXL)
- Optional support for:
- PickScore
- Aesthetic score
- HPSv2
- ImageReward
conda create -n nulltta python=3.10
conda activate nulltta
pip install -e .Install only the reward models required for your experiments.
ImageReward
pip install --no-deps image-rewardHPSv2 Install from: https://github.com/tgxs002/HPSv2
python examples/null_tta_sd.py
python examples/null_tta_sd_nograd.py
python examples/null_tta_sdxl.pynull_tta_sd.py— Gradient-based Null-TTA on Stable Diffusion v1.5null_tta_sd_nograd.py— Non-gradient variant on SD v1.5null_tta_sdxl.py— Gradient-based Null-TTA on SDXL
--target_reward {pickscore,aesthetic,hpsv2,imagereward}--seed--num_inference_steps--num_particles--min_inner_steps--max_inner_steps--lr_uncond--tampering_coef--lambda_alpha--lambda_reg--phi_variance
Each run typically saves:
*_base.png— Baseline sample*_opt.png— Null-TTA optimized sampleresults.csv— Per-prompt scores- (Optional) hyperparameter summary CSV
Example directory structure:
logs_sdxl/
SDXL_NullTTA_particle_3_tampering_steps_5_to_25_42_target-pickscore/
A_100_B_0.002_G_0.01/
0_base.png
0_opt.png
results.csv
If you use this code, please cite:
@inproceedings{kim2026nulltta,
title = {Test-Time Alignment of Text-to-Image Diffusion Models via Null-Text Embedding Optimisation},
author = {Taehoon Kim and Henry Gouk and Timothy Hospedales},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2026}
}This implementation builds upon components and ideas from:
We thank the authors for open-sourcing their work.