TextBFGS: A Case-Based Reasoning Approach to Code Optimization via Error-Operator Retrieval
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
Iterative code generation with Large Language Models (LLMs) can be viewed as an optimization process guided by textual feedback. However, existing LLM self-correction methods predominantly operate in a stateless, trial-and-error manner akin to first-order search, failing to leverage past problem-solving experiences. To bridge this gap, we introduce TextBFGS, a Case-Based Reasoning (CBR) framework inspired by the Quasi-Newton optimization method. Instead of retrieving raw, unstructured textual instances, TextBFGS maintains a dynamic Case Base of historical "Error-to-Operator" correction trajectories to approximate the semantic curvature (inverse Hessian matrix) of the task. Specifically, given a textual error feedback (the target problem), TextBFGS retrieves analogous historical correction patterns (Retrieve) and applies these abstract operators to refine the current code (Reuse/Revise). Furthermore, successful adaptations are continuously retained back into the Case Base (Retain), enabling a self-evolving system. Empirical evaluations on Python code optimization tasks (HumanEval, MBPP) demonstrate that TextBFGS significantly outperforms stateless baselines. It achieves superior pass rates with fewer model calls, establishing an efficient, experience-driven paradigm for LLM-based code optimization.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 24 of its 32 references that are in the map. First posted on arXiv 20 Jan 2026.
Builds on
24 of 32 references.
References · 24
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2025Qwen3 Technical Reportcited by 8,195
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2025Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Modelscited by 1,175
- 2023Large Language Models as Optimizerscited by 830
- 2023DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelinescited by 803
- 2019How Contextual are Contextualized Word Representations? Comparing the Geometry of BERT, ELMo, and GPT-2 Embeddingscited by 770
12 more
- 2025AlphaEvolve: A coding agent for scientific and algorithmic discoverycited by 763
- 2023Promptbreeder: Self-Referential Self-Improvement Via Prompt Evolutioncited by 521
- 2025GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learningcited by 449
- 2024A Systematic Survey of Prompt Engineering in Large Language Models: Techniques and Applicationscited by 428
- 2024Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programscited by 270
- 2024TextGrad: Automatic "Differentiation" via Textcited by 250
- 2024Meta-Prompting: Enhancing Language Models with Task-Agnostic Scaffoldingcited by 115
- 2025The Devil is in the Prompts: Retrieval-Augmented Prompt Optimization for Text-to-Video Generationcited by 21
- 2025Self-Evolving Multi-Agent Systems via Textual Backpropagationcited by 21
- 2024REVOLVE: Optimizing AI Systems by Tracking Response Evolution in Textual Optimizationcited by 20
- 2025metaTextGrad: Automatically optimizing language model optimizerscited by 6
- 2025Reflection-Enhanced Meta-Optimization Integrating TextGrad-style Prompt Optimization with Memory-Driven Self-Evolutioncited by 3
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025Optimizing Case-Based Reasoning System for Functional Test Script Generation with Large Language Models
- 2025LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMs
- 2024RethinkMCTS: Refining Erroneous Thoughts in Monte Carlo Tree Search for Code Generation
- 2026ShortCoder: Knowledge-Augmented Syntax Optimization for Token-Efficient Code Generation
- 2026CodeContests-O: Powering LLMs via Feedback-Driven Iterative Test Case Generation
- 2024Code Repair with LLMs gives an Exploration-Exploitation Tradeoff
- 2025rStar-Coder: Scaling Competitive Code Reasoning with a Large-Scale Verified Dataset
- 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval