Recent advancements in text-to-image diffusion models have demonstrated their remarkable capability to generate high-quality images from textual prompts. However, increasing research indicates that these models memorize and replicate images from their training data, raising tremendous concerns about potential copyright infringement and privacy risks. In our study, we provide a novel perspective to understand this memorization phenomenon by examining its relationship with cross-attention mechanisms. We reveal that during memorization, the cross-attention tends to focus disproportionately on the embeddings of specific tokens. The diffusion model is overfitted to these token embeddings, memorizing corresponding training images. To elucidate this phenomenon, we further identify and discuss various intrinsic findings of cross-attention that contribute to memorization. Building on these insights, we introduce an innovative approach to detect and mitigate memorization in diffusion models. The advantage of our proposed method is that it will not compromise the speed of either the training or the inference processes in these models while preserving the quality of generated images. Our code is available at https://github.com/renjie3/MemAttn .
翻译:近年来,文本到图像扩散模型在根据文本提示生成高质量图像方面展现出卓越能力。然而,越来越多的研究表明,这些模型会记忆并复制训练数据中的图像,从而引发对潜在版权侵权和隐私风险的严重担忧。本研究通过考察记忆现象与交叉注意力机制的关系,提供了理解该问题的新视角。我们发现,在记忆过程中,交叉注意力往往过度集中于特定词元(token)的嵌入表示。扩散模型对这些词元嵌入产生过拟合,从而记忆了对应的训练图像。为阐明这一现象,我们进一步识别并讨论了交叉注意力中导致记忆的多种内在发现。基于这些见解,我们提出了一种创新方法来检测并缓解扩散模型中的记忆效应。该方法的核心优势在于:既不会影响模型训练或推理过程的速度,又能保持生成图像的质量。我们的代码开源在 https://github.com/renjie3/MemAttn。