LLM Code Generation Using Execution Feedback for Runtime Efficiency
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code generation methods using large language models (LLMs) focus primarily on functional correctness but neglect runtime efficiency, leading to inefficient code that can impair network performance.
Innovation Solution
A neural network-based code generation framework that incorporates a large language model and a code execution environment, utilizing execution feedback to iteratively refine code snippets for both correctness and efficiency, ensuring improved computational efficiency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If LLM generates code based on natural language input, then functional correctness is achieved, but runtime efficiency deteriorates
Solution Approach 1:
The system executes generated code to obtain execution feedback including runtime metrics and performance data. This feedback is fed back to the LLM to iteratively refine and optimize the code, transforming the initial focus on functional correctness to also prioritize runtime efficiency through multiple refinement cycles.
Solution Approach 2:
The system performs preliminary execution of the generated code to evaluate its runtime efficiency before final deployment. By executing the code in a controlled environment first, the system identifies performance issues early and generates optimized versions, preventing inefficient code from being deployed to production.
2Productivity
If code is optimized for runtime efficiency, then execution speed improves, but functional correctness may deteriorate
Solution Approach 1:
The system continuously monitors both functional correctness and runtime efficiency metrics during code execution. When optimization changes are made, the execution feedback verifies that functional correctness is maintained while measuring improvements in execution speed, allowing safe optimization only when both criteria are satisfied.
Solution Approach 2:
The code optimization process is dynamic and iterative rather than static. The LLM continuously refines the code based on real-time execution feedback, adjusting the balance between functional correctness and execution speed through multiple cycles until optimal performance is achieved without sacrificing correctness.
3Manufacturing precision
If iterative code refinement is performed, then code quality improves, but processing time increases
Solution Approach 1:
The system performs a limited number of refinement iterations rather than exhaustive optimization. By executing the code a predetermined number of times or for a limited duration, the system achieves sufficient code quality improvement without incurring excessive processing time costs, balancing refinement depth with computational resource constraints.
Data Source
AI summary
A method of generating a code output in response to a natural language problem description. The method includes: receiving the natural language problem description; generating, by a neural network based language model, a first candidate code snippet based on a first input prompt combining the natural language problem description and a first instruction; executing, at a code execution environment, the first candidate code snippet based on a unit test thereby producing a first feedback reflecting a correctness of the first candidate code snippet; generating, by the neural network based language model, a second candidate code snippet based on a second input prompt combining the natural language problem description, the first candidate code snippet, and the first feedback; and executing, at the code execution environment, the second candidate code snippet based on a runtime test thereby producing a second feedback reflecting a runtime efficiency of the second candidate code snippet.


