Engineering contract flow chart extraction method and system, computer equipment and storage medium
By applying the flowchart extraction method in the engineering contract and using large language models and knowledge enhancement technology, the problem of low level of flowchart extraction automation in the engineering contract is solved, efficient and accurate flowchart extraction is achieved, and the efficiency of contract management is improved and precision.
Patent Information
- Application Number
- CN202411406533.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-10-10
AI Technical Summary
The existing technology has a low level of flow chart extraction automation in engineering contracts, and it is impossible to effectively extract the flow chart of key events in complex engineering contracts, resulting in inefficient and low accuracy in contract review.
Using the engineering contract flowchart extraction method, the contract input by the user is preprocessed, the relationship between entity nodes and entity pairs is defined, and the large language model is used for extraction. Combined with sample annotation data and knowledge enhancement technology, the overall prompt word is constructed to improve the extraction result. accuracy and efficiency.
The automated engineering contract flowchart extraction is realized, replacing manual reading and extraction, which significantly improves the efficiency and accuracy of contract process management, reduces dependence on manual experts, and reduces errors and omissions.
Smart Images

Figure CN118939741A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of engineering contract review and knowledge extraction, and in particular to an engineering contract flow chart extraction method, system, computer equipment and storage medium. Background Art
[0002] Contracts, especially construction contracts, contain many complex and critical processes. Considering the long-term and complex nature of construction projects, the specifications of such contracts for core processes such as progress payment, project changes, claims and final settlement are much more detailed and complex than those of general sales contracts. Each process includes multiple key events. For example, the progress payment process includes the owner receiving the interim payment application, the owner notifying the contractor of the milestone achievement, the owner issuing the milestone completion certificate, and the owner paying the progress payment. The claim process includes the contractor issuing a claim notice after becoming aware of the claim event, the contractor drafting a claim report, the owner reviewing the claim report, the contractor reviewing the owner's decision, and the two parties entering into a dispute resolution process for claims that cannot be agreed upon. The dispute resolution process includes friendly negotiations between the two parties, the intervention of the dispute arbitration committee, and the initiation of arbitration. During the contract review stage, each important time node in these processes must be thoroughly and carefully checked to ensure that there are no unreasonable time requirements in the contract. However, the currently commonly used review method mainly relies on a large amount of manual labor, which is not only inefficient, but also extremely dependent on expert experience, and is prone to omissions or errors.
[0003] With the development of natural language processing technology, extracting information about events in flowcharts by automated means is an important part of intelligent contract review, presenting flowchart information in contracts in a more efficient and intuitive form. Existing technologies for extracting key event information from contract texts include: methods based on rule dictionaries, such as the Chinese invention patent with publication number CN111931479B, which discloses a method and device for extracting information based on a contract dispute judgment; based on machine learning methods, such as the Chinese invention patent with publication number CN115270777A, which discloses a method for extracting information from contract documents; based on deep learning methods, such as the Chinese invention patent with publication number CN115422938A, which discloses a system and method for automatically extracting entity information from construction contracts. Among them: the method based on rule dictionaries requires heavy rule design and maintenance, and it is difficult to migrate and generalize to new tasks and new fields; the method based on machine learning also has the problem of high labor cost of feature engineering. At present, the mainstream methods mostly use models that combine machine learning and deep learning to achieve knowledge extraction, but they still need a large amount of high-quality training data on specific tasks, which is a great challenge for both engineering contracts and general contracts.
[0004] In addition, the key event information extraction that can be achieved by existing technologies is mostly concentrated on extracting relatively simple contract elements or single node time using named entity technology, such as the Chinese invention patent with publication number CN115270777A, which proposes a method for extracting contract document information, and the extracted contract elements are single contract advance payment ratio and amount entity information. In recent years, some emerging technologies have also used large language models to fine-tune and prompt engineering to explore the relationship extraction scheme in the text, such as the Chinese invention patent with publication number CN114661913A, which discloses a method and device for entity relationship extraction based on a pre-trained language model. However, simply extracting a number of isolated triples "(entity, relationship, entity)" formed by the relationship between two entities is still not enough to reflect a large number of contextual logical chains in engineering contracts, such as the complex timeline in the contract, involving payment, certificate issuance, dispute resolution and other aspects. The existing technology is still relatively blank in realizing the flowchart extraction of key events in engineering contracts, and the key event process, as an important focus of contract negotiations, is of great significance to contract management, progress and cost management. Therefore, there is an urgent need for automated process mining methods to extract flow charts from complex engineering contract texts to assist contract experts and related personnel in the management and communication of complex process knowledge. Summary of the invention
[0005] In view of the low level of automation in flowchart extraction in engineering contracts and the inability of existing methods to complete the task, the present invention proposes a method and system for automatically extracting flowcharts of engineering contracts, which extracts flowcharts of key contract events from unstructured engineering contract texts and returns them to contract managers in a visual form.
[0006] The engineering contract flow chart extraction method disclosed in the present invention comprises the following steps: (1) Preprocessing the contract input by the user, slicing the full text of the contract to obtain a text segment set including a plurality of text segments; (2) Define entity nodes, construct entity pairs, and design prompt words for extracting the relationship between the entity pairs; (3) For each entity pair relationship to be extracted, the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair are used as indexes to match the entity pair in the sample annotation data set established based on the historical review clauses, and the contract clauses that meet the preset conditions are used as sample clauses. Based on the sample clauses, the text segment is matched in the text segment set to obtain the target text segment; (4) Constructing extraction cases based on the sample clauses, forming overall prompt words through the entity nodes, prompt words extracted from entity pair relationships, extraction cases, and target text segments, and inputting the overall prompt words into the large language model to obtain extraction results.
[0007] The present invention also provides a system established by using the engineering contract flow chart extraction method, comprising: A text preprocessing module is used to preprocess the contract input by the user and slice the full text of the contract to obtain a text segment set containing several text segments; A prompt word design module is used to design prompt words for entity pair relationship extraction, and to construct overall prompt words through entity nodes, prompt words for entity pair relationship extraction, extraction cases, and target text segments; The knowledge-enhanced text positioning module is used to match the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair in the sample annotation data set, and take the contract clauses that meet the preset conditions as sample clauses. Based on the sample clauses, the text segment is matched in the text segment set to obtain the target text segment; The knowledge-enhanced information extraction module is used to build extraction cases based on sample clauses.
[0008] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing the engineering contract flowchart extraction method described in any one of the above items.
[0009] The present invention also provides a storage medium, including a computer program / instruction, which, when executed by a processor, implements any of the above-mentioned methods for extracting engineering contract flowcharts.
[0010] Compared with the prior art, the engineering contract flow chart extraction method of the present invention has the following beneficial effects: (1) The engineering contract flow chart extraction method of the present invention combines the prompt words extracted from entity nodes and entity node relationships, extraction cases, and target text segments to form an overall prompt word input into a large language model to obtain an extraction result, thereby replacing the large amount of manpower costs of manual reading, extraction, and knowledge management in the contract review stage. At the same time, it also avoids excessive reliance on the experience of manual experts, and can greatly improve the efficiency and accuracy of contract process management.
[0011] (2) The engineering contract flowchart extraction method of the present invention uses the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair as indexes to match the contract clauses that meet the preset conditions from the sample annotation database as sample clauses, matches the text segment through the sample clauses to obtain the target text segment, constructs an extraction case based on the sample clauses in the sample annotation database, and splices the prompt words extracted from the entity nodes, entity pair relationships, extraction cases, and target text segments to form an overall prompt word input into the large language model to obtain the extraction result. Such knowledge enhancement technology can improve the accuracy of locating the target text segment through the knowledge of the vector database without training the model parameters, and input the knowledge of the extraction case into the large language model in the form of natural language, so that the large language model can use domain knowledge to output more accurate extraction results.
[0012] (3) In view of the complex task of flowchart generation that requires long context understanding, the present invention also provides a system established by using the engineering contract flowchart extraction method, which includes a text preprocessing module, a prompt word design module, a knowledge-enhanced text positioning module, a knowledge-enhanced information extraction module and a visualization module to reduce the "hallucination" problem of large language model output. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is an overall flow chart of the first embodiment of the method for extracting the engineering contract flow chart of the present invention; Figure 2 A rendered visualized flowchart of Embodiment 1 of the method for extracting a project contract flowchart of the present invention; Figure 3 The diagram is a schematic diagram of the overall architecture of the second embodiment of the system established by the method for extracting engineering contract flowcharts according to the present invention. DETAILED DESCRIPTION
[0014] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0015] Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments disclosed in the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.
[0016] Unless otherwise defined, all technical and scientific terms used in this application document have the same meaning as those commonly understood by those skilled in the art of the present application, and the terms used are only for the purpose of describing specific embodiments and are not intended to limit the present application. The term "or / and" as used herein includes any and all combinations of one or more of the related listed items.
[0017] In addition, the descriptions of "first", "second", etc. in this application document are only for descriptive purposes, and do not specifically refer to the order or sequence, nor are they used to limit the present invention. They are only used to distinguish components or operations described with the same technical terms, and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0018] Explanation of terms Entity node. The set of entity nodes is represented by E. An entity node in the set E is represented by e. mn In this embodiment, the time relationship extraction of the same process is taken as an example, so the number m is omitted. The entity node in this embodiment is represented by E={e1, e2, …, e n}. "Entity node" can also be referred to as "entity" for short.
[0019] An entity pair, denoted by entity_pair, is a tuple consisting of two entity nodes, where (e i , e j ) is an instance of entity_pair, and the entity pair relationship is extracted to form a triple (e i , r, e j ), refers to entity e i and e j The time relationship stipulated in the contract is r, and e i occurs before e j .
[0020] Contract text segment, using chunks= {chunk1, chunk2, …, chunk i , …, chunk k} means that the input contract is preprocessed to obtain k text segments, where chunk iRefers to the i-th text segment in the set of contract text segments.
[0021] The vector database collection, represented by collection, is a storage collection of data in the vector database. This embodiment is named after each vector collection, such as contract_collection represents the text segment vector set after preprocessing of the contract text; case_collection represents the sample annotated data vector set.
[0022] The prompt word, or task prompt word, is also represented by prompt. It is a piece of text or sentence used to guide the language model to generate output of a specific type, theme or format. It should be noted that the content outside the curly brackets "{}" in the prompt word is universal, while the content inside the curly brackets is the specific content that needs to be retrieved based on the input content. It is necessary to splice the universal content and the specific content to obtain the prompt word. The prompt word in this embodiment includes background description, task instructions, external knowledge and other parts. These prompt words responsible for different functions are combined to form a total prompt word.
[0023] Vector representation, also known as vector embedding, can be used to convert text into vector representation through a text vectorization model, which maps each word into a K-dimensional real vector through training. In practice, a trained vector model is usually used to convert text into vectors.
[0024] Embodiment 1 In order to better understand and illustrate the technical solution of the engineering contract process extraction method of this embodiment, this embodiment takes the pending contract as "new energy project contract" as an example to explain how to extract the flowchart of the "progress payment process". It should be noted that other processes in the pending contract "new energy project contract" can refer to the method of this embodiment to extract the corresponding flowchart, and the method of this embodiment can also extract the overall flowchart of all processes.
[0025] The engineering contract flow chart extraction method of this embodiment is as follows: Figure 1 As shown, it includes the following steps S1-S4. It should be noted that step S1 and step S2 are steps predefined by the pre-text preprocessing and extraction framework, respectively. There is no fixed order between S1 and S2, and they only need to be before step S3.
[0026] Step S1, pre-processing the contract input by the user, slicing the full text of the contract to obtain a text segment set including a plurality of text segments.
[0027] In this embodiment, the user inputs a contract to be processed (contract_text) as "New Energy Project Contract". In order to process this contract, it needs to be sliced into several text segments. This embodiment uses the text cutting tool provided by the langchain toolkit to complete the segmentation of the contract text. Specifically, the RecursiveCharacterTextSplitter() method is called from the langchain.text_splitter package to split the full text of the contract into several text segments. The following is a sample code for slicing the input contract into several text segments:
[0028] The text segmentation method needs to define the text segment character length (chunk_size) and the overlapping character length (chunk_overlap). In this embodiment, the character length parameter (chunk_size) of the contract text segment is set to 512 characters. In order to ensure the semantic coherence as much as possible, there is also a 30-character overlap (chunk_overlap) between each text segment. The customized slicing method of this embodiment is named text_splitter, and create_document under this method is called to return the text segment set obtained by slicing, using chunks = {chunk1, chunk2, …, chunk k} indicates that k in the text-side set indicates that the new contract text is divided into k text segments, where chunk i Represents the i-th text segment from the front to the back.
[0029] The contract text preprocessing technology is a common and mature technology in the field. In this embodiment, the text slicing adopts the existing technical solution. It should be noted that this embodiment can also preprocess the contract to be processed through the slicing tool provided by Llama_index (a toolkit for building a data framework).
[0030] Step S2, define entity nodes, construct entity pairs, and design prompt words for entity pair relationship extraction.
[0031] In this embodiment, in order to realize the flow chart extraction, it is necessary to first define the entity nodes in the process, and then design extraction prompt words for extracting the time relationship between two entity nodes.
[0032] Specifically, the following method is used to implement it: Step S21, defining entity nodes for the process that needs to be extracted from the flowchart.
[0033] Define the entity nodes that need to be extracted from the flowchart. For example, the process in this embodiment is the "progress payment process". This process is generally for the contractor to submit relevant materials to the owner for payment application. After receiving the interim payment application, the owner will review the materials and the actual progress of the project. If the owner believes that part of the work progress has not reached the payment milestone conditions, the owner will notify the contractor of the milestone achievement recognized by the owner and require the contractor to modify or supplement the materials. After the contractor has modified the payment application materials, the owner should issue a milestone completion certificate to confirm that the contractor has actually achieved the milestone conditions in this period and the amount to be paid in this period. The owner will then pay this part of the amount. Therefore, the entity nodes defined in the "progress payment process" include four key nodes: the owner receives the payment application, the owner receives the interim payment application (e1), the owner notifies the contractor of the milestone achievement (e2), the owner issues a milestone completion certificate (e3), and the owner pays the progress payment (e4). In this embodiment, the entity node set of this process is represented as E p ={e1, e2, e3, e4}, represents the payment process set E p The entity nodes include e1, e2, e3, and e4.
[0034] It should be noted that in a construction contract, there is usually an objective time relationship between entity nodes, which determines the order of entity nodes. For example, in the four entity nodes involved in this embodiment, the owner receives the interim payment application (e1), the owner notifies the contractor of the milestone achievement (e2), the owner issues the milestone completion certificate (e3), and the owner pays the progress payment (e4). The time order before and after is determined, which is e1, e2, e3, and e4. It should be further noted that different contracts stipulate the time relationship of these four entity nodes in different ways. Some contracts stipulate that the payment of progress payment is "e2 is completed within x days after e1, e3 is completed within y days of e2, and e4 is completed within z days of e3", while some contracts stipulate that "e3 is completed within x days after e1, and e4 is completed within y days of e3", that is, the time limit for e2 is omitted, and some contracts even simply stipulate that "e4 is completed within x days after e1" without stipulating the time limit for e2 and e3.
[0035] Step S22: construct entity pairs based on the entity nodes.
[0036] Any two entity nodes can form an entity pair. In this embodiment, the “Progress Payment Process” has 4 entity nodes, so the entity pairs that may have a time relationship are: That is: (e1, e2), (e1, e3), (e1, e4), (e2,e3), (e2, e4), (e3, e4).
[0037] Step S23: Based on the entity pairs, design entity pair relationship extraction prompt words.
[0038] Prompt words, or prompts in the large language model, are considered an important medium for people to interact with the large language model, telling the large language model that its task is entity recognition, what constraints it has, etc. In the large language model, prompt words are text input to the large language model to prompt or guide the large language model to give expected output. This input can be likened to a command or instruction, so that the large language model knows clearly what task it needs to complete. For example, in a conversation with a large language model, the text asking questions to the large language model is a prompt word, and after understanding the prompt word, the large language model will give a corresponding answer.
[0039] In this embodiment, in order to extract the flowchart of the "Progress Payment Process" in the user-input contract "New Energy Project Contract", based on the defined entity nodes, extraction prompt words are designed to extract the relationship between two entity nodes in the flowchart (referred to as entity pair relationship).
[0040] The purpose of this step is to design prompt words to extract the relationship between entity nodes in each entity pair in turn, so as to return the accurate time relationship or return "not mentioned". "Not mentioned" means that the time relationship between the two entities is not specified in the engineering contract.
[0041] In this embodiment, for the entity pair (e i , e j ) ij , the design prompts are as follows: Please tell me about the event in the contract j Need to be in event i How many days after that will it start? ij To represent the number of days, please use a triple (e i , r ij , e j ) to return your answer; If the corresponding relationship is not specified in the contract text, return "not mentioned"; {Contract text}.
[0042] The specific description of the prompt word is as follows: {Contract text} is used as the input object, and entity pairs are extracted from the input object. i and e j If there is a relationship, the triple (e i , r ij , e j ) in the form of entity pair relations; otherwise, output “not mentioned”.
[0043] In this embodiment, it is necessary to traverse the entity pairs (e1, e2), (e1, e3), (e1, e4), (e2, e3), (e2, e4), (e3, e4) and output the extraction results respectively. i , e j ), by converting entity pair relationship extraction into “event j Need to be in event i How many days after that will the process begin?" to complete entity pair relationship extraction in a more specific and flexible way.
[0044] Step S3, for each entity pair relationship to be extracted, the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair are used as indexes, and a match is performed in the sample annotation data set established based on the historical review clauses. The contract clauses that meet the preset conditions are used as sample clauses. Based on the sample clauses, the text segment is matched in the text segment set to obtain the target text segment.
[0045] It should be noted that the sample annotation dataset in this step is pre-collected historical review clauses. For each clause, its project type, clause category, and the entity pairs and entity pair relationships contained in the clause are annotated. Since contract clauses of the same project type, clause category, and similar entity pairs often have similar expressions, the collected historical clauses can largely represent the expression of a certain entity pair relationship in the contract. Therefore, matching the clauses of the contract to be processed with historical clauses is an efficient matching method, which can match the most similar clauses with a very small amount of data.
[0046] The sample annotation data set of this embodiment is stored in a vector database, which is specifically implemented by the following method: (1) Based on any entity pair in different processes, collect one or more historical review contract data corresponding to the entity pair, annotate the historical review clause data, establish a sample annotated data set, and store the sample annotated data set in a vector database. In this embodiment, based on any entity pair in different processes, collect one historical review contract data corresponding to the entity pair, so that the most similar clauses can be matched with a very small amount of data and without parameter training of the model, thereby improving the extraction efficiency. Each piece of data in the established sample annotated data set includes five labels: "contract clause", "project type", "clause category", "entity pair", and "entity pair relationship".
[0047] The project types in the sample annotation dataset established in this embodiment include "housing construction projects" and "new energy projects", etc., the clause types include "progress payment clauses", "claim clauses", etc., "entity pairs" are the annotations of entity pairs contained in the contract terms, and "entity pair relationships" are the annotations of the time relationships between the constraints of two entity nodes in the entity pairs in the contract terms. Some examples of the sample annotation dataset are shown in Table 1: Table 1 No. Contract Terms Project Type Category of clauses <![CDATA[Entity pair (e i , e j )]]> <![CDATA[Entity pair relationship (R ij )]]> 1 Upon completion of a Milestone in accordance with the Payment Schedule by the Contractor, (i) the Contractor shall submit a Payment Request and all necessary supporting documents and information (including purchase orders, delivery notes and signed copies of Milestone achievements) to the Company Representative for evaluation, review and approval; (ii) the Company Representative shall evaluate the completion of the Works based on the contents of the Payment Request, the Payment Schedule and the Work Content; and (iii) the Company Representative shall complete the evaluation within fifteen (15) days of receipt of the Payment Request. New energy projects Progress Payment Terms <![CDATA[(e1, e2)]]> In 15 days 2 No amount will be certified or paid until the Owner has received and approved the Performance Security. The Owner’s Representative shall then issue to the Owner and the Contractor an Interim Payment Certificate within 21 days of receipt of the Application for Payment or Progress Bill and related documentation, which shall state the amount payable as determined by the Owner’s Representative and provide supporting materials to justify the Owner’s Representative’s reduction or withholding of the amount payable. After the Owner’s Representative issues the Interim Payment Certificate, the Contractor shall be notified to submit the invoice. New energy projects Progress Payment Terms <![CDATA[(e1, e3)]]> In 21 days 3 [Particular Conditions] Sub-Clause 14.20 [Time of Payment] Delete sub-clause (b) of this Sub-Clause and replace it with the following: (b) Pay the amount certified in each Interim Payment Certificate within 30 days after the Contractor submits his invoice and payment application under Sub-Clause 14.6 [Interim Payment]. Housing construction projects Progress Payment Terms <![CDATA[(e1, e4)]]> Within 30 days 4 14.7.1 The Employer shall pay to the Contractor the following amounts: (a) in accordance with the advance payments set out in Schedule 14.4 [Payment Schedule and Cash Flow Statement], on the first draw after the Commencement Date, subject to receipt of the Advance Payment Security, Performance Security and Parent Guarantee and compliance with Sub-Clause 4.2 [Performance Security]; and (b) within 30 days of the issue of an Interim Payment Certificate by the Employer’s Representative to the Contractor, in accordance with the amount certified in an Interim Payment Certificate issued by the Employer’s Representative. Housing construction projects Progress Payment Terms <![CDATA[(e3, e4)]]> Within 30 days The labeled sample annotated data set is stored in the vector database. In this embodiment, tools such as Milvus and Elastic Search (both tools for storing and retrieving vector databases) can be used to create a collection in the vector database for storing the sample annotated data set.
[0048] This embodiment uses the Milvus tool and names the sample annotation data set as case_collection. Each piece of data includes five fields, namely, "contract terms", "project type", "term category", "entity pair" and "entity pair relationship".
[0049] (2) Establish a data index based on the annotated content in the sample annotation dataset.
[0050] In this embodiment, in the case_collection set of the vector database, the collection.create_index method provided in the Milvus tool is used to automatically construct a data index for the content annotated in the sample annotated data set. It should be noted that the vector database usually provides a method for automatically constructing an index to construct an efficient index structure for vector data in order to query the vector most similar to the target vector. This embodiment uses the HNSW algorithm of the Milvus database to construct an index, and other methods of alternative databases are also applicable.
[0051] Step S31, using the entity pairs of the project type of the contract input by the user, the type of flowchart clause to be extracted, and the relationship to be extracted as indexes, matching is performed in the sample annotation data set, and the contract clauses that meet the preset conditions are used as sample clauses.
[0052] In this embodiment, the tags used to match the sample clauses include: the "project type" of the contract input by the user, the "clause type" corresponding to the flowchart to be extracted, and the "entity pair" to be extracted.
[0053] In this embodiment, the preset conditions for matching are: when the "project type", "clause type" and "entity pair" are completely consistent with the contents of the "project type", "clause type" and "entity pair" annotated in the sample annotation data set, it means that the preset conditions are met, and the corresponding "contract clause" in the sample annotation data set is selected as the sample clause for recall.
[0054] In this example, the "project type" of the contract entered by the user is "new energy project", the "clause category" corresponding to the flowchart to be extracted is "progress payment clause", and the entity pairs to be extracted include all pairs of e1, e2, e3, and e4. Taking the relationship of "(e1, e2)" as an example, the process of matching from the sample annotation data set to obtain sample clauses is explained.
[0055] The specific matching process is as follows: When the Project Type is New Energy Project, the Terms Category is Payment Terms, and the Entity i ,e j )" is "(e1,e2)". The "Contract Clause" that meets the conditions can be matched from some of the data provided in Table 1: "After the Contractor completes the milestones specified in the payment schedule, (i) the Contractor shall submit a payment application and all relevant necessary supporting documents and information (including purchase orders, delivery notes and signed copies of milestone achievements) to the Company Representative for evaluation, review and approval; (ii) the Company Representative shall evaluate the completion of the project based on the contents of the payment application, the payment schedule and the work content; (iii) the Company Representative will complete the evaluation within fifteen (15) days of receipt of the payment application." The matched "Contract Clause" is used as a sample clause and named sample_clause.
[0056] Step S32: Based on the sample clause, the text segment is matched in the text segment set to obtain a target text segment.
[0057] The text matching methods include direct matching based on text characters, matching based on word vector sequences, and matching based on sentence vectors constructed by word vector sequences. This embodiment uses a matching method based on sentence vectors constructed by word vector sequences to match text segments.
[0058] Specifically, it is achieved through the following methods: Step S321, converting the sample terms matched in step S31 into sample terms represented by vectors.
[0059] The sample clause sample_clause matched in step S31 is converted into a vector representation, named sample_embedding. In this embodiment, the sample clause is converted into its corresponding vector representation by calling the text-embedding-ada-002 model.
[0060] It should be noted that the conversion can also be performed through models such as text2vec and m3e-base. Text-embedding-ada-002, text2vec, and m3e-base are all text embedding models that can convert text into vector representations.
[0061] Step S322, converting the text segments in the text segment set obtained by slicing in step S1 into text segments represented by vectors.
[0062] The specific implementation method is as follows: 1) Slice the text segments obtained in step S1 into a set of chunks = {chunk1, chunk2,…, chunk k} is converted into a vector representation, and the vector representation text segment set is named chunk_embedding. The text segment vector representation in this step can be converted in the same way as step S321.
[0063] 2) Use the Milvus tool to create a collection in the vector database and name it contract_collection, and store the text segments represented by the vectors in chunk_embedding in this collection.
[0064] Step S323, establishing a data index based on the vector representation of the text segment.
[0065] This embodiment uses the collection.create_index method provided by the Milvus tool to automatically construct and create a data index for the text segment represented by the vector in the contract_collection collection.
[0066] Step S324 , by vector similarity matching, recall the target text segment with the highest semantic similarity to the sample clause from the text segment set.
[0067] This embodiment is aimed at the entity pair (e i , e j ) retrieves the target text segment and names it In this embodiment, cosine similarity is used to measure the similarity of vectors. It should be noted that other similarity matching methods such as Euclidean distance and Jaccard similarity coefficient can also be used, as shown in Formula 1. Where s and c are two points in n-dimensional space, representing the sample clause sample_clause and the text segment set chunks. The position in the vector space. |s| and |c| represent sample_clause and Normalized value. represents sample_clause and The cosine angle between them is larger, and the larger the calculated value is, the higher the semantic similarity between the candidate paragraph and the sample clause is. The similarity value range is [-1,1].
[0068] In this example, the target paragraph of the entity pair (e1, e2) is retrieved. For example, the cosine similarity is used to calculate the cosine angle between all the vector-represented text segments in the contract_collection set and the sample terms (sample_embedding) represented by the vector corresponding to the entity pair (e1, e2). Based on the calculation results, the text segment represented by the vector with the largest cosine angle value is determined, and the corresponding text segment is recalled as the target text segment in the text segment set chunks and named .
[0069] (1)
[0070] Step S33, traverse all entity pairs, repeat steps S31-S32, and output the corresponding target text segment.
[0071] In this embodiment, it is also necessary to repeat steps S31-S32 to output the target text segments (e1, e3), (e1, e4), (e2, e3), (e2, e4), (e3, e4), and name them as , , , , This kind of knowledge enhancement technology can locate the target text segment through knowledge enhancement of the vector database in the case of zero or few samples, that is, without training the model parameters, and input the knowledge into the large model in the form of natural language to provide knowledge for extraction cases, so that the large language model can use domain knowledge to output more accurate extraction results.
[0072] Step S4, constructing extraction cases based on sample clauses, extracting prompt words through entity nodes, entity pair relationships, extraction cases and target text segments to form overall prompt words, and inputting the overall prompt words into the large language model to obtain extraction results.
[0073] Specifically, the following method is used to implement it: Step S41, traverse the entity pairs, and construct extraction cases of entity pair relationships based on corresponding sample terms retrieved from the sample annotation database.
[0074] In the prompt engineering of large language models, a case refers to a similar question example and the corresponding correct answer for a specific task or problem, so as to guide the large model to generate more accurate and targeted answers to new questions.
[0075] In this embodiment, each case is a set of sample clauses and corresponding triple labels. The following is an example given in the task of extracting the relationship between entity pairs (e1, e2): (sample_clause, (e1, R 12 , e2)).
[0076] Where sample_clause represents the sample clause corresponding to the entity pair (e1, e2) in the sample annotation dataset, (e1, R 12 , e2) indicates that this clause contains descriptions about entity nodes e1, e2 and time constraints, and the relationship between e1 and e2 entities is defined as R 12 It should be noted that the entity pair relationships in the sample annotation dataset provided in this embodiment are represented by capital letters “R ij " indicates that the entity pair relationships to be extracted are represented by lowercase "r ij "express.
[0077] In this embodiment, the constructed extraction case is as follows: “For example, in the contract clause {sample_clause}, there is an entity e i , e j And the relationship between entities is constrained to be {R ij}, then the extraction result ({e i}, {R ij}, {e j}).” The large language model provides a specific method for extracting cases, which is explained in the prompt words of step S421.
[0078] In this embodiment, it is also necessary to output corresponding extraction cases for (e1, e3), (e1, e4), and (e3, e4), respectively.
[0079] Step S42, forming an overall prompt word through entity nodes, prompt words extracted from entity pair relationships, extraction cases and target text segments, and inputting the overall prompt word into the large language model to obtain an extraction result.
[0080] Through the prompt word engineering, the large language model is guided to generate the expected relation extraction results. Specifically, the following methods are used to achieve this: Step S421, forming an overall prompt word by splicing entity nodes, prompt words extracted from entity pair relationships, extracted cases, and target text segments.
[0081] The overall prompt words constructed in this embodiment are as follows: “Mid-term payments under a contract usually include the following time points: p Now I will give you a contract text. Please tell me what the event {e j} Need to be in the event {e i How many days after} will it start? ij To represent the number of days, please use a triple (e i , r ij ,e j ) to return your answer; If the corresponding relationship is not specified in the contract text, return "not mentioned"; Contract text: {chunk ij}; For example, in the contract clause {sample_clause}, there is entity e i , e j And the relationship between entities is constrained to be {R ij}, then the extraction result ({e i}, {R ij}, {e j}).
[0082] General tips: (1) “Interim payments under a contract usually include the following time points: p}. "This part is the defined entity nodes, which tells the large language model which entity nodes are included in the mid-term payment process, so that the large language model has an overall understanding of the extraction task. The entity nodes Ep={e1, e2, e3, e4} defined in this embodiment include the owner receiving the mid-term payment application (e1), the owner notifying the contractor of the milestone achievement (e2), the owner issuing the milestone completion certificate (e3), and the owner paying the progress payment (e4).
[0083] (2) “Now I will give you a contract text. Please tell me what the event {e j} Need to be in the event {e i How many days after} will it start? ij To represent the number of days, please use a triple (e i , r ij , e j ) in the form of; if the corresponding relationship is not specified in the contract text, return "not mentioned"; Contract text: {chunk ij}. "This part is the extraction task description, which means that the user provides a contract to be processed, and the large language model needs to identify the temporal relationship of a given entity pair in the text. ij Refers to the target text segment returned by the text positioning module S34. ij Identify the temporal relationship constraints r on entity_pair ij , then the large language model needs to return a triple (e i , r ij , e j ); if no temporal relationship is identified, then "not mentioned" needs to be returned.
[0084] (3) “For example, in the contract clause {sample_clause}, there is an entity e i , e j And the relationship between entities is constrained to be {R ij}, then the extraction result ({e i},{R ij},{e j}) "This part is the extraction case, which means to extract entity pairs (e i ,e j ) specific task, giving the correct entity pair relationship R ij The extraction cases guide the large language model to understand the task more accurately and generate extraction results that meet the requirements and specifications.
[0085] Step S422: input the overall prompt word into the large language model to obtain the extraction result.
[0086] In this embodiment, the gpt-4-0613 large language model is used, and the large language model outputs the extraction results. The entity pairs in this embodiment include (e1, e2), (e1, e3), (e1, e4), (e2, e3), (e2, e4), (e3, e4), and it takes four inputs to extract the relationship between these entity pairs, and six responses from the large language model are obtained, and the extraction results (e1, r12 ,e2)、(e1,r 13 ,e3)、(e1,r 14 ,e4)、(e2,r 23 ,e3)、(e2,r 24 ,e4) and (e3,r 34 ,e4).
[0087] In this embodiment, the extraction results are shown in Table 2: Table 2 Entity Pair Time relationship <![CDATA[( e 1 , e 2 )]]> <![CDATA[r 12 = "Within 28 days"]]> <![CDATA[( e 1 , e 3 )]]> <![CDATA[r 13 = "Within 21 days"]]> <![CDATA[( e 1 , e 4 )]]> <![CDATA[r 14 = "Not mentioned"]]> <![CDATA[( e 2 , e 3 )]]> <![CDATA[r 23 = "Not mentioned"]]> <![CDATA[( e 2 , e 4 )]]> <![CDATA[r 24 = "Not mentioned"]]> <![CDATA[( e 3 , e 4 )]]> <![CDATA[r 34 = "Within 35 days"]]> So far, this embodiment has extracted the time relationship between the various entity nodes in the "Progress Payment Process" flowchart of the engineering contract. In order to provide a more convenient browsing for users, this embodiment further proposes a step of converting the above-extracted entity pair relationship into a visual contract flowchart. This step S5 is a continuation and deepening of the technical solution of this embodiment. Based on the extraction results, a visual flowchart is constructed. Specifically, the following method is used to achieve: Step S51, designing a task prompt word that converts the extraction result into a graphical programming language.
[0088] In this embodiment, mermaid (a chart editing language) is used as the chart editing language, and the task prompt words designed are as follows: “Mid-term payments under a contract usually include the following time points: p}.
[0089] I will give you several triples representing the temporal relationship between these entity nodes. Please convert the given triples into a flowchart represented by mermaid grammar.
[0090] “For example (e i , within 20 days, e j ) represents node e j In e i After that, it will be carried out within 20 days and converted into mermaid chart language: 'graph LR e i [e i Corresponding entity node name] e i [e i Corresponding entity node name] e i -->|Within 20 days| e i '. " Mission prompts: (1) “Interim payments under a contract usually include the following time points: p}” is a background introduction, which defines the entity nodes included in the flow chart. The entity node E defined in this embodiment p = {e1, e2, e3, e4}, which includes the owner receiving the interim payment application (e1), the owner notifying the contractor of the milestone achievement (e2), the owner issuing the milestone completion certificate (e3), and the owner paying the progress payment (e4).
[0091] (2) “I will give you some triplets representing the temporal relationship between these nodes. Please convert the given triplets into a flowchart represented by mermaid syntax. Triple: (e1, r 12 ,e2)、(e1,r 13 ,e3)、(e1,r 14 ,e4)、(e3,r 34 ,e4)" is a task instruction, which gives the extraction result represented by the triple to the large language model, prompting the large language model to convert the entity relationship in the extraction result into the mermaid language instruction. The triple extraction result given here is replaced by a symbol, and the prompt word replaces the relationship in the triple with the specific relationship obtained by extraction.
[0092] (3) “For example (e i , within 20 days, e j ) represents node e j In e i After that, it will be carried out within 20 days and converted into mermaid chart language: 'graph LR e i [e i Corresponding entity node name] e i [e i Corresponding entity node name] e i -->|Within 20 days| e i '” is a task case, with a triple (e i , within 20 days, e j ) is converted into Mermaid graph language representation as an example, guiding the large language model to output more accurate answers.
[0093] Step S52, traverse the extraction results and judge the entity pair relationship. If the entity pair relationship is "not mentioned", the corresponding entity pair and entity pair relationship are not converted into a visual contract flow chart, otherwise proceed to step S53.
[0094] In this embodiment, when the temporal relationship of the entity pair in the extraction result is "not mentioned", it indicates that the temporal relationship between the extracted entity nodes is not explained in the engineering contract. In this embodiment, it is determined that there is no temporal relationship between them. 14 , r 23 , r 24 , we need to filter out these time relations. The filtering here means not to input them into the steps of generating the visual flowchart. The time relations constraining the progress payment process in this input contract are represented by triples: (e1, "within 28 days", e2), (e1, "within 21 days", e3), (e3, "within 35 days", e4).
[0095] Step S53, concatenate the task prompt words designed in step 1 with the extraction results, input them into the large language model, and generate a flowchart represented by a graphical programming language code.
[0096] According to the task prompt words designed to generate the visual flowchart, the triples representing the extraction results: (e1, r 12 ,e2)、(e1,r 13 ,e3)、(e1,r 14 ,e4)、(e3,r 34 ,e4) are replaced with the entity pair relationships obtained in step 2: (e1, "within 28 days", e2), (e1, "within 21 days", e3), (e3, "within 35 days", e4). The concatenated task prompt words are input into the large language model, and the large language model outputs a flowchart represented by the mermaid graph programming language.
[0097] In this embodiment, the flow chart output by the language model represented by the mermaid graph programming language is as follows: "graph LR e1[Owner receives interim payment request] e2 [Owner notifies contractor of milestone achievement] e3 [Milestone Completion Certificate issued by the Owner] e4[Owner pays progress payment] e1-->|within 21 days| e2 e1-->|within 28 days| e3 e3-->|within 35 days| e4".
[0098] The syntax explanation of the flowchart represented by the mermaid chart programming language above is: (1) “graph LR” represents the initialization graph, where the nodes of the flowchart are distributed from left to right.
[0099] (2) “e1[Owner receives interim payment application] e2[Owner notifies contractor of milestone achievement] e3[Owner issues milestone completion certificate] e4[Owner pays progress payment]” represents the initialization node. The four entity nodes in the flowchart are named e1, e2, e3, and e4 respectively.
[0100] (3) “e1-->|within 28 days|e2; e1-->|within 21 days|e3; e3-->|within 35 days|e4” means adding edges between nodes. Here, node e2 needs to be executed within 21 days after node e1; node e3 needs to be executed within 28 days after node e1; and node e4 needs to be executed within 35 days after node e3.
[0101] Step S54: Rendering the flowchart represented by the chart programming language code into a visual flowchart through a rendering tool.
[0102] In this step, the flowchart represented by the diagram programming language code obtained in step S53 is rendered into a visual flowchart by a rendering tool. In this embodiment, a mermaid rendering tool is used, such as a Markdown editor with integrated mermaid rendering function, to render the mermaid language into a flowchart and return it to the user in a visual form. Figure 2 The following is a rendered visual flowchart.
[0103] Embodiment 2 This embodiment also provides a system established by using the engineering contract flow chart extraction method, which at least includes: A text preprocessing module is used to preprocess the contract input by the user and slice the full text of the contract to obtain a text segment set containing several text segments; A prompt word design module is used to design prompt words for entity pair relationship extraction, and to construct overall prompt words through entity nodes, prompt words for entity pair relationship extraction, extraction cases, and target text segments; The knowledge-enhanced text positioning module is used to match the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair in the sample annotation data set, and take the contract clauses that meet the preset conditions as sample clauses. Based on the sample clauses, the text segment is matched in the text segment set to obtain the target text segment; The knowledge-enhanced information extraction module is used to build extraction cases based on sample clauses.
[0104] Preferably, it also includes a visualization module for constructing a visualized flow chart based on the extraction results; the prompt word design module is also used to design task prompt words that convert the extraction results into a graphical programming language.
[0105] like Figure 3 As shown, the overall architecture of this system includes user layer, business layer and data layer. The text preprocessing module and prompt word design module are located in the user layer, the knowledge-enhanced text positioning module, knowledge-enhanced information extraction module and visualization module are located in the business layer, and the sample annotation data set is located in the data layer.
[0106] Embodiment 3 This embodiment also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing any one of the above methods.
[0107] This embodiment also provides a storage medium, including a computer program / instruction, which, when executed by a processor, implements a method for extracting a construction contract flowchart as described in any one of the above.
[0108] In short, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. The method for extracting the engineering contract flow chart is characterized by: The steps include: (1) Preprocessing the contract input by the user, slicing the full text of the contract to obtain a text segment set including a plurality of text segments; (2) Define entity nodes, construct entity pairs, and design prompt words for extracting the relationship between the entity pairs; (3) For each entity pair relationship to be extracted, the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair are used as indexes to match the entity pair in the sample annotation data set established based on the historical review clauses, and the contract clauses that meet the preset conditions are used as sample clauses. Based on the sample clauses, the text segment is matched in the text segment set to obtain the target text segment; (4) Constructing extraction cases based on the sample clauses, forming overall prompt words through the entity nodes, prompt words extracted from entity pair relationships, extraction cases, and target text segments, and inputting the overall prompt words into the large language model to obtain extraction results.
2. The method for extracting a construction contract flow chart according to claim 1, characterized in that: The extraction result is set as a triple (e i , r ij , e j ) in the form of i and e j is the entity node, r ij is the entity node e i and e j The time relationship between them.
3. The method for extracting a construction contract flow chart according to claim 1 or 2, characterized in that: The content of any data annotation in the sample annotation dataset includes contract terms, project types, term categories, entity pairs and entity pair relationships.
4. The method for extracting a construction contract flowchart according to claim 3 is characterized in that: The preset condition includes matching the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair with the project type, clause category, and entity pair annotated by any data in the sample annotated data set. If they are consistent at the same time, the preset condition is met, otherwise the preset condition is not met.
5. The method for extracting a construction contract flow chart according to any one of claims 1 to 2 or 4, characterized in that: The step of matching the text segment in the text segment set based on the sample clause to obtain the target text segment specifically includes the following steps: (1) converting the matched sample clauses into sample clauses represented by vectors; (2) converting the text segments in the text segment set obtained by slicing into text segments represented by vectors; (3) Establish data index based on the vector representation of text segment; (4) Recalling the target text segment with the highest semantic similarity to the sample clause from the text segment set through vector similarity matching.
6. The method for extracting a construction contract flow chart according to any one of claims 1 to 2 or 4, characterized in that: The step S5 is also included, which is to construct a visual flowchart based on the extraction results, which specifically includes the following steps: Step S51, designing a task prompt word that converts the extraction result into a graphical programming language; Step S52, traverse the extraction results and judge the entity pair relationship. If the entity pair relationship is "not mentioned", the corresponding entity pair and entity pair relationship are not converted into a visual contract flow chart, otherwise proceed to step S53; Step S53, concatenating the task prompt words designed in step S51 with the extraction results, inputting them into the large language model, and generating a flowchart represented by a graphical programming language code; Step S54: Rendering the flowchart represented by the chart programming language code into a visual flowchart through a rendering tool.
7. A system established by using the method of extracting engineering contract flow chart, characterized in that: At least: A text preprocessing module, used to preprocess the contract input by the user, and slice the full text of the contract to obtain a text segment set including a plurality of text segments; A prompt word design module, used to design prompt words for entity pair relationship extraction, and to construct overall prompt words through the entity nodes, prompt words for entity pair relationship extraction, extraction cases and target text segments; The knowledge-enhanced text positioning module is used to match the project type of the contract input by the user, the clause category corresponding to the flowchart to be extracted, and the entity pair in the sample annotation data set, and take the contract clauses that meet the preset conditions as sample clauses. Based on the sample clauses, the text segment is matched in the text segment set to obtain the target text segment; The knowledge-enhanced information extraction module is used to construct extraction cases based on the sample clauses.
8. A system established by using the method for extracting engineering contract flow chart according to claim 7, characterized in that: It also includes a visualization module for constructing a visualized flow chart based on the extraction results; the prompt word design module is also used to design task prompt words that convert the extraction results into a graphical programming language.
9. A computer device, characterized in that: It comprises a memory and a processor, the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method for extracting a flow chart of an engineering contract as described in any one of claims 1-6.
10. A storage medium comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the method for extracting a construction contract flowchart as described in any one of claims 1-6 is implemented.
Citation Information
Patent Citations
Information extraction method and device based on contract dispute judgment
CN111931479B
Entity relationship extraction method and device based on pre-training language model
CN114661913A
Contract file information extraction method, device and system
CN115270777A
Building contract entity information automatic extraction system and method thereof
CN115422938A
Question and answer processing method, device and system, computing equipment and computer storage medium
CN116860949A
Cited By
Contract information extraction method and device, equipment and medium
CN120849530A
Information extraction method based on retrieval enhancement generation technology
CN121233728A
