Code generation device, code generation system, code generation method, and code generation program
The code generation device and system improve generative AI's code conformity to specifications by using an inference model to generate prompts based on conforming, non-conforming, and corrected code, reducing manual correction and developer workload, and offering a cost-effective solution for adaptive code generation.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- MITSUBISHI ELECTRIC SOFTWARE CORP
- Filing Date
- 2024-10-16
- Publication Date
- 2026-04-28
AI Technical Summary
Existing generative AI technologies struggle to generate code that perfectly conforms to specifications, as they often produce non-conforming and require manual correction, lacking a mechanism to adapt and improve code generation based on specification changes.
A code generation device and system that utilizes an inference model to learn the relationship between software specifications and code, generating prompts that incorporate conforming, non-conforming, and corrected code information, guiding generative AI to produce code that aligns more closely with specifications through iterative learning and reference information.
The system enhances code generation accuracy by reducing the need for manual correction, minimizing non-conforming code, and reducing the workload on developers, while providing a cost-effective alternative to traditional training methods.
Smart Images

Figure 2026071083000001_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to a code generation device, a code generation system, a code generation method, and a code generation program.
Background Art
[0002] In software development, there is an increasing demand for automatic code generation. Patent Document 1 discloses a technique for automatically generating new code in a form that reflects a correction when the code has already been automatically generated and the automatically generated code has been corrected.
Prior Art Documents
Patent Documents
[0003]
Patent Document 1
Summary of the Invention
Problems to be Solved by the Invention
[0004] With the advancement of generative AI (Artificial Intelligence) technology, it has become possible to automatically generate code using generative AI based on specifications. Here, basically, generative AI cannot generate code that perfectly conforms to the specifications, so a technology that enables generative AI to generate code that better conforms to the specifications is required. However, Patent Document 1 does not disclose or suggest a technology that enables generative AI to generate code that better conforms to the specifications with respect to the technology of automatically generating code using generative AI based on specifications.
[0005] An object of the present disclosure is to provide a technology that enables generative AI to generate code that better conforms to the specifications with respect to the technology of automatically generating code using generative AI based on specifications.
Means for Solving the Problems
[0006] The code generation device related to this disclosure is An inference model is a model that has learned the relationship between each software specification and the code corresponding to each specification, and generates code based on prompts indicating the software specification. The first automatically generated code generated based on the first prompt indicating the first specification is committed to the version control tool, and the first definitive code generated by modifying the first automatically generated code based on the first specification is committed to the version control tool, and When second reference information is generated regarding the knowledge that the inference model uses when generating the code, based on the first specification, the first non-conforming code included in the first automatically generated code but not in the first confirmed code, the first corrected code included in the first confirmed code but not in the first automatically generated code, and the first conforming code in the first automatically generated code that is not the first non-conforming code, A prompt generation unit generates a second prompt which is a prompt indicating the second specification, which is the specification of the software under development, and the second reference information, and which is a prompt indicating instructions for the inference model. It is equipped with. [Effects of the Invention]
[0007] According to this disclosure, the prompt generation unit generates a second prompt indicating the second specification and the second reference information. Here, the second reference information is information generated based on the first conforming code, the first non-conforming code, and the first corrected code, and is information about the knowledge used by the inference model when generating the code. Therefore, the code generated by the inference model based on the second prompt is expected to be a code that conforms more closely to the second specification. The inference model may also be a generative AI. Therefore, according to this disclosure, regarding the technology for automatically generating code using a generation AI based on specifications, it is possible to provide a technology that enables the generation AI to generate code that better conforms to the specifications. [Brief explanation of the drawing]
[0008] [Figure 1] A diagram showing an example configuration of the code generation system 90 according to Embodiment 1. [Figure 2] A diagram illustrating the purpose of generating the prompt 111 according to Embodiment 1. [Figure 3] A diagram illustrating an example of operation of the code generation device 100 according to Embodiment 1. [Figure 4] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 5] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 6] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 7] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 8] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 9] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 10] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 11] A diagram illustrating the code committed to the version control tool 51 according to Embodiment 1. [Figure 12] A diagram showing an example of the hardware configuration of the code generation device 100 according to Embodiment 1. [Figure 13] A flowchart illustrating the operation of the code generation device 100 according to Embodiment 1. [Figure 14] This figure shows an example of the hardware configuration of a code generation device 100 according to a modified example of Embodiment 1. [Figure 15] A diagram showing an example configuration of the code generation system 90 according to Embodiment 2. [Figure 16] Flowchart showing the operation of the code generation system 90 according to Embodiment 2.
Mode for Carrying Out the Invention
[0009] In the description of the embodiments and the drawings, the same elements and corresponding elements are denoted by the same reference numerals. The description of the elements with the same reference numerals will be omitted or simplified as appropriate. The arrows in the figures mainly indicate the flow of data or the flow of processing. Also, "section" may be appropriately read as "circuit", "device", "equipment", "process", "step", "procedure", "processing", or "circuitry". The functions of each part included in each device may be realized by firmware, software, hardware, or a combination thereof.
[0010] Embodiment 1. Hereinafter, this embodiment will be described in detail with reference to the drawings.
[0011] ***Description of the Configuration*** FIG. 1 shows a configuration example of a code generation system 90 according to this embodiment. The code generation system 90 includes an inference model 50, a version management tool 51, and a code generation device 100.
[0012] The inference model 50 is a model that has learned the relationship between each specification of software and the code corresponding to each specification of software, is a model that generates code based on a prompt indicating the specification of software, takes prompt 111 as an input, and is a model that infers automatically generated code 60 as the code corresponding to the input prompt 111. As a specific example, the inference model 50 is a generative AI (Artificial Intelligence) such as an LLM (Large Language Models), or other machine learning models.
[0013] Version control tools are tools that have the functionality to manage and share the editing history of code, and are also called version control systems. Specific examples of version control tools include GitHub® and TortoiseSVN.
[0014] As shown in Figure 1, the code generation device 100 includes a prompt generation unit 110 and a code generation management unit 120. The code generation device 100 may have an inference model 50, or it may access an external inference model 50. The code generation device 100 may have a version control tool 51, or it may access an external version control tool 51. The code generation device 100 is used, for example, when developing software based on specification 191 using a version control tool 51. The software under development is the software that complies with Specification 191, and is the software being developed.
[0015] Specification 191 is information that describes the specifications of the software under development, and is written in natural language. Specification 191 may include figures and tables. Specification 191 shall be revised sequentially in accordance with additions, changes, or deletions of functions related to the software under development. That is, Specification 191 shall be modified, changed, added to, and deleted as appropriate. Each time Specification 191 is revised, new automatically generated code 60, etc., will be generated. Specification 191 may also contain information that further describes constraints. Specification 191 may be committed to the version control tool 51. Committing data to the version control tool 51 is equivalent to registering data with the version control tool 51. Constraint information refers to information that indicates various constraints when developing the target software. Specifically, constraint information consists of information indicating coding conventions and information indicating the grammatical rules of the programming language used when developing the target software.
[0016] The prompt generation unit 110 generates a prompt 111 by referring to the information committed to the version control tool 51 each time specification 191 is revised. When generating prompt 111 for the first time, the prompt generation unit 110 generates prompt 111 using specification 191. This is because the automatically generated code 60 has not yet been generated, and therefore the conforming code 61, the non-conforming code 62, and the correction code 63 do not exist. When generating prompt 111 for the second time or later, the prompt generation unit 110 extracts the difference between the automatically generated code 60 and the confirmed code 64. Codes included in the automatically generated code 60 that are not included in the confirmed code 64 are designated as non-conforming codes 62, and codes included in the confirmed code 64 that are not included in the automatically generated code 60 are designated as corrected codes 63. The prompt generation unit 110 also designates codes included in the confirmed code 64 that are not corrected codes 63 as conforming codes 61. Subsequently, the prompt generation unit 110 generates a new prompt 111 by adding information indicating the specification 191 most recently given to the inference model 50, the conforming code 61 corresponding to the specification 191, the non-conforming code 62 corresponding to the specification 191, and the corrected code 63 corresponding to the specification 191 to the already generated prompt 111. The extracted difference includes the non-conforming code 62 and the corrected code 63. The prompt generation unit 110 can extract this difference even if a common code is not provided.
[0017] Furthermore, the prompt generation unit 110 may generate prompt 111 based on automatically generated code 60 and confirmed code 64 generated during the development of software different from the software being developed. Specifically, prompt 111 may reuse at least a part of another prompt if the degree of similarity between specification 191 and another specification of another software falls within a predetermined acceptable range. The alternative prompt is prompt 111, which was generated by utilizing the code generation device 100 when developing other software in the past. Other software is software separate from the software being developed. The tolerance range may be set in any way. The tolerance range may be set according to the nature and content of Specification 191, etc. The similarity between specifications may be defined in any way, and may be a value calculated according to the difference between the content of specification 191 and the content of another specification. The prompt generation unit 110 may calculate the similarity between specifications each time specification 191 is revised and determine whether or not to reuse another prompt based on the calculated similarity. The prompt generation unit 110 may calculate the similarity to at least a part of specification 191 for each part of another specification and reuse only the descriptions of the other prompts that correspond to the parts of the other specification whose similarity to at least a part of specification 191 falls within an acceptable range.
[0018] Therefore, the prompt generation unit 110 generates a second prompt when the first automatically generated code is committed to the version control tool 51, the first confirmed code is committed to the version control tool 51, and second reference information is generated based on the first specification, the first non-conforming code, the first correction code, and the first conforming code. Here, the prompt generation unit 110 extracts the first conforming code, the first non-conforming code, and the first correction code based on the first automatically generated code and the first confirmed code committed to the version control tool 51, and generates second reference information based on the extracted first conforming code, the first non-conforming code, and the first correction code. The prompt generation unit 110 may also generate a prompt 111 as a second prompt, which indicates information based on the first reference information and the second reference information. The information based on the first reference information and the second reference information is, as a specific example, information indicating the first reference information and the second reference information. The first automatically generated code is the automatically generated code 60 generated based on the inference model 50 and the first prompt indicating the first specification. The first conformance code is conformance code 61, which is not the first nonconformance code among the first automatically generated codes. The first nonconformity code is nonconformity code 62, which is included in the first automatically generated code but not in the first confirmed code. The first correction code is correction code 63, which is included in the first confirmed code but not in the first automatically generated code. The first confirmed code is confirmed code 64, which is generated by modifying the first automatically generated code based on the first specification. The second reference information is information about the knowledge that the inference model 50 uses when generating code. The second reference information may include constraint information. The first prompt is prompt 111, which provides instructions to the inference model 50. The first prompt may also provide first reference information about the knowledge that the inference model 50 uses when generating code. The first reference information may include constraint information. The instructions to the inference model 50 are basically information that includes natural language. The second prompt is a prompt 111 that indicates the second specification and the second reference information, and is a prompt 111 that indicates instructions for the inference model 50. The first specification may be the specification of the software under development, or it may be the specification of software different from the software under development. The second specification is the specification for the software under development. The second specification may be a revision of the first specification. The second specification may include constraint information.
[0019] Prompt 111 is the input to the inference model 50. The first prompt 111 generated contains information indicating specification 191. Each subsequent prompt 111 generated contains information that includes specification 191, conformance code 61, nonconformance code 62, and correction code 63, respectively. Prompt 111 may be managed by the version control tool 51.
[0020] Figure 2 illustrates the purpose of generating prompt 111. In Figure 2, the inference model 50 is assumed to be a generative AI. The generative AI possesses various types of knowledge, including knowledge that should be used when generating the automatically generated code 60 corresponding to specification 191, and knowledge that should not be used when generating the said automatically generated code 60, as knowledge for generating code related to the specification. When the generating AI generates the automatically generated code 60 that conforms to specification 191, if it uses the knowledge it should use and avoids using the knowledge it should not use, it is expected that the generating AI will produce the automatically generated code 60 that is more in line with specification 191. Furthermore, the knowledge used by the generating AI can be controlled to some extent through instructions via prompt 111. Therefore, prompt 111 is generated with the aim of controlling the knowledge that the generating AI uses when generating the automatically generated code 60.
[0021] The code generation management unit 120 generates automatically generated code 60 using the prompt 111 generated by the prompt generation unit 110 and the inference model 50. Specifically, the code generation management unit 120 inputs the prompt 111 generated by the prompt generation unit 110 to the inference model 50, receives the automatically generated code 60 which is the output of the inference model 50, and commits the received automatically generated code 60 to the version control tool 51. In other words, the code generation management unit 120 generates a second automatically generated code based on the inference model 50 and the second prompt, and commits the generated second automatically generated code to the version control tool 51.
[0022] The automatically generated code 60 is a code corresponding to prompt 111 and is a code generated by the code generation management unit 120. The automatically generated code 60 basically consists of a conforming code 61 and a non-conforming code 62. The automatically generated code 60 may not include at least one of the conforming code 61 and the non-conforming code 62. The automatically generated code 60 may contain non-conforming code 62. That is, the automatically generated code 60 may not fully conform to specification 191 indicated by the corresponding prompt 111. Therefore, the user checks the automatically generated code 60 committed to the version control tool 51, extracts the non-conforming code 62, and generates the finalized code 64 by appropriately modifying the non-conforming code 62 to conform to specification 191 and generating corrected code 63. After that, the user commits the generated finalized code 64 to the version control tool 51. Note that in the modification of non-conforming code 62, the entire non-conforming code 62 may be deleted and corrected code 63 may be newly generated. A user, in this case, is the developer of the software being developed. There may be multiple users.
[0023] Compliant code 61 is a code among the corresponding automatically generated codes 60 that is not a non-compliant code 62, is a code among the corresponding automatically generated codes 60 that has been adopted, is a code that conforms to specification 191 corresponding to the corresponding automatically generated code 60, is a code that the inference model 50 should generate, and is a code that should be included in the corresponding definitive code 64.
[0024] Non-conforming code 62 is a code among the corresponding automatically generated codes 60 that is not conforming code 61, a code among the corresponding automatically generated codes 60 that was rejected, a code that does not conform to specification 191 corresponding to the corresponding automatically generated code 60, a code that the inference model 50 should not generate, and a code that should not be included in confirmed code 64. Non-conforming code 62 includes, as specific examples, at least one of the following: code that does not conform to the software specifications set forth in the corresponding specification 191; code that does not conform to the coding conventions set forth in the corresponding specification 191; and code that does not conform to the programming language grammar rules set forth in the corresponding specification 191.
[0025] Correction code 63 is a code associated with nonconformity code 62, a code in which the nonconformity cause of nonconformity code 62 has been resolved, and a code generated by correcting nonconformity code 62 based on specification 191 corresponding to the corresponding automatically generated code 60. Correction code 63 is the code that should have been generated based on specification 191 corresponding to the corresponding automatically generated code 60.
[0026] Confirmed code 64 is a code generated by correcting non-conforming code 62 included in the corresponding automatically generated code 60, and is a code that conforms to the corresponding specification 191. Confirmation code 64 consists of the corresponding conformance code 61 and correction code 63.
[0027] Figure 3 illustrates an example of the operation of the code generation device 100. In this example, the inference model 50 is assumed to be a generating AI. The main branch and the AI branch are branches managed by the version control tool 51. The main branch represents each confirmed code 64. The AI branch represents each automatically generated code 60. In actual operation, as a specific example, with the aim of reducing the risk of generating non-conforming code 62, each time specification 191 is revised, generation by the generating AI (AI branch) and creation by the developer (main branch) are performed based on the revised specification 191, and the "information to be passed to the AI next" is updated based on the committed information. Here, past "information to be passed to the AI next" is kept as history. The "information to be passed to the AI next" is the information contained in prompt 111. In this embodiment, a learning model linking specification 191 and code is not created in advance. However, in this embodiment, by combining the inference model 50 and the version control tool 51, the inference model 50 generates code based on specification 191 while understanding, through prompt 111, examples that the inference model 50 may generate (compliant code 61) and examples that the inference model 50 should not generate (non-compliant code 62). That is, when the inference model 50 is a generative AI, prompt 111 narrows down the knowledge of the generative AI to the code corresponding to specification 191.
[0028] First, a prompt 111 containing the initially created specification 191 is created, and based on the prompt 111, the inference model 50 generates automatically generated code 60, which is then committed to the version control tool 51. Subsequently, the user appropriately corrects the non-conforming code 62 contained in the automatically generated code 60 to generate the finalized code 64, and commits the generated finalized code 64 to the version control tool 51.
[0029] Next, the most recently used specification 191, the revised specification 191 of the most recently used specification 191, the conforming code 61 and non-conforming code 62 included in the most recently generated automatic code 60, and the most recently generated correction code 63 are added to the existing prompt 111 to generate a new prompt 111. Based on the newly generated prompt 111, the inference model 50 generates the automatic code 60, and the generated automatic code 60 is committed to the version control tool 51. Subsequently, the user appropriately corrects the non-conforming code 62 included in the automatic code 60 to generate the final code 64, and commits the generated final code 64 to the version control tool 51. Here, the information added to prompt 111 is considered reference information. The same process will be performed each time Specification 191 is further revised.
[0030] Figures 4 to 6 illustrate the code committed to the version control tool 51. In the following description of the code committed to the version control tool 51, the inference model 50 is assumed to be a generative AI.
[0031] The prompt 111 shown on the left side of Figure 4 illustrates a specific example of Specification 191. This Specification 191 corresponds to Specification 1. The right side of Figure 4 shows a specific example of the automatically generated code 60 generated based on the prompt 111, which has been committed to the version control tool 51 by the code generation management unit 120. This automatically generated code 60 corresponds to the first automatically generated code. The user generates final code 64 by modifying the committed automated code 60, and commits the generated final code 64 to the version control tool 51. At this time, the user may also commit specification 191 to the version control tool 51 together with final code 64.
[0032] The right side of Figure 5 shows a specific example of a confirmed code 64 committed by the user to the version control tool 51. This confirmed code 64 is the first confirmed code. The conforming code 61, the non-conforming code 62, and the correction code 63 are each determined based on the automatically generated code 60 and the confirmed code 64. Each line without a prefix is a code from the automatically generated code 60 that the user has confirmed and adopted, i.e., a compliant code 61. Each line preceded by a "-" is a code that the user deleted from the automatically generated code 60, i.e., a non-compliant code 62. Each line preceded by a "+" is a code added by the user to the automatically generated code 60, i.e., a modified code 63. Confirmation code 64 consists of rows that have nothing at the beginning and rows that have a "+" at the beginning.
[0033] The left side of Figure 6 shows prompt 111 generated by the prompt generation unit 110 after specification 191 was revised. Prompt 111 indicates the revised specification 191. This specification 191 corresponds to either the first or second specification. In addition, prompt 111 shows, as reference information, the pre-revision specification 191 and the corresponding conformance code 61, non-conformance code 62, and correction code 63. This reference information corresponds to either the first or second reference information. The right side of Figure 6 shows the automatically generated code 60 generated based on the prompt 111 shown on the left side of Figure 6. This automatically generated code 60 corresponds to either the first automatically generated code or the second automatically generated code. By adding reference information to prompt 111, the inference model 50 understood the compliant code 61 and non-compliant code 62, and generated an automatically generated code 60 that more closely conformed to specification 191. Specifically, in the automatically generated code 60, the proportion of compliant codes 61 became relatively higher, and the proportion of non-compliant codes 62 became relatively lower.
[0034] Figures 7 and 8 illustrate the code committed to the version control tool 51, and are diagrams illustrating another specific example. The prompt 111 shown on the left side of Figure 7 indicates specification 191. The right side of Figure 7 shows a specific example of the automatically generated code 60 that was generated based on the prompt 111 and committed to the version control tool 51 by the code generation management unit 120.
[0035] The prompt 111 shown on the left side of Figure 8 represents the same specification 191 as specification 191 in Figure 7. In addition, this prompt 111 includes supplementary information generated when the calendar program was previously created. This supplementary information includes constraint information. Specifically, the history of modifications made from the notation "a+=b" to the notation "a=a+b" constitutes the constraint information. The right side of Figure 8 shows a specific example of the automatically generated code 60 that was generated based on the prompt 111 and committed to the version control tool 51 by the code generation management unit 120. The right side of Figure 7 includes non-conforming code 62 that does not follow the coding conventions. On the other hand, on the right side of Figure 8, the inference model 50 has understood, through reference information, which codes follow the coding conventions and which do not. Therefore, the code corresponding to the non-conforming code 62 on the right side of Figure 7 has become a compliant code 61 that follows the coding conventions. Here, the user is not explicitly instructing the inference model 50 to use the notation "a=a+b" instead of "a+=b". However, by supplementing the data modified by the user using the revision history of the version control tool 51, and including constraint information, at prompt 111, the inference model 50 becomes more capable of generating the code that the user expects.
[0036] Figures 9 to 11 illustrate the code committed to the version control tool 51 and show specific examples of conforming to the format. The prompt 111 shown on the left side of Figure 9 indicates instructions to be output in C language, in addition to the specification 191. These instructions constitute constraint information. The right side of Figures 9 and 10 shows a concrete example of the finalized code 64, which was created by a user who modified the automatically generated code 60 generated based on the prompt 111 and committed it to the version control tool 51. The user added comments and modified function names to conform to the coding conventions. In other words, the comments were not generated in the automatically generated code 60, and the naming conventions for the functions violated the coding conventions.
[0037] Figure 11 corresponds to Figures 9 and 10. The prompt 111 shown on the left side of Figure 11 represents specification 191. Additionally, this prompt 111 includes supplementary information generated when a calendar program was previously created. The right side of Figure 11 shows a specific example of the automatically generated code 60 generated based on the prompt 111, which has been committed to the version control tool 51 by the code generation management unit 120. Unlike the automatically generated code 60 corresponding to the right sides of Figures 9 and 10, the inference model 50 has understood the rules for adding comments and the naming conventions for functions through reference information, so that each comment is generated in accordance with the coding conventions and the naming conventions for each function conform to the coding conventions. In this way, the inference model 50 can be guided through the reference information in prompt 111 to generate code that adheres as closely as possible to coding conventions and to generate code that conforms as closely as possible to the style of code developed by companies and other organizations.
[0038] Figure 12 shows an example of the hardware configuration of the code generation device 100 according to this embodiment. The code generation device 100 consists of a computer. The code generation device 100 may consist of multiple computers.
[0039] As shown in this figure, the code generation device 100 is a computer equipped with hardware such as a processor 11, memory 12, auxiliary storage device 13, input / output interface 14, and communication device 15. These hardware components are appropriately connected via signal lines 19.
[0040] The processor 11 is an integrated circuit (IC) that performs arithmetic operations and controls the hardware of the computer. Specific examples of the processor 11 include a CPU (Central Processing Unit), a DSP (Digital Signal Processor), or a GPU (Graphics Processing Unit). The code generation device 100 may include multiple processors that replace the processor 11. The multiple processors share the role of the processor 11.
[0041] Memory 12 is typically a volatile storage device, specifically RAM (Random Access Memory). Memory 12 is also called main memory. Data stored in memory 12 is saved to auxiliary storage device 13 as needed.
[0042] The auxiliary storage device 13 is typically a non-volatile storage device, specifically a ROM (Read Only Memory), an HDD (Hard Disk Drive), or flash memory. Data stored in the auxiliary storage device 13 is loaded into memory 12 as needed. The memory 12 and the auxiliary storage device 13 may be configured as a single unit.
[0043] Input / Output IF14 is a port to which input and output devices are connected. A specific example of an input / output IF14 is a USB (Universal Serial Bus) terminal. Specific examples of input devices include a keyboard and mouse. Specific examples of output devices include a display.
[0044] The communication device 15 consists of a receiver and a transmitter. A specific example of the communication device 15 is a communication chip or a NIC (Network Interface Card).
[0045] Each part of the code generation device 100 may use the input / output IF 14 and the communication device 15 as appropriate when communicating with other devices.
[0046] The auxiliary storage device 13 stores the code generation program. The code generation program is a program that enables the computer to implement the functions of each part of the code generation device 100. The code generation program is loaded into memory 12 and executed by the processor 11.
[0047] Data used when executing the code generation program, and data obtained by executing the code generation program, are appropriately stored in a memory device. Each part of the code generation device 100 utilizes the memory device as appropriate. The memory device consists of, specifically, memory 12, auxiliary memory device 13, registers in the processor 11, and at least one of the cache memory in the processor 11. Note that the terms data and information are sometimes synonymous. The memory device may be independent of the computer. The functions of memory 12 and auxiliary storage device 13 may be implemented by other storage devices.
[0048] The code generation program may be recorded on a computer-readable non-volatile recording medium. Specific examples of non-volatile recording media include optical discs or flash memory. The code generation program may also be provided as a program product.
[0049] ***Explanation of operation*** The operating procedure of the code generation device 100 corresponds to the code generation method. Furthermore, the program that implements the operation of the code generation device 100 corresponds to the code generation program.
[0050] Figure 13 is a flowchart illustrating an example of the operation of the code generation device 100. This operation will be explained using Figure 13.
[0051] (Step S101) The prompt generation unit 110 generates prompt 111 using the given specification 191.
[0052] (Step S102) The code generation management unit 120 generates automatically generated code 60 by inputting the prompt 111 generated by the prompt generation unit 110 to the inference model 50, and commits the generated automatically generated code 60 to the version control tool 51.
[0053] (Step S103) This step is performed each time Specification 191 is revised. First, the prompt generation unit 110 refers to the version control tool 51 and extracts the conformance code 61, the non-conformance code 62, and the correction code 63. Next, the prompt generation unit 110 generates a prompt 111 using the pre- and post-revision specifications 191, and the extracted conformance code 61, non-conformance code 62, and correction code 63.
[0054] ***Explanation of the effects of Embodiment 1*** Conventional techniques generate an inference model that learns the relationship between specifications and the code that should be generated for those specifications. Therefore, it is difficult to generate code for specifications that the inference model has not learned using this inference model. Conventional techniques are a general machine learning approach, and are supervised learning methods that train the inference model to learn conforming code that corresponds to the specifications. On the other hand, in this embodiment, by including each specification 191 and corresponding conformance codes 61, nonconformance codes 62, and correction codes 63 as reference information in the prompt 111, the inference model 50 can formulate a policy regarding the automatically generated code 60 based on its existing knowledge. Therefore, according to this embodiment, even if the inference model 50 has not learned the codes related to specification 191, the inference model 50 can generate the codes related to specification 191 relatively appropriately. Furthermore, as the prompt generation unit 110 and the code generation management unit 120 repeat the processing, the missing information is sequentially filled in by adding reference information to the prompt 111, and the proportion of nonconformance codes 62 becomes relatively smaller. Therefore, by utilizing the code generation device 100, the amount of work that humans have to do to create the codes can be reduced.
[0055] Furthermore, if the task of collecting and providing information on conformance code 61 and non-conformance code 62 is performed manually, the workload would be enormous. In development using the version control tool 51, if the code created by the developer is OK, that code is committed to the version control tool 51. Therefore, the user basically selects the compliant code 61 without being particularly conscious of it. Also, because the version control tool 51 manages the editing history, the prompt generation unit 110 can automatically select the code that has been rejected (non-compliant code 62) from the automatically generated code 60. Therefore, by utilizing a code generation device 100 that combines an inference model 50 and a version control tool 51, "accepted compliant code" and "rejected non-compliant code" are determined unconsciously or automatically within the development flow. Consequently, according to this embodiment, the workload of developers can be reduced.
[0056] The following describes the case where inference model 50 is a generative AI. In this embodiment, the generation AI is not actually trained or fine-tuned. However, according to this embodiment, by generating prompts 111 based on history and difference information, the same effect as training and fine-tuning the inference model 50 can be expected. Furthermore, the cost and time required for training and fine-tuning generative AI are generally enormous due to the use of large amounts of data. On the other hand, simply correcting prompt 111 can significantly reduce the cost and time compared to training and fine-tuning generative AI.
[0057] The generating AI in this embodiment is generated by learning a large amount of correspondence between specifications and code. Therefore, since the generating AI has basically already learned a wide range of general data, it does not require retraining. Consequently, the generating AI can generate some code based on specifications that it has not learned. However, it is not possible to know in advance what the generating AI will return from its broad knowledge of the learning data, and whether or not the code that the developer expects is generated depends on the generating AI. Therefore, an idea can be considered in which the generating AI is instructed via prompt 111 on the scope or direction of the code so that it can generate the code that the developer expects. Common methods for generating appropriate code based on specifications using generative AI include creating a model in which the generative AI has been trained on suitable code 61 through fine tuning, and providing the generative AI with specific examples of suitable code 61 as reference information in the form of FewShots, allowing the generative AI to generate code close to suitable code 61. However, since specification 191 can be created independently of the training data and reference information, there is not necessarily a generating AI that has learned code that conforms to specification 191, nor is appropriate code always provided to the generating AI as reference information. In this case, if conforming code 61 is not provided, the generating AI will attempt to generate code from the vast range of knowledge related to the training data. Therefore, in this embodiment, as concrete examples of code generated based on a certain specification, the generating AI is provided with code adopted for that specification (conforming code 61), code rejected for that specification (non-conforming code 62), and missing code for that specification (correction code 63), thereby narrowing the scope or direction of the code generated by the generating AI to the scope or direction expected by the developer. Furthermore, if a generative AI is generated by learning the relationship between specifications and code, there is a high probability that the generated code will meet the developer's expectations. However, such a generative AI may have low generality. Also, while one of the advantages of generative AI is that it can be used without preparing training data, this advantage cannot be utilized when using such a generative AI.
[0058] ***Other configurations*** <Example 1> Reference information is added to prompt 111 sequentially. Therefore, each time specification 191 is revised, information in prompt 111 accumulates, eventually providing a large amount of data to the inference model 50. In general, providing a large amount of information to the generating AI reduces the accuracy of the response. Also, depending on the quantity and quality of the information, it is thought that accuracy can be ensured without using all the information extracted by the prompt generation unit 110. Therefore, the prompt generation unit 110 may use a mechanism such as RAG (Retrieval-Augmented Generation) to narrow down the information related to the latest specification 191 from previously generated reference information and extracted information, or from the extracted information, and add the narrowed-down information as reference information to the prompt 111. In this case, if specification 191 is managed by a version control tool 51, the prompt generation unit 110 may refer to the version control tool 51 to narrow down the information. In addition, the prompt generation unit 110 may use other methods to generate information that is a summary of previously generated reference information and extracted information, or a summary of the extracted information, as reference information. In other words, the prompt generation unit 110 may generate summary information, which is a summary of the first and second reference information, as information based on the first and second reference information.
[0059] <Modification 2> Figure 14 shows an example of the hardware configuration of the code generation device 100 according to this modified example. The code generation device 100 includes a processor 11, a processor 11 and memory 12, a processor 11 and auxiliary storage device 13, or a processing circuit 18 instead of a processor 11, memory 12 and auxiliary storage device 13. The processing circuit 18 is hardware that implements at least some of the components of the code generation device 100. The processing circuit 18 may be dedicated hardware, or it may be a processor that executes the program stored in memory 12.
[0060] When the processing circuit 18 is dedicated hardware, specific examples of the processing circuit 18 include a single circuit, a composite circuit, a programmed processor, a parallel programmed processor, an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or a combination thereof. The code generation device 100 may include multiple processing circuits that replace the processing circuit 18. The multiple processing circuits share the role of the processing circuit 18.
[0061] In the code generation device 100, some functions may be implemented by dedicated hardware, while the remaining functions may be implemented by software or firmware.
[0062] The processing circuit 18 can be implemented, in specific examples, by hardware, software, firmware, or a combination thereof. The processor 11, memory 12, auxiliary storage device 13, and processing circuit 18 are collectively referred to as the "processing circuitry." In other words, the functions of each functional component of the code generation device 100 are realized by the processing circuitry. The devices according to other embodiments may also have the same configuration as this modified example.
[0063] Embodiment 2. The following will explain the differences from the previously described embodiment, primarily with reference to the drawings.
[0064] ***Explanation of the structure*** Figure 15 shows a code generation system 90 according to this embodiment. The code generation system 90 comprises a code generation device 100 and a code learning device 200. The code generation device 100 according to this embodiment further comprises an input unit 130. The code learning device 200 comprises an input unit 210, a learning unit 220, and an output unit 230. Based on specification 191, the code learning device 200 has a function to provide feedback learning to the inference model 50 using the automatically generated code 60.
[0065] The input unit 210 accepts the automatically generated code 60 and the confirmed code 64 from the version control tool 51. Furthermore, the input unit 210 accepts input of the specification 191 corresponding to each received code. In this case, the input unit 210 may accept the input of the specification 191 from the version control tool 51.
[0066] The learning unit 220 generates second reference information based on the first specification, the first automatically generated code, and the first confirmed code. Specifically, the learning unit 220 generates at least a portion of the input to the inference model 50 based on each data input to the input unit 210. At least a portion of the input is reference information to be included in the prompt 111 as a concrete example. In this case, the input unit 210 may use an inference model such as AI. The inference model may be a model that has learned the difference between the non-conforming code 62 and the corrected code 63. The learning unit 220 may train the inference model it uses to learn the relationship between the difference between the non-conforming code 62 and the corrected code 63 and at least a portion of the input to the inference model 50. Furthermore, each time specification 191 is revised, the learning unit 220 may train the inference model it uses to learn the relationship between the conforming code 61, the non-conforming code 62, the corrected code 63 and at least a portion of the input to the inference model 50. The learning unit 220 may generate a summary of the data received by the input unit 210, or it may generate information using RAG. The learning unit 220 may have functions similar to those of the prompt generation unit 110 according to Embodiment 1. The learning unit 220 may generate information that appropriately includes each specification 191.
[0067] The output unit 230 outputs the information generated by the learning unit 220 to the code generation device 100.
[0068] The input unit 130 receives the output from the code learning device 200.
[0069] The prompt generation unit 110 according to this embodiment appropriately incorporates the functions of the prompt generation unit 110 according to Embodiment 1, receives the output of the code learning device 200 from the input unit 130, and generates a prompt 111 using the revised specification 191 and the received output. The prompt generation unit 110 may use the output of the code learning device 200 as the prompt 111.
[0070] ***Explanation of operation*** Figure 16 is a flowchart illustrating an example of the operation of the code generation system 90. The operation will be explained using Figure 16. Below, the differences from Embodiment 1 will be mainly explained.
[0071] (Step S201) This step is performed each time Specification 191 is revised. The input unit 210 receives the automatically generated code 60 and the confirmed code 64 from the version control tool 51. The input unit 210 also receives the specification 191 corresponding to each of the received codes.
[0072] (Step S202) The learning unit 220 generates information that represents at least a portion of the input to the inference model 50 based on the input received by the input unit 210.
[0073] (Step S203) The output unit 230 outputs the information generated by the learning unit 220 to the code generation device 100.
[0074] (Step S121) The input unit 130 receives the output of the code learning device 200.
[0075] (Step S122) The prompt generation unit 110 generates a prompt 111 based on the specifications 191 before and after the revision, and the input received by the input unit 130.
[0076] ***Explanation of the effects of Embodiment 2*** According to this embodiment, at least a portion of the input to the inference model 50 can be generated using a device different from the code generation device 100.
[0077] ***Other Embodiments*** The embodiments described above can be freely combined, any component of each embodiment can be modified, or any component can be omitted in each embodiment. Furthermore, the embodiments are not limited to those shown in Embodiments 1 and 2, and various modifications can be made as needed. The procedures described using flowcharts and the like may be modified as appropriate.
[0078] The various aspects of this disclosure are summarized below as an appendix.
[0079] (Note 1) An inference model is a model that has learned the relationship between each software specification and the code corresponding to each specification, and generates code based on prompts indicating the software specification. The first automatically generated code generated based on the first prompt indicating the first specification is committed to the version control tool, and the first definitive code generated by modifying the first automatically generated code based on the first specification is committed to the version control tool, and When second reference information is generated regarding the knowledge that the inference model uses when generating the code, based on the first specification, the first non-conforming code included in the first automatically generated code but not in the first confirmed code, the first corrected code included in the first confirmed code but not in the first automatically generated code, and the first conforming code in the first automatically generated code that is not the first non-conforming code, A prompt generation unit generates a second prompt which is a prompt indicating the second specification, which is the specification of the software under development, and the second reference information, and which is a prompt indicating instructions for the inference model. A code generation device equipped with the following features.
[0080] (Note 2) The code generation device according to Appendix 1, wherein the prompt generation unit extracts the first conforming code, the first non-conforming code, and the first corrected code based on the first automatically generated code and the first confirmed code committed to the version control tool, and generates the second reference information based on the extracted first conforming code, first non-conforming code, and first corrected code.
[0081] (Note 3) The first prompt provides first reference information regarding the knowledge that the inference model uses when generating code. The code generation device described in Appendix 2, wherein the prompt generation unit generates a prompt indicating information based on the first reference information and the second reference information as the second prompt.
[0082] (Note 4) The code generation device described in Appendix 3, wherein the prompt generation unit generates summary information which is a summary of the first and second reference information, as information based on the first and second reference information.
[0083] (Note 5) The second specification is a code generation device described in any one of the appendices 1 to 4, which are specifications that revise the first specification.
[0084] (Note 6) The first specification is a code generation device described in any one of the appendices 1 to 4, which are specifications for software different from the software under development.
[0085] (Note 7) A code generation device according to any one of the appendices 1 to 6, wherein at least one of the second specification and the second reference information includes constraint information indicating constraints when developing the software to be developed.
[0086] (Note 8) The code generation device further, A code generation management unit generates a second automatically generated code based on the inference model and the second prompt, and commits the generated second automatically generated code to the version control tool. A code generation device according to any one of the appendices 1 to 7, comprising:
[0087] (Note 9) The aforementioned inference model is a code generation device described in any one of the appendices 1 to 8, which is a generative AI (Artificial Intelligence).
[0088] (Note 10) A learning unit that generates the second reference information based on the first specification, the first automatically generated code, and the first confirmed code. A code learning device equipped with, A code generation device described in any one of the appendices 1 to 9 and A code generation system equipped with the following features. [Explanation of Symbols]
[0089] 11 Processor, 12 Memory, 13 Auxiliary storage device, 14 Input / Output IF, 15 Communication device, 18 Processing circuit, 19 Signal line, 50 Inference model, 51 Version control tool, 60 Auto-generated code, 61 Compliant code, 62 Non-compliant code, 63 Corrected code, 64 Finalized code, 90 Code generation system, 100 Code generation device, 110 Prompt generation unit, 111 Prompt, 120 Code generation management unit, 130 Input unit, 191 Specifications, 200 Code learning device, 210 Input unit, 220 Learning unit, 230 Output unit.
Claims
1. An inference model is a model that has learned the relationship between each specification of the software and the code corresponding to each specification, and generates code based on prompts indicating the software specifications. Based on this inference model and a first prompt indicating a first specification, the first automatically generated code is committed to a version control tool, and the first definitive code generated by modifying the first automatically generated code based on the first specification is committed to the version control tool, and When second reference information relating to the knowledge used by the inference model when generating code is generated based on the first specification, the first non-conforming code included in the first automatically generated code but not in the first confirmed code, the first corrected code included in the first confirmed code but not in the first automatically generated code, and the first conforming code among the first automatically generated code that is not the first non-conforming code, A prompt generation unit generates a second prompt which is a prompt indicating the second specification, which is the specification of the software under development, and the second reference information, and which is a prompt indicating instructions for the inference model. A code generation device equipped with the following features.
2. The code generation device according to claim 1, wherein the prompt generation unit extracts the first conforming code, the first non-conforming code, and the first corrected code based on the first automatically generated code and the first confirmed code committed to the version control tool, and generates the second reference information based on the extracted first conforming code, the first non-conforming code, and the first corrected code.
3. The first prompt provides first reference information regarding the knowledge that the inference model uses when generating code. The code generation device according to claim 2, wherein the prompt generation unit generates a prompt indicating information based on the first reference information and the second reference information as the second prompt.
4. The code generation device according to claim 3, wherein the prompt generation unit generates summary information which is a summary of the first reference information and the second reference information, as information based on the first reference information and the second reference information.
5. The code generation device according to any one of claims 1 to 4, wherein the second specification is a revised specification of the first specification.
6. The code generation device according to any one of claims 1 to 4, wherein the first specification is the specification of software different from the software under development.
7. The code generation device according to any one of claims 1 to 4, wherein at least one of the second specification and the second reference information includes constraint information indicating constraints when developing the software to be developed.
8. The code generation device further, A code generation management unit generates a second automatically generated code based on the inference model and the second prompt, and commits the generated second automatically generated code to the version control tool. A code generation device according to any one of claims 1 to 4, comprising:
9. The code generation device according to any one of claims 1 to 4, wherein the inference model is Artificial Intelligence (Generative AI).
10. A learning unit that generates the second reference information based on the first specification, the first automatically generated code, and the first confirmed code. A code learning device equipped with, A code generation device according to any one of claims 1 to 4 and A code generation system equipped with the following features.
11. An inference model is a model that has learned the relationship between each specification of the software and the code corresponding to each specification, and generates code based on prompts indicating the software specifications. Based on this inference model and a first prompt indicating a first specification, the first automatically generated code is committed to a version control tool, and the first definitive code generated by modifying the first automatically generated code based on the first specification is committed to the version control tool, and When second reference information relating to the knowledge used by the inference model when generating code is generated based on the first specification, the first non-conforming code included in the first automatically generated code but not in the first confirmed code, the first corrected code included in the first confirmed code but not in the first automatically generated code, and the first conforming code among the first automatically generated code that is not the first non-conforming code, A code generation method in which a computer generates a second prompt which is a prompt indicating a second specification, which is the specification of the software under development, and the second reference information, and which is a prompt indicating an instruction to the inference model.
12. An inference model is a model that has learned the relationship between each specification of the software and the code corresponding to each specification, and generates code based on prompts indicating the software specifications. Based on this inference model and a first prompt indicating a first specification, the first automatically generated code is committed to a version control tool, and the first definitive code generated by modifying the first automatically generated code based on the first specification is committed to the version control tool, and When second reference information relating to the knowledge used by the inference model when generating code is generated based on the first specification, the first non-conforming code included in the first automatically generated code but not in the first confirmed code, the first corrected code included in the first confirmed code but not in the first automatically generated code, and the first conforming code among the first automatically generated code that is not the first non-conforming code, A prompt generation process generates a second prompt which is a prompt indicating the second specification, which is the specification of the software under development, and the second reference information, and which is a prompt indicating instructions for the inference model. A code generation program that causes a computer, or code generation device, to execute it.
Citation Information
Patent Citations
PROGRAM, INFORMATION PROCESSING METHOD, AND INFORMATION PROCESSING APPARATUS
JP7564601B1
Performance bug repair via retrieval-augmented neural code generation model
US20240248686A1
Elidable text for prompt crafting
US20240311093A1
Information processor, information processing method, and computer program
JP2014106557A