Decoupling compilation method and system based on AI large model
By adopting a decoupled compilation method based on AI large models, the problems of low compilation fault tolerance and poor adaptability of traditional compilation technology in large-scale engineering projects are solved, realizing an efficient and adaptive compilation process and generating efficient and loosely coupled target code.
Patent Information
- Application Number
- CN202611257927.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-11-03
AI Technical Summary
Traditional compilation techniques suffer from low compilation fault tolerance, poor adaptability, excessive compilation redundancy, and inaccurate conflict resolution when dealing with large-scale engineering projects and highly coupled code across modules. Furthermore, existing incremental compilation schemes cannot identify deep semantic dependencies and implicit coupling relationships, making them unsuitable for complex code scenarios.
We adopt a decoupled compilation method based on an AI large model. Through syntax parsing and semantic slicing, we remove global coupling dependencies in the code. We use a dedicated AI large model for compilation to perform independent compilation reasoning and fusion. Combined with dependency priority sorting and intelligent conflict resolution, we generate uncoupled intermediate files and improve compilation capabilities through iterative optimization.
It achieves precise decoupling compilation of highly coupled code, improves compilation fault tolerance and compilation efficiency, adapts to different code types and hardware platforms, has self-iterative optimization capabilities, and generates efficient, loosely coupled target code.
Smart Images

Figure CN123030184A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer program compilation and large-scale artificial intelligence models, specifically to a decoupled compilation method and system based on large-scale AI models. Background Technology
[0002] Compilation technology is a core foundational technology for computer program development and execution. Traditional compilation architectures employ a globally coupled, holistic compilation scheme, which involves performing lexical analysis, syntax analysis, semantic parsing, and code generation on the entire source code. The compilation process heavily relies on global dependencies and static binding logic. For small to medium-sized, loosely coupled code, traditional compilation methods can meet basic compilation needs. However, for large-scale engineering projects, highly coupled cross-module code, and multi-language mixed code scenarios, traditional compilation technology has many inherent shortcomings.
[0003] First, the traditional monolithic compilation model has extremely high coupling. Explicit call dependencies, implicit data dependencies, and temporal logic dependencies between code modules can interfere with each other. Syntactic flaws, logical defects, or adaptation errors in a single module can spread globally, leading to overall compilation failure and extremely low compilation fault tolerance. Second, traditional compilation rules are fixed, relying on manually preset compilation syntax libraries and adaptation rules. They cannot adapt to complex code scenarios with different programming languages, hardware platforms, and different degrees of coupling. They cannot accurately decompose and independently compile highly coupled nested code, resulting in poor compilation adaptability and versatility. Third, existing compilation systems lack intelligent optimization and self-iteration capabilities. The compilation process, conflict resolution strategies, and code optimization logic are all fixed, unable to adapt and upgrade based on historical compilation data and scenario characteristics. This has long resulted in problems such as excessive compilation redundancy, inaccurate conflict resolution, poor target code performance, and low compilation efficiency for complex code.
[0004] In existing technologies, some solutions attempt to use modular split compilation and incremental compilation as optimization methods. However, their split logic is only based on the code surface structure and cannot identify deep semantic dependencies and implicit coupling relationships in the code. After splitting, there are still a lot of cross-module compilation interferences, which cannot fundamentally solve the problem of global coupling compilation conflicts. At the same time, existing incremental compilation only performs local recompilation on the modified code area and does not have the functions of semantic reasoning, intelligent conflict resolution and closed-loop iterative compilation capabilities based on artificial intelligence. The level of intelligence is low and it cannot adapt to the increasingly complex compilation needs of large-scale engineering code. Summary of the Invention
[0005] To address the aforementioned technical problems, this paper provides a decoupled compilation method and system based on a large AI model. This technical solution solves the problems mentioned in the background section.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A decoupled compilation method based on large AI models includes: Obtain the original source code to be compiled, perform syntax parsing, semantic slicing and dependency decoupling preprocessing on the original source code, remove code syntax redundancy, global coupling dependencies and static binding relationships, and output several semantically independent, loosely coupled atomic code slices and corresponding slice dependency metadata; The atomic code slices and slice dependency metadata are input into a pre-trained compilation-specific AI model. Through the compilation semantic understanding branch, decoupling inference branch, and incremental optimization branch of the AI model, each atomic code slice is independently compiled and inferred to generate the corresponding single-slice intermediate compilation representation. The compilation-specific AI model is a dedicated large model obtained by fine-tuning based on massive cross-language compilation samples and coupled compilation defect samples. It has the ability to dynamically decompose code dependencies and adaptively match compilation rules. Based on the slice dependency metadata, the intermediate compilation representations of all single slices are layered and fused through the decoupling and fusion strategy of the AI large model to avoid inter-slice coupling compilation conflicts and generate globally unified uncoupled intermediate compilation files. The decoupling and fusion strategy includes three core sub-steps: dependency priority sorting, intelligent resolution of compilation conflicts, and cross-slice semantic alignment. Incremental compilation optimization, syntax verification and target code adaptation are performed on the decoupled intermediate compilation file to generate the final executable target code, thus completing the entire decoupled compilation process. The entire decoupled compilation process was collected, including runtime data, conflict data, and performance data. After cleaning and annotation, structured iterative samples were generated. The AI model dedicated to compilation was then fine-tuned and its performance verified. The compilation scenario knowledge base was dynamically updated to achieve closed-loop iterative optimization of compilation capabilities.
[0007] Preferably, the semantic slicing and dependency decoupling preprocessing of the original source code specifically includes the following steps: Lexical analysis and syntax tree construction are performed on the original source code. The syntax tree nodes are traversed to identify the four core code units: functions, variables, logical modules, and call relationships. Based on the AI semantic clustering algorithm, code nodes with semantic relevance higher than a preset threshold in the syntax tree are aggregated into initial code slices, and invalid cross-module relevance nodes are removed; Construct a global code dependency graph, mark the explicit call dependencies, implicit data dependencies, and temporal logic dependencies of each initial code slice, cut the strong coupling binding relationships between slices, and iteratively optimize the initial code slices into semantically independent atomic code slices; Extract the slice identifier, dependent objects, compilation constraints, and semantic feature information of each atomic code slice to generate structured slice dependency metadata.
[0008] Preferably, the pre-training and fine-tuning method for the dedicated AI large model includes the following steps: Construct a dedicated training dataset for compilation, which includes cross-programming language standard compilation samples, traditional coupled compilation error samples, code decoupling compilation comparison samples, and complex scenario multi-dependency code compilation samples. Based on the basic large model architecture, a compilation semantic understanding module, a dependency decoupling reasoning module, and a compilation error correction module are added to build a dedicated basic model for compilation. A combination of mask learning and contrastive learning is used to pre-train the compiler-specific basic model, enabling it to master general code syntax rules, compilation logic, and code dependencies. Supervised fine-tuning is performed based on manually annotated decoupled compilation benchmark samples, while iterative optimization is carried out using online feedback data from real compilation scenarios to improve the model's ability to decouple coupled code and the accuracy of decoupled compilation inference.
[0009] Preferably, the AI large model performs independent compilation and inference on each atomic code slice, specifically including the following steps: The compiler semantic understanding branch reads the code content and basic semantic features of atomic code slices and matches them with the corresponding programming language compilation rules, syntax specifications and hardware adaptation constraints. The decoupled inference branch is based on slice-dependent metadata, shielding the compilation interference of unrelated slices, and independently completing the lexical transformation, syntax transformation, and semantic mapping of a single slice to generate an initial intermediate representation; The incremental optimization branch performs redundancy removal, compilation accuracy correction, and format standardization on the initial intermediate representation, and outputs a standardized single-slice intermediate compilation representation.
[0010] Preferably, the specific execution steps of the decoupling and fusion strategy include: Dependency priority sorting: Based on the temporal dependencies and call hierarchy dependencies in the slice dependency metadata, all single slice intermediate compilation representations are sorted hierarchically to determine the fusion order; Intelligent compilation conflict resolution: The AI large model identifies syntax conflicts, data conflicts, and logical timing conflicts in the slice fusion process. Based on the preset compilation conflict rule base and model inference results, the conflict nodes are adaptively corrected, remapped, or redundantly removed. Cross-slice semantic alignment: unify the semantic dimensions, data formats, and compilation logic of intermediate compilation representations across slices, eliminate semantic deviations caused by independent compilation of slices, and merge to generate globally consistent, uncoupled intermediate compilation files.
[0011] Preferably, the decoupled intermediate compilation file is subjected to incremental compilation optimization, syntax verification, and target code adaptation processing to generate the final executable target code, completing the entire decoupled compilation process, which specifically includes the following steps: Perform global incremental optimization on decoupled intermediate compilation files, eliminate redundant global compilation code and repeated compilation logic, and optimize code execution timing and resource consumption; Perform multi-level syntax checks, logic checks, and dependency validity checks on the optimized intermediate compilation files to locate and fix minor compilation exceptions; Based on the target running hardware and operating system environment, the intermediate compiled files that pass verification are adapted to the instruction set and converted to the format to generate efficient and executable final target code.
[0012] Preferably, the process of collecting runtime data, conflict data, and performance data from the entire decoupled compilation process, cleaning and labeling them to generate structured iterative samples, performing targeted fine-tuning and performance verification on the dedicated AI model for compilation, and dynamically updating the compilation scenario knowledge base to achieve closed-loop iterative optimization of compilation capabilities specifically includes the following steps: After a single decoupling compilation task is completed, core data of the entire compilation process is automatically collected, including source code slice decoupling accuracy data, slice dependency matching deviation data, compilation conflict type and frequency data, intermediate characterization optimization parameters, compilation time, target code runtime latency, memory usage and exception error data, forming raw log data of single task compilation. The collected single-task compilation raw log data is deduplicated, noise-reduced, and abnormal data is removed. The valid compilation data is labeled and marked with dimensions including code coupling level, decoupling compilation difficulty, conflict resolution type, and compilation optimization gain magnitude, and structured compilation scenario iterative sample data is constructed. Structured compilation scenario iterative sample data is input into a large AI model dedicated to compilation. Targeted supervised fine-tuning is performed on the model’s dependency decoupling inference accuracy, compilation conflict identification accuracy, cross-slice semantic alignment capability, and incremental compilation optimization effect to correct the model’s inference bias under complex coupled code and extreme compilation scenarios. After fine-tuning, the model performance is verified by using a preset standard compilation test set. The decoupling success rate, compilation efficiency, and target code running performance before and after fine-tuning are compared. If the performance gain reaches the preset threshold, the model weight parameters are solidified, and a single closed-loop iteration is completed. The iteratively optimized model capability parameters, solutions to typical compilation problems, and newly added decoupled compilation rules are synchronously updated to the compilation scenario knowledge base, providing adaptive strategy support for subsequent source code decoupling preprocessing, sliced compilation inference, and fusion conflict resolution, thereby achieving continuous iterative upgrades of compilation capabilities.
[0013] Furthermore, a decoupled compilation system based on a large AI model is proposed to implement the aforementioned decoupled compilation method based on a large AI model, including: The code decoupling preprocessing module is used to obtain the original source code, complete syntax parsing, semantic slicing and dependency decoupling processing, and output atomic code slices and slice dependency metadata. The AI large model compilation and inference module is equipped with a pre-trained compilation-specific AI large model, which is used to independently complete the compilation and inference of each atomic code slice and generate intermediate compilation representations of a single slice. The decoupling and fusion processing module is used to execute a decoupling and fusion strategy based on slice dependency metadata, complete the hierarchical fusion and conflict resolution of intermediate representations of multiple slices, and generate uncoupled intermediate compilation files. The compilation optimization and output module is used to perform incremental optimization and verification of intermediate compilation files and generate the final executable target code. The iterative optimization module is used to collect data from the entire compilation process and realize closed-loop iterative fine-tuning of the large AI model.
[0014] Preferably, the AI large model compilation and inference module has built-in compilation semantic understanding branch, decoupled inference branch, and incremental optimization branch. Each branch operates independently and collaboratively, respectively realizing compilation rule matching, interference-free slice compilation and inference, and intermediate representation standardization optimization functions.
[0015] Preferably, the decoupling and fusion processing module has a built-in conflict detection unit, priority sorting unit, and semantic alignment unit, which are used to realize intelligent resolution of compilation conflicts, slice fusion sorting, and cross-slice semantic unification.
[0016] Compared with existing technologies, this invention provides a decoupled compilation method and system based on large AI models, which has the following beneficial effects: 1. This invention abandons the traditional fixed mode of overall compilation. Through AI semantic clustering and dependency graph analysis, it achieves fine decoupling and slicing of source code at the semantic and logical levels. It can accurately distinguish between explicit and implicit code dependencies, completely isolate compilation interference between modules, solve the core problems of global spread of single faults in traditional compilation and low compilation success rate of highly coupled code, and significantly improve the fault tolerance rate of complex code compilation.
[0017] 2. This invention constructs a large AI model specifically for compilation. Through multi-dimensional compilation sample pre-training and scenario fine-tuning, it has cross-language and multi-scenario compilation and reasoning capabilities. It can adaptively match the compilation requirements of different code types, hardware platforms, and coupling complexity, thus overcoming the technical defects of traditional compilation rules being rigid and lacking versatility.
[0018] 3. This invention solves the semantic deviation and fusion conflict problems after independent compilation of slices by hierarchical priority sorting, intelligent identification and adaptive correction of multiple types of conflicts, and cross-slice semantic alignment mechanism, ensuring global compilation consistency after multi-module split compilation, and the compilation accuracy is far superior to traditional modular compilation schemes.
[0019] 4. This invention pioneers a closed-loop iterative mechanism for compilation data acquisition, structured sample construction, model-oriented fine-tuning, parameter solidification, and knowledge base updates. This mechanism enables the compilation system to autonomously accumulate scenario experience, correct inference biases, and optimize compilation strategies during long-term use, thereby achieving continuous upgrades in compilation capabilities. It completely solves the problem that traditional compilation systems lack self-optimization capabilities and do not improve performance over long-term use.
[0020] 5. The atomic slicing independent parallel compilation mode reduces the amount of computation per compilation, the incremental optimization mechanism eliminates compilation redundancy, and combined with closed-loop iterative continuous optimization, it can effectively shorten compilation time and reduce compilation resource consumption. At the same time, the generated target code has better timing and lower memory consumption, resulting in a significant improvement in overall compilation performance. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating the overall process of the decoupled compilation method based on a large AI model, as described in this invention. Figure 2 This is a schematic diagram of the branch structure of the dedicated AI large model for compilation in this invention; Figure 3 This is a schematic diagram of the module architecture of the decoupled compilation system of the present invention; Figure 4 This is a schematic diagram of the closed-loop iterative optimization process for compiling this invention; Figure 5 This is a structural block diagram of a decoupled compilation system based on a large AI model. Detailed Implementation
[0022] The following description is intended to disclose the invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art.
[0023] Reference Figure 1 As shown, a decoupled compilation method based on a large AI model includes: S100. Obtain the original source code to be compiled, perform syntax parsing, semantic slicing and dependency decoupling preprocessing on the original source code, remove code syntax redundancy, global coupling dependencies and static binding relationships, and output several semantically independent, loosely coupled atomic code slices and corresponding slice dependency metadata. S200. Input the atomic code slices and slice dependency metadata into a pre-trained compilation-specific AI model. Through the compilation semantic understanding branch, decoupling inference branch, and incremental optimization branch of the AI model, perform independent compilation inference on each atomic code slice to generate corresponding single-slice intermediate compilation representations. The compilation-specific AI model is a dedicated large model obtained by fine-tuning based on massive cross-language compilation samples and coupled compilation defect samples. It has the ability to dynamically decompose code dependencies and adaptively match compilation rules. S300. Based on the slice dependency metadata, the intermediate compilation representations of all single slices are layered and fused through the decoupling and fusion strategy of the AI large model to avoid inter-slice coupling compilation conflicts and generate globally unified uncoupled intermediate compilation files. The decoupling and fusion strategy includes three core sub-steps: dependency priority sorting, intelligent resolution of compilation conflicts, and cross-slice semantic alignment. S400. Perform incremental compilation optimization, syntax verification and target code adaptation on the decoupled intermediate compilation file to generate the final executable target code and complete the entire decoupled compilation process. The S500 collects runtime data, conflict data, and performance data from the entire decoupled compilation process. After cleaning and annotation, it generates structured iterative samples, performs targeted fine-tuning and performance verification on the dedicated AI model for compilation, and dynamically updates the compilation scenario knowledge base to achieve closed-loop iterative optimization of compilation capabilities.
[0024] Specifically, step S100, which involves semantic slicing and dependency decoupling preprocessing of the original source code, includes the following steps: S101. Perform lexical analysis and syntax tree construction on the original source code, traverse the syntax tree nodes, and identify the four core code units: functions, variables, logic modules, and call relationships. S102. Based on the AI semantic clustering algorithm, code nodes in the syntax tree with a semantic correlation higher than a preset threshold are aggregated into initial code slices, and invalid cross-module correlation nodes are removed. S103. Construct a global code dependency graph, mark the explicit call dependencies, implicit data dependencies, and temporal logic dependencies of each initial code slice, cut the strong coupling binding relationship between slices, and iteratively optimize the initial code slices into semantically independent atomic code slices. S104. Extract the slice identifier, dependent objects, compilation constraints, and semantic feature information of each atomic code slice to generate structured slice dependency metadata; In this embodiment, the system receives the complete original source code of the project to be compiled in real time, supporting various input formats such as single-file code, multi-file project code, and cross-module mixed code. The system first performs a complete lexical scan and syntax parsing of the original source code, identifying keywords, identifiers, expressions, and statement structures line by line, constructing a fully covered abstract syntax tree to completely reconstruct the code hierarchy and node relationships. After traversing all nodes of the syntax tree, it accurately distinguishes and extracts four types of core code units: function definitions, global and local variables, business logic code blocks, and cross-module call interfaces.
[0025] In this step, an AI semantic clustering model with a preset semantic relevance threshold is used to aggregate and group syntax tree nodes. Code nodes with a semantic relevance greater than 0.8 are grouped into the same initial code slice, while redundant nodes with weak cross-module connections and invalid references are removed to ensure that the internal semantics of each initial slice are highly aggregated and external connections are weakened as much as possible. Subsequently, a global directed dependency graph is constructed, with each initial code slice as a graph node and code calls, data read / write, and sequential execution as edges, respectively labeling explicit call dependencies, implicit data dependencies, and sequential logical dependencies to accurately identify strong coupling binding relationships between slices.
[0026] By employing dependency splitting and boundary optimization strategies, strongly coupled slices undergo secondary splitting and boundary correction, iteratively generating semantically independent, functionally singular, and loosely coupled atomic code slices. All atomic code slices retain only lightweight, traceable, and canonical dependencies, eliminating static strong bindings and global interference relationships. Finally, the system automatically extracts the unique slice ID, dependency object list, compilation environment constraints, hardware adaptation requirements, and semantic feature vectors for each atomic code slice, structurally generating slice dependency metadata. This provides standardized, parsable, and isolated input data for subsequent independent compilation and inference of large models.
[0027] Reference Figure 2 As shown, in step S200, the pre-training and fine-tuning method for compiling a dedicated large AI model includes the following steps: S201. Construct a dedicated training dataset for compilation, which includes cross-programming language standard compilation samples, traditional coupled compilation error samples, code decoupling compilation comparison samples, and complex scenario multi-dependency code compilation samples. S202. Based on the basic large model architecture, add a compilation semantic understanding module, a dependency decoupling reasoning module, and a compilation error correction module to build a dedicated basic model for compilation. S203. Pre-train the compiler-specific basic model by combining mask learning and contrastive learning, so that it can master the general code syntax rules, compilation logic and code dependency relationships. S204. Supervised fine-tuning is performed based on manually annotated decoupled compilation benchmark samples, and iterative optimization is performed using online feedback data from real compilation scenarios to improve the model's ability to decouple coupled code and the accuracy of decoupled compilation inference. Furthermore, in step S200, the AI large model performs independent compilation and inference on each atomic code slice, including the following steps: S205. The compiler semantic understanding branch reads the code content and basic semantic features of the atomic code slices and matches them with the corresponding programming language compilation rules, syntax specifications and hardware adaptation constraints. S206. The decoupled reasoning branch is based on slice dependency metadata, shields the compilation interference of non-related slices, and independently completes the lexical transformation, syntax transformation, and semantic mapping of a single slice to generate the initial intermediate representation. S207, the incremental optimization branch performs redundancy removal, compilation accuracy correction and format standardization on the initial intermediate representation, and outputs a standardized single-slice intermediate compilation representation. In this embodiment, all atomic code slices output in step S100 and their corresponding slice dependency metadata are batch-input into a pre-trained and scenario-fine-tuned compilation-specific AI large model. This large model differs from general-purpose large models, possessing dedicated compilation semantic understanding, decoupled reasoning, and incremental optimization capabilities. It completes independent compilation and reasoning for each slice through three parallel and collaborative functional branches.
[0028] The compilation semantic understanding branch reads the content and semantic features of each atomic code slice in real time, automatically identifies the syntax systems of different programming languages such as C, C++, Java, and Python, and accurately matches the lexical rules, syntax specifications, compilation keyword constraints, and target hardware instruction set adaptation conditions of the corresponding language to complete the standardized parsing of code semantics. The decoupled inference branch, relying on the isolation properties of slice dependency metadata, shields all parameter and logical interference from unrelated slices during single-slice inference, achieving closed-loop, independent compilation inference for each slice. It completes lexical mapping, syntax transformation, and semantic logic reconstruction slice by slice, generating the initial intermediate representation corresponding to each atomic code slice.
[0029] The incremental optimization branch performs unified post-processing on all initial intermediate representations, correcting and eliminating redundant dimensions, inference bias parameters, and non-standardized content in each representation. It unifies the dimensional format, semantic paradigm, and expression precision of all slice intermediate representations, and outputs batch-standardized, highly consistent, and directly fusionable single-slice intermediate compiled representation sets. This ensures that the compilation results of each slice are independent, accurate, and uniform in format, laying the foundation for subsequent global conflict-free fusion.
[0030] Reference Figure 3 As shown, in step S300, the specific execution steps of the decoupling and fusion strategy include: S301. Dependency Priority Sorting: Based on the temporal dependencies and call hierarchy dependencies in the slice dependency metadata, sort all the intermediate compilation representations of single slices hierarchically to determine the order of fusion; S302, Intelligent resolution of compilation conflicts: Through AI large model, syntax conflicts, data conflicts, and logical timing conflicts in the slice fusion process are identified. Based on the preset compilation conflict rule base and model inference results, conflict nodes are adaptively corrected, remapped, or redundantly removed. S303, Cross-slice semantic alignment: unify the semantic dimensions, data formats, and compilation logic of intermediate compilation representations across slices, eliminate semantic deviations caused by independent compilation of slices, and merge to generate globally consistent, uncoupled intermediate compilation files; In this embodiment, the system first reads all intermediate compilation representations of single slices and their corresponding slice dependency metadata. Based on the call level, dependency weight, and execution order in the metadata, the system prioritizes all slice representations and generates an ordered fusion sequence according to the rules of "fusion of dependents first, fusion of timing-preceding modules first, and fusion of basic modules first," thus preventing logical errors and compilation anomalies caused by disordered fusion.
[0031] During the successive fusion process, the system monitors in real time various compilation conflicts caused by the overlay of multiple slices, such as variable redefinition, function interface conflicts, data type mismatches, execution timing reversals, and semantic logic contradictions. For detected conflicts, the system intelligently resolves them by combining AI-powered large-scale model semantic reasoning with a built-in compilation conflict rule library: it performs variable domain remapping for variable naming conflicts, adaptive parameter alignment for interface parameter mismatches, sequence correction for timing logic conflicts, and direct removal of invalid and redundant conflicting code, achieving fully automatic conflict resolution without human intervention.
[0032] After conflict resolution is completed, cross-slice semantic alignment processing is initiated to unify the semantic expression dimension, data storage format, logical execution paradigm and compilation level of all intermediate compiled representations. This eliminates local semantic deviations and format differences caused by independent compilation of each slice, ensuring that all slice representations maintain logical consistency and semantic compatibility in the global dimension. Finally, the resulting fusion outputs a complete, uncoupled intermediate compiled file that is globally coherent, free from coupling interference and compilation conflicts.
[0033] Reference Figure 4 As shown, step S400, which involves incremental compilation optimization, syntax verification, and target code adaptation processing of the decoupled intermediate compilation file to generate the final executable target code, and completing the entire decoupled compilation process, specifically includes the following steps: S401. Perform global incremental optimization on uncoupled intermediate compilation files, eliminate redundant global compilation code and repeated compilation logic, and optimize code execution timing and resource consumption. S402. Perform multi-level syntax checks, logic checks, and dependency validity checks on the optimized intermediate compilation files to locate and fix minor compilation exceptions. S403. Based on the target running hardware and operating system environment, perform instruction set adaptation and format conversion on the verified intermediate compilation files to generate efficient and executable final target code. In this embodiment, a refined global incremental compilation optimization is performed on the fused uncoupled intermediate compilation file. The entire logic of the intermediate code is traversed to remove invalid and redundant code, repetitive calculation logic, redundant compilation parameters and invalid data definitions, simplify the program's memory and computational overhead, optimize branch judgment logic, loop execution logic and task scheduling timing, and significantly improve the overall code execution efficiency.
[0034] After optimization, multi-level closed-loop verification is performed, sequentially carrying out syntax standardization verification, business logic integrity verification, slice dependency legality verification, and cross-module compatibility verification. Syntax errors, logical vulnerabilities, dependency failures, and adaptation anomalies are checked line by line and module by module. Minor compilation defects are automatically repaired and compensated to ensure that intermediate compiled files are logically complete, syntactically compliant, and have valid dependencies.
[0035] Finally, based on the user's preset target runtime environment, including embedded hardware architecture, general processor instruction set, operating system type and runtime permission constraints, the verified intermediate compilation files are translated into instructions, converted into formats, adapted to runtime parameters and optimized for platform compatibility. Ultimately, executable target code that can be directly deployed, loaded normally, and is highly efficient and stable is generated, completing the main process of single-cycle decoupled compilation.
[0036] Specifically, step S500 involves collecting runtime data, conflict data, and performance data from the entire decoupled compilation process, cleaning and labeling them to generate structured iterative samples, performing targeted fine-tuning and performance verification on the dedicated AI model for compilation, and dynamically updating the compilation scenario knowledge base to achieve closed-loop iterative optimization of compilation capabilities. This includes the following steps: S501, Real-time Data Acquisition Throughout the Entire Process: After a single decoupling compilation task is completed, core data of the entire compilation process is automatically collected, including source code slice decoupling accuracy data, slice dependency matching deviation data, compilation conflict type and frequency data, intermediate characterization optimization parameters, compilation time, target code runtime latency, memory usage and exception error data, forming raw log data for single-task compilation. S502. Data cleaning and sample structuring: The collected single-task compilation raw log data is deduplicated, noise-reduced, and abnormal data is removed. The effective compilation data is labeled and marked. The labeling dimensions include code coupling level, decoupling compilation difficulty, conflict resolution type, and compilation optimization gain magnitude. Structured compilation scenario iterative sample data is constructed. S503, Model-oriented fine-tuning training: Input structured compilation scenario iterative sample data into the compilation-specific AI large model, and perform targeted supervised fine-tuning on the model's dependency decoupling inference accuracy, compilation conflict identification accuracy, cross-slice semantic alignment capability, and incremental compilation optimization effect to correct the model's inference bias in complex coupled code and extreme compilation scenarios. S504. Iteration effect verification and parameter solidification: After fine-tuning, the model performance is verified by using a preset standard compilation test set. The decoupling success rate, compilation efficiency, and target code running performance before and after fine-tuning are compared. If the performance gain reaches the preset threshold, the model weight parameters are solidified to complete a single closed-loop iteration. S505, Dynamic Update of Scenario Knowledge Base: The iteratively optimized model capability parameters, solutions to typical compilation problems, and newly added decoupling compilation rules are synchronously updated to the compilation scenario knowledge base, providing adaptive strategy support for subsequent source code decoupling preprocessing, slice compilation inference, and fusion conflict resolution, and realizing continuous iterative upgrades of compilation capabilities; In this embodiment, after a single compilation task is completed, the system automatically triggers a closed-loop iterative optimization process without human intervention. First, full-dimensional data collection is initiated, recording in real time a complete set of compilation log data, including slice decoupling accuracy, dependency matching error, conflict type and frequency, intermediate representation optimization parameters, overall compilation time, target code runtime latency, peak memory usage, and exception error information, forming a complete raw compilation dataset.
[0037] The original dataset is automatically cleaned, denoised, and deduplicated to remove abnormal, duplicate, invalid, and extremely interfering data, while retaining valid compiled samples. At the same time, it is labeled in multiple dimensions according to code coupling level, decoupling difficulty, conflict type, and optimization gain magnitude to construct a structured, standardized, iterative sample set that can be used for model training.
[0038] The iterative sample set is input into a dedicated AI model for compilation. Supervised fine-tuning is then performed on the model's implicit dependency identification capability, decoupled inference accuracy, conflict intelligent identification accuracy, cross-slice semantic alignment effect, and incremental optimization level. This corrects inference biases in extreme scenarios such as highly coupled complex code, multi-module nesting, and cross-language mixed compilation. After fine-tuning, performance is compared and verified using a standard compilation test dataset. When any one or more gains in compilation success rate, compilation efficiency, or code execution performance reach a preset threshold, the system automatically fixes the latest model weight parameters, completing a single model iteration upgrade.
[0039] Simultaneously, the system updates the new decoupling rules, conflict resolution schemes, optimization strategies, and model capability parameters obtained in this iteration to the compilation scenario knowledge base, achieving dynamic iterative upgrades of the knowledge base. The updated model and knowledge base then influence the entire process of preprocessing, slice reasoning, and fusion optimization in the next round of compilation tasks, enabling the system's compilation capabilities to continuously evolve autonomously, forming a permanent closed-loop iterative mechanism of data collection—sample construction—model fine-tuning—performance verification—knowledge base updates.
[0040] Reference Figure 5 As shown, a decoupled compilation system based on a large AI model is used to implement the decoupled compilation method based on a large AI model as described above, including: The code decoupling preprocessing module is used to obtain the original source code, complete syntax parsing, semantic slicing and dependency decoupling processing, and output atomic code slices and slice dependency metadata. The AI large model compilation and inference module is equipped with a pre-trained compilation-specific AI large model, which is used to independently complete the compilation and inference of each atomic code slice and generate intermediate compilation representations of a single slice. The decoupling and fusion processing module is used to execute a decoupling and fusion strategy based on slice dependency metadata, complete the hierarchical fusion and conflict resolution of intermediate representations of multiple slices, and generate uncoupled intermediate compilation files. The compilation optimization and output module is used to perform incremental optimization and verification of intermediate compilation files and generate the final executable target code. An iterative optimization module is used to collect data from the entire compilation process and realize closed-loop iterative fine-tuning of the AI large model. The AI large model compilation and inference module includes a built-in compilation semantic understanding branch, a decoupled inference branch, and an incremental optimization branch. Each branch operates independently and collaboratively, respectively achieving compilation rule matching, interference-free slice compilation and inference, and intermediate representation standardization and optimization functions. The decoupling and fusion processing module has a built-in conflict detection unit, priority sorting unit, and semantic alignment unit, which are used to achieve intelligent resolution of compilation conflicts, slice fusion sorting, and cross-slice semantic unification.
[0041] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.
Claims
1. A decoupled compilation method based on a large AI model, characterized in that, include: Obtain the original source code to be compiled, perform syntax parsing, semantic slicing and dependency decoupling preprocessing on the original source code, remove code syntax redundancy, global coupling dependencies and static binding relationships, and output several semantically independent, loosely coupled atomic code slices and corresponding slice dependency metadata; The atomic code slices and slice dependency metadata are input into a pre-trained compilation-specific AI model. Through the compilation semantic understanding branch, decoupling inference branch, and incremental optimization branch of the AI model, each atomic code slice is independently compiled and inferred to generate the corresponding single-slice intermediate compilation representation. The compilation-specific AI model is a dedicated large model obtained by fine-tuning based on massive cross-language compilation samples and coupled compilation defect samples. It has the ability to dynamically decompose code dependencies and adaptively match compilation rules. Based on the slice dependency metadata, the intermediate compilation representations of all single slices are layered and fused through the decoupling and fusion strategy of the AI large model to avoid inter-slice coupling compilation conflicts and generate globally unified uncoupled intermediate compilation files. The decoupling and fusion strategy includes three core sub-steps: dependency priority sorting, intelligent resolution of compilation conflicts, and cross-slice semantic alignment. Incremental compilation optimization, syntax verification and target code adaptation are performed on the decoupled intermediate compilation file to generate the final executable target code, thus completing the entire decoupled compilation process. The entire decoupled compilation process was collected, including runtime data, conflict data, and performance data. After cleaning and annotation, structured iterative samples were generated. The AI model dedicated to compilation was then fine-tuned and its performance verified. The compilation scenario knowledge base was dynamically updated to achieve closed-loop iterative optimization of compilation capabilities.
2. The decoupled compilation method based on a large AI model according to claim 1, characterized in that, The semantic slicing and dependency decoupling preprocessing of the original source code specifically includes the following steps: Lexical analysis and syntax tree construction are performed on the original source code. The syntax tree nodes are traversed to identify the four core code units: functions, variables, logical modules, and call relationships. Based on AI semantic clustering algorithm, code nodes with semantic relevance higher than a preset threshold in the syntax tree are aggregated into initial code slices, and invalid cross-module relevance nodes are removed; Construct a global code dependency graph, mark the explicit call dependencies, implicit data dependencies, and temporal logic dependencies of each initial code slice, cut the strong coupling binding relationships between slices, and iteratively optimize the initial code slices into semantically independent atomic code slices; Extract the slice identifier, dependent objects, compilation constraints, and semantic feature information of each atomic code slice to generate structured slice dependency metadata.
3. The decoupled compilation method based on a large AI model according to claim 1, characterized in that, The pre-training and fine-tuning method for the dedicated AI large model includes the following steps: Construct a dedicated training dataset for compilation, which includes cross-programming language standard compilation samples, traditional coupled compilation error samples, code decoupling compilation comparison samples, and complex scenario multi-dependency code compilation samples. Based on the basic large model architecture, a compilation semantic understanding module, a dependency decoupling reasoning module, and a compilation error correction module are added to build a dedicated basic model for compilation. A combination of mask learning and contrastive learning is used to pre-train the compiler-specific basic model, enabling it to master general code syntax rules, compilation logic, and code dependencies. Supervised fine-tuning is performed based on manually annotated decoupled compilation benchmark samples, while iterative optimization is carried out using online feedback data from real compilation scenarios to improve the model's ability to decouple coupled code and the accuracy of decoupled compilation inference.
4. The decoupled compilation method based on a large AI model according to claim 1, characterized in that, The AI large model performs independent compilation and inference on each atomic code slice, specifically including the following steps: The compiler semantic understanding branch reads the code content and basic semantic features of atomic code slices and matches them with the corresponding programming language compilation rules, syntax specifications and hardware adaptation constraints. The decoupled inference branch is based on slice-dependent metadata, shielding the compilation interference of unrelated slices, and independently completing the lexical transformation, syntax transformation, and semantic mapping of a single slice to generate an initial intermediate representation; The incremental optimization branch performs redundancy removal, compilation accuracy correction, and format standardization on the initial intermediate representation, and outputs a standardized single-slice intermediate compilation representation.
5. The decoupled compilation method based on a large AI model according to claim 4, characterized in that, The specific execution steps of the decoupling and fusion strategy include: Dependency priority sorting: Based on the temporal dependencies and call hierarchy dependencies in the slice dependency metadata, all single slice intermediate compilation representations are sorted hierarchically to determine the fusion order; Intelligent compilation conflict resolution: The AI large model identifies syntax conflicts, data conflicts, and logical timing conflicts in the slice fusion process. Based on the preset compilation conflict rule base and model inference results, the conflict nodes are adaptively corrected, remapped, or redundantly removed. Cross-slice semantic alignment: unify the semantic dimensions, data formats, and compilation logic of intermediate compilation representations across slices, eliminate semantic deviations caused by independent compilation of slices, and merge to generate globally consistent, uncoupled intermediate compilation files.
6. The decoupled compilation method based on a large AI model according to claim 1, characterized in that, Incremental compilation optimization, syntax verification, and target code adaptation are performed on the decoupled intermediate compilation file to generate the final executable target code. The entire decoupled compilation process includes the following steps: Perform global incremental optimization on decoupled intermediate compilation files, eliminate redundant global compilation code and repeated compilation logic, and optimize code execution timing and resource consumption; Perform multi-level syntax checks, logic checks, and dependency validity checks on the optimized intermediate compilation files to locate and fix minor compilation exceptions; Based on the target running hardware and operating system environment, the intermediate compiled files that have passed verification are adapted to the instruction set and converted to the format to generate efficient and executable final target code.
7. The decoupled compilation method based on a large AI model according to claim 1, characterized in that, The process of collecting runtime data, conflict data, and performance data from the entire decoupled compilation process, cleaning and labeling them to generate structured iterative samples, performing targeted fine-tuning and performance verification on the dedicated AI model for compilation, and dynamically updating the compilation scenario knowledge base to achieve closed-loop iterative optimization of compilation capabilities specifically includes the following steps: After a single decoupling compilation task is completed, core data of the entire compilation process is automatically collected, including source code slice decoupling accuracy data, slice dependency matching deviation data, compilation conflict type and frequency data, intermediate characterization optimization parameters, compilation time, target code runtime latency, memory usage and exception error data, forming raw log data of single task compilation. The collected raw log data of single-task compilation is deduplicated, noise-reduced, and abnormal data is removed. The effective compilation data is labeled and marked with dimensions including code coupling level, decoupling compilation difficulty, conflict resolution type, and compilation optimization gain magnitude, and structured compilation scenario iterative sample data is constructed. Structured compilation scenario iterative sample data is input into a large AI model dedicated to compilation. Targeted supervised fine-tuning is performed on the model’s dependency decoupling inference accuracy, compilation conflict identification accuracy, cross-slice semantic alignment capability, and incremental compilation optimization effect to correct the model’s inference bias in complex coupled code and extreme compilation scenarios. After fine-tuning, the model performance is verified by using a preset standard compilation test set. The decoupling success rate, compilation efficiency, and target code running performance before and after fine-tuning are compared. If the performance gain reaches the preset threshold, the model weight parameters are solidified, and a single closed-loop iteration is completed. The iteratively optimized model capability parameters, solutions to typical compilation problems, and newly added decoupled compilation rules are synchronously updated to the compilation scenario knowledge base, providing adaptive strategy support for subsequent source code decoupling preprocessing, sliced compilation inference, and fusion conflict resolution, thereby achieving continuous iterative upgrades of compilation capabilities.
8. A decoupled compilation system based on a large AI model, used to implement the decoupled compilation method based on a large AI model as described in any one of claims 1-7, characterized in that, include: The code decoupling preprocessing module is used to obtain the original source code, complete syntax parsing, semantic slicing and dependency decoupling processing, and output atomic code slices and slice dependency metadata. The AI large model compilation and inference module is equipped with a pre-trained compilation-specific AI large model, which is used to independently complete the compilation and inference of each atomic code slice and generate intermediate compilation representations of a single slice. The decoupling and fusion processing module is used to execute a decoupling and fusion strategy based on slice dependency metadata, complete the hierarchical fusion and conflict resolution of intermediate representations of multiple slices, and generate uncoupled intermediate compiled files. The compilation optimization and output module is used to perform incremental optimization and verification of intermediate compilation files and generate the final executable target code. The iterative optimization module is used to collect data from the entire compilation process and realize closed-loop iterative fine-tuning of the large AI model.
9. A decoupled compilation system based on a large AI model according to claim 8, characterized in that, The AI large model compilation and inference module has built-in compilation semantic understanding branch, decoupled inference branch, and incremental optimization branch. Each branch operates independently and collaboratively, respectively realizing compilation rule matching, interference-free slice compilation and inference, and intermediate representation standardization optimization functions.
10. A decoupled compilation system based on a large AI model according to claim 8, characterized in that, The decoupling and fusion processing module has a built-in conflict detection unit, priority sorting unit, and semantic alignment unit, which are used to realize intelligent resolution of compilation conflicts, slice fusion sorting, and cross-slice semantic unification.
