The strength of modern generative models lies in their ability to be controlled through text-based prompts. Typical "hard" prompts are made from interpretable words and tokens, and must be hand-crafted by humans. There are also "soft" prompts, which consist of continuous feature vectors. These can be discovered using powerful optimization methods, but they cannot be easily interpreted, re-used across models, or plugged into a text-based interface. We describe an approach to robustly optimize hard text prompts through efficient gradient-based optimization. Our approach automatically generates hard text-based prompts for both text-to-image and text-to-text applications. In the text-to-image setting, the method creates hard prompts for diffusion models, allowing API users to easily generate, discover, and mix and match image concepts without prior knowledge on how to prompt the model. In the text-to-text setting, we show that hard prompts can be automatically discovered that are effective in tuning LMs for classification.
翻译:现代生成模型的力量在于其能够通过文本提示进行控制。典型的“硬”提示由可解释的单词和标记组成,必须由人工手动设计。此外还有“软”提示,由连续特征向量构成,可通过强大的优化方法自动发现,但难以解释、跨模型复用或嵌入文本界面。我们提出一种方法,通过高效的基于梯度的优化来稳健优化硬文本提示。该方法能自动生成用于文本到图像和文本到文本应用的硬文本提示。在文本到图像场景中,该方法为扩散模型创建硬提示,使API用户无需事先了解如何提示模型即可轻松生成、发现和混合图像概念。在文本到文本场景中,我们证明可自动发现有效的硬提示,用于调整语言模型以完成分类任务。