[Paper Review] KNN-Diffusion: Image Generation via Large-Scale Retrieval
KNN-Diffusion trains a text-to-image diffusion model without text data by conditioning on k-nearest neighbor image embeddings retrieved in a joint CLIP space, enabling text-driven generation, out-of-distribution sampling, and mask-free local manipulations.
Recent text-to-image models have achieved impressive results. However, since they require large-scale datasets of text-image pairs, it is impractical to train them on new domains where data is scarce or not labeled. In this work, we propose using large-scale retrieval methods, in particular, efficient k-Nearest-Neighbors (kNN), which offers novel capabilities: (1) training a substantially small and efficient text-to-image diffusion model without any text, (2) generating out-of-distribution images by simply swapping the retrieval database at inference time, and (3) performing text-driven local semantic manipulations while preserving object identity. To demonstrate the robustness of our method, we apply our kNN approach on two state-of-the-art diffusion backbones, and show results on several different datasets. As evaluated by human studies and automatic metrics, our method achieves state-of-the-art results compared to existing approaches that train text-to-image generation models using images only (without paired text data)
Motivation & Objective
- Enable training of a text-to-image diffusion model without any text data using large-scale image embeddings.
- Leverage kNN retrieval to broaden conditioning distributions and bridge train/inference gaps.
- Demonstrate out-of-distribution generation by swapping retrieval databases at inference time.
- Show text-driven local semantic manipulation without needing edit masks.
- Validate the approach across multiple diffusion backbones and datasets.
Proposed method
- Use CLIP as a shared multi-modal encoder for text and image embeddings.
- Maintain a non-trainable kNN retrieval index over image embeddings indexed by f_img to supply k nearest neighbors.
- Condition the diffusion model on both the input embedding (training on image) or text embedding (inference) and on the kNN embeddings retrieved from the index.
- Apply both discrete and continuous diffusion backbones to demonstrate robustness of the approach.
- Adopt a training regime where the model learns to reconstruct originals from manipulated images that replace local regions with their kNN counterparts.
- Extend the manipulation framework to local, text-guided edits without user-provided masks by conditioning on the CLIP embedding of the target modification.
Experimental results
Research questions
- RQ1Can a text-to-image diffusion model be trained without any text data by leveraging large-scale image retrieval in a shared CLIP space?
- RQ2Does conditioning on kNN image embeddings improve alignment between text and image distributions during training and inference?
- RQ3Can retrieval-based conditioning enable out-of-distribution image generation by swapping retrieval databases at inference?
- RQ4Is local, semantic image manipulation possible without masks, guided by text prompts, while preserving object identity?
- RQ5Do discrete and continuous diffusion backbones benefit from kNN conditioning in image generation and manipulation tasks?
Key findings
- The kNN-Diffusion framework achieves state-of-the-art zero-shot results on MS-COCO, LN-COCO, and CUB when trained on image data only.
- Models trained with kNN conditioning outperform baselines trained without kNN across both discrete and continuous diffusion backbones.
- The approach enables out-of-distribution image generation by swapping retrieval databases at inference without retraining.
- It supports local, semantic image manipulations guided by text prompts without requiring user-provided masks, preserving object identity.
- Human evaluations and FID metrics demonstrate superior image quality and text alignment compared to baselines and several text-trained models, with relatively small parameter counts and fast inference.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.