LLM Code Generation via Sub-Module Clustering
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Large language models (LLMs) struggle with complex and competitive programming tasks as they tend to generate monolithic code blocks instead of decomposing tasks into logical sub-tasks, limiting their effectiveness in solving complex programming problems.
Innovation Solution
A code-chain framework that uses pre-trained LLMs to generate sub-modules representing logical sub-tasks, which are then clustered and filtered based on test cases, iteratively refined to produce a functionally correct program, allowing for the decomposition of complex tasks into manageable components.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Device complexity
If LLM models generate monolithic code blocks, then the code generation process is simple, but the ability to solve complex programming tasks deteriorates
Solution Approach 1:
The patent applies segmentation by dividing the code generation process into multiple iterations where LLM models generate sub-modules representing logical sub-tasks. Each sub-module is independently generated, tested, and refined, allowing complex programming tasks to be broken down into manageable components that can be solved more effectively than monolithic code blocks
2Reliability
If LLM models decompose tasks into logical sub-tasks, then the ability to solve complex programming tasks improves, but the code generation process complexity increases
Solution Approach 1:
The patent implements feedback mechanisms where generated sub-modules are tested against test cases and evaluation criteria. The results of these tests feed back into the generation process, allowing the system to refine and improve sub-modules iteratively. This feedback loop manages the complexity by providing structured guidance for refinement rather than uncontrolled complexity
Solution Approach 2:
The system dynamically adapts the code generation process by iteratively refining sub-modules based on test results and evaluation metrics. The generation process is not static but evolves through multiple iterations, adjusting the complexity management as the solution develops and converges toward a working program
3Manufacturing precision
If sub-modules are iteratively refined through testing and filtering, then the accuracy of source code generation improves, but the time required for code generation increases
Solution Approach 1:
The patent applies partial action by filtering and selecting representative sub-modules from the generated set rather than refining all sub-modules equally. The system identifies and focuses computational effort on the most promising or critical sub-modules, achieving high accuracy while managing time constraints by not performing exhaustive refinement on every generated component
4Productivity
If representative sub-modules are selected through clustering, then the efficiency of code generation improves, but the complexity of the generation process increases
Solution Approach 1:
The patent uses copying by creating clusters of similar sub-modules and selecting representative examples from each cluster. Instead of processing every generated sub-module individually, the system creates copies or variations around representative sub-modules, improving efficiency by reducing redundancy while managing complexity through systematic organization of similar components
Data Source
AI summary
The embodiments are directed to generating source code for a program from a problem description. One or more pre-trained code large language models (LLMs) generate sub-modules from a problem description in a natural language. The sub-modules are filtered based on testing criteria and encoded into sub-module encodings in an embedding space. The sub-module encodings are clustered into multiple clusters. A subset of sub-modules encoding that are close to the centroids of the clusters are selected. The sub-set of sub-modules is decoded into representative sub-modules. The problem description is augmented with the representative sub-modules and fed into one or more pre-trained code LLMs and new sub-modules are generated. The iterations continue until a program is generated from the representative sub-modules.


