[论文解读] Energy-Based Cross Attention for Bayesian Context Update in Text-to-Image Diffusion Models
本文提出能量基础交叉注意力(EBCA),一种无需训练的贝叶斯框架,通过基于能量的后验估计自适应更新上下文向量,从而提升文生图扩散模型中的语义对齐。通过最小化跨注意力层中的分层能量函数,EBCA 实现零样本组合生成,并在无需微调的情况下显著减少多概念生成、图像修复和图像编辑任务中的语义错位。
Despite the remarkable performance of text-to-image diffusion models in image generation tasks, recent studies have raised the issue that generated images sometimes cannot capture the intended semantic contents of the text prompts, which phenomenon is often called semantic misalignment. To address this, here we present a novel energy-based model (EBM) framework for adaptive context control by modeling the posterior of context vectors. Specifically, we first formulate EBMs of latent image representations and text embeddings in each cross-attention layer of the denoising autoencoder. Then, we obtain the gradient of the log posterior of context vectors, which can be updated and transferred to the subsequent cross-attention layer, thereby implicitly minimizing a nested hierarchy of energy functions. Our latent EBMs further allow zero-shot compositional generation as a linear combination of cross-attention outputs from different contexts. Using extensive experiments, we demonstrate that the proposed method is highly effective in handling various image generation tasks, including multi-concept generation, text-guided image inpainting, and real and synthetic image editing. Code: https://github.com/EnergyAttention/Energy-Based-CrossAttention.
研究动机与目标
- 为解决文生图扩散模型中的语义错位问题,即生成的图像未能反映预期的文本概念。
- 通过建模后验分布 $ p(\text{context} \mid \text{representations}) $ 而非依赖固定冻结的文本嵌入,提升上下文向量的质量。
- 通过能量模型(EBM)的固有组合性,实现零样本组合生成。
- 提供即插即用、无需训练的解决方案,与现有扩散模型(如 Stable Diffusion)兼容。
- 在多种任务中展示有效性,包括多概念生成、文本引导的图像修复以及真实/合成图像编辑。
提出的方法
- 在每个跨注意力层中构建能量函数 $ E(K_l; Q_{t,l}) $,以建模后验 $ p(K_l \mid Q_{t,l}) $,其中 $ K_l $ 为键(上下文),$ Q_{t,l} $ 为查询(图像表征)。
- 推导上下文向量后验对数的梯度,以实现可传播至后续层的迭代自适应更新。
- 引入先验能量函数 $ \operatorname{E}(K) $,自适应地正则化 $ \|k_i\| $ 的平滑最大值,防止对上下文向量的过度惩罚。
- 采用单步上下文更新并传播至后续层,平衡性能与计算成本。
- 通过多个基于能量的上下文向量的跨注意力输出的线性组合,实现零样本组合生成。
- 仅在推理阶段应用该框架,无需任何模型微调或额外训练。

实验结果
研究问题
- RQ1基于能量的后验估计是否能改善扩散模型中文本提示与生成图像之间的语义对齐?
- RQ2通过最小化能量函数实现的自适应上下文更新,如何影响多概念生成与图像编辑?
- RQ3所提方法是否能在不重新训练的情况下实现零样本组合生成?
- RQ4与均匀正则化相比,自适应先验能量函数是否能防止对显著上下文向量的过度抑制?
- RQ5上下文更新次数如何影响图像质量和语义保真度?
主要发现
- 所提出的 EBCA 方法显著减少了语义错位,多概念任务(如 'a lion and a crown')中的生成质量得到明显提升。
- 随着正则化强度 $ \alpha $ 增大,显著的上下文元素(如王冠、狮子)逐渐消失,证实了自适应惩罚在保留关键概念方面的有效性。
- 将最终时间步的上下文向量 $ C_T $ 作为固定嵌入使用,可生成语义准确的图像,表明自适应更新有效保留了原始语义意图。
- 多步上下文更新可提升图像质量,但计算成本较高,表明单步更新已足以实现最优性能。
- 该方法在真实与合成图像编辑中表现有效,包括仅通过文本提示将马变为斑马、猫变为狗,且无需训练。
- 通过线性组合多个基于能量的上下文向量的跨注意力输出,该框架支持零样本组合编辑,实现灵活直观的操控。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。