Code generation device, code generation system, code generation method, and code generation program

The code generation system addresses the challenge of generating code that matches specifications by using an inference model and version control history to refine code generation, ensuring high compliance and reducing manual effort.

JP7777649B1Active Publication Date: 2025-11-28MITSUBISHI ELECTRIC SOFTWARE CORP
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
JP2024181271
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-11-28
Estimated Expiration
2044-10-16

AI Technical Summary

Technical Problem

Existing generative AI technologies struggle to generate code that perfectly matches software specifications, leading to a demand for improved code generation that conforms more closely to these specifications.

Method used

A code generation system that includes an inference model learning the relationship between specifications and code, a prompt generation unit that generates prompts based on compliant, non-compliant, and modified code, and a code generation management unit to refine the generated code, ensuring it aligns with specifications using a version control tool.

Benefits of technology

The system effectively generates code that closely conforms to specifications by leveraging version control history to identify and correct non-compliant code, reducing manual effort and costs associated with traditional training methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007777649000001_ABST
    Figure 0007777649000001_ABST
Patent Text Reader

Abstract

Regarding technology that uses generative AI to automatically generate code based on specifications, we would like to provide technology that enables generative AI to generate code that more closely conforms to the specifications. [Solution] The code generation device 100 includes a prompt generation unit 110 that generates a second prompt indicating the second specification and the second reference information when a first automatically generated code generated based on an inference model 50 and a first prompt indicating the first specification is committed to a version control tool 51, a first finalized code generated by modifying the first automatically generated code based on the first specification is committed to the version control tool 51, and second reference information regarding knowledge used by the inference model 50 when generating code is generated based on the first specification, the first compliant code, the first non-compliant code, and the first modified code.
Need to check novelty before this filing date? Find Prior Art

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 technology]

[0002] In software development, there is a growing demand for automatic code generation. Patent Document 1 discloses a technology that, when code has already been automatically generated and modifications have been made to the automatically generated code, automatically generates new code that reflects the modifications. [Prior art documents] [Patent documents]

[0003] [Patent Document 1] Japanese Patent Application Laid-Open No. 2014-106557 Summary of the Invention [Problem to be solved by the invention]

[0004] Advances in generative AI (artificial intelligence) technology have made it possible to use generative AI to automatically generate code based on specifications. However, since generative AI is generally unable to generate code that perfectly matches the specifications, there is a demand for technology that enables generative AI to generate code that more closely matches the specifications. However, Patent Document 1 does not disclose or suggest any technology that enables a generation AI to generate code that is more compliant with the specifications, with regard to the technology that automatically generates code using a generation AI based on specifications.

[0005] The present disclosure aims to provide a technology for automatically generating code using a generation AI based on specifications, which enables the generation AI to generate code that more closely conforms to the specifications. [Means for solving the problem]

[0006] A code generation device according to the present disclosure includes: an inference model that learns the relationship between each specification of the software and the code corresponding to each specification, and that generates code based on a prompt indicating the software specification; a first automatically generated code generated based on a first prompt indicating a first specification is committed to a version control tool; and a first finalized 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 regarding knowledge used by the inference model when generating code is generated based on the first specification, a first non-compliant code that is included in the first automatically generated code but not included in the first finalized code, a first corrected code that is included in the first finalized code but not included in the first automatically generated code, and a first compliant code in the first automatically generated code that is not the first non-compliant code, a prompt generation unit that generates a second prompt that indicates a second specification, which is a specification of the software to be developed, and the second reference information, and that indicates an instruction to the inference model; Equipped with. [Effects of the Invention]

[0007] According to the present disclosure, a prompt generation unit generates a second prompt indicating a second specification and second reference information. Here, the second reference information is information generated based on the first compliant code, the first noncompliant code, and the first modified code, and is information regarding knowledge used by the inference model when generating code. Therefore, it is considered that the code generated by the inference model based on the second prompt will be code that is more compliant with the second specification. Furthermore, the inference model may be a generative AI. Therefore, according to the present disclosure, a technology can be provided that automatically generates code using a generation AI based on specifications, allowing the generation AI to generate code that more closely conforms to the specifications. [Brief explanation of the drawings]

[0008] [Figure 1] FIG. 1 is a diagram showing an example of the configuration of a code generation system 90 according to a first embodiment. [Figure 2] FIG. 1 is a diagram for explaining the purpose of generating a prompt 111 according to the first embodiment. [Figure 3] 1 is a diagram for explaining an example of operation of the code generating device 100 according to the first embodiment. [Figure 4] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 5] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 6] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 7] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 8] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 9] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 10] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 11] FIG. 2 is a diagram for explaining code committed to a version management tool 51 according to the first embodiment. [Figure 12] FIG. 1 is a diagram showing an example of a hardware configuration of a code generation device 100 according to a first embodiment. [Figure 13] 3 is a flowchart showing the operation of the code generation device 100 according to the first embodiment. [Figure 14] FIG. 10 is a diagram showing an example of a hardware configuration of a code generation device 100 according to a modification of the first embodiment. [Figure 15] FIG. 10 is a diagram showing an example of the configuration of a code generation system 90 according to a second embodiment. [Figure 16] 10 is a flowchart showing the operation of the code generation system 90 according to the second embodiment. DETAILED DESCRIPTION OF THE INVENTION

[0009] In the description of the embodiments and drawings, the same elements and corresponding elements are given the same symbols. Descriptions of elements given the same symbols are omitted or simplified as appropriate. Arrows in the drawings mainly indicate the flow of data or the flow of processing. Furthermore, "unit" may be interpreted as "circuit," "device," "equipment," "process," "step," "procedure," "processing," or "circuitry" as appropriate. The functions of each unit in each device may be realized by firmware, software, hardware, or a combination of these.

[0010] Embodiment 1 Hereinafter, this embodiment will be described in detail with reference to the drawings.

[0011] ***Configuration Description*** 1 shows an example of the configuration of a code generation system 90 according to this embodiment. The code generation system 90 comprises an inference model 50, a version management tool 51, and a code generation device 100.

[0012] The inference model 50 is a model that learns the relationship between each software specification and the code corresponding to each software specification, and generates code based on a prompt indicating the software specification, and is a model that takes a prompt 111 as input and infers automatically generated code 60 as code corresponding to the input prompt 111. Specific examples of the inference model 50 include generative AI (Artificial Intelligence) such as LLM (Large Language Models), or other machine learning models.

[0013] The version management tool 51 is a tool that has a function of managing and sharing the edit history of code, and is also called a version control system. Specific examples of the version management tool 51 include GitHub (registered trademark) and TortoiseSVN.

[0014] 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 include an inference model 50 or may access an external inference model 50. The code generation device 100 may include a version control tool 51 or may access an external version control tool 51. As a specific example, the code generating device 100 is used when developing software to be developed based on a specification 191 using a version management tool 51. The software to be developed is software that complies with the specification 191 and is the software that is the subject of development.

[0015] The specification 191 is information indicating the specifications of the software to be developed, and is information indicating natural language. The specification 191 may include diagrams, tables, etc. The specification 191 is to be revised sequentially in response to the addition, modification, or deletion of functions related to the software to be developed. In other words, the specification 191 is to be corrected, changed, added, and deleted as appropriate. Each time the specification 191 is revised, the automatically generated code 60, etc. is newly generated. The specification 191 may also be information indicating constraint information. The specification 191 may be committed to the version management tool 51. Committing data to the version management tool 51 is equivalent to registering data in the version management tool 51. The constraint information is information that indicates various constraints when developing the target software. For example, the constraint information consists of information that indicates coding conventions and information that indicates the grammar rules of the programming language used when developing the target software.

[0016] The prompt generator 110 generates the prompt 111 by referring to the information committed to the version management tool 51 each time the specification 191 is revised. When generating prompt 111 for the first time, prompt generator 110 generates prompt 111 using specification 191. This is because compliant code 61, non-compliant code 62, and modified code 63 do not exist because automatically generated code 60 has not yet been generated. When generating the prompt 111 for the second or subsequent times, the prompt generation unit 110 extracts the differences between the automatically generated code 60 and the confirmed code 64, and designates the codes included in the automatically generated code 60 but not included in the confirmed code 64 as noncompliant codes 62, and the codes included in the confirmed code 64 but not included in the automatically generated code 60 as corrected codes 63. The prompt generation unit 110 also designates the codes included in the confirmed code 64 but not corrected codes 63 as compliant codes 61. The prompt generation unit 110 then generates a new prompt 111 by adding information indicating the specification 191 most recently given to the inference model 50, the compliant code 61 corresponding to the specification 191, the noncompliant 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 differences include the noncompliant code 62 and the corrected code 63. The prompt generation unit 110 can extract the differences even if a common code is not prepared.

[0017] Furthermore, the prompt generation unit 110 may generate the prompt 111 based on the automatically generated code 60 and the finalized code 64 that were generated during the development of software different from the software being developed. As a specific example, when the similarity between the specification 191 and another specification, which is the specification of the other software, falls within a predetermined allowable range, the prompt 111 reuses at least a part of the other prompt. The other prompt is a prompt 111 that was generated by utilizing the code generating device 100 when other software was previously developed. The separate software is software that is separate from the software being developed. The tolerance range may be set in any manner. The tolerance range may be set depending on the nature and content of the specification 191. 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 the specifications each time specification 191 is revised, and determine whether to reuse another prompt according to the calculated similarity. The prompt generation unit 110 may calculate the similarity of each part of the other specification to at least a part of specification 191, and reuse only the description of the other prompt that corresponds to the part 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 management tool 51, the first confirmed code is committed to the version management tool 51, and second reference information is generated based on the first specification, the first non-compliant code, the first modified code, and the first compliant code. Here, the prompt generation unit 110 extracts the first compliant code, the first non-compliant code, and the first modified code based on the first automatically generated code and the first confirmed code committed to the version management tool 51, and generates the second reference information based on the extracted first compliant code, the first non-compliant code, and the first modified code. The prompt generation unit 110 may generate, as the second prompt, a prompt 111 indicating 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, for example, information indicating the first reference information and the second reference information. The first automatically generated code is an automatically generated code 60 generated based on an inference model 50 and a first prompt indicating a first specification. The first compliant code is the compliant code 61 that is not the first non-compliant code among the first automatically generated codes. The first nonconformance code is a nonconformance code 62 that is included in the first automatically generated code but is not included in the first finalized code. The first correction code is a correction code 63 that is included in the first defined code but not included in the first automatically generated code. The first defined code is a defined code 64 generated by modifying the first automatically generated code based on the first specification. The second reference information is information about knowledge used when generating code by the inference model 50. The second reference information may include constraint information. The first prompt is a prompt 111 that indicates an instruction to the inference model 50. The first prompt may indicate first reference information regarding knowledge that the inference model 50 uses when generating code. The first reference information may include constraint information. The instruction to the inference model 50 is basically information that includes natural language. The second prompt is a prompt 111 that indicates a second specification and second reference information, and is a prompt 111 that indicates instructions to the inference model 50. The first specification may be the specification of the software under development, or may be the specification of software different from the software under development. The second specification is a specification of the software to be developed. The second specification may be a revised version of the first specification. The second specification may include constraint information.

[0019] The prompt 111 is an input to the inference model 50. The first generated prompt 111 is information indicating the specification 191. Each prompt 111 generated after the first is information that accumulates the specification 191, compliant code 61, non-compliant code 62, and modified code 63. The prompts 111 may be managed by a version control tool 51 .

[0020] 2 is a diagram illustrating the purpose of generating prompt 111. In FIG. 2, inference model 50 is assumed to be a generation AI. The generation AI has various knowledge, and as knowledge of code generation related to specifications, it has knowledge that should be used when generating automatically generated code 60 corresponding to specification 191 and knowledge that should not be used when generating the automatically generated code 60. If the generation AI uses knowledge that should be used and does not use knowledge that should not be used when generating automatically generated code 60 corresponding to specification 191, it is believed that the generation AI will generate automatically generated code 60 that is more in line with specification 191. Furthermore, the knowledge used by the generation AI can be controlled to some extent by instructions via prompt 111. Therefore, a prompt is generated as prompt 111 with the aim of controlling the knowledge used by the generation AI when generating 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 that is the output of the inference model 50, and commits the received automatically generated code 60 to the version management tool 51. That is, the code generation management unit 120 generates 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 management tool 51.

[0022] The automatically generated code 60 is code corresponding to the prompt 111 and is generated by the code generation management unit 120. The automatically generated code 60 basically consists of compliant code 61 and non-compliant code 62. The automatically generated code 60 does not necessarily include at least one of the compliant code 61 and the non-compliant code 62. The automatically generated code 60 may contain non-compliant code 62. In other words, the automatically generated code 60 may not completely conform to the specification 191 indicated by the corresponding prompt 111. For this reason, the user checks the automatically generated code 60 committed to the version control tool 51, extracts the non-compliant code 62, and generates fixed code 63 by appropriately modifying the non-compliant code 62 so that it conforms to the specification 191, thereby generating finalized code 64. The user then commits the generated finalized code 64 to the version control tool 51. Note that when modifying the non-compliant code 62, the entire non-compliant code 62 may be deleted and new fixed code 63 may be generated. A specific example of the user is the developer of the software being developed. There may be multiple users.

[0023] Compliant code 61 is code among the corresponding automatically generated code 60 that is not non-compliant code 62, is adopted code among the corresponding automatically generated code 60, is code that conforms to specification 191 corresponding to the corresponding automatically generated code 60, is code that should be generated by inference model 50, and is code that should be included in the corresponding confirmed code 64.

[0024] Non-compliant code 62 is code that is not compliant code 61 among the corresponding automatically generated code 60, code that has been rejected among the corresponding automatically generated code 60, code that does not conform to specification 191 corresponding to the corresponding automatically generated code 60, code that should not be generated by inference model 50, and code that should not be included in final code 64. Specific examples of non-compliant code 62 include at least one of code that does not conform to the software specifications indicated by the corresponding specification 191, code that does not conform to the coding conventions indicated by the corresponding specification 191, and code that does not conform to the grammatical rules of the programming language indicated by the corresponding specification 191.

[0025] Corrected code 63 is code associated with non-compliant code 62, is code in which the reason for the non-compliance of non-compliant code 62 has been resolved, and is code generated by correcting non-compliant code 62 based on specification 191 corresponding to corresponding automatically generated code 60. Corrected code 63 corresponds to code that should have been generated based on specification 191 corresponding to corresponding automatically generated code 60.

[0026] The finalized code 64 is generated by correcting the non-compliant code 62 contained in the corresponding automatically generated code 60, and is code that complies with the corresponding specification 191. The determined code 64 consists of the corresponding adapted code 61 and corrected code 63 .

[0027] FIG. 3 is a diagram illustrating an example of operation of the code generation device 100. In this example, the inference model 50 is assumed to be a generation AI. The main branch and the AI ​​branch are each 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-compliant code 62, each time the specification 191 is revised, generation by the generation 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, the past "information to be passed to the AI ​​next" is kept as history. The "information to be passed to the AI ​​next" is information included in the prompt 111. In this embodiment, a learning model linking the specification 191 and the code is not created in advance. However, in this embodiment, by combining the inference model 50 with the version management tool 51, the inference model 50 generates code based on the specification 191 while understanding examples that the inference model 50 may generate (compliant code 61) and examples that the inference model 50 must not generate (non-compliant code 62) through the prompt 111. In other words, when the inference model 50 is a generation AI, the prompt 111 narrows down the knowledge about the code corresponding to the specification 191 from the vast knowledge of the generation AI.

[0028] First, a prompt 111 is created that includes the initially created specification 191, and then an inference model 50 generates automatically generated code 60 based on the prompt 111. The generated automatically generated code 60 is then committed to a version management tool 51. After that, the user appropriately corrects non-compliant code 62 included in the automatically generated code 60 to generate finalized code 64, and commits the generated finalized code 64 to the version management tool 51.

[0029] Next, a new prompt 111 is generated by adding to the existing prompt 111 the most recently used specification 191, the revised specification 191 of the most recently used specification 191, the compliant code 61 and non-compliant code 62 contained in the most recently generated automatically generated code 60, and the most recently generated modified code 63, and the inference model 50 generates the automatically generated code 60 based on the newly generated prompt 111, and the generated automatically generated code 60 is committed to the version management tool 51. Thereafter, the user appropriately modifies the non-compliant code 62 contained in the automatically generated code 60 to generate finalized code 64, and commits the generated finalized code 64 to the version management tool 51. Here, the information added to the prompt 111 corresponds to reference information. The same process will be carried out each time Specification 191 is further revised.

[0030] 4 to 6 are diagrams illustrating the code committed to the version management tool 51. In the following description of the code committed to the version management tool 51, it is assumed that the inference model 50 is a generative AI.

[0031] 4 shows a specific example of the specification 191. The specification 191 corresponds to the first specification. 4 shows a specific example of automatically generated code 60 that is generated based on the prompt 111 and that has been committed to the version management tool 51 by the code generation management unit 120. This automatically generated code 60 corresponds to the first automatically generated code. The user generates finalized code 64 by modifying the committed automatically generated code 60, and commits the generated finalized code 64 to the version management tool 51. At this time, the user may also commit the specification 191 to the version management tool 51 together with the finalized code 64.

[0032] 5 shows a specific example of confirmed code 64 committed by the user to the version control tool 51. This confirmed code 64 corresponds to the first confirmed code. Compliant code 61, non-compliant code 62, and modified code 63 are each determined based on the automatically generated code 60 and the confirmed code 64. Each line with nothing at the beginning is code that the user has checked and adopted from the automatically generated code 60, that is, compliant code 61. Each line prefixed with "-" is code that the user has deleted from the automatically generated code 60, that is, non-compliant code 62. Each line prefixed with “+” is code added by the user to the automatically generated code 60, that is, modified code 63. The defined code 64 consists of lines that start with nothing and lines that start with a "+".

[0033] The left side of Figure 6 shows prompt 111 generated by prompt generator 110 after specification 191 is revised. Prompt 111 shows revised specification 191. This specification 191 corresponds to the first specification or the second specification. Prompt 111 also shows, as reference information, specification 191 before the revision, and compliant code 61, non-compliant code 62, and modified code 63 corresponding to specification 191 before the revision. This reference information corresponds to the first reference information or the second reference information. The right side of Fig. 6 shows automatically generated code 60 generated based on the prompt 111 shown on the left side of Fig. 6. The automatically generated code 60 corresponds to the first automatically generated code or the second automatically generated code. By adding reference information to prompt 111, inference model 50 understood compliant code 61 and non-compliant code 62, and generated automatically generated code 60 that was more in line with specification 191. That is, in automatically generated code 60, the proportion of compliant code 61 became relatively high, and the proportion of non-compliant code 62 became relatively low.

[0034] 7 and 8 are diagrams for explaining code committed to the version management tool 51, showing another specific example. The prompt 111 shown on the left side of FIG. The right side of FIG. 7 shows a specific example of the automatically generated code 60 that is generated based on the prompt 111 and that has been committed to the version management tool 51 by the code generation management unit 120.

[0035] The prompt 111 shown on the left side of FIG. 8 shows the same specifications 191 as the specifications 191 in FIG. 7. Furthermore, information generated when a calendar program was generated in the past has been added to the prompt 111 as reference information. The reference information includes constraint information. Specifically, the history of correcting the notation "a+=b" to "a=a+b" corresponds to the constraint information. The right side of FIG. 8 shows a specific example of automatically generated code 60 that is generated based on the prompt 111 and that has been committed to the version management tool 51 by the code generation management unit 120. The right side of Figure 7 includes non-compliant code 62 that does not comply with the coding conventions. On the other hand, on the right side of Figure 8, the inference model 50 has understood the code that complies with the coding conventions and the code that does not comply with the coding conventions through reference information, so the code that corresponds to the non-compliant code 62 on the right side of Figure 7 has become compliant code 61 that complies with the coding conventions. Here, the user does not explicitly instruct the inference model 50 to use the notation "a=a+b" instead of "a+=b." However, by utilizing the revision history of the version control tool 51 to supplement the prompt 111 with data modified by the user and including constraint information, the inference model 50 can more easily generate code that the user expects.

[0036] 9 to 11 are diagrams for explaining code committed to the version control tool 51, and are diagrams showing specific examples of format adaptation. 9 indicates an instruction to be output in C language in addition to the specification 191. This instruction corresponds to constraint information. 9 and 10 show a specific example of finalized code 64 that the user modified from the automatically generated code 60 generated based on the prompt 111 and committed to the version control tool 51. The user added comments and modified the 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 convention for the function names violated the coding conventions.

[0037] FIG. 11 is a diagram corresponding to FIGS. 11 shows the specifications 191. Furthermore, the prompt 111 includes, as reference information, information that was generated when a calendar program was generated in the past. The right side of Figure 11 shows a specific example of automatically generated code 60 generated based on the prompt 111 and committed to the version management tool 51 by the code generation management unit 120. The right side of Figure 11 differs from the automatically generated code 60 corresponding to the right side of Figures 9 and 10 in that the inference model 50 has understood the comment addition rules and function naming rules through reference information, and therefore each comment is generated to conform to the coding rules, and the naming rules for each function conform to the coding rules. In this way, through the reference information in prompt 111, the inference model 50 can be guided to generate code that conforms as closely as possible to coding conventions and to generate code that conforms as closely as possible to the code style developed by a company or the like.

[0038] 12 shows an example of the hardware configuration of a code generation device 100 according to this embodiment. The code generation device 100 is made up of a computer. The code generation device 100 may be made up of multiple computers.

[0039] As shown in the figure, the code generation device 100 is a computer that includes hardware such as a processor 11, a memory 12, an auxiliary storage device 13, an input / output IF (Interface) 14, and a communication device 15. These pieces of hardware are appropriately connected via signal lines 19.

[0040] The processor 11 is an integrated circuit (IC) that performs arithmetic processing and controls the hardware of the computer. Specific examples of the processor 11 include a central processing unit (CPU), a digital signal processor (DSP), or a graphics processing unit (GPU). The code generating device 100 may include multiple processors that replace the processor 11. The multiple processors share the role of the processor 11.

[0041] The memory 12 is typically a volatile storage device, specifically a random access memory (RAM). The memory 12 is also called a primary storage device or a main memory. Data stored in the memory 12 is saved in the secondary storage device 13 as needed.

[0042] The auxiliary storage device 13 is typically a non-volatile storage device, and specific examples thereof include a ROM (Read Only Memory), an HDD (Hard Disk Drive), or a flash memory. Data stored in the auxiliary storage device 13 is loaded into the memory 12 as needed. The memory 12 and the auxiliary storage device 13 may be integrated into one unit.

[0043] The input / output IF 14 is a port to which an input device and an output device are connected. A specific example of the input / output IF 14 is a USB (Universal Serial Bus) terminal. Specific examples of the input device are a keyboard and a mouse. A specific example of the output device is a display.

[0044] The communication device 15 is a receiver and a transmitter, and is, for example, a communication chip or a network interface card (NIC).

[0045] Each unit 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 a code generation program. The code generation program is a program that causes a computer to realize the functions of each unit included in the code generation device 100. The code generation program is loaded into the 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 stored in a storage device as appropriate. Each part of the code generation device 100 uses a storage device as appropriate. Specific examples of the storage device include at least one of the memory 12, the auxiliary storage device 13, a register in the processor 11, and a cache memory in the processor 11. Note that the terms "data" and "information" may have the same meaning. The storage device may be independent of the computer. The functions of the memory 12 and the auxiliary storage device 13 may be realized by other storage devices.

[0048] The code generation program may be stored in a computer-readable non-volatile storage medium. Specific examples of the non-volatile storage medium include an optical disk and a flash memory. The code generation program may be provided as a program product.

[0049] ***Explanation of Operation*** The operating procedure of the code generating device 100 corresponds to a code generating method, and the program that realizes the operation of the code generating device 100 corresponds to a code generating program.

[0050] 13 is a flowchart showing an example of the operation of the code generation device 100. The operation will be described with reference to FIG.

[0051] (Step S101) The prompt generator 110 generates a 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 into the inference model 50, and commits the generated automatically generated code 60 to the version management tool 51.

[0053] (Step S103) This step is performed each time the specification 191 is revised. First, prompt generator 110 refers to version management tool 51 and extracts compliant code 61, non-compliant code 62, and modified code 63. Next, prompt generator 110 generates prompt 111 using pre- and post-revision specifications 191 and the extracted compliant code 61, non-compliant code 62, and corrected code 63.

[0054] ***Explanation of the effect of the first embodiment*** In the conventional technology, an inference model is generated that has learned the relationship between specifications and the code to be generated for the specifications, so it is difficult to use the inference model to generate code for specifications that the inference model has not learned. Note that the conventional technology is a general machine learning approach, and is supervised learning in which the inference model learns compliant code corresponding to the specifications. On the other hand, in this embodiment, by including each specification 191 and the compliant code 61, non-compliant code 62, and modified code 63 corresponding to each specification 191 as reference information in the prompt 111, a policy for the automatically generated code 60 is established based on the knowledge held by the inference model 50. Therefore, according to this embodiment, even if the inference model 50 has not learned the code related to the specification 191, the inference model 50 can generate the code related to the specification 191 relatively appropriately. Furthermore, as the prompt generation unit 110 and the code generation management unit 120 repeat the process, reference information is added to the prompt 111, thereby sequentially filling in the missing information, and the proportion of non-compliant code 62 becomes relatively smaller. Therefore, by utilizing the code generation device 100, the work of creating code by hand can be reduced.

[0055] Furthermore, if the information on the compliant code 61 and the non-compliant code 62 is collected and provided manually, the workload will be enormous. Here, in development using version management tool 51, if the code created by the developer is OK, the code is committed to version management tool 51. Therefore, the user basically selects compliant code 61 without being particularly conscious of the need to select compliant code 61. Furthermore, because version management tool 51 manages the editing history, prompt generation unit 110 can automatically select rejected code (non-compliant code 62) from automatically generated code 60. Therefore, by utilizing the code generation device 100 that combines the inference model 50 and the version management tool 51, the "adopted compliant code" and the "rejected non-compliant code" are determined unconsciously or automatically during the development flow. Therefore, according to this embodiment, the workload of the developer can be reduced.

[0056] Below, we will explain the case where the inference model 50 is a generative AI. In this embodiment, the generation AI is not actually trained or fine-tuned, but by generating prompt 111 based on history and difference information, the present embodiment is expected to achieve the same effects as training and fine-tuning of inference model 50. In addition, the cost and time required for training and fine-tuning a generative AI are generally enormous due to the use of large amounts of data. On the other hand, if only the prompt 111 is modified, the cost and time required can be significantly reduced compared to training and fine-tuning a generative AI.

[0057] The generation AI according to this embodiment is generated by learning a large amount of correspondence between specifications and code. Therefore, the generation AI has basically learned a wide range of general data and therefore does not need to be re-learned. Therefore, the generation AI can generate some code based on unlearned specifications. However, it is not known in advance what the generation AI will return from its broad knowledge of the learning data, and it is up to the generation AI whether or not it generates code that meets the developer's expectations. Therefore, one idea is to instruct the generation AI on the scope or direction of the code through prompt 111 so that the generation AI can generate the code that the developer expects. Common methods for using generative AI to generate appropriate code based on specifications include creating a model in which the generative AI learns the adaptive code 61 through fine tuning, and providing the generative AI with specific examples of adaptive code 61 as reference information as a few shots, causing the generative AI to generate code that is close to the adaptive code 61. However, because the specification 191 can be created regardless of the training data and reference information, it is not necessarily the case that a generation AI has learned code that conforms to the specification 191, and appropriate code is not always provided to the generation AI as reference information. If compliant code 61 is not provided, the generation AI attempts to generate code from a vast range of knowledge related to the training data. Therefore, in this embodiment, the generation AI is provided with specific examples of code generated based on a certain specification, including code adopted for that specification (compliant code 61), code rejected for that specification (non-compliant code 62), and code that is missing for that specification (corrected code 63), thereby narrowing the range or direction of the code generated by the generation AI to the range or direction expected by the developer. Furthermore, if a generative AI is generated by learning the relationship between specifications and code, it is highly likely to generate the code that the developer expects. However, the generative AI generated in this way may have low versatility. 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 a generative AI generated in this way.

[0058] ***Other Configurations*** <Variation 1> Reference information is added sequentially to the prompt 111. Therefore, each time the specification 191 is revised, information in the prompt 111 accumulates, and eventually a large amount of data is provided to the inference model 50. Here, providing a large amount of information to the generation AI generally reduces the accuracy of the answer. Also, depending on the quantity and quality of the information, it is considered that accuracy can be ensured without using all of the information extracted by the prompt generation unit 110. Therefore, the prompt generation unit 110 may narrow down the previously generated reference information and extracted information, or the extracted information, to only information related to the latest specification 191 by using a mechanism such as RAG (Retrieval-Augmented Generation), and add the narrowed down information as reference information to the prompt 111. In this case, if the specification 191 is managed by a version management tool 51, the prompt generation unit 110 may narrow down the information by referring to the version management tool 51. Furthermore, the prompt generation unit 110 may generate, as reference information, a summary of the previously generated reference information and extracted information, or information equivalent to a summary of the extracted information, by using another method. That is, the prompt generating section 110 may generate summary information that 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.

[0059] <Variation 2> FIG. 14 shows an example of the hardware configuration of the code generation device 100 according to this modification. The code generating device 100 includes a processing circuit 18 in place of the processor 11, the processor 11 and memory 12, the processor 11 and auxiliary storage device 13, or the processor 11, memory 12, and auxiliary storage device 13. The processing circuitry 18 is hardware that realizes at least some of the components of the code generation device 100 . The processing circuitry 18 may be dedicated hardware or may be a processor that executes a program stored in the memory 12 .

[0060] When processing circuitry 18 is dedicated hardware, processing circuitry 18 may be, for example, 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 generating device 100 may include a plurality of processing circuits that replace the processing circuit 18. The plurality of processing circuits share the role of the processing circuit 18.

[0061] In the code generating device 100, some functions may be realized by dedicated hardware, and the remaining functions may be realized by software or firmware.

[0062] Processing circuitry 18 is illustratively implemented in 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 "processing circuitry." In other words, the functions of the functional components of the code generation device 100 are realized by the processing circuitry. Each device according to the other embodiments may also have a similar configuration to this modified example.

[0063] Embodiment 2 The following mainly describes the differences from the above-described embodiment with reference to the drawings.

[0064] ***Configuration Description*** 15 shows a code generation system 90 according to this embodiment. The code generation system 90 includes a code generation device 100 and a code learning device 200. The code generating device 100 according to this embodiment further includes an input unit 130. The code learning device 200 includes an input unit 210, a learning unit 220, and an output unit 230. The code learning device 200 has a function of performing feedback learning on the inference model 50 using the automatically generated code 60 based on the specifications 191.

[0065] The input unit 210 receives input of the automatically generated code 60 and the confirmed code 64 from the version management tool 51 . The input unit 210 also receives input of the specifications 191 corresponding to each received code. At this time, the input unit 210 may receive the input of the specifications 191 from the version management 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 for the inference model 50 based on each piece of 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 specific 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 nonconforming code 62 and the corrected code 63. The learning unit 220 may cause the inference model used by the learning unit 220 to learn the relationship between the difference between the noncompliant code 62 and the corrected code 63 and at least a part of the input to the inference model 50. Furthermore, every time the specification 191 is revised, the learning unit 220 may cause the inference model used by the learning unit 220 to learn the relationship between the compliant code 61, the noncompliant code 62, the corrected code 63, and at least a part 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 may generate information using RAG. The learning unit 220 may have the same functions as the prompt generation unit 110 according to Embodiment 1. The learning unit 220 may generate information that includes each specification 191 as appropriate.

[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 of the chord learning device 200 .

[0069] The prompt generation unit 110 of this embodiment appropriately has the functions of the prompt generation unit 110 of 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 generating unit 110 may use the output of the code learning device 200 as the prompt 111 as is.

[0070] ***Explanation of Operation*** Fig. 16 is a flowchart showing an example of the operation of the code generation system 90. The operation will be explained using Fig. 16. The differences from the first embodiment will be mainly explained below.

[0071] (Step S201) This step is performed each time the specification 191 is revised. The input unit 210 receives input of the automatically generated code 60 and the finalized code 64 from the version management tool 51. The input unit 210 also receives input of the specifications 191 corresponding to each received code.

[0072] (Step S202) The learning unit 220 generates information indicating 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 chord learning device 200 as input.

[0075] (Step S122) The prompt generator 110 generates a prompt 111 based on the pre- and post-revision specifications 191 and the input received by the input unit 130 .

[0076] ***Explanation of the effect of the second embodiment*** According to this embodiment, at least a portion of the input to the inference model 50 can be generated using a device other than the code generation device 100.

[0077] ***Other embodiments*** The above-described embodiments may be freely combined, or any of the components in each embodiment may be modified, or any of the components in each embodiment may be omitted. Furthermore, the embodiments are not limited to those shown in Embodiments 1 and 2, and various modifications are possible as necessary. The procedures explained using flowcharts and the like may be modified as appropriate.

[0078] Various aspects of the present disclosure are summarized below as appendices.

[0079] (Appendix 1) an inference model that learns the relationship between each specification of the software and the code corresponding to each specification, and that generates code based on a prompt indicating the software specification; a first automatically generated code generated based on a first prompt indicating a first specification is committed to a version control tool; and a first finalized 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 regarding knowledge used by the inference model when generating code is generated based on the first specification, a first non-compliant code that is included in the first automatically generated code but not included in the first finalized code, a first corrected code that is included in the first finalized code but not included in the first automatically generated code, and a first compliant code in the first automatically generated code that is not the first non-compliant code, a prompt generation unit that generates a second prompt that indicates a second specification, which is a specification of the software to be developed, and the second reference information, and that indicates an instruction to the inference model; A code generating device comprising:

[0080] (Appendix 2) The code generation device described in Appendix 1, wherein the prompt generation unit extracts the first compliant code, the first non-compliant code, and the first correction 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 compliant code, first non-compliant code, and first correction code.

[0081] (Appendix 3) the first prompt indicates a first reference to knowledge that the inference model uses to generate code; 3. The code generation device according to claim 2, wherein the prompt generation unit generates, as the second prompt, a prompt indicating information based on the first reference information and the second reference information.

[0082] (Appendix 4) The code generation device described in Appendix 3, wherein the prompt generation unit generates summary information that 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.

[0083] (Appendix 5) 5. The code generation device according to claim 1, wherein the second specification is a revised version of the first specification.

[0084] (Appendix 6) 5. The code generation device according to claim 1, wherein the first specification is a specification of software different from the software to be developed.

[0085] (Appendix 7) A code generation device described in any one of 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] (Appendix 8) The code generation device further a code generation management unit that generates second automatically generated code based on the inference model and the second prompt, and commits the generated second automatically generated code to the version management tool; 8. The code generating device of claim 1, comprising:

[0087] (Appendix 9) 9. A code generation device according to any one of appendices 1 to 8, wherein the inference model is a generative AI (Artificial Intelligence).

[0088] (Appendix 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 chord learning device comprising: A code generating device according to any one of appendices 1 to 9; A code generation system comprising: [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 automatically generated code, 61 compliant code, 62 non-compliant code, 63 modified 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 specification, 200 code learning device, 210 input unit, 220 learning unit, 230 output unit.

Claims

1. A model that learns the relationship between each software specification and the code that corresponds to each specification. , an inference model that generates code based on prompts that describe software specifications. A first automatically generated code is generated based on the model and the first prompt indicating the first specification. the first automatically generated command is committed to a program management tool based on the first specification. The first finalized code generated by modifying the code is stored in the version management tool. and committed, and The first specification and the first determined code of what is included in the first automatically generated code A first non-conformity code that is not included in the first confirmed code and a first confirmed code that is included in the first confirmed code a first modified code that is not included in the automatically generated code; and the inference model generates code based on the first compliant code that is not the first non-compliant code. When a second reference information is generated regarding knowledge to be used in A prompt indicating the second specification, which is the specification of the software to be developed, and the second reference information. generating a second prompt that is a prompt indicating an instruction to the inference model; Prompt generation part A code generation device comprising: The prompt generation unit generates the Based on the first automatically generated code and the first determined code, the first compatible code and the The first non-compliant code and the first correction code are extracted, and the extracted first compliant code and the first non-compliant code are a code generating device that generates the second reference information based on the combined code and the first modified code;

2. A model that learns the relationship between each software specification and the code that corresponds to each specification. , an inference model that generates code based on prompts that describe software specifications. A first automatically generated code is generated based on the model and the first prompt indicating the first specification. the first automatically generated command is committed to a program management tool based on the first specification. The first finalized code generated by modifying the code is stored in the version management tool. and committed, and The first specification and the first determined code of what is included in the first automatically generated code A first non-conformity code that is not included in the first confirmed code and a first confirmed code that is included in the first confirmed code a first modified code that is not included in the automatically generated code; and the inference model generates code based on the first compliant code that is not the first non-compliant code. When a second reference information is generated regarding knowledge to be used in A prompt indicating the second specification, which is the specification of the software to be developed, and the second reference information. generating a second prompt that is a prompt indicating an instruction to the inference model; a prompt generator for generating a prompt; generating second automatically generated code based on the inference model and the second prompt; committing the generated second automatically generated code to the version management tool. Management Department and A code generating device comprising:

3. The prompt generation unit generates the Based on the first automatically generated code and the first determined code, the first compatible code and the The first non-compliant code and the first correction code are extracted, and the extracted first compliant code and the first non-compliant code are 3. The computer according to claim 2, wherein the second reference information is generated based on the combined code and the first modified code. Code generation device.

4. The first prompt is about knowledge that the inference model uses to generate code. First, reference information is provided. The prompt generation unit generates the second prompt by combining the first reference information and the second reference information. The code generating device of claim 1 generates a prompt indicating information based on the input and the input information.

5. The prompt generation unit generates information based on the first reference information and the second reference information. and generating summary information that is a summary of the first reference information and the second reference information. The code generating device described above.

6. 6. The method according to claim 1, wherein the second specification is a revised version of the first specification. The code generating device described above.

7. The first specification is a specification of software different from the software to be developed.

6. The code generating device according to any one of items 1 to 5.

8. At least one of the second specification and the second reference information includes the software to be developed. The method according to any one of claims 1 to 5, further comprising: The code generating device described above.

9. The code generation device further generating second automatically generated code based on the inference model and the second prompt; committing the generated second automatically generated code to the version management tool. Management department 6. The code generating device of claim 1, 4 or 5, comprising:

10. The inference model is a generative AI (Artificial Intelligence) The code generating device according to any one of claims 1 to 5.

11. based on the first specification, the first automatically generated code, and the first confirmed code.

2. Learning unit for generating reference information a chord learning device comprising: The code generating device according to any one of claims 1 to 5, A code generation system comprising:

12. A model that learns the relationship between each software specification and the code corresponding to each specification. , an inference model that generates code based on prompts that describe software specifications. A first automatically generated code is generated based on the model and the first prompt indicating the first specification. the first automatically generated command is committed to a program management tool based on the first specification. The first finalized code generated by modifying the code is stored in the version management tool. and committed, and The first specification and the first determined code of what is included in the first automatically generated code A first non-conformity code that is not included in the first confirmed code and a first confirmed code that is included in the first confirmed code a first modified code that is not included in the automatically generated code; and the inference model generates code based on the first compliant code that is not the first non-compliant code. When a second reference information is generated regarding knowledge to be used in A prompt indicating the second specification, which is the specification of the software to be developed, and the second reference information. generating a second prompt that is a prompt indicating an instruction to the inference model; Prompt generation part a code generating device comprising: based on the first specification, the first automatically generated code, and the first confirmed code.

2. Learning unit for generating reference information A chord learning device comprising: A code generation system comprising:

13. A model that learns the relationship between each software specification and the code that corresponds to each specification. , an inference model that generates code based on prompts that describe software specifications. A first automatically generated code is generated based on the model and the first prompt indicating the first specification. the first automatically generated command is committed to a program management tool based on the first specification. The first finalized code generated by modifying the code is stored in the version management tool. and committed, and The first specification and the first determined code of what is included in the first automatically generated code A first non-conformity code that is not included in the first confirmed code and a first confirmed code that is included in the first confirmed code a first modified code that is not included in the automatically generated code; and the inference model generates code based on the first compliant code that is not the first non-compliant code. When a second reference information is generated regarding knowledge to be used in The computer is configured to: a second prompt indicating an instruction to the inference model; Generates a prompt, The computer is configured to: Based on the automatically generated code and the first determined code, the first conforming code and the first invalid code are generated. The compliant code and the first modified code are extracted, and the extracted first compliant code and the first non-compliant code are combined. A code generation method for generating the second reference information based on a code and a first modified code.

14. A model that learns the relationship between each software specification and the code that corresponds to each specification. , an inference model that generates code based on prompts that describe software specifications. A first automatically generated code is generated based on the model and the first prompt indicating the first specification. the first automatically generated command is committed to a program management tool based on the first specification. The first finalized code generated by modifying the code is stored in the version management tool. and committed, and The first specification and the first determined code of what is included in the first automatically generated code A first non-conformity code that is not included in the first confirmed code and a first confirmed code that is included in the first confirmed code a first modified code that is not included in the automatically generated code; and the inference model generates code based on the first compliant code that is not the first non-compliant code. When a second reference information is generated regarding knowledge to be used in The computer is configured to: a second prompt indicating an instruction to the inference model; Generates a prompt, The computer generates a second automatic decision based on the inference model and the second prompt. and then coercing the generated second automatically generated code into the version management tool. A code generation method that targets

15. A model that learns the relationship between each software specification and the code that corresponds to each specification. , an inference model that generates code based on prompts that describe software specifications. A first automatically generated code is generated based on the model and the first prompt indicating the first specification. the first automatically generated command is committed to a program management tool based on the first specification. The first finalized code generated by modifying the code is stored in the version management tool. and committed, and The first specification and the first determined code of what is included in the first automatically generated code A first non-conformity code that is not included in the first confirmed code and a first confirmed code that is included in the first confirmed code a first modified code that is not included in the automatically generated code; and the inference model generates code based on the first compliant code that is not the first non-compliant code. When a second reference information is generated regarding knowledge to be used in A prompt indicating the second specification, which is the specification of the software to be developed, and the second reference information. generating a second prompt that is a prompt indicating an instruction to the inference model; Prompt generation process A code generation program that causes a code generation device that is a computer to execute the above The prompt generation process includes: Based on the first automatically generated code and the first determined code, The first non-compliant code and the first correction code are extracted, and the extracted first compliant code and the first correction code are compared. a code generation process for generating the second reference information based on the non-compliant code and the first modified code; Grams.

16. A model that learns the relationship between each software specification and the code that corresponds to each specification. , an inference model that generates code based on prompts that describe software specifications. A first automatically generated code is generated based on the model and the first prompt indicating the first specification. the first automatically generated command is committed to a program management tool based on the first specification. The first finalized code generated by modifying the code is stored in the version management tool. and committed, and The first specification and the first determined code of what is included in the first automatically generated code A first non-conformity code that is not included in the first confirmed code and a first confirmed code that is included in the first confirmed code a first modified code that is not included in the automatically generated code; and the inference model generates code based on the first compliant code that is not the first non-compliant code. When a second reference information is generated regarding knowledge to be used in A prompt indicating the second specification, which is the specification of the software to be developed, and the second reference information. generating a second prompt that is a prompt indicating an instruction to the inference model; A prompt generation process generating second automatically generated code based on the inference model and the second prompt; committing the generated second automatically generated code to the version management tool. Management process and A code generation program that causes a code generation device, which is a computer, to execute the above.

Citation Information

Patent Citations

  • Information processor, information processing method, and computer program

    JP2014106557A

  • JPP7564601B

  • Performance bug repair via retrieval-augmented neural code generation model

    US20240248686A1

  • Elidable text for prompt crafting

    US20240311093A1