通过嵌入空间梯度优化,让大模型提示词更精准地推理
EmbedGrad: Gradient-Based Prompt Optimization in Embedding Space for Large Language Models
- 在嵌入空间用梯度调整提示词,保持语义同时精细优化
- 使数学推理准确率从14.74%提升至58.96%,小模型提升显著
- 无需增加参数,适合追求高效与可解释性的部署场景
将强大预训练基础模型适配到多样任务仍是人工智能部署的关键挑战。当前方法主要分为两类:基于文本提示的离散优化,或通过额外可训练参数进行连续调整。前者精度不足,后者增加复杂性且降低可解释性。为此,我们提出EmbedGrad,一种通过梯度驱动在嵌入空间中优化文本提示的新框架。该方法将训练与推理解耦:优化阶段利用标注样本精确调整嵌入表示,同时保留语义;推理时仅使用优化后的嵌入与用户查询结合。这实现了文本空间无法实现的细粒度校准,如增强“请逐步推理”类提示的推理能力。在数学推理、情感分析和因果判断任务上的综合评估表明,对Qwen2.5-Math-1.5B优化“请逐步推理”提示后,数学问题准确率从14.74%提升至58.96%。模型规模(0.5B–14B)与任务类型均表现出一致提升,尤其在复杂任务上对小模型增益明显。本工作在不改变架构的前提下,融合提示工程与参数效率,确立嵌入微调作为任务适配的新范式。
原文摘要 · Abstract (English)
Effectively adapting powerful pretrained foundation models to diverse tasks remains a key challenge in AI deployment. Current approaches primarily follow two paradigms:discrete optimization of text prompts through prompt engineering, or continuous adaptation via additional trainable parameters. Both exhibit limitations-discrete methods lack refinement precision while parameter-based techniques increase complexity and reduce interpretability. To address these constraints, we propose EmbedGrad, a novel framework that optimizes text prompt embeddings through gradient-based refinement. Our approach uniquely decouples training from deployment:during optimization,labeled examples guide precise embedding adjustments while preserving semantic meaning; during inference, only optimized embeddings integrate with user queries. This enables fine-grained calibration impossible in text space, such as enhancing the reasoning capability of prompts like please reason step by step. Comprehensive evaluations across mathematical reasoning, sentiment analysis, and causal judgment tasks demonstrate EmbedGrad's effectiveness:optimizing this reasoning prompt for Qwen2.5-Math-1.5B increased accuracy from 14.74\% to 58.96\% on mathematical problems. Consistent improvements were observed across model scales (0.5B-14B) and all tasks, with particularly significant gains for smaller models on complex problems like causal judgment. By bridging prompt engineering and parameter efficiency without architectural changes, our work establishes embedding refinement as a powerful new paradigm for task adaptation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。