A format contract generation method and system based on a knowledge base and a contract template

By analyzing contract templates and user needs, and utilizing a knowledge base to generate standardized contracts, the problem of inconsistent contract formats generated from large models was solved. This enabled efficient and automated contract generation, ensuring the consistency and quality of contract formats.

CN122113879APending Publication Date: 2026-05-29MIMOUSE

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
MIMOUSE
Filing Date
2024-11-27
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing technologies, when generating contracts based on large models, the format compliance is poor, which fails to meet the user's need to use specific templates, resulting in low contract generation efficiency.

Method used

By acquiring user requirement text, user knowledge base, and contract template, analyzing the components and format of the template, retrieving related information from the knowledge base, generating prompt words, and submitting them to the large model to generate a formatted contract, the process involves a systematic processing of acquisition, analysis, retrieval, submission, and parsing modules.

Benefits of technology

It enables the rapid generation of contracts that meet the required format, improves work efficiency, reduces human error, and ensures the high quality and consistency of contracts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122113879A_ABST
    Figure CN122113879A_ABST
Patent Text Reader

Abstract

The application discloses a format contract generation method and system based on a knowledge base and a contract template, and relates to the technical field of format contract generation. The application aims to improve contract generation efficiency and solve the problem that users need to manually modify contract templates to meet specific contract requirements. The method comprises the following steps: obtaining user demand text, a user knowledge base and a contract template; analyzing the composition elements, format and blank position of the contract template to reconstruct a format template containing format information; retrieving associated information in the knowledge base based on the composition elements; combining the retrieved associated information, the format template and the demand text to form a prompt word, and submitting the prompt word to a large model; obtaining the text with format information returned by the large model, and analyzing and generating a contract with format. This process aims to constrain the large model output to meet the requirements of the contract template and generate a format contract carrying user knowledge. In this way, the efficiency and quality of contract generation can be effectively improved.
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 method and system for generating formatted contracts based on a knowledge base and contract templates. Background Technology

[0002] In an office environment, people frequently need to handle various contracts, such as employment contracts, procurement contracts, and technology research and development contracts. Typically, they first choose a suitable contract template and then modify it according to specific needs. For example, they might fill in the content of a sales contract template to create a sales contract for a specific product, or fill in the information of the parties involved, the research and development details, and the delivery content based on a technology research and development contract template. These operations are all based on the user's immediate needs and relevant information. However, manually modifying templates is inefficient.

[0003] Currently, there are some methods on the market for generating documents based on large models and user needs. For example, the invention patent application number 202410613264.8, "A Method and System for Generating Legal Documents Based on Large Models and Vector Retrieval," proposes a method for automatically generating customized legal contract documents based on user needs and legal contract knowledge in a vector database. However, the content format generated by these methods using large models is uncontrolled; even if the user provides a template as input, the large model's adherence to the template's format is poor. In practical applications, this cannot address the user's need to write contracts using a specific template.

[0004] Therefore, how to provide an efficient and automated method for generating standardized contracts has become an urgent problem to be solved. Summary of the Invention

[0005] The purpose of this invention is to solve the above-mentioned problems by proposing a method and system for generating formatted contracts based on a knowledge base and contract templates.

[0006] To achieve the above objectives, the present invention adopts the following technical solution:

[0007] A method for generating formatted contracts based on a knowledge base and contract templates, comprising:

[0008] Obtain user requirement texts, user knowledge bases, and contract templates;

[0009] Analyze the components, format, and blank spaces of the contract template to reconstruct a format template containing format information;

[0010] Retrieve related information from the knowledge base based on the constituent elements;

[0011] Combine related information, format templates, and requirement text to form prompt words, and submit them to the large model;

[0012] Obtain the formatted text returned by the large model, parse it, and generate a formatted contract.

[0013] In some implementations, the user knowledge base is generated and updated based on user-uploaded information, and includes: user name, contact information, address, email, work unit, legal representative of the unit, and unit invoicing information.

[0014] In some implementations, the analysis of the contract template's components, format, and blank spaces to reconstruct a format template containing format information includes:

[0015] Convert the contract template content into a string, add the requirement to extract all the components of the contract from the text, submit it to the generative big model, and obtain the components of the contract template returned by the big model.

[0016] Read the XML file in the contract template to obtain the format information of the contract template content;

[0017] Parse the blank and underlined areas in the contract template content and set them to blank.

[0018] Add format information identifiers and blank information identifiers to the contract template content to form a format template.

[0019] In some implementations, retrieving related information from the knowledge base based on constituent elements includes:

[0020] Each component element is set as the target text in turn, and multiple pieces of knowledge in the knowledge base are set as the text to be compared.

[0021] Feature extraction is performed on the target text and each text to be compared, generating corresponding feature vectors;

[0022] The reranker model is used to calculate the similarity score between the target text and each text to be compared.

[0023] Multiple texts to be compared are sorted according to their similarity scores, and the text with the highest similarity score is set as the similar text.

[0024] The highest similarity score is compared with a threshold; the threshold is set to 0.85.

[0025] If the highest similarity score is greater than the threshold, then the similar text is set as the associated information of the target text.

[0026] In some implementations, the combination of associated information, format templates, and requirement text to form prompt words includes...

[0027] The prompt should include relevant information, format template, and requirement text;

[0028] The prompt requires filling in the blank spaces of the format template based on the associated information and the required text;

[0029] The prompt requires you to enrich the content of the format template based on the associated information and the required text.

[0030] Furthermore, this invention also proposes a formatted contract generation system based on a knowledge base and contract templates, including an acquisition module, an analysis module, a retrieval module, a submission module, and a parsing module:

[0031] The acquisition module is used to acquire user requirement text, user knowledge base, and contract template;

[0032] The analysis module is used to analyze the components, format, and blank spaces of the contract template and reconstruct a format template containing format information.

[0033] The retrieval module is used to retrieve related information from the knowledge base based on the constituent elements;

[0034] The submission module is used to combine related information, format templates, and requirement text to form prompt words, which are then submitted to the large model.

[0035] The parsing module is used to obtain the formatted text returned by the large model and parse it to generate a formatted contract.

[0036] Compared with the prior art, the present invention includes at least one of the following beneficial technical effects:

[0037] 1. This invention provides a method for generating standardized contracts based on a knowledge base and contract templates, allowing users to quickly obtain standardized contracts that meet their needs. This method reduces the time spent manually editing templates, making contract generation more efficient and faster. Users only need to provide the required text and relevant fixed information, and the system can automatically retrieve relevant information and generate a contract that meets the format requirements. This automated process significantly improves work efficiency, allowing users to focus more on other core tasks.

[0038] 2. This invention utilizes a large model combined with a knowledge base and contract templates to effectively constrain the output of the large model, ensuring that the generated content not only meets the format template requirements but also carries relevant fixed information from the user. This method guarantees high-quality and consistent generated contracts, avoiding problems such as formatting errors or information omissions caused by human error. Furthermore, this invention supports contract template replacement. Users simply upload the contract to be replaced to the knowledge base through the user interface, and then select the desired contract template to complete the replacement. This significantly saves replacement time and improves user efficiency. Attached Figure Description

[0039] Figure 1 This is a schematic diagram illustrating a method for generating formatted contracts based on a knowledge base and contract template, as proposed in an embodiment of this application.

[0040] Figure 2 A flowchart illustrating a method for generating formatted contracts based on a knowledge base and contract templates, as proposed in an embodiment of this application;

[0041] Figure 3 This is a schematic diagram of a knowledge base proposed in an embodiment of this application;

[0042] Figure 4 This is a schematic diagram of a contract template proposed in an embodiment of this application;

[0043] Figure 5 This is a schematic diagram of a format template proposed in an embodiment of this application;

[0044] Figure 6 This is a schematic diagram of a prompt word proposed in an embodiment of this application. Detailed Implementation

[0045] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0046] A schematic diagram of a method for generating formatted contracts based on a knowledge base and contract template according to an embodiment of this application is shown below. Figure 1 As shown, it includes:

[0047] Obtain user requirement texts, user knowledge bases, and contract templates;

[0048] Analyze the components, format, and blank spaces of the contract template to reconstruct a format template containing format information;

[0049] Retrieve related information from the knowledge base based on the constituent elements;

[0050] Combine related information, format templates, and requirement text to form prompt words, and submit them to the large model;

[0051] Obtain the formatted text returned by the large model, parse it, and generate a formatted contract.

[0052] A flowchart of a method for generating formatted contracts based on a knowledge base and contract template according to an embodiment of this application is shown below. Figure 1As shown, in a specific embodiment of the present invention, the system receives user requirement text, user knowledge base, and user-specified contract template; wherein, the user knowledge base is generated and updated based on user-uploaded materials. An example of the user requirement text is: "Please draft a software development technology contract for me. The contract is valid for two years. The partner is XX Technology Co., Ltd. The project name is 'Smart Logistics Platform,' the project budget is 2 million yuan, and the payment method is phased payment, with 30% paid in the first phase. The project acceptance standards must comply with relevant national industry standards, and both parties to the contract must assume confidentiality obligations."

[0053] like Figure 3 As shown, the user knowledge base can include user name, contact information, address, email, employer, legal representative, and invoicing information, as well as professional knowledge, product information, and partner information.

[0054] The contract template specified by the user can be a technology contract, an employment contract, or a sales contract, such as... Figure 4 The image shows an example of a technology contract. The contract template provides the basic style and terms of the contract, while key personalized information is left blank or underlined.

[0055] In some implementations, the components, format, and blank spaces of the contract template are analyzed to reconstruct a format template containing format information, including:

[0056] The contract template content is converted into a string, and the requirement to extract all the components of the contract from the text is merged into the prompt words. This is then submitted to the generative big model to obtain the components of the contract template returned by the big model. Specific components may include: Party A, Party B, cooperation period, cooperation matters, liability for breach of contract, ownership of intellectual property rights, dispute resolution, products, etc.

[0057] Unzip the contract template file, read the XML file in the contract template, and obtain the format information of the contract template content; the format information includes title, body text, font, font size, color, alignment, first line indentation, line spacing, paragraph spacing, etc.

[0058] Parse the blank and underlined areas in the contract template content and set them to blank.

[0059] Add format information markers and blank information markers to the contract template content to create a format template;

[0060] like Figure 5 The image shown is a partial example of a format template.

[0061] In some implementations, related information is retrieved from a knowledge base based on constituent elements, including:

[0062] Each component element is set as the target text in turn, and multiple pieces of knowledge in the knowledge base are set as the text to be compared.

[0063] Feature extraction is performed on the target text and each text to be compared, generating corresponding feature vectors;

[0064] The reranker model is used to calculate the similarity score between the target text and each text to be compared.

[0065] Multiple texts to be compared are sorted according to their similarity scores, and the text with the highest similarity score is set as the similar text.

[0066] The highest similarity score is compared with a threshold; the threshold is set to 0.85.

[0067] If the highest similarity score is greater than the threshold, then the similar text is set as the associated information of the target text;

[0068] If the highest similarity score is less than or equal to the threshold, then no information associated with the target text was found.

[0069] In some implementations, related information, format templates, and requirement text are combined to form prompt words, including

[0070] The prompt should include all relevant information, format templates, and requirements text;

[0071] The prompt requires filling in the blank spaces of the format template based on the associated information and the required text;

[0072] The prompt requires you to enrich the content of the format template based on related information and the required text;

[0073] like Figure 6 The image shown is a partial example of a prompt word.

[0074] Submit the generated complete prompt to the large model; obtain the formatted text returned by the large model, parse it to generate a formatted contract.

[0075] In some embodiments, when all associated information, format templates, and requirement text are specified in the prompt, the format template can be split into multiple paragraphs and submitted together with the associated information and requirement text to accommodate the limitations of large models on input and output tokens.

[0076] In other embodiments, users may want to replace the original contract content with a new contract template. Users can store the original contract in a knowledge base, and the system can retrieve related knowledge similar to the contract template from the knowledge base, thereby generating a new contract template from the original contract.

[0077] Furthermore, this invention also proposes a formatted contract generation system based on a knowledge base and contract templates, including an acquisition module, an analysis module, a retrieval module, a submission module, and a parsing module, wherein:

[0078] The acquisition module is used to acquire user requirement text, user knowledge base, and contract template;

[0079] The analysis module is used to analyze the components, format, and blank spaces of the contract template and reconstruct a format template containing format information.

[0080] The retrieval module is used to retrieve related information from the knowledge base based on the constituent elements;

[0081] The submission module is used to combine related information, format templates, and requirement text to form prompt words, which are then submitted to the large model.

[0082] The parsing module is used to obtain the formatted text returned by the large model and parse it to generate a formatted contract.

[0083] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for generating formatted contracts based on a knowledge base and contract templates, characterized in that, include: Obtain user requirement texts, user knowledge bases, and contract templates; Analyze the components, format, and blank spaces of the contract template to reconstruct a format template containing format information; Retrieve related information from the knowledge base based on the constituent elements; Combine related information, format templates, and requirement text to form prompt words, and submit them to the large model; Obtain the formatted text returned by the large model, parse it, and generate a formatted contract.

2. The method for generating formatted contracts based on a knowledge base and contract templates according to claim 1, characterized in that, The user knowledge base is generated and updated based on user-uploaded information. The user knowledge base includes: user name, contact information, address, email, work unit, legal representative of the unit, and unit invoicing information.

3. The method for generating formatted contracts based on a knowledge base and contract templates according to claim 1, characterized in that, The analysis of the contract template's components, format, and blank spaces reconstructs a format template containing format information, including: Convert the contract template content into a string, add the requirement to extract all the components of the contract from the text, submit it to the generative big model, and obtain the components of the contract template returned by the big model. Read the XML file in the contract template to obtain the format information of the contract template content; Parse the blank and underlined areas in the contract template content and set them to blank. Add format information identifiers and blank information identifiers to the contract template content to form a format template.

4. The method for generating a formatted contract based on a knowledge base and a contract template according to claim 1, characterized in that, The process of retrieving related information from the knowledge base based on constituent elements includes: Each component element is set as the target text in turn, and multiple pieces of knowledge in the knowledge base are set as the text to be compared. Feature extraction is performed on the target text and each text to be compared, generating corresponding feature vectors; The reranker model is used to calculate the similarity score between the target text and each text to be compared. Multiple texts to be compared are sorted according to their similarity scores, and the text with the highest similarity score is set as the similar text. The highest similarity score is compared with a threshold; the threshold is set to 0.

85. If the highest similarity score is greater than the threshold, then the similar text is set as the associated information of the target text.

5. The method for generating formatted contracts based on a knowledge base and contract templates according to claim 1, characterized in that, The process of combining related information, format templates, and requirement text to form prompt words includes... The prompt should include relevant information, format template, and requirement text; The prompt requires filling in the blank spaces of the format template based on the associated information and the required text; The prompt requires you to enrich the content of the format template based on the associated information and the required text.

6. A formatted contract generation system based on a knowledge base and contract templates, comprising an acquisition module, an analysis module, a retrieval module, a submission module, and a parsing module, characterized in that: The acquisition module is used to acquire user requirement text, user knowledge base and contract template; The analysis module is used to analyze the components, format, and blank spaces of the contract template and reconstruct a format template containing format information. The retrieval module is used to retrieve related information from the knowledge base based on the constituent elements; The submission module is used to combine related information, format templates and requirement text to form prompt words and submit them to the large model; The parsing module is used to obtain the formatted text returned by the large model and parse it to generate a formatted contract.