Optimization strategy model training method and device, storage medium and equipment

By optimizing the initial model using relative entropy during the LLVM IR statement conversion process and generating an optimization strategy model, the problems of low efficiency and manual dependence in existing technologies are solved, and efficient and accurate assembly code generation is achieved.

CN121579019APending Publication Date: 2026-02-27CIX TECH (SHANGHAI) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511772705.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

In the process of converting LLVM IR statements into assembly code, existing technologies require a lot of manual intervention, and the accuracy depends on experience, resulting in low efficiency and high cost.

Method used

By inputting sample programs into the initial and reference models, a set of primary and reference optimization rules is obtained. The initial model is then optimized using relative entropy to generate an optimization strategy model, thereby reducing computational resource consumption and improving accuracy and efficiency.

Benefits of technology

It improves the accuracy and efficiency of converting LLVM IR statements into assembly code, reduces computational costs, and decreases reliance on human experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579019A_ABST
    Figure CN121579019A_ABST
Patent Text Reader

Abstract

The invention provides an optimization strategy model training method and device, a storage medium and equipment, and the method comprises the steps: inputting a sample program into an initial model and a reference model, so as to obtain a plurality of first-order optimization rule sets outputted by the initial model and a reference optimization rule set outputted by the reference model; obtaining a relative entropy between each first-order optimization rule set and the reference optimization rule set; and optimizing the initial model according to the relative entropy to obtain an optimization strategy model. The initial model is optimized according to the output of the reference model, and the obtained optimization strategy model improves the reasoning efficiency and accuracy compared with the initial model and reduces the calculation cost compared with the reference model. The optimization rule corresponding to the LLVM IR statement is generated by utilizing the optimization strategy model, so that the generation efficiency and accuracy are guaranteed, the dependence on artificial experience is eliminated, and the labor cost is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computers, and more specifically, to an optimization strategy model training method, apparatus, storage medium, and device. Background Technology

[0002] Low Level Virtual Machine Intermediate Representation (LLVM IR) is an intermediate language within the low-level virtual machine compiler framework. It provides an abstraction layer that enables the compiler to perform optimizations and code generation at multiple stages. LLVM IR features a near-reduced instruction set architecture and uses a three-address instruction format, making it very powerful and flexible in compiler design. Assembly code is an important computer language. In actual execution, the program corresponding to LLVM IR statements needs to be converted into assembly code corresponding to assembly instructions.

[0003] In the process of assembling programs, it is usually necessary to specify the optimization rules corresponding to LLVM IR statements. This will consume a lot of manpower and resources, and its correctness depends heavily on human experience, making it difficult to guarantee accuracy. This has become a difficult point of concern for those skilled in the art. Summary of the Invention

[0004] The purpose of this invention is to provide an optimization strategy model training method, apparatus, storage medium, and device to improve the above-mentioned problems.

[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: In a first aspect, embodiments of the present invention provide a method for training an optimization strategy model, the method comprising: The sample program is input into the initial model and the reference model respectively to obtain a set of multiple initial optimization rules output by the initial model and a set of reference optimization rules output by the reference model. The initial optimization rule set and the reference optimization rule set both include optimization rules corresponding to each LLVM IR statement in the sample program at different stages of assembler conversion. The computational resource consumption of the initial model in the running state is less than that of the reference model in the running state. The initial model is a network trained to a preliminary convergence state using training statements. The reference model is a model fine-tuned using training statements on the source language model and then fine-tuned after verification. Obtain the relative entropy between each of the initial optimization rule sets and the reference optimization rule set; The initial model is optimized based on the relative entropy to obtain an optimized strategy model.

[0006] In a second aspect, embodiments of the present invention provide an optimization strategy model training apparatus, the apparatus comprising: The first processing unit is used to input the sample program into the initial model and the reference model respectively, so as to obtain a set of multiple initial optimization rules output by the initial model and a set of reference optimization rules output by the reference model. The initial optimization rule set and the reference optimization rule set both include optimization rules corresponding to each LLVM IR statement in the sample program at different stages of assembler conversion. The computational resource consumption of the initial model in the running state is less than that of the reference model in the running state. The initial model is a network trained to a preliminary convergence state using training statements. The reference model is a model fine-tuned using training statements on the source language model and then fine-tuned after verification. The first processing unit is further configured to obtain the relative entropy between each of the initial optimization rule sets and the reference optimization rule set; The second processing unit is used to optimize the initial model based on the relative entropy to obtain an optimized strategy model.

[0007] Thirdly, embodiments of the present invention provide a storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method.

[0008] Fourthly, embodiments of the present invention provide an electronic device, the electronic device comprising: a processor and a memory, the memory being used to store one or more programs; when the one or more programs are executed by the processor, the above-described method is implemented.

[0009] Compared to existing technologies, the present invention provides an optimization strategy model training method, apparatus, storage medium, and device, comprising: inputting a sample program into an initial model and a reference model respectively to obtain a set of multiple initial-order optimization rules output by the initial model and a set of reference optimization rules output by the reference model; wherein, both the initial-order optimization rule set and the reference optimization rule set include optimization rules corresponding to each LLVM IR statement in the sample program at different stages of assembler conversion; the computational resource consumption of the initial model in its running state is less than that of the reference model in its running state; the initial model is a network trained to a preliminary convergence state using training statements; the reference model is a model fine-tuned using training statements and then fine-tuned after verification; obtaining the relative entropy between each set of initial-order optimization rules and the reference optimization rule set; optimizing the initial model based on the relative entropy to obtain an optimization strategy model. The optimization strategy model obtained by optimizing the initial model based on the output of the reference model improves inference efficiency and accuracy compared to the initial model and reduces computational cost compared to the reference model. By using an optimization strategy model to generate optimization rules corresponding to LLVM IR statements, the generation efficiency and accuracy are guaranteed, eliminating reliance on human experience and saving labor costs.

[0010] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.

[0013] Figure 2 This is one of the flowcharts illustrating the optimization strategy model training method provided in an embodiment of the present invention.

[0014] Figure 3 This is the second flowchart illustrating the optimization strategy model training method provided in this embodiment of the invention.

[0015] Figure 4 This is a schematic diagram of a unit of an optimization strategy model training device provided in an embodiment of the present invention.

[0016] In the diagram: 10-Processor; 11-Memory; 12-Bus; 13-Communication interface; 501-First processing unit; 502-Second processing unit. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0018] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0019] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0020] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0021] The following detailed description of some embodiments of the present invention is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0022] This invention provides an electronic device, which may be a computer device or a server device. Please refer to... Figure 1This is a schematic diagram of the structure of an electronic device. The electronic device includes a processor 10, a memory 11, and a bus 12. The processor 10 and the memory 11 are connected via the bus 12. The processor 10 is used to execute executable modules, such as computer programs, stored in the memory 11.

[0023] Processor 10 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the optimization strategy model training method can be completed through integrated logic circuits in the hardware or software instructions within processor 10. The aforementioned processor 10 can be a general-purpose processor, including a Central Processing Unit (CPU); it can also be a Digital Signal Processor (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0024] The memory 11 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage.

[0025] Bus 12 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. Figure 1 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus 12 or one type of bus 12.

[0026] The memory 11 is used to store programs, such as programs corresponding to an optimization strategy model training device. The optimization strategy model training device includes at least one software functional module that can be stored in the memory 11 in the form of software or firmware, or embedded in the operating system (OS) of the electronic device. Upon receiving an execution instruction, the processor 10 executes the program to implement the optimization strategy model training method.

[0027] The electronic device provided in this embodiment of the invention may further include a communication interface 13. The communication interface 13 is connected to the processor 10 via a bus.

[0028] It should be understood that, Figure 1 The structure shown is only a partial schematic diagram of the electronic device; the electronic device may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0029] The optimization strategy model training method provided in this embodiment of the invention can be applied to, but is not limited to, [various applications]. Figure 1 For the specific process of the electronic devices shown, please refer to [link / reference]. Figure 2 The optimization strategy model training methods include S10, S20, and S50, which are described in detail below.

[0030] S10, input the sample program into the initial model and the reference model respectively to obtain the set of multiple initial optimization rules output by the initial model and the set of reference optimization rules output by the reference model.

[0031] The sample program is a program compiled using LLVM IR statements. Both the initial optimization rule set and the reference optimization rule set include the optimization rules corresponding to each LLVM IR statement in the sample program at different stages of the assembler conversion. The computational resource consumption of the initial model in the running state is less than that of the reference model in the running state. The initial model is a network trained to a preliminary convergence state using training statements. The reference model is a source language model (including Qwen, Llama, DeepSeek, etc.) fine-tuned using training statements and fine-tuned after verification. The training statements are LLVM IR statements with added labels. The labels include the long chain inference process record of the training statements converted into assembly statements and their corresponding optimization rule set.

[0032] S20, obtain the relative entropy between each set of initial optimization rules and the reference optimization rule set.

[0033] The relative entropy, also known as KL divergence or Kullback-Leibler Divergence, is used to constrain the model's update magnitude, preventing it from deviating too far from the original policy and thus maintaining the stability of exploration and exploitation.

[0034] S50, optimize the initial model based on relative entropy to obtain the optimized strategy model.

[0035] The initial model, in its preliminary convergence state, performs worse than the reference model. Therefore, it needs to be optimized based on relative entropy to obtain an optimized strategy model. The reference model is obtained by fine-tuning the source language model, which consumes a large amount of computational resources during runtime. It performs better inference, but if it is used directly as the optimization strategy model, it will cause the optimization strategy model to consume a large amount of computational resources during runtime, increasing the computational cost.

[0036] Therefore, in the optimization strategy model training method provided in this embodiment of the invention, the initial model is optimized based on the output of the reference model. The resulting optimized strategy model improves inference efficiency and accuracy compared to the initial model, while reducing computational cost compared to the reference model. Utilizing the optimized strategy model to generate optimization rules corresponding to LLVM IR statements ensures efficient and accurate generation, eliminates reliance on human experience, and saves labor costs.

[0037] exist Figure 2 Based on this, regarding how to further improve the optimization effect of the model, this embodiment of the invention also provides an optional implementation method, please refer to... Figure 3 Other optimization strategy model training methods include S30 and S40, as detailed below.

[0038] S30: Obtain the accuracy reward value, format reward value, inference length reward value, language readability reward value, and running speed reward value corresponding to each set of initial optimization rules.

[0039] S40 calculates the comprehensive reward value for each set of initial optimization rules by weighting the reward values ​​for accuracy, format, inference length, language readability, and execution speed.

[0040] The formula for calculating the overall reward value can be: M total =a 1× M1+ a 2× M2+ a 3× M3+ a 4× M4+ a 5× M5; Among them, M total The values ​​represent the overall reward value, with M1 representing the accuracy reward value, M2 representing the format reward value, M3 representing the inference length reward value, M4 representing the language readability reward value, M5 representing the running speed reward value, a1 representing the accuracy reward weight, a2 representing the format reward weight, a3 representing the inference length reward weight, a4 representing the language readability reward weight, and a5 representing the running speed reward weight.

[0041] Please continue to refer to this. Figure 3S50, optimize the initial model based on relative entropy to obtain the optimized strategy model, including: S51, which is explained in detail below.

[0042] S51. Based on the relative entropy and the comprehensive reward value corresponding to each set of initial optimization rules, the initial model is optimized to obtain the optimization strategy model.

[0043] By setting reward values ​​and relative entropy, the initial model is optimized, causing it to evolve towards higher rewards under the constraint of relative entropy. This improves the final optimization effect and yields an optimized strategy model that balances accuracy, format consistency, inference length, language readability, and running speed.

[0044] Building upon the preceding text, this invention also provides an optional implementation method for obtaining the accuracy reward value, format reward value, inference length reward value, language readability reward value, and running speed reward value corresponding to each set of initial optimization rules. Please refer to the following text.

[0045] Optionally, obtain the accuracy reward value corresponding to each set of initial optimization rules, including: S311 to S315, as detailed below.

[0046] S311, add the set of primary optimization rules to the pre-trained compilation framework to obtain the primary assembler conversion model.

[0047] S312 inputs the sample program into the primary assembler conversion model.

[0048] S313, the primary assembler conversion model combines the optimization rules in the primary optimization rule set to perform assembly conversion on the LLVM IR statements in the sample program to obtain its corresponding primary assembler.

[0049] S314 compares the primary assembler with the target assembler corresponding to the sample program to determine its corresponding accuracy evaluation coefficient.

[0050] S315. Based on the average value of the accuracy evaluation coefficients, determine the accuracy reward value corresponding to each set of initial optimization rules. The accuracy reward value is the difference between the accuracy evaluation coefficient and the average value of the accuracy evaluation coefficients. When the accuracy reward value is positive, it corresponds to a positive reward; when the accuracy reward value is negative, it corresponds to a negative reward.

[0051] By setting an accuracy reward value, the accuracy of the output results of the assembler conversion model built based on the optimization rules output by the optimization strategy model is ensured.

[0052] Optionally, obtain the language readability reward value corresponding to each set of initial optimization rules, including: S321 and S322, as detailed below.

[0053] S321 analyzes the code types and comment language types in elementary assembly programs to generate language readability coefficients.

[0054] S322, determine the language readability reward value corresponding to each set of initial optimization rules based on the average language readability coefficient.

[0055] The language readability reward value is the difference between the language readability coefficient and the average language readability coefficient. When the language readability reward value is positive, it corresponds to a positive reward; when the language readability reward value is negative, it corresponds to a negative reward.

[0056] When the code type and comment language type are uniform and the degree of uniformity is high, the readability coefficient of the language is high. This ensures that the generated code and comment language have a consistent style, avoids mixing of multiple languages, and improves readability.

[0057] By setting a language readability reward value, the code and comment language styles in the output of the assembly program conversion model built according to the optimization rules output by the optimization strategy model are kept consistent, avoiding multi-language mixing and improving readability.

[0058] Optionally, obtain the formatted reward value corresponding to each set of initial optimization rules, including: S331 to S333, as detailed below.

[0059] S331, obtain the record of the initial long chain reasoning process corresponding to each set of initial optimization rules.

[0060] S332, obtain the format matching coefficient between the initial long chain inference process record and the compilation framework corresponding to the assembler conversion model.

[0061] S333: Determine the format reward value corresponding to each set of initial optimization rules based on the average value of the format matching coefficients.

[0062] The format reward value is the difference between the format matching coefficient and the average of the format matching coefficients. When the format reward value is positive, it corresponds to a positive reward; when the format reward value is negative, it corresponds to a negative reward.

[0063] By setting format reward values, the reasoning process of the optimization strategy model is made consistent with the reasoning process of the compilation framework, thus ensuring format consistency.

[0064] Optionally, obtain the inference length reward value corresponding to each set of initial optimization rules, including: S341 and S342, as detailed below.

[0065] S341, obtain the record of the initial long chain inference process corresponding to each initial optimization rule set, and then determine its corresponding inference length coefficient.

[0066] S342, determine the inference length reward value corresponding to each set of initial optimization rules based on the average value of the inference length coefficient.

[0067] The reasoning length reward is the difference between the reasoning length coefficient and the average reasoning length coefficient. When the reasoning length reward is positive, it corresponds to a positive reward; when the reasoning length reward is negative, it corresponds to a negative reward.

[0068] By setting a reward value for inference length, the model is encouraged to think deeply during the inference process, gradually improving its ability to handle complex inference tasks, while optimizing the inference length to enhance the overall training effect.

[0069] Optionally, obtain the running speed reward value corresponding to each set of initial optimization rules, including: S351 to S355, as detailed below.

[0070] S351, add the set of primary optimization rules to the pre-trained compilation framework to obtain the primary assembler conversion model.

[0071] S352 inputs the sample program into the elementary assembler conversion model.

[0072] S353, the primary assembler conversion model combines the optimization rules in the primary optimization rule set to perform assembly conversion on the LLVM IR statements in the sample program to obtain their corresponding primary assemblers.

[0073] S354 uses a compiler simulator to verify a basic assembly program in order to determine its corresponding execution speed coefficient.

[0074] S355 determines the running speed reward value corresponding to each set of initial optimization rules based on the average running speed coefficient.

[0075] The running speed bonus value is the difference between the running speed coefficient and the average running speed coefficient. When the running speed bonus value is positive, it corresponds to a positive bonus; when the running speed bonus value is negative, it corresponds to a negative bonus.

[0076] By setting a runtime bonus value, the execution efficiency of the assembly program built according to the optimization rules output by the optimization strategy model is ensured to reach the optimal state, thereby reducing runtime.

[0077] Building upon the foregoing, this invention also provides an optional implementation method for obtaining the reference model, as detailed below.

[0078] The source language model (including models such as Qwen, Llama, and DeepSeek) is fine-tuned using training statements to obtain a fine-tuned model. The training statements are labeled LLVM IR statements, and the labels include long-chain inference process records of the training statements converted into assembly statements and their corresponding set of optimization rules.

[0079] The fine-tuned model is verified according to the verification procedure. If the verification passes, the fine-tuned model is used as the reference model. The verification procedure is a program compiled using LLVM IR statements, and the LLVM IR statements are unlabeled.

[0080] If the fine-tuning model fails the verification, staff will be prompted to manually calibrate the set of optimization rules for the verification category.

[0081] Based on the set of optimized rules for the verification procedure and manual calibration, the fine-tuned model is optimized and trained. After the optimization training is completed, a new verification procedure is specified, and the fine-tuned model is repeatedly verified according to the verification procedure.

[0082] Optionally, the fine-tuning model is validated according to the validation procedure, including: inputting the LLVM IR statements in the validation procedure into the fine-tuning model, and the fine-tuning model outputting the corresponding set of validation class optimization rules; adding the set of validation class optimization rules to a pre-trained compilation framework to obtain a validation class assembler conversion model; inputting the validation procedure into the validation class assembler conversion model; the validation class assembler conversion model, in conjunction with the optimization rules in the set of validation class optimization rules, performing assembly conversion on the LLVM IR statements in the validation procedure to obtain their corresponding validation class assemblers; validating the validation class assemblers using a compiler simulator, and using the validation result of the validation class assemblers as the validation result of the fine-tuning model.

[0083] Please see Figure 4 , Figure 4 An optimization strategy model training device is provided as an embodiment of the present invention. Optionally, the optimization strategy model training device is applied to the electronic device described above.

[0084] The optimization strategy model training device includes: a first processing unit 501 and a second processing unit 502.

[0085] The first processing unit 501 is used to input the sample program into the initial model and the reference model respectively, so as to obtain a set of multiple initial optimization rules output by the initial model and a set of reference optimization rules output by the reference model. The initial optimization rule set and the reference optimization rule set both include the optimization rules corresponding to each LLVM IR statement in the sample program at different stages of the assembler conversion. The computational resource consumption of the initial model in the running state is less than that of the reference model in the running state. The initial model is a network trained to a preliminary convergence state using training statements, and the reference model is a model fine-tuned using training statements and then fine-tuned after verification. The first processing unit 501 is also used to obtain the relative entropy between each set of initial optimization rules and the reference optimization rule set; The second processing unit 502 is used to optimize the initial model based on the relative entropy to obtain an optimized strategy model.

[0086] Optionally, the second processing unit 502 may execute the above-described S50, and the first processing unit 501 may execute other steps in the above-described method embodiments.

[0087] It should be noted that the optimization strategy model training device provided in this embodiment can execute the method flow shown in the above method flow embodiment to achieve the corresponding technical effect. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.

[0088] This invention also provides a storage medium storing computer instructions and programs, which, when read and executed, perform the optimization strategy model training method described above. The storage medium may include memory, flash memory, registers, or a combination thereof.

[0089] The following provides an electronic device, which may be a computer device or a server device, such as... Figure 1 As shown, the above-described optimization strategy model training method can be implemented. Specifically, the electronic device includes: a processor 10, a memory 11, and a bus 12. The processor 10 may be a CPU. The memory 11 is used to store one or more programs, and when one or more programs are executed by the processor 10, the optimization strategy model training method of the above embodiment is executed.

[0090] In summary, the present invention provides an optimization strategy model training method, apparatus, storage medium, and device, comprising: inputting a sample program into an initial model and a reference model respectively to obtain a set of multiple initial-order optimization rules output by the initial model and a set of reference optimization rules output by the reference model; wherein, both the initial-order optimization rule set and the reference optimization rule set include optimization rules corresponding to each LLVM IR statement in the sample program at different stages of assembler conversion; the computational resource consumption of the initial model in its running state is less than that of the reference model in its running state; the initial model is a network trained to a preliminary convergence state using training statements; the reference model is a model fine-tuned using training statements and then fine-tuned after verification; obtaining the relative entropy between each set of initial-order optimization rules and the reference optimization rule set; optimizing the initial model based on the relative entropy to obtain an optimization strategy model. The optimization strategy model obtained by optimizing the initial model based on the output of the reference model improves inference efficiency and accuracy compared to the initial model and reduces computational cost compared to the reference model. By using an optimization strategy model to generate optimization rules corresponding to LLVM IR statements, the generation efficiency and accuracy are guaranteed, eliminating reliance on human experience and saving labor costs.

[0091] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

[0092] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A method for training an optimization strategy model, characterized in that, The method includes: The sample program is input into the initial model and the reference model respectively to obtain a set of multiple initial optimization rules output by the initial model and a set of reference optimization rules output by the reference model. The initial optimization rule set and the reference optimization rule set both include optimization rules corresponding to each LLVM IR statement in the sample program at different stages of assembler conversion. The computational resource consumption of the initial model in the running state is less than that of the reference model in the running state. The initial model is a network trained to a preliminary convergence state using training statements. The reference model is a model fine-tuned using training statements on the source language model and then fine-tuned after verification. Obtain the relative entropy between each of the initial optimization rule sets and the reference optimization rule set; The initial model is optimized based on the relative entropy to obtain an optimized strategy model.

2. The optimization strategy model training method as described in claim 1, characterized in that, The method further includes: Obtain the accuracy reward value, format reward value, inference length reward value, language readability reward value, and running speed reward value corresponding to each of the aforementioned initial optimization rule sets; The accuracy reward value, the format reward value, the inference length reward value, the language readability reward value, and the running speed reward value are weighted and calculated to obtain the comprehensive reward value corresponding to each of the initial optimization rule sets; The step of optimizing the initial model based on the relative entropy to obtain an optimized strategy model includes: optimizing the initial model based on the relative entropy and the comprehensive reward value corresponding to each set of initial optimization rules to obtain an optimized strategy model.

3. The optimization strategy model training method as described in claim 2, characterized in that, Obtain the accuracy reward value corresponding to each of the aforementioned initial optimization rule sets, including: The set of primary optimization rules is added to a pre-trained compilation framework to obtain a primary assembler conversion model; The sample program is input into the primary assembler conversion model; The primary assembler conversion model, combined with the optimization rules in the primary optimization rule set, performs assembly conversion on the LLVM IR statements in the sample program to obtain their corresponding primary assembler. The primary assembler is compared with the target assembler corresponding to the sample program to determine its corresponding accuracy evaluation coefficient. The accuracy reward value corresponding to each set of initial optimization rules is determined based on the average value of the accuracy evaluation coefficients.

4. The optimization strategy model training method as described in claim 3, characterized in that, Obtain the language readability reward value corresponding to each of the aforementioned initial optimization rule sets, including: The code types and annotation speech types in the aforementioned elementary assembler are analyzed to generate a language readability coefficient; Based on the average language readability coefficient, determine the language readability reward value corresponding to each set of initial optimization rules.

5. The optimization strategy model training method as described in claim 2, characterized in that, Obtain the formatted reward value corresponding to each of the aforementioned initial optimization rule sets, including: Obtain the initial long-chain inference process record corresponding to each set of initial optimization rules; Obtain the format matching coefficient between the initial long-chain inference process record and the compilation framework corresponding to the assembler conversion model; The format reward value corresponding to each set of initial optimization rules is determined based on the average value of the format matching coefficients.

6. The optimization strategy model training method as described in claim 2, characterized in that, Obtain the inference length reward value corresponding to each of the aforementioned initial optimization rule sets, including: Obtain the initial long chain inference process record corresponding to each set of initial optimization rules, and then determine its corresponding inference length coefficient; Based on the average value of the inference length coefficients, determine the inference length reward value corresponding to each set of the initial optimization rules.

7. The optimization strategy model training method as described in claim 2, characterized in that, Obtain the running speed bonus value corresponding to each of the aforementioned initial optimization rule sets, including: The set of primary optimization rules is added to a pre-trained compilation framework to obtain a primary assembler conversion model; The sample program is input into the primary assembler conversion model; The primary assembler conversion model, combined with the optimization rules in the primary optimization rule set, performs assembly conversion on the LLVM IR statements in the sample program to obtain their corresponding primary assembler. The elementary assembly program was verified using a compiler simulator to determine its corresponding execution speed coefficient. Based on the average value of the running speed coefficient, determine the running speed reward value corresponding to each set of the initial optimization rules.

8. An optimization strategy model training device, characterized in that, The device includes: The first processing unit is used to input the sample program into the initial model and the reference model respectively, so as to obtain a set of multiple initial optimization rules output by the initial model and a set of reference optimization rules output by the reference model. The initial optimization rule set and the reference optimization rule set both include optimization rules corresponding to each LLVM IR statement in the sample program at different stages of assembler conversion. The computational resource consumption of the initial model in the running state is less than that of the reference model in the running state. The initial model is a network trained to a preliminary convergence state using training statements. The reference model is a model fine-tuned using training statements on the source language model and then fine-tuned after verification. The first processing unit is further configured to obtain the relative entropy between each of the initial optimization rule sets and the reference optimization rule set; The second processing unit is used to optimize the initial model based on the relative entropy to obtain an optimized strategy model.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method as described in any one of claims 1-7.

10. An electronic device, characterized in that, include: Processor and memory, the memory being used to store one or more programs; When the one or more programs are executed by the processor, the method as described in any one of claims 1-7 is implemented.

Citation Information

Patent Citations

  • Multi-language safety protection framework based on reasoning, medium and equipment

    CN120745837A

  • Multi-round automatic machine learning agent system based on reinforcement learning optimization

    CN120806041A

  • KR20250132312A