arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2501.16673cs.CL
收藏

LLM-AutoDiff:对任意 LLM 工作流进行自动微分

LLM-AutoDiff: Auto-Differentiate Any LLM Workflow

SylphAI(西尔菲AI);University of Texas at Austin(德克萨斯大学奥斯汀分校)

Li Yin, Zhangyang Wang

AI总结:

LLM-AutoDiff 是一种自动提示工程框架,将基于文本梯度的方法扩展至多组件、潜在循环的 LLM 架构,通过将文本输入视为可训练参数并利用冻结的向后引擎生成反馈来指导迭代更新,在准确率和训练成本上均优于现有基线。

摘要:

大型语言模型(LLMs)重塑了自然语言处理,驱动了从多跳检索和问答到自主智能体工作流的应用。然而,提示工程——即制作文本输入以有效引导 LLMs 的任务——依然困难且耗费人力,特别是对于将多次 LLM 调用与检索和数据格式化等功能操作相结合的复杂流水线。我们引入了 LLM-AutoDiff:一种用于自动提示工程(APE)的新颖框架,它将基于文本梯度的方法(如 Text-Grad)扩展到多组件、潜在循环的 LLM 架构。LLM-AutoDiff 在 AdalFlow 库中实现,将每个文本输入视为可训练参数,并使用冻结的向后引擎 LLM 生成反馈(类似于文本梯度),以指导迭代的提示更新。与先前的单节点方法不同,LLM-AutoDiff 天然地容纳功能节点,在重复调用(例如,多跳循环)中保留时间顺序行为,并通过隔离不同的子提示(指令、格式或小样本示例)来对抗“中间丢失”问题。它进一步通过选择性梯度计算聚焦于易错样本,从而提升训练效率。在包括单步分类、基于多跳检索的问答和智能体驱动的流水线在内的多样任务中,LLM-AutoDiff 在准确率和训练成本上始终优于现有的文本梯度基线。通过以图为中心的视角统一提示优化,LLM-AutoDiff 为扩展和自动化 LLM 工作流提供了强大的新范式——映射了自动微分库在神经网络研究中长期发挥的变革性作用。

英文摘要:

Large Language Models (LLMs) have reshaped natural language processing, powering applications from multi-hop retrieval and question answering to autonomous agent workflows. Yet, prompt engineering -- the task of crafting textual inputs to effectively direct LLMs -- remains difficult and labor-intensive, particularly for complex pipelines that combine multiple LLM calls with functional operations like retrieval and data formatting. We introduce LLM-AutoDiff: a novel framework for Automatic Prompt Engineering (APE) that extends textual gradient-based methods (such as Text-Grad) to multi-component, potentially cyclic LLM architectures. Implemented within the AdalFlow library, LLM-AutoDiff treats each textual input as a trainable parameter and uses a frozen backward engine LLM to generate feedback-akin to textual gradients -- that guide iterative prompt updates. Unlike prior single-node approaches, LLM-AutoDiff inherently accommodates functional nodes, preserves time-sequential behavior in repeated calls (e.g., multi-hop loops), and combats the "lost-in-the-middle" problem by isolating distinct sub-prompts (instructions, formats, or few-shot examples). It further boosts training efficiency by focusing on error-prone samples through selective gradient computation. Across diverse tasks, including single-step classification, multi-hop retrieval-based QA, and agent-driven pipelines, LLM-AutoDiff consistently outperforms existing textual gradient baselines in both accuracy and training cost. By unifying prompt optimization through a graph-centric lens, LLM-AutoDiff offers a powerful new paradigm for scaling and automating LLM workflows - mirroring the transformative role that automatic differentiation libraries have long played in neural network research.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑