TextBFGS: A Case-Based Reasoning Approach to Code Optimization via Error-Operator Retrieval
Zizheng Zhang, Yuyang Liao, Chen Chen, Jian He, Dun Wu, Qianjin Yu, Yanqin Gao, Jin Yang, Kailai Zhang, Eng Siong Chng, Xionghu Zhong

TL;DR
TextBFGS introduces a case-based reasoning framework for code optimization with LLMs, leveraging historical correction trajectories to improve efficiency and effectiveness over traditional trial-and-error methods.
Contribution
It presents a novel CBR approach inspired by Quasi-Newton methods, maintaining a dynamic case base to enhance iterative code correction in LLMs.
Findings
Outperforms stateless baselines in Python code tasks
Achieves higher pass rates with fewer model calls
Demonstrates effective self-evolving correction system
Abstract
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).…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
