A Two-Stage Electronic Contract Element Extraction Method Based on a Large Model

By combining a large model with a two-stage approach of prompting engineering and semantic similarity calculation, the shortcomings of traditional methods in terms of flexibility, contextual understanding, and accuracy are addressed, achieving high efficiency and accuracy in the extraction of electronic contract elements.

CN120911437BActive Publication Date: 2026-03-13SICHUAN TUOTUO DI SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-02
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Traditional methods for extracting electronic contract elements based on keywords and rule bases lack flexibility, are difficult to adapt to contract texts of different formats and languages, cannot handle diverse expressions, and have insufficient contextual understanding capabilities, leading to erroneous or missed extraction of important information. They also have high maintenance costs and are susceptible to noise.

Method used

A large model is used in conjunction with prompting engineering for initial element extraction, and then the original paragraph is recalled for secondary verification through semantic similarity calculation. The semantic understanding capability of the large model is utilized and the hallucination problem is avoided through a two-stage mechanism, thereby improving flexibility and accuracy.

Benefits of technology

It greatly enhances the flexibility and accuracy of extracting electronic contract elements, reduces erroneous and missed extractions, integrates information when processing long paragraphs, ensures the reliability and accuracy of extraction results, and meets the efficient and precise extraction needs of modern electronic contract management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120911437B_ABST
    Figure CN120911437B_ABST
Patent Text Reader

Abstract

This invention relates to the field of information processing technology, specifically disclosing a two-stage electronic contract element extraction method based on a large model. The method includes: S1: Constructing a direct question-and-answer module, inputting the electronic contract file into the large model, and obtaining preliminary element extraction results and associated contextual text based on preset prompts; S2: Constructing a text segmentation and semantic retrieval module, using the text segmentation module to perform paragraph segmentation on the electronic contract text to generate a paragraph set, and using the semantic retrieval module to perform similarity scoring and sorting on the paragraph list based on associated contextual text to generate a candidate paragraph set; S3: Constructing a precise answer module, performing element type judgment and precise extraction based on the candidate paragraph set and preset secondary prompts, and outputting the final extraction result. By combining the large model with the prompts, preliminary element extraction is achieved, and then the original paragraphs are recalled through semantic similarity calculation for secondary verification, meeting the needs of modern electronic contract management for efficient and accurate element extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information processing technology, and specifically to a two-stage electronic contract element extraction method based on a large model. Background Technology

[0002] Electronic contract element extraction refers to the technology of automatically extracting key information (such as clause content, amount, date, subject information, etc.) from contract text. It can be applied to automated contract management, risk identification and compliance inspection, data analysis and decision support, and regulatory reporting. Traditional electronic contract element extraction technology is mainly based on keyword matching and rule base driving. Its typical implementation method is to predefine keywords and syntax rules related to elements and extract information from the text through pattern matching.

[0003] Traditional keyword- and rule-based methods for extracting electronic contract elements have several shortcomings. First, these methods lack flexibility, relying on predefined keywords and rules, making them ill-suited to contract texts in different formats and languages, and unable to handle diverse expressions. Furthermore, the rule base has limited coverage, potentially failing to encompass all possible elements or variations, leading to the omission of important information. Maintenance costs are also high; as contract formats and legal clauses change, the rule base needs constant updating, increasing complexity and cost. Regarding contextual understanding, keyword-based methods often fail to effectively grasp the text's context, resulting in incorrect or missed extraction of important information. For information in long paragraphs, keyword-based methods struggle to integrate interconnected content, demonstrating limited processing capabilities. This method is also susceptible to textual noise, such as spelling errors or irrelevant information, potentially leading to inaccurate extraction results. Therefore, keyword- and rule-based extraction methods are insufficient for the demands of modern contract element extraction.

[0004] This invention aims to propose a "two-stage electronic contract element extraction method": preliminary element extraction is achieved by combining a large model with prompting engineering, and then the original paragraphs are recalled for secondary verification through semantic similarity calculation. This method not only utilizes the semantic understanding capabilities of the large model to improve flexibility and accuracy, but also avoids the illusion problem through the two-stage mechanism, thereby breaking through the existing technical bottlenecks and meeting the needs of modern electronic contract management for efficient and accurate element extraction. Summary of the Invention

[0005] To overcome the aforementioned technical problems in the existing technology, this invention provides a two-stage electronic contract element extraction method based on a large model. The method achieves initial element extraction by combining a large model with prompting engineering, and then recalls the original paragraphs for secondary verification through semantic similarity calculation. This method not only utilizes the semantic understanding capabilities of the large model to improve flexibility and accuracy, but also avoids the illusion problem through the two-stage mechanism, thereby breaking through the bottleneck of the existing technology and meeting the needs of modern electronic contract management for efficient and accurate element extraction.

[0006] To achieve the above objectives, embodiments of the present invention provide a two-stage electronic contract element extraction method based on a large model, comprising the following steps:

[0007] S1: Construct a direct question-and-answer module, input the electronic contract document into the large model, and obtain preliminary extraction results of the elements according to the preset prompts. The preliminary extraction results include element values ​​and associated context text.

[0008] S2: Construct a text segmentation module and a semantic retrieval module. Use the text segmentation module to perform paragraph segmentation on the electronic contract text to generate a paragraph set. Use the semantic retrieval module to perform similarity scoring and sorting on the paragraph list based on the associated context text to generate a candidate paragraph set.

[0009] S3: Construct a precise answer module, which performs element type judgment and precise extraction based on the candidate paragraph set and preset secondary prompts, and outputs the final extraction result of the elements.

[0010] Preferably, the construction of the direct question-and-answer module in S1 specifically includes: the preset prompt engineering design structured prompt template, wherein the structured prompt template is: {"element": element value, "evidence": related context text}, where element is the initially extracted element value, and evidence is the related context text, which is the surrounding paragraph text containing the element value; the electronic contract file is input into the large model, the text generation module of the large model performs text parsing on the electronic contract file, and the question-and-answer extraction operation is performed based on the direct question-and-answer module to generate the extraction result in JSON format that conforms to the structured prompt template.

[0011] Preferably, S2 specifically includes: the text segmentation module performs segmentation operations on the electronic contract text based on punctuation marks, paragraph marks, and semantic coherence to obtain multiple paragraphs, and generates a paragraph set based on the multiple paragraphs, wherein the paragraph set is represented by formula (1), and formula (1) is:

[0012] Paragraph set = {paragraph_1, paragraph_2, ..., paragraph_N} (1)

[0013] Where paragraph_1 represents the first paragraph, paragraph_2 represents the second paragraph, and paragraph_N represents the Nth paragraph;

[0014] The semantic retrieval module is used to calculate the similarity score between each paragraph in the paragraph set and the associated context text, and a score set is generated.

[0015] The paragraphs in the paragraph set are sorted in descending order according to the score set to obtain a descending paragraph set; the top k paragraphs in the descending paragraph set are extracted to form the candidate paragraph set, which is represented by formula (2), and formula (2) is:

[0016] (2)

[0017] Where C represents the set of candidate paragraphs, and k is a positive integer constant.

[0018] Preferably, the semantic retrieval module is used to calculate the similarity score between each paragraph in the paragraph set and the associated context text. Specifically, this includes: first, performing a keyword matching and scoring operation, and then performing word segmentation and deduplication on both the associated context text and each paragraph in the paragraph set to obtain the corresponding associated text word list and paragraph word list. The associated text word list is represented by formula (3), which is:

[0019] (3)

[0020] The list of words in the paragraph is represented by formula (4), which is:

[0021] (4)

[0022] Where k and l represent the lengths of the word lists respectively; each word in the related text word list is matched cyclically with the paragraph word list, and the keyword matching score is calculated using formula (5), which is:

[0023] (5)

[0024] Wherein, KeywordScore represents the keyword matching score, and the keywords are entity nouns, numbers, and technical terms after the related context text is segmented; then, a pre-trained language model is used to perform semantic similarity scoring on the related context text and the paragraph set, and the semantic similarity score is calculated by formula (6), which is:

[0025] (6)

[0026] Wherein, RankScore represents the semantic similarity score; finally, the similarity score is calculated based on the keyword matching score and the semantic similarity score using formula (7), which is:

[0027] S(paragraph_i) = KeywordScore(paragraph_i) + RankScore(paragraph_i) (7)

[0028] Where S(paragraph_i) represents the similarity score, weight1+weight2=1, and weight1, weight2∈[0.2,0.8].

[0029] Preferably, a pre-trained language model is then used to perform semantic similarity scoring on the associated context text and the paragraph set. The semantic similarity score is calculated using formula (5), specifically including: performing text segmentation and sequence construction on each paragraph in the associated context text and the paragraph set to obtain the associated text token sequence and the paragraph token sequence, respectively. The associated text token sequence is represented as: E=[e1,e2,…,ek], and the paragraph token sequence is represented as: P=[p1,p2,…,pl]; merging the associated text token sequence and the paragraph token sequence, and adding a classification label at the beginning. <cls>Use a separator in the middle. <sep>Separate the tokens to obtain a merged sequence; input the merged sequence into a transformer network, which outputs a vector representation of each token in the merged sequence; the transformer network extracts the vector representation of each token through a self-attention mechanism. <cls>The labeled output vector serves as a semantic similarity vector. The semantic similarity vector is then mapped into a scalar score through a linear layer. The scalar score is the semantic similarity score.

[0030] Preferably, step S3 specifically includes: the preset secondary prompt engineering design secondary prompt template, wherein the secondary prompt template is: {"element": element value, "type": entity type / paragraph type, "index": reference candidate paragraph index}; taking the candidate paragraph set and user query elements as input to the large model, guiding the large model to generate JSON format output conforming to the secondary prompt template; determining the element extraction method based on the type field, and outputting the final extraction result: if type is entity type and is in the original paragraph text corresponding to the candidate paragraph index, then directly returning the element value as the final extraction result; if type is paragraph type, then returning the original text of the reference candidate paragraph index as the final extraction result.

[0031] Preferably, an element verification module is constructed, which performs the following steps: performing format verification on the extracted element values, the format including date format, amount format and ID card format; checking whether the element value is in the original text of the candidate paragraph; if the type field is neither entity type nor paragraph type, then triggering a manual review process or returning an extraction failure result.

[0032] Preferably, a model optimization module is constructed, which performs the following steps: collecting labeled contract sample data to construct a training dataset; fine-tuning the large model parameters based on a reinforcement learning framework, using extraction accuracy and recall as reward signals; and periodically updating the model weights to adapt to the language style and element distribution of different types of electronic contracts.

[0033] On the other hand, the present invention also provides a computer-readable storage medium having instructions stored thereon that, when executed on a computer, implement the method provided by the present invention.

[0034] The present invention has at least the following technical effects through the technical solution provided by the present invention:

[0035] By using a large-scale model to extract elements from electronic contract text, and through prompting engineering and semantic similarity calculation, flexibility is greatly enhanced. This is because the large-scale model can understand the diversity of natural language, adapt to different formats and expressions, and avoid the problem of limited rule base coverage. By extracting elements and their associated contextual text information, the large-scale model can better understand the context, thereby reducing false positives and false negatives. When processing long paragraphs, the large-scale model can integrate information within the paragraphs, providing more accurate answers to specific questions. Semantic similarity calculation can effectively extract relevant content, reducing the model's illusion problem and ensuring more reliable extraction results. Through secondary processing of the extracted content, the model can determine whether an element is an entity or a paragraph level, thus providing a more explicit answer, further improving the accuracy of information extraction and user experience. In summary, the two-stage electronic contract element extraction method based on a large-scale model provided by this invention solves the shortcomings of traditional rule-based methods in terms of flexibility, contextual understanding, information integration, and accuracy, making contract element extraction more efficient and accurate. Attached Figure Description

[0036] The accompanying drawings are provided to further illustrate embodiments of the present invention and form part of the specification. They are used together with the following detailed description to explain the embodiments of the present invention, but do not constitute a limitation thereof. In the drawings:

[0037] Figure 1 This is a flowchart of the two-stage electronic contract element extraction method based on a large model provided in this embodiment of the invention;

[0038] Figure 2 This is a network structure diagram of the converter network provided in an embodiment of the present invention. Detailed Implementation

[0039] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the scope of the present invention.

[0040] In this invention, the terms "system" and "network" are used interchangeably. "Multiple" refers to two or more; therefore, in this invention, "multiple" can also be understood as "at least two." "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / ", unless otherwise specified, generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, it should be understood that in the description of this invention, words such as "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or order.

[0041] Please see Figure 1 This invention provides a two-stage electronic contract element extraction method based on a large model, comprising the following steps:

[0042] S1: Construct a direct question-and-answer module, input the electronic contract document into the large model, and obtain the preliminary extraction results of the elements and related contextual text according to the preset prompts;

[0043] S2: Construct a text segmentation module and a semantic retrieval module. Use the text segmentation module to perform paragraph segmentation on the electronic contract text to generate a paragraph set. Use the semantic retrieval module to perform similarity scoring and sorting on the paragraph list based on the associated context text to generate a candidate paragraph set.

[0044] S3: Construct a precise answer module, which performs element type judgment and precise extraction based on the candidate paragraph set and preset secondary prompts, and outputs the final extraction result of the elements.

[0045] In this embodiment of the invention, for step S1, a large-scale language model (hereinafter referred to as LLM) is used. LLM's text understanding and generation capabilities are utilized to achieve preliminary extraction of contract elements and associated contextual text. The original electronic contract document is then completely parsed to obtain the plain text content of the original electronic contract document, while preserving paragraph structure and punctuation. This plain text content is represented by "context". A prompting project is constructed to enable LLM to simultaneously return the answer and its associated contextual text. A structured prompt template is designed to guide LLM to simultaneously return the element value, i.e., the associated contextual text. The structured prompt template uses JSON format: {"element": "Contract Term" element value, "evidence": associated contextual text}. <prompt>For example, building a prompting project. <prompt>You are a document parser. Extract the "Contract Term" element from the contract based on the context content and return the associated context text for this element. Output the result in JSON format: {"element": the value of the "Contract Term" element, "evidence": the associated context text of the contract term}. <prompt>Context: [Plain text content of the contract]; Input the context and structured prompt template into the large model to obtain the initial extraction structure {element, evidence}, where element is the extracted element value and evidence is the contextual text associated with the element value, i.e., the surrounding paragraph text containing the element value; By returning the element and its surrounding text, users can better understand the specific location and meaning of the extracted results in the contract, which is particularly important for the analysis and review of legal texts; In addition, this method can also reduce the model's error when understanding complex text and improve the overall accuracy of extraction; Ultimately, the goal is to improve the efficiency and quality of contract processing, enabling users to be more confident in their review and decision-making, and ensuring legal compliance.

[0046] In this embodiment of the invention, for step S2, a text segmentation module and a semantic retrieval module are constructed. First, the text segmentation module is used to perform segmentation operations on the electronic contract text based on punctuation marks, paragraph marks, and semantic coherence, so as to obtain multiple paragraphs corresponding to the electronic contract text. A paragraph set is generated based on the multiple paragraphs, and the paragraph set is represented by formula (1). Formula (1) is:

[0047] Paragraph set = {paragraph_1, paragraph_2, ..., paragraph_N} (1)

[0048] In this context, paragraph_1 represents the first paragraph, paragraph_2 represents the second paragraph, and paragraph_N represents the Nth paragraph.

[0049] Next, the semantic retrieval module is used to calculate the similarity score between each paragraph in the paragraph set and the associated context text to generate a score set; specifically, firstly, keyword matching and scoring is performed, and word segmentation and deduplication are performed on each paragraph in the associated context text and paragraph set to obtain the corresponding associated text word list and paragraph word list. The associated text word list can be represented by formula (3), which is as follows:

[0050] (3);

[0051] The list of words in a paragraph can be represented by formula (4), which is as follows:

[0052] (4);

[0053] Where k and l represent the lengths of the word lists respectively; each word in the related text word list is matched with the paragraph word list in a loop, and the keyword similarity score is calculated using formula (5), which is as follows:

[0054] (5)

[0055] Here, KeywordScore represents the keyword matching score. Keywords are entity nouns, numbers, and technical terms in the associated context text. The keyword scoring logic is as follows: the initial score is Score=0. Each word in E is checked in a loop to see if it appears in each paragraph in P. If it does, the score is updated to Score1=Score+1. The final keyword score is Score / max(k,l). This keyword similarity score is used to measure the similarity between the literal associated context text and the set of paragraphs.

[0056] For further details, please see Figure 2 The process involves using a pre-trained language model to perform semantic similarity scoring on the associated context text and paragraph sets. Specifically, a Transformer network is used to calculate semantic similarity. The associated context text and paragraph sets are then segmented and sequenced to obtain associated text token sequences and paragraph token sequences, respectively. The associated text token sequence is represented as E=[e1,e2,…,ek], and the paragraph token sequence is represented as P=[p1,p2,…,pl]. The associated text token sequences and paragraph token sequences are then merged, and a classification label is added at the beginning. <cls>And use a separator in the middle. <sep>Separate the tokens to obtain the merged sequence, which can be represented as [CLS, E, SEP, P]. Input this merged sequence into the transformer network, and the transformer network outputs the vector representation of each token in the merged sequence. Extract the vector representation of each token through a self-attention mechanism. <cls>The labeled output vector serves as the semantic similarity vector, which is then mapped into a scalar score through a linear layer. This scalar score is the semantic relevance score, calculated using formula (6). Formula (6) is as follows:

[0057] (6)

[0058] Here, RankScore represents the semantic similarity score; this score captures the deep semantic connections between texts and serves as a score to measure the similarity between evidence and each paragraph in the paragraph set. The higher the score, the more similar the two paragraphs are.

[0059] Furthermore, after obtaining the keyword similarity score and semantic similarity score, the resemblance score is calculated using formula (7), which is:

[0060] S(paragraph_i) = KeywordScore(paragraph_i) + RankScore(paragraph_i) (7)

[0061] Where S(paragraph_i) represents the similarity score, weight1+weight2=1, and weight1, weight2∈[0.2,0.8], that is, weight1 and weight2 both take the range of [0.2,0.8], by weighted balancing of literal matching and semantic understanding; finally, the final list of similarity scores between each paragraph and evidence is obtained, and a score set is generated, which can be represented as: [s_1,s_2,s_3,…,s_N]. Then, according to the score set, the paragraphs in the paragraph set are sorted in descending order of score from high to low, thus obtaining a descending paragraph set. The top k paragraphs in the descending paragraph set are extracted to form a candidate paragraph set, which is represented by formula (2), which is:

[0062] (2)

[0063] Where C represents the candidate paragraph set, and k is a positive integer constant. In this embodiment, k=3, that is, the top 3 paragraphs in the descending paragraph set are extracted to form the candidate paragraph set C.

[0064] In this embodiment of the invention, a precise answer module is constructed. This module performs secondary extraction based on a candidate paragraph set C and outputs the final result by determining the element type. Specifically, a secondary suggestion project is preset. This project designs a secondary suggestion template to guide the large model in determining the element type and reference paragraph index. The secondary suggestion template is: {"element": element value, "type": entity type / paragraph type, "index": reference candidate paragraph index id}, and the format is JSON. For example, a secondary suggestion project is constructed and input into the large model. <prompt>You are an element extraction robot. Based on the candidate paragraph set [c_1, c_2, c_3], please extract the element "Breach of Contract Liability", determine whether the element "Breach of Contract Liability" is an entity type element or a paragraph type element, and provide the final reference candidate paragraph index. Return the result in the following JSON format: {"element": "Breach of Contract Liability", "type": "Entity (Paragraph)", "index": id} <prompt>The core purpose of this precise answer module is to further determine the result of feature value extraction based on the candidate paragraph set C obtained from the text segmentation and semantic retrieval modules. To prevent the illusion problem that may occur when generating non-entity features, we ask the large model to directly output the paragraph ID, and then directly index the candidate paragraph set using the ID to obtain the unmodified paragraph content. This greatly avoids the illusion problem. The feature extraction method is determined based on the type field, and the final extraction result is output. The logic for determining the final extraction result is as follows:

[0065] (1) If the returned type is entity type and is in the original paragraph text corresponding to "index: reference candidate paragraph index id", then "element: element value" is the final extraction result;

[0066] (2) If the returned type is paragraph type, then the original text corresponding to "index: reference candidate paragraph index id" is the final extraction result;

[0067] (3) If the type is otherwise, return extraction failure.

[0068] In this embodiment of the invention, an element verification module is also constructed. This module performs the following steps: performing format verification on the extracted element values, including date format, amount format, and ID card format; checking whether the element values ​​exist in the original text of the candidate paragraphs to avoid LLM generating illusory content; if the verification fails, for example, if the type field is neither entity type nor paragraph type, then a manual review process is triggered or an extraction failure result is returned. Furthermore, a model optimization module is constructed. This module performs the following steps: collecting labeled contract sample data to construct a training dataset; fine-tuning the large model parameters based on a reinforcement learning framework, using extraction accuracy and recall as reward signals; and periodically updating the model weights to adapt to the language style and element distribution of different types of electronic contracts.

[0069] The present invention provides a two-stage electronic contract element extraction method for large models, which has the following beneficial effects in application:

[0070] Two-stage extraction mechanism: Through a closed-loop process of "initial extraction of large model - semantic retrieval verification - secondary confirmation of large model", semantic retrieval technology is introduced into the large model element extraction scenario for the first time, effectively reducing the illusion problem and improving the extraction accuracy.

[0071] Hybrid similarity calculation model: It integrates keyword matching and Transformer semantic calculation, taking into account both literal relevance and deep semantic understanding, solving the semantic discontinuity problem in traditional methods, and is more adaptable to scenarios such as synonymous expressions and contextual ambiguity;

[0072] Intelligent differentiation of element types: The design of a dual-track output mechanism of "entity type - paragraph type" directly returns the original paragraph for unstructured elements (such as complex clauses), avoiding information distortion caused by large model reconstruction and ensuring the rigor of legal texts;

[0073] Combining semantic understanding and verification: The semantic understanding capabilities of large models solve the flexibility problem of rule-based methods, while the semantic retrieval verification mechanism solves the illusion problem of large models, achieving complementary advantages;

[0074] Multi-dimensional similarity assessment: A hybrid model of keyword matching and semantic calculation ensures both rapid matching of explicit keywords and the ability to understand deep semantics, adapting to diverse contract texts;

[0075] Intelligent processing of element types: A differentiated processing mechanism that distinguishes between entity-type and paragraph-type elements, taking into account both extraction efficiency and legal rigor, and is especially suitable for legal scenarios with extremely high requirements for text accuracy;

[0076] Highly adaptable: No need to adjust the model separately for different industries and contract formats. It achieves efficient cross-domain applications through the generalization ability of the large model and the robustness of semantic retrieval.

[0077] Furthermore, embodiments of the present invention also provide a computer-readable storage medium storing instructions thereon, which, when executed on a computer, perform the two-stage electronic contract element extraction method based on a large model as described in the present invention.

[0078] The optional embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the embodiments of the present invention are not limited to the specific details in the above embodiments. Within the scope of the technical concept of the embodiments of the present invention, various simple modifications can be made to the technical solutions of the embodiments of the present invention, and these simple modifications all fall within the protection scope of the embodiments of the present invention.

[0079] It should also be noted that the various specific technical features described in the above embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, the embodiments of the present invention will not describe the various possible combinations separately.

[0080] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a microcontroller, chip, or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0081] Furthermore, various different implementations of the present invention can be combined arbitrarily, as long as they do not violate the spirit of the present invention, they should also be regarded as the content disclosed in the present invention.< / prompt> < / prompt> < / cls> < / sep> < / cls> < / prompt> < / prompt> < / prompt> < / cls> < / sep> < / cls>

Claims

1. A two-stage electronic contract element extraction method based on a large model, characterized in that, Includes the following steps: S1: Construct a direct question-and-answer module, input the electronic contract document into the large model, and obtain preliminary extraction results of the elements according to the preset prompts. The preliminary extraction results include element values ​​and associated context text. S2: Construct a text segmentation module and a semantic retrieval module. Use the text segmentation module to perform paragraph segmentation on the electronic contract text to generate a paragraph set. Use the semantic retrieval module to perform similarity scoring and sorting on the paragraph list based on the associated context text to generate a candidate paragraph set. S3: Construct a precise answer module, which performs element type judgment and precise extraction based on the candidate paragraph set and preset secondary prompts, and outputs the final extraction result of the elements, specifically including: The preset secondary prompt engineering design secondary prompt template is: {"element": element value, "type": entity type / paragraph type, "index": reference candidate paragraph index}; The candidate paragraph set and user query elements are used as input to the large model, guiding the large model to generate JSON format output that conforms to the secondary prompt template; The feature extraction method is determined based on the 'type' field, and the final extraction result is output: If the type is entity type and it is in the original paragraph text corresponding to the candidate paragraph index, the feature value is directly returned as the final extraction result. If the type is paragraph, the original text with reference to the candidate paragraph index is returned as the final extraction result.

2. The method for extracting elements of a two-stage electronic contract based on a large model according to claim 1, characterized in that, The construction of the direct question-answering module in S1 specifically includes: The preset prompt engineering design structured prompt template is: {"element": element value, "evidence": associated context text}, where element is the initially extracted element value, and evidence is the associated context text, which is the surrounding paragraph text containing the element value; The electronic contract document is input into the large model. The text generation module of the large model performs text parsing on the electronic contract document and performs question and answer extraction operation based on the direct question and answer module to generate JSON format extraction results that conform to the structured prompt template.

3. The method for extracting elements of a two-stage electronic contract based on a large model according to claim 1, characterized in that, S2 specifically includes: The text segmentation module performs segmentation operations on the electronic contract text based on punctuation marks, paragraph marks, and semantic coherence to obtain multiple paragraphs. A paragraph set is generated based on these multiple paragraphs, and the paragraph set is represented by formula (1), which is: Paragraph set = {paragraph_1, paragraph_2, ..., paragraph_N} (1) Where paragraph_1 represents the first paragraph, paragraph_2 represents the second paragraph, and paragraph_N represents the Nth paragraph; The semantic retrieval module is used to calculate the similarity score between each paragraph in the paragraph set and the associated context text, and a score set is generated. Based on the score set, the paragraphs in the paragraph set are sorted in descending order to obtain a descending paragraph set; The top k paragraphs are extracted from the descending paragraph set to form the candidate paragraph set. The candidate paragraph set is represented by formula (2), which is: (2) Where C represents the set of candidate paragraphs, and k is a positive integer constant.

4. The two-stage electronic contract element extraction method based on a large model according to claim 3, characterized in that, The semantic retrieval module is used to calculate a similarity score between each paragraph in the paragraph set and the associated context text, specifically including: First, keyword matching and scoring are performed. The associated context text and each paragraph in the paragraph set are then segmented and deduplicated to obtain the corresponding associated text word list and paragraph word list. The associated text word list is represented by formula (3), which is: (3) The list of words in the paragraph is represented by formula (4), which is: (4) Where k and l represent the lengths of the word lists, respectively; Each word in the related text word list is matched cyclically with the paragraph word list, and the keyword matching score is calculated using formula (5), which is: (5) Here, KeywordScore represents the keyword matching score, and the keywords are entity nouns, numbers, and technical terms after the related context text is segmented; Next, a pre-trained language model is used to perform semantic similarity scoring on the associated context text and the paragraph set. The semantic similarity score is calculated using formula (6), which is: (6) Wherein, RankScore represents the semantic similarity score, and the ranking and scoring module is constructed based on the pre-trained language model; Finally, the similarity score is calculated based on the keyword matching score and the semantic similarity score using formula (7), which is: S(paragraph_i) = KeywordScore(paragraph_i) + RankScore(paragraph_i) (7) Where S(paragraph_i) represents the similarity score, and paragraph_i represents a single paragraph. + =1, and , ∈[0.2,0.8].

5. The two-stage electronic contract element extraction method based on a large model according to claim 4, characterized in that, Next, a pre-trained language model is used to perform semantic similarity scoring on the associated context text and the paragraph set. The semantic similarity score is calculated using formula (6), specifically including: Based on the sorting and scoring module, text segmentation and sequence construction are performed on the associated context text and each paragraph in the paragraph set to obtain the associated text token sequence and the paragraph token sequence, respectively. The associated text token sequence is represented as: E=[e1,e2,…,ek], and the paragraph token sequence is represented as: P=[p1,p2,…,pl]; Merge the associated text token sequence with the paragraph token sequence, and add a category tag at the beginning. <cls>Use a separator in the middle. <sep> Separate them to obtain the merged sequence;< / sep> < / cls> The merged sequence is input into a transformer network, which outputs a vector representation of each token in the merged sequence. The converter network extracts through a self-attention mechanism. <cls> The labeled output vector serves as a semantic similarity vector. The semantic similarity vector is then mapped into a scalar score through a linear layer, and the scalar score is the semantic similarity score.< / cls> 6. The method for extracting elements of a two-stage electronic contract based on a large model according to claim 1, characterized in that, A feature verification module is constructed, which performs the following steps: The extracted element values ​​are formatted and validated, including date format, amount format, and ID card format. Check if the feature value is present in the original text of the candidate paragraph; If the type field is neither entity type nor paragraph type, a manual review process will be triggered or an extraction failure result will be returned.

7. The method for extracting elements of a two-stage electronic contract based on a large model according to claim 1, characterized in that, A model optimization module is constructed, and the model optimization module performs the following steps: Collect labeled contract sample data to construct a training dataset; Based on a reinforcement learning framework, extraction accuracy and recall are used as reward signals to fine-tune the parameters of the large model. The model weights are updated regularly to adapt to the language styles and element distributions of different types of electronic contracts.

Citation Information

Patent Citations

  • Informatization construction function point retrieval and comparison method based on large language model

    CN119719337A

  • Intelligent rule and regulation question answering method and device based on two-stage retrieval and large model

    CN119807346A