High-precision contract document analysis method based on large model
By fine-tuning the pre-trained model and combining RAG technology, YOLO model and text comparison method, high-precision contract document analysis is achieved, solving the limitations of the existing system in terms of accuracy and multi-format processing, and improving contract data processing completeness and accuracy.
Patent Information
- Application Number
- CN202411447661.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing smart contract management system has limitations in the accuracy of processing contract documents, intelligent comparison of contract content and intelligent question and answer, and it is difficult to accurately identify key information in the contract and effectively process contract documents in multiple formats.
A high-precision contract document analysis method based on large models is adopted, and a query and answer generation model is obtained by fine-tuning the pre-trained model, and a differential content identification and risk assessment are carried out in combination with RAG technology, YOLO model and text comparison method.
It improves the accuracy and efficiency of contract document analysis, can effectively extract key information in the contract, optimizes the analysis process of contract document, and improves the completeness and accuracy of contract data processing.
Smart Images

Figure CN119415633A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of contract document parsing, and specifically is a high-precision contract document parsing method based on a large model. Background Art
[0002] With the rapid development of information technology and artificial intelligence technology, especially the progress in the field of natural language processing (NLP), intelligent contract management systems are becoming an important research direction in the field of legal technology.
[0003] Traditional contract management and processing methods are often time-consuming, labor-intensive, and error-prone, making it difficult to meet the needs of modern enterprises for efficient and accurate contract management. Existing intelligent contract management systems use advanced technologies such as computer vision and natural language processing to parse contract documents and provide certain automation functions. However, these systems still have many limitations in terms of the accuracy of contract document processing, intelligent comparison of contract content, and intelligent question and answer. For example, some systems may not be able to accurately identify key information in the contract, or have difficulty effectively processing contract documents in multiple formats, which affects the practicality of the system and user experience.
[0004] Therefore, the present invention proposes a high-precision contract document parsing method based on a large model to solve the above problems. Summary of the invention
[0005] The present invention aims to solve at least one of the technical problems existing in the prior art; to this end, the present invention proposes a high-precision contract document parsing method based on a large model, which is used to solve the existing intelligent contract management system that utilizes advanced technologies such as computer vision and natural language processing to parse contract documents and provide certain automation functions; however, these systems still have many limitations in terms of the accuracy of processing contract documents, intelligent comparison of contract contents, intelligent question and answer, etc.
[0006] To achieve the above object, the first aspect of the present invention provides a high-precision contract document parsing method based on a large model, comprising:
[0007] Step 1: Get user input data;
[0008] Step 2: Fine-tune the pre-trained model to obtain a query question and answer generation model, and process the query question and answer generation model based on the input data to obtain the query result;
[0009] Step 3: Obtain recognition results by performing differential content recognition on the input data;
[0010] Step 4: Conduct risk assessment on the input data and obtain the assessment results.
[0011] Preferably, the obtaining of user input data includes:
[0012] Obtain the query and several documents that the user needs to input; the several documents refer to the documents that the user needs to identify the differences in the content of different versions of contract documents; the documents include: PDF, Word, and pictures, etc.
[0013] It should be noted that in the field of computer science and information retrieval, input query usually refers to the request submitted by the user to the system or database in order to obtain certain information, data or perform certain operations. This request can be a simple keyword search, a complex SQL query statement, or an advanced query language command for searching, retrieving or calculating data.
[0014] Preferably, the fine-tuning of the pre-trained model includes:
[0015] The pre-trained model is fine-tuned through fine-tuning technology to obtain a query question and answer generation model; wherein the fine-tuning technology includes: large model fine-tuning technology and LoRA fine-tuning technology;
[0016] S1: Obtain relevant datasets based on fine-tuning tasks;
[0017] S2: Set the hyperparameters in the fine-tuning process; hyperparameters include: learning rate, weight and loss function;
[0018] S3: Further train the pre-trained model based on the dataset.
[0019] It should be noted that the fine-tuning task refers to a specific application scenario or goal, including: question-answering tasks, text classification tasks, and entity recognition tasks, etc. The entity recognition task refers to identifying specific entities in the text, such as parties, amounts, dates, etc.;
[0020] Pre-trained models are trained on large-scale datasets and learn a wide range of language or visual features. These models usually have strong general capabilities, such as GPT, BERT, RoBERTa, etc. The fine-tuning process is to further train the pre-trained model using task-specific datasets; the goal of fine-tuning is to make the model shift from general capabilities to high performance for specific tasks.
[0021] Preferably, the processing based on the input data by generating a query question and answer model includes:
[0022] Retrieve information related to the query input by the user based on the RAG technology, and generate an answer corresponding to the query input by the user based on the retrieved information;
[0023] S1: obtaining query data by preprocessing the query input by the user; wherein the preprocessing includes: query parsing and query expansion;
[0024] S2: Retrieve several candidate documents related to the query data from the existing text library through RAG technology;
[0025] S3: Input the query and candidate documents entered by the user into the query question answering generation model to obtain the query result.
[0026] It should be noted that RAG technology is a method that combines unstructured data retrieval and generative models to process and generate natural language text; it is mainly composed of two key components: Retriever and Generator; these two components work together to retrieve relevant information from large unstructured text libraries and use this information to generate high-quality answers or texts.
[0027] Preferably, the step of identifying the difference content of the input data includes:
[0028] S1: Extract several documents input by the user;
[0029] S2: converting a number of documents into an editable text format to obtain one-to-one comparison data of the documents;
[0030] S3: Perform layout analysis on the data by comparing with the YOLO model to obtain the layout analysis result; extract text data from the layout analysis result by using OCR; wherein the YOLO model includes: YOLOv4, YOLOv5 or YOLOv8;
[0031] S4: Compare text data extracted from several documents by using a text comparison method to obtain a comparison result; wherein the text comparison method includes: diff-match-patch, difflib; the comparison result includes: added, deleted and modified content.
[0032] It should be noted that the layout analysis refers to analyzing the page layout of a document to identify different types of elements and their positions in the document; the layout analysis results include: title, text, images, tables, etc.
[0033] Preferably, the risk assessment of the input data includes:
[0034] S1: extract entities from historical text content; historical text content refers to the text content of historical documents; entities include: parties, amounts, dates, etc.;
[0035] S2: Label the entities and integrate the historical text content and the corresponding labeled entities into training data; the labeling includes: entity category labeling and entity location labeling;
[0036] S3: Train an artificial intelligence model based on the training data to obtain a named entity recognition model; wherein the artificial intelligence model includes: LSTM, BiLSTM-CRF or BERT;
[0037] S4: Extract entities from the input document based on the named entity recognition model, and merge the extracted entities to obtain the contract terms in the document;
[0038] S5: Input the contract terms into the pre-trained risk factor identification model for identification, and obtain the risk factors corresponding to the contract terms;
[0039] S6: By formula:
[0040]
[0041] Calculate the risk score of the contract terms; where w i is the weight of the contract clause corresponding to the ith risk factor, p i is the probability or impact of the i-th risk factor corresponding to the contract terms; n is the number of risk factors, and i is a positive integer;
[0042] S7: Determine whether the risk score is greater than a preset threshold; if yes, it is judged as high risk; if no, it is judged as low risk; wherein the preset threshold is set according to actual risk requirements.
[0043] It should be noted that the risk factors refer to specific elements in the contract terms that may bring adverse consequences, including legal risks, financial risks and compliance risks; the weights of the risk factors and the probability of occurrence or impact of the risk factors are set based on historical data or industry experience.
[0044] Preferably, the risk factor identification model obtained by pre-training includes:
[0045] By integrating contract terms as standard input data, the risk factors corresponding to the contract terms are integrated as standard output data;
[0046] The artificial intelligence model is trained based on standard input data and standard output data to obtain a risk factor identification model.
[0047] It should be noted that the risk factors corresponding to the contract terms are manually identified based on historical data or industry experience.
[0048] Compared with the prior art, the present invention has the following beneficial effects:
[0049] 1. The present invention obtains the user's input data, fine-tunes the pre-trained model through fine-tuning technology, and obtains a query question and answer generation model; obtains query data by preprocessing the query input by the user; retrieves a number of candidate documents related to the query data from the existing text library through RAG technology; inputs the query input by the user and the candidate documents into the query question and answer generation model to obtain the query result, which is conducive to providing more detailed and accurate answers.
[0050] 2. The present invention extracts several documents input by the user; converts the several documents into an editable text format to obtain one-to-one comparison data of the several documents; classifies the comparison data through the YOLO model to obtain the classification result; compares the classification results corresponding to different comparison data through a text comparison method to obtain the comparison result. The present invention can effectively extract key information from contract documents in various formats, and uses technologies such as the YOLO model to identify and sort text types, thereby ensuring the comprehensive reflection of the structure and content of contract terms, which not only optimizes the parsing process of contract documents, but also improves the integrity and accuracy of contract data processing.
[0051] 3. The present invention trains an artificial intelligence model based on training data to obtain a named entity recognition model; extracts entities from several documents based on the named entity recognition model, and merges the extracted entities to obtain contract terms in the documents; obtains a risk score for the contract terms by calculation; determines whether the risk score is greater than a preset threshold; if yes, it is judged as high risk; if not, it is judged as low risk, which is beneficial to improving contract analysis and risk control capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 A schematic diagram of the method steps of an embodiment of the present invention;
[0054] Figure 2 A schematic diagram of differential content identification according to an embodiment of the present invention;
[0055] Figure 3 Schematic diagram of the steps of the risk assessment method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0057] See also Figure 1 The first aspect of the present invention provides a high-precision contract document parsing method based on a large model, comprising:
[0058] Step 1: Get user input data;
[0059] Step 2: Fine-tune the pre-trained model to obtain a query question and answer generation model, and process the query question and answer generation model based on the input data to obtain the query result;
[0060] Step 3: Obtain recognition results by performing differential content recognition on the input data;
[0061] Step 4: Conduct risk assessment on the input data and obtain the assessment results.
[0062] Get user input data, including:
[0063] Obtain the query and several documents that the user needs to input; the several documents refer to the documents that the user needs to identify the differences in the content of different versions of contract documents; the documents include: PDF, Word, and pictures, etc.
[0064] By fine-tuning the pre-trained model, including:
[0065] The pre-trained model is fine-tuned through fine-tuning technology to obtain a query question and answer generation model; wherein the fine-tuning technology includes: large model fine-tuning technology and LoRA fine-tuning technology;
[0066] S1: Obtain relevant datasets based on fine-tuning tasks;
[0067] S2: Set the hyperparameters in the fine-tuning process; hyperparameters include: learning rate, weight and loss function;
[0068] S3: Further train the pre-trained model based on the dataset.
[0069] For example: 1. Choose the BERT model as the pre-training model because it performs well in text classification and question answering tasks.
[0070] 2. Prepare fine-tuning data;
[0071] Dataset collection;
[0072] Task dataset: Collect relevant datasets based on the task that needs fine-tuning. For example, for question-answering tasks, collect datasets containing question-answer pairs; for text classification tasks, collect text datasets containing labels.
[0073] Example: Collect data about customer service conversations from multiple public datasets and internal enterprise data.
[0074] Dataset partitioning;
[0075] Training set: used for model training, accounting for the vast majority of the data set.
[0076] Validation set: used to monitor model performance during training to adjust hyperparameters and avoid overfitting.
[0077] Test set: used to finally evaluate the performance of the model and ensure that the model performs well on unseen data.
[0078] Add a sequence generation layer for generation tasks.
[0079] Example: Use 80% of the labeled conversation data for training, 10% for validation, and 10% for testing.
[0080] 3. Fine-tune parameters;
[0081] Fine-tuning usually uses a lower learning rate to prevent large changes in model parameters, thereby maintaining the general capabilities of the pre-trained model. The fine-tuning learning rate can be set as:
[0082] η fine-tuning =α·η pre-training ;
[0083] Here, α is a constant less than 1.
[0084] LoRa fine-tuning technology: LoRA is an efficient model fine-tuning technology that fine-tunes large pre-trained models by introducing parameters of low-rank matrices without significantly modifying the parameters of the original model. The core idea of LoRA is to inject the trainable low-rank decomposition matrix into each layer of the Transformer architecture after freezing the weights of the pre-trained model, thereby greatly reducing the amount of trainable parameters on downstream tasks. This method not only saves computing resources, but also effectively improves the performance of the fine-tuning model. The following is the derivation of the relevant formulas for the LoRA fine-tuning model:
[0085] For the pre-trained weight matrix W0∈R d×d , LoRA limits its update method, that is, the incremental parameter matrix δW of all parameter fine-tuning is expressed as a low-rank approximation of two matrices B and A with smaller parameters:
[0086] W0+δW=W0+BA;
[0087] Among them, B and A are the weight matrices of LoRa low-rank adaptation, and the rank r is much smaller than d.
[0088] At this time, the fine-tuning parameter amount changes from the original d×d of δW to 2*r*d of B and A.
[0089] Given an input x∈R d , the output h∈R after adding LoRA d :
[0090] h=(W0+δW)x=W0x+BAx;
[0091] Here, δh=BAx to facilitate subsequent derivation.
[0092] It should be noted that rank r refers to the rank of the low-rank matrix, that is, the number of linearly independent columns of the low-rank matrix. In the LoRA method, the original weight matrix is decomposed into two low-rank matrices A and B, whose product can approximate the original high-dimensional parameter matrix. The "rank r" here refers to the rank of matrices A and B, which determines the number of columns of the two matrices, that is, their width. Usually, the original weight matrix W0 has a very high dimension, that is, its number of rows and columns is very large, and the rank r of the low-rank matrices A and B is much smaller than d (d is the number of columns of the original weight matrix W0).
[0093] During training, the original parameters will be frozen, which means that although the original parameters will participate in forward propagation and back propagation, their gradients will not be calculated and the parameters will not be updated.
[0094] Calculate its gradient and do not update the parameters.
[0095] LoRA parameter initialization;
[0096] At the beginning of training, the matrix B is initialized by a Gaussian function, b i ~N(0,σ b 2 ). The matrix A is initialized to all zeros. This makes the bypass BA of LoRA = 0 before training begins, and fine-tuning can only start from the pre-trained weight W0.
[0097] LoRA parameter merging coefficient;
[0098] δW=BA will be multiplied by the coefficient Merge with pre-trained weights, where α is a hyperparameter:
[0099]
[0100] Fine-tune training;
[0101] Use the dataset of the target task to perform fine-tuning training and update the model parameters.
[0102] Loss function:
[0103] Commonly used loss functions in the fine-tuning process include cross entropy loss (classification tasks) and mean square error (regression tasks). For classification tasks, cross entropy loss is defined as:
[0104]
[0105] Among them, y i is the true label, is the predicted probability of the model.
[0106] Optimization method:
[0107] Gradient descent methods (such as Adam, SGD, etc.) are usually used to minimize the loss function and update the model parameters. The update rule of the Adam optimizer is:
[0108]
[0109] Among them, θ t is the model parameter, η is the learning rate, m t and v t are the first and second moment estimates of the gradient, respectively.
[0110] Save model: Save the trained model weights.
[0111] Based on the input data, the query and answer generation model is processed, including:
[0112] Retrieve information related to the query input by the user based on the RAG technology, and generate an answer corresponding to the query input by the user based on the retrieved information;
[0113] S1: obtaining query data by preprocessing the query input by the user; wherein the preprocessing includes: query parsing and query expansion;
[0114] S2: Retrieve several candidate documents related to the query data from the existing text library through RAG technology;
[0115] S3: Input the query and candidate documents entered by the user into the query question answering generation model to obtain the query result.
[0116] For example, in a typical unstructured data retrieval system, an input query goes through the following processing steps:
[0117] Query parsing: Parse the query entered by the user, identify keywords, phrases, entities, etc., and understand the intent of the query.
[0118] Term segmentation: Separate the words in the query.
[0119] Part-of-speech tagging: Tag the words in the query to identify nouns, verbs, adjectives, etc.
[0120] Query expansion: Generate related expanded queries based on the user's query to improve the recall rate of retrieval.
[0121] Vectorization: Convert the query into a vector form so that similarity calculation can be performed with the document.
[0122] Word embedding: Map the words in the query to a high-dimensional vector space.
[0123] Sentence vector: Map the entire query into a vector.
[0124] Document vectors: Encode each document fragment in a document collection as a vector.
[0125] Relevant document retrieval;
[0126] Relevant document retrieval refers to retrieving the most relevant document fragments to an input query from a large unstructured document collection before generating an answer.
[0127] Use the retrieval model to find the most relevant document fragments for the input query from a pre-built document library. This step usually relies on a pre-trained dual encoder model.
[0128] Similarity measurement theorem: used to measure the similarity between the input text and the retrieved knowledge source.
[0129] Similarity calculation: Calculate the cosine similarity between the query vector and the document vector.
[0130] Retrieve relevant documents: Sort by similarity score and select the first k document fragments with the highest scores as relevant documents; where k is a preset value.
[0131] Combine input and retrieval results: Combine the input query and the retrieved relevant document fragments to form a contextual input sequence. The goal of this step is to provide rich contextual information for the generative model to generate high-quality answers.
[0132] Generate answers;
[0133] Generating answers refers to using a query-answer generation model to generate natural language answers based on a sequence of contextual inputs. This step includes:
[0134] Contextual input processing: The input query and the retrieved relevant document fragments are merged to form a continuous text sequence as the input of the query question answering generation model.
[0135] Answer generation: Query answer generation models generate answers based on contextual input.
[0136] Output the answer;
[0137] The system returns the generated answer or text for the user's reference.
[0138] See also Figure 2 , by performing differential content recognition on the input data, including:
[0139] S1: Extract several documents input by the user;
[0140] S2: converting a number of documents into an editable text format to obtain one-to-one comparison data of the documents;
[0141] S3: Perform layout analysis on the data by comparing with the YOLO model to obtain the layout analysis result; extract text data from the layout analysis result by using OCR; wherein the YOLO model includes: YOLOv4, YOLOv5 or YOLOv8;
[0142] S4: Compare text data extracted from several documents by using a text comparison method to obtain a comparison result; wherein the text comparison method includes: diff-match-patch, difflib; the comparison result includes: added, deleted and modified content.
[0143] For example: users upload contract documents through the system interface, which supports multiple formats (such as PDF, Word, pictures, etc.).
[0144] Identify the document type;
[0145] The model determines the data type of the input document based on its suffix, including PDF, docx, doc, PNG, etc.
[0146] Example: User input document: contract.docx System identification: docx document;
[0147] Data preprocessing;
[0148] Document format conversion: Convert contract documents in various formats (such as PDF, Word, etc.) into editable text formats.
[0149] Text cleaning: Clean the contract text to remove unnecessary blank characters, special symbols, etc. to ensure the purity of the text.
[0150] Sentence and word segmentation: Sentence and word segmentation are performed on the contract text to identify sentence and word boundaries in the text, laying the foundation for subsequent processing.
[0151] OCR technology;
[0152] OCR technology is used to convert text content in an image into an editable text format. The specific steps are as follows:
[0153] 1. Preprocessing, including: grayscale processing, denoising, binarization, and tilt correction;
[0154] 2. Layout analysis;
[0155] Text Block Detection: Detect text blocks using a connected component analysis approach.
[0156] Text line segmentation: Use the horizontal projection method to project the image horizontally and detect the valley value in the projection to segment the text line.
[0157] Character segmentation: Use the vertical projection method to project the text line in the vertical direction and detect the valley value in the projection to segment the characters.
[0158] Character recognition;
[0159] Character feature extraction: Use Hough transform, SIFT (Scale Invariant Feature Transform), HOG (Histogram of Oriented Gradients) and other methods to extract features.
[0160] Character classification: Common methods include convolutional neural network (CNN), recurrent neural network (RNN), etc.
[0161] 3. Semantic post-processing;
[0162] Format Restoration: Restore the formatting of the original text.
[0163] Install necessary libraries: Install Tesseract OCR engine.
[0164] Use Tesseract OCR engine to extract text from preprocessed images into editable strings.
[0165] YOLO recognition technology:
[0166] Dataset preparation: Collect and annotate samples containing different types of text (such as body text, titles, graphics).
[0167] Model training: Use the YOLO framework for training. The loss function mainly includes classification loss and positioning loss.
[0168] Classification loss function:
[0169]
[0170] Where: S represents the size of the grid, usually the network into which the image is divided; i represents the current grid unit index; classes represents the set of all categories; 1iobj is an indicator variable that takes the value 1 when the i-th grid cell contains an object and 0 otherwise.
[0171] p i (c): The probability that the i-th grid cell is predicted to be class c.
[0172] The probability that the i-th grid cell is actually class c (the true label).
[0173] Positioning loss function:
[0174]
[0175] Among them, λ coord is a weight parameter used to balance the positioning loss and other losses; J represents the index of the bounding box; B represents the number of bounding boxes predicted for each grid cell; (x i ,y i ) are the coordinates of the center of the bounding box predicted by the i-th grid cell; are the coordinates of the actual bounding box center of the i-th grid cell (the true label).
[0176] Complete loss function formula:
[0177] Loss=Loss coord +Loss class +Loss obj +Loss noobj ;
[0178] Among them, Loss obj : Object loss, which measures whether the predicted bounding box contains an object.
[0179] Loss noobj : Object-free loss, which measures whether the predicted bounding box does not contain an object.
[0180] Non-maximum suppression:
[0181]
[0182] Among them, IoU is the intersection-over-union ratio of each pair of detection frames, the numerator represents the overlapping area between the two detection frames, and the denominator represents the total area of the two detection frames, that is, the union area of the two detection frames;
[0183] The intersection over union (IoU) of each pair of detection boxes is calculated. If the IoU exceeds a set threshold (such as 0.5), the detection box with lower confidence is removed.
[0184] Text region extraction: Get the bounding box coordinates and text type of each text region.
[0185] Text classification and sorting order;
[0186] Text Classification:
[0187] According to the category label of the detection box, the text area is classified into different text types (such as title, body, table).
[0188] Output result: Output the detected text area and its category and coordinate information.
[0189] Comparison of contract texts;
[0190] You can use some common text comparison methods to compare the converted text, for example, diff-match-patch, difflib, etc.
[0191] Result output: Generate a difference report that lists in detail the differences between the contracts, including additions, deletions and modifications.
[0192] See also Figure 3 , by conducting a risk assessment of the input data, including:
[0193] S1: extract entities from historical text content; historical text content refers to the text content of historical documents; entities include: parties, amounts, dates, etc.;
[0194] S2: Label the entities and integrate the historical text content and the corresponding labeled entities into training data; the labeling includes: entity category labeling and entity location labeling;
[0195] S3: Train an artificial intelligence model based on the training data to obtain a named entity recognition model; wherein the artificial intelligence model includes: LSTM, BiLSTM-CRF or BERT;
[0196] S4: Extract entities from the input document based on the named entity recognition model, and merge the extracted entities to obtain the contract terms in the document;
[0197] S5: Input the contract terms into the pre-trained risk factor identification model for identification, and obtain the risk factors corresponding to the contract terms;
[0198] S6: By formula:
[0199]
[0200] Calculate the risk score of the contract terms; where w i is the weight of the contract clause corresponding to the ith risk factor, p i is the probability or impact of the i-th risk factor corresponding to the contract terms; n is the number of risk factors, and i is a positive integer;
[0201] S7: Determine whether the risk score is greater than a preset threshold; if yes, it is judged as high risk; if no, it is judged as low risk; wherein the preset threshold is set according to actual risk requirements.
[0202] The pre-trained risk factor identification model includes:
[0203] By integrating contract terms as standard input data, the risk factors corresponding to the contract terms are integrated as standard output data;
[0204] The artificial intelligence model is trained based on standard input data and standard output data to obtain a risk factor identification model.
[0205] For example, suppose you need to automatically identify and evaluate potential risk clauses by fully parsing and analyzing the contract text to ensure the legality, integrity, and risk controllability of the contract. The specific steps are as follows:
[0206] 1. Data preprocessing;
[0207] Contract text extraction: Extract text content from contract documents.
[0208] Text cleaning and standardization: remove unnecessary blank characters and special symbols, and unify text formats.
[0209] 2. Risk identification;
[0210] Named Entity Recognition: Identify key entities in the contract text (such as parties, amounts, dates, etc.). The following are the specific steps for named entity recognition:
[0211] Text preprocessing;
[0212] Word segmentation: divide the text into vocabulary units (tokens); vocabulary units include: words, punctuation marks, etc.
[0213] Standardization: Perform uniform processing on text, such as converting to lowercase letters, removing special characters, etc.
[0214] Feature extraction;
[0215] Word embedding: Convert words into fixed-length vectors to preserve the semantic information of the vocabulary. Commonly used word embedding technologies include Word2Vec, GloVe, and Transformer-based embedding (such as BERT, GPT).
[0216] Contextual information: Use contextual information to enhance the understanding of vocabulary. For example, in the BERT model, word embedding takes contextual information into account to generate word vectors.
[0217] Entity recognition models;
[0218] Select model: Select a suitable model for training, such as LSTM, BiLSTM-CRF, BERT, etc.
[0219] Entity prediction;
[0220] Predict entities: Use the trained model to predict entities in the text content of new documents.
[0221] Result analysis: Analyze the entity information output by the model, including entity category and location.
[0222] Post-processing;
[0223] Entity merging: Merge adjacent entities (e.g. "New" and "York" are merged into "New York").
[0224] Result filtering: Filter out entities with low confidence or non-target entities.
[0225] Dependency parsing: Understanding the structure and semantics of contract terms by parsing the dependency relationships of sentences.
[0226] It should be noted that filtering low-confidence entities means that during the named entity recognition process, the model will give each entity a confidence score, which reflects the probability that the model believes that the entity is a real entity. If the confidence of an entity is lower than a predetermined threshold (such as 0.5 or 0.7), then the entity may not be a real entity, but a misidentification of the model. Therefore, these entities with low confidence need to be filtered out to reduce false positives.
[0227] Filtering non-target entities refers to filtering out specific types of entities in certain application scenarios. For example, when processing contract texts, we only focus on the names, amounts, dates, and other information of the parties involved. Non-target entities are those entities that do not belong to the category we are interested in. For example, if an entity is labeled as a place by the model, but our goal is to identify the amount in the contract, then this place entity should be filtered out.
[0228] 3. Identification of risk factors in contract terms;
[0229] Identify contract terms based on the pre-trained risk factor identification model to obtain the risk factors corresponding to the contract terms;
[0230] Example: Assume there is a contract clause that says “Party A shall compensate Party B for any loss or damage”;
[0231] By identifying the following risk factors:
[0232] Risk factor 1 (i=1): The scope of compensation is too broad (which may cause Party A to bear unexpectedly high compensation).
[0233] Risk factor 2 (i=2): There is a lack of a clear upper limit on compensation in the terms.
[0234] Risk Factor 3 (i=3): The clause does not distinguish between different types of losses (such as direct losses and indirect losses).
[0235] Risk Factor 4 (i=4): The definition of “loss or damage” is not clearly defined (may lead to disputes).
[0236] The total number of risk factors n is 4.
[0237] 4. Risk assessment;
[0238] By formula:
[0239]
[0240] Calculate the risk score of the contract terms; where w i is the weight of the contract clause corresponding to the ith risk factor, p i is the probability or impact of the i-th risk factor corresponding to the contract terms; n is the number of risk factors, and i is a positive integer;
[0241] Determine whether the risk score is greater than the preset threshold; if yes, it is judged as high risk; if no, it is judged as low risk.
[0242] The specific evaluation results are as follows:
[0243] Serial number Terms Risk Classification Risk Scoring 1 Party A shall compensate Party B for any loss or damage High risk 0.85 2 This agreement is valid for one year Low risk 0.10 3 Confidential information shall not be disclosed to third parties High risk 0.75 4 Payment must be made within 30 days of invoice date Low risk 0.20 5 Either party may terminate the agreement upon 30 days written notice Low risk 0.15
[0244] Through such classification and scoring, users can clearly understand which clauses in the contract pose higher risks and take appropriate measures to avoid them or strengthen management.
[0245] Part of the data in the above formula is calculated by removing the dimension and taking its numerical value. The formula is a formula closest to the actual situation obtained by software simulation of a large amount of collected data; the preset parameters and preset thresholds in the formula are set by technical personnel in this field according to actual conditions or obtained through simulation of a large amount of data.
[0246] The above embodiments are only used to illustrate the technical method of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.
Claims
1. A high-precision contract document parsing method based on a large model, characterized in that: include: Step 1: Get user input data; Step 2: Fine-tune the pre-trained model to obtain a query question and answer generation model, and process the query question and answer generation model based on the input data to obtain the query result; Step 3: Obtain recognition results by performing differential content recognition on the input data; Step 4: Conduct risk assessment on the input data and obtain the assessment results.
2. According to the high-precision contract document parsing method based on a large model according to claim 1, it is characterized in that: The obtaining of user input data comprises: Obtain the query and several documents that the user needs to input; wherein the several documents refer to the documents that the user needs to identify the differences in the contents of different versions of contract documents.
3. According to claim 1, a high-precision contract document parsing method based on a large model is characterized in that: The pre-trained model is fine-tuned, including: The pre-trained model is fine-tuned through fine-tuning technology to obtain a query question and answer generation model; wherein the fine-tuning technology includes: large model fine-tuning technology and LoRA fine-tuning technology; S1: Obtain relevant datasets based on fine-tuning tasks; S2: Set the hyperparameters in the fine-tuning process; hyperparameters include: learning rate, weight and loss function; S3: Further train the pre-trained model based on the dataset.
4. According to the high-precision contract document parsing method based on a large model as described in claim 1, it is characterized in that: The processing based on the input data by querying the question-answer generation model includes: Retrieve information related to the query input by the user based on the RAG technology, and generate an answer corresponding to the query input by the user based on the retrieved information; S1: obtaining query data by preprocessing the query input by the user; wherein the preprocessing includes: query parsing and query expansion; S2: Retrieve several candidate documents related to the query data from the existing text library through RAG technology; S3: Input the query and candidate documents entered by the user into the query question answering generation model to obtain the query result.
5. According to claim 1, a high-precision contract document parsing method based on a large model is characterized in that: The step of identifying the difference content of the input data includes: S1: Extract several documents input by the user; S2: converting a number of documents into an editable text format to obtain one-to-one comparison data of the documents; S3: Perform layout analysis on the data by comparing with the YOLO model to obtain the layout analysis result; extract text data from the layout analysis result by using OCR; wherein the YOLO model includes: YOLOv4, YOLOv5 or YOLOv8; S4: Compare text data extracted from several documents by using a text comparison method to obtain a comparison result; wherein the text comparison method includes: diff-match-patch, difflib; the comparison result includes: added, deleted and modified content.
6. According to the high-precision contract document parsing method based on a large model as described in claim 1, it is characterized in that: The risk assessment of input data includes: S1: extracting entities from historical text content; wherein the historical text content refers to the text content of historical documents; S2: Label the entities and integrate the historical text content and the corresponding labeled entities into training data; the labeling includes: entity category labeling and entity location labeling; S3: Train an artificial intelligence model based on the training data to obtain a named entity recognition model; wherein the artificial intelligence model includes: LSTM, BiLSTM-CRF or BERT; S4: Extract entities from the input document based on the named entity recognition model, and merge the extracted entities to obtain the contract terms in the document; S5: Input the contract terms into the pre-trained risk factor identification model for identification, and obtain the risk factors corresponding to the contract terms; S6: By formula: Calculate the risk score of the contract terms; where w i is the weight of the contract clause corresponding to the ith risk factor, p i is the probability or impact of the i-th risk factor corresponding to the contract terms; n is the number of risk factors, and i is a positive integer; S7: Determine whether the risk score is greater than a preset threshold; if yes, it is judged as high risk; if no, it is judged as low risk; wherein the preset threshold is set according to actual risk requirements.
7. A high-precision contract document parsing method based on a large model according to claim 6, characterized in that: The risk factor identification model obtained by pre-training includes: By integrating contract terms as standard input data, and integrating the risk factors corresponding to the contract terms as standard output data; The artificial intelligence model is trained based on standard input data and standard output data to obtain a risk factor identification model.
Citation Information
Patent Citations
Fine tuning training method of large language model, contract risk review method and system
CN116775879A
Question and answer result processing method and device, equipment, medium and program product
CN118503389A
Artificial intelligence-based legal document analysis system and method
WO2021040124A1
Cited By
Literature reading guiding method, system and equipment and medium
CN120670529A
End-side adaptive document structure understanding method and system
CN121706767A
An end-side adaptive document structure understanding method and system
CN121706767B
Generative document analysis system evaluation method and device
CN121809459A