A document generation method and system based on multi-model and database intelligent agents

By employing a multi-model collaboration and database intelligence approach to document generation, the system addresses the shortcomings of existing document writing assistance systems in terms of intelligence and rigid templates. This enables efficient and professional automatic document generation, enhancing the automation of the writing process and improving user experience.

CN122491233APending Publication Date: 2026-07-31SHANGHAI BIG DATA INC
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI BIG DATA INC
Filing Date
2026-04-15
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing document writing assistance systems cannot deeply understand user intent, lack the ability to generate content autonomously, have rigid templates, poor scenario adaptability, closed knowledge systems, and difficulty in automatically referencing relevant data, resulting in a broken writing process and poor user experience, making it difficult to cope with complex document writing scenarios.

Method used

By employing multi-model collaboration and database intelligence, the system identifies target document types through a multi-level document type system, calls multiple model intelligences and database intelligences in stages to generate high-quality document drafts, and then revises them using an interactive interface, achieving fully automated generation throughout the entire process.

Benefits of technology

It significantly improves the intelligence level of official document generation, enhances writing efficiency and quality, reduces manual operation time and error risk, and strengthens the accuracy and professionalism of the content, adapting to complex and ever-changing writing needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122491233A_ABST
    Figure CN122491233A_ABST
Patent Text Reader

Abstract

This invention provides a document generation method and system based on multi-model and database intelligence agents, belonging to the field of document generation technology. The method includes: parsing and planning document generation requests; scheduling corresponding model workflows according to the target document type; calling model intelligence agents and database intelligence agents matching the target document type at each stage of the workflow; executing document generation tasks in stages to generate document drafts; assembling and verifying according to standard specifications; and outputting the target document. Beneficial effects: Through multi-model collaboration and dynamic task planning, the entire process of generating standardized documents from vague user requirements is automated. Differentiated models are scheduled based on document type to execute tasks in stages. Model generation and reasoning capabilities are used to automatically generate high-quality, structured, and data-driven document content. The combination of database intelligence agents enables automatic data import, improving the accuracy, standardization, and professionalism of the generated content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of document generation technology, and in particular to a document generation method and system based on multi-model and database intelligent agents. Background Technology

[0002] Official documents are legally binding and standardized written documents created by statutory authorities or other social organizations in their official activities. The term "documents" encompasses all files and materials in two main categories: official documents and private documents. The efficiency and quality of official document drafting directly affect the smoothness of official procedures and the effectiveness of decision-making.

[0003] With the development of intelligent technologies, various document writing assistance systems have emerged. Most existing document writing assistance systems rely on template libraries and rule-based validation mechanisms to achieve their auxiliary functions; essentially, they are intelligent fill-in-the-blank tools based on templates and rules. These systems cannot deeply understand the user's specific writing intentions and contextual information, nor do they possess the ability to proactively generate high-quality paragraphs, standardized wording, or accurately match policy references. The core creative work of document writing still relies on independent user input, resulting in a low overall level of intelligence and a lack of autonomous content generation capabilities.

[0004] Meanwhile, the templates are static and predefined, lacking flexibility and adaptability when facing non-standard, cross-departmental, or new document generation needs. They struggle to dynamically combine or generate text structures that meet specific requirements, resulting in rigid templates and poor scenario adaptability. The rules and template system is closed, disconnected from key knowledge sources within the organization, such as business databases, policy and regulation databases, and historical archives. During the writing process, relevant data, policy clauses, or historical cases cannot be automatically and accurately retrieved and referenced; writers must manually search, filter, and confirm, which not only consumes significant time and effort but also easily introduces data citation errors due to manual operation, leading to isolated knowledge and weak data support. The entire document generation process exhibits a one-way collaborative characteristic of human-led, machine-assisted operation. Users must continuously perform repetitive operations such as searching, copying, pasting, and verifying. The system cannot proactively provide writing suggestions or complete specific task segments as a collaborator, resulting in a broken writing process, inconsistent user experience, and limited improvement in office efficiency.

[0005] In addition, the system's core rule engine model is relatively simple and cannot dynamically adjust the writing style and level of detail based on the differentiated needs of the document, such as its importance, urgency, and target audience. The existing system is unable to cope with complex document writing scenarios that require comprehensive analysis of multi-source information, such as research reports and work summaries. Summary of the Invention

[0006] To address the above technical problems, this invention provides a document generation method based on multiple models and database agents; on the other hand, it provides a document generation system based on multiple models and database agents.

[0007] The technical problem solved by this invention can be achieved by the following technical solutions: A document generation method based on multi-model and database agent includes: Step S1: Receive a document generation request, perform requirement analysis and task planning on the document generation request, identify the target document type, and construct a document generation task; Step S2: According to the target document type, schedule the corresponding model workflow, and call one or more model agents and database agents that match the target document type from the preset model agent set and database agent set according to each stage of the model workflow, and execute the document generation task in stages to generate a document draft. Step S3: Assemble the document draft according to the standard specifications of the target document type, verify the assembled document, and output the target document.

[0008] The document generation method based on multi-model and database agent of the present invention, wherein step S1 of identifying the target document type includes: A predefined multi-level document type system is defined, which includes multiple major categories, a first subclass under each major category, and a second subclass under each first subclass. Based on a predefined multi-level document type system, identify at least one of the major category, first subcategory, and second subcategory to which the document generation request belongs, and determine the target document type.

[0009] The document generation method based on multi-model and database agent described in this invention includes one or more combinations of document type, writing purpose, target audience, word count requirement, and reference attachments in the document generation request.

[0010] The document generation method based on multi-model and database agent of the present invention includes step S2 as follows: Step S21: Invoke the first model agent. The first model agent performs title polishing on the document generation request according to the first prompt word corresponding to the target polishing style to obtain the target title. Step S22: Invoke the second model agent according to the configured thinking mode switch. The second model agent generates an overview content based on the target title. The overview content includes at least one or more combinations of theme, goal, and outcome. Step S23: Invoke the third model agent that matches the target document type. The third model agent generates a document outline that meets the structural requirements of the target document type based on the multi-dimensional prompt words that match the target document type and the overview content. Step S24: Slice the generated document outline into paragraphs, break the document outline into multiple logically related chapter units, expand the content of each chapter unit, and generate the chapter content corresponding to each chapter unit. Step S25: Based on the logical structure of the document outline, integrate the chapter content corresponding to each chapter unit to generate the document draft.

[0011] The document generation method based on multi-model and database agent of the present invention includes step S22 as follows: In response to the thinking mode switch being configured to be on, the first overview generation model is invoked as the second model agent, and the first overview generation model generates the overview content based on the target title; In response to the thinking mode switch being configured to be off, the second overview generation model is invoked as the second model agent. The second overview generation model generates the overview content based on the second prompt word corresponding to the target document type and the target title.

[0012] The document generation method based on multi-model and database agent described in this invention includes a reference attachment in the document generation request, and the steps preceding step S23 include: The fourth model agent is invoked to perform semantic parsing on the reference attachment and extract a content summary. Step S23 further includes: constructing an association mapping relationship between the content summary of the reference attachment and the overview content, extracting the association information in the content summary according to the association mapping relationship, embedding the association information into the output content of the third model agent, and generating the document outline.

[0013] The document generation method based on multi-model and database agents described in this invention, wherein step S23, invoking a third model agent that matches the target document type, includes: When the target document type is the first major category, the first outline generation model is invoked as the third model agent; When the target document type is the second major category, the second outline generation model, which is fine-tuned based on the database agent, is invoked as the third model agent.

[0014] The document generation method based on multi-model and database agent of the present invention includes step S3 as follows: Step S31: Assemble and format the document draft according to the standard specifications of the target document type; Step S32: Perform integrity and logical structure consistency checks on the assembled document, and output the target document after the checks pass.

[0015] The document generation method based on multi-model and database agent described in this invention further includes: An interactive interface is provided, which is used to display the content generated by each model agent; In response to an interactive revision instruction input by the user through the interactive interface, the interactive revision instruction includes at least one of a local correction instruction, a fragment recombination instruction, a supplementary generation instruction, and a style adjustment instruction, and performs a corresponding modification operation on the content generated by the model agent based on the interactive revision instruction.

[0016] On the other hand, a document generation system based on multi-model and database agent is provided for implementing the document generation method based on multi-model and database agent as described above, including: The requirement analysis and task planning module is used to receive document generation requests, perform requirement analysis and task planning on the document generation requests, identify target document types, and construct document generation tasks. The phased draft generation module is connected to the requirement analysis and task planning module. It is used to schedule the corresponding model workflow according to the target document type. According to each stage of the model workflow, it calls one or more model agents and database agents that match the target document type from the preset set of model agents and set of database agents to execute the document generation task in stages and generate document drafts. The assembly and verification module, connected to the phased draft generation module, is used to assemble the document draft according to the standard specifications of the target document type, verify the assembled document, and output the target document.

[0017] The advantages or beneficial effects of the technical solution of this invention are as follows: This invention achieves fully automated generation of documents from vague user needs to standardized documents through multi-model collaboration and dynamic task planning. It executes tasks in stages based on a differentiated model that schedules document types, and utilizes model generation and reasoning capabilities to automatically generate high-quality, structured, and data-driven document content. Furthermore, it combines a database agent to automatically import data, significantly improving the accuracy, standardization, and professionalism of the generated content, reducing the writing burden, and enhancing organizational collaboration and knowledge reuse efficiency. Attached Figure Description

[0018] Figure 1This is a flowchart illustrating a preferred embodiment of the document generation method based on multiple models and database agents. Figure 2 This is a schematic diagram of the document draft generation process in a preferred embodiment of the present invention; Figure 3 This is a schematic diagram of the assembly and verification process in a preferred embodiment of the present invention; Figure 4 A schematic diagram of the structural frame of a document generation system based on multiple models and database agents, as shown in a preferred embodiment of the present invention; Figure 5 This is a flowchart illustrating a document generation method based on multiple models and database agents, as described in a preferred embodiment of the present invention. Detailed Implementation

[0019] 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.

[0020] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.

[0021] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but this is not intended to limit the scope of the invention.

[0022] In a preferred embodiment of the present invention, addressing the problems of low intelligence level, insufficient flexibility, and closed knowledge system in the prior art, a document generation method and system based on multi-model and database intelligent agents are provided. The present invention aims to fundamentally transform the traditional work mode, elevating document generation from a process reliant on manual pre-setting and passive content filling to a creative collaborative process driven by intelligent agents and deeply integrated with data and knowledge.

[0023] like Figure 1 As shown, the document generation methods include: Step S1: Receive document generation request, analyze the requirements and plan the task for the document generation request, identify the target document type, and construct the document generation task; Step S2: Based on the target document type, schedule the corresponding model workflow. According to each stage of the model workflow, call one or more model agents and database agents that match the target document type from the preset set of model agents and set of database agents, execute the document generation task in stages, and generate a document draft. Step S3: Assemble the document draft according to the standard specifications of the target document type, verify the assembled document, and output the target document.

[0024] Specifically, existing document generation systems are essentially just intelligent fill-in-the-blank tools, their capabilities limited to format and rule verification, unable to truly understand writing intentions and policy contexts. This invention, however, introduces a large language model as a cognitive engine, capable of recognizing multiple user intentions, deeply analyzing the underlying semantics of user commands, and proactively generating logically rigorous, appropriately worded, and policy-oriented high-quality paragraphs and core arguments, even accurately citing authoritative policy evidence. This shifts the core creative work of document generation from entirely relying on the user to having the system undertake the main task of generating the initial draft, significantly improving writing efficiency and quality.

[0025] Existing templates are typically static and predefined, failing to adapt to the complex and ever-changing needs of actual work. This invention aims to completely abandon this one-size-fits-all template-dependent approach. By leveraging the powerful logical reasoning and structured thinking capabilities of the model, it can dynamically perceive and generate the most suitable and personalized text outline and chapter structure based on various factors such as the specific document type, writing purpose, and reporting recipient. This demonstrates strong flexibility and adaptability when facing non-standard, cross-departmental, or unprecedented new document generation tasks, fundamentally eliminating the "cutting the feet to fit the shoes" phenomenon caused by template limitations.

[0026] To address the issues of isolated knowledge and disconnected business data in existing systems, this invention introduces a database intelligent agent as a core component. Its purpose is to proactively and intelligently connect and query internal business databases, policy and regulatory databases, and historical case databases to form a knowledge graph as a knowledge source. During document generation, it is no longer a closed text editor, but can automatically and accurately locate and reference relevant business data, authoritative policy provisions, and successful historical cases, injecting solid evidence support and authority into the generated document content, significantly reducing the time cost and error risk required for manual verification.

[0027] Considering the diversity of document generation in terms of importance, urgency, and target audience, this invention abandons a single rule engine model and adopts a multi-model collaborative working mechanism. It intelligently schedules different models based on task complexity and characteristics. For example, it schedules a model skilled in logical planning to generate an outline, calls a model skilled in text generation to expand chapter content, or uses a domain-adjusted expert model to handle professional content. This allows for dynamic adjustment of the writing style's seriousness and approachability, and the content's detail and brevity, thus possessing powerful capabilities to handle various complex document generation scenarios, from daily notifications to comprehensive work summaries and in-depth research reports.

[0028] The document generation method based on multi-model and database agent of the present invention includes identifying the target document type in step S1, which includes: A predefined multi-level document type system is defined, which includes multiple major categories, a first subclass under each major category, and a second subclass under each first subclass. Based on a predefined multi-level document type system, identify at least one of the major category, first subcategory, and second subcategory to which the document generation request belongs, and determine the target document type.

[0029] Specifically, in this embodiment, an interactive interface is provided to receive document generation requests submitted by users through the interface. The requirements in the document generation request include one or more combinations of document type, writing purpose, target audience, word count requirement, and reference attachments.

[0030] In this embodiment, "documents" specifically refers to official documents, or simply official documents. Of course, this method can also be applied to private documents.

[0031] Upon receiving a document generation request, the system first parses and plans the requirements, automatically identifying the corresponding document categories and subcategories, and routing the request to the appropriate generation process. The accuracy of the task planning determines whether the entire intelligent writing process can generate official documents that meet the expected format and content depth. Since the initial user request description is relatively vague and unstructured, it needs to be structured and parsed. During this parsing process, the core elements of the user's input request are integrated. These core elements include document type (e.g., work report, notice), writing purpose, target audience, word count requirements, and user-uploaded materials as reference attachments, constructing a structured writing task description that lays the foundation for subsequent multi-model collaboration.

[0032] In this embodiment, document types include three main categories: general documents, legal documents, and policy documents. In the application scenario of this invention, the document generation task mainly includes two types: general comprehensive documents and legal and regulatory documents.

[0033] For example, the classification structure of a multi-level document type system is as follows: Major Categories: The multi-level document type system comprises two core categories: general comprehensive documents and legal documents. General documents are uniformly classified as general comprehensive documents, serving as the first major category of the multi-level document type system. Legal documents and policy documents are uniformly classified as legal documents, serving as the second major category of the multi-level document type system.

[0034] The first subcategory is divided into two categories: General comprehensive documents include speeches, plans, research reports, work reports, work briefings, evaluation opinions, and open letters; Legal and regulatory documents include local regulations, departmental rules, and other legal documents, as well as planning schemes, management rules, requests for instructions, notices, and policy instructions.

[0035] The second subcategories are as follows: Speeches include, but are not limited to, conference speeches, work launch speeches, work summary speeches, exchange speeches, inaugural speeches, and work deployment speeches; Plans and schemes include, but are not limited to, work plans, work schemes, and work contingency plans; Research reports include, but are not limited to, field investigation research, opinion summary research, and data analysis research; Work reports include, but are not limited to, departmental work reports, individual work reports, project application reports, problem rectification reports, performance reports, work summaries, and learning experience reports; Work reports include, but are not limited to, periodic work reports and thematic work reports; Evaluation opinions include, but are not limited to, personal evaluations and work evaluations; Public letters include, but are not limited to, initiatives, letters of determination, letters of commendation, letters of thanks, letters of condolence, congratulatory letters, and circulars; Planning schemes include, but are not limited to, action plans, implementation plans, work priorities, special policies, and guiding opinions; Management rules include, but are not limited to, management regulations and management methods; Requests and reports mainly consist of requests for instructions; Notices and reports include, but are not limited to, notices and application guidelines; Decisions and instructions include, but are not limited to, approvals and replies.

[0036] The multi-level document type system of this invention adopts a three-level classification architecture to form a fully covered and scalable document classification matrix.

[0037] The document generation method based on multi-model and database agent of the present invention, such as Figure 2 As shown, step S2 includes: Step S21: Invoke the first model agent. The first model agent performs title polishing on the document generation request based on the first prompt word corresponding to the target polishing style to obtain the target title. Step S22: The second model agent is invoked according to the configured thinking mode switch. The second model agent generates an overview based on the target title. The overview includes at least one or more combinations of the theme, goal, and outcome. Step S23: Invoke the third model agent that matches the target document type. The third model agent generates a document outline that meets the structural requirements of the target document type based on the multi-dimensional prompts and overview content that match the target document type. Step S24: Slice the generated document outline into paragraphs, break it down into multiple logically related chapter units, expand the content of each chapter unit, and generate the corresponding chapter content for each chapter unit. Step S25: Based on the logical structure of the document outline, integrate the chapter content corresponding to each chapter unit to generate a document draft.

[0038] Specifically, after task planning, this invention schedules the corresponding model workflow based on the document type in the task, constraining and guiding the original open-domain dialogue capabilities of the general-purpose model to specialized document generation tasks. After task scheduling, an optimized workflow for specific document types and writing scenarios is obtained. Based on this workflow, the corresponding large language model is then invoked for text generation, exhibiting clear document generation characteristics in terms of content quality and standardization. Then, this invention sends the structured task instructions into a multi-model collaborative text generation pipeline, obtaining the outputs of each stage, which can be simply understood as key intermediate products in the writing process. By executing the document generation task in stages, firstly, a model skilled in logical planning generates a full outline; then, a model skilled in text generation expands the content by chapter according to the outline; and through iterative iteration and a polishing module, style and quality control are performed. After multiple rounds of adjustments, satisfactory chapter content is generated, ultimately resulting in a final draft document at a reliable level.

[0039] Meanwhile, during the execution of different types of document generation tasks, high-quality generated content is grouped into experience knowledge pairs and incorporated into the model optimization knowledge base to provide reference for subsequent generation tasks. After document generation, users can continuously iterate and optimize by selecting polishing styles and inputting sentences, controlling the quality and style of chapters and content within the document.

[0040] Furthermore, the system predefines one or more document generation workflows. Each workflow includes multiple stages and the flow relationships between these stages, such as, but not limited to, a title polishing stage, a topic / objective / outcome overview generation stage, an outline generation stage, a chapter content expansion stage, a content assembly and formatting stage, and a verification stage. An attachment reference stage can be set after the title polishing stage and before the outline generation stage, based on actual needs. This stage uses abstract information extracted from reference attachments to assist in outline generation, improving the relevance between the outline and attachment content.

[0041] Each stage is implemented by an agent based on a large language model. For all or some stages, the appropriate model agent can be invoked according to the document type and the task of the current stage, forming a dedicated model workflow corresponding to the document type, and realizing document generation through multi-model collaboration.

[0042] For all or part of the stages, such as the chapter expansion stage, a database agent can be invoked. This database agent includes internal business databases, policy and regulation databases, and historical case databases. During the document generation process, relevant business data, authoritative policy provisions, and successful historical cases can be located and cited, injecting solid evidence support and authority into the generated document content.

[0043] The model agents invoked at each stage can be the same. For example, the same type of model can be invoked for the title polishing stage and the topic / objective / outcome summary generation stage, performing the corresponding stage tasks based on the different prompts for each stage. Alternatively, the model agents invoked at each stage can be different. For example, different types of models can be invoked for the title polishing stage and the topic / objective / outcome summary generation stage, achieving differentiated capability adaptation and performing the corresponding stage tasks based on the prompts for the corresponding stage.

[0044] During the title polishing stage, the first model agent is invoked to use different prompt words for different polishing styles. This process performs semantic optimization and format standardization on the initial title (if any) in the document generation request or the candidate title generated based on requirements, resulting in a target title that conforms to the target document type specifications and scenario requirements. In this embodiment, the first model agent uses the Qwen2.5-72B-Instruct model. By constructing differentiated prompt word templates, it generates corresponding prompt words for different polishing styles such as formal, concise, and solemn, achieving dual optimization of title semantic accuracy and format standardization. Of course, this is not the only approach; in other embodiments, other models combined with prompt words can also be used to achieve title polishing.

[0045] In the overview generation stage (topic / objective / outcome), based on the user-configured thinking mode on / off state, a differentiated generation strategy is activated. Using the target title as the core, an overview containing one or more combinations of the topic, objective, and outcome is generated to enrich the main content. The document generation method based on multi-model and database agents of this invention includes step S22 as follows: In response to the thinking mode switch being configured to be on, the first overview generation model is invoked as the second model agent, and the first overview generation model generates overview content based on the target title. In response to the thinking mode switch being configured to be off, the second overview generation model is invoked as the second model agent. The second overview generation model generates overview content based on the second prompt word corresponding to the target document type and the target title.

[0046] Specifically, the interactive interface provides a thinking mode switch, which users can click to turn deep thinking mode on or off.

[0047] When the deep thinking mode is activated, the first overview generation model, such as the DeepSeek-R1-Distill-Llama-70B model, is invoked. Through a multi-round reasoning mechanism, the writing scenario, audience characteristics, and expression intentions are deeply deconstructed to generate an overview that is both logical and targeted.

[0048] When Deep Thinking Mode is disabled, in Standard Mode, a second overview generation model, such as the Qwen2.5-72B-Instruct model, is invoked for efficient content generation. Different prompts are used to directly output the core elements that conform to the specifications, tailored to different document types.

[0049] The second prompt word is obtained through prompt word engineering optimization. It includes elements such as different policy directive designs and context construction. It is also repeatedly optimized through question-and-answer effects to ensure that the core summary elements that conform to the standards are output for different document types.

[0050] The document generation method based on multi-model and database agent of the present invention includes a document generation request with reference attachments, and includes the following steps before step S23: The fourth model agent is invoked, which performs semantic parsing on the reference attachments and extracts a content summary. Step S23 also includes: constructing a mapping relationship between the content summary and the overview content of the reference attachment, extracting the related information from the content summary based on the mapping relationship, embedding the related information into the output content of the third model agent, and generating a document outline.

[0051] Specifically, when the reference attachment function is enabled, it supports uploading and parsing documents in various formats, including but not limited to common formats such as PDF, DOCX, and XLSX, as well as other formats such as images.

[0052] The user interface provides an attachment upload button. Users can click this button to bring up a file selection window, locate the path of the file to be uploaded, and then select and upload the corresponding document; or they can directly drag and drop the file from the file manager to the user interface, further enhancing the system's ease of use and user-friendliness.

[0053] Upon receiving an uploaded attachment document, the reference attachment function can be enabled by default. Based on a fourth-model intelligent agent, such as the Qwen2.-5-72B-Instruct model, deep semantic analysis is performed on the uploaded document to extract key information and generate a content summary. By constructing a document semantic graph and mapping it to document generation requirements, the relevance between attachment content and document topic is intelligently identified, and the extracted core information is dynamically embedded into the generation process, ultimately achieving a deep integration and collaborative application of external knowledge and writing requirements.

[0054] Based on the content generated by the model, combined with reference documents in the user-uploaded attachments, the content is more accurate in fact, which can significantly reduce the illusion of the model and enhance the professionalism and authority of the documents.

[0055] The document generation method based on multi-model and database agents of the present invention includes, in step S23, invoking a third model agent that matches the target document type, as follows: When the target document type is the first major category, the first outline generation model is invoked as the third model agent; When the target document type is the second major category, the second outline generation model, which is fine-tuned based on the database agent, is called as the third model agent.

[0056] Specifically, in this embodiment, based on intelligent document type identification, the model generation path is dynamically configured: for document types with high professional and normative requirements, such as laws and regulations, a second outline generation model, fine-tuned from massive amounts of legal text, is automatically dispatched, such as the SHDLLM-9B-PolicyWriter domain-specific model. This model is a model fine-tuned based on the glm4-9b-chat model using Low-Rank Adaptation (LoRA). The training data comes from a real legal and regulatory database, deeply integrating the legal terminology system and the structural features of normative texts to ensure that the generated content conforms to legal document standards in terms of legal logic, clause expression, and format specifications.

[0057] For other types of general comprehensive documents, the first outline generation model is invoked. This model is a basic model without fine-tuning, such as the Qwen2.5-72B-Instruct pre-trained basic model. A multi-dimensional prompt word engineering system is constructed to achieve domain adaptability. Specifically, different multi-dimensional prompt word engineering is used for different policy types, such as approvals, replies, requests for instructions, notices, application guidelines, action plans, implementation plans, work priorities, guiding opinions, special policies, and management rules. In the specific implementation process, differentiated prompt word templates are dynamically loaded based on the document type feature library: first, routing is performed according to the document type, policy type, and task document type; second, prompt words for the corresponding task type are selected based on the corresponding document type. On the one hand, domain-specific content generation guidelines are designed for different document types; on the other hand, standard official document format specifications are transformed into structured constraints and embedded in the generation process. This dual control mechanism ensures that the output simultaneously meets the dual standards of content professionalism and format standardization.

[0058] The generated outline is structurally decomposed, and paragraph slicing technology is used to divide the outline into logically related chapter units, generating compliant content components section by section. During the generation process, the logical coherence and content completeness between chapters are monitored in real time, and finally, through multiple rounds of iteration, a well-structured main body of the document is generated.

[0059] During the chapter expansion phase, a database agent can be invoked simultaneously. The database agent intelligently queries and references business data, authoritative policy provisions, and successful historical cases related to the chapter topic from internal business databases, policy and regulation databases, and historical case databases, injecting solid evidence support and authority into the chapter content.

[0060] The document generation method based on multi-model and database agent of the present invention, such as Figure 3 As shown, step S3 includes: Step S31: Assemble and format the document draft according to the standard specifications of the target document type; Step S32: Perform integrity and logical structure consistency checks on the assembled document, and output the target document after the checks pass.

[0061] Specifically, after completing the content generation iterations at each stage, an end-to-end document quality optimization and formatted output are achieved through a model architecture that combines multi-model collaboration and rule verification, further reducing model illusion and ensuring the standardization and reliability of the generated documents.

[0062] The draft document is formatted and typed according to the standard specifications of the target document type. The assembled document is then checked for completeness, logical structure consistency, and data accuracy. Once the checks are passed, the target document is output. The specific implementation steps are as follows: The content is generated by combining elements according to the standard format corresponding to the target document type. The corresponding typesetting specifications are automatically applied according to the document type, including but not limited to font, line spacing, paragraph format, and signature format, to ensure that all necessary components are complete and without omission.

[0063] Perform a completeness check on the format and logical structure to verify that key content elements are complete; perform a logical structure consistency check to verify that the logic between chapters is coherent and the structure is rigorous; and perform a data citation accuracy check to verify that the cited business data, policy clauses, and case information are accurate and complete. After passing the checks, output the final target document of the corresponding document type.

[0064] The document generation method based on multi-model and database agent of the present invention further includes: It provides an interactive interface for displaying the content generated by each model agent in real time, including but not limited to intermediate results such as generated titles, overviews, outlines, and chapter contents, as well as the final document; In response to interactive revision instructions input by the user through the interactive interface, the interactive revision instructions include at least one of local correction instructions, fragment recombination instructions, supplementary generation instructions, and style adjustment instructions, and the corresponding modification operations are performed on the content generated by the model agent based on the interactive revision instructions.

[0065] Specifically, this invention provides an interactive revision function, which supports local correction, fragment recombination and supplementary generation of generated content to ensure that the output meets the user's personalized needs.

[0066] It also provides complete version management functions, recording the content, time and author of each revision, and supports revision record tracing and version rollback; it also supports generating documents in various formats such as Word and PDF that conform to industry standards, adapting to different application scenarios.

[0067] Testing is conducted based on user interaction data, and a closed loop for model optimization is constructed. High-quality revised cases and user preference features are incorporated into the model training dataset. Through iterative training, model parameters and prompt word templates are optimized to achieve continuous improvement in generation quality.

[0068] On the other hand, a document generation system based on multi-model and database agent is provided to implement the document generation method based on multi-model and database agent as described above, such as... Figure 4 As shown, it includes: The requirement analysis and task planning module 101 is used to receive document generation requests, perform requirement analysis and task planning on document generation requests, identify target document types, and construct document generation tasks. The phased draft generation module 102 is connected to the requirement analysis and task planning module 101. It is used to schedule the corresponding model workflow according to the target document type, and call one or more model agents and database agents that match the target document type from the preset model agent set and database agent set according to each stage of the model workflow, execute the document generation task in stages, and generate document drafts. The assembly and verification module 103 is connected to the phased draft generation module 102. It is used to assemble the document draft according to the standard specifications of the target document type, verify the assembled document, and output the target document.

[0069] Further implementation details of this system have been disclosed and will not be repeated in this embodiment.

[0070] The following text combines Figure 5 Specific embodiments are provided to illustrate this technical solution: like Figure 5 As shown, the specific document generation steps of the method and system of the present invention are as follows: 201. Input document generation request: Users submit document generation requests through a natural language interactive interface. The interface supports text input and attachment upload. The request elements that users can submit include, but are not limited to, a natural language description of the document generation, the target document type, reference attachments (including documents, data files, etc.), word count threshold, target audience, and writing purpose.

[0071] 202, Task Parsing and Routing: After receiving the document generation request, the requirement parsing and task planning module 101 starts the structured task parsing and intelligent routing process; it deeply deconstructs the unstructured request content, extracts the core requirement elements and performs standardized processing to construct the document generation task; 203. Identify document types and categories: Based on the document generation requirements input by the user, automatically identify the corresponding document categories and subcategories, and route them to the appropriate generation process; This invention establishes a complete document classification architecture, combines intelligent parsing and routing mechanisms to achieve accurate classification and recognition of input text, and adopts an adaptive routing strategy based on the classification results to dynamically allocate tasks to the corresponding specialized document generation processes.

[0072] 204. Title Polishing: The phased draft generation module 102 calls the first model agent. In this embodiment, the Qwen2.5-72B-Instruct model is selected for title polishing. Based on the target document type and potential user needs, the system presets multiple polishing styles such as formal, concise, solemn, and rigorous, and constructs differentiated prompt word templates for different polishing styles. The first model agent performs semantic precision optimization and format standardization processing on the initial title provided by the user (if any) or the candidate title generated based on the needs, according to the prompt words corresponding to the selected polishing style. Finally, it outputs the target title that conforms to the target document type, scenario requirements, and style positioning, ensuring the professionalism and adaptability of the title.

[0073] 205. Determine whether thinking mode is enabled; if thinking mode is enabled, proceed to step 206; otherwise, proceed to step 207. 206. When the deep thinking mode is enabled, the first overview generation model is invoked. In this embodiment, the DeepSeek-R1-Distill-Llama-70B model is selected, which uses a multi-round reasoning mechanism to deeply deconstruct the writing scenario, audience characteristics and expression intention. 207. When the deep thinking mode is turned off, in the standard mode, the second overview generation model is called. In this embodiment, the Qwen2.5-72B-Instruct model is selected for efficient content generation. For different text types, different prompt words are used to directly output the core elements that conform to the specifications. The prompt word project includes the design of different policy instructions and the construction of context, and the prompt words are repeatedly optimized through question and answer effects. 208. Generate an overview of the theme / objectives / outcomes: Based on the results of step 206 or 207, the model automatically generates an overview that includes one or more combinations of the theme, objectives, and outcomes. 209. Determine if attachments are referenced: The system automatically detects whether the document generation request submitted by the user contains reference attachments. If reference attachments are detected, i.e. the user has enabled the reference attachment function, proceed to steps 210-212; if no reference attachments are detected, proceed directly to step 213. 210. Document Basis: For the detected reference attachments, the system first classifies the attachment types, distinguishes between document-related files and data-related files, and adopts a differentiated parsing strategy to ensure that the core information of different types of attachments can be effectively extracted and utilized. 211a. Document-related files: For document attachments, including but not limited to PDF, DOCX, TXT and other formats, the system uses a text semantic parsing algorithm to extract the core viewpoints, key sentences, logical framework and other information from the document, and organizes them in a structured manner to form a document information summary; 211b, Data-related files: For data attachments, including but not limited to XLSX, CSV and other formats, the system uses data extraction and visualization preprocessing algorithms to extract key data indicators, data trends, statistical results and other core information, and transforms structured data into content elements that can be directly embedded into documents; 212. The system calls the fourth model agent. In this embodiment, the Qwen2.5-72B-Instruct model is selected to perform deep semantic analysis on the uploaded document. Combined with the classification results of steps 211a and 211b, key information extraction, content summary generation, and document semantic graph construction are achieved. By constructing the association mapping relationship between the document semantic graph and the document generation requirements, the system intelligently identifies the relevance between the attachment content and the document topic, and dynamically embeds the extracted core information into the generation process, ultimately achieving deep integration and collaborative application of external knowledge and writing requirements.

[0074] 213. Determine if fine-tuning is needed: If yes, proceed to step 214, where a domain-specific fine-tuning model is invoked to generate an outline, ensuring a high degree of match between the model and the document type's professional requirements; otherwise, proceed to step 215, where an outline is generated using a combination of a basic model and prompt word engineering. The system dynamically configures the model generation path based on the intelligent document type identification results.

[0075] 214. For document types with high requirements for professional standardization, such as laws and regulations, the system automatically deploys the SHDLLM-9B-PolicyWriter domain-specific model, which has been fine-tuned using massive amounts of legal text. This model is based on the glm4-9b-chat model and fine-tuned using LoRA (low-rank adaptation). The fine-tuning training data comes from authoritative data sources such as real legal and regulatory databases and judicial case databases. It deeply integrates the legal terminology system and the structural features of standardized texts to ensure that the generated content conforms to legal document standards in terms of legal logic, clause expression, and format specifications. 215. For other general and comprehensive documents, the system adopts the Qwen2.5-72B-Instruct pre-trained basic model. It achieves domain adaptability by constructing a multi-dimensional prompt word engineering system, eliminating the need for fine-tuning model parameters and balancing generation efficiency and adaptability. Specifically, for different policy types such as approvals, replies, requests, notices, application guidelines, action plans, implementation plans, work priorities, guiding opinions, special policies, and management rules, the system configures differentiated multi-dimensional prompt word engineering. Each prompt word template corresponds to the structural specifications, expression requirements, and core elements of a specific document type. In implementation, the system dynamically loads differentiated prompt templates based on a document type feature library: first, it performs routing selection based on document type, policy type, and task type; second, it selects the appropriate prompt words based on the corresponding document type. On the one hand, it designs domain-specific content generation guidelines for different document types; on the other hand, it transforms standard official document format specifications into structured constraints and embeds them into the generation process. This dual control mechanism ensures that the output simultaneously meets the dual standards of content professionalism and format standardization.

[0076] This invention utilizes a multi-model scheduling and collaborative working mechanism, based on user-configured thinking mode switches, to activate differentiated generation strategies, call different models to generate summaries of themes / objectives / results, etc., to enrich the main content, and combines attachment parsing to extract relevant document data, thereby achieving intelligent generation of high-quality official document content.

[0077] 216. Generate Content Outline: Based on the model generation results of step 214 or 215, the system outputs a content outline that meets the structural requirements of the target document type and is logically rigorous.

[0078] 217. Outline Slicing for Step-by-Step Content Generation: The generated outline content is structurally decomposed, and paragraph slicing technology is used to divide the outline into logically related chapter units. For each segmented unit, an adapted model agent is invoked to generate content components that conform to the specifications section by section. During the generation process, the logical coherence and content completeness between chapters are monitored in real time. 218. Generate complete chapter content: The system systematically splices and refines each chapter unit, adds transitional phrases between chapters, standardizes the writing style and the use of professional terminology, and generates complete chapter content. Simultaneously, for chapters requiring data support, policy citations, or case studies, the system synchronously invokes a database agent to extract relevant resources from internal business databases, policy and regulation databases, and historical case databases, embedding them into the corresponding chapter content to enhance the document's authority and persuasiveness.

[0079] 219. Content assembly and formatting: The assembly and verification module 103 generates content by combining it according to the standard format of the target document type, automatically applies the corresponding typesetting standards, and ensures that all necessary components are complete and without omission. 220. Format and integrity verification: Verify the integrity of the format and logical structure, confirm that key content elements are complete, and ensure that data references are accurate and complete. 221. Output the final document: After verification, the system outputs the final document that meets the requirements, supporting multiple industry standard formats such as Word and PDF, and adapting to the usage and transmission needs of different scenarios.

[0080] The purpose of this invention is to address the writing needs of various general and professional official documents (such as work reports and legal documents) by using multi-model task planning and database intelligent agent enhancement technology, and leveraging the generation and reasoning capabilities of large language models to achieve the automatic generation of high-quality, structured, and data-driven official document content.

[0081] This invention effectively solves the problems of weak content generation capabilities and poor adaptability of traditional template-based systems by employing multi-model collaboration and dynamic task planning, achieving fully automated generation of standardized official documents from vague user requirements. Based on differentiated models such as R1 and Qwen for task type scheduling, it completes outline planning and content expansion respectively, and combines database intelligence to automatically import policies, cases, and business data, significantly improving the accuracy, standardization, and professionalism of the generated content, effectively supporting the intelligent creation of more than 40 document types.

[0082] This invention can precisely empower government agencies, enterprises and institutions in high-frequency scenarios such as daily document writing, policy document drafting, and special work reports, significantly reducing the writing burden of clerical staff and improving organizational collaboration and knowledge reuse efficiency.

[0083] The above are merely preferred embodiments of the present invention and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should recognize that any equivalent substitutions and obvious changes made using the content of this specification and illustrations should be included within the protection scope of the present invention.

Claims

1. A document generation method based on multi-model and database intelligent agents, characterized in that, include: Step S1: Receive a document generation request, perform requirement analysis and task planning on the document generation request, identify the target document type, and construct a document generation task; Step S2: According to the target document type, schedule the corresponding model workflow, and call one or more model agents and database agents that match the target document type from the preset model agent set and database agent set according to each stage of the model workflow, and execute the document generation task in stages to generate a document draft. Step S3: Assemble the document draft according to the standard specifications of the target document type, verify the assembled document, and output the target document.

2. The document generation method based on multi-model and database agent according to claim 1, characterized in that, The identification of the target document type in step S1 includes: A predefined multi-level document type system is defined, which includes multiple major categories, a first subclass under each major category, and a second subclass under each first subclass. Based on a predefined multi-level document type system, identify at least one of the major category, first subcategory, and second subcategory to which the document generation request belongs, and determine the target document type.

3. The document generation method based on multi-model and database agent according to claim 1, characterized in that, The requirements in the document generation request include one or more combinations of document type, writing purpose, target audience, word count requirement, and reference attachments.

4. The document generation method based on multi-model and database agent according to claim 1, characterized in that, Step S2 includes: Step S21: Invoke the first model agent. The first model agent performs title polishing on the document generation request according to the first prompt word corresponding to the target polishing style to obtain the target title. Step S22: Invoke the second model agent according to the configured thinking mode switch. The second model agent generates an overview content based on the target title. The overview content includes at least one or more combinations of theme, goal, and outcome. Step S23: Invoke the third model agent that matches the target document type. The third model agent generates a document outline that meets the structural requirements of the target document type based on the multi-dimensional prompt words that match the target document type and the overview content. Step S24: Slice the generated document outline into paragraphs, break the document outline into multiple logically related chapter units, expand the content of each chapter unit, and generate the chapter content corresponding to each chapter unit. Step S25: Based on the logical structure of the document outline, integrate the chapter content corresponding to each chapter unit to generate the document draft.

5. The document generation method based on multi-model and database agent according to claim 4, characterized in that, Step S22 includes: In response to the thinking mode switch being configured to be on, the first overview generation model is invoked as the second model agent, and the first overview generation model generates the overview content based on the target title; In response to the thinking mode switch being configured to be off, the second overview generation model is invoked as the second model agent. The second overview generation model generates the overview content based on the second prompt word corresponding to the target document type and the target title.

6. The document generation method based on multi-model and database agent according to claim 1, characterized in that, The document generation request includes a reference attachment, and the process preceding step S23 includes: The fourth model agent is invoked to perform semantic parsing on the reference attachment and extract a content summary. Step S23 further includes: constructing an association mapping relationship between the content summary of the reference attachment and the overview content, extracting the association information in the content summary according to the association mapping relationship, embedding the association information into the output content of the third model agent, and generating the document outline.

7. The document generation method based on multi-model and database agent according to claim 1, characterized in that, The step S23, which involves calling a third model agent that matches the target document type, includes: When the target document type is the first major category, the first outline generation model is invoked as the third model agent; When the target document type is the second major category, the second outline generation model, which is fine-tuned based on the database agent, is invoked as the third model agent.

8. The document generation method based on multi-model and database agent according to claim 1, characterized in that, Step S3 includes: Step S31: Assemble and format the document draft according to the standard specifications of the target document type; Step S32: Perform integrity and logical structure consistency checks on the assembled document, and output the target document after the checks pass.

9. The document generation method based on multi-model and database agent according to claim 1, characterized in that, Also includes: An interactive interface is provided, which is used to display the content generated by each model agent; In response to an interactive revision instruction input by the user through the interactive interface, the interactive revision instruction includes at least one of a local correction instruction, a fragment recombination instruction, a supplementary generation instruction, and a style adjustment instruction, and performs a corresponding modification operation on the content generated by the model agent based on the interactive revision instruction.

10. A document generation system based on multi-model and database intelligent agents, characterized in that, A document generation method based on multi-model and database agents as described in any one of claims 1-9, comprising: The requirement analysis and task planning module is used to receive document generation requests, perform requirement analysis and task planning on the document generation requests, identify target document types, and construct document generation tasks. The phased draft generation module is connected to the requirement analysis and task planning module. It is used to schedule the corresponding model workflow according to the target document type. According to each stage of the model workflow, it calls one or more model agents and database agents that match the target document type from the preset set of model agents and set of database agents to execute the document generation task in stages and generate document drafts. The assembly and verification module, connected to the phased draft generation module, is used to assemble the document draft according to the standard specifications of the target document type, verify the assembled document, and output the target document.