Software design document generation method and system
By combining a vector database and a structured template library, and using query vectors to accurately match project knowledge, structured software design documents are automatically generated. This solves the problems of low writing efficiency and difficulty in standardization in existing technologies, and achieves efficient and accurate document generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- LINGSHU TECH CO LTD
- Filing Date
- 2026-02-12
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, software design documentation is inefficient and difficult to standardize. The lack of domain knowledge in general-purpose language models leads to empty and inaccurate generated content, and unstructured knowledge is difficult to assemble in a standardized manner.
By acquiring vector databases and structured template libraries, and using query vectors to accurately match project-related knowledge, structured software design documents are automatically generated. Combined with targeted retrieval and generation mechanisms, a closed-loop process from data upload to document generation is achieved.
It significantly improves document writing efficiency, ensures that generated content is based on actual project knowledge, prevents illusions, and ensures the accuracy and standardization of documents.
Smart Images

Figure CN122174815A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information technology, and in particular to a method and system for generating software design documents. Background Technology
[0002] Software design documents are key deliverables in software engineering activities, typically taking the form of preliminary design specifications, detailed design specifications, interface documents, database design documents, etc. These documents systematically describe the core design information of the software system, including its architecture, module division, data structures, interface protocols, business processes, and deployment environment. They serve as crucial evidence for project development, team collaboration, quality review, post-launch maintenance, and knowledge transfer. Their completeness and accuracy directly impact the controllability, maintainability, and delivery quality of the software project.
[0003] In current software engineering practices, the writing of software design documents (such as preliminary design, detailed design, interface documentation, etc.) suffers from the following problems: Low writing efficiency and repetitive work: Developers need to spend a lot of time sorting out old data, code logic and technical solutions, resulting in a lot of formatted and boilerplate repetitive writing.
[0004] The lack of domain knowledge in the general large model (illusion problem): When using the general large language model (LLM) directly to generate design documents, the lack of private knowledge within the project (such as private API definitions, specific database architecture, business rules) in the model leads to empty, inaccurate, or even illusion-like content.
[0005] The contradiction between unstructured knowledge and structured documents: Existing knowledge bases mostly consist of unstructured data (Wiki, PDF, Word), while design documents require strict structured formats (such as the CMMI standard). Current technologies struggle to accurately "assemble" fragmented knowledge into standardized document templates, resulting in generated documents with chaotic formats that cannot be directly used for production delivery.
[0006] There is currently no effective solution to the problems of low efficiency and difficulty in standardization of software design documentation in existing technologies. Summary of the Invention
[0007] To address the aforementioned issues, this invention provides a software design document generation and system. It generates query vectors based on a target structured template and accurately matches project-related knowledge from a vector database. Combined with the constraints of the structured template, it automatically generates documents, thereby improving efficiency while ensuring the accuracy and standardization of the documents.
[0008] To achieve the above objectives, the present invention provides a method for generating software design documents, comprising: acquiring a vector database, a structured template library, and a document generation request; selecting a target structured template from the structured template library according to the document generation request; wherein the target structured template includes chapter constraints; generating a query vector according to the chapter constraints of the target structured template; matching target vectorized data from the vector database according to the query vector, and retrieving target text data corresponding to the target vectorized data; and generating a target design document according to the chapter constraints of the target structured template, the document generation request, and the target text data.
[0009] Further optionally, the process of generating the vector database includes: obtaining raw data from at least one data source; performing text cleaning and text slicing on each piece of raw data to obtain corresponding text segments; performing vectorization on each text segment to obtain corresponding vectorized data; and storing all vectorized data in the vector database.
[0010] Optionally, the generation process of the structured template database includes: obtaining template definition data; generating a corresponding structured template based on the template definition data; and storing the structured template in the structured template library; wherein the structured template includes document type, chapter hierarchy structure, and chapter constraints for each chapter.
[0011] Further optionally, the step of generating a query vector based on the chapter constraints of the target structured template, and matching target vectorized data from the vector database based on the query vector, includes: constructing a corresponding chapter task for each chapter in the target structured template; generating a query vector for the current chapter task based on the corresponding chapter constraints; and performing semantic similarity matching in the vector database based on the query vector and preset matching rules to obtain at least one target vectorized data corresponding to the current chapter task.
[0012] Optionally, generating the target design document based on the chapter constraints of the target structured template, the document generation request, and the target text data includes: fusing the target text data, chapter constraints, and user instructions in the document generation request corresponding to each chapter task to obtain chapter generation prompts for each chapter task; inputting the chapter generation prompts for each chapter task into the text generation model to obtain the text content corresponding to each chapter task; and filling the text content of each chapter task into the predetermined position of the corresponding chapter to obtain the target design document.
[0013] On the other hand, the present invention also provides a software design document generation system, comprising: a data acquisition module for acquiring a vector database, a structured template library, and a document generation request; a template selection module for selecting a target structured template in the structured template library according to the document generation request; wherein the target structured template includes chapter constraints; a data matching module for generating a query vector according to the chapter constraints of the target structured template, matching target vectorized data from the vector database according to the query vector, and retrieving target text data corresponding to the target vectorized data; and a design document generation module for generating a target design document according to the chapter constraints of the target structured template, the document generation request, and the target text data.
[0014] Further optionally, it also includes: a raw data acquisition module for acquiring raw data from at least one data source; a text processing module for performing text cleaning and text slicing processing on each of the raw data to obtain corresponding text fragments; and a vector processing module for performing vectorization processing on each of the text fragments to obtain corresponding vectorized data, and storing all vectorized data in the vector database.
[0015] Further optionally, it also includes: a template definition data acquisition module for acquiring template definition data; and a template generation module for generating a corresponding structured template based on the template definition data and storing the structured template in the structured template library; wherein the structured template includes document type, chapter hierarchy structure, and chapter constraints for each chapter.
[0016] Further optionally, the data matching module includes: a chapter task construction submodule, used to construct a corresponding chapter task for each chapter in the target structured template; a query vector generation submodule, used to generate a query vector for the current chapter task according to the corresponding chapter constraints; and a semantic similarity matching submodule, used to perform semantic similarity matching in the vector database according to the query vector and preset matching rules to obtain at least one target vectorized data corresponding to the current chapter task.
[0017] Further optionally, the design document generation module includes: a prompt word generation submodule, used to integrate the target text data corresponding to each chapter task, chapter constraints, and user instructions in the document generation request to obtain chapter generation prompts corresponding to each chapter task; a text content generation submodule, used to input the chapter generation prompts of each chapter task into a text generation model to obtain the text content corresponding to each chapter task; and a filling submodule, used to fill the text content of each chapter task into the predetermined position of the corresponding chapter to obtain the target design document.
[0018] The above technical solution has the following beneficial effects: It adopts a template-based targeted retrieval and generation mechanism, realizing a closed loop from data upload to document generation, significantly reducing manual sorting and repetitive writing, thereby improving document writing efficiency; Through vectorization processing and precise matching, it ensures that the generated content is based on actual project knowledge, effectively preventing the illusion caused by general models, thereby improving the accuracy of the document; Through structured templates, it enforces constraints on the organizational framework of the generated content, ensuring that unstructured knowledge can be assembled in a standardized manner, thereby guaranteeing the standardization and compliance of the document. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of the software design document generation method provided in the embodiments of the present invention; Figure 2 This is a flowchart of the vector database generation method provided in the embodiments of the present invention; Figure 3 This is a flowchart of the structured template library generation method provided in this embodiment of the invention; Figure 4 This is a flowchart of the target vector data determination method provided in the embodiments of the present invention; Figure 5 This is a flowchart of the target design document generation method provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of the software design document generation system provided in an embodiment of the present invention; Figure 7 This is a schematic diagram of the structure of a module for generating a vector database provided in an embodiment of the present invention; Figure 8 This is a schematic diagram of the structure of a template for generating a structured template library provided in an embodiment of the present invention; Figure 9 This is a schematic diagram of the structure of the data matching module provided in an embodiment of the present invention; Figure 10 This is a schematic diagram of the design document generation module provided in an embodiment of the present invention.
[0021] Figure labeling: 100-Data acquisition module; 200-Template selection module; 300-Data matching module; 3001-Chapter task construction submodule; 3002-Query vector generation submodule; 3003-Semantic similarity matching submodule; 400-Design document generation module; 4001-Prompt word generation submodule; 4002-Text content generation submodule; 4003-Fill submodule; 500-Original data acquisition module; 600-Text processing module; 700-Vector processing module; 800-Template definition data acquisition module; 900-Template generation module. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] To address the problems of low efficiency and difficulty in standardization in existing software design document writing, this invention provides a method for generating software design documents. Figure 1 This is a flowchart of the software design document generation method provided in the embodiments of the present invention, such as... Figure 1 As shown, the method includes: S1. Obtain the vector database, structured template library, and document generation request.
[0024] Accessing the vector database refers to connecting to a pre-built, dedicated database that stores semantic vectors of the enterprise's proprietary knowledge. Each vectorized data in this database has an index relationship with its corresponding text data, enabling subsequent retrieval of the text data based on the vectorized data. This database is independently built and persistent, and is updated periodically. The vector database stores processed semantic representations of project history documents, code comments, API descriptions, and other materials.
[0025] Generating a structured template database refers to accessing a predefined and managed collection of document templates. Each template specifies a fixed chapter structure, formatting requirements, and writing guidelines for each chapter of a particular type of document (such as a "detailed design specification"). For example, a file titled "Microservice Detailed Design Template.docx" predefines the inclusion of chapters such as "1. Overview," "2. Interface Design," and "3. Database Design," and provides a framework constraint on the content to be described in each section.
[0026] A document generation request is a user-input instruction to generate documents based on their needs. This request is the starting point for triggering the entire automation process, specifying "what is needed" and "what is about". For example, if a user selects the template "Detailed Design Specification" in the front-end interface and enters the instruction "Generate detailed design of the order refund module" in the input box, then the user's selected template and instruction together constitute the document generation request.
[0027] S2. Select the target structured template from the structured template library according to the document generation request; the target structured template includes chapter constraints.
[0028] Matching is performed based on the document type specified or implicit in the document generation request, which is usually an explicit classification identifier. The front-end interface provides a type selection box so users can directly select the template type. This is the specified document type, and a target structured template of the same type or name can be selected from the structured template library based on the selected template type. Alternatively, the template type can be determined by recognizing user input commands (e.g., if the user command is "generate a detailed design specification for the order payment module," then the keyword "detailed design specification" is the template type). This is the implicit document type, and a target structured template of the same type or name can be selected from the structured template library based on the recognized document type.
[0029] The target structured template is a document structure definition that carries metadata and generation rules. Each chapter corresponds to a chapter constraint, which is the predefined content requirements, writing standards or generation guidelines for the corresponding chapter.
[0030] S3. Generate a query vector based on the chapter constraints of the target structured template, match the target vectorized data from the vector database based on the query vector, and retrieve the target text data corresponding to the target vectorized data.
[0031] Based on the chapter constraints defined for each chapter in the target structured template, a query representation (i.e., query vector) that represents the semantic knowledge required for that chapter is automatically constructed. The purpose is to transform chapter constraints into retrieval instructions.
[0032] The system retrieves vector data from the vector database based on the query vector and matches some vectorized data with high similarity. These vectorized data are then used as the target vectorized data.
[0033] The target text data corresponding to the target vectorized data is retrieved through the index mapping relationship so that it can participate in the subsequent text content generation.
[0034] S4. Generate the target design document based on the chapter constraints of the target structured template, the document generation request, and the target text data.
[0035] The document generation is designed based on the document generation request that reflects the user's specific intent, the target text data representing specific factual materials retrieved from the knowledge base, and the chapter constraints of the target structured template that specifies the document framework and the specific content requirements of each chapter.
[0036] Specifically, the document generation function is achieved based on a preset mapping rule or generation algorithm that transforms the above three input elements into the final document, such as the Retrieval Enhancement Generation Algorithm (RAG), in order to obtain the target design document.
[0037] As an optional implementation method, Figure 2 This is a flowchart of the vector database generation method provided in the embodiments of the present invention, such as... Figure 2 As shown, the process of generating a vector database includes: S5. Obtain the original data from at least one data source.
[0038] Before acquiring the vector database, it is necessary to build the vector database in advance, based on a large amount of original data.
[0039] To ensure data diversity, raw data should be collected from multiple data sources. These sources primarily include internal enterprise knowledge bases, such as project documents, technical solutions, and meeting minutes on collaboration platforms; documentation and code comments in version control systems; and historical design materials stored in document management systems. Additionally, personal files, such as common office documents, portable documents, and plain text files, can be uploaded to the cloud. Furthermore, publicly accessible web resources, such as internal technical blogs or relevant specification websites, can be collected automatically using a crawling module. Raw data refers to the initial files or page content directly obtained from the above channels. This raw data is uniformly stored in object storage (such as MinIO / S3) as a raw asset pool.
[0040] Data acquisition is primarily achieved through various methods. For structured online knowledge bases or platforms, automated collection methods are typically employed, such as configuring web crawler tasks for periodic fetching or utilizing application programming interfaces (APIs) for efficient integration and synchronization. For scattered local files, a user interface is used to support batch or single file uploads.
[0041] S6. Perform text cleaning and text slicing on each piece of original data to obtain the corresponding text fragments.
[0042] The raw data may contain additional information unrelated to the core knowledge, requiring preprocessing for each piece of raw data acquired. It should be noted that the preprocessing step can be performed asynchronously with data acquisition; for example, a scheduled task can trigger a background processing flow to preprocess the unstructured raw data in the original asset pool.
[0043] Preprocessing mainly includes text cleaning and text slicing. Text cleaning primarily aims to remove irrelevant and distracting information from the raw data. This includes removing formatting tags from documents, such as HTML code in web pages and style tags in Word documents; filtering out inherent page noise, such as advertisements, navigation bars, headers, footers, and copyright notices; and performing text normalization, such as correcting encoding errors and standardizing number and date formats.
[0044] Text slicing aims to break down lengthy, cleaned documents into appropriately sized, semantically complete segments. A simple implementation involves fixed-length overlapping slices, cutting by a specified number of characters while retaining some overlap to prevent the complete semantic meaning from being fragmented at the split point. A better approach is intelligent segmentation based on semantic boundaries, utilizing natural language processing techniques to segment at the end of paragraphs, headings, or sentence groups, ensuring that each slice expresses a relatively independent meaning, such as a complete functional description, an interface definition, or a database table description.
[0045] By combining text cleaning and text slicing, the original data was transformed into text fragments with independent semantics.
[0046] S7. Perform vectorization processing on each text segment to obtain the corresponding vectorized data, and store all vectorized data in the vector database.
[0047] Vectorization refers to using a specialized embedding model to map each text fragment from its original natural language form into a numerical vector in a high-dimensional space. Text fragments with similar semantics will have their corresponding vectors closer together in space.
[0048] These generated semantic vectors and their corresponding original text fragments are persistently stored in a dedicated vector database. A vector database is a system optimized for efficient storage and retrieval of high-dimensional vector data. It establishes a specialized index structure for all stored vectors, enabling the retrieval process to quickly find the few most similar vectors to the query vector from massive amounts of data.
[0049] As an optional implementation method, Figure 3 This is a flowchart of the structured template library generation method provided in the embodiments of the present invention, such as... Figure 3As shown, the process of generating a structured template database includes: S8. Obtain template definition data.
[0050] Before obtaining the structured template database, it is necessary to build the structured template database in advance.
[0051] Users input template definition data through the system's interactive interface. Typically, the system provides a template editing and management interface, allowing users to create new document type templates or modify existing ones. The specifications defined by the user in this interface constitute the template definition data.
[0052] S9. Generate the corresponding structured template based on the template definition data, and store the structured template in the structured template library; wherein, the structured template includes document type, chapter hierarchy structure and chapter constraints for each chapter.
[0053] The template definition data is parsed to validate its basic logic. Then, an internal template object is created based on this data. This object explicitly records the document type identifier, constructs a tree-like chapter hierarchy, and transforms the specific writing requirements or guidelines set by the user for each chapter into metadata (chapter constraints, such as "this chapter needs to reference the database table structure") attached to the corresponding chapter node.
[0054] As an optional implementation method, Figure 4 This is a flowchart of the target vector data determination method provided in the embodiments of the present invention, such as... Figure 4 As shown, a query vector is generated based on the chapter constraints of the target structured template. The target vectorized data is then matched from the vector database based on the query vector, including: S301. Build corresponding chapter tasks for each chapter in the target structured template.
[0055] Iterate through all chapters defined in the selected target structured template. For each chapter, create a separate task instance based on its definition in the template (including its hierarchical position, title, and associated chapter constraints).
[0056] This chapter task instance is a structured data object that encapsulates all the core information and instructions needed to generate the chapter. It includes at least the chapter's unique identifier, title text, specific content constraints and generation guidelines inherited from the template, and its hierarchical relationship within the entire document.
[0057] As an alternative implementation, different chapter tasks can be processed in parallel across multiple threads.
[0058] S302. For the current chapter task, generate a query vector based on the corresponding chapter constraints.
[0059] For each chapter task, it is processed as the current chapter task and transformed into a query vector. For the current chapter task, its chapter constraints are transformed into a query vector.
[0060] As an optional implementation, the structured chapter constraints in the current chapter task (such as "the request and response format of the interface needs to be described") are used as natural language query text that can fully express the knowledge scope required for the chapter. Then, a pre-selected embedding model is called to convert this query text into a numerical vector in a high-dimensional space, i.e., a query vector. Furthermore, when constructing the natural language query text, it can also be constructed by combining the chapter title and the overall subject of the corresponding document type.
[0061] S303. Based on the query vector and preset matching rules, perform semantic similarity matching in the vector database to obtain at least one target vectorized data corresponding to the current chapter task.
[0062] Calculate the semantic similarity (e.g., cosine similarity) between the query vector and each vectorized data in the vector database, and filter the target vectorized data according to preset matching rules. The preset matching rules include: using vectorized data with semantic similarity exceeding a preset similarity threshold as target vectorized data; or using one or more (i.e., TOP-K) vectorized data with the highest similarity as target vectorized data.
[0063] Subsequently, the target text data is determined and retrieved based on the target vectorized data.
[0064] As an optional implementation, after obtaining the target text data, it is necessary to perform deduplication, reordering, and context window adaptation to remove noisy data.
[0065] Deduplication typically involves comparing the semantic similarity between target text data (or combining surface feature comparison) to select a more complete text from the text data with high similarity; re-ranking is usually based on semantic similarity and may also introduce more refined ranking models (such as cross-encoders) or perform secondary scoring and ranking of fragments based on rules (such as information completeness, source authority, publication time, etc.) to ensure that the most relevant and reliable fragments are placed first; context window adaptation usually adopts a strategy of truncating the least important fragments from the end or performing intelligent summarization extraction on long fragments to adapt the overall input scale to the range that the model can handle while preserving the core semantics.
[0066] As an optional implementation method, Figure 5 This is a flowchart of the target design document generation method provided in an embodiment of the present invention, such as... Figure 5As shown, based on the chapter constraints of the target structured template, the document generation request, and the target text data, the target design document is generated, including: S401. Integrate the target text data, chapter constraints, and user instructions in the document generation request corresponding to each chapter task to obtain the chapter generation prompts corresponding to each chapter task.
[0067] The system uses a predefined prompt template as its basic framework. This template is a text structure containing fixed guiding statements and variable placeholders. Content from three sources is sequentially inserted into the corresponding positions in the template through variable substitution or contextual concatenation to generate chapter prompts.
[0068] First, the target text data is organized and formatted, and then filled into the prompt as factual basis for generating the required reference, usually guided by identifiers such as "Reference Information:" or "Background Information:".
[0069] Secondly, the chapter constraints are extracted from the template, which clarifies the rules of "what must be written" and "how to write" in the chapter. This part will be integrated into specific requirements for the model, such as "please ensure that the following points are included:".
[0070] Finally, extract the most relevant specific themes and focuses from the user instructions in the document generation request, and use them as the core description of the generation task, such as "Based on the above information, please write the chapter content on 'Order Payment Interface Design'".
[0071] S402. Input the chapter generation prompts for each chapter task into the text generation model to obtain the text content corresponding to each chapter task.
[0072] Following the document's structural order (or based on task dependencies), each chapter's task is processed sequentially. For each task, its corresponding chapter generation hints are used as complete input, and a deployed text generation model (typically a large language model such as GPT-5 or ChatGLM) is invoked via an application programming interface. This text generation model can be fine-tuned based on the large language model to meet specific needs.
[0073] The text generation model comprehensively understands the role settings, task requirements, reference facts, and format specifications contained in the chapter generation prompts, performs reasoning, and generates a coherent and professional plain text content as output, that is, the text content of the current chapter task.
[0074] S403. Fill the text content of each chapter's task into the predetermined position of the corresponding chapter to obtain the target design document.
[0075] The structure of the target structured template is parsed to identify the predetermined positions (usually marked by unique identifiers or placeholders) corresponding to each chapter title or paragraph. Then, a precise mapping and replacement operation is performed to fill the text content generated by each chapter task into the predetermined positions in the template that match it.
[0076] During the population process, the system ensures that the generated content inherits the predefined styles (such as fonts and numbering) of the template and maintains the hierarchical relationship and formatting consistency throughout the document. After population is complete, the system packages the synthesized complete document to generate the final deliverable target design document, which can be in common formats such as DOCX, PDF, or HTML.
[0077] This invention also provides a software design document generation system. Figure 6 This is a schematic diagram of the structure of the software design document generation system provided in an embodiment of the present invention, such as... Figure 6 As shown, the system includes: The data acquisition module 100 is used to acquire vector databases, structured template libraries, and document generation requests.
[0078] Accessing the vector database refers to connecting to a pre-built, dedicated database that stores semantic vectors of the enterprise's proprietary knowledge. Each vectorized data in this database has an index relationship with its corresponding text data, enabling subsequent retrieval of the text data based on the vectorized data. This database is independently built and persistent, and is updated periodically. The vector database stores processed semantic representations of project history documents, code comments, API descriptions, and other materials.
[0079] Generating a structured template database refers to accessing a predefined and managed collection of document templates. Each template specifies a fixed chapter structure, formatting requirements, and writing guidelines for each chapter of a particular type of document (such as a "detailed design specification"). For example, a file titled "Microservice Detailed Design Template.docx" predefines the inclusion of chapters such as "1. Overview," "2. Interface Design," and "3. Database Design," and provides a framework constraint on the content to be described in each section.
[0080] A document generation request is a user-input instruction to generate documents based on their needs. This request is the starting point for triggering the entire automation process, specifying "what is needed" and "what is about". For example, if a user selects the template "Detailed Design Specification" in the front-end interface and enters the instruction "Generate detailed design of the order refund module" in the input box, then the user's selected template and instruction together constitute the document generation request.
[0081] The template selection module 200 is used to select a target structured template from the structured template library according to the document generation request; wherein, the target structured template includes chapter constraints.
[0082] Matching is performed based on the document type specified or implicit in the document generation request, which is usually an explicit classification identifier. The front-end interface provides a type selection box so users can directly select the template type. This is the specified document type, and a target structured template of the same type or name can be selected from the structured template library based on the selected template type. Alternatively, the template type can be determined by recognizing user input commands (e.g., if the user command is "generate a detailed design specification for the order payment module," then the keyword "detailed design specification" is the template type). This is the implicit document type, and a target structured template of the same type or name can be selected from the structured template library based on the recognized document type.
[0083] The target structured template is a document structure definition that carries metadata and generation rules. Each chapter corresponds to a chapter constraint, which is the predefined content requirements, writing standards or generation guidelines for the corresponding chapter.
[0084] The data matching module 300 is used to generate a query vector based on the chapter constraints of the target structured template, match the target vectorized data from the vector database based on the query vector, and retrieve the target text data corresponding to the target vectorized data.
[0085] Based on the chapter constraints defined for each chapter in the target structured template, a query representation (i.e., query vector) that represents the semantic knowledge required for that chapter is automatically constructed. The purpose is to transform chapter constraints into retrieval instructions.
[0086] The system retrieves vector data from the vector database based on the query vector and matches some vectorized data with high similarity. These vectorized data are then used as the target vectorized data.
[0087] The target text data corresponding to the target vectorized data is retrieved through the index mapping relationship so that it can participate in the subsequent text content generation.
[0088] The design document generation module 400 is used to generate the target design document based on the chapter constraints of the target structured template, the document generation request, and the target text data.
[0089] The document generation is designed based on the document generation request that reflects the user's specific intent, the target text data representing specific factual materials retrieved from the knowledge base, and the chapter constraints of the target structured template that specifies the document framework and the specific content requirements of each chapter.
[0090] Specifically, the document generation function is achieved based on a preset mapping rule or generation algorithm that transforms the above three input elements into the final document, such as the Retrieval Enhancement Generation Algorithm (RAG), in order to obtain the target design document.
[0091] As an optional implementation method, Figure 7 This is a schematic diagram of the structure of a module for generating a vector database provided in an embodiment of the present invention, as shown below. Figure 7 As shown, the system also includes: The raw data acquisition module 500 is used to acquire raw data from at least one data source.
[0092] Before acquiring the vector database, it is necessary to build the vector database in advance, based on a large amount of original data.
[0093] To ensure data diversity, raw data should be collected from multiple data sources. These sources primarily include internal enterprise knowledge bases, such as project documents, technical solutions, and meeting minutes on collaboration platforms; documentation and code comments in version control systems; and historical design materials stored in document management systems. Additionally, personal files, such as common office documents, portable documents, and plain text files, can be uploaded to the cloud. Furthermore, publicly accessible web resources, such as internal technical blogs or relevant specification websites, can be collected automatically using a crawling module. Raw data refers to the initial files or page content directly obtained from the above channels. This raw data is uniformly stored in object storage (such as MinIO / S3) as a raw asset pool.
[0094] Data acquisition is primarily achieved through various methods. For structured online knowledge bases or platforms, automated collection methods are typically employed, such as configuring web crawler tasks for periodic fetching or utilizing application programming interfaces (APIs) for efficient integration and synchronization. For scattered local files, a user interface is used to support batch or single file uploads.
[0095] The text processing module 600 is used to perform text cleaning and text slicing on each piece of original data to obtain the corresponding text fragments.
[0096] The raw data may contain additional information unrelated to the core knowledge, requiring preprocessing for each piece of raw data acquired. It should be noted that the preprocessing step can be performed asynchronously with data acquisition; for example, a scheduled task can trigger a background processing flow to preprocess the unstructured raw data in the original asset pool.
[0097] Preprocessing mainly includes text cleaning and text slicing. Text cleaning primarily aims to remove irrelevant and distracting information from the raw data. This includes removing formatting tags from documents, such as HTML code in web pages and style tags in Word documents; filtering out inherent page noise, such as advertisements, navigation bars, headers, footers, and copyright notices; and performing text normalization, such as correcting encoding errors and standardizing number and date formats.
[0098] Text slicing aims to break down lengthy, cleaned documents into appropriately sized, semantically complete segments. A simple implementation involves fixed-length overlapping slices, cutting by a specified number of characters while retaining some overlap to prevent the complete semantic meaning from being fragmented at the split point. A better approach is intelligent segmentation based on semantic boundaries, utilizing natural language processing techniques to segment at the end of paragraphs, headings, or sentence groups, ensuring that each slice expresses a relatively independent meaning, such as a complete functional description, an interface definition, or a database table description.
[0099] By combining text cleaning and text slicing, the original data was transformed into text fragments with independent semantics.
[0100] The vector processing module 700 is used to vectorize each text segment to obtain the corresponding vectorized data, and store all vectorized data in the vector database.
[0101] Vectorization refers to using a specialized embedding model to map each text fragment from its original natural language form into a numerical vector in a high-dimensional space. Text fragments with similar semantics will have their corresponding vectors closer together in space.
[0102] These generated semantic vectors and their corresponding original text fragments are persistently stored in a dedicated vector database. A vector database is a system optimized for efficient storage and retrieval of high-dimensional vector data. It establishes a specialized index structure for all stored vectors, enabling the retrieval process to quickly find the few most similar vectors to the query vector from massive amounts of data.
[0103] As an optional implementation method, Figure 8 This is a schematic diagram of the structure of a template for generating a structured template library provided in an embodiment of the present invention, such as... Figure 8 As shown, the system also includes: Template definition data acquisition module 800 is used to acquire template definition data.
[0104] Before obtaining the structured template database, it is necessary to build the structured template database in advance.
[0105] Users input template definition data through the system's interactive interface. Typically, the system provides a template editing and management interface, allowing users to create new document type templates or modify existing ones. The specifications defined by the user in this interface constitute the template definition data.
[0106] The template generation module 900 is used to generate corresponding structured templates based on template definition data and store the structured templates in the structured template library; wherein, the structured template includes document type, chapter hierarchy structure and chapter constraints for each chapter.
[0107] The template definition data is parsed to validate its basic logic. Then, an internal template object is created based on this data. This object explicitly records the document type identifier, constructs a tree-like chapter hierarchy, and transforms the specific writing requirements or guidelines set by the user for each chapter into metadata (chapter constraints, such as "this chapter needs to reference the database table structure") attached to the corresponding chapter node.
[0108] As an optional implementation method, Figure 9 This is a schematic diagram of the structure of the data matching module provided in an embodiment of the present invention, as shown below. Figure 9 As shown, the data matching module 300 includes: The chapter task construction submodule 3001 is used to construct corresponding chapter tasks for each chapter in the target structured template.
[0109] Iterate through all chapters defined in the selected target structured template. For each chapter, create a separate task instance based on its definition in the template (including its hierarchical position, title, and associated chapter constraints).
[0110] This chapter task instance is a structured data object that encapsulates all the core information and instructions needed to generate the chapter. It includes at least the chapter's unique identifier, title text, specific content constraints and generation guidelines inherited from the template, and its hierarchical relationship within the entire document.
[0111] As an alternative implementation, different chapter tasks can be processed in parallel across multiple threads.
[0112] The query vector generation submodule 3002 is used to generate query vectors for the current chapter task based on the corresponding chapter constraints.
[0113] For each chapter task, it is processed as the current chapter task and transformed into a query vector. For the current chapter task, its chapter constraints are transformed into a query vector.
[0114] As an optional implementation, the structured chapter constraints in the current chapter task (such as "the request and response format of the interface needs to be described") are used as natural language query text that can fully express the knowledge scope required for the chapter. Then, a pre-selected embedding model is called to convert this query text into a numerical vector in a high-dimensional space, i.e., a query vector. Furthermore, when constructing the natural language query text, it can also be constructed by combining the chapter title and the overall subject of the corresponding document type.
[0115] The semantic similarity matching submodule 3003 is used to perform semantic similarity matching in the vector database based on the query vector and preset matching rules to obtain at least one target vectorized data corresponding to the current chapter task.
[0116] Calculate the semantic similarity (e.g., cosine similarity) between the query vector and each vectorized data in the vector database, and filter the target vectorized data according to preset matching rules. The preset matching rules include: using vectorized data with semantic similarity exceeding a preset similarity threshold as target vectorized data; or using one or more (i.e., TOP-K) vectorized data with the highest similarity as target vectorized data.
[0117] Subsequently, the target text data is determined and retrieved based on the target vectorized data.
[0118] As an optional implementation, after obtaining the target text data, it is necessary to perform deduplication, reordering, and context window adaptation to remove noisy data.
[0119] Deduplication typically involves comparing the semantic similarity between target text data (or combining surface feature comparison) to select a more complete text from the text data with high similarity; re-ranking is usually based on semantic similarity and may also introduce more refined ranking models (such as cross-encoders) or perform secondary scoring and ranking of fragments based on rules (such as information completeness, source authority, publication time, etc.) to ensure that the most relevant and reliable fragments are placed first; context window adaptation usually adopts a strategy of truncating the least important fragments from the end or performing intelligent summarization extraction on long fragments to adapt the overall input scale to the range that the model can handle while preserving the core semantics.
[0120] As an optional implementation method, Figure 10 This is a schematic diagram of the design document generation module provided in an embodiment of the present invention, such as... Figure 10 As shown, the design document generation module 400 includes: The prompt word generation submodule 4001 is used to integrate the target text data, chapter constraints, and user instructions in the document generation request corresponding to each chapter task to obtain the chapter generation prompts corresponding to each chapter task.
[0121] The system uses a predefined prompt template as its basic framework. This template is a text structure containing fixed guiding statements and variable placeholders. Content from three sources is sequentially inserted into the corresponding positions in the template through variable substitution or contextual concatenation to generate chapter prompts.
[0122] First, the target text data is organized and formatted, and then filled into the prompt as factual basis for generating the required reference, usually guided by identifiers such as "Reference Information:" or "Background Information:".
[0123] Secondly, the chapter constraints are extracted from the template, which clarifies the rules of "what must be written" and "how to write" in the chapter. This part will be integrated into specific requirements for the model, such as "please ensure that the following points are included:".
[0124] Finally, extract the most relevant specific themes and focuses from the user instructions in the document generation request, and use them as the core description of the generation task, such as "Based on the above information, please write the chapter content on 'Order Payment Interface Design'".
[0125] The text content generation submodule 4002 is used to input the chapter generation prompts of each chapter task into the text generation model to obtain the text content corresponding to each chapter task.
[0126] Following the document's structural order (or based on task dependencies), each chapter's task is processed sequentially. For each task, its corresponding chapter generation hints are used as complete input, and a deployed text generation model (typically a large language model such as GPT-5 or ChatGLM) is invoked via an application programming interface. This text generation model can be fine-tuned based on the large language model to meet specific needs.
[0127] The text generation model comprehensively understands the role settings, task requirements, reference facts, and format specifications contained in the chapter generation prompts, performs reasoning, and generates a coherent and professional plain text content as output, that is, the text content of the current chapter task.
[0128] The fill submodule 4003 is used to fill the text content of each chapter's task into the predetermined position of the corresponding chapter to obtain the target design document.
[0129] The structure of the target structured template is parsed to identify the predetermined positions (usually marked by unique identifiers or placeholders) corresponding to each chapter title or paragraph. Then, a precise mapping and replacement operation is performed to fill the text content generated by each chapter task into the predetermined positions in the template that match it.
[0130] During the population process, the system ensures that the generated content inherits the predefined styles (such as fonts and numbering) of the template and maintains the hierarchical relationship and formatting consistency throughout the document. After population is complete, the system packages the synthesized complete document to generate the final deliverable target design document, which can be in common formats such as DOCX, PDF, or HTML.
[0131] The above technical solution has the following beneficial effects: It adopts a template-based targeted retrieval and generation mechanism, realizing a closed loop from data upload to document generation, significantly reducing manual sorting and repetitive writing, thereby improving document writing efficiency; Through vectorization processing and precise matching, it ensures that the generated content is based on actual project knowledge, effectively preventing the illusion caused by general models, thereby improving the accuracy of the document; Through structured templates, it enforces constraints on the organizational framework of the generated content, ensuring that unstructured knowledge can be assembled in a standardized manner, thereby guaranteeing the standardization and compliance of the document.
[0132] The above-described specific embodiments of the invention further illustrate the purpose, technical solution, and beneficial effects of the invention. It should be understood that the above content is only for specific embodiments of the invention and is not intended to limit the scope of protection of the invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the scope of protection of the invention.
Claims
1. A method for generating software design documents, characterized in that, include: Retrieve vector database, structured template library, and document generation requests; According to the document generation request, a target structured template is selected from the structured template library; wherein, the target structured template includes chapter constraints; A query vector is generated based on the chapter constraints of the target structured template. The target vectorized data is matched from the vector database based on the query vector, and the target text data corresponding to the target vectorized data is retrieved. Generate the target design document based on the chapter constraints of the target structured template, the document generation request, and the target text data.
2. The software design document generation method according to claim 1, characterized in that, The process of generating the vector database includes: Obtain the original data from at least one data source; Each piece of original data is subjected to text cleaning and text slicing to obtain the corresponding text fragments; Each text segment is vectorized to obtain corresponding vectorized data, and all vectorized data is stored in the vector database.
3. The software design document generation method according to claim 1, characterized in that, The process of generating the structured template database includes: Retrieve template definition data; A corresponding structured template is generated based on the template definition data, and the structured template is stored in the structured template library; wherein, the structured template includes document type, chapter hierarchy structure and chapter constraints for each chapter.
4. The software design document generation method according to claim 1, characterized in that, The step of generating a query vector based on the chapter constraints of the target structured template, and matching target vectorized data from the vector database based on the query vector, includes: For each chapter in the target structured template, construct a corresponding chapter task; For the task in the current chapter, generate a query vector based on the corresponding chapter constraints; Based on the query vector and preset matching rules, semantic similarity matching is performed in the vector database to obtain at least one target vectorized data corresponding to the current chapter task.
5. The software design document generation method according to claim 4, characterized in that, The process of generating the target design document based on the chapter constraints of the target structured template, the document generation request, and the target text data includes: By integrating the target text data, chapter constraints, and user instructions in the document generation request corresponding to each chapter task, chapter generation prompts corresponding to each chapter task are obtained. Input the chapter generation prompts for each chapter task into the text generation model to obtain the text content corresponding to each chapter task; Fill the text content of each chapter's tasks into the predetermined positions of the corresponding chapters to obtain the target design document.
6. A software design document generation system, characterized in that, include: The data acquisition module is used to acquire vector databases, structured template libraries, and document generation requests; The template selection module is used to select a target structured template from the structured template library according to the document generation request; wherein, the target structured template includes chapter constraints; The data matching module is used to generate a query vector based on the chapter constraints of the target structured template, match the target vectorized data from the vector database based on the query vector, and retrieve the target text data corresponding to the target vectorized data. The design document generation module is used to generate the target design document based on the chapter constraints of the target structured template, the document generation request, and the target text data.
7. The software design document generation system according to claim 6, characterized in that, Also includes: The raw data acquisition module is used to acquire raw data from at least one data source; The text processing module is used to perform text cleaning and text slicing on each of the original data to obtain the corresponding text fragments; The vector processing module is used to vectorize each of the text segments to obtain corresponding vectorized data, and store all vectorized data in the vector database.
8. The software design document generation system according to claim 6, characterized in that, Also includes: The template definition data acquisition module is used to acquire template definition data; The template generation module is used to generate a corresponding structured template based on the template definition data, and store the structured template in the structured template library; wherein, the structured template includes document type, chapter hierarchy structure and chapter constraints for each chapter.
9. The software design document generation system according to claim 6, characterized in that, The data matching module includes: The chapter task construction submodule is used to construct corresponding chapter tasks for each chapter in the target structured template; The query vector generation submodule is used to generate query vectors for the current chapter task based on the corresponding chapter constraints. The semantic similarity matching submodule is used to perform semantic similarity matching in the vector database according to the query vector and preset matching rules to obtain at least one target vectorized data corresponding to the current chapter task.
10. The software design document generation system according to claim 9, characterized in that, The design document generation module includes: The prompt word generation submodule is used to integrate the target text data, chapter constraints, and user instructions in the document generation request corresponding to each chapter task to obtain the chapter generation prompts corresponding to each chapter task. The text content generation submodule is used to input the chapter generation prompts of each chapter task into the text generation model to obtain the text content corresponding to each chapter task. The fill submodule is used to fill the text content of each chapter's tasks into the predetermined positions of the corresponding chapters to obtain the target design document.