AlgoSAGE: Formal Problem Representation and Grounded Expertise for Algorithmic Code Generation
Abstract
Large language models (LLMs) have demonstrated strong capabilities in automated code generation; however, achieving reliable performance on algorithmic programming problems remains challenging, as implicit problem abstraction and free-form planning can lead to inappropriate algorithm choices, underspecified solution plans, and constraint-violating implementations. Our key insight is that reliable code generation requires making the computational structure of a problem explicit, using it to select appropriate algorithmic expertise, and translating that expertise into concrete plans before coding. We propose AlgoSAGE, which constructs a formal problem representation and retrieves expertise at two complementary levels: reusable Algorithmic Knowledge and Algorithmic Application Exemplars that demonstrate how the retrieved knowledge is applied. AlgoSAGE then adapts this evidence into target-specific, executable, and auditable plans. Extensive experiments across multiple benchmarks and LLM backbones demonstrate that AlgoSAGE consistently improves algorithmic code generation. With Qwen3.8-27B-Coder, AlgoSAGE achieves 70.3%, 76.0%, and 78.3% Pass@1 on CodeContests, APPS, and xCodeEval, respectively, outperforming existing approaches by up to 6.7 percentage points. Experiments with additional backbones and function-level programming benchmarks further demonstrate the robustness and general applicability of AlgoSAGE. Code is available at https://anonymous.4open.science/r/AlgoSage-82F9/.
Then back it, or bet against it.
Related papers
Open the market on this paper to see 7 more related papers.