Document generation method, apparatus, device, storage medium, and program product

By constructing a technical document path tree structure and recursively splitting the technical document outline, the accuracy problem of large language models when processing a large number of technical documents is solved, improving the accuracy of the generated technical documents and the efficiency of code reading.

CN122174795APending Publication Date: 2026-06-09SHUXING TECH (BEIJING) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHUXING TECH (BEIJING) CO LTD
Filing Date
2026-03-05
Publication Date
2026-06-09

Smart Images

  • Figure CN122174795A_ABST
    Figure CN122174795A_ABST
Patent Text Reader

Abstract

This application relates to a document generation method, apparatus, device, storage medium, and program product. The method includes: constructing an outline generation prompt text based on a first tree structure composed of the file paths of various technical documents of a target project; generating an outline based on the outline generation prompt text using a large language model to obtain the outline of the technical document for the target project and the chapter description information of each initial chapter in the outline; recursively splitting each initial chapter according to the chapter description information to obtain the chapter content of each sub-chapter under each initial chapter; and generating the technical document for the target project based on the outline and the chapter content of each sub-chapter under each initial chapter. This method can improve the accuracy of generating technical documents for the target project.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a document generation method, apparatus, device, storage medium, and program product. Background Technology

[0002] In the development process of internet projects, a large number of technical documents are typically generated. These documents may contain a massive amount of code and related configuration files, forming the overall architecture of the project. To facilitate rapid understanding of the project by technical personnel, structured explanatory documents (i.e., technical documentation) can be generated based on all the technical documents. This allows technical personnel to quickly grasp the project architecture without having to read the code line by line.

[0003] Currently, in order to generate technical documentation for a project, all technical documents of the project are mainly input into a Large Language Model (LLM). The LLM then reads and understands the technical documents and outputs the technical documentation.

[0004] However, the effective context window of a large model is limited. When the technical document data of a project is large, inputting all technical documents into the large model will cause the effective context window to overflow. As a result, the large model will only generate the technical documents for the entire project based on a portion of the technical documents, making the technical documents unable to accurately summarize the content of the entire project, and the accuracy of the generated technical documents will be low. Summary of the Invention

[0005] Therefore, it is necessary to provide a document generation method, apparatus, device, storage medium, and program product that can improve the accuracy of project technical documents in response to the above-mentioned technical problems.

[0006] Firstly, this application provides a document generation method, including:

[0007] Based on the first tree structure composed of the file paths of the various technical documents of the target project, construct an outline to generate prompt text;

[0008] Using a large language model, a prompt text is generated based on the outline to generate an outline, resulting in an outline of the technical document for the target project and chapter description information for each initial chapter in the outline.

[0009] Based on the chapter description information of each initial chapter, each initial chapter is recursively split to obtain the chapter content of the sub-chapter under each initial chapter;

[0010] Based on the outline and the content of the sub-chapters under each initial chapter, generate the technical documentation for the target project.

[0011] In one embodiment, the step of generating an outline based on the outline prompt text using a large language model to obtain the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline includes:

[0012] Using a large language model, the first tree structure in the prompt text is generated based on the outline; and the target file to be read is selected from each of the technical documents; and...

[0013] Obtain the compressed file corresponding to each target file, and based on each compressed file, output the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline.

[0014] In one embodiment, obtaining the compressed file corresponding to each of the target files includes:

[0015] For each target file, if the target file is a code file, the target file is compressed to obtain a compressed code file, and a compressed file corresponding to the target file is obtained according to the compressed code file and the file dependency relationship between the target file and each of the technical files;

[0016] If the target file is not a code file, the extraction range of the target file is determined based on the file name of the target file, and the content within the extraction range is obtained from the target file to obtain the compressed file corresponding to the target file.

[0017] In one embodiment, the step of recursively splitting each initial chapter according to its chapter description information to obtain the chapter content of each sub-chapter under the initial chapter includes:

[0018] For each initial chapter, if the initial chapter meets the splitting conditions, the initial chapter is recursively split according to the chapter description information of the initial chapter to obtain the sub-chapter under the initial chapter and the chapter description information of each sub-chapter;

[0019] Based on the chapter description information of each sub-chapter, generate the chapter content of the corresponding sub-chapter.

[0020] In one embodiment, the step of recursively splitting the initial chapter according to the chapter description information of the initial chapter to obtain sub-chapters under the initial chapter and chapter description information of each sub-chapter includes:

[0021] Based on the chapter description information of the initial chapter, the initial chapter is recursively split. During the recursive splitting process, after each round of splitting, for each sub-chapter obtained by splitting, if the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next level sub-chapter of the level to which the sub-chapter belongs and the chapter description information of the next level sub-chapter.

[0022] If none of the sub-chapter levels meet the splitting conditions, the recursive splitting of the initial chapter is stopped, resulting in sub-chapter levels under the initial chapter and chapter description information for each sub-chapter.

[0023] In one embodiment, the splitting condition includes at least one of the following:

[0024] The target chapter belongs to a level lower than a preset level, and the number of associated files of the target chapter in each of the technical documents is greater than a preset number;

[0025] The target chapter belongs to a lower level than the preset level, the number of associated files of the target chapter in each of the technical documents is not greater than the preset number, and the type of the target chapter is the target type;

[0026] The target chapter is either the initial chapter or a sub-chapter.

[0027] In one embodiment, the step of performing a new round of splitting the sub-chapter to obtain the next-level sub-chapter of the level to which the sub-chapter belongs and the chapter description information of the next-level sub-chapter includes:

[0028] Based on the chapter description information of the sub-chapter, determine the associated files of the sub-chapter in each of the technical documents;

[0029] Construct a second tree structure based on the file paths of the associated files;

[0030] Based on the second tree structure, construct the chapter splitting prompt text;

[0031] The chapter splitting prompt text is input into a large language model for chapter splitting, to obtain the next level of sub-chapter to which the sub-chapter belongs and the chapter description information of each next level of sub-chapter.

[0032] In one embodiment, constructing the second tree structure based on the file path of the associated file includes:

[0033] If the number of associated files is less than or equal to a preset number, the dependent files of each associated file are searched from each of the technical files according to the file dependency relationship of each associated file;

[0034] A second tree structure is constructed based on the file paths of each associated file and each dependent file.

[0035] In one embodiment, when the sub-section meets the splitting conditions, performing a new round of splitting on the sub-section to obtain the next-level sub-section of the sub-section's hierarchy and the chapter description information of the next-level sub-section includes:

[0036] Based on the chapter description information of the sub-chapter and the chapter description information of each historical sub-chapter, the similarity between the sub-chapter and each historical sub-chapter is determined; wherein, each historical sub-chapter is a sub-chapter that was split off before the sub-chapter.

[0037] If no similarity score is greater than the similarity threshold, determine whether the sub-section meets the splitting conditions;

[0038] If the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next level sub-chapter of the level to which the sub-chapter belongs and the chapter description information of the next level sub-chapter.

[0039] In one embodiment, the method further includes:

[0040] If any similarity score exceeds the similarity threshold, the subsection will be removed from its corresponding level.

[0041] In one embodiment, the chapter description information of each sub-chapter includes the associated file identifier of the sub-chapter; generating the chapter content of the sub-chapter based on the chapter description information of each sub-chapter includes:

[0042] For each sub-chapter, a prompt text is generated based on the chapter description information of the sub-chapter;

[0043] Using the large language model, the associated file identifier in the prompt text is generated based on the content, the associated files of the sub-chapter in each technical file are obtained, and the chapter content of the sub-chapter is generated based on the associated files.

[0044] In one embodiment, the step of constructing the outline to generate prompt text based on the first tree structure composed of the file paths of the various technical documents of the target project includes:

[0045] Based on the development type of the target project, determine the outline template corresponding to the target project;

[0046] Based on the outline prompt template and the file paths of the technical files of the target project in the code repository, an outline prompt text is generated.

[0047] Secondly, this application also provides a document generation apparatus, comprising:

[0048] The build module is used to construct an outline and generate prompt text based on the first tree structure composed of the file paths of the various technical documents of the target project.

[0049] The outline generation module is used to generate an outline based on the outline prompt text using a large language model, thereby obtaining the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline;

[0050] The content generation module is used to recursively split each initial chapter according to the chapter description information of each initial chapter in order to obtain the chapter content of the sub-chapter under each initial chapter.

[0051] The document generation module is used to generate technical documents for the target project based on the outline and the chapter content of the sub-chaps under each initial chapter.

[0052] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the various method embodiments provided in the first aspect above.

[0053] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the various method embodiments provided in the first aspect above.

[0054] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the various method embodiments provided in the first aspect above.

[0055] The aforementioned document generation method, apparatus, device, storage medium, and program product construct an outline generation prompt text based on a first tree structure composed of the file paths of the technical documents of the target project. Then, using a large language model, it generates an outline of the technical documents of the target project based on the outline generation prompt text. Based on the chapter description information of each initial chapter, it recursively splits each initial chapter to obtain the chapter content of the sub-chaps under each initial chapter in the outline. By compressing the file paths of each technical document into a tree structure and providing it to the large language model, compared to directly inputting the technical documents into the large language model, the amount of data input to the large language model can be effectively reduced. This allows the large language model to read as many technical documents as possible based on the file paths, thereby improving the accuracy of the generated outline and, consequently, the accuracy of the chapter content of the sub-chaps of each initial chapter in the outline. Finally, based on the outline and the content of the sub-chaps under each initial chapter, technical documentation for the target project is generated. By splitting the task of generating technical documentation into two sub-tasks—outline generation and chapter content generation—the large language model can focus on executing one sub-task at a time. During each sub-task execution, it reads as many related technical documents as possible, improving the accuracy of the sub-task and thus the accuracy of the generated technical documentation. Furthermore, based on the generated technical documentation, technical personnel can quickly grasp the architecture of the target project, enhancing their learning and understanding of the target project, lowering the code comprehension threshold, and improving code reading efficiency. Attached Figure Description

[0056] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0057] Figure 1 This is a diagram illustrating the application environment of a document generation method in one embodiment.

[0058] Figure 2 This is a flowchart illustrating a document generation method in one embodiment;

[0059] Figure 3 This is a schematic diagram of the first tree structure in one embodiment;

[0060] Figure 4 This is a flowchart illustrating the recursive splitting process of the initial chapter in one embodiment;

[0061] Figure 5 This is a schematic diagram of the outline generation process in one embodiment;

[0062] Figure 6 This is a schematic diagram of the content generation process in one embodiment;

[0063] Figure 7 This is a flowchart illustrating the recursive splitting steps of the initial chapter in one embodiment;

[0064] Figure 8 This is a flowchart illustrating a new round of splitting steps for sub-sections in one embodiment;

[0065] Figure 9 This is a flowchart illustrating the document generation method in another embodiment;

[0066] Figure 10 This is a structural block diagram of a document generation device in one embodiment;

[0067] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0068] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0069] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0070] The document generation method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store data that server 104 needs to process, such as technical documents for a project. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. In one embodiment, terminal 102 sends a document generation request containing the project identifier of the target project to server 104. Server 104 determines that a technical document for the target project needs to be generated based on the project identifier. Then, based on a first tree structure composed of the file paths of the technical documents of the target project, it constructs an outline generation prompt text. Using a large language model, it generates an outline based on the outline generation prompt text, obtaining the outline of the technical document for the target project and the chapter description information of each initial chapter in the outline. Based on the chapter description information of each initial chapter, it recursively splits each initial chapter to obtain the chapter content of the sub-chaps under each initial chapter. Based on the outline and the chapter content of the sub-chaps under each initial chapter, it generates the technical document for the target project.

[0071] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, etc. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0072] In one exemplary embodiment, such as Figure 2 As shown, a document generation method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the explanation includes:

[0073] S201, Based on the first tree structure composed of the file paths of the various technical documents of the target project, construct the outline to generate prompt text.

[0074] Optionally, the technical documents of the target project can be stored in a code repository. The code repository can be a dedicated repository for the target project or a public repository for multiple projects; no specific limitation is made here. In this embodiment, the code repository is mainly used as a dedicated repository for the target project for illustration. Technical documents can be divided into two types: code files and non-code files (such as configuration files). The file path of the technical file is used to locate the storage location of the technical file in the code repository. It is understood that there may be some common paths in the file paths of different technical files. For example, the file path of technical file 1 is "C: / java / com / abcd / efd.ord", the file path of technical file 2 is "C: / java / com / abcd / efd.prf", and the file path of technical file 3 is "C: / java / com / abcd". The same path is "C: / java / com / abcd". If the file paths of these two technical files are directly put into the outline generation prompt text, the same path will be repeatedly given to the large language model (hereinafter referred to as the large model). Therefore, the file paths of each technical file can be compressed into a first tree structure, thereby reducing the number of tokens input to the large model. Optionally, the hierarchical relationship of file paths can be represented in the first tree structure using line breaks and spaces, and different file extensions can be used to represent different file types. For example, the first tree structure consisting of the file paths of Technical File 1, Technical File 2, and Technical File 3 can be as follows: Figure 3 As shown, the suffix " / F" indicates that the technical file corresponding to the file path is a directory file, and the suffix " / D" indicates that the technical file corresponding to the file path is not a directory file.

[0075] It's understandable that the code repository may contain a large number of files related to the target project, some of which are useless for generating technical documentation. Therefore, prior to S201, these files can be filtered to obtain the technical documentation for the target project. For example, based on the target project's path, all files with the ".gitignore" extension in the project path can be read and ignored. The code repository's file directories can be traversed, skipping ignored and invalid files. Valid files, excluding ignored and invalid files, can be used as the target project's technical documentation. Invalid files can include at least one of the following: non-text files, excessively large text files, test directory files, resource directory files, and empty directory files. Excessively large text files can be defined according to actual needs; for example, code files larger than 1 megabyte can be considered excessively large text files, and configuration files larger than 50 kilobytes can be considered excessively large text files.

[0076] For the technical files of the selected target files, a breadth-first search (BFS) approach can be used to construct a tree structure of the file paths, namely the first tree structure (also known as a compressed directory structure). This not only saves the amount of tokens required to input a large model, but also expands the first tree structure in conjunction with the BFS path, while filtering out invalid files, which can greatly improve the diversity of reading and allow the outline generation stage to focus less on details and to decompose the code repository from a global perspective.

[0077] The outline generation prompt text is used to instruct the large model to generate outlines corresponding to each technical document. Optionally, in addition to including the first tree structure, the outline generation prompt text may also include prompt words to guide the large model in generating outlines, so as to instruct the large model to generate outlines that meet expectations. Therefore, the first tree structure and prompt words can be combined to obtain the outline generation prompt text.

[0078] S202, using a large language model, generate an outline based on the outline prompt text, and obtain the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline.

[0079] Optionally, the outline generation prompt text can be input into the large language model to generate the outline. The large model can intelligently select the technical file to be read based on the first tree structure in the outline generation prompt text, read the technical file according to the file path, and then generate the outline of the technical document and the chapter description information of the initial chapter in the outline based on the read technical file.

[0080] The outline of a technical document summarizes the main content and logical order of each technical document. It can include titles for multiple initial chapters and can also be considered the first-level directory of the technical document. The chapter description information for each initial chapter describes its core content and can be used for subsequent recursive splitting and content generation. For example, the chapter description information can include the chapter name (Chinese and / or English name), the technical documents covered by the initial chapter, the four-dimensional knowledge of the initial chapter, and suggestions from the larger model regarding whether the initial chapter needs further recursive splitting. The technical documents covered by the initial chapter can be represented using file wildcards (glob patterns) to specify file path rules. For example, if the technical documents covered by the initial chapter are ".java" files in all subdirectories under the "abc" directory, the corresponding glob pattern could be "abc / ** / *.java". Optionally, the four-dimensional knowledge of the initial chapter can include Objective & Scope, Context Knowledge, Focus On, and Avoidance Strategy, where:

[0081] Objectives and scope define the boundaries and goals of each chapter, clarifying the theme and type of output content. During content generation, they guide LLM material selection and narrative approach, ensuring consistency in direction.

[0082] Contextual knowledge is used to inject domain and implementation background, reducing model illusion and ensuring consistency. During content generation, each chapter carries accurate information about its parent and sibling levels, avoiding information offset, reducing redundant explanations and context loss, and improving coherence.

[0083] Focus points are used to define the scope and priority, facilitating focus and selection. During content generation, it determines which files to read and which implementation details to extract, avoiding irrelevant content, and, in conjunction with chapter-specific glob patterns, quickly defines code and document areas.

[0084] Avoidance strategies are used to clearly define the division of labor among chapters and reduce duplication and blurred boundaries between chapters. During content generation, content deduplication can be controlled to achieve flush stitching.

[0085] Optionally, the chapter description information may also include the thought process behind the chapter splitting of the large model and the process of analyzing the dependencies between technical documents, so as to facilitate the verification of the accuracy of the large model's output results based on the thought process and analysis process.

[0086] S203, using a large language model, generates an outline based on the outline prompt text, obtaining the outline of the target project's technical document and the chapter description information of each initial chapter in the outline.

[0087] After obtaining the outline of the technical documents, to present the overall architecture of the target project in as much detail as possible, the initial chapters in the outline can be recursively broken down. This allows for a comprehensive understanding of the technical documents covered by the initial chapters based on their sub-chapters. The chapter descriptions describe the core content of the initial chapters; therefore, the core content can be further broken down based on these descriptions to obtain the sub-chapters. Furthermore, the initial chapters are essentially a summary of the covered technical documents. Therefore, dividing the initial chapters into multiple sub-chapters results in corresponding sub-chapters for each sub-chapter. Then, the content of each sub-chapter can be generated based on the technical documents it covers. For example, if the initial chapter is "Overall Architecture of the Social Module," covering technical documents 1-100, dividing it into three sub-chapters results in "Message System," "Comment Interaction," and "Dynamic Posting." The "Message System" sub-chapter covers technical documents 1-50, the "Comment Interaction" sub-chapter covers technical documents 51-70, and the "Dynamic Posting" sub-chapter covers technical documents 71-100.

[0088] S204: Generate the technical documentation for the target project based on the outline and the content of the sub-chapters under each initial chapter.

[0089] Specifically, based on the above S201-S203, the outline of the technical document, the sub-chapter under the initial chapter in the outline, and the chapter content of the sub-chapter are obtained. By combining the outline, sub-chapter, and chapter content, the technical document of the target project is generated.

[0090] In the above method, an outline generation prompt text is constructed based on the first tree structure composed of the file paths of the technical documents of the target project. Then, through a large language model, an outline of the technical documents of the target project is generated based on the outline generation prompt text. Each initial chapter is recursively split according to its chapter description information to obtain the chapter content of each sub-chapter under each initial chapter in the outline. By compressing the file paths of each technical document into a tree structure and providing it to the large language model, compared to directly inputting the technical documents into the large language model, the amount of data input to the large language model can be effectively reduced. This allows the large language model to read as many technical documents as possible based on the file paths, thereby improving the accuracy of the generated outline and, consequently, the accuracy of the chapter content of each sub-chapter under each initial chapter in the outline. Finally, based on the outline and the content of the sub-chaps under each initial chapter, technical documentation for the target project is generated. By splitting the task of generating technical documentation into two sub-tasks—outline generation and chapter content generation—the large language model can focus on executing one sub-task at a time. During each sub-task execution, it reads as many related technical documents as possible, improving the accuracy of the sub-task and thus the accuracy of the generated technical documentation. Furthermore, based on the generated technical documentation, technical personnel can quickly grasp the architecture of the target project, enhancing their learning and understanding of the target project, lowering the code comprehension threshold, and improving code reading efficiency.

[0091] In one embodiment, the steps for constructing the outline to generate prompt text are further refined, including:

[0092] Based on the development type of the target project, determine the corresponding outline prompt template for the target project; based on the first tree structure composed of the outline prompt template and the file paths of each technical file of the target project in the code repository, construct the outline generation prompt text.

[0093] The development type (also known as project type) identifies the technologies used in the development of the target project, such as the development framework and core technology stack. Optionally, the development type can be identified by detecting the target project's build configuration and dependencies. Different outline prompt templates are set for different development types, each containing different document structures, resulting in different final outline structures. For example, when identified as a JavaSpring development type, the outline prompt template will include a specified document structure with ten predefined sections, explicitly prohibiting LLM from extending or modifying this structure to ensure standardization and consistency of enterprise-level Spring project documentation. For other development types, a flexible strategy is adopted, providing LLM with multiple recommended document structures as reference bases. For example, when the target project is a front-end application, it is recommended to include component architecture and state management sections; when the target project is a back-end service, it is recommended to include data model and business logic layer sections. However, LLM is allowed and encouraged to dynamically adjust and extend the section structure based on the actual code file content.

[0094] Furthermore, the first tree structure is populated into the outline hint template to construct outline generation hint text, which can indicate that the outline structure generated by the large model conforms to the specified document structure.

[0095] In the above embodiments, different outline prompt templates are set according to different development types, so that the generated outlines can better match the content of the target project, improve the accuracy of the generated outlines, and thus improve the accuracy of the technical documents.

[0096] In one embodiment, the steps for generating the outline are further defined, including:

[0097] Using a large language model, the system generates the first tree structure in the prompt text based on the outline, selects the target file to be read from each technical document, obtains the compressed file corresponding to each target file, and outputs the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline based on each compressed file.

[0098] The large model can autonomously decide which technical files (target files) to read based on the first tree structure. To reduce the token input to the large model and allow it to read more target files and obtain more useful information before generating the outline for the corresponding chapters, it obtains the compressed files corresponding to the target files and generates the outlines based on these compressed files. Optionally, the large model calls a file reading tool to obtain the compressed files. Since the file paths provided to the large model in the first tree structure are compressed rather than provided in full, the file reading tool may not be able to accurately find the corresponding files based on the file paths in the first tree structure. In this case, fuzzy path matching can be performed based on the file paths in the first tree structure, the paths can be standardized, and permissions, size, and cache can be checked. If a compressed file is found in the cache, it is returned directly; otherwise, the file content is read, the target file is compressed, and the compressed file is returned to the large model. During the fuzzy path matching process, the file paths are first standardized (unified slashes, lowercase, removal of redundant prefixes / suffixes), and then a progressively degraded search is attempted. Precise / relative path existence checks are performed first; if no match is found, a fuzzy search is performed in the pre-indexed list of repository paths. Fuzzy search is based on path segmentation comparison and string similarity (with higher weighting for base names, inter-segment overlap rate, and a combination of edit distance / similarity scores). It also considers prefix / suffix matching and segment order consistency. Finally, the best candidate is selected based on the comprehensive score and its existence is confirmed a second time. The results are cached with confidence scores to accelerate subsequent queries.

[0099] In the above embodiments, by inputting compressed files into the large model, the number of tokens consumed in reading a single target file is reduced, and the upper limit of the number of files that the large model can read is increased. This allows the large model to generate the outline of the corresponding chapters after reading more code files and obtaining more useful information, thereby improving the accuracy of outline generation and thus improving the accuracy of technical documents.

[0100] In one embodiment, the step of obtaining the compressed file is further defined, including:

[0101] For each target file, if the target file is a code file, the target file is compressed to obtain a compressed code file. Based on the compressed code file and the file dependencies between the target file and each technical file, the corresponding compressed file is obtained. If the target file is not a code file, the extraction range of the target file is determined based on the file name of the target file, and the content within the extraction range is obtained from the target file to obtain the corresponding compressed file.

[0102] The target files can be divided into code files and non-code files. Understandably, the file structures of code files and non-code files are usually different, hence the use of different compression methods. For code files, during the work process, it was found that the specific implementation of functions does not affect the quality of the generated outline during the outline generation stage. Therefore, compressing the code during the outline generation stage can significantly reduce the number of tokens consumed in reading a single code file, increasing the upper limit of the number of files that the large model can read. This allows the large model to generate outlines for corresponding chapters only after reading more code files and obtaining more useful information.

[0103] Optionally, during code compression, common classes / interfaces / enumerations, methods, modules, specified function annotations, filtered code comments, and line numbers in the code file are retained to obtain a compressed code file. After code compression, reverse code completion can be performed using a large model to maintain the basic functionality of the compressed code file. After code file compression, file dependencies are also injected synchronously. File dependencies represent the dependencies between the target file and various technical files. Specifically, a call graph can be constructed for all technical files in the code repository, where each node represents a technical file, enabling the identification of file references. Then, after obtaining the compressed code file corresponding to the target file, an abstract syntax tree parser is used to traverse the call graph to resolve the file dependencies of the target file. Currently, the abstract syntax tree parser is applicable to parsing languages ​​such as Java, Rust, Python, and TypeScript. By introducing file dependencies, when generating the outline, the large model can be guided to select the required technical files based on file dependencies, which can greatly improve the relevance of file reading and consider how the dependencies of key files in the parent chapter affect the division of the child chapters.

[0104] For non-code files, the extraction range can be limited based on the filename (extension). For example, the extraction range can be [total readable lines, first readable lines, last readable lines], preventing the reading of too much useless content or excessive token consumption. For non-code files, the number of lines can be limited by filename and only the beginning and end segments can be retained. Furthermore, a maximum of 20 files can be read at a time.

[0105] In the above embodiments, by compressing code files and non-code files, the number of tokens required to input the large model is reduced, and the upper limit of the number of files that the large model can read is increased. This allows the large model to generate the outline of the corresponding chapters after reading more code files and obtaining more useful information, thereby improving the accuracy of outline generation and ultimately improving the accuracy of technical documents.

[0106] In one embodiment, such as Figure 4As shown, for each initial chapter, the steps for recursively splitting the initial chapter are further defined, including:

[0107] S401, if the initial chapter meets the splitting conditions, recursively split the initial chapter according to the chapter description information of the initial chapter to obtain the sub-chapters under the initial chapter and the chapter description information of each sub-chapter.

[0108] Whether to recursively split the initial chapter requires a splitting condition, which can be set according to actual needs. For example, the splitting condition can be based on the number of technical documents covered by the initial chapter. Optionally, the splitting condition can be that the number of technical documents covered by the initial chapter exceeds a certain threshold, which can be set based on experience, multiple trials, and actual needs. Furthermore, since the chapter description information of the initial chapter contains suggestions from the larger model regarding whether to further split the chapter, the splitting condition can also be that the larger model suggests further splitting of the chapter. Additionally, the splitting condition can also be that the initial chapter is a pre-defined core chapter; these are not all listed here.

[0109] like Figure 5 As shown, an outline generation agent can be deployed on the server. First, the outline generation agent inputs the constructed outline generation prompt text into the large language model. The large language model outputs the generated outline, which contains three initial chapters. Each initial chapter meets the splitting conditions. Further, initial chapter 1 is recursively split into sub-chapters 1-4, initial chapter 2 is recursively split into sub-chapters 5-6, and initial chapter 3 is recursively split into sub-chapters 7-12. The final outline includes initial chapters 1-3 and sub-chapters 1-12. The large language model returns the generated outline to the outline generation agent.

[0110] S402, Generate the chapter content of the corresponding sub-chapter based on the chapter description information of each sub-chapter.

[0111] Specifically, for a sub-chapter, the technical documents covered by the sub-chapter can be determined based on the chapter description information, and then the chapter content is generated by combining the technical documents under the sub-chapter. Optionally, the chapter content of the sub-chapter can be generated using a large language model based on the chapter description information.

[0112] In the above embodiments, by recursively splitting the initial chapters, more detailed sub-chaps are obtained, enabling technical personnel to fully understand the overall architecture of the target project through the sub-chaps. Furthermore, by generating content using the chapter description information of the sub-chaps, the accuracy of the generated chapter content can be guaranteed.

[0113] In one embodiment, the chapter description information for each sub-chapter includes the associated file identifier of the sub-chapter, and the steps for generating the chapter content of the sub-chapter are further defined, including:

[0114] For each sub-chapter, content-generating prompt text is constructed based on the sub-chapter's chapter description information; using a large language model, the associated file identifiers in the content-generating prompt text are used to obtain the associated files of the sub-chapter in each technical document, and the chapter content of the sub-chapter is generated based on the associated files.

[0115] The chapter description information of a sub-chapter describes the core content of the sub-chapter. For example, the chapter description information of a sub-chapter may include the chapter name (Chinese name and / or English name), the sub-chapter's glob pattern, and the four-dimensional knowledge of the sub-chapter (objective and scope, contextual knowledge, focus and avoidance strategies). The content generation prompt text is used to instruct the large language model to generate the chapter content of the sub-chapter. The associated file identifier is the identifier of the technical file covered by the sub-chapter. It can be represented by the sub-chapter's glob pattern. That is, the associated file identifier can be a file wildcard of the technical file. Then, through the glob pattern, the large model can find the associated files of the sub-chapter. Similarly, during the content generation process, the large model calls the file reading tool to read the associated files. The large model can send the file path of the associated file to be read to the file reading tool, and the file reading tool returns the content of the associated file.

[0116] In addition to providing the chapter descriptions of the sub-chaps to the large model during the content generation phase, a text search tool (grep) is also provided. This allows the large model to read the dependencies between related files, increasing the depth of the generated content. Furthermore, when the number of related files corresponding to a sub-chapter is less than a file count threshold, the file reading tool stops compressing the related files, allowing the large model to read all relevant files, thus improving the accuracy of the generated content. The file count threshold can be set based on experience, multiple trials, and actual needs. For the same topic, the more files the large model reads, the higher the quality of the generated content. Besides outputting the chapter content of the sub-chaps, the large model can also output which files were read, which files were referenced, appropriate content and charts were generated, and related entities / methods were listed, etc., in order to generate the chapter content.

[0117] like Figure 6The diagram illustrates the content generation process. A content generation agent can be deployed on the server. Taking sub-chapter 1 as an example, the content generation agent fills the chapter description information of sub-chapter 1 into the content splitting prompt template to obtain the content generation prompt text. The content generation prompt text is then input into the large language model. Based on the associated file identifier, the large language model reads associated file 1, associated file 2, and associated file 3 to generate the chapter content of sub-chapter 1 and returns it to the content generation agent.

[0118] In the above embodiments, by constructing content prompt text to instruct the large model to generate content, the large model can more accurately generate the chapter content of sub-chaps based on chapter description information and associated files, thereby improving the accuracy of technical documents.

[0119] In one embodiment, such as Figure 7 As shown, the steps of S401 to recursively split the initial chapter are further specified, including:

[0120] S701, based on the chapter description information of the initial chapter, recursively split the initial chapter, and in the process of recursive splitting, after each round of splitting, for each sub-chapter obtained by splitting, if the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next level of sub-chapter and the chapter description information of the next level of sub-chapter.

[0121] In the recursive splitting process, the initial chapter is split into sub-chaps, and these sub-chaps are further split into next-level sub-chaps. The sub-chaps from the initial chapter form the second-level directory of the technical document, and so on. Before splitting each sub-chapter, it's necessary to determine if it meets the splitting criteria. Only if it does can a new round of splitting begin. During the recursive splitting process, the four-dimensional knowledge of the initial chapter is recursively passed down the recursion path. This ensures that even with deep recursion, the larger model retains a global perspective. This allows the larger model to understand the four-dimensional knowledge of the ancestor and parent chapters of the chapter to be split, avoiding information gaps or duplication, thus improving the efficiency and accuracy of outline generation.

[0122] S702, if the sub-chapter at each level does not meet the splitting conditions, stop the recursive splitting of the initial chapter and obtain the sub-chapter at different levels under the initial chapter and the chapter description information of each sub-chapter.

[0123] Understandably, if none of the sub-chaps at each level meet the splitting criteria, there's no need to split any further sub-chaps. Therefore, the recursive splitting of the initial chapters stops, and the resulting initial chapters and sub-chaps at different levels constitute the outline of the technical document. It's worth noting that the glob pattern in the chapter description information of each sub-chapter will be a subset of the glob pattern of the parent chapter. This gradually reduces the reading scope of the large model and progressively breaks down the code repository.

[0124] In the above embodiments, by determining the splitting conditions, the splitting of sub-chaps can be decided, which can avoid excessive splitting of sub-chaps. Furthermore, by passing on the chapter description information, the large model can retain a global perspective during the splitting process, thereby improving the accuracy of the outline.

[0125] In one embodiment, the splitting conditions include at least one of the following:

[0126] (1) The target chapter belongs to a lower level than the preset level, and the number of related files of the target chapter in each technical document is greater than the preset number;

[0127] (2) The target chapter belongs to a lower level than the preset level, the number of related files of the target chapter in each technical document is not greater than the preset number, and the type of the target chapter is the target type;

[0128] The target chapter can be either the initial chapter or a sub-chapter. The preset levels and number of sub-chapters can be set based on experience, multiple trials, and actual needs, and are not specifically limited here. The target type refers to a designated core chapter for which the larger model recommends further splitting. Optionally, for target chapters, the highest priority is to determine if the target chapter's level is lower than the preset level. If the level is lower, the number of associated files covered by the target chapter's glob pattern is counted. If this number exceeds the preset number, the target chapter is directly split. If the number is not greater than the preset number, it is determined whether the target chapter is a designated core chapter for which the larger model recommends further splitting. If so, splitting continues; otherwise, splitting stops.

[0129] Optionally, the splitting tasks for different target chapters can be processed concurrently through an asynchronous queue until all splitting tasks are completed and the chapter description information for all chapters of the entire outline is generated.

[0130] In the above embodiments, the splitting conditions are determined by integrating multiple aspects such as the level to which the target chapter belongs, the number of associated files, and the type of the target chapter. This can more accurately determine whether to split the target chapter and improve the accuracy of outline generation.

[0131] In one embodiment, such as Figure 8 As shown, the steps for further splitting sub-chaps may include:

[0132] S801, based on the chapter description information of the sub-chapter, determine the associated files of the sub-chapter in each technical document.

[0133] Optionally, the chapter description information of the sub-chapter includes the sub-chapter's glob pattern. Based on the glob pattern, the associated files of the sub-chapter in each technical document can be matched.

[0134] S802, construct the second tree structure based on the file path of the associated file.

[0135] Understandably, there can be multiple associated files for a sub-section. To reduce the number of tokens input to a large model, the file paths of each associated file are compressed into a second tree structure. The second tree structure can be found by referring to... Figure 3 The first tree structure shown in the image also uses line breaks and spaces to represent the hierarchical relationship of file paths, and different file extensions to represent different file types.

[0136] S803, construct chapter splitting prompt text based on the second tree structure.

[0137] In this process, the second tree structure is placed in the chapter splitting prompt text. The large model can intelligently select and read files based on the second tree structure, and split the sub-chapter into the next level of sub-chapter according to the code structure. Optionally, when constructing the chapter splitting prompt text, the four-dimensional knowledge of the parent chapter and the four-dimensional knowledge of the sibling chapter can also be placed in the chapter splitting prompt text. The sibling chapter and the sub-chapter are split from the same chapter and belong to the same level as the sub-chapter.

[0138] Optionally, based on the sub-chapter's hierarchy in the outline, a content generation tooltip template is determined for each sub-chapter. The second tree structure is then filled into the content generation tooltip template to obtain the chapter splitting tooltip text. The tooltip text in the content generation tooltip template may include: the sub-chapter's glob pattern should be a subset of the parent chapter's glob pattern; the file format matched by the sub-chapter's glob pattern should be consistent with the file format matched by the parent chapter's glob pattern; all sub-chapter glob patterns should be orthogonal as much as possible, overlapping is allowed, but they should have different meanings or functional perspectives, rather than simple repetition.

[0139] S804: Input the chapter splitting prompt text into the large language model for chapter splitting, and obtain the next level of sub-chapter to which the sub-chapter belongs and the chapter description information of each next level of sub-chapter.

[0140] The process involves inputting the chapter splitting prompt text into a large language model. The large language model can intelligently select the relevant files to be read based on the second tree structure, and then split the sub-chapter into the next level sub-chapter based on the relevant files.

[0141] In the above embodiments, placing the second tree structure into the chapter splitting prompt text can reduce the number of tokens input to the large model, thereby enabling the large model to read as many selected related files as possible during the chapter splitting process, thus improving the accuracy of chapter splitting.

[0142] In one embodiment, special processing is applied to the generation of Java project Application Programming Interface (API) chapters. A series of API files are matched according to rules, and each API file is provided to the large model. The large model generates a chapter for each API file by reading the API files and their dependencies, and incorporates these chapters into the technical documentation outline. Specifically, an API-specific hint template is used, and the build file (with the suffix pom.xml or build.gradle) along with the detected controller and annotation locations are injected into the hint template. Functions such as DocumentsHelper and FileTreeBuilder prioritize extracting the interface entry point and related source code paths. If a missing API file is found, a completion process is triggered (generating complete text, validating, and merging into the root directory structure). After merging, validation and deduplication logic are executed, potentially creating or updating the top-level API directory in the directory tree. API file entries are incorporated into the outline according to strict path / signature validation rules. The entire process emphasizes build file dependency checks, interface signature consistency verification, and the validation and merging of completion results.

[0143] In one embodiment, the step of constructing the second tree structure is further defined, including:

[0144] If the number of associated files is less than or equal to the preset number, the dependent files of each associated file are found from each technical file according to the file dependency relationship of each associated file. Based on the file paths of each associated file and each dependent file, a second tree structure is constructed.

[0145] In cases where a sub-chapter meets the splitting criteria, but the number of associated files for that sub-chapter is less than or equal to a preset number, file supplementation and recall are performed based on file dependencies to ensure the accuracy of the chapter splitting. This ensures that the sum of the number of associated and dependent files reaches the preset number. Dependent files can be selected based on the distance between technical files and associated files in the file dependency relationship. For example, the number of files between dependent and associated files can be less than a specified number, which can be set based on experience, multiple trials, and actual needs. During the content generation stage, the large model can also read file dependencies and read files accordingly to prevent insufficient depth in the generated content. Furthermore, if the number of associated files for a sub-chapter is 0, it can fall back to the associated files of the parent chapter and construct a second tree structure based on the associated files of the parent chapter.

[0146] Optionally, the file dependency relationship is a call graph composed of various technical files. Each node in the call graph represents a technical file. For an associated file, when searching for dependent files of the associated file, a breadth-first expansion is performed on the call graph starting from the associated file. Files directly dependent on the associated file and the dependent files (with a distance of 1 from the associated file) are prioritized. Then, two-hop and three-hop nodes are captured in ascending order of distance as dependent files until the number of associated files and dependent files reaches a preset number. If enough dependent files cannot be obtained from the call graph based on distance, the file system proximity strategy is used. Files in the same directory as the associated file, sibling files in the same parent directory, and files in the parent directory are used as candidate files. Then, the scores of the candidate files are determined according to the path similarity (prefix / segment similarity) and filename similarity between the associated file and the candidate files. The candidate files corresponding to the top N scores are returned as dependent files. If necessary, the candidate files are fine-tuned using semantic similarity.

[0147] In the above embodiments, when the number of associated files is less than or equal to a preset number, the dependent files of the associated files are recalled according to the file dependency relationship, so that the large model can be split into chapters based on sufficient technical files, thereby improving the accuracy of chapter splitting.

[0148] In one embodiment, the step of further splitting the sub-sections is further refined, including:

[0149] Based on the chapter description information of the sub-chapter and the chapter description information of each historical sub-chapter, the similarity between the sub-chapter and each historical sub-chapter is determined; if no similarity exceeds the similarity threshold, it is determined whether the sub-chapter meets the splitting conditions; if the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next level of sub-chapter and the chapter description information of the next level of sub-chapter.

[0150] Each historical sub-chapter is a sub-chapter split from a previous sub-chapter. After splitting to obtain a sub-chapter, the similarity (e.g., semantic similarity) between the sub-chapter and the historical sub-chapter is first calculated. If no similarity score exceeds a similarity threshold, it means there is no historical sub-chapter with high similarity to the sub-chapter. The sub-chapter can then be further evaluated to determine if it meets the splitting criteria. If it does, a new round of splitting is performed. The similarity threshold can be set based on experience, multiple trials, and actual needs. If no similarity score exceeds the similarity threshold, the sub-chapter can be immediately added to the local snapshot to avoid duplication among sub-chapters in the same batch.

[0151] In the above embodiments, the split sub-sections are deduplicated based on the similarity between the sub-sections and historical sub-sections, avoiding redundant sections in the outline, thus ensuring the quality of the generated outline and improving the accuracy of the technical documents.

[0152] In one embodiment, if any similarity is greater than a similarity threshold, the subsection is deleted from its hierarchical level.

[0153] In this case, if any similarity score is greater than the similarity threshold, it indicates that the sub-chapter is a duplicate chapter, and the sub-chapter can be deleted from its level without needing to perform a splitting condition determination step.

[0154] In the above embodiments, redundant sub-sections are deleted, and subsequent splitting conditions are no longer determined, which can save computing resources and improve the generation efficiency of technical documents.

[0155] Based on the above embodiments, the generated technical documentation enables developers to improve their efficiency, quickly grasp the project architecture, improve code review efficiency, and assist in code refactoring and optimization; accelerate new employee training and team knowledge accumulation, reduce new employee training costs, and improve the efficiency of technical sharing and communication; increase the pass rate of repository-level tasks, while reducing token consumption and the inference step size of large models.

[0156] Based on the above embodiments, in an exemplary embodiment, such as Figure 9 As shown, the document generation method in this application embodiment may include the following steps:

[0157] S901, based on the first tree structure composed of the file paths of the various technical documents of the target project, construct the outline to generate prompt text.

[0158] S902, through a large language model:

[0159] S9021, Based on the first tree structure generated in the outline prompt text, select the target file to be read from each technical file.

[0160] S9022, for each target file, if the target file is a code file, compress the target file to obtain a compressed code file, and obtain the compressed file corresponding to the target file based on the compressed code file, the file dependency relationship between the target file and each technical file; if the target file is not a code file, determine the extraction range of the target file based on the file name of the target file, and obtain the content within the extraction range from the target file to obtain the compressed file corresponding to the target file.

[0161] S9023, based on each compressed file, output the outline of the technical document for the target project and the chapter description information of each initial chapter in the outline.

[0162] S903, for each initial chapter, if the initial chapter meets the splitting conditions, recursively split the initial chapter according to the chapter description information, and during the recursive splitting process, after each round of splitting, for each sub-chapter obtained by the splitting:

[0163] S9031, Based on the chapter description information of the sub-chapter and the chapter description information of each historical sub-chapter, determine the similarity between the sub-chapter and each historical sub-chapter;

[0164] S9032, if no similarity exceeds the similarity threshold, determine whether the sub-section meets the splitting conditions; if the sub-section meets the splitting conditions, determine the associated files of the sub-section in each technical document based on the sub-section's chapter description information;

[0165] S9033, when the number of associated files is less than or equal to the preset number, search for the dependent files of each associated file from each technical file according to the file dependency relationship of each associated file; construct a second tree structure according to the file path of each associated file and the file path of each dependent file.

[0166] S9034, Based on the second tree structure, construct chapter splitting prompt text; input the chapter splitting prompt text into the large language model for chapter splitting, and obtain the next level of sub-chapter to which the sub-chapter belongs and the chapter description information of each next level of sub-chapter.

[0167] S904, if the sub-chapter at each level does not meet the splitting conditions, stop the recursive splitting of the initial chapter and obtain the sub-chapter at different levels under the initial chapter and the chapter description information of each sub-chapter.

[0168] S905: For each sub-chapter, construct content-generating prompt text based on the sub-chapter's chapter description information; using a large language model, obtain the associated file identifiers in the content-generating prompt text, retrieve the associated files of the sub-chapter in each technical document, and generate the sub-chapter's chapter content based on the associated files.

[0169] S906, Based on the outline and the content of the sub-chapters under each initial chapter, generate the technical documentation for the target project.

[0170] The specific implementation methods of S901-S906 are the same as those in the above method embodiments, and will not be repeated here.

[0171] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0172] Based on the same inventive concept, this application also provides a document generation apparatus for implementing the document generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more document generation apparatus embodiments provided below can be found in the limitations of the document generation method described above, and will not be repeated here.

[0173] In one exemplary embodiment, such as Figure 10 As shown, a document generation device is provided, including: a construction module 1001, an outline generation module 1002, a content generation module 1003, and a document generation module 1004, wherein:

[0174] Module 1001 is used to build an outline and generate prompt text based on the first tree structure composed of the file paths of the various technical documents of the target project.

[0175] The outline generation module 1002 is used to generate an outline based on the outline generation prompt text using a large language model, so as to obtain the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline;

[0176] The content generation module 1003 is used to recursively split each initial chapter according to the chapter description information of each initial chapter in order to obtain the chapter content of the sub-chapter under each initial chapter.

[0177] The document generation module 1004 is used to generate technical documents for the target project based on the outline and the content of the sub-chaps under each initial chapter.

[0178] In one embodiment, the outline generation module 1002 includes:

[0179] The selection unit is used to generate the first tree structure in the prompt text based on the outline using a large language model, and to select the target file to be read from various technical documents.

[0180] The acquisition unit is used to acquire the compressed file corresponding to each target file through the large language model, and output the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline based on each compressed file.

[0181] In one embodiment, the acquisition unit is specifically used for:

[0182] For each target file, if the target file is a code file, the target file is compressed to obtain a compressed code file. Based on the compressed code file and the file dependencies between the target file and each technical file, the corresponding compressed file of the target file is obtained.

[0183] If the target file is not a code file, the extraction range of the target file is determined based on the file name of the target file, and the content within the extraction range is obtained from the target file to obtain the compressed file corresponding to the target file.

[0184] In one embodiment, the content generation module 1003 includes:

[0185] The splitting unit is used to recursively split each initial chapter according to its chapter description information, provided that the initial chapter meets the splitting conditions, to obtain the sub-chapters under the initial chapter and the chapter description information of each sub-chapter.

[0186] The generation unit is used to generate the chapter content of the corresponding sub-chapter based on the chapter description information of each sub-chapter.

[0187] In one embodiment, the splitting unit is specifically used for:

[0188] Based on the chapter description information of the initial chapter, the initial chapter is recursively split. During the recursive splitting process, after each round of splitting, for each sub-chapter obtained by splitting, if the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next level of sub-chapter and the chapter description information of the next level of sub-chapter.

[0189] If none of the sub-chaps at each level meet the splitting conditions, stop the recursive splitting of the initial chapter, and obtain the sub-chaps at different levels under the initial chapter and the chapter description information of each sub-chapter.

[0190] In one embodiment, the splitting conditions include at least one of the following:

[0191] The target chapter belongs to a lower level than the preset level, and the number of related files of the target chapter in each technical document is greater than the preset number;

[0192] The target chapter belongs to a lower level than the preset level, the number of related files of the target chapter in each technical document does not exceed the preset number, and the type of the target chapter is the target type;

[0193] The target chapter is either the initial chapter or a sub-chapter.

[0194] In one embodiment, the splitting unit is specifically used for:

[0195] Based on the chapter description information of the sub-chapter, determine the associated files of the sub-chapter in each technical document;

[0196] Construct a second tree structure based on the file paths of the associated files;

[0197] Based on the second tree structure, construct chapter splitting prompt text;

[0198] The chapter splitting prompt text is input into the large language model for chapter splitting, which yields the next level of sub-chapter to which the sub-chapter belongs and the chapter description information of each next level of sub-chapter.

[0199] In one embodiment, the splitting unit is specifically used for:

[0200] If the number of associated files is less than or equal to the preset number, the dependent files of each associated file are found from each technical file according to the file dependency relationship of each associated file.

[0201] Construct a second tree structure based on the file paths of each associated file and each dependent file.

[0202] In one embodiment, the splitting unit is specifically used for:

[0203] Based on the chapter description information of the sub-chapter and the chapter description information of each historical sub-chapter, determine the similarity between the sub-chapter and each historical sub-chapter; where each historical sub-chapter is a sub-chapter that was split off before the sub-chapter.

[0204] If no similarity score exceeds the similarity threshold, determine whether the sub-chapter meets the splitting criteria.

[0205] If a sub-chapter meets the splitting criteria, a new round of splitting is performed on the sub-chapter to obtain the next level of sub-chapter and the chapter description information of the next level of sub-chapter.

[0206] In one embodiment, the splitting unit is further configured to:

[0207] If any similarity score exceeds the similarity threshold, the subsection will be removed from its corresponding level.

[0208] In one embodiment, the chapter description information of each sub-chapter includes the associated file identifier of the sub-chapter; the generation unit is specifically used for:

[0209] For each sub-chapter, generate prompt text based on the sub-chapter's description information;

[0210] Using a large language model, the associated file identifiers in the prompt text are generated based on the content. The associated files of each sub-chapter in each technical document are obtained, and the chapter content of the sub-chapter is generated based on the associated files.

[0211] In one embodiment, the construction module 1001 is specifically used for:

[0212] Based on the development type of the target project, determine the corresponding outline template for the target project;

[0213] Based on the first tree structure consisting of the outline prompt template and the file paths of the technical files of the target project in the code repository, construct the outline prompt text.

[0214] Each module in the aforementioned document generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.

[0215] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as technical documents. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a document generation method.

[0216] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0217] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0218] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0219] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0220] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0221] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0222] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0223] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A document generation method, characterized in that, The method includes: Based on the first tree structure composed of the file paths of the various technical documents of the target project, construct an outline to generate prompt text; Using a large language model, a prompt text is generated based on the outline to generate an outline, resulting in an outline of the technical document for the target project and chapter description information for each initial chapter in the outline. Based on the chapter description information of each initial chapter, each initial chapter is recursively split to obtain the chapter content of the sub-chapter under each initial chapter; Based on the outline and the content of the sub-chapters under each initial chapter, generate the technical documentation for the target project.

2. The method according to claim 1, characterized in that, The process involves generating an outline using a large language model, generating prompt text based on the outline, and obtaining the outline of the technical document for the target project and the chapter description information of each initial chapter in the outline, including: Using a large language model, the first tree structure in the prompt text is generated based on the outline; and the target file to be read is selected from each of the technical documents; and... Obtain the compressed file corresponding to each target file, and based on each compressed file, output the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline.

3. The method according to claim 2, characterized in that, The step of obtaining the compressed file corresponding to each target file includes: For each target file, if the target file is a code file, the target file is compressed to obtain a compressed code file, and a compressed file corresponding to the target file is obtained according to the compressed code file and the file dependency relationship between the target file and each of the technical files; If the target file is not a code file, the extraction range of the target file is determined based on the file name of the target file, and the content within the extraction range is obtained from the target file to obtain the compressed file corresponding to the target file.

4. The method according to claim 1, characterized in that, The process of recursively splitting each initial chapter according to its chapter description information to obtain the chapter content of each sub-chapter under each initial chapter includes: For each initial chapter, if the initial chapter meets the splitting conditions, the initial chapter is recursively split according to the chapter description information of the initial chapter to obtain the sub-chapter under the initial chapter and the chapter description information of each sub-chapter; Based on the chapter description information of each sub-chapter, generate the chapter content of the corresponding sub-chapter.

5. The method according to claim 4, characterized in that, The step of recursively splitting the initial chapter according to its chapter description information to obtain sub-chapters and chapter description information for each sub-chapter includes: Based on the chapter description information of the initial chapter, the initial chapter is recursively split. During the recursive splitting process, after each round of splitting, for each sub-chapter obtained by splitting, if the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next level sub-chapter of the level to which the sub-chapter belongs and the chapter description information of the next level sub-chapter. If none of the sub-chapter levels meet the splitting conditions, the recursive splitting of the initial chapter is stopped, resulting in sub-chapter levels under the initial chapter and chapter description information for each sub-chapter.

6. The method according to claim 5, characterized in that, The splitting conditions include at least one of the following: The target chapter belongs to a lower level than a preset level, and the number of associated files of the target chapter in each of the technical documents is greater than a preset number; The target chapter belongs to a lower level than the preset level, the number of associated files of the target chapter in each of the technical documents is not greater than the preset number, and the type of the target chapter is the target type; The target chapter is either the initial chapter or a sub-chapter.

7. The method according to claim 5, characterized in that, The step of further splitting the sub-chapter to obtain the next-level sub-chapter of the level to which the sub-chapter belongs and the chapter description information of the next-level sub-chapter includes: Based on the chapter description information of the sub-chapter, determine the associated files of the sub-chapter in each of the technical documents; Construct a second tree structure based on the file paths of the associated files; Based on the second tree structure, construct the chapter splitting prompt text; The chapter splitting prompt text is input into a large language model for chapter splitting, to obtain the next level of sub-chapter to which the sub-chapter belongs and the chapter description information of each next level of sub-chapter.

8. The method according to claim 7, characterized in that, The step of constructing a second tree structure based on the file path of the associated file includes: If the number of associated files is less than or equal to a preset number, the dependent files of each associated file are searched from each of the technical files according to the file dependency relationship of each associated file; A second tree structure is constructed based on the file paths of each associated file and each dependent file.

9. The method according to claim 6, characterized in that, When the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next-level sub-chapter of the sub-chapter's hierarchy and the chapter description information of the next-level sub-chapter, including: Based on the chapter description information of the sub-chapter and the chapter description information of each historical sub-chapter, the similarity between the sub-chapter and each historical sub-chapter is determined; wherein, each historical sub-chapter is a sub-chapter that was split off before the sub-chapter. If no similarity score is greater than the similarity threshold, determine whether the sub-section meets the splitting conditions; If the sub-chapter meets the splitting conditions, a new round of splitting is performed on the sub-chapter to obtain the next level sub-chapter of the level to which the sub-chapter belongs and the chapter description information of the next level sub-chapter.

10. The method according to claim 9, characterized in that, The method further includes: If any similarity score exceeds the similarity threshold, the subsection will be removed from its corresponding level.

11. The method according to claim 4, characterized in that, The chapter description information for each sub-chapter includes the associated file identifier of the sub-chapter; generating the chapter content of the sub-chapter based on the chapter description information of each sub-chapter includes: For each sub-chapter, a prompt text is generated based on the chapter description information of the sub-chapter; Using the large language model, the associated file identifier in the prompt text is generated based on the content, the associated files of the sub-chapter in each technical file are obtained, and the chapter content of the sub-chapter is generated based on the associated files.

12. The method according to any one of claims 1 to 11, characterized in that, The process of constructing an outline and generating prompt text based on the first tree structure composed of the file paths of the various technical documents of the target project includes: Based on the development type of the target project, determine the outline template corresponding to the target project; Based on the outline prompt template and the file paths of the technical files of the target project in the code repository, an outline prompt text is generated.

13. A document generation apparatus, characterized in that, The device includes: The build module is used to construct an outline and generate prompt text based on the first tree structure composed of the file paths of the various technical documents of the target project. The outline generation module is used to generate an outline based on the outline prompt text using a large language model, thereby obtaining the outline of the technical document of the target project and the chapter description information of each initial chapter in the outline; The content generation module is used to recursively split each initial chapter according to the chapter description information of each initial chapter in order to obtain the chapter content of the sub-chapter under each initial chapter. The document generation module is used to generate technical documents for the target project based on the outline and the chapter content of the sub-chaps under each initial chapter.

14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 12.

15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 12.

16. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 12.