Text generation system
The text generation system addresses the inefficiency of manual documentation by identifying key code fragments and generating explanatory text, effectively summarizing large codebases into comprehensive documentation.
Patent Information
- Application Number
- JP2023081096
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2024-11-28
AI Technical Summary
Existing methods for generating documentation for an entire software repository, such as a readme, are inefficient as they require manual creation and lack automated abstraction from tens of thousands to millions of lines of program code.
A text generation system that identifies representative program code fragments and generates explanatory text using a processor, model information, and prompt templates to summarize large codebases.
Abstractly summarizes tens of thousands to millions of lines of program code to generate comprehensive documentation for a repository efficiently.
Smart Images

Figure 2024165175000001_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to text generation systems. [Background technology]
[0002] In recent years, there has been remarkable progress in the automation of software development, as exemplified by low-code / no-code development. However, the current situation is that explanatory text (documentation) for the entire repository, such as readme, which is as important as the program code, is still created manually, despite being a source of worry for many developers.
[0003] As a means to support the creation of documentation for the entire repository, there are known systems that present static templates to developers and fill in the templates based on user input. However, these methods merely show developers the requirements for creating documentation and do not actually support developers in writing the contents of the documentation.
[0004] Related techniques include, for example, Patent Document 1 and Non-Patent Document 1.
[0005] Patent Document 1 discloses a method for generating documentation for an entire repository by collecting one or more code comments from program code and combining the code comments.
[0006] Non-Patent Document 1 discloses a system that generates code comments for a class or function from the program code of the class or function by utilizing a large-scale language model. [Prior art documents] [Patent documents]
[0007] [Patent Document 1] JP 2000-163260 A [Non-patent literature]
[0008] [Non-Patent Document 1] Yue Wang, Weishi Wang, Shafiq Joty and Steven CH Hoi. 2021. CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 8696-8708. Association for Computational Linguistics. Summary of the Invention [Problem to be solved by the invention]
[0009] Patent Document 1 merely compiles code comments that have already been written by the developer, but does not disclose a method for creating documentation for the entire repository from the program code itself.
[0010] Non-Patent Document 1 states that generating code comments for a class or function merely involves generating at most a few lines of highly specific explanatory text from several tens of lines of program code.
[0011] On the other hand, when generating documentation for an entire repository, such as a readme, it is necessary to abstractly summarize and generate tens of thousands to millions of lines of program code, but the amount of calculation in Non-Patent Document 1 increases quadratically with the length of the input program code. Therefore, code comment generation technology cannot be applied to the problem of generating documentation for an entire repository.
[0012] The objective of the present invention is to generate documentation for an entire repository by abstractly summarizing tens of thousands to millions of lines of program code in a text generation system. [Means for solving the problem]
[0013] A text generation system of one embodiment of the present invention is a text generation system that generates explanatory text for program code from program code using a processor, and is characterized in having a representative program code identification unit that identifies a program code portion, which is a part of the program code in which representative processing of the program is described, from the program code, and a content generation unit that generates the explanatory text for the program code based on the program code portion and at least one setting value as model information. Effect of the Invention
[0014] According to one aspect of the present invention, a text generation system is capable of abstractly summarizing tens of thousands to millions of lines of program code to generate documentation for an entire repository. [Brief description of the drawings]
[0015] [Figure 1] FIG. 1 illustrates an example of a configuration of a text generation system according to a first embodiment. [Figure 1A] FIG. 1 illustrates an example of a configuration of a text generation system according to a first embodiment. [Diagram 2] 11 is a flowchart illustrating an example of a process executed by a representative program code identifying unit 110 according to the first embodiment. [Diagram 3] 10 is a diagram for explaining input and output of data in the process executed by the representative program code identification unit 110 of the first embodiment. FIG. [Figure 4] 10 is a diagram for explaining input and output of data in the process executed by the representative program code identification unit 110 of the first embodiment. FIG. [Diagram 5]10 is a diagram for explaining input and output of data in the process executed by the representative program code identification unit 110 of the first embodiment. FIG. [Figure 6] 10 is a diagram for explaining input and output of data in the process executed by the representative program code identification unit 110 of the first embodiment. FIG. [Figure 7] 11 is a flowchart illustrating an example of a process executed by a representative program code identifying unit 110 according to the first embodiment. [Figure 8] 10 is a diagram for explaining input and output of data in the process executed by the representative program code identification unit 110 of the first embodiment. FIG. [Figure 9] 11 is a flowchart illustrating an example of a process executed by a representative program code identifying unit 110 according to the first embodiment. [Figure 10] 11 is a flowchart illustrating an example of a process executed by a content generating unit 112 according to the first embodiment. [Figure 11] FIG. 2 illustrates an example of a token dictionary. [Figure 12] FIG. 11 is a diagram illustrating an example of a configuration of a text generation system according to a second embodiment. [Figure 13] 11 is a flowchart illustrating an example of a process executed by a learning unit 1310 according to the second embodiment. [Figure 14A] FIG. 13 illustrates an example of a prompt template. [Figure 14B] FIG. 13 illustrates an example of a prompt template. [Figure 15] FIG. 11 is a diagram illustrating an example of a configuration of a text generation system according to a third embodiment. [Figure 16] 13 is a flowchart illustrating an example of a process executed by an output ranking unit 1601 according to the third embodiment. [Figure 17] FIG. 13 is a diagram illustrating an example of a configuration of a text generation system according to a fourth embodiment. [Figure 18A] FIG. 13 illustrates an example of a prompt template. [Figure 18B] FIG. 13 illustrates an example of a prompt template. [Figure 19] FIG. 13 illustrates an example of a prompt template. [Figure 20] FIG. 13 is a diagram illustrating an example of the configuration of a text generation system according to a fifth embodiment. [Figure 21] 13 is a flowchart illustrating an example of a process executed by an interactive input receiving unit 2101 according to the fifth embodiment. [Figure 22A] FIG. 13 illustrates an example of a prompt template. [Figure 22B] FIG. 13 illustrates an example of a prompt template. [Figure 22C] FIG. 13 illustrates an example of a prompt template. [Figure 22D] FIG. 13 illustrates an example of a prompt template. [Figure 23A] FIG. 23 is a diagram showing an example of contents displayed on a user interface of an output unit (display unit) according to the sixth embodiment. [Figure 23B] FIG. 23 is a diagram showing an example of contents displayed on a user interface of an output unit (display unit) according to the sixth embodiment. [Figure 23C] FIG. 23 is a diagram showing an example of contents displayed on a user interface of an output unit (display unit) according to the sixth embodiment. [Figure 24] FIG. 13 illustrates an example of a prompt template. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0016] Hereinafter, examples of the present invention will be described with reference to the drawings. However, the present invention should not be interpreted as being limited to the description of the embodiments shown below. It will be easily understood by those skilled in the art that the specific configuration can be changed without departing from the concept or purpose of the present invention.
[0017] In the configurations of the invention described below, the same or similar configurations or functions are given the same reference numerals, and duplicated explanations are omitted.
[0018] In this specification, the terms "first," "second," "third," and the like are used to identify components and do not necessarily limit the number or order.
[0019] In order to facilitate understanding of the invention, the position, size, shape, range, etc. of each component shown in the drawings, etc. may not represent the actual position, size, shape, range, etc. Therefore, the present invention is not limited to the position, size, shape, range, etc. disclosed in the drawings, etc. EXAMPLES
[0020] 1 and 1A are diagrams illustrating an example of a configuration of a text generation system (computer system) according to a first embodiment.
[0021] The text generation system receives a program code repository and outputs documentation for the entire repository. In the first embodiment, a computer system is assumed that receives a repository written in Python and outputs one English readme, which is documentation for the entire repository.
[0022] In addition, the program code to be targeted is not limited to the Python language, but may be any computer language intended to be executed by a computer for the purpose of providing one or more functions, such as Java, Javascript, C, R, Mathematica, Visual Basic for Applications, HTML, or other programming or markup languages, or user-constructed domain-specific languages (DSLs), or a combination thereof, regardless of whether the language is in a state or form that can actually be executed by a computer.
[0023] Furthermore, the documentation to be output may be not only a readme but also a portion of a design specification, a user document, a usage manual, or the like, regardless of language, so long as it is abstract documentation for the entire repository.
[0024] The text generation system is composed of one computer 100. The computer 100 has a processor 101, a memory 102, and a network interface 103. Each piece of hardware is connected to each other via an internal bus. The computer 100 may also have storage devices such as a hard disk drive (HDD) and a solid state drive (SSD), input devices such as a keyboard, a mouse, and a touch panel, and an output device such as a display.
[0025] The processor 101 executes a program stored in the memory 102. The processor 101 executes processing according to the program, thereby operating as a functional unit (module) having a predetermined function. In the following explanation, when a processing is explained with a functional unit as the subject, it means that the processor 101 is executing a program that realizes the functional unit.
[0026] The memory 102 stores the programs executed by the processor 101 and information required for the programs. The memory 102 also includes a work area temporarily used by the programs. The network interface 103 connects to other devices via a network.
[0027] Here, the programs and information stored in the memory 102 of the computer 100 will be described.
[0028] The memory 102 of the computer 100 holds model information 111 and a prompt template database 113 , and also stores programs for realizing a representative program code identifying unit 110 and a content generating unit 112 .
[0029] The representative program code identification unit 110 receives an input of a program code and identifies a program code fragment describing a representative process of the program from the program code. The representative process of the program is, for example, an abstract overall process of the program.
[0030] The representative program code may take a variety of forms, such as an entry point for an application, a facade in the facade design pattern, or a base class in an object-oriented library.
[0031] The program code fragment is a part of the program code, and is at least one of a file, a package, a function, a class, a code block, a user interface component, etc. In the first embodiment, a file is adopted as the program code fragment.
[0032] The content generation unit 112 receives the program code fragment, and generates an explanatory text for the program code based on at least one setting value stored in the model information 111.
[0033] The computer system may include a terminal or the like for inputting data to the computer 100 and acquiring data from the computer 100. The functions of the computer 100 may be realized by two or more computers connected via a network. The computer 100 may also be realized by utilizing virtualization technology.
[0034] The process executed by the representative program code identification unit 110 will be described with reference to Fig. 2 to Fig. 9. Fig. 2, Fig. 7, and Fig. 9 are flowcharts for explaining an example of the process executed by the representative program code identification unit 110 of the first embodiment. Fig. 3, Fig. 4, Fig. 5, Fig. 6, and Fig. 8 are diagrams for explaining input and output of data in the process executed by the representative program code identification unit 110 of the first embodiment.
[0035] First, the representative program code identifying unit 110 receives a program code composed of one or more files written in the programming language Python (step S201).
[0036] The program code may be a set of files managed in a single repository, a set of files managed across multiple repositories, a subset of the files managed in a single repository, or a set of files managed by means other than a repository.
[0037] Next, the representative program code identification unit 110 divides the program code into N files 300 (step S202). The division unit may be a file, or a unit smaller than a file such as a function or class. It may be a unit spanning multiple files such as a package, or a non-exclusive unit such as a combination of a package and a function.
[0038] As shown in FIG. 3, a file 300 stores a file identifier 301 unique to the file 300, a file directory 302 which is the storage location of the file 300 in the repository, and file contents 303 recorded in the file.
[0039] Next, the representative program code identification unit 110 starts loop processing of the file 300 (step S203).
[0040] Next, the representative program code identification unit 110 analyzes the file contents 303 of the target file 300, and identifies the file 300 on which the program code of the file contents 303 depends (step S204). A dependency edge 401 is added from the target file 300 to the dependency graph 400 (see FIG. 4) to the file 300 on which the program code depends. Static program analysis may be used to identify the file 300 on which the program code depends, regular expressions may be used, dynamic analysis may be used, or reverse engineering may be performed after compiling the program code.
[0041] Next, the representative program code identification unit 110 analyzes the file contents 303 of the target file 300, and identifies the file 300 that contains a class that is inherited by a class contained in the file (step S205). An inheritance edge 501 is added from the target file 300 to the dependent file 300 in the inheritance graph 500 (see FIG. 5).
[0042] Next, the representative program code identification unit 110 judges whether or not the processing has been executed for all the files 300 included in the program code (step S206).
[0043] If it is determined that there is at least one file 300 for which processing has not been executed, the representative program code identification unit 110 returns to step S203 and executes the same processing.
[0044] If it is determined that the processing has been executed for all the files 300 included in the program code, the representative program code identification unit 110 ends the loop processing of the files 300, and proceeds to step S207.
[0045] Next, the representative program code identification unit 110 calculates the dependency graph ordinal number 602 of each file 300 from the dependency graph 400 (step S207). The calculation of the dependency graph ordinal number S207 will be described with reference to FIGS.
[0046] The representative program code identification unit 110 starts loop processing of the file 300 (step S701). The target file 300 is referred to as target file i.
[0047] The representative program code identification unit 110 starts loop processing of the file 300 (step S702). The target file 300 is referred to as target file j.
[0048] The representative program code identification unit 110 stores the distance (the number of edges in the shortest path) on the directed graph from target file j to target file i in the dependency graph 400 in the coordinates (i, j) of the distance matrix 601 (step S703). If target file i cannot be reached from target file j, 0 is stored.
[0049] Next, the representative program code identification unit 110 judges whether or not the process of step S703 has been executed for all the files 300 included in the program code (step S704).
[0050] If it is determined that there is at least one file 300 for which processing has not been executed, the representative program code identification unit 110 returns to step S702 and executes the same processing.
[0051] If it is determined that the processing has been executed for all the files 300 included in the program code, the representative program code identification unit 110 ends the loop processing of the files 300, and proceeds to step S705.
[0052] The representative program code identification unit 110 calculates the maximum value of the i-th column of the distance matrix 601, and stores it as the dependency graph ordinal number 602 of the target file i (step S705).
[0053] Next, the representative program code identification unit 110 judges whether or not the processes from steps S702 to S705 have been executed for all the files 300 included in the program code (step S706).
[0054] If it is determined that there is at least one file 300 for which processing has not been executed, the representative program code identification unit 110 returns to step S701 and executes the same processing.
[0055] If it is determined that the processing has been executed for all the files 300 included in the program code, the representative program code identification unit 110 ends the loop processing of the files 300, and ends the calculation of the dependency graph ordinals S207.
[0056] Next, the representative program code identification unit 110 starts loop processing of the file 300 (step S208).
[0057] Next, the representative program code identification unit 110 calculates a provisional classification result 801 indicating the likelihood of the target file 300 being a representative program code (step S209). The calculation S209 of the provisional classification result will be described with reference to Figs.
[0058] If the dependency graph ordinal number 602 of the target file 300 is the same as the minimum value of the dependency graph ordinal numbers 602 of all files 300, the representative program code identification unit 110 determines that the target file 300 is at the top of the dependency graph (step S901). Since a file at the top of the dependency graph is highly likely to describe a representative and abstract process of the code, such as an entry point, if the determination result is true, the value "1" is stored in (i, 0) of the provisional classification result 801 indicating the likelihood of the target file 300 being a representative program code, and if the determination result is negative, the value "0" is stored in (i, 0) of the provisional classification result 801.
[0059] Next, if the dependency graph ordinal number 602 of the target file 300 is the same as the maximum value of the dependency graph ordinal numbers 602 of all files 300, the representative program code identification unit 110 determines that the target file 300 is at the bottom of the dependency graph 400 (step S902).
[0060] Since a file at the bottom of the dependency graph is unlikely to be an entry point that is likely to describe representative and abstract processing, if the judgment result is true, the value of “−1” is stored in (i, 1) of the provisional classification result 801, which indicates the likelihood of the target file 300 being representative program code, and if the judgment result is negative, the value of “0” is stored in (i, 1) of the provisional classification result 801.
[0061] Next, the representative program code identification unit 110 determines whether the in-degree of the target file 300 in the inheritance graph 500 is 3 or more (step S903).
[0062] When a class inherits from many classes, the class is highly likely to describe representative and abstract processing of code, such as a base class in an object-oriented library, so if the judgment result is true, a value of "1" is stored in (i, 2) of the provisional classification result 801 indicating the likelihood of the code being representative of the target file 300, and if the judgment result is negative, a value of "0" is stored in (i, 2) of the provisional classification result 801. The in-degree threshold value may be any value.
[0063] Next, the representative program code identification unit 110 determines whether the file name of the target file 300 includes the character string "main" based on the file directory 302 of the target file 300 (step S904).
[0064] When a file has a file name that includes the character string "main", the file is highly likely to describe a representative and abstract process of code such as an entry point, so if the determination result is true, a value of "1" is stored in (i, 3) of the provisional classification result 801 indicating the likelihood of the target file 300 being a representative program code, and if the determination result is negative, a value of "0" is stored in (i, 3) of the provisional classification result 801. Note that any character string such as "cli" or "command" may be used in place of the character string "main".
[0065] Next, the representative program code identification unit 110 determines whether or not a function including the character string "main" exists in the target file 300 based on the file contents 303 of the target file 300 (step S905).
[0066] When a function contains the character string "main", the function is highly likely to describe a representative and abstract process of the code, such as an entry point, and therefore if the determination result is true, a value of "1" is stored in (i, 4) of the provisional classification result 801 indicating the likelihood of the code being representative of the target file 300, and if the determination result is negative, a value of "0" is stored in (i, 4) of the provisional classification result 801. Note that any character string, such as "cli", may be used instead of the character string "main".
[0067] Next, the representative program code identification unit 110 judges whether the file size of the target file 300 is 300 bytes or less based on the file contents 303 of the target file 300 (step S906). If the program code written in a certain file is extremely short, it is unlikely that specific processing is written in the file, so if the judgment result is true, the value of "-1" is stored in (i, 5) of the provisional classification result 801 indicating the likelihood of the target file 300 being a representative program code, and if the judgment result is negative, the value of "0" is stored in (i, 5) of the provisional classification result 801. The threshold value may be any value other than 300 bytes, and the judgment target may be another index such as the number of Unicode characters.
[0068] Next, the representative program code identification unit 110 ends the calculation of the provisional classification result S209.
[0069] Next, the representative program code identification unit 110 judges whether or not the process of step S209 has been executed for all files 300 included in the program code (step S210).
[0070] If it is determined that there is at least one file 300 for which processing has not been executed, the representative program code identification unit 110 returns to step S208 and executes the same processing.
[0071] If it is determined that the processing has been executed for all the files 300 included in the program code, the representative program code identification unit 110 ends the loop processing of the files 300, and proceeds to step S211.
[0072] Next, the representative program code identification unit 110 calculates a file score 802 indicating the likelihood of the target file 300 being a representative program code by adding up the provisional classification results 801 for each file (step S211). Any integration method such as weighted sum or voting may be used to integrate the provisional classification results 801. Also, weakly supervised learning may be used in which the file score 802 is regarded as pseudo-ground-truth data, a file score 802 predictor is created using the provisional classification result 801 or the file contents 303 as features, and the file score 802 is recalculated using the predictor.
[0073] Next, the representative program code identification unit 110 selects the file 300 with the maximum file score 802 of each file 300 (step S212). Note that two or more files 300 may be selected, such as by selecting files 300 in order of the file score 802 of each file 300 until the total file size exceeds a threshold value.
[0074] Furthermore, when selecting two or more files 300, the files 300 may be selected from different viewpoints, such as excluding a file 300 whose file contents 303 are highly similar to the selected file 300. When a plurality of files 300 are selected in the first embodiment, the file contents 303 are combined and treated as if they were a single file 300.
[0075] In the first embodiment, a method of using six weak classifiers has been described, but any number of weak classifiers may be used. The weak classifiers to be used are not limited to those disclosed above, and may include various processes including programming language-dependent processes, application form-dependent processes, and meta-information-dependent processes, such as "whether an argument analyzer is included", "is the process equivalent to a controller in an MVC model", "whether the file name does not start with 'test_'", "is the file initially registered on version control software", and "is the file created by a specific user". Furthermore, a specification by a user may be accepted, regardless of the file contents 303.
[0076] The above is an explanation of the process executed by the representative program code identification unit 110.
[0077] The content generation unit 112 generates a readme file by inputting the model information 111, the prompt template database 113, and the selected file 300. 11 The processing of the content generating unit 112 will be explained using the above.
[0078] The content generator 112 receives an input of the selected file 300 (step S1001).
[0079] Next, the content generation unit 112 performs pre-processing of the files 300 (step S1002). In this pre-processing, import statements and license indications at the beginning of the files that are deemed unnecessary for understanding the abstract processing of the code repository are removed from the file contents 303 of each file 300 using regular expressions, and then the file contents 303 of each file 300 are combined. Note that in this pre-processing, duplicate descriptions may be removed, important parts may be identified based on heuristics, and so on.
[0080] Next, the content generator 112 shortens the combined file contents 303 to a representative program code string of the first K characters based on a predetermined threshold K (step S1003). Note that instead of removing only the first K characters, any shortening method may be used, such as removing only the last K characters, or removing only the first K / 2 characters and the last K / 2 characters. Also, any value may be specified for the threshold K according to the desired calculation time.
[0081] Next, the content generating unit 112 receives the representative program code string and the prompt template 113. A prompt template (e.g., the prompt template in Figure 18A) 1100-1) by combining prompt (Step S1004).
[0082] for example, figure 18 As shown in A, prompt template 1100-1 is composed of prompt text 1101 that prompts the generation of documentation in natural language, a representative program code placeholder 1102, and a file placeholder 1103. Content generation unit 112 stores the representative program code character string in representative program code placeholder 1102, extracts file names from file directories 302 of files 300 randomly extracted from the repository, combines the file names, and stores them in file placeholder 1103.
[0083] If the prompt template 1100-1 is intended to generate documentation by utilizing a representative program code, it does not have to be configured with prompt text 1101, representative program code placeholder 1102, and file placeholder 1103, and may include various information such as a repository name, a user name, and license information. In addition, such information may be separately input from the user through interactive questions or a setting file (see FIG. 24 reference).
[0084] Next, the content generating unit 112 The promptinto a prompt token string consisting of one or more tokens (step S1005). A "token" generally means a minimum unit constituting a programming language, such as a variable name, reserved word, or operator, but in the present invention, division may be performed in units other than "tokens" in programming languages, such as byte pair encoding.
[0085] Next, the content generator 112 converts the prompt token string into a token dictionary 1200 (see FIG. 11 ) and use the prompt token index sequence {t 0 ,t 1 , t P} (step S1006). This conversion is realized by matching each token constituting the prompt token string with a token 1201 in the token dictionary 1200 and acquiring an index 1202 associated with the matching token 1201. If there is no token 1201 that matches the token, the token is associated with a predetermined index 1202.
[0086] Next, the content generator 112 starts a loop process of the variable i (step S1007), storing 0 in the variable i as an initial value. Using a probability distribution model for token index sequences such as GPT-3, the prompt token index sequence and the generated token index sequences up to the (i-1)th sequence are input, and the generated token index x i Calculate the probability distribution of .
[0087] p(x i |θ,t 0 ,t 1 , t P ,x 0 ,x 1 ,x i-1 ) Here, θ is a setting value (parameter) of the probability distribution model stored in the model information 111.
[0088] The generated token index with the maximum probability value is obtained as the i-th generated token index.
[0089] argmax xi p(x i |t 0 ,t 1 , t P ,x 0 , x 1 ,x i-1 ) Note that instead of selecting a token index with the maximum probability value, a token index may be selected by performing sampling based on a probability distribution, using beam search, etc. Also, the probability distribution model may be realized by a model based on a Transformer architecture such as T5 or BLOOM, a model based on recursive calculation such as ELMo, or a model based on distributed calculation such as GShard.
[0090] The probability distribution model may be a model that learns the probability distribution of words using various documents, a model that learns a model having the same architecture as the above using an original corpus, or any of these models. If an input token index can be generated based on an input token index sequence, the probability distribution requirement does not need to be met.
[0091] Next, the content generator 112 determines whether the i-th generated token index is a token index indicating the end of the document, or whether the variable i is a predetermined number of generated tokens L minus 1 (step S1009).
[0092] If it is determined that the condition is not satisfied, the content generating unit 112 increments the variable i, returns to step S1007, and executes the same process. If it is determined that the condition is satisfied, the content generating unit 112 ends the loop process of the variable i, and proceeds to step S1010.
[0093] The content generator 112 generates the generated token index string {x 0 , x1 ,x L-1} is converted to generated text 1104 (step S1010). In this conversion, first, each token index constituting the generated token index string is matched with an index 1202 in a token dictionary 1200, and a generated token string is obtained by acquiring a token 1201 associated with the matching index 1202. After that, the generated token string is combined to obtain a generated text.
[0094] In this way, for example, figure 19 The generated text 1104 is obtained as shown in the prompt template 1100-3.
[0095] Next, the content generating unit 112 performs post-processing on the generated text (step S1011). In the post-processing, three or more line breaks in the generated text are converted into two line breaks. Any conversion based on heuristics or machine learning may be performed depending on the desired state of the generated text.
[0096] According to the first embodiment, the computer system can generate documentation for the entire repository by abstractly summarizing tens of thousands to millions of lines of program code. EXAMPLES
[0097] figure 12 FIG. 11 is a diagram illustrating an example of a configuration of a text generation system (computer system) according to a second embodiment.
[0098] In the second embodiment, the computer 100 generates the documentation without using the prompt template database 113. The second embodiment will be described below, focusing on the differences from the first embodiment.
[0099] The configuration of the computer system of the second embodiment is the same as that of the first embodiment. The hardware configuration of the computer 100 of the second embodiment is the same as that of the first embodiment. In addition, the process executed by the representative program code identification unit 110 of the second embodiment is the same as that of the first embodiment.
[0100] In the second embodiment, the software configuration of the computer 100 is partially different. In the memory 102 of the computer 100 in the third embodiment, a program for realizing a model learning unit 1301 is stored in addition to a program for realizing a content generating unit 112.
[0101] The model learning unit 1301 receives one or more selected files 300 as input, calculates the setting values (parameters) of the probability distribution model of the model, and stores the calculated values in the model information 111. The process performed by the model learning unit 1301 is shown in FIG. 13 ,figure 14 A,Fig. 14 Explain using B.
[0102] The model learning unit 1301 receives a file 300 and one or more pairs of a correct documentation pair corresponding to the file 300 (S1401).
[0103] The answer documentation can be created manually or can be extracted from readme files in a repository that is publicly available as open source software.
[0104] Next, the model learning unit 1301 starts a loop process of the file 300 and the correct documentation pair (step S1402).
[0105] The processes from S1002 to S1006 are the same as those in the first embodiment. However, in the second embodiment, model learning is performed, so the prompt template for prompting the generation of documentation as in the first embodiment is not necessary. 14 As shown in prompt 1510-1 of A, the representative program code placeholder 1102 and the file placeholder 1103 are combined with an appropriate character string, and the prompt 1510-2 (Figure 14 B)
[0106] In steps S1403 and S1404, the same processes as in steps S1005 and S1006 are performed on the supervised documentation, respectively, to obtain a supervised documentation token index string.
[0107] Next, the model learning unit 1301 starts loop processing of the variable i (step S1405), and stores 0 in the variable i as an initial value.
[0108] The process of S1008 is the same as that of claim 1.
[0109] Generated token index x for the i-th token i and the i-th correct documentation token index x' i Based on the probability distribution of loss l i Calculate.
[0110] l i =-logp(x i =x' i |θ,t 0 ,t 1 , t P ,x 0 , x 1 ,x i-1 ) Next, the model learning unit 1301 determines whether the i-th correct documentation token index is a token index indicating the end of the document (step S1009).
[0111] If it is determined that the condition is not satisfied, the content generator 112 increments the variable i, returns to step S1007, and executes the same process. If it is determined that the condition is satisfied, the content generator 112 ends the loop process of the variable i, and proceeds to step S1407.
[0112] Next, the model learning unit 1301 calculates the sum L of the losses (step S1408).
[0113] L=Σ i l i Next, the model learning unit 1301 calculates each parameter θ from the sum of losses L. k∈ Gradient Δ with respect to θ k Calculate the parameter θ k is updated based on the gradient (step S1409).
[0114] Δ k =∂L / ∂θ k θ k ←θ k -ηΔ k Next, the model learning unit 1301 determines whether or not the processes from step S1002 to S1409 have been performed for all file 300 and correct document pairs (step S1410). If it is determined that there is at least one file 300 and correct document pair for which the processes have not been performed, the model learning unit 1301 returns to step S1002 and executes the same processes.
[0115] If it is determined that the processing has been performed for all the file 300 and supervised documentation pairs, the model learning unit 1301 ends the loop processing of the file 300 and supervised documentation pairs, and proceeds to step S1409.
[0116] Next, the model learning unit 1301 stores the updated parameter θ in the model information 111 (step S1401).
[0117] The above is an explanation of the processing executed by model learning unit 1301.
[0118] Although the above example shows training a model using stochastic gradient methods, you can also use mini-batch stochastic gradient methods, or more sophisticated optimization methods using AdamW or second-order derivatives. Also, instead of a word-by-word classification problem, you can use symmetric learning or reinforcement learning.
[0119] The process of the content generation unit 112 in the second embodiment is the same as that in the first embodiment. However, like the model learning unit 1301, 14As shown in A, the representative program code placeholder 1102 and the file placeholder 1103 are combined with an appropriate character string, and a prompt 1510-2 (Figure 14 B) is created.
[0120] According to the embodiment 2, the computer system can efficiently generate documentation by learning the model and utilizing a relatively smaller model than that of the embodiment 1. In addition, it is no longer necessary to adjust the prompt template for each model, and more robust generation is possible. EXAMPLES
[0121] figure 15 FIG. 11 is a diagram illustrating an example of a configuration of a text generation system (computer system) according to a third embodiment.
[0122] In the third embodiment, the computer 100 generates a plurality of documentation candidates. The third embodiment will be described below, focusing on the differences from the first embodiment.
[0123] The configuration of the computer system of the third embodiment is the same as that of the first embodiment. The hardware configuration of the computer 100 of the third embodiment is the same as that of the first embodiment.
[0124] In the third embodiment, the software configuration of the computer 100 is partially different. The memory 102 of the computer 100 in the third embodiment stores a program for realizing an output ranking unit 1601 in addition to the programs for realizing the input unit 117, the representative program code identification unit 110, the content generation unit 112, and the output unit 118.
[0125] The representative program code identifying unit 110 according to the third embodiment will be described with reference to FIG. 2 and FIG.
[0126] The processes from steps S201 to S211 are the same as those in the first embodiment.
[0127] Next, the representative program code identification unit 110 selects P files 300 (P≧1) whose file scores 802 are the highest (step S212). In addition, when selecting multiple files 300, the files 300 may be selected from different perspectives, such as excluding files 300 whose file contents 303 are highly similar to those of the selected files 300. Note that instead of selecting multiple files 300, the selection of files 300 may be repeated P times until the total file size exceeds a threshold, and P sets of files 300 may be selected. When multiple sets of files 300 are selected, the file contents 303 of each set of files 300 are combined and treated as if they were P files 300.
[0128] This concludes the description of the process executed by the representative program code identification unit 110 of the third embodiment.
[0129] The process performed by the content generation unit 112 of the third embodiment is the same as that of the first embodiment. However, the process is performed for a combination (P×Q set) of the P files 300 and Q (Q≧1) prompt templates 1100-1. Note that it is not necessary to apply the content generation unit 112 to all combinations of the P×Q sets, and the content generation unit 112 may be applied to, for example, R sets (≦P×Q) selected at random. Furthermore, the content generation unit 112 of the third embodiment may generate K (K≧1) documentation candidates using nucleus sampling or the like.
[0130] The output ranking unit 1601 receives the one or more documentation candidates and sorts the documentation candidates in an order that is deemed appropriate for documentation. The process performed by the output ranking unit 1601 is shown in FIG. 16 This will be explained using:
[0131] The output ranking unit 1601 receives one or more documentation candidates (step S1701).
[0132] Next, the output ranking unit 1601 starts a loop process of the documentation candidates (step S1702).
[0133] Next, the output ranking unit 1601 analyzes the selected candidate documentation and calculates the coverage score s of the candidate documentation. c Since a proper Readme must describe the project's purpose and installation information, if the document candidate contains any of the strings "goal", "aim", "objective", or "provide" as a reference to the project's purpose, then s c =1, if the documentation candidate contains any of the strings "install", "set up", "getting started", "prerequisite", or "how to" c = 1, if both conditions are met, s c = 2, if both of the above conditions are met, s c =0.
[0134] Next, the output ranking unit 1601 analyzes the selected candidate documentation and calculates the redundancy score s r (Step S1704). Since it is not desirable for the same description to be repeated many times in a proper Readme, if two or more document candidates contain the same string of 30 or more characters, s r = -1, otherwise s r =0.
[0135] Next, the output ranking unit 1601 analyzes the selected candidate documentation and calculates the content amount score s l (Step S1705). Since an appropriate Readme usually has a certain length, if the length of the documentation candidate is less than 200 characters, s l = -2, otherwise s l =0.
[0136] Next, the output ranking unit 1601 outputs the coverage score s c , the redundancy score s r , the content amount score s l Based on these scores, a total score s of the selected document candidate is calculated (step S1705). The total score s is calculated as the simple sum of the three scores.
[0137] s=s c +s r +s l Next, the output ranking unit 1601 determines whether the process has been executed for all the documentation candidates (step S1707).
[0138] If it is determined that there is at least one documentation candidate for which processing has not been performed, the output ranking unit 1601 returns to step S1702 and executes the same processing.
[0139] If it is determined that the process has been executed for the documentation candidates, the output ranking unit 1601 ends the loop process for the documentation candidates, and the process proceeds to step S1708.
[0140] Next, the output ranking unit 1601 sorts the documentation candidates so that the total score s of each documentation candidate is in descending order (step S1708). Note that when sorting the documentation candidates, the documentation candidates may be sorted using a different perspective, such as deleting a documentation candidate whose content is highly similar to a selected documentation candidate. This concludes the description of the processing executed by the output ranking unit 1601.
[0141] Although the output ranking unit 1301 using three heuristics has been described in the third embodiment, the output ranking unit 1601 may be realized using different heuristics. Also, a rank learner trained using pairs of a documentation candidate and a manually assigned appropriateness score for the documentation candidate may be used.
[0142] The output unit 118 of the third embodiment receives the one or more sorted documentation candidates and outputs one documentation. At this time, the topmost documentation may be output, or the top T documentation candidates may be presented to the user to prompt the user to select one.
[0143] According to the third embodiment, the computer system can generate appropriate documentation with a higher probability than the first embodiment. In addition, since an appropriate prompt template is selected for each model, the robustness of the prompt template is improved. In addition, by presenting a plurality of documentation candidates to the user, the documentation can be generated based on the user's preferences, which may be different from those of the system designer. EXAMPLES
[0144] figure 17 FIG. 13 is a diagram illustrating an example of the configuration of a text generation system (computer system) according to a fourth embodiment.
[0145] In the fourth embodiment, the computer 100 generates the documentation in a number of separate parts and then aggregates them. The fourth embodiment will be described below, focusing on the differences from the first embodiment.
[0146] The configuration of the computer system of the fourth embodiment is the same as that of the first embodiment. The hardware configuration of the computer 100 of the fourth embodiment is the same as that of the first embodiment.
[0147] In the fourth embodiment, the software configuration of the computer 100 is partially different. The memory 102 of the computer 100 in the fourth embodiment stores a program for realizing a generated text aggregating unit 1801 in addition to the programs for realizing the input portion 117, the representative program code identifying unit 110, the content generating unit 112, and the output unit 118.
[0148] The process performed by the content generating unit 112 in the fourth embodiment is the same as that in the first embodiment. However, the prompt template database 113 is different. 18 A,Fig. 18 B and Figure 19 As shown, the system holds one or more prompt templates 1100-1, including export documentation 1901.
[0149] The documentation output 1901 is the title of the content to be included in the Readme. The content generator 112 generates generated text 1104 for each prompt template 1100-1 (see FIG. 19 ). The prompt template database 113 may employ a prompt template 1100-1 having an export 1901 of other documentation, such as license information. Also, the content of the description desired by the user may be adopted based on the selection of the prompt template 1100-1 (see FIG. 24 reference).
[0150] The generated text aggregation unit 1801 combines the one or more generated texts 1104 to create the final documentation. 19 The generated text aggregator 1801 will be described with reference to the generated text aggregator 1801. The generated text aggregator 1801 combines the one or more generated texts 1104 to create the documentation 2000.
[0151] According to the third embodiment, the computer system can generate documentation that always includes desired content. EXAMPLES
[0152] figure 20 FIG. 13 is a diagram illustrating an example of the configuration of a text generation system (computer system) according to a fifth embodiment.
[0153] In the fifth embodiment, the computer 100 generates the documentation in a number of parts through a dialogue with the user. The fifth embodiment will be described below, focusing on the differences from the first embodiment.
[0154] The configuration of the computer system of the fifth embodiment is the same as that of the first embodiment. The hardware configuration of the computer 100 of the fifth embodiment is the same as that of the first embodiment.
[0155] In the fifth embodiment, the software configuration of the computer 100 is partially different. In the memory 102 of the computer 100 in the fifth embodiment, a program for realizing an interactive input receiving unit 2101 is stored in addition to the programs for realizing the input portion 117, the representative program code identifying unit 110, the content generating unit 112, and the output unit 118.
[0156] FIG. 13 shows the process performed by the content generating unit 112 and the interactive input receiving unit 2101 according to the fifth embodiment. 21 From the figure 22 I will explain using up to D.
[0157] The interactive input receiving unit 2101 receives the documentation 2301 edited by the user (step S2201). When step S2201 is executed for the first time, 22 You will enter the documentation export as shown in A.
[0158] Next, the content generating unit 112 of the fifth embodiment generates documentation based on the documentation 2301 edited by the user (step S2202). The process performed by the content generating unit 112 of the fifth embodiment is the same as that of the first embodiment. However, the content generating unit 112 regards the documentation 2301 edited by the user as a part of the prompt 1110-2, and generates the remaining documentation 2302 (see FIG. 22 B).
[0159] Next, the interactive input receiving unit 2101 presents the generated text 1104 to the user (step S2203).
[0160] Next, the content generating unit 112 receives an input from the user as to whether or not additional dialogue is desired (step S2204). If the user does not desire additional dialogue, the interactive input receiving unit 2101 ends the process. If the user desires additional dialogue, the content generating unit 112 returns to step S2201.
[0161] Next, the interactive input receiving unit 2101 receives the documentation 2301 edited by the user based on the generated text 1104 (step S2201). When step S2201 is executed for the second time, for example, the user 22 As shown in FIG. 11C, the contents of the generated text 1104 can be deleted or added.
[0162] Next, the content generating unit 112 of the fifth embodiment generates documentation based on the documentation 2301 edited by the user again (step S2202). The process performed by the content generating unit 112 of the fifth embodiment is the same as that of the first embodiment. However, the content generating unit 112 generates documentation based on the documentation 2301 edited by the user (step S2202). Prompt It is considered as a part of the document and the rest of the document 2302 is generated (see Fig. 22 (see D).
[0163] The above is an explanation of the processes executed by the content generating unit 112 and the interactive input receiving unit 2101 in the fifth embodiment.
[0164] According to the fifth embodiment, the computer system can interactively generate documentation including content desired by the user. EXAMPLES
[0165] In the sixth embodiment, the computer 100 presents the generated text 1104 along with the prompt 1110-2 and the selected file 300 that were used to generate the generated text 1104.
[0166] The configuration of the computer system and the hardware configuration of the computer 100 in the sixth embodiment are the same as those in the first embodiment. The hardware configuration and the software configuration of the computer 100 in the sixth embodiment are the same as those in the first embodiment.
[0167] The output unit (display unit) 118 (see FIG. 1) of the sixth embodiment is shown in FIG. 23 A~Figure 23 This will be explained using C.
[0168] The output unit (display unit) 118 of the sixth embodiment displays a user interface 2300. The user interface 2300 includes a tab 2301 for switching between display panes, an output pane 2302-1 for displaying the generated text 1104, and a text used to generate the generated text 1104. prompt A prompt pane 2302-2 that displays the prompt The user interface 2300 is composed of a representative code pane 2302-3 that displays the selected files 300 that were used to create the program code. The user interface 2300 may also include other intermediate outputs that are generated in the course of implementing the present invention, such as a provisional classification result 801 that indicates the likelihood that each file 300 is representative program code.
[0169] According to the sixth embodiment, the computer system can provide the user with a means for checking whether the generated documentation is valid.
[0170] According to the above embodiment, by identifying representative code fragments that provide an overview of what the code repository does, documentation for the entire repository can be generated in a realistic execution time by abstractly summarizing tens of thousands to millions of lines of program code using large-scale language models. [Explanation of symbols]
[0171] 100 calculator 101 Processor 102 Memory 103 Network Interface 110 Representative program code identification part 111 Model Information 112 Content Generation Division 117 Input section 118 Output section 1301 Learning Department 1601 Output Ranking Section 1801 Generated Text Aggregation Unit 2101 Interactive input unit
Claims
1. A text generation system for generating an explanatory text for a program code from the program code by a processor, comprising: a representative program code identifying unit that identifies a program code portion that is a part of the program code in which a representative process of a program is described from the program code; a content generation unit that generates the explanatory text of the program code based on the program code portion and at least one setting value as model information; 1. A text generation system comprising:
2. The representative program code identification unit 2. The text generation system according to claim 1, wherein a program code fragment constituting the fragment of the program code is identified as the program code portion.
3. The representative program code identification unit Identifying a program code portion in which an abstract overall process of the program is described as the representative process of the program; 2. The text generation system of claim 1, wherein the program code portion is identified as at least one of a file, a package, a function, a class, a code block, and a user interface component.
4. The representative program code identification unit The text generation system according to claim 1 , wherein the program code portion is identified from the program code based on the contents of the program code.
5. The representative program code identification unit Dividing the program code into a number of program code portions; 2. The text generation system according to claim 1, wherein the program code portions are identified based on at least one of the contents of the divided program code portions and the structural relationships between the divided program code portions.
6. The content generation unit 2. The text generation system according to claim 1, wherein the explanatory text is generated by using parameter values of an affine transformation or a nonlinear transformation as the set values, the parameter values being used for the affine transformation or the nonlinear transformation.
7. a prompt template database for storing at least one character string for controlling the content generated by the content generating unit; The content generation unit 2. The text generation system according to claim 1, wherein the system accepts input of the character string from the prompt template database, and generates the explanatory text based on the setting value and the character string.
8. 2. The text generation system according to claim 1, further comprising a model learning unit that learns the model information from the program code portion identified by the representative program code identification unit and generates the setting value based on the learned model information.
9. The content generation unit The text generation system according to claim 1 , further comprising: a program code generating unit configured to generate a program code for each of the plurality of programs;
10. 10. The text generation system according to claim 9, further comprising an output ranking unit that assigns a predetermined order to the multiple explanatory texts.
11. 10. The text generation system according to claim 9, further comprising a generated text aggregating unit that generates an aggregated generated text by aggregating a plurality of the explanatory texts.
12. The apparatus further includes an interactive input receiving unit that receives a text input by a user, The content generation unit The text generation system of claim 1 , further comprising: a program code portion that generates the explanatory text based on the text input, the program code portion, and the setting value.
13. 2. The text generation system according to claim 1, further comprising a display unit for displaying the explanatory text.
Citation Information
Patent Citations
Method and device for managing document preparation, and machine-readable recording medium with program recorded thereon
JP2000163260A
