Natural language programming methods, devices, electronic devices, and storage media

By guiding the state-of-the-art (SOTA) model to convert natural language into target code and verifying the function form in a code sandbox, and generating a corrected function form, the problem of insufficient identification of logical errors when large models generate code is solved, and efficient and reliable natural language programming is achieved.

CN122086375APending Publication Date: 2026-05-26CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
Filing Date
2026-04-27
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In existing technologies, logical errors cannot be identified when generating code for large models. The lack of a closed-loop interaction mechanism for generation, verification, and correction means that code verification can only guarantee the accuracy of calculations but cannot correct logical errors.

Method used

By setting a first and second prompt word, the SOTA model is guided to convert sample natural language into target code, and then the target code into function form. The execution result of the function form is verified using a code sandbox. Combined with error information and the SOTA model to generate a corrected function form, a closed-loop interactive mechanism of generation-verification-correction is constructed.

Benefits of technology

It improves the accuracy of natural language to code conversion and the correctness of code execution, ensures the reliability of programming results, builds a compact inference mechanism, and reduces the consumption of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086375A_ABST
    Figure CN122086375A_ABST
Patent Text Reader

Abstract

This disclosure relates to the field of artificial intelligence technology, and more particularly to a natural language programming method, apparatus, electronic device, and storage medium. The method includes: inputting sample natural language and a first prompt word into a state-of-the-art (SOTA) model to obtain target code corresponding to the sample natural language; the first prompt word is used to guide the SOTA model to learn the concept of converting natural language into a programming language; inputting the target code and a second prompt word into the SOTA model to obtain the function form corresponding to the target code; the second prompt word is used to guide the SOTA model to convert the target code into a function form conforming to a preset specification; based on the function form and a code sandbox, determining whether the execution result corresponding to the function form is correct; if there is an error result in the execution result, based on the error message corresponding to the error result, the function form, the second prompt word, and the SOTA model. This disclosure effectively solves the problem of poor performance in existing natural language to code conversion methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence technology, and in particular to a natural language programming method, apparatus, electronic device, and storage medium. Background Technology

[0002] Currently, the mainstream approach for verifying the generated code of large models is to use code editors such as VS Code and PyCharm for offline verification. After the code is generated through large model inference, the complete code text is obtained by calling the large model API, and then the code is executed and the results are verified by relying on the code editor.

[0003] However, the aforementioned code verification methods have significant limitations: code editors can only verify the syntactic validity and execution feasibility of the code, ensuring that the code is syntactically correct and the computation process is executable, but they cannot identify logical errors at the inference chain level when large models generate code. Even if the code can be executed normally by the code editor, if its underlying program logic does not match the problem requirements, the large model will still output incorrect results. In short, existing code verification methods can only ensure that the code is "calculated accurately," but cannot verify "logical correctness," and have not established a closed-loop interaction mechanism for large model code generation-verification-correction, making it impossible to achieve automatic feedback and iterative optimization for logical errors. Summary of the Invention

[0004] In view of the above-mentioned technical problems, this disclosure provides a natural language programming method, apparatus, electronic device and storage medium.

[0005] Firstly, this disclosure provides a natural language programming method, including: Input the sample natural language and the first prompt word into the SOTA model to obtain the target code corresponding to the sample natural language. The first prompt word is used to guide the SOTA model to learn the idea of ​​converting natural language into programming language. Input the target code and the second prompt word into the SOTA model to obtain the function form corresponding to the target code. The second prompt word is used to guide the SOTA model to convert the target code into a function form that conforms to the preset specification. Based on function form and code sandbox, determine whether the execution result corresponding to the function form is correct; If there are erroneous results in the execution results, a corrected function form is generated based on the error message, function form, second prompt word, and SOTA model corresponding to the erroneous results. The revised function form is then put into the code sandbox for verification. Once the verification is successful, it is used as the programming result.

[0006] Furthermore, according to the method of the first aspect of this disclosure, the first prompt word includes a problem description, example guidance, and requirement description.

[0007] Furthermore, according to the method of the first aspect of this disclosure, the function form includes: an executable main function, an input / output description, an input generation function, and a problem statement; Based on function form and code sandboxing, determine whether the execution result corresponding to the function form is correct, including: Execute the input generation function in a code sandbox to obtain multiple test inputs; Multiple test inputs are fed into the executable main function, and the executable main function is executed in the code sandbox to obtain multiple input-output pairs, which include each test input and its corresponding test result. Based on multiple input-output pairs, determine whether the execution result corresponding to the function form is correct.

[0008] Furthermore, according to the method of the first aspect of this disclosure, based on the error message corresponding to the erroneous result, the function form, the second prompt word, and the SOTA model, a corrected function form is generated, including: Based on the error message and function form corresponding to the error result, a fourth prompt word is generated; Based on the fourth cue word, the second cue word, and the SOTA model, the corrected function form is generated.

[0009] Furthermore, according to the method of the first aspect of this disclosure, the method also includes: Multiple target input / output pairs are obtained based on multiple input / output pairs, the corrected function form, and the code sandbox.

[0010] Furthermore, according to the method of the first aspect of this disclosure, the method also includes: Based on multiple target input-output pairs, the corrected function form, and the preset inference step size, a fourth prompt word is constructed for each target input-output pair; Based on multiple target input-output pairs and the fourth cue word corresponding to each target input-output pair, the SOTA model is invoked for forward and backward reasoning. The code sandbox was used to verify the first reasoning result corresponding to forward reasoning and the second reasoning result corresponding to backward reasoning; Based on the validation results, multiple target input-output pairs, the corrected function form, the first inference result, and the second inference result, a target training dataset is constructed, which is used to train the large inference model.

[0011] Furthermore, according to the method of the first aspect of this disclosure, a target training dataset is constructed based on the verification results, multiple target input-output pairs, a first inference result, and a second inference result. This target training dataset is used to train a large inference model, including: If the verification results are correct, a first training dataset is constructed based on multiple target input-output pairs, the corrected function form, the first inference result, and the second inference result. If the verification result is incorrect, based on multiple target input-output pairs and the fourth prompt word, the SOTA model is called again to perform the second forward reasoning and the second backward reasoning. The reasoning step size of each step of the SOTA model is not limited by the preset reasoning step size. The reasoning results of the second forward reasoning and the second backward reasoning are verified using a code sandbox; If the secondary verification result is correct, a second training dataset is constructed based on multiple target input-output pairs, the corrected function form, the reasoning result of the second forward reasoning, and the reasoning result of the second backward reasoning. Based on the first and second training datasets, construct the target training dataset.

[0012] Secondly, this disclosure provides a natural language programming apparatus, comprising: The Natural Language to Code Unit is used to input sample natural language and first prompt word into the SOTA model to obtain the target code corresponding to the sample natural language. The first prompt word is used to guide the SOTA model to learn the idea of ​​converting natural language into programming language. The code normalization unit is used to input the target code and the second prompt word into the SOTA model to obtain the function form corresponding to the target code. The second prompt word is used to guide the SOTA model to transform the target code into a function form that conforms to the preset standard. The code execution verification unit is used to determine whether the execution result corresponding to the function form is correct based on the function form and the code sandbox. The code error correction unit is used to generate a corrected function form based on the error message, function form, second prompt word, and SOTA model if there is an error in the execution result. The result verification unit is used to connect the modified function form to the code sandbox for verification, and after successful verification, it is used as the programming result.

[0013] Thirdly, this disclosure provides an electronic device, including: a memory for storing computer-readable instructions; and a processor for executing the computer-readable instructions, causing the electronic device to perform the method as described in any embodiment of the first aspect.

[0014] Fourthly, this disclosure provides a non-transitory computer-readable storage medium for storing computer-readable instructions that, when executed by a processor, cause the processor to perform the method as described in any embodiment of the first aspect.

[0015] Fifthly, this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the method as described in any embodiment of the first aspect.

[0016] This disclosure provides a natural language programming method, apparatus, electronic device, and storage medium. By setting a first prompt word and a second prompt word to guide a state-of-the-art (SOTA) model, the method first converts sample natural language into target code, then converts the target code into function form, and then verifies the execution result of the function form using a code sandbox. Combining the error messages corresponding to incorrect results with the second prompt word and the SOTA model, a corrected function form is generated and verified again. The verified function form is used as the encoding result. This effectively solves the problems of poor performance in existing natural language to code conversion and the fact that code verification can only guarantee computational accuracy but cannot correct logical errors. It constructs a closed-loop interactive mechanism of "generation-verification-correction," improving the accuracy of natural language to code conversion and the correctness of code execution, while also standardizing code format and ensuring the reliability of programming results.

[0017] It should be understood that both the foregoing general description and the following detailed description are exemplary and intended to provide further illustration of the claimed technology. Attached Figure Description

[0018] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of the embodiments thereof in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.

[0019] Figure 1 A flowchart illustrating a natural language programming method provided in this embodiment of the disclosure; Figure 2 A flowchart illustrating yet another natural language programming method provided in this disclosure embodiment; Figure 3 A flowchart illustrating yet another natural language programming method provided in this disclosure embodiment; Figure 4 A structural block diagram of a natural language programming device provided in this disclosure embodiment; Figure 5 A flowchart illustrating yet another natural language programming method provided in this disclosure embodiment; Figure 6 A hardware block diagram of an electronic device provided in an embodiment of this disclosure; Figure 7This is a schematic diagram of a computer-readable storage medium provided in an embodiment of this disclosure. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this disclosure more apparent, exemplary embodiments according to this disclosure will now be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this disclosure, and not all embodiments of this disclosure. It should be understood that this disclosure is not limited to the exemplary embodiments described herein.

[0021] Currently, mainstream large-scale model inference frameworks (such as DeepSpeed ​​and FasterTransformer) generally adopt streaming output technology. This technology outputs the generated text sequence in blocks, returning each generated token to the user immediately, thus achieving real-time feedback. For example, in dialogue scenarios, each word or phrase generated by the model is immediately displayed on the screen without waiting for the entire sentence to be generated. The SoT method achieves latency optimization through a two-stage pipeline. The first stage is the skeleton generation stage, which typically uses hierarchical text formats (such as Markdown heading levels and pseudocode module division), and the generation strategy employs low-temperature decoding (Temperature < 1.0) to ensure structural stability. The second stage is the parallel decoding stage, which first decomposes the skeleton into independent semantic units, then starts parallel decoding threads for each unit, and finally merges the parallel-generated code fragments using a dynamic programming algorithm. The above large-scale models fully preserve the natural language inference steps, intermediate result descriptions, and multi-branch enumerations during the inference process.

[0022] While the above strategies ensure the interpretability of the inference process, they significantly increase the length of the inference chain, requiring substantial computational resources during inference. For example, generating 1000 tokens in the Llama-3 70B model consumes 12.6 kWh of energy (A100 cluster). Furthermore, in latency-sensitive scenarios such as medical diagnosis, response times exceeding clinically acceptable thresholds occur when the inference chain length exceeds 1500 tokens. In addition, existing models lack compact training data, hindering compact inference and further exacerbating computational resource consumption.

[0023] Furthermore, there is currently no good method for converting natural language into code, making it difficult to meet the accuracy requirements of code generation in practical applications. Moreover, in current large-scale model inference, the code generated by large models is mostly verified using code editors. Currently, most mainstream code editors (such as VS Code and PyCharm) use offline verification, obtaining the complete code text through the large model API during the generation stage and executing it to obtain the final result. If the program logic generated by the LLM (Large Language Model) contains errors, even if the Python interpreter executes the code correctly, the final result will still be incorrect. In other words, current methods can only guarantee the accuracy of computation but cannot correct logical errors in the inference chain. There is a lack of a closed-loop interaction mechanism for generation-verification-correction.

[0024] To address the aforementioned technical issues, this disclosure provides a natural language programming method and apparatus.

[0025] Figure 1 This is a flowchart illustrating a natural language programming method provided in an embodiment of the present disclosure.

[0026] like Figure 1 As shown, the natural language programming method specifically includes the following steps: Step 101: Input the sample natural language and the first prompt word into the SOTA model to obtain the target code corresponding to the sample natural language. The first prompt word is used to guide the SOTA model to learn the idea of ​​converting natural language into programming language.

[0027] In one embodiment of this disclosure, the target code refers to programming language code that perfectly matches the semantics of the sample natural language. By pre-setting a first prompt word, the sample natural language and the first prompt word are input into the SOTA model, enabling the SOTA model to process the natural language and convert it into target code based on the guidance of the first prompt word. The target code can be executable / parsable code in any programming language, including but not limited to Python, Java, C++, and JavaScript, capable of accurately implementing the function or logic described by the sample natural language. The SOTA model, or State-of-the-Art model, refers to a pre-trained large language model whose current performance metrics (such as conversion accuracy, code executability, and semantic matching degree) have reached industry-leading levels in the technical field of natural language to code conversion tasks. For example, SOTA models include, but are not limited to, advanced artificial intelligence models with natural language understanding and code generation capabilities, such as the GPT series models, CodeLlama models, StarCoder models, and Deepseek-R1.

[0028] In one embodiment of this disclosure, the first prompt includes a problem description, example guidance, and requirements. The problem description refers to the natural language content to be converted into target code. The example guidance is used to demonstrate the correspondence between natural language and code, helping the model learn how to perform the conversion. Exemplarily, the example guidance includes natural language comments and their corresponding code steps, and the variable names in the code steps must be meaningful. The requirements are used to inform the model what needs to be output. For example, the output content includes natural language comments and their corresponding executable code. The output content may also include natural language content converted into code. In one embodiment of this disclosure, the problem description is as follows: Q: Tina earns $18.00 per hour. If she works more than 8 hours per shift, she is eligible for overtime pay, which is calculated as your hourly wage plus half. If she works 10 hours a day for 5 consecutive days, how much does she earn? Example guidance is as follows: Q: John had 3 apples, and Mary gave him 2 apples. How many apples does John have now? A: # The number of apples John initially had apples_john_initial = 3 # The number of apples Mary gave John apples_received = 2 # Calculate the total number of apples John currently owns answer = apples_john_initial + apples_received Q: A shirt originally cost $50, but is now 20% off. What is the current price of the shirt? A: # Original price of the shirt shirt_original_price = 50 # Discount Rate discount_rate = 0.2 # Calculate the discount amount discount_amount = shirt_original_price × discount_rate # Calculate the current price of the shirt answer = shirt_original_price - discount_amount The requirements are as follows: Please output a solution containing natural language annotations and executable code, following the format shown in the example above. The final result should be stored in the variable `answer`.

[0029] The target code is as follows: # Tina's normal hourly wage hourly_wage = 18 # Normal working hours (hours) regular_hours_per_day = 8 # Total working hours per day (hours) total_hours_per_day = 10 # Number of working days working_days = 5 # Calculate the money earned from a normal working day regular_earnings_per_day = regular_hours_per_day × hourly_wage # Calculate daily overtime hours overtime_hours_per_day = total_hours_per_day - regular_hours_per_day # Calculate hourly overtime pay overtime_wage = hourly_wage + hourly_wage × 0.5 # Calculate the money earned from daily overtime hours overtime_earnings_per_day = overtime_hours_per_day × overtime_wage # Calculate total daily earnings total_earnings_per_day = regular_earnings_per_day + overtime_earnings_per_day # Calculate the total money earned in 5 days answer = total_earnings_per_day × working_days Step 102: Input the target code and the second prompt word into the SOTA model to obtain the function form corresponding to the target code. The second prompt word is used to guide the SOTA model to convert the target code into a function form that conforms to the preset specifications.

[0030] In one embodiment of this disclosure, the function form refers to the standardized code style corresponding to the target code that enables function calls. Preset specifications include, but are not limited to, function naming rules, parameter definition rules, return value format rules, and code indentation rules. By setting a second prompt word, the target code and the second prompt word are input into the SOTA model, causing the SOTA model to convert the target code into a uniformly formatted function form that conforms to the preset specifications, guided by the second prompt word.

[0031] In a specific embodiment of this disclosure, the second prompt word is as follows: Task Overview: Given a code file (as described in the target code above), you need to construct a main function using Python and generate a question based on this function. The question should include the following components: Main function: Refer to the provided code file to build your solution function to solve the problem; the function should contain the main logic of the code file.

[0032] If you have imported some custom modules, leave them as is and do not write placeholders for them.

[0033] The function should be named main_solution; you can achieve this by renaming some functions in the code file or by calling multiple functions in a new main function.

[0034] The input and output variables of the main_solution function must be JSON serializable.

[0035] If the reference code file does not require input variables, adjust the code to ensure that input variables are always present, for example, by rewriting code for specific cases to general cases.

[0036] If some input variables in the original code file are not JSON serializable (such as sets, tuples, NumPy arrays, functions, custom objects, etc.), you need to convert the JSON serializable inputs of the main_solution function to raw input variables at the beginning of the function.

[0037] If some output variables in the original code file are not JSON serializable (such as sets, tuples, NumPy arrays, functions, custom objects, etc.), you must convert them to JSON serializable output before the main_solution function returns.

[0038] The size of both input and output variables should be reasonable, for example, less than 1KB.

[0039] Try to avoid overly complex input and output variables, such as too many nested structures, extremely large numbers, or floating-point numbers with too many decimal places.

[0040] The main_solution function should return the final output, not the printed output.

[0041] Please delete all plotting code, keeping only the core solution code, as we do not need to return to plotting. Also delete all print statements and file write operations, and remove code comments as well.

[0042] Always define the main_solution function at the end of this section. Before doing so, you must refer to the code file and prepare all the necessary code to ensure that the main_solution function can run correctly.

[0043] Input / output description: You need to provide a clear description of the input and output variables in the main_solution function.

[0044] In your description, you should include a brief description of the type of each variable and its meaning.

[0045] For example, if the variable is a dictionary, you should specify the key names and the object type and meaning of the value corresponding to each key. In short, ensure that the input and output requirements are very clear and unambiguous.

[0046] For example, if the variable is a string, you need to specify the format the string should be presented (e.g., what the separator is for connecting multiple items in the string), and you are not allowed to use unrestricted string input and output.

[0047] Input generator: You need to provide a function called input_generator, which generates input parameters for the main_solution function.

[0048] The input_generator function should not require any input parameters, and each time it is called, it should return a set of input parameters that satisfy the requirements of the main_solution function.

[0049] The output of input_generator should always be a dictionary, because we always use it in the main_solution function. Make the call.

[0050] Add some randomness to the input_generator function to ensure that the input parameters are different each time it is called.

[0051] Please try to make the generated input parameters reasonable, and avoid generating input variables that are too complex or too simple. The size of the variables should also be reasonable, for example, less than 1KB.

[0052] Problem Statement Guidelines: Based on the main_solution function, you need to create a problem related to the provided code.

[0053] Please avoid writing things like "implement a function", "write a function" or "implement a system" in your question. Instead, describe the background and requirements to present a non-programming problem, and your question must contain an interrogative word that begins with wh (such as what, who, when, where, why, how, etc.).

[0054] You should clearly indicate the input variable names (but not the exact or specific values) in your problem statement and clearly ask for the return value to be consistent with the main_solution function.

[0055] In this section, you do not need to include the requirements or any examples for the input and output variables again. The target code to be processed is as follows: [Code Start] # Tina's normal hourly wage hourly_wage = 18 # Normal working hours (hours) regular_hours_per_day = 8 # Total working hours per day (hours) total_hours_per_day = 10 # Number of working days working_days = 5 # Calculate the money earned from a normal working day regular_earnings_per_day = regular_hours_per_day × hourly_wage # Calculate daily overtime hours overtime_hours_per_day = total_hours_per_day - regular_hours_per_day # Calculate hourly overtime pay overtime_wage = hourly_wage + hourly_wage × 0.5 # Calculate the money earned from daily overtime hours overtime_earnings_per_day = overtime_hours_per_day × overtime_wage # Calculate total daily earnings total_earnings_per_day = regular_earnings_per_day + overtime_earnings_per_day # Calculate the total money earned in 5 days answer = total_earnings_per_day × working_days [Code End] In one embodiment of this disclosure, the function form includes: an executable main function, input / output descriptions, an input generation function, and a problem statement. The executable main function refers to a main function that can be called independently, contains core business logic, and conforms to preset specifications. The input / output descriptions provide a structured and unambiguous description of the input and output variables of the main function, clearly defining the type, meaning, and format constraints of each variable. The input generation function, named `input_generator`, is an auxiliary function used to generate random test inputs that meet the requirements for the main function and is the core of automatic testing of the main function.

[0056] For example, based on the above example, the function form is as follows: Executable main function def main_solution(hourly_wage, regular_hours_per_day, total_hours_per_day, working_days): regular_earnings_per_day = regular_hours_per_day × hourly_wage overtime_hours_per_day = total_hours_per_day - regular_hours_per_day overtime_wage = hourly_wage + hourly_wage × 0.5 overtime_earnings_per_day = overtime_hours_per_day × overtime_wage total_earnings_per_day = regular_earnings_per_day + overtime_earnings_per_day total_earnings = total_earnings_per_day × working_days return total_earnings Input / output description: enter: hourly_wage (float): The normal hourly wage.

[0057] regular_hours_per_day (int): The normal working hours per day (in hours).

[0058] total_hours_per_day (int): Total working hours per day (in hours).

[0059] working_days (int): The number of working days.

[0060] Output: return (float): Total wages, including regular work and overtime, for the specified number of working days.

[0061] Input generating function: import random def input_generator(): hourly_wage = random.uniform(10, 30) regular_hours_per_day = random.randint(6, 8) total_hours_per_day = random.randint(regular_hours_per_day, 12) working_days = random.randint(1, 7) return { "hourly_wage": hourly_wage, "regular_hours_per_day": regular_hours_per_day, "total_hours_per_day": total_hours_per_day, "working_days": working_days } Problem Statement: Tina's normal hourly wage is [hourly_wage], and her normal daily wage is [regular_hours_per_day] hours. However, she actually works [total_hours_per_day] hours per day, and her overtime pay is 1.5 times the normal wage. She worked [working_days] days. So, how much money did she earn in those few days? Step 103: Based on the function form and code sandbox, determine whether the execution result corresponding to the function form is correct.

[0062] In one embodiment of this disclosure, determining whether the execution result corresponding to the function form is correct based on the function form and the code sandbox includes: Execute the input generation function in a code sandbox to obtain multiple test inputs; Multiple test inputs are fed into the executable main function, and the executable main function is executed in the code sandbox to obtain multiple input-output pairs, which include each test input and its corresponding test result. Based on multiple input-output pairs, determine whether the execution result corresponding to the function form is correct.

[0063] Specifically, the input generation function in the function form is run multiple times in a code sandbox. Each run generates a set of random test inputs, resulting in multiple different sets of test inputs. These multiple sets of test inputs are then passed one by one to the executable main function, which is then run in the code sandbox. Each run yields a set of test inputs and their corresponding test results. Each test input and its corresponding test result constitute an input-output pair, resulting in multiple input-output pairs. By verifying whether the test results in these multiple input-output pairs conform to the preset business logic (no execution exceptions and accurate results), the correctness of the execution result corresponding to the function form is determined.

[0064] Step 104: If there are erroneous results in the execution results, generate the corrected function form based on the error message, function form, second prompt word, and SOTA model corresponding to the erroneous results.

[0065] In one embodiment of this disclosure, when the code sandbox verifies an error in the execution result of a function form based on multiple input-output pairs, it passes "error message, original function form, and second prompt word" as new input to the SOTA model. The SOTA model then automatically generates a corrected, executable function form based on the error cause and preset specifications. The error message can refer to the complete exception context information automatically captured and recorded by the code sandbox when an exception is triggered during code execution, including the error type, error location, error description, the code fragment that triggered the error, and input parameters.

[0066] For example, based on the error message corresponding to the erroneous result, the function form, the second prompt word, and the SOTA model, a corrected function form is generated, including: Based on the error message and function form corresponding to the error result, a third prompt word is generated; Based on the third prompt word, the second prompt word, and the SOTA model, the corrected function form is generated.

[0067] Specifically, the third prompt word is used for error correction, transforming error messages and function forms into instruction-based error correction prompts. When the second and third prompt words are input into the SOTA model, the SOTA model, while adhering to the specifications of the second prompt word, corrects the original function form according to the third prompt word, generating a function form that conforms to the preset specifications and can be executed correctly.

[0068] Step 105: Connect the corrected function form to the code sandbox for verification. Once the verification is successful, use it as the programming result.

[0069] In one embodiment of this disclosure, after obtaining the modified function form, the modified function form is run in the code sandbox, that is, the verification logic of step 103 is repeated to verify whether there are no execution exceptions and whether the result conforms to the preset business logic; if the verification passes, the modified function form is output as the final programming result.

[0070] In summary, according to the technical solution provided in the embodiments of this disclosure, this disclosure guides the SOTA model by setting a first prompt word and a second prompt word. First, the sample natural language is converted into target code, then the target code is converted into a function form. Next, the execution result of the function form is verified using a code sandbox. Combining the error messages corresponding to incorrect results with the second prompt word and the SOTA model, a corrected function form is generated and verified again. The verified function form is used as the encoding result. This effectively solves the problems of poor performance in existing natural language to code conversion and the fact that code verification can only guarantee computational accuracy but cannot correct logical errors. It constructs a closed-loop interactive mechanism of "generation-verification-correction," improving the accuracy of natural language to code conversion and the correctness of code execution. At the same time, it standardizes the code format and ensures the reliability of the programming results.

[0071] Furthermore, natural language programming methods also include: If the execution result is correct, the function form will be used as the programming result.

[0072] Specifically, when the code sandbox verifies and finds that the execution results of the function form are consistent with the expected output based on multiple input-output pairs, that is, the execution results are all correct, the function form is directly used as the programming result.

[0073] In summary, according to the technical solution provided in the embodiments of this disclosure, this disclosure comprehensively verifies the generated function form through multiple sets of inputs and outputs, and directly determines the final programming result when all execution results are consistent with expectations, thereby improving the accuracy and reliability of natural language programming output and ensuring that the generated function code can be run directly and correctly.

[0074] Furthermore, natural language programming methods also include: Multiple target input / output pairs are obtained based on multiple input / output pairs, the corrected function form, and the code sandbox.

[0075] Specifically, the modified function form is run in the code sandbox, that is, the verification logic of step 103 is repeated to verify whether there are no execution exceptions and whether the result conforms to the preset business logic; if the verification is successful, the multiple new input-output pairs obtained in this verification are combined with the correct input-output pairs in step 103 to form the final multiple target input-output pairs.

[0076] In summary, according to the technical solution provided by the embodiments of this disclosure, this disclosure obtains all correct new input-output pairs by re-executing and verifying the modified function form in the code sandbox, and combines them with the correct input-output pairs in step 103 to form a set of target input-output pairs that are all executed correctly, without exceptions, and whose results conform to business logic, thus providing high-quality and highly reliable sample data for subsequent model training and data accumulation.

[0077] Furthermore, natural language programming methods also include: Based on the revised function form and code sandbox, multiple target input-output pairs are obtained.

[0078] Specifically, the modified function form is run in the code sandbox, that is, the verification logic of step 103 is repeated to verify whether there are no execution exceptions and whether the result conforms to the preset business logic; if the verification is successful, the multiple new input-output pairs obtained in this verification are used as the final multiple target input-output pairs.

[0079] In summary, according to the technical solution provided by the embodiments of this disclosure, this disclosure re-verifies the modified function form in the code sandbox. After successful verification, all correct new input-output pairs obtained are used as target input-output pairs, providing high-quality and highly reliable sample data for subsequent model training and data accumulation.

[0080] Figure 2 This is a flowchart illustrating a natural language programming method provided in an embodiment of the present disclosure.

[0081] like Figure 2 As shown, the natural language programming method also includes the following steps: Step 201: Based on multiple target input-output pairs, the corrected function form, and the preset inference step size, construct the fourth prompt word corresponding to each target input-output pair.

[0082] In one embodiment of this disclosure, a preset inference step size is used to limit the length of each inference step. A fourth cue word is designed, which includes at least: the preset inference step size, the core task instruction, the problem statement to be inferred, the definition of input and output parameters, the known input / output values, the code inference process reference instructions, and the output format constraints, to limit the inference rules, logical basis, and result format of the subsequent state-of-the-art (SOTA) model. The preset inference step size can be set to 8-15 words depending on the actual application, preferably allowing 10 words to be generated for each inference step. The problem statement to be inferred, the definition of input and output parameters, the known input / output values, and the code inference process reference instructions can be determined based on the target input / output pair and the modified function form.

[0083] For example, the fourth prompt word is: Please limit each step of the reasoning to generating only 10 words, and complete the reasoning based on the problem statement and the executable main function: Here is a problem that requires some input and output variables, as shown below: Tina's normal hourly wage is [hourly_wage], and her normal daily wage is [regular_hours_per_day] hours. However, she actually works [total_hours_per_day] hours per day, and her overtime pay is 1.5 times the normal wage. She worked [working_days] days. So, how much money did she earn in those few days? The input and output parameters are as follows: enter: hourly_wage (float): The normal hourly wage.

[0084] regular_hours_per_day (int): The normal working hours per day (in hours).

[0085] total_hours_per_day (int): Total working hours per day (in hours).

[0086] working_days (int): The number of working days.

[0087] Output: return (float): Total wages, including regular work and overtime, for the specified number of working days.

[0088] Given input {'hourly_wage': 15.5,'regular_hours_per_day': 8,'total_hours_per_day': 10,'working_days': 3}.

[0089] Can you predict the output without writing any code? Please reason and represent your final answer in the following JSON format: {'output':<your output>},in<your output> The output should strictly adhere to the specified requirements. Please think through the process step by step, but keep only a minimum draft of 10 words for each step.

[0090] Note: This is a sample code snippet for this problem. You can refer to this code to guide your reasoning, but do not directly copy large sections of code.

[0091] def main_solution(hourly_wage, regular_hours_per_day, total_hours_per_day, working_days): regular_earnings_per_day = regular_hours_per_day × hourly_wage overtime_hours_per_day = total_hours_per_day - regular_hours_per_day overtime_wage = hourly_wage + hourly_wage × 0.5 overtime_earnings_per_day = overtime_hours_per_day × overtime_wage total_earnings_per_day = regular_earnings_per_day + overtime_earnings_per_day total_earnings = total_earnings_per_day × working_days return total_earnings Step 202: Based on multiple target input-output pairs and the fourth prompt word corresponding to each target input-output pair, call the SOTA model to perform forward and backward reasoning.

[0092] In one embodiment of this disclosure, each target input-output pair is input into the SOTA model. According to the reasoning constraints, problem description, input-output definitions and code reasoning process reference in the fourth prompt word, the SOTA model is driven to perform forward reasoning and backward reasoning respectively. Forward reasoning is to derive the corresponding output result based on the known input parameters, and backward reasoning is to deduce reasonable input parameters based on the known output result, thereby obtaining the model reasoning content that meets the requirements of compact reasoning.

[0093] For example, combining step 201 above, the model obtains the following through forward reasoning: The reasoning steps are as follows: Normal daily wage: 8 × 15.5 = 124.

[0094] Daily overtime hours: 10 - 8 = 2.

[0095] Overtime pay: 15.5 × 1.5 = 23.25.

[0096] Overtime pay per day: 2 × 23.25 = 46.5.

[0097] Total daily wage: 124 + 46.5 = 170.5.

[0098] Total wages for 3 days: 170.5 × 3 = 511.5.

[0099] {'output': 511.5} Step 203: Use the code sandbox to verify the first reasoning result corresponding to forward reasoning and the second reasoning result corresponding to backward reasoning.

[0100] In one embodiment of this disclosure, the results obtained from the forward inference of the SOTA model (i.e., the first inference result) and the results obtained from the backward inference (i.e., the second inference result) are combined with the modified function form and run in a code sandbox to verify whether these inference results are correct and whether they meet expectations.

[0101] Step 204: Based on the verification results, multiple target input-output pairs, the corrected function form, the first inference result, and the second inference result, construct the target training dataset. The target training dataset is used to train the large inference model.

[0102] In one embodiment of this disclosure, if the verification results are all correct, the first inference result / second inference result is integrated with the corresponding target input-output pair and the corrected function form to construct target training data for training a large inference model with compact inference capabilities.

[0103] In summary, according to the technical solution provided in the embodiments of this disclosure, this disclosure constructs a constrained fourth prompt word based on the target input-output pair, the modified function form, and the preset inference step length. This drives the SOTA model to perform forward and backward compact inference, and uses a code sandbox to automatically verify the inference results. Finally, based on the verified multi-dimensional data, an instruction-based training dataset is constructed. Under the premise of strictly limiting the length of the inference steps, the standardization, logical correctness, and accuracy of the model's inference process are guaranteed. At the same time, high-quality inference data that can be directly used for training is formed, which significantly improves the computational efficiency, inference accuracy, and compact thought chain generation capability of the large inference model, and realizes efficient, reliable, and scalable model training and inference optimization in natural language programming scenarios.

[0104] Figure 3 This is a flowchart illustrating a natural language programming method provided in an embodiment of the present disclosure.

[0105] like Figure 3As shown, based on the validation results, multiple target input-output pairs, the first inference result, and the second inference result, a target training dataset is constructed. This target training dataset is used to train the large inference model and includes: Step 301: If the verification result is correct, construct the first training dataset based on multiple target input-output pairs, the corrected function form, the first inference result, and the second inference result.

[0106] In one embodiment of this disclosure, if the verification results are all correct, the first inference result / second inference result is integrated with the corresponding target input-output pair and the corrected function form to construct a first training dataset for training a large inference model with compact inference capabilities.

[0107] Step 302: If the verification result is incorrect, based on multiple target input-output pairs and the fourth prompt word, the SOTA model is called again to perform the second forward inference and the second backward inference. The inference step size of each step of the SOTA model is not limited by the preset inference step size.

[0108] In one embodiment of this disclosure, if the verification result is incorrect, each target input-output pair is input into the SOTA model. According to the problem description, input-output definition and code reasoning process reference in the fourth prompt, each reasoning step of the SOTA model is not limited by the preset reasoning step, driving the SOTA model to perform the second forward reasoning and the second backward reasoning respectively. The first forward reasoning is to derive the corresponding output result based on the known input parameters, and the second backward reasoning is to deduce the reasonable input parameters based on the known output result, thereby obtaining the model reasoning content.

[0109] Step 303: Use the code sandbox to verify the reasoning results of the second forward reasoning and the second backward reasoning.

[0110] In one embodiment of this disclosure, the reasoning results of the second forward reasoning and the second backward reasoning are input into the code sandbox for execution, in conjunction with the modified function form, to verify whether the reasoning results of the second forward reasoning and the second backward reasoning are correct.

[0111] Step 304: If the secondary verification result is correct, construct a second training dataset based on multiple target input-output pairs, the corrected function form, the reasoning result of the second forward reasoning, and the reasoning result of the second backward reasoning.

[0112] In one embodiment of this disclosure, if the reasoning results of the second forward reasoning and the second backward reasoning are both correct (i.e., the secondary verification results are correct), the reasoning results of the second forward reasoning and the second backward reasoning are integrated with the corresponding target input-output pairs and the corrected function forms, respectively, to construct a second training dataset for training a large reasoning model with compact reasoning capabilities.

[0113] Step 305: Construct the target training dataset based on the first training dataset and the second training dataset.

[0114] In one embodiment of this disclosure, a first training dataset and a second training dataset are integrated to form a target training dataset for training a large inference model.

[0115] In summary, based on the technical solutions provided in the embodiments of this disclosure, this disclosure carefully constructs a compact large-scale model reasoning training dataset by limiting the length of the thought chain reasoning. After large-scale model training, it can enable the large-scale reasoning model to learn accurately and produce compact outputs efficiently, effectively improving reasoning efficiency and reducing computational resource consumption. Furthermore, a training dataset without limiting the length of the thought chain reasoning is designed for training the large-scale reasoning model, making the trained large-scale reasoning model flexible and stable. When the model cannot use compact reasoning, it can seamlessly switch to long thought chain reasoning mode, ensuring that the reasoning process is not interrupted and the results are not lost when facing complex problems, and enhancing the system's adaptability and fault tolerance performance in diverse task scenarios.

[0116] Figure 4 This is a structural block diagram of a natural language programming device provided in an embodiment of the present disclosure.

[0117] like Figure 4 As shown, the natural language programming device 400 includes: a natural language to code conversion unit 401, a code normalization unit 402, a code execution verification unit 403, a code error correction unit 404, and a result confirmation unit 405.

[0118] In one exemplary embodiment, the natural language to code unit 401 is used to input sample natural language and a first prompt word into the SOTA model to obtain the target code corresponding to the sample natural language. The first prompt word is used to guide the SOTA model to learn the idea of ​​converting natural language into a programming language. In one exemplary embodiment, the code normalization unit 402 is used to input the target code and the second prompt word into the SOTA model to obtain the function form corresponding to the target code, and the second prompt word is used to guide the SOTA model to transform the target code into a function form that conforms to a preset specification; In one exemplary embodiment, the code execution verification unit 403 is used to determine whether the execution result corresponding to the function form is correct based on the function form and the code sandbox; In one exemplary embodiment, the code error correction unit 404 is configured to generate a corrected function form based on the error message corresponding to the error result, the function form, the second prompt word, and the SOTA model if there is an error result in the execution result; In one exemplary embodiment, the result confirmation unit 405 is used to access the modified function form into the code sandbox for verification, and after successful verification, use it as the programming result.

[0119] Figure 5 This is a flowchart illustrating a natural language programming method provided in an embodiment of the present disclosure.

[0120] like Figure 5 As shown, this natural language programming method specifically includes the following steps: Step 501: Convert natural language into code.

[0121] Specifically, by pre-setting a first prompt word, natural language and the first prompt word are input into the SOTA model, so that the SOTA model processes the natural language and converts it into code according to the guidance of the first prompt word.

[0122] Step 502: Convert the code into function form.

[0123] Specifically, a second prompt word is set, and the code and the second prompt word are input into the SOTA model. Guided by the second prompt word, the SOTA model converts the code into a function form with a uniform format and conforms to preset specifications. The function form includes an executable main function, an input generation function, input and output descriptions, and a problem statement.

[0124] Step 503: Execute the code in the code sandbox.

[0125] Specifically, the input generation function is executed in a code sandbox to obtain multiple test inputs. These multiple test inputs are then used as inputs to the executable main function, which is then run in the code sandbox. Each run yields a set of test inputs and their corresponding test results. This results in multiple input-output pairs containing the test inputs and their corresponding test results.

[0126] Step 504: Is the execution result correct?

[0127] Specifically, by verifying the input-output pairs, it is determined whether the function form conforms to the preset business logic (i.e., there are no execution exceptions and the results are accurate), and then it is determined whether the execution result of the function form is correct.

[0128] Step 505: Merge the data in the code sandbox.

[0129] Specifically, if correct, the correct input-output pair is retained. For incorrect input-output pairs, a third prompt is constructed based on the error message, function form, and second prompt word corresponding to the incorrect result. When the second and third prompt words are input into the SOTA model, the SOTA model corrects the original function form according to the third prompt word while adhering to the specification of the second prompt word, generating a function form that conforms to the preset specification and can be executed correctly. The verification process in step 503 is then executed again to obtain new input-output pairs. The new input-output pairs are then merged with the initially correct input-output pairs and the corrected function.

[0130] Step 506: Construct input and output training samples: Construct thought chain reasoning according to the template prompts and limit the number of words.

[0131] Specifically, a fourth prompt word is designed, which includes at least: a preset inference step size, core task instructions, a problem statement to be inferred, input / output parameter definitions, known input / output values, a code inference process reference, and output format constraints. This serves to define the inference rules, logical basis, and result format of the subsequent SOTA model. The preset inference step size can be set to 8-15 words depending on the actual application, preferably allowing 10 words to be generated for each inference step. The problem statement to be inferred, input / output parameter definitions, known input / output values, and a code inference process reference can be determined based on the input / output pair and the corrected function form obtained in step 504. Each input / output pair is input into the SOTA model, and according to the inference constraints, problem description, input / output definitions, and code inference process reference in the fourth prompt word, the SOTA model is driven to perform forward and backward inference. Forward inference derives the corresponding output result based on the known input parameters, while backward inference derives reasonable input parameters based on the known output result, thus obtaining model inference content that meets the requirements of compact inference.

[0132] Step 507: Verify the reasoning results in the code sandbox.

[0133] Specifically, by combining the modified function form, the results obtained from the forward inference of the SOTA model (i.e., the first inference result) and the results obtained from the backward inference (i.e., the second inference result) are run in the code sandbox to verify whether these inference results are correct and whether they meet expectations.

[0134] Step 508: Is the execution result correct?

[0135] Specifically, the correctness of the execution result is determined by verifying whether the reasoning result is correct.

[0136] If correct, proceed to step 510. If incorrect, proceed to step 509.

[0137] Step 509: Conduct thought chain reasoning without word limit.

[0138] Specifically, if the verification result is incorrect, each input-output pair is input into the SOTA model. Following the problem description, input-output definitions, and code reasoning process reference in the fourth prompt, the SOTA model's inference step size is not limited by a preset inference step size. This drives the SOTA model to execute the second forward inference and the second backward inference. The first forward inference derives the corresponding output result based on known input parameters, while the second backward inference deduces reasonable input parameters based on known output results, thus obtaining the model's inference content. Finally, the process proceeds to step 511.

[0139] Step 510: Obtain dataset 1.

[0140] Specifically, the first inference result / second inference result is integrated with the corresponding target input-output pair and the corrected function form to construct a dataset1 for training a large inference model with compact inference capabilities.

[0141] Step 511: Obtain dataset 2.

[0142] Specifically, if the reasoning results of the second forward reasoning and the second backward reasoning are both correct (i.e., the secondary verification results are correct), the reasoning results of the second forward reasoning and the second backward reasoning are integrated with the corresponding target input-output pairs and the corrected function forms, respectively, to construct a dataset 2 for training a large reasoning model with compact reasoning capabilities.

[0143] Step 512, Final Dataset.

[0144] Specifically, dataset 1 and dataset 2 are integrated to form the target training dataset, which is used for training the large inference model.

[0145] Figure 6 This is a hardware block diagram of an electronic device provided according to an embodiment of the present disclosure. The electronic device 600 according to an embodiment of the present disclosure includes at least a processor; and a memory for storing computer-readable instructions. When the computer-readable instructions are loaded and executed by the processor, the processor performs the natural language programming method described in any of the preceding embodiments of the present disclosure.

[0146] Figure 6The illustrated electronic device 600 specifically includes a central processing unit (CPU) 601, a graphics processing unit (GPU) 602, and a memory 603. These units are interconnected via a bus 604. The CPU 601 and / or GPU 602 can function as the aforementioned processor, and the memory 603 can function as the aforementioned memory storing computer-readable instructions. Furthermore, the electronic device 600 may also include a communication unit 605, a storage unit 606, an output unit 607, an input unit 608, and an external device 609, all of which are also connected to the bus 604.

[0147] Figure 7 This is a schematic diagram of a computer-readable storage medium provided in an embodiment of this disclosure. (As shown...) Figure 7 As shown, a computer-readable storage medium 700 according to an embodiment of the present disclosure stores computer-readable instructions 701 thereon. When the computer-readable instructions 701 are executed by a processor, the natural language programming method described with reference to the above figures according to any embodiment of the present disclosure is performed. The computer-readable storage medium includes, but is not limited to, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, optical disk, magnetic disk, etc.

[0148] This disclosure further provides a computer program product, including a computer program that, when executed by a processor, implements the natural language programming method described in any of the preceding embodiments of this disclosure.

[0149] The above, in conjunction with the appendix Figure 1-7 This disclosure provides a detailed description of natural language programming methods, apparatus, electronic devices, and storage media provided according to embodiments of the present disclosure. The present disclosure innovatively converts natural language into a unified code style, utilizes a sandbox environment for rigorous verification, and establishes a complete generation-verification-correction closed-loop interaction mechanism. This mechanism not only ensures the standardization and accuracy of the output code but also enables rapid iterative optimization to address problems, improving the reliability of task execution. Furthermore, it constructs a compact (limited inference step length) large-scale model inference training dataset. After large-scale model training, this enables the model to learn accurately and efficiently produce compact outputs, effectively improving inference efficiency and reducing computational resource consumption. Simultaneously, it constructs a training dataset without inference step length limitations for training large-scale inference models. When the large-scale inference model cannot utilize compact inference, it can seamlessly switch to a long thought chain inference mode, ensuring that the inference process is uninterrupted and results are not lost when facing complex problems. This enhances the system's adaptability and fault tolerance in diverse task scenarios, balancing the flexibility and stability of model inference.

[0150] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0151] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.

[0152] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.

[0153] Additionally, as used herein, the "or" used in a list of items beginning with "at least one" indicates a separate list, such that a list of, for example, "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not imply that the described example is preferred or better than other examples.

[0154] It should also be noted that in the systems and methods of this disclosure, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions to this disclosure.

[0155] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.

[0156] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.

[0157] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

Claims

1. A natural language programming method, characterized in that, include: The sample natural language and the first prompt word are input into the SOTA model to obtain the target code corresponding to the sample natural language. The first prompt word is used to guide the SOTA model to learn the idea of ​​converting natural language into programming language. The target code and the second prompt word are input into the SOTA model to obtain the function form corresponding to the target code. The second prompt word is used to guide the SOTA model to convert the target code into a function form that conforms to a preset specification. Based on the function form and the code sandbox, determine whether the execution result corresponding to the function form is correct; If there is an error in the execution result, a corrected function form is generated based on the error message corresponding to the error, the function form, the second prompt word, and the SOTA model. The modified function form is then executed and verified in a code sandbox. Once the verification is successful, it is used as the programming result.

2. The natural language programming method according to claim 1, characterized in that, The first prompt includes a problem description, example guidance, and requirements.

3. The natural language programming method according to claim 1, characterized in that, The function form includes: an executable main function, input / output description, input generation function, and problem statement; The step of determining whether the execution result corresponding to the function form is correct based on the function form and the code sandbox includes: The input generation function is executed in a code sandbox to obtain multiple test inputs; The multiple test inputs are input into the executable main function, and the executable main function is executed in the code sandbox to obtain multiple input-output pairs, which include each test input and its corresponding test result; Based on the multiple input-output pairs, determine whether the execution result corresponding to the function form is correct.

4. The natural language programming method according to claim 3, characterized in that, The step of generating a corrected function form based on the error message corresponding to the error result, the function form, the second prompt word, and the SOTA model includes: Based on the error message corresponding to the error result and the function form, a fourth prompt word is generated; Based on the fourth prompt word, the second prompt word, and the SOTA model, the corrected function form is generated.

5. The natural language programming method according to claim 4, characterized in that, The method further includes: Multiple target input / output pairs are obtained based on multiple input / output pairs, the corrected function form, and the code sandbox.

6. The natural language programming method according to claim 5, characterized in that, The method further includes: Based on multiple target input-output pairs, the corrected function form, and the preset inference step size, a fourth prompt word is constructed for each target input-output pair; Based on multiple target input-output pairs and the fourth prompt word corresponding to each target input-output pair, the SOTA model is invoked to perform forward and backward reasoning. The code sandbox was used to verify the first reasoning result corresponding to forward reasoning and the second reasoning result corresponding to backward reasoning; Based on the verification results, multiple target input-output pairs, the corrected function form, the first inference result, and the second inference result, a target training dataset is constructed, which is used to train the large inference model.

7. The natural language programming method according to claim 6, characterized in that, Based on the verification results, multiple target input-output pairs, the first inference result, and the second inference result, a target training dataset is constructed. This target training dataset is used to train a large inference model and includes: If the verification results are correct, a first training dataset is constructed based on multiple target input-output pairs, the corrected function form, the first inference result, and the second inference result. If the verification result is incorrect, based on multiple target input-output pairs and the fourth prompt word, the SOTA model is called again to perform the second forward reasoning and the second backward reasoning. The reasoning step size of the SOTA model is not limited by the preset reasoning step size. The reasoning results of the second forward reasoning and the second backward reasoning are verified using a code sandbox; If the secondary verification result is correct, a second training dataset is constructed based on multiple target input-output pairs, the corrected function form, the reasoning result of the second forward reasoning, and the reasoning result of the second backward reasoning. Based on the first and second training datasets, construct the target training dataset.

8. A natural language programming device, characterized in that, include: The Natural Language to Code Unit is used to input sample natural language and a first prompt word into the SOTA model to obtain the target code corresponding to the sample natural language. The first prompt word is used to guide the SOTA model to learn the idea of ​​converting natural language into programming language. The code normalization unit is used to input the target code and the second prompt word into the SOTA model to obtain the function form corresponding to the target code. The second prompt word is used to guide the SOTA model to transform the target code into a function form that conforms to a preset standard. The code execution verification unit is used to determine whether the execution result corresponding to the function form is correct based on the function form and the code sandbox. The code error correction unit is used to generate a corrected function form based on the error message corresponding to the error result, the function form, the second prompt word, and the SOTA model if there is an error result in the execution result. The result confirmation unit is used to connect the modified function form to the code sandbox for execution verification, and after successful verification, use it as the programming result.

9. An electronic device, characterized in that, include: Memory, used to store computer-readable instructions; as well as A processor for executing the computer-readable instructions, causing the electronic device to perform the natural language programming method as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium for storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by a processor, the processor performs the natural language programming method as described in any one of claims 1 to 7.