LLM Program Optimization via Retrieval Augmented Search
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
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.06× better than prior state-of-the-art blackbox adaptation strategies on optimizing C++ programs, and that AEGIS performs up to 1.37× 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.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 15 of its 23 references that are in the map. First posted on arXiv 31 Jan 2025.
Builds on
15 of 23 references.
Closest ancestors · 1
Same direction, newest first
Other references · 14
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
- 2021CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Taskscited by 200
- 2024MapCoder: Multi-Agent Code Generation for Competitive Problem Solvingcited by 177
- 2021Reframing Instructional Prompts to GPTk's Languagecited by 176
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2023Learning Performance-Improving Code Editscited by 106
- 2024How Efficient is LLM-Generated Code? A Rigorous & High-Standard Benchmarkcited by 43
- 2024Search-Based LLMs for Code Optimizationcited by 28
2 more
Built on by
Citing papers per year: 2025: 1; 2026: 3.
4 papers.
- 2025Toward Agentic AI: Generative Information Retrieval Inspired Intelligent Communications and Networkingcited by 9
- 2026MaxCode: A Max-Reward Reinforcement Learning Framework for Automated Code Optimizationcited by 4
- 2026Tape: A Cellular Automata Benchmark for Evaluating Rule-Shift Generalization in Reinforcement Learningcited by 0
- 2026RASP-Tuner: Retrieval-Augmented Soft Prompts for Context-Aware Black-Box Optimization in Non-Stationary Environmentscited by 0
- 2026RASP-Tuner: Retrieval-Augmented Soft Prompts for Context-Aware Black-Box Optimization in Non-Stationary Environments20 Apr 2026
- 2026MaxCode: A Max-Reward Reinforcement Learning Framework for Automated Code Optimization9 Jan 2026
- 2026Tape: A Cellular Automata Benchmark for Evaluating Rule-Shift Generalization in Reinforcement Learning8 Jan 2026
- 2025Toward Agentic AI: Generative Information Retrieval Inspired Intelligent Communications and Networking24 Feb 2025
Similar, not cited
Close in wording, no citation either way
- 2025FasterPy: An LLM-based Code Execution Efficiency Optimization Framework
- 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
- 2026Overcoming the Weakest-Link Effect in LLM-Driven Program Optimization via Heterogeneous Edit Recombination
- 2024Retrieval-augmented code completion for local projects using large language models
- 2026Can LLMs Beat Classical Hyperparameter Optimization Algorithms? A Study on autoresearch
- 2024Symbolic Prompt Program Search: A Structure-Aware Approach to Efficient Compile-Time Prompt Optimization
- 2023CRAFT: Customizing LLMs by Creating and Retrieving from Specialized Toolsets
- 2026AdaptEval: A Benchmark for Evaluating Large Language Models on Code Snippet Adaptation