# 基于检索增强搜索的LLM程序优化方法

- 来源：HuggingFace Daily Papers（社区热门论文）
- 发布时间：2026-06-23 08:00
- AIHOT 分数：37
- AIHOT 链接：https://aihot.virxact.com/items/cmr0zbl2e006osldx4hac2lch
- 原文链接：https://arxiv.org/abs/2501.18916

## AI 摘要

提出检索增强搜索（RAS）方法，通过束搜索优化候选程序，每一步从慢-快程序对训练数据中检索上下文示例引导LLM。基于LLM生成的自然语言描述进行上下文检索效果优于基于源代码的检索。同时提出AEGIS方法，将训练示例分解为原子编辑以提高可解释性。在C++程序优化上，RAS比先前最先进黑盒适应策略性能提升2.06倍，AEGIS提升1.37倍且编辑量更小。对于Python程序，RAS使平均运行时间百分位提升10.27。

## 正文

Recent work has demonstrated the potential of large language models (LLMs) for program optimization, a key challenge in programming languages. We propose a blackbox adaptation method called Retrieval Augmented Search (RAS) that performs beam search over candidate optimizations; at each step, it retrieves in-context examples from a given training dataset of slow-fast program pairs to guide the LLM. Critically, we find that performing contextual retrieval based on an LLM-generated natural language description significantly outperforms retrieval based on the source code. We also propose AEGIS, a method for improving interpretability by decomposing training examples into ''atomic edits'' that are significantly more incremental in nature. We show that RAS performs up to 2.06times better than prior state-of-the-art blackbox adaptation strategies on optimizing C++ programs, and that AEGIS performs up to 1.37times better while making significantly smaller edits. We also show that using RAS improves the mean runtime percentile of Python programs by 10.27 compared to baselines.
