Contract risk detection method and system based on deep learning
By modeling contract risk detection as a question-and-answer task, using deep learning technology and SimCSE comparative learning retrieval model, combined with the question-and-answer analysis of the BERT model, the problems of cumbersome contract review and difficulty in detecting risk points are solved, and efficient and accurate Risk point identification and automated analysis.
Patent Information
- Application Number
- CN202410517045.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2024-11-12
AI Technical Summary
Traditional contract review is complicated and lacks unified standards. The existing technology has problems such as large video memory demand, explosion of output space and insufficient data in the detection of contract risk points, and has failed to effectively deal with the risk-free points in the contract paragraph.
Model contract risk detection as a question-and-answer task, use deep learning technology and SimCSE comparison learning to build a search model, combine the question-and-answer model to analyze contract paragraphs, obtain semantic information through the BERT model, and use the cross entropy loss function to calculate whether there are answers and answer intervals. Loss, abandon risk-free paragraphs to improve detection efficiency and accuracy.
It realizes automated analysis of contract reviews, improves review efficiency and accuracy, can more accurately identify risk points, adapt to new review needs, and reduces costs.
Smart Images

Figure CN118941418A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a contract risk detection method and system based on deep learning. Background Art
[0002] Traditionally, contract review is mainly done by professional lawyers. This work is very tedious for lawyers, and the level of lawyers varies. Due to the lack of corresponding evaluation standards for contract review, it is difficult for parties to distinguish the review level of lawyers. Therefore, freeing lawyers from the complicated tasks of contract review and unifying the review standards of contracts has become a major challenge facing the legal community.
[0003] Hendrycks et al. borrowed the idea of BERT for question-answering tasks, used sliding windows to solve the problem of insufficient context windows of BERT, and used the BERT question-answering model to determine whether there are risk items in the contract. However, they did not consider the situation where there may be no answer in the text, and because all contracts were reasoned in full text, the reasoning speed was slow and could not meet application requirements.
[0004] Wong et al. proposed a method for reviewing construction contracts using a self-consistency approach, but the system did not explain how to quantify the effectiveness of the work and only relied on feedback from human experts.
[0005] Therefore, there are certain problems in treating the contract risk point review task as a classification task. Treating the contract risk point review as a binary classification problem requires training an independent classification model for each risk point. Although it is theoretically feasible, it is difficult to achieve when there are many risk points due to its huge demand for video memory. On the other hand, treating the contract risk point review as a multi-label classification problem will face the problem of output space explosion, and due to insufficient data volume, multi-classification is also difficult to achieve.
[0006] In order to overcome these defects, this application proposes a contract risk detection method and system based on deep learning, which transforms the contract review task into a question-answering task, thereby improving the contract review effect. Summary of the invention
[0007] The purpose of this application is to provide a contract risk detection method and system based on deep learning, aiming to solve the problem of difficulty in modeling the contract review task as a classification task due to the lack of current contract review labeled data.
[0008] To achieve the above objectives, this application provides the following technical solutions:
[0009] This application provides a contract risk detection method based on deep learning, including:
[0010] Obtain contract documents;
[0011] Based on the pre-built retrieval model, the contract document is searched for contract paragraphs related to risk points to obtain candidate risk points;
[0012] The contract paragraph is analyzed using a question-answering model, and the candidate risk point is input into the question-answering model for judgment; if the contract paragraph does not contain the candidate risk point, the contract paragraph is discarded; if the contract paragraph contains the candidate risk point, a predicted answer is output;
[0013] The predicted answer is transmitted to the user terminal to obtain the risk points in the contract document.
[0014] Furthermore, the step of retrieving the contract paragraphs related to the risk points from the contract document based on the pre-built retrieval model to obtain the candidate risk points specifically includes the following steps:
[0015] The retrieval model is constructed based on deep learning technology and SimCSE contrastive learning, and is pre-trained using a data set consisting of the contract documents;
[0016] The loss function of SimCSE under supervised conditions is:
[0017]
[0018] where h i is the vector representation of the contract problem, is the vector representation of the positive example corresponding to the contract problem, N is the number of samples in a set, and τ is the temperature coefficient.
[0019] Furthermore, the step of analyzing the contract paragraph using the question-answer model specifically includes the following steps:
[0020] The contract paragraphs and contract questions are spliced together in the following format:
[0021] X i =[CLS]Q[SEP]p i [SEP]
[0022] Where [CLS] is the comprehensive representation of all the following contents by the pre-trained model, Q is the contract question query, [SEP] is the separator of the pre-trained model, and p i is the i-th paragraph in the contract paragraph set P.
[0023] Furthermore, the step of inputting the candidate risk points into the question-answering model for judgment specifically includes the following steps:
[0024] The specific formula for judgment is:
[0025] bertOutput = BERT(X i )
[0026] output=Linear(bertOutput)=[E1,…E n ],E i ∈R 2
[0027] Start,End=split(output)
[0028] cls,start,end=E1,argmax(softmax(Start)),argmax(softmax(End))
[0029] Where E1 is the semantic information of contract questions and contract paragraphs;
[0030] X i Input question and answer to get output bertOutput, and then classify it through a linear layer to get output output;
[0031] Split the output into Start and End according to the dimension; extract the start mark of the answer from Start and the end mark of the answer from End;
[0032] Using the cross entropy loss function, the formula for calculating the loss is:
[0033] clsLoss=CrossEntropy(cls,y t )
[0034] qaLoss=CrossEntropy(start,y start )+CrossEntropy(end,y end )
[0035] Loss=α×clsLoss+(1-α)×qaLoss
[0036] Where clsLoss is the loss of calculating whether there is an answer, and qaLoss is the loss of calculating the answer interval; the total loss is obtained by multiplying clsLoss and qaLoss by their respective weights, where the sum of the two weights is 1; y c Is the label of whether the candidate risk point has an answer, y start is the starting position of the answer, y end The end position of the answer.
[0037] Furthermore, the question-answering model also includes:
[0038] If the cls of the question-answer model is classified as a category with no answer, the contract paragraph is discarded;
[0039] If cls is classified as having an answer, but the end position y predicted by the question-answering model end At the starting position y start Before, or end position y end With the starting position y start If they overlap, the contract paragraph does not include the answer to the question and the question paragraph is discarded;
[0040] If the end position y predicted by the question-answering model end At the starting position y start Afterwards, it is determined whether the contract paragraph contains the candidate risk point and a predicted answer is output.
[0041] This application proposes a contract risk detection system based on deep learning, including:
[0042] Acquisition module: obtain contract documents;
[0043] Retrieval module: based on the pre-built retrieval model, the contract document is searched for contract paragraphs related to risk points to obtain candidate risk points;
[0044] Training module: using a question-answering model to analyze the contract paragraph, and inputting the candidate risk point into the question-answering model for judgment; if the contract paragraph does not contain the candidate risk point, the contract paragraph is discarded; if the contract paragraph contains the candidate risk point, a predicted answer is output;
[0045] Output module: transmits the predicted answer to the user terminal to obtain the risk points in the contract document.
[0046] The present application provides a device, which includes a processor and a memory coupled to the processor, wherein the memory stores program instructions for implementing a contract risk detection method based on deep learning; the processor is used to execute the program instructions stored in the memory to implement a contract risk detection method based on deep learning.
[0047] The present application provides a storage medium storing program instructions executable by a processor, wherein the program instructions are used to execute a contract risk detection method based on deep learning.
[0048] This application provides a contract risk detection method and system based on deep learning, which has the following beneficial effects:
[0049] (1) This application uses deep learning technology to review contract risk points, effectively solving the problems of tediousness and uneven lawyer levels in the traditional contract review process; through the training and application of deep learning, it can realize the automated analysis of contract paragraphs, improving the efficiency and accuracy of the review;
[0050] (2) The retrieval model is used to retrieve contract paragraphs related to risk points from contract documents. Compared with manual review, the paragraphs related to risk points can be identified more accurately. As new risk points continue to emerge, the model can be updated and adjusted to meet new review requirements.
[0051] (3) The question-answering model proposed in this application takes into account the situation where the contract paragraph does not include risk points, which is superior to the design scheme that treats the contract review task as classification or does not consider whether the paragraph has risk points. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A flowchart of a contract risk detection method based on deep learning according to Example 1 of the present application;
[0053] Figure 2 This is a structural block diagram of a contract risk detection method based on deep learning in Example 1 of the present application;
[0054] Figure 3 A schematic diagram of positive and negative examples of comparative learning in Example 1 of the present application;
[0055] Figure 4 This is a schematic diagram of the question-answering model of Example 1 of the present application;
[0056] Figure 5 This is a structural diagram of a contract risk detection system based on deep learning according to Example 2 of the present application;
[0057] Figure 6 This is a schematic diagram of the device structure of Example 3 of the present application;
[0058] Figure 7 This is a schematic diagram of the storage medium structure of Example 4 of the present application. DETAILED DESCRIPTION
[0059] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0060] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0061] Example 1
[0062] See also Figure 1 , is a flowchart of a contract risk detection method based on deep learning in Example 1 of the present application; the steps include:
[0063] S1: Obtain contract documents.
[0064] S2: Based on a pre-built retrieval model, the contract document is searched for contract paragraphs related to risk points to obtain candidate risk points.
[0065] In this embodiment, the retrieval model is constructed based on deep learning technology and SimCSE comparative learning, and is pre-trained using a data set consisting of the contract documents.
[0066] SimCSE contrasts learning by generating semantically rich sentence representations, making similar sentences closer in the embedding space and dissimilar sentences farther away. The loss function of SimCSE under supervised conditions is:
[0067]
[0068] where h i is the vector representation of the contract problem, is the vector representation of the positive example corresponding to the contract problem, N is the number of samples in a set, and τ is the temperature coefficient.
[0069] It is understandable that the recalled contract paragraphs are only recalled together because they are similar to the questions, so these recalled contract paragraphs may not necessarily contain risk points. Therefore, after obtaining the contract paragraph sets corresponding to each question, the question-answering model is required to make the final selection of these paragraph sets.
[0070] S3: Analyze the contract paragraph using a question-answering model, and input the candidate risk point into the question-answering model for judgment; if the contract paragraph does not contain the candidate risk point, discard the contract paragraph; if the contract paragraph contains the candidate risk point, output a predicted answer.
[0071] In this embodiment, the contract paragraph and the contract question are spliced in the following format:
[0072] Xi =[CLS]Q[SEP]p i [SEP]
[0073] Where [CLS] is the comprehensive representation of all the following contents by the pre-trained model, Q is the contract question query, [SEP] is the separator of the pre-trained model, and p i is the i-th paragraph in the contract paragraph set P.
[0074] Rewrite all candidate risk points into questions. For example, the risk point "lease purpose" is rewritten as the question "Is the lease purpose mentioned?" The positive example of this question is the contract paragraph related to the lease purpose in the contract marked by the lawyer, and all other paragraphs that are not marked as this risk point by the lawyer can be regarded as negative examples. In order to enrich the data set, the answers corresponding to the questions are regarded as positive examples, and the rest can be filtered as negative examples according to the BM25 algorithm.
[0075] The specific formula for judging whether the question can be answered is:
[0076] bertOutput = BERT(X i )
[0077] output=Linear(bertOutput)=[E1,…E n ],E i ∈R 2
[0078] Start,End=split(output)
[0079] cls,start,end=E1,argmax(softmax(Start)),argmax(softmax(End))
[0080] Among them, E1 is the semantic information of contract questions and contract paragraphs.
[0081] X i Input the question and answer to get the output bertOutput, which is classified through a linear layer to reduce the dimension from 768 dimensions to 2 dimensions to get the output output. Split the output into Start and End according to the dimension, extract the start mark of the answer for Start, and extract the end mark of the answer for End.
[0082] Using the cross entropy loss function, the formula for calculating the loss is:
[0083] clsLoss=CrossEntropy(cls,y c )
[0084] qaLoss=CrossEntropy(start,y start )+CrossEntropy(end,y end )
[0085] Loss=α×clsLoss+(1-α)×qaLoss
[0086] Where clsLoss is the loss of calculating whether there is an answer, and qaLoss is the loss of calculating the answer interval; the total loss is obtained by multiplying clsLoss and qaLoss by their respective weights, where the sum of the two weights is 1; y c Is the label of whether the candidate risk point has an answer, y start is the starting position of the answer, y end The end position of the answer.
[0087] The judgment process is as follows: if the cls of the question-answering model is classified as a category without an answer, the contract paragraph is discarded; if the cls is classified as a category with an answer, but the end position y predicted by the question-answering model is end At the starting position y start Before, or end position y end With the starting position y start If the end position y predicted by the question-answering model is end At the starting position y start Afterwards, it is determined whether the contract paragraph contains the candidate risk point and a predicted answer is output.
[0088] S4: Transmit the predicted answer to the user terminal to obtain the risk points in the contract document.
[0089] In this embodiment, the risk point paragraphs confirmed by the question-answer model are output as the review results, helping users to quickly locate the risk points in the contract and improve the efficiency and accuracy of the contract review.
[0090] In summary, Example 1 of the present application proposes a contract risk detection method based on deep learning to address the problems in the traditional contract review process. This method uses deep learning technology to transform contract review into a question-and-answer task, effectively improving the efficiency and accuracy of the review. By combining a retrieval model based on contrastive learning and a question-and-answer model, the present invention can accurately identify risk points in contracts and solve the problems of huge video memory requirements and output space explosion in the prior art. Specifically, the positive and negative examples of the answers to the questions are first screened by the BM25 algorithm, and then the retrieval model of SimCSE contrastive learning is used to generate semantically rich sentence representations, so that similar sentences are closer in the embedding space; the question-and-answer model predicts the starting and ending positions of the answer, and obtains a comprehensive representation through the BERT model; at the same time, the question-and-answer model takes into account the situation where risk points are not included in the contract paragraph, which is superior to the design scheme that treats the contract review task as a classification or does not consider whether the paragraph has risk points. The present application improves the accuracy of risk point identification and review efficiency, and reduces the review cost.
[0091] Example 2
[0092] See also Figure 5 , which is a structural diagram of a contract risk detection system based on deep learning in Example 2 of the present application; the specific contents include:
[0093] Acquisition module: obtain contract documents;
[0094] Retrieval module: based on the pre-built retrieval model, searching the contract document for contract paragraphs related to risk points to obtain candidate risk points;
[0095] Training module: using a question-answering model to analyze the contract paragraph, and inputting the candidate risk point into the question-answering model for judgment; if the contract paragraph does not contain the candidate risk point, the contract paragraph is discarded; if the contract paragraph contains the candidate risk point, a predicted answer is output;
[0096] Output module: transmits the predicted answer to the user terminal to obtain the risk points in the contract document.
[0097] In this example, the question-answering model of the contract was tested, and two solutions for reviewing the risk points of the contract were selected for comparison. The first one was proposed by Hendrycks to use the BERT question-answering model to review the risk points of the contract. The model gave the answer interval, but he did not consider the situation that there might be no answer in the contract paragraph. The second one was a solution where the BERT classification model judged whether the risk point was related to the paragraph. The evaluation results are as follows:
[0098]
[0099] Because the BERT classification model does not involve the question-answering part, the EM and fuzzy matching indicators are not measured for BERT classification. Compared with the BERT classification scheme, the question-answering model adds question-answering tasks, and the joint training of multiple tasks introduces noise, which improves the generalization ability of the model. Therefore, the question-answering model proposed in this application is better than the BERT question-answering model.
[0100] Example 3
[0101] See also Figure 6 , is a schematic diagram of the device structure of Embodiment 3 of the present application. The device 50 includes a processor 51 and a memory 52 coupled to the processor 51 .
[0102] The memory 52 stores program instructions for implementing the above-mentioned contract risk detection method based on deep learning.
[0103] The processor 51 is used to execute program instructions stored in the memory 52 to implement a contract risk detection based on deep learning.
[0104] The processor 51 may also be referred to as a CPU (Central Processing Unit).
[0105] The processor 51 may be an integrated circuit chip with signal processing capabilities. The processor 51 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0106] Example 4
[0107] See also Figure 7 , which is a schematic diagram of the structure of the storage medium of Example 4 of the present application. The storage medium of the embodiment of the present application stores a program file 61 that can implement all the above methods, wherein the program file 61 can be stored in the above storage medium in the form of a software product, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or a computer, a server, a mobile phone, a tablet, and other devices.
[0108] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, device, article or method including the element.
[0109] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
[0110] Although the embodiments of the present application have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the appended claims and their equivalents.
[0111] Of course, the present invention may have many other implementations. Based on this implementation, other implementations obtained by ordinary technicians in this field without any creative work are all within the scope of protection of the present invention.
Claims
1. A contract risk detection method based on deep learning, It is characterized in that include: Obtain contract documents; Based on the pre-built retrieval model, the contract document is searched for contract paragraphs related to risk points to obtain candidate risk points; Using a question-answer model to analyze the contract paragraphs, and inputting the candidate risk points into the question-answer model for judgment; If the contract paragraph does not contain the candidate risk point, the contract paragraph is discarded; If the contract paragraph contains the candidate risk point, outputting a predicted answer; The predicted answer is transmitted to the user terminal to obtain the risk points in the contract document.
2. According to the deep learning-based contract risk detection method of claim 1, It is characterized in that The step of retrieving contract paragraphs related to risk points from the contract document based on the pre-built retrieval model to obtain candidate risk points specifically includes the following steps: The retrieval model is constructed based on deep learning technology and SimCSE contrastive learning, and is pre-trained using a data set consisting of the contract documents; The loss function of SimCSE under supervised conditions is: where h i is the vector representation of the contract problem, is the vector representation of the positive example corresponding to the contract problem, N is the number of samples in a set, and τ is the temperature coefficient.
3. According to the contract risk detection method based on deep learning according to claim 1, It is characterized in that The step of analyzing the contract paragraph using the question-answer model specifically includes the following steps: The contract paragraphs and contract questions are spliced together in the following format: X i =[CLS]Q[SEP]p i [SEP] Where [CLS] is the comprehensive representation of all the following contents by the pre-trained model, Q is the contract question query, [SEP] is the separator of the pre-trained model, and p i is the i-th paragraph in the contract paragraph set P.
4. According to the deep learning-based contract risk detection method of claim 1, It is characterized in that The step of inputting the candidate risk points into the question-answering model for judgment specifically includes the following steps: The specific formula for judgment is: bertOutput=BERT(X i ) output=Linear(bertOutput)=[E 1, …E n ],E i ∈R 2 Start,End=split(output) cls,start,end=E 1 ,argmax(softmax(Start)),argmax(softmax(End)) Where E 1 Semantic information for contract questions and contract paragraphs; X i Input question and answer to get output bertOutput, and then classify it through a linear layer to get output output; Split the output into Start and End according to the dimension; extract the start mark of the answer from Start and the end mark of the answer from End; Using the cross entropy loss function, the formula for calculating the loss is: clsLoss=CrossEntropy(cls,y c ) qaLoss=CrossEntropy(start,y start )+CrossEntropy(end,y end ) Loss=α×clsLoss+(1-α)×qaLoss Where clsLoss is the loss of calculating whether there is an answer, and qaLoss is the loss of calculating the answer interval; the total loss is obtained by multiplying clsLoss and qaLoss by their respective weights, where the sum of the two weights is 1; y c Is the label of whether the candidate risk point has an answer, y start is the starting position of the answer, y end The end position of the answer.
5. According to the deep learning-based contract risk detection method of claim 4, It is characterized in that The question-answering model also includes: If the cls of the question-answer model is classified as a category with no answer, the contract paragraph is discarded; If cls is classified as having an answer, but the end position y predicted by the question-answering model end At the starting position y start Before, or end position y end With the starting position y start If they overlap, the contract paragraph does not include the answer to the question and the question paragraph is discarded; If the end position y predicted by the question-answering model end At the starting position y start Afterwards, it is determined whether the contract paragraph contains the candidate risk point and a predicted answer is output.
6. A system for contract risk detection method based on deep learning according to claim 1, It is characterized in that include: Acquisition module: obtain contract documents; Retrieval module: based on the pre-built retrieval model, the contract document is searched for contract paragraphs related to risk points to obtain candidate risk points; Training module: using a question-answering model to analyze the contract paragraphs, and inputting the candidate risk points into the question-answering model for judgment; If the contract paragraph does not contain the candidate risk point, the contract paragraph is discarded; If the contract paragraph contains the candidate risk point, outputting a predicted answer; Output module: transmits the predicted answer to the user terminal to obtain the risk points in the contract document.
7. A device, It is characterized in that The device includes a processor and a memory coupled to the processor, wherein the memory stores program instructions for implementing a deep learning-based contract risk detection method as described in any one of claims 1 to 5; and the processor is used to execute the program instructions stored in the memory to implement a deep learning-based contract risk detection method.
8. A storage medium, It is characterized in that Processor-executable program instructions are stored, and the program instructions are used to execute a contract risk detection method based on deep learning as described in any one of claims 1-5.
Citation Information
Cited By
Text analysis method for default management based on artificial intelligence
CN121071115A
A text analysis method for default management based on artificial intelligence
CN121071115B
