---
id: 20260528-T0-12
title: "SPEAR：让提示词优化器自己写代码，提升LLM任务表现"
title_en: "SPEAR: Code-Augmented Prompt Optimization Improves LLM Tasks"
url: https://ai.daily.yangsir.net/daily/20260528-T0-12
issue_date: 2026-05-28
publish_date: 2026-05-27T04:00:00.000Z
category: research
source_name: "arXiv cs.CL (NLP)"
source_url: https://arxiv.org/abs/2605.26275
---

# SPEAR：让提示词优化器自己写代码，提升LLM任务表现

自动提示词工程（APE）通常将优化器视作固定的流水线，难以应对复杂任务。SPEAR方法将CodeAct（代码即动作）理念引入APE，让优化器能通过编写和执行代码来优化提示词。实验证明，这种动态的代码增强策略能有效突破固定管线的限制，显著提升大语言模型在下游任务中的表现。提示词工程师和开发者可以通过该方法构建更健壮的智能体工作流。

## English Version

**SPEAR: Code-Augmented Prompt Optimization Improves LLM Tasks**

SPEAR introduces the code-as-action paradigm into automatic prompt engineering (APE), allowing the optimizer to write and execute code for prompt refinement. This dynamic approach breaks fixed pipeline limits and improves LLM performance on downstream tasks. Developers can use it to build more robust agent workflows.

---

**来源**：[arXiv cs.CL (NLP)](https://arxiv.org/abs/2605.26275)

**详情页**：https://ai.daily.yangsir.net/daily/20260528-T0-12

---

*智语观潮 · Daily — https://ai.daily.yangsir.net/llms.txt*