动态调整提示词,让扩散语言模型更快生成且不丢质量。
DIP: Dynamic In-Context Planner For Diffusion Language Models
- 生成时按信心动态添加示例,而非一次性塞满提示。
- 在数学和编程任务上提速1.59倍,质量几乎不变。
- 适合追求高效推理的扩散语言模型使用者。
扩散语言模型(DLM)在自然语言任务中展现强大潜力,依赖上下文示例进行学习。现有上下文学习方法沿用自回归语言模型的做法,将所有示例固定在提示中,但这种静态方式在DLM上带来巨大计算开销,因模型需每步评估最大上下文长度。我们发现DLM推理中的分块键值缓存机制可实现低成本动态调整上下文。据此提出动态上下文规划器(DIP),初始仅用最小提示生成,仅当生成词置信度低时才动态插入新示例。实验表明,平均验证置信度与生成准确率强相关,是可靠的词质量信号。在LLaDA-1.5和LLaDA-8B-Instruct上,DIP分别实现最高1.59×和1.36×加速,同时保持与固定提示基线相当的生成质量。代码已开源。
原文摘要 · Abstract (English)
Diffusion language models (DLMs) have shown strong potential for general natural language tasks with in-context examples. Existing In-Context Learning (ICL) approaches largely inherit the practice of autoregressive language models (ARLMs), incorporating all examples into a fixed prompt. However, applying this rigid, static-prompt paradigm to DLMs incurs substantial computational overhead, as the model must evaluate the maximum context length at every step. We address this inefficiency with a key discovery: the block-wise KV-cache mechanism inherent to DLM inference enables the \textit{low-cost dynamic adjustment of the context}. Following this intuition, our core idea is to start generation with a minimal prompt and progressively insert additional examples on the fly only when the generated tokens are of low confidence. Through rigorous empirical evaluations, we observe that average verified token confidence correlates strongly with generation accuracy, making it a reliable and computationally efficient signal of token quality. Formally, we propose \textbf{D}ynamic \textbf{I}n-Context \textbf{P}lanner (DIP), a context-optimization algorithm based on average verified confidence that dynamically ranks and inserts in-context examples during generation, rather than providing all examples up front. Experimental results on math and coding benchmarks with LLaDA-1.5 and LLaDA-8B-Instruct show that DIP achieves up to $1.59\times$ and $1.36\times$ speedups, respectively, while largely preserving the generation quality of the fixed-prompt baseline. Code: https://github.com/wmd3i/DIP
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。