Neural Code Generation Ranking by Execution-Output Clustering
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code generation models, particularly those using likelihood-based decoding techniques, often produce code sequences with syntactical or logical flaws, and lack a deep understanding of program behavior, leading to inconsistent outputs and increased manual review requirements.
Innovation Solution
A neural network system that generates and ranks code solutions by clustering them based on execution outputs, using an interaction matrix to quantify functional overlap between clusters, and determining scores that prioritize the most accurate and efficient code.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If likelihood-based decoding techniques (greedy search or beam search) are used to generate code sequences, then the model can optimize for token likelihood and generate code efficiently, but the generated code contains syntactical or logical flaws and lacks semantic correctness
Solution Approach 1:
The patent implements a feedback mechanism by executing generated code through test cases and using the execution results to guide further generation. The system clusters code solutions by execution output and iteratively refines generation based on which clusters pass tests, creating a closed-loop feedback system that improves both efficiency and correctness
Solution Approach 2:
The patent introduces test case execution results as an intermediary between code generation and evaluation. Instead of directly evaluating code quality, the system uses execution outputs from test cases as a mediator to assess semantic correctness, enabling the model to learn from actual program behavior rather than just token patterns
2Reliability
If the model generates diverse code solutions to improve coverage, then more potential correct solutions are found, but the computational overhead increases due to clustering and interaction matrix computation
Solution Approach 1:
The patent segments the code generation process into distinct phases: initial generation, test execution, clustering by execution output, interaction matrix computation, and selective refinement. This segmentation allows the system to manage computational complexity by processing only necessary clusters in detail while grouping similar solutions efficiently
Solution Approach 2:
The patent dynamically adjusts generation parameters based on cluster performance. When a cluster passes test cases, the system modifies generation parameters to favor similar solutions, changing the search space parameters to concentrate computational effort on promising regions rather than uniformly exploring all possibilities
3Adaptability or versatility
If small variations in input prompt are allowed, then the model demonstrates flexibility in interpretation, but significant discrepancies appear in output code quality and correctness
Solution Approach 1:
The execution-based feedback mechanism grounds the model's flexible interpretations in actual program behavior. Regardless of how differently code solutions interpret the prompt, the test case execution provides an objective feedback signal that validates or rejects each interpretation, ensuring consistent quality standards are applied to all outputs
Solution Approach 2:
The patent applies different evaluation strictness to different code clusters based on their execution performance. High-quality clusters that pass tests receive focused refinement, while problematic clusters are either corrected or discarded. This local quality approach ensures that flexibility in interpretation does not compromise overall output consistency
Data Source
AI summary
A computer-implemented method for generating and ranking source code for performing a task is described. The method includes: receiving input data comprising a task description, a code generation prompt and a test case generation prompt; processing the input data using at least one trained code generation neural network to generate a plurality of code solutions and a plurality of test cases; for each code solution, executing the set of candidate source code on the test inputs of the plurality of test cases to generate a plurality of execution outputs; clustering the plurality of code solutions into a plurality of clusters; computing an interaction matrix that specifies functional overlap between the plurality of clusters; determining, for each cluster, a score based the interaction matrix; and ranking the plurality of clusters based on the scores of the plurality of clusters.


