arXiv:2502.12926cs.AI2025-02被引 2

自动优化提示词,让大模型代理更懂特定场景。

Towards more Contextual Agents: An extractor-Generator Optimization Framework

  • 用提取-生成框架自动优化提示词,提升模型适应能力。
  • 在专业领域任务中显著降低错误率,增强语义一致性。
  • 适合需要精准响应的行业应用,如医疗、法律等复杂场景。

基于大语言模型(LLM)的智能体在多种通用任务中表现出色,但在特定领域场景下性能常因缺乏领域知识而下降,导致结果不准确或次优。为解决此问题,本文提出一种提取-生成优化框架,通过自动化优化底层提示词来提升智能体的上下文适应性。该方法包含两个阶段:(i) 从高质量输入-输出示例数据集中提取特征;(ii) 借助高层优化策略迭代识别表现不佳的案例,并应用自改进技术生成优化提示。该框架显著提升了提示词在多样化输入下的泛化能力,尤其在强调语义一致性和减少误差传播的上下文敏感任务中表现优异。尽管设计用于单阶段流程,本方法可自然扩展至多阶段工作流,在各类基于智能体的系统中具备广泛适用性。实证评估表明,该框架能显著提升提示优化智能体的性能,提供一种结构化且高效的上下文适应解决方案。

原文摘要 · Abstract (English)

Large Language Model (LLM)-based agents have demonstrated remarkable success in solving complex tasks across a wide range of general-purpose applications. However, their performance often degrades in context-specific scenarios, such as specialized industries or research domains, where the absence of domain-relevant knowledge leads to imprecise or suboptimal outcomes. To address this challenge, our work introduces a systematic approach to enhance the contextual adaptability of LLM-based agents by optimizing their underlying prompts-critical components that govern agent behavior, roles, and interactions. Manually crafting optimized prompts for context-specific tasks is labor-intensive, error-prone, and lacks scalability. In this work, we introduce an Extractor-Generator framework designed to automate the optimization of contextual LLM-based agents. Our method operates through two key stages: (i) feature extraction from a dataset of gold-standard input-output examples, and (ii) prompt generation via a high-level optimization strategy that iteratively identifies underperforming cases and applies self-improvement techniques. This framework substantially improves prompt adaptability by enabling more precise generalization across diverse inputs, particularly in context-specific tasks where maintaining semantic consistency and minimizing error propagation are critical for reliable performance. Although developed with single-stage workflows in mind, the approach naturally extends to multi-stage workflows, offering broad applicability across various agent-based systems. Empirical evaluations demonstrate that our framework significantly enhances the performance of prompt-optimized agents, providing a structured and efficient approach to contextual LLM-based agents.

大模型智能体提示优化上下文适配

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。