通过梯度优化反推语言模型输入,实现高效精准的文本生成逆向控制。
Language Model Inversion through End-to-End Differentiation
- 将语言模型视为分布序列的函数,实现端到端可微
- 对长度20的目标输出,成功优化10和80长度的输入提示
- 适用于多个白盒模型,无需额外训练
尽管语言模型研究日益深入,但其可逆性分析仍较少。即:给定一个语言模型和期望的输出标记序列,如何确定能产生该输出的输入提示仍是未解问题。本文将其建模为经典的基于梯度的优化问题。首先提出一种简单算法,使给定(冻结)的语言模型具备端到端可微性,进而通过梯度下降优化输入提示。核心思路是将语言模型视为作用于标记分布序列的函数(而非传统上的标记序列)。实验与消融结果表明,基于DLM的逆向方法能够可靠且高效地优化长度为10和80的提示,以生成长度为20的目标输出,适用于多个白盒语言模型(开箱即用)。
原文摘要 · Abstract (English)
Despite emerging research on Language Models (LM), few approaches analyse the invertibility of LMs. That is, given a LM and a desirable target output sequence of tokens, determining what input prompts would yield the target output remains an open problem. We formulate this problem as a classical gradient-based optimisation. First, we propose a simple algorithm to achieve end-to-end differentiability of a given (frozen) LM and then find optimised prompts via gradient descent. Our central insight is to view LMs as functions operating on sequences of distributions over tokens (rather than the traditional view as functions on sequences of tokens). Our experiments and ablations demonstrate that our DLM-powered inversion can reliably and efficiently optimise prompts of lengths $10$ and $80$ for targets of length $20$, for several white-box LMs (out-of-the-box).
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。