Aerospace control flow chart intelligent code generation system based on chain thinking reasoning

By building a knowledge base in the field of aerospace control and a chain thinking and reasoning module, complex problems are decomposed into multiple subtasks, and code that conforms to the C language programming conventions of spacecraft software is generated, which solves the problem of code generation in the aerospace field and improves generation efficiency and accuracy.

CN120631330APending Publication Date: 2025-09-12NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510740201.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-05
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

Existing technologies make it difficult to effectively generate codes in the aerospace field, especially flowchart codes with complex structures, and large language models lack the ability to generate codes in specific fields.

Method used

An intelligent code generation system for aerospace control flow charts based on chain thinking and reasoning is adopted, including a space control domain knowledge base module, a chain thinking and reasoning module based on prompt engineering, and a space control domain code generation and optimization module. By building a domain knowledge base, decomposing complex problems into multiple subtasks, and gradually reasoning to generate node codes, the system optimizes the code to comply with the C language programming conventions of spacecraft software.

Benefits of technology

It improves the efficiency and accuracy of code generation in the aerospace field, ensures that the generated code complies with the programming specifications of spacecraft software, reduces the workload of developers, and improves work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120631330A_ABST
    Figure CN120631330A_ABST
Patent Text Reader

Abstract

The invention discloses a chain thinking reasoning-based spaceflight control flow chart intelligent code generation system, which relates to the crossing field of artificial intelligence and spaceflight control, and comprises a spaceflight control field knowledge base module, a prompt project-based chain thinking reasoning module and a spaceflight control field code generation and optimization module, by constructing a domain knowledge base and integrating domain knowledge into a prompt project, a model can more accurately understand specific domain task requirements, then the knowledge-driven prompt optimization effect is improved, and on this basis, a multi-step reasoning chain thinking mechanism and a code optimization strategy are combined, so that the knowledge-driven prompt optimization effect is improved. And finally, high-quality codes which are strict in logic and conform to field specifications are generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of intersection of artificial intelligence and aerospace control, and in particular to an intelligent code generation system for aerospace control flow charts based on chain thinking and reasoning. Background Art

[0002] With the development of artificial intelligence technology, large language models have made significant progress in natural language processing and generation tasks. Flowcharts can be used to represent the logic of a specific algorithm or program. Developers can draw flowcharts before writing code to help them understand and write the code. Generating code directly from flowcharts helps streamline the development process and reduce development time. Therefore, research on flowchart-based program synthesis technology can reduce developer workload and improve work efficiency.

[0003] Current methods for synthesizing code based on flowcharts have shortcomings, such as limited requirements for flowchart drawing, the text in flowcharts strictly conforming to the C programming language standard, and incomplete structural parsing of complex flowcharts. While large language models can solve some code generation problems, they still pose challenges for code generation in specific domains. Some researchers have proposed methods to improve the code generation capabilities of LLMs, but these methods have not been able to address the code generation challenges in the aerospace field. Summary of the Invention

[0004] The purpose of the present invention is to provide an aerospace control flow chart intelligent code generation system based on chain thinking and reasoning, which solves the problems existing in the background technology.

[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions: The present invention provides an intelligent code generation system for aerospace control flow charts based on chain thinking and reasoning, including: an aerospace control field knowledge base module, a chain thinking and reasoning module based on prompt engineering, and an aerospace control field code generation and optimization module.

[0006] The aerospace control domain knowledge base module is used to store domain knowledge related to aerospace control software and its corresponding codes, and integrate the domain knowledge into the prompt engineering.

[0007] The chain thinking reasoning module based on prompt engineering is used to generate optimized prompts according to the input natural language description and domain knowledge base, and decompose the generation task into multiple subtasks to generate node codes step by step.

[0008] The aerospace control field code generation and optimization module is used to generate code based on the optimized prompts of the large language model.

[0009] Furthermore, the specific process of the domain knowledge prompting project is as follows:

[0010] S1: Build a domain knowledge base by collecting domain knowledge in the aerospace field and relevant data such as corresponding code variables, and store the knowledge in a structured form.

[0011] S2: Extract knowledge from new data sources, update it to the knowledge base, and ensure the accuracy of the newly added knowledge through expert review or automatic verification mechanism.

[0012] S3: Based on the natural language description input by the user, relevant knowledge is extracted from the domain knowledge base and the domain knowledge is integrated into the prompts to generate optimization prompts.

[0013] Furthermore, the basic mechanism of chain thinking and reasoning is:

[0014] A1: Use chain thinking and reasoning to generate node code. Decompose the domain knowledge text into multiple subtasks, such as formula decomposition, variable definition, assignment, judgment, etc., reason for each subtask, and gradually generate code snippets based on prompts.

[0015] A2: Generate complete code from the generated code snippets according to the logic of the program structure tree.

[0016] A3: Optimize the code according to the C language programming conventions of spacecraft software to make the code comply with aerospace regulations.

[0017] Furthermore, the domain knowledge base module includes:

[0018] ①ID: Each domain knowledge name has a unique ID.

[0019] ②Knowledge name: the professional name of domain knowledge.

[0020] ③Function description: Functional description of the knowledge name.

[0021] ④Input port: parameter list of the function in domain knowledge.

[0022] ⑤Output port: the return result after the function in the domain knowledge is run.

[0023] ⑥Program code: The program code corresponding to the knowledge name.

[0024] Furthermore, the specific construction method of the domain knowledge base is as follows:

[0025] B1: Collect data. The data source is the domain knowledge of the aerospace field and the corresponding code variables, etc. Collect aerospace professional domain knowledge and preprocess the domain knowledge.

[0026] B2: Perform vectorization representation. Use vectorization technology to convert text into a computer-processable form. Select an appropriate language model or embedding model to convert text content into a high-dimensional vector representation.

[0027] B3: Build an index structure, select an efficient indexing method, and build an efficient index structure to facilitate efficient query of the domain knowledge table.

[0028] B4: Knowledge updating and maintenance, incremental updating, regularly extracting knowledge from new data sources and updating it to the knowledge base, ensuring the accuracy of the newly added knowledge through expert review or automatic verification mechanism.

[0029] Furthermore, the specific usage of the aerospace knowledge base module includes:

[0030] i. Knowledge query and retrieval: Provides a natural language query interface where users can input questions to obtain relevant knowledge. The visualization function of the knowledge graph helps users understand the relationships between knowledge.

[0031] ii. Decision Support and Reasoning: Combined with chain reasoning technology, it solves complex problems through step-by-step reasoning, providing decision support for design, testing, and fault diagnosis in the aerospace field.

[0032] iii. C language code generation: Combining domain knowledge with code generation, aerospace domain knowledge is incorporated into code generation prompts, and a large language model is used to generate C language code based on the prompts.

[0033] Furthermore, the chain thinking and reasoning module based on the prompt engineering includes the following specific contents:

[0034] Step 1: Decompose domain knowledge text and decompose complex problems into multiple sub-problems

[0035] b1. The large language model determines the category of the domain knowledge.

[0036] b2. Natural language function point extraction.

[0037] b3. Construct a detailed reasoning process for each function point.

[0038] Step 2: Construct a binary subtree of control logic

[0039] c1. Construct a program structure tree corresponding to the flowchart.

[0040] c2. Convert the node into a control logic binary subtree and attach it to the program structure tree.

[0041] c3. Analyze the program structure tree and synthesize C language code.

[0042] Step 3: Build a query to retrieve results from the database

[0043] d1. Generate each node code based on the newly obtained program structure tree.

[0044] d2. Generate a large answer model based on the context and obtain the corresponding domain code.

[0045] d3. Annotate node code and use domain knowledge as annotations.

[0046] Step 4: Check the generated node code and check the code variable definition and other issues

[0047] Step 5: Code Optimization

[0048] e1. Optimize the code according to the C language programming conventions of spacecraft software to ensure that the code complies with aerospace regulations.

[0049] Step 6: Overall code accuracy and feasibility check test analysis

[0050] f1. Code accuracy check.

[0051] f2. Code feasibility test.

[0052] Furthermore, the domain knowledge is decomposed into and includes:

[0053] a1. For computational domain knowledge, large models can be directly decomposed according to each publicly available item, with each item corresponding to a domain vocabulary.

[0054] a2. For assignment and judgment domain knowledge texts, use a large model to extract and divide the functional points first to obtain more accurate results when generating code.

[0055] Furthermore, the natural language function point extraction includes:

[0056] For a single function, it is generally a domain vocabulary or a short sentence. There is no need to use technical means to extract functional points. The code can be directly generated using a large model combined with the domain knowledge base.

[0057] For multi-function point text, direct processing may make it difficult for the model to accurately understand or generate it. It is necessary to decompose the function points and gradually solve each sub-problem to improve the model's reasoning ability and generation quality. Identify the function points in the domain knowledge text one by one and decompose them into independent sub-problems.

[0058] Furthermore, the node synthesis C language includes:

[0059] g1. The program structure tree is an intermediate data structure between the flowchart model and the C code. Each node of the structure tree corresponds to a section of code. The root node corresponds to the beginning of the code. The While type tree node corresponds to the while loop control statement, the For type tree node corresponds to the for loop control statement, the If type tree node corresponds to the if selection control statement, the LeftCondNode corresponds to the conditional true statement, the RightCondNode corresponds to the conditional false statement, the Switch type tree node corresponds to the switch selection control statement, and the CASE corresponds to a conditional satisfaction statement. Therefore, by parsing the program structure tree, C language code can be automatically synthesized.

[0060] The beneficial effect of the present invention is that a method combining a large model is proposed, and a domain knowledge base and chain thinking reasoning are introduced to solve the situation where the flow chart contains domain knowledge. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0062] Figure 1 This is a schematic diagram of the system structure connection of the present invention. Figure 2 Decomposition diagram of the test formula for the large model. Figure 3 This is a diagram of decomposition principles corresponding to domain knowledge categories. DETAILED DESCRIPTION

[0063] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0064] Reference Figure 1 As shown, the present invention provides an aerospace control flow chart intelligent code generation system based on chain thinking and reasoning, including: an aerospace control field knowledge base module, a chain thinking and reasoning module based on prompt engineering, and an aerospace control field code generation and optimization module;

[0065] The aerospace control domain knowledge base module is used to store domain knowledge related to aerospace control software and its corresponding codes, and integrate the domain knowledge into the prompt engineering;

[0066] The chained thinking and reasoning module based on prompt engineering is used to generate optimized prompts based on the input natural language description and domain knowledge base, and decompose the generation task into multiple subtasks to gradually reason and generate node codes;

[0067] The aerospace control field code generation and optimization module is used to generate code based on the optimized prompts of the large language model.

[0068] In the above embodiment, the domain knowledge prompting project has the following specific process:

[0069] S1: Build a domain knowledge base by collecting domain knowledge in the aerospace field and related data such as corresponding code variables, and store the knowledge in a structured form;

[0070] S2: Extract knowledge from new data sources, update it to the knowledge base, and ensure the accuracy of the new knowledge through expert review or automatic verification mechanism;

[0071] S3: Based on the natural language description input by the user, relevant knowledge is extracted from the domain knowledge base and the domain knowledge is integrated into the prompts to generate optimization prompts.

[0072] In the above embodiment, the basic mechanism of chain thinking and reasoning is:

[0073] A1: Generate node code using chained reasoning. This method breaks down domain knowledge text into multiple subtasks, such as formula decomposition, variable definition, assignment, and judgment. It then reasons for each subtask and uses prompts to gradually generate code snippets.

[0074] A2: Generate complete code from the generated code snippets according to the program structure tree logic;

[0075] A3: Optimize the code according to the C language programming conventions of spacecraft software to make the code comply with aerospace regulations.

[0076] In the above embodiment, the domain knowledge base module includes:

[0077] ①ID: Each domain knowledge name has a unique ID;

[0078] ②Knowledge name: the professional name of the domain knowledge;

[0079] ③ Functional description: functional description of the knowledge name;

[0080] ④ Input port: parameter list of the function in domain knowledge;

[0081] ⑤ Output port: the return result after the function in the domain knowledge is run;

[0082] ⑥Program code: The program code corresponding to the knowledge name.

[0083] In the above embodiment, the specific construction method of constructing the domain knowledge base is as follows:

[0084] B1: Data collection. The data source is aerospace domain knowledge and corresponding code variables. This knowledge is collected and preprocessed, such as removing irrelevant content and processing noisy data, to improve the quality of vectorized representation. Language preprocessing is also performed on the text content, such as word segmentation, stop word removal, and part-of-speech tagging, to optimize subsequent embedding effects.

[0085] B2: Perform vectorization. Use vectorization technology to convert text into a computer-processable form. Select an appropriate language model or embedding model to convert text content into a high-dimensional vector representation.

[0086] B3: Build an index structure, select an efficient indexing method, and build an efficient index structure to facilitate efficient query of the domain knowledge table;

[0087] B4: Knowledge updating and maintenance, incremental updating, regularly extracting knowledge from new data sources and updating it to the knowledge base, ensuring the accuracy of the newly added knowledge through expert review or automatic verification mechanism.

[0088] In the above embodiment, the aerospace knowledge base module has the following specific uses:

[0089] i. Knowledge query and retrieval: Provides a natural language query interface, allowing users to input questions to obtain relevant knowledge. The visualization function of the knowledge graph helps users understand the relationships between knowledge.

[0090] ii. Decision Support and Reasoning: Incorporating chain reasoning techniques, this approach solves complex problems through step-by-step reasoning, providing decision support for aerospace design, testing, and fault diagnosis.

[0091] iii. C language code generation: Combining domain knowledge with code generation, aerospace domain knowledge (such as orbit calculation and sensor data processing) is incorporated into code generation prompts, and a large language model is used to generate C language code based on the prompts.

[0092] In a specific embodiment, the chain thinking and reasoning module based on the prompt engineering includes the following specific contents:

[0093] It should be noted that, based on the chain thinking and reasoning module based on the prompt engineering, the following supplementary explanations are made:

[0094] C1: Chain thinking is a method of reasoning that gradually deduces the final result by breaking down the problem, using logical reasoning and verification. The core of this method lies in step-by-step reasoning and logical verification.

[0095] C2: Characteristics of chain thinking and reasoning

[0096] Step-by-step: break down the problem into multiple steps and solve them step by step;

[0097] Logic: Each step of reasoning has a clear logical basis;

[0098] Explainability: The reasoning process is clear, easy to understand and verify;

[0099] Flexibility: The reasoning path can be adjusted based on intermediate results;

[0100] C3: Chain thinking and reasoning steps

[0101] Step 1: Decompose domain knowledge text and decompose complex problems into multiple sub-problems

[0102] b1. The large language model determines the category of the domain knowledge;

[0103] b2. Natural language function point extraction;

[0104] b3. Construct a detailed reasoning process for each function point;

[0105] It should be noted that, based on b1, a supplementary explanation is given. The large language model can determine which category of domain knowledge it belongs to by itself, as shown in Table 1 - Domain Knowledge Categories;

[0106] Table 1 - Domain Knowledge Categories

[0107]

[0108] Step 2: Construct a binary subtree of control logic

[0109] c1. Construct a program structure tree corresponding to the flowchart;

[0110] c2. Convert the node into a control logic binary subtree and attach it to the program structure tree;

[0111] c3. Parse the program structure tree to synthesize C language code;

[0112] Step 3: Build a query to retrieve results from the database

[0113] d1. Generate code for each node based on the newly obtained program structure tree;

[0114] d2. Generate a large answer model based on the context and obtain the corresponding domain code;

[0115] d3. Annotate node code and use domain knowledge as annotations;

[0116] Step 4: Check the generated node code and check the code variable definition and other issues

[0117] It should be noted that, as a supplement to step 4, the generated node code is checked, and the code variable definitions are the following issues: e1. Code variable definition and duplicate name issues: The large model can use its natural language understanding capabilities, combined with the code context, to help developers quickly identify potential problems in the code, including syntax errors, logic problems, security vulnerabilities, etc. Therefore, we directly use this function of the large model to check the node code, mainly checking whether the variables are defined and duplicate names.

[0118] e2. Divide by zero: Divide by zero is a common runtime error in programming that can cause program crashes or unexpected behavior. The large model can detect potential divide-by-zero issues through static code analysis and semantic understanding. By understanding the context, the large model can identify whether a variable might be assigned to zero before use. It can then generate code snippets or fix suggestions to help us avoid divide-by-zero issues.

[0119] e3. Real number judgment issues: In code, real number judgments often involve the comparison and processing of floating-point numbers, which can lead to precision issues or logical errors. Large models can help resolve these issues in the following ways: Precision problem detection: Large models can detect whether there are precision issues in the code that may be caused by floating-point number comparisons. Logical error identification: Through semantic analysis, large models can identify real number judgments in the code that may lead to logical errors. Repair suggestions: Large models can generate more precise comparison logic or use more appropriate math libraries;

[0120] e4: Overflow prevention: Integer overflow is a common security vulnerability in programming that can cause a program to crash or be exploited maliciously. Large models can help detect and fix overflow issues in the following ways: Static analysis: Large models can identify code snippets that may cause overflows through syntactic and semantic analysis. Control flow analysis: By analyzing the control flow of the code, large models can predict the value range of variables and thus detect potential overflow risks. Large models can also generate suggestions for fixing the code, such as using larger data types or adding overflow checks.

[0121] Step 5: Code Optimization

[0122] f1. Optimize the code according to the C language programming conventions of spacecraft software to ensure that the code complies with aerospace regulations.

[0123] It should be noted that, based on F1, the coding standards of the spacecraft software C language programming specification are as follows: Structural optimization category: Regarding the structure of the generated code, there are some rules and constraints in the spacecraft software C language programming conventions. For example, the if-else specification stipulates that when the generated code contains an if-else statement but the else branch is empty (that is, no operation is executed in the else branch), the else branch is deleted;

[0124] Switch branch specifications: Avoid cases in switch statements that do not have statements. If this is a special software design, add comments to explain it. Avoid cases in switch statements that are not terminated by a break. If this is a special software design, add comments to explain it.

[0125] Code function specification: For functions that are declared but not defined, comment on the function. If the function does not take parameters, use the (void) form to describe it.

[0126] Variable definition class: In the generated code, all variables used in the code need to be defined in advance. The variable parameters in the function table will be checked before the code is generated. If they are not defined in the data dictionary in advance, the tool will pop up a prompt indicating that the variable is not defined. The user needs to add the variable to the data dictionary.

[0127] Step 6: Overall code accuracy and feasibility check test analysis

[0128] g1. Code accuracy check

[0129] It should be noted that, based on G1, a supplementary explanation is given. Code accuracy checks can be divided into the following: Syntax check: Use static code analysis tools (such as Cppcheck, Visual Studio, etc.) to check whether the code has syntax errors;

[0130] Logic check:

[0131] Code path coverage: Ensure that all possible paths through the code (such as conditional branches, loops, etc.) are tested, using code coverage tools to assist in analysis.

[0132] Unit testing: Write test cases that cover normal input, boundary input, and abnormal input to verify the correctness of code logic;

[0133] g2. Code feasibility test

[0134] It should be noted that, based on G2, a supplementary explanation is given. Code feasibility testing is divided into the following: Static testing: without running the program, the feasibility is checked by analyzing the structure and interface of the code;

[0135] Dynamic testing: Run the program to check whether the results meet expectations and evaluate performance, correctness, and robustness.

[0136] Input scale testing: Select input data of different sizes to evaluate the performance of the code under different conditions;

[0137] In the above embodiment, the domain knowledge decomposition includes:

[0138] h1. For computational domain knowledge, the large model can directly decompose it, breaking it down according to each item in the public description. Each item corresponds to a domain vocabulary. For example, for the formula "Call the gyro data processing formula to calculate the gyro angle increment, "Gyro i angle increment" = "Gyro i acquisition data source code" / "Gyro nominal equivalent" * "degree to radian product coefficient" * "control period"", the large model can decompose each item of the formula separately, such as Figure 2 The following figure shows the test results of the large model without the domain knowledge base. Although the large model cannot generate the required code, it breaks down each item and provides an explanation, indicating that this task can be solved by the large model.

[0139] h2. For assignment and judgment domain knowledge texts, use a large model to extract and divide the functional points first to obtain more accurate results when generating code.

[0140] In a specific embodiment, the natural language function point extraction includes:

[0141] For a single function, which is usually a domain word or a short sentence, there is no need to use technical means to extract the function points. The code can be directly generated by combining the large model with the domain knowledge base.

[0142] Direct processing of multi-function point text may make it difficult to accurately understand or generate the model. Therefore, it is necessary to decompose the function points and gradually solve each sub-problem to improve the model's reasoning ability and generation quality. The function points in the domain knowledge text should be identified one by one and decomposed into independent sub-problems. For example, if the domain knowledge involves the orbit calculation and attitude control of a spacecraft, it can be decomposed into: 1. Calculation of orbital parameters 2. Implementation of attitude control logic. A detailed reasoning process needs to be constructed for each function point, including:

[0143] Instructions: clearly describe the tasks of each functional point;

[0144] Logical Basis: Detailed explanation of the reasoning steps for each function point, including intermediate calculations, logical relationships, and related knowledge. For domain knowledge text related to multiple functions, the text will contain corresponding connectives, which can also provide certain logical relationships for the larger model and determine the logical order.

[0145] Example: Providing a small number of input-output pairs to a large model helps the model understand the specific requirements of the task.

[0146] In a specific embodiment, the node synthesis C language includes:

[0147] The program structure tree is the intermediate data structure between the flowchart model and the C code. Each node in the structure tree corresponds to a section of code. The root node corresponds to the beginning of the code. The While type tree node corresponds to the while loop control statement, the For type tree node corresponds to the for loop control statement, the If type tree node corresponds to the if selection control statement, the LeftCondNode corresponds to the conditional true statement, the RightCondNode corresponds to the conditional false statement, the Switch type tree node corresponds to the switch selection control statement, and the CASE type corresponds to the conditional satisfied statement. Therefore, by parsing the program structure tree, C language code can be automatically synthesized.

[0148] It should be noted that, as a supplement to what was said in j1, each node of the tree does not necessarily correspond to a piece of code. It is necessary to generate the code for each node based on the newly obtained program structure tree. Since there are various nested sequences, loops, and branch structures in the flowchart, a recursive method is used to sequentially scan the program structure tree starting from the root node. During the scanning process, the corresponding code segments or control structure statements are synthesized. For the code in the program structure tree nodes, no further processing is required. For the node text in natural language text, the node text needs to be vectorized to generate a query vector. The query vector is searched for similarity with the vector in the knowledge base. The retrieval enhancement generation technology is used to input the most relevant knowledge fragments retrieved as context into the large model.

[0149] The above contents are merely examples and explanations of the concept of the present invention. Those skilled in the art may make various modifications or additions to the described specific embodiments or replace them in a similar manner. As long as they do not deviate from the concept of the invention or exceed the scope defined by the present invention, they should all fall within the scope of protection of the present invention.

Claims

1. The intelligent code generation system for aerospace control flow chart based on chain thinking reasoning is characterized by: include: Knowledge base module in the field of aerospace control, chain thinking and reasoning module based on prompt engineering, and code generation and optimization module in the field of aerospace control; The aerospace control domain knowledge base module is used to store domain knowledge related to aerospace control software and its corresponding codes, and integrate the domain knowledge into the prompt engineering; The chained thinking and reasoning module based on prompt engineering is used to generate optimized prompts based on the input natural language description and domain knowledge base, and decompose the generation task into multiple subtasks to gradually reason and generate node codes; The aerospace control field code generation and optimization module is used to generate code based on the optimized prompts of the large language model.

2. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 1 is characterized in that: The specific process of the domain knowledge prompting project is as follows: S1: Build a domain knowledge base by collecting domain knowledge in the aerospace field and related data such as corresponding code variables, and store the knowledge in a structured form; S2: Extract knowledge from new data sources, update it to the knowledge base, and ensure the accuracy of the new knowledge through expert review or automatic verification mechanism; S3: Based on the natural language description input by the user, relevant knowledge is extracted from the domain knowledge base and the domain knowledge is integrated into the prompts to generate optimization prompts.

3. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 1 is characterized in that: The basic mechanism of chain thinking and reasoning is: A1: Generate node code using chained reasoning. This method breaks down domain knowledge text into multiple subtasks, such as formula decomposition, variable definition, assignment, and judgment. It then reasons for each subtask and uses prompts to gradually generate code snippets. A2: Generate complete code from the generated code snippets according to the program structure tree logic; A3: Optimize the code according to the C language programming conventions of spacecraft software to make the code comply with aerospace regulations.

4. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 1 is characterized in that: The domain knowledge base module includes: ①ID: Each domain knowledge name has a unique ID; ②Knowledge name: the professional name of the domain knowledge; ③ Functional description: functional description of the knowledge name; ④ Input port: parameter list of the function in domain knowledge; ⑤ Output port: the return result after the function in the domain knowledge is run; ⑥Program code: The program code corresponding to the knowledge name.

5. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 1 is characterized in that: The specific construction method of the domain knowledge base is as follows: B1: Collect data. The data source is the domain knowledge of the aerospace field and the corresponding code variables. Collect aerospace professional domain knowledge and pre-process the domain knowledge. B2: Perform vectorization, using vectorization technology to convert text into a computer-processable form. Select an appropriate language model or embedding model to convert text content into a high-dimensional vector table. B3: Build an index structure, select an efficient indexing method, and build an efficient index structure to facilitate efficient query of the domain knowledge table; B4: Knowledge updating and maintenance, incremental updating, regularly extracting knowledge from new data sources and updating it to the knowledge base, ensuring the accuracy of the newly added knowledge through expert review or automatic verification mechanism.

6. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 1 is characterized in that: The specific usage of the aerospace knowledge base module includes: i. Knowledge query and retrieval: Provides a natural language query interface, allowing users to input questions to obtain relevant knowledge. The visualization function of the knowledge graph helps users understand the relationships between knowledge. ii. Decision Support and Reasoning: Incorporating chain reasoning techniques, this approach solves complex problems through step-by-step reasoning, providing decision support for aerospace design, testing, and fault diagnosis. iii. C language code generation: Combining domain knowledge with code generation, aerospace domain knowledge is incorporated into code generation prompts, and a large language model is used to generate C language code based on the prompts.

7. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 1 is characterized in that: The chain thinking and reasoning module based on the prompt engineering includes the following specific contents: Step 1: Decompose domain knowledge text and decompose complex problems into multiple sub-problems b1. The large language model determines the category of the domain knowledge; b2. Natural language function point extraction; b3. Construct a detailed reasoning process for each function point; Step 2: Construct a binary subtree of control logic c1. Construct a program structure tree corresponding to the flowchart; c2. Convert the node into a control logic binary subtree and attach it to the program structure tree; c3. Parse the program structure tree to synthesize C language code; Step 3: Build a query to retrieve results from the database d1. Generate code for each node based on the newly obtained program structure tree; d2. Generate a large answer model based on the context and obtain the corresponding domain code; d3. Annotate node code and use domain knowledge as annotations; Step 4: Check the generated node code and check the code variable definition and other issues Step 5: Code Optimization e1. Optimize the code according to the C language programming conventions for spacecraft software to ensure that the code complies with aerospace regulations; Step 6: Overall code accuracy and feasibility check test analysis f1. Code accuracy check; f2. Code feasibility test.

8. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 1 is characterized in that: The domain knowledge decomposition includes: For computational domain knowledge, large models can be directly decomposed according to the publicly available items, with each item corresponding to a domain vocabulary. a2. For assignment and judgment domain knowledge texts, use a large model to extract and divide the functional points first to obtain more accurate results when generating code.

9. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 7 is characterized in that: The natural language function point extraction includes: For a single function, which is usually a domain word or a short sentence, there is no need to use technical means to extract the function points. The code can be directly generated by combining the large model with the domain knowledge base. For multi-function point text, direct processing may make it difficult for the model to accurately understand or generate it. It is necessary to decompose the function points and gradually solve each sub-problem to improve the model's reasoning ability and generation quality. Identify the function points in the domain knowledge text one by one and decompose them into independent sub-problems.

10. The aerospace control flow chart intelligent code generation system based on chain thinking and reasoning according to claim 8 is characterized in that: The node synthesis C language includes: g1. The program structure tree is an intermediate data structure between the flowchart model and the C code. Each node of the structure tree corresponds to a section of code. The root node corresponds to the beginning of the code. The While type tree node corresponds to the while loop control statement, the For type tree node corresponds to the for loop control statement, the If type tree node corresponds to the if selection control statement, the LeftCondNode corresponds to the conditional true statement, the RightCondNode corresponds to the conditional false statement, the Switch type tree node corresponds to the switch selection control statement, and the CASE corresponds to a conditional satisfaction statement. Therefore, by parsing the program structure tree, C language code can be automatically synthesized.

Citation Information

Cited By

  • Space algorithm application scene-oriented intelligent process arrangement and example generation system and method

    CN122044546A