Introduction
Personalizing text-to-image models like Stable Diffusion allows users to introduce unique concepts—such as a specific pet or a custom piece of furniture—into the model's vocabulary. Techniques like Textual Inversion (TI) achieve this by learning a new pseudo-word (e.g., cat*) from a few reference images. However, these methods frequently suffer from a lack of compositionality. When a user prompts the model with "a cat* chasing butterflies," the resulting image often features the specific cat but fails to include the butterflies or the requested action. This paper investigates the mechanics of this "overfitting" and proposes Compositional Inversion, a post-training method designed to blend custom concepts seamlessly with existing ones.
The Mechanics of Attention Hijacking
Previous research often attributed poor compositionality to simple overfitting. However, this study reveals a deeper geometric cause. When a new concept is inverted, the resulting embedding often falls out-of-distribution (OOD) relative to the pretrained embedding space. These OOD embeddings tend to have higher entropy because they inadvertently encode irrelevant background details from the training samples.
During the diffusion process, these high-entropy embeddings monopolize the cross-attention mechanism. Essentially, the pseudo-word's attention queries match too broadly across the latent noise, physically crowding out the attention maps of other tokens in the prompt. This "attention hijacking" makes the model effectively blind to other elements of the user's request.
Compositional Inversion: A Two-Fold Solution
To address these issues without the heavy computational cost of fine-tuning the entire U-Net (as seen in methods like DreamBooth), the authors introduce a two-part approach:
1. Semantic Inversion
Instead of allowing pseudo-embeddings to drift into OOD regions, the authors use "semantic attractors." By identifying a set of general anchor concepts (e.g., pet, animal, furniture), they apply a sparse coding loss that pulls the new embedding toward the core distribution of semantically related standard tokens. This ensures the embedding remains well-behaved and "understandable" by the model's existing weights.
2. Spatial Inversion
To prevent the custom concept from bleeding into the entire image area, the authors regularize the cross-attention maps. They utilize a small Multi-Layer Perceptron (MLP) to predict logical bounding boxes for pairs of concepts. During the early stages of reverse diffusion, a loss function forces the attention maps to stay within these predicted spatial boundaries, ensuring that both the custom concept and the surrounding elements have their own dedicated space in the final image.
Evaluation and Results
The method was evaluated using 10 diverse custom concepts and 1,600 compositional prompts. The results demonstrate a significant leap in the model's ability to handle complex scenes.
- Quantitative Gains: Compositional Inversion improved Concept of Interest (CoI) Likelihood—the probability that all requested objects appear—by up to 52.9%. Text-alignment also saw improvements of up to 16.4% over baselines like Textual Inversion and Custom Diffusion.
- Qualitative Success: As shown in the examples below, the method allows for natural interactions between personalized subjects and their environments, such as a specific dog "coding" or a cat "piloting a spaceship."
While there is a minor trade-off in raw image fidelity (Image-Alignment dropped by 6.6% to 14.8%), this is considered a necessary compromise for achieving true compositionality. The model moves away from rote memorization toward a more flexible, generative understanding of the custom subject.
Conclusion and Future Directions
Compositional Inversion provides an efficient and effective way to personalize Stable Diffusion while maintaining the model's creative flexibility. The study also highlights that the "rigidity" of an object influences its composability—rigid objects like chairs are easier to place in new scenes than deformable objects like animals. Future work will likely focus on better handling these non-rigid deformations to further enhance the realism of personalized generations.
Summary updated