Intelligent generation and compliance checking method for official documents

By employing a technical framework of structured template constraints, large language model generation, and rule engine verification, the problems of non-standard formatting and difficulty in ensuring compliance in official document generation have been solved, achieving efficient, intelligent, and compliant official document generation and verification.

CN123139969APending Publication Date: 2026-11-20DIGITAL XINJIANG IND INVESTMENT (GRP) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611100281.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Existing methods for generating official documents suffer from problems such as non-standard formats and difficulty in ensuring compliance.

Method used

By employing a technical approach that combines structured template constraints, large language model generation, and rule engine verification, official documents are automatically generated that conform to standards, have complete content structure, and use compliant terminology.

Benefits of technology

Significantly reduces the workload of manual proofreading and modification, enabling efficient, intelligent, and compliant document drafting and output.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123139969A_ABST
    Figure CN123139969A_ABST
Patent Text Reader

Abstract

The application relates to a method for intelligent generation and compliance verification of official documents. The method comprises the following steps: obtaining the core elements of the official document input by a user; retrieving a matched structured official document template from a template library according to the core elements of the official document; generating a preliminary draft of the official document by using a pre-trained large language model according to the structured official document template and the core elements of the official document; performing format standardization processing on the preliminary draft of the official document according to a format constraint field to obtain a formatted official document; verifying the formatted official document by using a compliance verification rule engine, and outputting a final official document or generating a modification prompt according to the verification result. The method can automatically generate an official document with a standard format, a complete content structure and compliant language by integrating a complete technical link of structured template constraints, large language model generation, format standardization processing and rule engine verification, thereby significantly reducing the workload of manual proofreading and modification, and realizing efficient, intelligent and compliant official document drafting and output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of natural language processing and office automation technology, and in particular to a method for intelligent generation and compliance verification of official documents. Background Technology

[0002] With the development of artificial intelligence technology, large language models are widely used in text generation tasks. In the field of office automation, using large language models to assist in document drafting can significantly improve work efficiency. However, existing document generation methods suffer from technical problems such as non-standard formats and difficulty in ensuring compliance. Summary of the Invention

[0003] This invention provides a method for intelligent generation and compliance verification of official documents, which overcomes at least one of the above-mentioned technical problems existing in the prior art.

[0004] To achieve the above objectives, the embodiments of the present invention adopt the following technical solutions: Firstly, this invention provides a method for intelligent generation and compliance verification of official documents, including: Obtain the core elements of the official document input by the user; Based on the core elements of the official document, a matching structured official document template is retrieved from the template library. The structured official document template includes at least a fixed paragraph field, a variable field slot, and a format constraint field. Based on the structured document template and the core elements of the document, a preliminary draft of the document is generated using a pre-trained large language model; The initial draft of the official document is formatted according to the format constraint fields to obtain a formatted official document; The formatted official document is validated using a compliance verification rule engine, and the final official document is output or a modification prompt is generated based on the verification results.

[0005] In one possible implementation of the first aspect, the structured document template further includes basic information fields and compliance prerequisites; wherein, The basic information field is used to store the template's metadata; The fixed paragraph field is used to store the fixed layout area of ​​the document template; The variable field slot is used to dynamically populate changed elements in official documents; The format constraint field is used to define the layout specification parameters of the official document template. The compliance prerequisites are used to record the compliance elements corresponding to the document type.

[0006] In one possible implementation of the first aspect, generating a draft document using a pre-trained large language model based on the structured document template and the core elements of the document includes: Extract key information from the core elements of the official document, and combine it with the structured document template and the compliance prerequisites to construct structured prompt words; The structured prompts are input into a pre-trained large language model to obtain the initial draft text; The variable content in the initial draft text is filled into the variable field slot, and the preset field values ​​are automatically filled; The filled variable paragraphs are assembled sequentially with the fixed paragraphs in the fixed paragraph field to generate a complete draft of the official document.

[0007] In one possible implementation of the first aspect, the training process of the large language model includes: Obtain a training sample set consisting of official document texts; The large language model is fine-tuned using a composite loss function, which is composed of a weighted sum of a language modeling loss term and a format compliance loss term. The format compliance loss item is determined based on the compliance score of the model-generated text by the rule engine. The compliance score covers at least four evaluation dimensions: structural integrity, format standardization, language compliance, and logical coherence.

[0008] In one possible implementation of the first aspect, the weight coefficient of the format compliance loss term in the composite loss function is dynamically adjusted based on the format compliance rate on the validation set.

[0009] In one possible implementation of the first aspect, the standardization of the document draft based on the format constraint field includes: The draft document is subjected to structured parsing to identify structural elements; Based on the typesetting specification parameters defined in the format constraint field, set corresponding format attributes for each structural element; Automatically add header elements, which include at least the issuing authority logo, document number, and separator line; If the document carries a non-public security classification mark, then a security classification mark box will be configured on the homepage; A footer should be placed at the bottom of the last page of the official document. The footer should include at least the recipients, the issuing authority, and the date of issuance.

[0010] In one possible implementation of the first aspect, the verification of the formatted document using a compliance verification rule engine includes: Based on the document type of the formatted document, a corresponding set of verification rules is selected from a preset rule base; the rule base includes at least structural integrity verification rules, format standardization verification rules, language compliance verification rules, logical consistency verification rules, and security and confidentiality verification rules. Execute the verification rules in the set of verification rules to identify violations in the formatted document; Based on the verification rule type to which the violation belongs, perform the corresponding processing operation on the violation, and output the processed document or generate a modification prompt.

[0011] In one possible implementation of the first aspect, performing a corresponding processing operation on the violation item according to the verification rule type to which the violation item belongs includes: For violations of structural integrity and / or security and confidentiality, interception will be performed and modification prompts will be generated; For violations of formatting standards, language compliance, and / or logical consistency, automatic correction or modification prompts will be generated.

[0012] One possible implementation of the first aspect also includes: Collect user modification data on the final official document and store it in the incremental dataset; The large language model is incrementally fine-tuned based on the incremental dataset at a preset period.

[0013] In one possible implementation of the first aspect, the incremental fine-tuning of the large language model based on the incremental dataset includes: Retain historical model versions; If the performance metrics of the current version of the model deteriorate by more than a preset deterioration threshold compared to the previous version, the model will revert to the previous version.

[0014] Compared with the prior art, the present invention has at least the following beneficial effects: The intelligent document generation and compliance verification method provided by this invention integrates a complete technical chain of structured template constraints, large language model generation, format standardization processing and rule engine verification. It can automatically generate official documents with format conforming to standards (such as GB / T 9704), complete content structure and compliant language, significantly reducing the workload of manual proofreading and modification, and achieving efficient, intelligent and compliant document drafting and output.

[0015] Secondly, the present invention provides an intelligent document generation and compliance verification system, comprising: The acquisition module is used to acquire the core elements of the official document input by the user; The document template matching module is used to retrieve a matching structured document template from the template library based on the core elements of the document. The structured document template includes at least a fixed paragraph field, a variable field slot, and a format constraint field. The document draft generation module is used to generate a draft document based on the structured document template and the core elements of the document using a pre-trained large language model. The formatting processing module is used to perform format standardization processing on the initial draft of the official document according to the format constraint field to obtain the formatted official document; The compliance verification module is used to verify the formatted official document using a compliance verification rule engine, and output the final official document or generate modification prompts based on the verification results.

[0016] Thirdly, the present invention provides an electronic device comprising: at least one processor and at least one memory, wherein the memory stores computer-readable instructions; the computer-readable instructions are executed by one or more of the processors, causing the electronic device to implement the document intelligent generation and compliance verification method as described in any implementation of the first aspect.

[0017] Fourthly, the present invention provides a storage medium having a computer-executable program stored thereon, the computer-executable program being used to cause a computer to execute the document intelligent generation and compliance verification method as described in any implementation of the first aspect.

[0018] Understandably, the beneficial effects achieved by the system of the second aspect, the electronic device of the third aspect, and the storage medium of the fourth aspect provided above can be referred to in light of the beneficial effects of the first aspect and any of its possible design embodiments, which will not be repeated here. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of this application 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 some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention; Figure 2 A flowchart illustrating a method for intelligent document generation and compliance verification provided in this embodiment of the invention; Figure 3 This is a structural block diagram of an intelligent document generation and compliance verification system provided in an embodiment of the present invention. Detailed Implementation

[0021] The technical solutions of the embodiments of the present invention will be described below with reference to the accompanying drawings. In the description of the present invention, unless otherwise stated, " / " indicates that the objects before and after are in an "or" relationship. For example, A / B can represent A or B. The "or" in the present invention is merely a description of the relationship between the related objects, indicating that three relationships can exist. For example, A or B can represent: A alone, A and B simultaneously, and B alone. A and B can be singular or plural. Furthermore, in the description of the present invention, unless otherwise stated, "multiple" refers to two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items.

[0022] Furthermore, to facilitate a clear description of the technical solutions of the embodiments of the present invention, the terms "first" and "second" are used in the embodiments of the present invention to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.

[0023] In this embodiment of the invention, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" or "for example" in this embodiment of the invention should not be construed as superior or more advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner for ease of understanding.

[0024] With the development of artificial intelligence technology, large language models are widely used in text generation tasks. In the field of office automation, using large language models to assist in document drafting can significantly improve work efficiency. However, existing document generation methods suffer from technical problems such as non-standard formats and difficulty in ensuring compliance.

[0025] In view of this, on the one hand, embodiments of the present invention provide a method for intelligent generation and compliance verification of official documents, including: obtaining core elements of an official document input by a user; retrieving a matching structured official document template from a template library based on the core elements of the official document, wherein the structured official document template includes at least fixed paragraph fields, variable field slots, and format constraint fields; generating a draft official document using a pre-trained large language model based on the structured official document template and the core elements of the official document; performing format standardization processing on the draft official document based on the format constraint fields to obtain a formatted official document; verifying the formatted official document using a compliance verification rule engine, and outputting the final official document or generating modification prompts based on the verification results.

[0026] The present invention provides a method for intelligent document generation and compliance verification. By integrating a complete technical chain of structured template constraints, large language model generation, format standardization processing and rule engine verification, it can automatically generate official documents with format conforming to standards (such as GB / T 9704), complete content structure and compliant language. This significantly reduces the workload of manual proofreading and modification, and achieves efficient, intelligent and compliant document drafting and output.

[0027] In some embodiments, the document intelligent generation and compliance verification method provided by the present invention can be executed by any electronic device 20 with data processing capabilities, such as a general-purpose computer, personal computer, laptop computer, switch or tablet computer, etc. The specific implementation method of the electronic device 20 is not limited here.

[0028] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention is shown. The electronic device 20 includes a processor 210, a memory 220, and a communication interface 230.

[0029] Processor 210 may include one or more processing cores. Processor 210 connects to various parts within electronic device 20 using various interfaces and lines, and performs various functions and processes data of electronic device 20 by running or executing instructions, programs, code sets, or instruction sets stored in memory 220, and by calling data stored in memory 220. Optionally, processor 210 may be implemented using at least one of the following hardware forms: Central Processing Unit (CPU), Graphics Processing Unit (GPU), Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA).

[0030] The memory 220 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 220 may include a non-transitory computer-readable storage medium. The memory 220 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 220 may include a program storage area. This program storage area may store instructions for implementing an operating system, instructions for implementing at least one function, instructions for implementing the various method embodiments described above, etc.

[0031] Communication interface 230 is used to communicate with other devices, equipment or communication networks, such as data storage devices, image processing devices or Ethernet, wireless access network (RAN), wireless local area network (WLAN), etc.

[0032] In terms of physical implementation, the aforementioned devices (such as processor 210, memory 220, and communication interface 230) can each be devices within the same device (such as a laptop computer). Alternatively, at least two of these devices can be located within the same device, i.e., as different devices within the same device, similar to the deployment of devices or components in a distributed system.

[0033] It is understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 20. In other embodiments of the present invention, the electronic device 20 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0034] The following description, in conjunction with the accompanying drawings, illustrates an embodiment of the present invention that provides a method for intelligent generation and compliance verification of official documents.

[0035] like Figure 2 As shown, this embodiment of the invention provides a method for intelligent generation and compliance verification of official documents, which may include, but is not limited to: S1: Obtain the core elements of the official document input by the user.

[0036] In specific implementation, embodiments of the present invention may provide, but are not limited to, the following three parallel input channels, which users may choose to use in combination: Natural language text input: Users submit unstructured descriptive text through a text box, such as "Draft a work summary on safety production in 2025, highlighting the effectiveness of hazard investigation and management and emergency drills." This text will serve as the information source for subsequent semantic parsing.

[0037] Structured form input: The system provides a graphical user interface with the following preset fields for users to select or fill in: document type (work summary, request for instructions, report, notice, announcement, etc.), urgency level (urgent, urgent, regular), security level (public, internal, secret, confidential), issuing authority (automatically filled in by the system according to the user's role and supports manual modification), addressee / copy recipient, date of issuance, etc.

[0038] Reference document upload: Users can upload historical official documents, previous versions, or sample documents (supporting common formats such as .docx and .pdf). The system uses the document parsing component to extract their structural features, writing style, and key content fragments as contextual references to assist in the generation process.

[0039] In specific implementation, after receiving information input by the user through different input channels, this embodiment of the invention encapsulates all input information from all sources into a request object in a preset format (such as JSON format). The request object includes at least the following fields: request_id: A globally unique identifier used for request tracing and log association; user_id: The identifier of the initiating user, used for permission verification and personalized configuration; department: The user's organizational unit, used to determine the default issuing authority and writing style adaptation; timestamp: The time when the request was initiated, used to automatically generate time-related fields such as the document date; The input sub-object further contains: text_input: Natural language description text (set to empty if not provided); form_input: A collection of key-value pairs for structured form fields, including at least doc_type (document type code), urgency, security_level, and issuing_authority; reference_docs: A list of metadata for referenced documents, each item containing the document name, storage path, and a summary of the key content extracted; The context sub-object contains environment information for the user's current session, such as role and permission level.

[0040] In specific implementation, this embodiment of the invention may perform, but is not limited to, the following mandatory verification operations while generating the request object: Not null and mutual exclusion check: Ensure that at least one of text_input and form_input.doc_type is not null. If both are missing, return an error message and terminate the process.

[0041] Permission boundary verification: Based on context.permission_level and department, determine whether the security_level and issuing_authority selected by the user are within the authorized scope; if they are outside the authorized scope, the system will automatically adjust the relevant fields to the valid default values ​​or require the user to re-enter them.

[0042] Format standardization: Date fields are standardized to ISO 8601 format (YYYY-MM-DD), and document type names are mapped to internal standard coding tables (e.g., "Request for Instructions and Report" is mapped to "QS") to ensure accurate matching in template retrieval.

[0043] In specific implementation, when the user only provides text_input but does not fully fill in form_input, this embodiment of the invention can also call a lightweight semantic understanding module (e.g., a BERT-based fine-tuning classifier) ​​to perform the following inference: Document type classification: Extract document type feature words such as "request for instructions", "report", "notice" and "summary" from natural language text, and output the most likely document type and its confidence level by combining the context semantics.

[0044] Key entity extraction: Identify key information such as time, amount, organization name, and event object in the text and automatically fill it into the corresponding fields of form_input (e.g., fill "2 million yuan" into the budget amount field).

[0045] After the above processing, regardless of the user's input method, the embodiments of the present invention can output a complete, standardized request object that has passed basic verification. This object provides clear input data specifications for subsequent template retrieval and content generation steps.

[0046] S2: Based on the core elements of the official document, retrieve a matching structured official document template from the template library. The structured official document template includes at least a fixed paragraph field, a variable field slot, and a format constraint field.

[0047] In one feasible implementation, the structured document template in this embodiment of the invention may include, but is not limited to, basic information fields and compliance prerequisites; The basic information field is used to store the template's metadata, including the template's unique identifier (template_id), template name, document type (doc_type), list of applicable departments, version number, creation / update time, etc. The fixed paragraph field is used to store the fixed layout area of ​​the document template, such as the header area (issuing authority logo, document number position), the fixed body part (such as "The relevant matters are hereby requested as follows"), and the imprint area (copy and distribution information); The variable field slots are used to dynamically fill the changed elements in the official document. Specifically, they can mark the position of the content that needs to be dynamically filled in the official document in the form of placeholders ({field name}), such as {issuing authority name}, {document number}, {title}, {body content}, {date of issuance}, etc. The format constraint field is used to define the layout specification parameters of the official document template, including font (Fangzheng Xiaobiao Songti No. 2 for title, Fangsong No. 3 for body text), font size, line spacing (fixed value 28 points), page margins (top 37mm / bottom 35mm / left 28mm / right 26mm), numbering level, page size (A4 paper), etc.

[0048] The aforementioned compliance prerequisites are used to record the compliance elements corresponding to the document type. For example, requests must include the closing phrase "Please approve or disapprove," and summaries must include four parts: "Basic Information," "Main Tasks," "Existing Problems," and "Next Steps."

[0049] In specific implementation, the embodiments of the present invention can use a hybrid storage method of database and file system to store templates. Specifically, the template's meta-information and field definitions are stored in the template table of a relational database (such as MySQL), while the complete layout is stored in the file system as an OOXML file and associated with the template ID.

[0050] In specific implementation, embodiments of the present invention can retrieve matching structured document templates from the template library in the following ways: The first step is to extract key information for retrieval from the request object generated by S1, including: Document type: prioritize form_input.doc_type (if the user has explicitly selected it). If it is missing, use the semantic understanding module to classify text_input by document type and output the predicted document type and confidence level.

[0051] Keyword set: Extract noun phrases, action objects, etc. from the text_input and reference_docs abstracts to form a search keyword vector.

[0052] Semantic vector: The supplementary descriptions in text_input and form_input are concatenated into the query text, and a fixed-dimensional vector representation is generated by a pre-trained semantic encoder (such as BGE-large-zh).

[0053] The second step is to perform the search. Embodiments of this invention may employ, but are not limited to, a search strategy that combines precise index retrieval and semantic vector retrieval, as detailed below: (1) Precise index retrieval: A B+ tree index is built based on the doc_type and applicable_departments fields in the template's basic information. Execute the following query: Based on the extracted document types, perform equivalent matching to obtain a candidate template set Set_exact.

[0054] If the user's department is in the list of applicable departments for the template, then the template score is weighted.

[0055] (2) Semantic Vector Retrieval: For each template in the template library, a semantic vector (using BGE-large-zh encoding) is pre-generated for its name, description, and example content. The cosine similarity between the semantic vector and each template vector is calculated, and the templates are sorted from high to low similarity. The top K templates are selected to form a semantic candidate set Set_semantic (K can be set to 5).

[0056] (3) Merging and sorting: Templates in Set_exact are ranked before those in Set_semantic (i.e., exact matches have absolute priority). Within Set_exact, templates are sorted in descending order by applicable department matching degree and template usage frequency; within Set_semantic, templates are sorted in descending order by similarity. The template at the top of the final output is used as the default matching template, and the top 3 templates are returned to the user interface as a candidate list (if the user wishes to select manually).

[0057] In the specific implementation process, if the exact index retrieval does not find any template (i.e., there is no template that completely matches the document type specified by the user), it will be downgraded to pure semantic retrieval, directly using the semantic candidate set, and taking the template with the highest similarity as the default template. At the same time, the user interface will prompt "No exact matching template found. The following templates are recommended for reference".

[0058] In specific implementation, after matching and determining the template, the embodiments of the present invention perform a loading operation, including: First, query the Redis cache. If template:{template_id} exists, then directly retrieve the serialized template object.

[0059] If the cache misses, the template metadata is loaded from the database, and the corresponding OOXML layout file is read from the file system. Its fixed paragraph content is parsed, assembled into a structured template object in memory, and written to the Redis cache (with an expiration time set to 1 hour).

[0060] Once loaded, a complete structured document template object is output, which includes fixed paragraphs, variable slots, format constraints, and compliance prerequisites.

[0061] S3: Based on the structured document template and the core elements of the document, generate the first draft of the document using a pre-trained large language model.

[0062] In one feasible implementation, the generation of a draft document using a pre-trained large language model based on the structured document template and the core elements of the document in this embodiment of the invention may include, but is not limited to: Extract key information from the core elements of the official document, and combine it with the structured document template and the compliance prerequisites to construct structured prompt words; The structured prompts are input into a pre-trained large language model to obtain the initial draft text; The variable content in the initial draft text is filled into the variable field slot, and the preset field values ​​are automatically filled; The filled variable paragraphs are assembled sequentially with the fixed paragraphs in the fixed paragraph field to generate a complete draft of the official document.

[0063] In specific implementation, this embodiment of the invention performs joint parsing of the natural language text (input.text_input) and structured form fields (input.form_input) in the request object generated by S1 to extract the key information required for constructing the prompt words, which may include, but is not limited to: Document type and topic: If form_input.doc_type has been explicitly specified by the user, it will be used directly; otherwise, the lightweight semantic understanding module (based on a BERT-based fine-tuned classifier or a small instance of a large language model) will be called to classify text_input and output the most likely document type (such as "request", "report", "notice"). At the same time, core topic phrases (such as "application for special funds for safe production") will be extracted from the text.

[0064] Entities and Data: The Named Entity Recognition (NER) module (also based on fine-tuning of a pre-trained language model) is used to extract entities such as time, amount, department, and event name from text_input, for example, {amount: "2 million yuan", event: "procurement of hidden danger investigation equipment and emergency drill"}.

[0065] Additional constraints: Read the meta-information such as urgency level, security classification, issuing authority, and addressee explicitly filled in by the user from form_input, as well as the structural features and common expressions extracted from reference_docs abstracts, as style references for the generation stage.

[0066] The aforementioned key information is temporarily stored in the context of the current request in the form of structured key-value pairs for use in the construction of subsequent prompts.

[0067] In specific implementation, this embodiment of the invention constructs a multi-layered instruction-type prompt based on the field definitions in the structured document template output by S2 and the extracted key information. The prompt includes at least the following components: Role definition layer: Specifies the role played by the large language model, such as "You are a senior expert in writing official documents for state-owned enterprises, and are proficient in the 'Regulations on the Processing of Official Documents' and the GB / T 9704 standard".

[0068] Task description layer: Clearly defines the target content to be generated by the model, such as "Please write a complete document of {doc_type} based on the following information".

[0069] Template structure constraint layer: Extract structural requirements from the template's fixed paragraph fields, variable field slot positions, and format constraint fields, such as "must include the following fixed paragraphs: 'I. Reasons for application' 'II. Application matters', and use second-level numbering (I) (II) in the matters section."

[0070] Compliance prerequisite layer: The compliance prerequisites stored in the template (such as requests must end with "Please approve") are written into prompts in the form of natural language instructions, such as "The end must use 'Please approve'".

[0071] Content Highlights Layer: The key information, including themes, entities, and data, is embedded with prompts in the form of structured lists or paragraphs. For example, “Core content: Apply for 2 million yuan of special funds for safe production in 2025, which will be used for the purchase of equipment for hidden danger investigation (1.2 million yuan) and the conduct of emergency drills (800,000 yuan).”

[0072] If a user uploads a reference document, this embodiment of the invention can also extract typical paragraphs (with length limited to avoid exceeding the limit) and attach them as style examples to the end of the prompt words, i.e., the reference example layer.

[0073] All levels are concatenated into a single, complete string according to a predefined template; this string is the structured prompt. Placeholders marked with {variable name} will be replaced with actual values ​​in subsequent steps.

[0074] After constructing the structured prompt words, input them into a pre-trained large language model to obtain the initial draft text.

[0075] In one feasible implementation, the training process of the large language model in this embodiment of the invention may include, but is not limited to: Obtain a training sample set consisting of official document texts; The large language model is fine-tuned using a composite loss function, which is composed of a weighted sum of a language modeling loss term and a format compliance loss term. The format compliance loss item is determined based on the compliance score of the model-generated text by the rule engine. The compliance score covers at least four evaluation dimensions: structural integrity, format standardization, language compliance, and logical coherence.

[0076] In the specific implementation process, the large language model in this embodiment of the invention does not directly use a general base model for zero-shot inference, but is based on a corpus specific to the field of state-owned enterprise documents, and is adapted to the domain through supervised fine-tuning. The specific fine-tuning process is as follows: (1) Construction of the training sample set This invention collects a large amount of raw text data (approximately 57,000 documents) from historical compliance documents, policy and regulatory texts, and internal corporate regulations. The following preprocessing is performed on the raw text data: De-identification: Using regular expressions and named entity recognition models, specific names, contact information, financial data, and confidential details in official documents are masked and replaced (for example, "Zhang San" is replaced with "[name]", and specific amounts are replaced with "[amount]") to ensure that no real sensitive information is contained.

[0077] Structured annotation: Each official document is annotated at the paragraph level, marking structural areas such as the header, title, addressee, paragraphs of the main text (including numbering levels), attachment description, signature, date of issuance, and imprint, and annotating the stylistic features of each area (such as the required closing remarks in request documents).

[0078] Quality filtering: Remove low-quality samples that are too short (less than 200 words), have severely incomplete formatting, or have more than 90% content duplication.

[0079] Sample format construction: Each annotated official document is converted into an "instruction-input-output" triple. The instruction is a task description for that document type (e.g., "Please write the main body of a request report based on the following information"), the input is the core elements extracted from the original text (e.g., the reason for the request, amount, background), and the output is the complete annotated document text. Approximately 80,000 training samples are ultimately generated, divided into training, validation, and test sets in an 8:1:1 ratio.

[0080] (2) Fine-tuning algorithm and hyperparameter configuration This invention can, but is not limited to, employing the QLoRA (Quantized Low-Rank Adaptation) lightweight fine-tuning scheme. The base model is a general-purpose large language model with 7B or 13B parameters (such as LLaMA, ChatGLM, etc.). During fine-tuning, the base model is quantized to 4-bit, and only the low-rank adaptation matrix is ​​trained without updating the original model weights. The LoRA configuration is as follows: Low-rank rank: 64; Scaling parameter (alpha): 128; The number of trainable parameters is approximately 0.5%-1% of the total number of parameters in the base model.

[0081] Key hyperparameter settings: Learning rate: 2e-4, combined with cosine annealing decay strategy, warm-up steps account for 3% of the total steps; Batch size: Set the batch size per device to 4, and the gradient accumulation step count to 8 (equivalent to a global batch size of 32). Training rounds: 3 epochs, with an early stopping mechanism (the training will terminate if the validation set loss does not decrease for 3 consecutive rounds). Optimizer: AdamW, weight decay factor 0.01; Maximum sequence length: 4096 tokens.

[0082] (3) Design of composite loss function The loss function in this embodiment of the invention is composed of a weighted sum of a language modeling loss term and a format compliance loss term: L total =L ce +λ×L compliance ; Among them, L ce The standard cross-entropy loss is used to measure the word-level difference between the model-generated text and the target text.

[0083] L complianc =1-S format S format This is a compliance score (range 0-1) given by the rules engine to the text currently generated by the model. The scoring dimensions include: Structural integrity (weight 0.3): Check whether it contains the necessary structural elements for this document type (e.g., requests must include the reason for the request, the matter at hand, and a closing statement). Formatting compliance (weight 0.3): Check whether the font, font size, line spacing, numbering hierarchy, etc. conform to the GB / T 9704 standard; Language compliance (weight 0.2): Check whether it contains essential official document language (such as "Please approve or disapprove"), and whether it avoids colloquial expressions and prohibited expressions; Logical coherence (weight 0.2): Evaluates whether the logical connections between paragraphs are natural and whether the data references are consistent.

[0084] The following generation parameters can be set during inference: Temperature: 0.2~0.3 (low temperature ensures the determinism and standardization of output); top_p: 0.85~0.9 (kernel sampling, preserving moderate diversity while avoiding divergence); max_new_tokens: 4096 (to ensure the complete generation of long official documents); stop_strings: can set the end marker such as "(No text on this page)".

[0085] λ is the weighting coefficient for the format compliance loss term, initially set to 0.1. It is dynamically adjusted during training based on the format compliance rate on the validation set. When the validation set format compliance rate is below 80%, λ increases to 0.3; When the validation set format compliance rate is higher than 95%, λ decreases to 0.05.

[0086] This composite loss function imposes a strong constraint on the model's format compliance during the training phase, forcing it to generate text that is more in line with official document standards.

[0087] In specific implementation, when the structured prompt words are input into a pre-trained large language model, the following generation parameters can be set, but are not limited to: Temperature: 0.2~0.3 (low temperature ensures the determinism and standardization of output); top_p: 0.85~0.9 (kernel sampling, preserving moderate diversity while avoiding divergence); max_new_tokens: 4096 (to ensure the complete generation of long official documents); stop_strings: can set the end marker such as "(No text on this page)".

[0088] The large language model outputs a plain text that contains the main content of the official document, which conforms to the template structure and compliance requirements; this is the first draft text.

[0089] After generating the initial draft text, this embodiment of the invention inserts the already filled variable paragraphs into the correct positions according to the sequential structure of the fixed paragraph fields (such as the header, main fixed lead, and footer) defined in the template. The specific assembly steps can be understood as follows: Iterate through the list of fixed paragraph fields in the template and retrieve the complete content of each fixed paragraph in order of paragraph_index.

[0090] If a variable field slot is defined after or within the current fixed paragraph, the corresponding filled variable paragraph will be inserted at that position (recursive nesting is supported).

[0091] For fixed paragraphs without variable slots, simply copy the original content.

[0092] Finally, all paragraphs are connected into a complete text stream, which is the complete first draft of the official document.

[0093] After assembly, a complete draft of the official document containing a fixed format framework and dynamically generated content is output. The draft strictly conforms to the conventions of the selected official document template in terms of structure, but it is still in an unformatted plain text state in terms of layout style (font, font size, margins, etc.).

[0094] S4: Standardize the format of the initial draft of the document according to the format constraint fields to obtain the formatted document.

[0095] In one feasible implementation, the format standardization processing of the initial draft of the official document based on the format constraint field in this embodiment of the invention may include, but is not limited to: The draft document is subjected to structured parsing to identify structural elements; Based on the typesetting specification parameters defined in the format constraint field, set corresponding format attributes for each structural element; Automatically add header elements, which include at least the issuing authority logo, document number, and separator line; If the document carries a non-public security classification mark, then a security classification mark box will be configured on the homepage; A footer should be placed at the bottom of the last page of the official document. The footer should include at least the recipients, the issuing authority, and the date of issuance.

[0096] In specific implementation, embodiments of the present invention may, but are not limited to, employ a hybrid method of regular expressions and rule engines to perform structured parsing of the initial draft of the official document. The specific process can be understood as follows: Title recognition: Match independent lines that begin with typical official document title patterns such as "About...", "Notice of...", or "Report of...", and that have no numbering before or after them, and mark them as title elements.

[0097] Recipient identification: Locate the first line below the title that ends with a colon or comma and contains keywords such as "organization", "bureau", or "group", and mark it as the recipient element.

[0098] Body paragraph and number hierarchy recognition: Level 1 headings: match lines starting with Chinese numerals followed by a顿号 such as "一、" and "二、", and mark them as heading1; Level 2 headings: match lines starting with parenthesized Chinese numerals such as "(一)" and "(二)", and mark them as heading2, etc.; Ordinary body text: paragraphs not belonging to the above categories are marked as body_text.

[0099] Attachment description recognition: match an independent line starting with "附件:", and mark it as attachment.

[0100] Signature recognition: locate the second last line and the last line at the end of the document, match the patterns of the issuing authority signature and the written date respectively, and mark them as signature_authority and signature_date.

[0101] After the parsing is completed, a structured representation list containing the element type, original text, start position and end position is generated.

[0102] In a specific implementation process, the format constraint field in the embodiment of the present invention may be stored in the form of a key-value pair set, for example: Traverse the structured representation list, create a FormatAttributes object containing the above-mentioned format attribute key-value pairs for each element, and associate it with the element.

[0103] In a specific implementation process, the embodiment of the present invention automatically injects the following elements before the start position of the document body (that is, above the title) according to the header area specification defined by the fixed paragraph field in the structured official document template: Issuing authority mark: According to the full name of the issuing authority predefined in the template (or obtained from the user context), generate large red characters (in Founder Xiaobiaosong typeface, size 2 or size 1), center-aligned, located about 25mm below the top margin of the page. The content of the mark is usually "XX Group Document" or "XX Group".

[0104] Document number: Leave one blank line below the issuing authority mark, and generate the document number line. The format of the document number is "Authority abbreviation [Year] Serial number", for example, "XX Safety Supervision

[2025] No. 8". The year is the current four-digit year, and the serial number is automatically generated by the system according to the document issuing sequence or specified by the user. The font is size 3 Fangsong, center-aligned or right-aligned (depending on the template requirements).

[0105] Separator line (red line): Draw a red separator line below the document number. The line is 1.5pt wide and its length is equal to the page width (28mm from both the left and right margins), and 25mm from the bottom edge of the header (i.e., a fixed distance from the bottom of the issuing authority's logo). This line uses the document object model... <w:border>Alternatively, it can be implemented using graphical objects.

[0106] In the specific implementation process, if the official document carries a non-public security classification identifier (i.e., the value of form_input.security_level is "Secret", "Confidential", or "Top Secret"), and the template requires the classification to be marked, this embodiment of the invention generates a security classification identifier box in the upper left corner of the header (i.e., the upper left side of the issuing authority's logo). This box is a rectangle with a black solid line border, inside which the security classification text and the confidentiality period (e.g., "Confidential ★ 5 years") are displayed in bold, size 15pt font, centered. The box is positioned 20mm from the top edge and 20mm from the left edge. If the official document is classified as "Internal" or "Public", this box is not added.

[0107] In specific implementation, this embodiment of the invention automatically adds a footer area at the bottom of the last page of the document (after the last line of text or signature), based on the fixed paragraph field definition in the structured document template. The footer may include, but is not limited to, the following parts: Copies to: Begins with "Copies to:", followed by a list of recipients (separated by commas or spaces). Use SimSun font, size 3, left-aligned, with a fixed line spacing of 28 points. If there are no recipients, omit this line.

[0108] Issuing Authority: Start a new line and write the name of the issuing authority (usually the office department of the issuing authority), for example, "XX Group Office".

[0109] Date of Issuance: Write the date of issuance at the top right of the line corresponding to the issuing authority, in the format "Issued on [Date]". The date should be the current system time.

[0110] Page citation separator: Add a thin black line (0.5pt wide) above and below the page citation area, the same width as the page.

[0111] All footer elements are placed at the bottom of the last page of the document, with a certain amount of space between them and the main text (achieved by setting the paragraph spacing).

[0112] In specific implementation, this embodiment of the invention also applies the page-level parameters specified in GB / T 9704 standard to set the page-wide parameters, for example: Paper size: A4 (210mm × 297mm), portrait orientation.

[0113] Margins: Top margin 37mm, bottom margin 35mm, left margin 28mm, right margin 26mm. The binding margin is set to left by default, with a width of 0.

[0114] Header and Footer: No header; footer content is page number, centered, font SimSun, size 12pt. The first page displays the page number, but does not show "Page 1 of X pages", it directly displays "1". The page number is 15mm from the bottom margin.

[0115] Line spacing: The line spacing is fixed at 28 points (approximately 9.3 mm) throughout the text, ensuring a fixed number of lines per page (usually 22 lines per page). There are no extra blank lines between paragraphs; they are separated naturally by line spacing alone.

[0116] Character spacing: Standard, no scaling.

[0117] After the above processing, this embodiment of the invention will encode the document content, which has complete format attributes, header, footer, security classification box, and global page settings, according to the OOXML (Office Open XML) standard, into a .docx format binary file stream, i.e., the formatted official document. This file can be directly opened by mainstream office software such as Microsoft Word and WPS, and the layout conforms to the standard.

[0118] S5: Use the compliance verification rule engine to verify the formatted official document, and output the final official document or generate modification prompts based on the verification results.

[0119] In one feasible implementation, the verification of the formatted official document using a compliance verification rule engine, as described in this embodiment of the invention, may include, but is not limited to: Based on the document type of the formatted document, a corresponding set of verification rules is selected from a preset rule base; the rule base includes at least structural integrity verification rules, format standardization verification rules, language compliance verification rules, logical consistency verification rules, and security and confidentiality verification rules. Execute the verification rules in the set of verification rules to identify violations in the formatted document; Based on the verification rule type to which the violation belongs, perform the corresponding processing operation on the violation, and output the processed document or generate a modification prompt.

[0120] In specific implementation, this embodiment of the invention dynamically selects a subset of verification rules applicable to the document type (doc_type) from a preset rule base based on the document type determined in S1. The rule base is stored in a structured manner, and each rule contains at least the following attributes: Rule identifier (rule_id); rule name; category (structural integrity, format standardization, language compliance, logical consistency, security and confidentiality); list of applicable document types (e.g., requests for instructions apply to R-S01, R-S02, etc.); triggering condition (e.g., docType="Request for Instructions"); validation logic (regular expression, word matching algorithm, semantic classifier, or numerical comparison function); whether it can be automatically corrected (Boolean value); correction method (if it can be automatically corrected, points to the corresponding correction function), etc.

[0121] In this embodiment of the invention, based on the doc_type of the current document, the rule base is traversed to filter out all rules in applicable_types that contain that type or the wildcard "*", thus forming the current verification rule set.

[0122] After obtaining the current verification rule set, this embodiment of the invention executes each rule in the current verification rule set sequentially to detect the document content and structure of the formatted official document and record all violations. The verification execution method can be divided into the following categories based on the rule logic type: Regular expression matching classes (such as date format, document number format): Compile regular expressions and match them in specified areas of the document (such as body text, signature). If a match fails, a violation is recorded.

[0123] For word list matching (such as spoken word detection and prohibited expressions): Build an Aho-Corasick automaton multi-pattern matcher, scan the entire document, and record the violation location and the matched word if a word in the word list is matched.

[0124] Semantic judgment type (such as consistency between request and title): Call a lightweight semantic model (such as a classifier fine-tuned by BERT) to calculate the semantic similarity between two texts, and judge it as a violation if it is lower than the threshold.

[0125] Numerical comparison type (such as data consistency): Extract numerical values ​​(such as amount, number of people, date) and their context from the main text, and compare them with the same indicator in the attachments or surrounding text. If the difference exceeds the preset tolerance, a violation is recorded.

[0126] Each violation record includes the following information: Violation identifier (violation_id); Rule ID (rule_id); Violation location (paragraph index, character offset); Description of violation content (e.g., "Missing the closing phrase 'Please approve'"); Suggested correction method (if the rule can be automatically corrected, include the parameters required for the correction function).

[0127] All violations are stored as a list called violations.

[0128] In a feasible embodiment, in the embodiment of the present invention, performing a corresponding processing operation on the violation item according to the type of the verification rule to which the violation item belongs may include, but is not limited to: For structural integrity violation items and / or security and confidentiality violation items, perform interception and generate a modification prompt; For format standardization violation items, wording compliance violation items and / or logical consistency violation items, perform automatic correction or generate a modification prompt.

[0129] In the specific implementation process, the embodiment of the present invention divides the violation items into two types of processing paths: The first category (mandatory interception): Rules that hit the rule category of "security and confidentiality" or "structural integrity" involving essential core elements (for example, a request document lacks closing wording, a public official document contains classified keywords). Such violation items are preset to be not automatically correctable, and once they occur, it means that the official document has a major defect, which must be modified by user intervention.

[0130] The second category (automatic correction or prompt): Hits the rule category of "format standardization", "wording compliance" or "logical consistency". Wherein: If the rule is marked as "correctable", the process proceeds to the automatic correction process; If the rule is marked as "uncorrectable", a modification prompt is generated for user reference.

[0131] In the specific implementation process, for the violation items that can be automatically corrected, the embodiment of the present invention may call a corresponding correction function to directly modify the formatted official document. For example: Format standardization correction: Number format correction: Replace "1、" with "1.", and correct "(一)" to "(一)" (full-width parentheses).

[0132] Date format standardization: Convert "2025-6-9" to "June 9, 2025".

[0133] Line spacing and font correction: Set paragraph attributes through Document Object Model APIs (such as python-docx).

[0134] Wording compliance correction: Spoken word replacement: Replace "did" with "carried out", and replace "do" with "conduct".

[0135] Deletion or replacement of prohibited expressions: Replace "approximately" with "about", and delete redundant uncertain words such as "maybe" and "possible".

[0136] Logical consistency correction: Numerical consistency: The "2 million yuan" appearing in the main text and the "2 million yuan" in the appendix should be consistent with "2 million yuan"; Date alignment: If the text says "last year" but the date of the document is 2025, it will be automatically replaced with "2024".

[0137] After each correction, the document content is updated, and the violation record is marked "corrected" along with the corrected value. For the same document, there may be multiple similar violations; the correction operation will iterate through all matching locations.

[0138] In the specific implementation process, for violations that cannot be automatically corrected (such as inappropriate tone without a standard replacement, or logical contradictions requiring manual judgment), this embodiment of the invention can generate a user-readable modification prompt for each violation, for example: The location of the violation (e.g., "second paragraph, third line"); the original content (e.g., "the relevant funding gap is relatively large"); the suggested direction of modification (e.g., "please specify the specific amount of the gap or change it to 'insufficient funding guarantee'").

[0139] All prompts are aggregated into a structured message, which can be displayed in a list format in the user interface and allows users to click to locate the corresponding position in the document.

[0140] In the specific implementation process, this embodiment of the invention outputs one of the following two results based on the result of the classification and processing of violations: If a Category 1 (intercepted) violation exists: the system will not output the official document, but will return an error report containing a detailed list of all intercepted violations and mandatory modification requirements. The user must modify the violation according to the prompts and then re-initiate the generation request (either by returning to S1 or directly editing the current document). At this time, the output of S5 will be the modification requirements.

[0141] If no Category I violations exist, the system will output the document after automatic correction. However, if any Category II violations exist that cannot be automatically corrected, the system will output an additional list of suggested modifications, but the document itself will still be allowed to be output (because it does not involve security or structural integrity). Users can ignore the prompts and use the document directly, or they can manually optimize it according to the prompts.

[0142] In specific implementation, the output format of this invention embodiment can adopt one of the following: If a user makes an API call, the returned JSON object contains status ("success" or "blocked"), document_url (the corrected document link), and suggestions (an array of modification suggestions).

[0143] If the user operates through the interactive interface, the revised document preview is displayed directly on the interface, and modification prompts are listed in the sidebar.

[0144] In specific implementation, embodiments of the present invention can also employ a multi-check and retry mechanism. For example, it can be configured to perform a second round of check on the automatically corrected document to confirm whether the correction has eliminated the violations. If there are still violations that can be automatically corrected in the second round of check, the correction is performed again, and the number of corrections is recorded. When the number of corrections reaches a preset threshold (e.g., 3 times), even if there are still violations that can be automatically corrected, the loop is terminated and the current version is output, while uncorrected violations are converted into modification prompts. Multi-round checks can ensure the robustness of the correction operation and avoid problems caused by incomplete correction in one attempt.

[0145] Through the above steps, this invention achieves a complete closed loop from rule matching, multi-dimensional verification, intelligent classification processing to final output, ensuring high compliance of the output documents in terms of format, language, logic and security, while minimizing manual intervention by users.

[0146] In one feasible implementation, the embodiments of the present invention may include, but are not limited to: Collect user modification data on the final official document and store it in the incremental dataset; The large language model is incrementally fine-tuned based on the incremental dataset at a preset period.

[0147] In the specific implementation process, after the final document is output, the user may further modify the document during the actual writing process (such as adjusting wording, supplementing data, correcting format details, etc.). This embodiment of the invention uses a document editor plugin or version comparison component to collect users' differentiated modification behaviors on the final document in real time. Specific collected content may include, but is not limited to, character-level modifications (inserting, deleting, replacing specific characters and their contextual positions), paragraph-level operations (adding, deleting, and rearranging paragraphs), and format adjustments (changing style attributes such as font, font size, color, alignment, and line spacing). During collection, metadata including user identifier, modification timestamp, original content fragment before modification, target content fragment after modification, and modification type (add / delete / modify / move) is recorded. All collected data is stored in an incremental dataset in the form of a structured log, which is physically isolated from the original training sample set but logically isomorphic.

[0148] In the specific implementation process, to prevent privacy leaks and training bias, the embodiments of the present invention can also perform anonymization processing on the collected modification behavior data: specific names, contact information, internal project codes, etc., are replaced with category placeholders (such as [PERSON], [PROJECT]). At the same time, for modifications involving sensitive information (such as changes in security classification), the system decides whether to include them in the training data according to the permission rules.

[0149] In specific implementation, embodiments of the present invention may, but are not limited to, organize the incremental dataset by time slices (e.g., by month or by quarter). Within each time slice, the collected modification behavior data is converted into the same instruction-input-output triplet format as the original fine-tuning stage. For modifications involving only format adjustments or local terminology optimization, embodiments of the present invention may construct comparative learning samples: using the difference segments before and after the modification as positive examples to strengthen the model's tendency towards specific improvements. In addition, embodiments of the present invention periodically conduct quality audits on the incremental dataset, removing samples that are too short (<100 characters), have minimal modification (edit distance <5%), or are obviously erroneous, ensuring that the number of newly added effective training samples each quarter remains between 5,000 and 10,000.

[0150] In specific implementation, embodiments of the present invention automatically trigger incremental fine-tuning tasks at a preset period (e.g., the 1st of the first month of each quarter). The fine-tuning process may include, but is not limited to, the following: The newly accumulated samples in the current incremental dataset are mixed with the original training sample set in a 7:3 ratio to form the training set for this fine-tuning. The mixing ratio can be dynamically adjusted according to the amount of data, but the weight of the original samples should not be less than 30% to prevent catastrophic forgetting.

[0151] The hyperparameters finely tuned by QLoRA above (learning rate 2e-4, batch size 32, training epochs 3) can be reused. However, the learning rate can be appropriately reduced to 1e-4 to stabilize old knowledge.

[0152] Load the 4-bit quantized weights of the previous model onto the training server and continue training on the low-rank adaptation matrix. During training, monitor the loss value and format compliance rate on the validation set, and employ an early stopping mechanism (stop if the loss does not decrease after two consecutive validation rounds).

[0153] After training is complete, the new LoRA adapter weights are merged with the base model (or kept separate to reduce storage overhead) to generate a new version of the model, and a version number is assigned (e.g., v2.0.0). At the same time, all weights and configuration files of the previous version (e.g., v1.9.9) are retained.

[0154] In specific implementation, after the new model training is completed, the embodiments of the present invention can adopt A / B testing or canary release strategies: Deploy the new model to a small number of nodes (e.g., 10% of the traffic) and run it in parallel with the old model.

[0155] For requests that hit the new model, record performance metrics such as user modification rate, format compliance pass rate, and user feedback rating of the generated documents.

[0156] When the new model has been running on the test node for 7 days and all performance indicators are no worse than the old model, the traffic ratio of the new model will be gradually increased to 100%.

[0157] In one feasible implementation, the incremental fine-tuning of the large language model based on the incremental dataset in this embodiment of the invention may, but is not limited to, include: Retain historical model versions; If the performance metrics of the current version of the model deteriorate by more than a preset deterioration threshold compared to the previous version, the model will revert to the previous version.

[0158] In the specific implementation process, if the new model experiences performance degradation after deployment, this embodiment of the invention will automatically trigger a rollback. The degradation judgment criteria may include, but are not limited to: Increased revision rate: The average percentage of characters modified by users in generated documents increased by more than 10% compared to the previous version; The compliance pass rate has decreased: the proportion of documents without intercepted violations in step 105 has decreased by more than 5% compared to the previous version; User rating decline: The average score of user-initiated ratings (1-5 points) decreased by more than 0.5 points.

[0159] In this embodiment of the invention, the performance degradation of the current version of the model relative to the previous version is calculated periodically (e.g., hourly). The degradation is defined as: ; Where P can be the modification rate (a negative indicator, rising is negative) or the compliance pass rate (a positive indicator, falling is negative). If the absolute value of the decline in either indicator exceeds the preset threshold (such as -10% or -5%), it is determined that the decline has exceeded the limit.

[0160] When a decline exceeds the limit, an automatic rollback operation is performed: Load the complete model weights from the previous version from the model repository; Switch all production traffic to the previous version; Record the current version as "unstable version" and generate an alarm log to notify maintenance personnel to analyze the cause.

[0161] In the specific implementation process, after the rollback is completed, the embodiments of the present invention may not delete the new version of the model file, but pause further incremental fine-tuning before the next preset cycle until manual intervention is required to resolve the degradation problem.

[0162] Through the aforementioned continuous optimization strategy, this invention can learn from users' actual modifications and gradually adapt to the personalized writing habits of different units and departments. For example, if a department frequently changes "carry out" to "implement," the system will tend to use "implement" after incremental fine-tuning; if the common closing phrase of a certain type of official document changes from "This is to notify you" to "This is to notify you specifically," the model will also adjust accordingly. Simultaneously, the automatic rollback mechanism ensures that the model will not suffer catastrophic obsolescence or performance crashes due to low-quality incremental data. This achieves automated management of the model's entire lifecycle, significantly improving its adaptability to different scenarios and its long-term operational reliability.

[0163] Based on the above-mentioned method for intelligent document generation and compliance verification provided in the first aspect, embodiments of the present invention provide a system for intelligent document generation and compliance verification, such as... Figure 3 As shown, the intelligent document generation and compliance verification system includes: The acquisition module 110 is used to acquire the core elements of the official document input by the user; The document template matching module 120 is used to retrieve a matching structured document template from the template library based on the core elements of the document. The structured document template includes at least a fixed paragraph field, a variable field slot, and a format constraint field. The document draft generation module 130 is used to generate a document draft based on the structured document template and the core elements of the document using a pre-trained large language model. The formatting processing module 140 is used to perform format standardization processing on the initial draft of the official document according to the format constraint field to obtain the formatted official document; The compliance verification module 150 is used to verify the formatted official document using a compliance verification rule engine, and output the final official document or generate modification prompts based on the verification results.

[0164] Based on the document intelligent generation and compliance verification method provided in the first aspect, this embodiment of the invention also provides a storage medium storing a computer-executable program. The computer-executable program is used to cause a computer to execute the document intelligent generation and compliance verification method as described in any implementation of the first aspect. Explanations of the relevant content and descriptions of the beneficial effects of any of the computer-readable storage media provided above can be found in the corresponding embodiments described above, and will not be repeated here.

[0165] Those skilled in the art will understand that the program for implementing all or part of the steps of the above embodiments, which can be executed by a program instructing related hardware, can be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a random access memory, etc. The processing unit or processor mentioned above can be a central processing unit, a general-purpose processor, an application-specific integrated circuit (ASIC), a microprocessor (DSP), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof.

[0166] This invention also provides a computer program product containing instructions that, when executed on a computer, cause the computer to perform any of the methods described in the above embodiments. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., SSD), etc.

[0167] It should be noted that the devices for storing computer instructions or computer programs provided in the embodiments of the present invention, such as, but not limited to, the aforementioned memory, computer-readable storage medium, and communication chip, are all non-transitory. Those skilled in the art should recognize that the functions described in the embodiments of the present invention in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable storage medium or transmitted as one or more instructions or code on a computer-readable storage medium. Computer-readable storage media include computer storage media and communication media, wherein communication media include any medium that facilitates the transmission of computer programs from one place to another. Storage media can be any available medium accessible to general-purpose or special-purpose computers.

[0168] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.< / w:border>

Claims

1. A method for intelligent generation and compliance verification of official documents, characterized in that, include: Obtain the core elements of the official document input by the user; Based on the core elements of the official document, a matching structured official document template is retrieved from the template library. The structured official document template includes at least a fixed paragraph field, a variable field slot, and a format constraint field. Based on the structured document template and the core elements of the document, a first draft of the document is generated using a pre-trained large language model; The initial draft of the official document is formatted according to the format constraint fields to obtain a formatted official document; The formatted official document is validated using a compliance verification rule engine, and the final official document is output or a modification prompt is generated based on the verification results.

2. The method for intelligent generation and compliance verification of official documents according to claim 1, characterized in that, The structured document template also includes basic information fields and compliance prerequisites; among which, The basic information field is used to store the template's metadata; The fixed paragraph field is used to store the fixed layout area of ​​the document template; The variable field slot is used to dynamically populate changed elements in official documents; The format constraint field is used to define the layout specification parameters of the official document template. The compliance prerequisites are used to record the compliance elements corresponding to the document type.

3. The method for intelligent generation and compliance verification of official documents according to claim 2, characterized in that, The step of generating a draft document using a pre-trained large language model based on the structured document template and the core elements of the document includes: Extract key information from the core elements of the official document, and construct structured prompt words by combining the structured document template and the compliance prerequisites. The structured prompts are input into a pre-trained large language model to obtain the initial draft text; The variable content in the initial draft text is filled into the variable field slot, and the preset field values ​​are automatically filled; The filled variable paragraphs are assembled sequentially with the fixed paragraphs in the fixed paragraph field to generate a complete draft of the official document.

4. The method for intelligent generation and compliance verification of official documents according to claim 1, characterized in that, The training process of the large language model includes: Obtain a training sample set consisting of official document texts; The large language model is fine-tuned using a composite loss function, which is a weighted sum of a language modeling loss term and a format compliance loss term. The format compliance loss item is determined based on the compliance score of the model-generated text by the rule engine. The compliance score covers at least four evaluation dimensions: structural integrity, format standardization, language compliance, and logical coherence.

5. The method for intelligent generation and compliance verification of official documents according to claim 4, characterized in that, The weight coefficient of the format compliance loss term in the composite loss function is dynamically adjusted based on the format compliance rate on the validation set.

6. The method for intelligent generation and compliance verification of official documents according to claim 1, characterized in that, The step of standardizing the format of the initial draft of the official document according to the format constraint fields includes: The initial draft of the official document was subjected to structured parsing to identify structural elements; Based on the typesetting specification parameters defined in the format constraint field, set corresponding format attributes for each structural element; Automatically add header elements, which include at least the issuing authority logo, document number, and separator line; If the document carries a non-public security classification mark, then a security classification mark box will be configured on the homepage; A footer should be placed at the bottom of the last page of the official document. The footer should include at least the recipients, the issuing authority, and the date of issuance.

7. The method for intelligent generation and compliance verification of official documents according to claim 1, characterized in that, The verification of the formatted official document using a compliance verification rule engine includes: Based on the document type of the formatted document, a corresponding set of verification rules is selected from a preset rule base; the rule base includes at least structural integrity verification rules, format standardization verification rules, language compliance verification rules, logical consistency verification rules, and security and confidentiality verification rules; Execute the verification rules in the set of verification rules to identify violations in the formatted document; Based on the verification rule type to which the violation belongs, perform the corresponding processing operation on the violation, and output the processed document or generate a modification prompt.

8. The method for intelligent generation and compliance verification of official documents according to claim 7, characterized in that, The step of performing corresponding processing operations on the violation item according to the verification rule type to which the violation item belongs includes: For violations of structural integrity and / or security and confidentiality, interception will be performed and modification prompts will be generated; For violations of formatting standards, language compliance, and / or logical consistency, automatic correction or modification prompts will be generated.

9. The method for intelligent generation and compliance verification of official documents according to claim 1, characterized in that, Also includes: Collect user modification data on the final official document and store it in the incremental dataset; The large language model is incrementally fine-tuned based on the incremental dataset at a preset period.

10. The method for intelligent generation and compliance verification of official documents according to claim 9, characterized in that, The incremental fine-tuning of the large language model based on the incremental dataset includes: Retain historical model versions; If the performance metrics of the current version of the model deteriorate by more than a preset deterioration threshold compared to the previous version, the model will revert to the previous version.