Text semantic matching method and system for judging consistency of collection and sales contract subject matter
Through the contract subject consistency comparison model of twin network and cross attention mechanism, the problems of low accuracy and low efficiency of the consistency inspection of the subject matter of procurement and sales contract are solved, and efficient and accurate identification of false transactions is achieved, and diverse contract texts are adapted to.
Patent Information
- Application Number
- CN202510613364.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-08-19
AI Technical Summary
In the prior art, the consistency inspection method for purchasing and sales contract subject matter has low accuracy, low efficiency and poor adaptability, making it difficult to effectively identify false trade behaviors.
The contract subject consistency comparison model with a twin network structure is adopted, combined with the cross attention mechanism and similarity measurement module, text data processing is performed through the pre-trained language model RoBERTa, and procurement and sales contract data sets are constructed to make efficient consistency judgments.
It improves the accuracy and efficiency of the judgment of consistency of the subject matter of the procurement and sales contract, can identify subtle differences between the contract texts, timely discover false transactions, and protect the safety of corporate assets.
Smart Images

Figure CN120508635A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing, and in particular to a text semantic matching method and system for judging the consistency of the subject matter of a procurement and sales contract. Background Art
[0002] In modern business operations, procurement and sales are the core links connecting upstream and downstream supply chains, enabling the circulation of goods and the return of capital. To maintain production operations and expand market share, companies frequently sign procurement and sales contracts with suppliers and customers. These contracts detail key terms such as the description of the subject matter, quantity, price, quality, and delivery method and time.
[0003] To address the issue of fraudulent trade, checking the consistency of the subject matter in purchase and sales contracts is key to identifying fraudulent trade. Currently, there are roughly three methods for checking the consistency of the subject matter in purchase and sales contracts: manual review, where specialized personnel compare the subject matter descriptions in the purchase and sales contracts one by one to determine whether they are consistent. This method is time-consuming and labor-intensive, and susceptible to human error. Keyword matching, where a computer program matches keywords in the purchase and sales contract texts to determine whether the subject matter is identical, is susceptible to synonyms, near-synonyms, and different expressions, resulting in a high rate of false positives. Rule matching, where a series of rules are defined to perform pattern matching on the purchase and sales contract texts to identify inconsistencies, is complex to formulate and maintain, and is difficult to adapt to the diverse nature of contract texts. Therefore, designing an efficient, intelligent, highly accurate, and widely applicable method for determining the consistency of the subject matter in purchase and sales contracts has become an urgent challenge for enterprises. Summary of the Invention
[0004] In view of the above analysis, the present invention aims to provide a text semantic matching method and system for judging the consistency of the subject matter of procurement and sales contracts, so as to solve the problems of low accuracy, low efficiency and poor adaptability of the current consistency checking method of the subject matter of procurement and sales contracts.
[0005] The present invention provides a text semantic matching method and system for determining the consistency of the subject matter of a procurement and sales contract. The method comprises the following steps:
[0006] Set keywords related to the contract subject matter, extract the content corresponding to the keywords from the purchase and sales contract documents to obtain the purchase and sales contract subject matter text data, and pre-process the purchase and sales contract subject matter text data to construct the purchase and sales contract data sets;
[0007] Construct a contract subject matter consistency comparison model to input sample pairs of purchase and sales contract subject matter and output consistency judgment results of the purchase and sales contract subject matter;
[0008] Training the contract subject matter consistency comparison model based on the purchase and sales contract dataset to obtain a trained contract subject matter consistency comparison model;
[0009] The pre-processed text data of the purchase and sales contract subject matter to be tested is input into the trained contract subject matter consistency comparison model to obtain the consistency judgment result of the text data of the purchase and sales contract subject matter to be tested.
[0010] Furthermore, the contract subject matter consistency comparison model includes a twin network, a cross-attention mechanism module, a similarity measurement module, and a consistency judgment module;
[0011] The twin network is used to input the text data of the subject matter of the procurement and sales contract and output the fusion vector corresponding to the text data of the subject matter of the procurement and sales contract. The cross-attention mechanism module is used to input the fusion vector corresponding to the text data of the subject matter of the procurement and sales contract and output the global vector corresponding to the text data of the subject matter of the procurement and sales contract. The similarity measurement module is used to calculate the similarity between the global vectors corresponding to the text data of the subject matter of the procurement and sales contract. The consistency judgment module is used to obtain the consistency judgment result of the subject matter of the procurement and sales contract based on the calculation result of the similarity measurement module.
[0012] Furthermore, the twin network is composed of two sub-networks with identical structures and shared weights. Each sub-network is composed of a contract subject embedding representation learning module, which is used to represent the text data of the purchase and sales contract subject matter as a fusion vector.
[0013] The contract subject matter embedding representation learning module includes a word segmentation module, a contract subject matter text representation vector learning layer, and a contract subject matter text representation vector fusion layer;
[0014] The word segmentation module is based on the Jieba tool and is used to perform word segmentation on the input text data of the subject matter of the procurement and sales contract; the contract subject matter text representation vector learning layer is based on the pre-trained language model RoBERTa and is used to input the text data of the subject matter of the procurement and sales contract after word segmentation and output the word vector corresponding to the text data of the subject matter of the procurement and sales contract.
[0015] Furthermore, the contract subject matter text representation vector fusion layer includes a self-attention layer, a first residual connection and layer normalization module, a feedforward neural network layer, a second residual connection and layer normalization module, and a pooling layer connected in sequence; wherein the input of the contract subject matter text representation vector fusion layer is connected to the first residual connection and layer normalization module, and the output of the first residual connection and layer normalization module is connected to the second residual connection and layer normalization module.
[0016] Furthermore, the similarity between the text data of the subject matter of the purchase and sales contracts is calculated using the following formula:
[0017]
[0018] Where α and β are defined weights, and α + β = 1; n represents the total number of samples in the purchase / sales contract dataset, c Ai represents the global vector corresponding to the i-th sample in the procurement contract dataset, c Bi Represents the global vector corresponding to the i-th sample in the sales contract dataset.
[0019] Furthermore, the training of the contract subject matter consistency comparison model based on the procurement and sales contract dataset to obtain a trained contract subject matter consistency comparison model includes:
[0020] A sample set is constructed based on the procurement and sales contract datasets and annotated; a sample in the sample set includes a sample pair consisting of a sample in the procurement contract dataset and a sample in the sales contract dataset, as well as an annotated label;
[0021] The contract subject matter consistency comparison model is trained using the sample set until the loss function converges or a preset number of training times is reached, thereby obtaining a trained contract subject matter consistency comparison model.
[0022] Furthermore, constructing a sample set based on the procurement and sales contract dataset and labeling the sample set includes:
[0023] Randomly select one sample from each of the purchase contract dataset and the sales contract dataset to form a sample pair, which is expressed as: {(X Ai ,Y Ai ),(X Bj ,Y Bj )}; if Y Ai =Y Bj , and X Ai With X Bj If the corresponding contract subject matter text data is consistent, let Y = 1, otherwise let Y = 0, and use Y to mark the sample pair, thus forming a sample in the sample set, which is expressed as: (X Ai ,X Bj ,Y);
[0024] The samples in the purchase contract dataset and the sales contract dataset are traversed to form sample pairs and annotated to construct a sample set.
[0025] Furthermore, the loss function is expressed as:
[0026]
[0027] Among them, L S The loss caused when the text data label of the subject matter of the purchase contract is consistent with the text data label of the subject matter of the sales contract, L D The loss caused by the inconsistency between the text data label of the purchase contract subject matter and the text data label of the sales contract subject matter, S n represents the similarity between the purchase contract dataset sample and the sales contract dataset sample corresponding to the nth sample in the sample set, m represents the set threshold; Y n A binary label indicating whether the purchase contract dataset sample and the sales contract dataset sample corresponding to the nth sample in the sample set are consistent. If they are consistent, Y = 1, otherwise Y = 0; N represents the total number of samples in the sample set.
[0028] Furthermore, the pre-processing of the text data of the subject matter of the purchase and sales contracts to construct the purchase and sales contract datasets includes:
[0029] Clean and annotate the text data of the subject matter of purchase and sales contracts respectively;
[0030] The procurement contract dataset is constructed using the labeled text data of the procurement contract subject matter, and the sales contract dataset is constructed using the labeled text data of the sales contract subject matter.
[0031] Furthermore, the system includes:
[0032] The data processing module is used to extract the content corresponding to the keywords in the purchase and sales contract documents to obtain the text data of the purchase and sales contract subjects, and pre-process the text data of the purchase and sales contract subjects to construct the purchase and sales contract data sets;
[0033] A contract subject matter consistency comparison model generation module is used to construct a contract subject matter consistency comparison model and train the contract subject matter consistency comparison model based on the purchase and sales contract data set to obtain a trained contract subject matter consistency comparison model;
[0034] The consistency judgment module is used to input the sample pairs of the purchase and sales contract subject matter to be tested into the trained contract subject matter consistency comparison model, and output the consistency judgment results of the purchase and sales contract subject matter.
[0035] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0036] 1. The present invention analyzes and mines the text content of the subject matter of procurement and sales contracts, and learns the feature representation of the text data of the subject matter of procurement and sales contracts based on a pre-trained language model. It is not restricted by the type, style, or text type of the contract, and has a wide range of applications. It can meet the needs of enterprises for abnormal trade detection, promptly discover false transaction behaviors, improve the level of supervision, and protect the security of corporate assets.
[0037] 2. The present invention adopts a twin network structure to judge the consistency of the subject matter of procurement and sales contracts, and processes two contract texts at the same time, thereby improving processing efficiency; at the same time, it introduces a self-attention mechanism and a cross-attention mechanism to capture the key information in the text data of the subject matter of procurement and sales contracts and the difference information between the text data of the subject matter of procurement and sales contracts, thereby more effectively distinguishing the characteristics of different contract texts, thereby improving the accuracy and efficiency of the consistency judgment of the subject matter of procurement and sales contracts.
[0038] 3. The present invention improves the accuracy of similarity calculation results by weighted calculation of the similarity between the text data of the subject matter of procurement and sales contracts, and can identify subtle differences between the text data of the subject matter of contracts, thereby effectively identifying potential fraudulent transactions.
[0039] In the present invention, the above-mentioned technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of the present invention will be described in the following description, and some advantages will become apparent from the description or be learned through practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like parts throughout the drawings.
[0041] Figure 1 This is a flow chart of a text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to an embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram of a contract subject matter embedding representation learning module according to an embodiment of the present invention;
[0043] Figure 3 Schematic diagram of a contract subject matter consistency comparison model according to an embodiment of the present invention;
[0044] Figure 4 The block diagram of the text semantic matching system for judging the consistency of the subject matter of a procurement and sales contract according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0045] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, and are not used to limit the scope of the present invention.
[0046] A specific embodiment of the present invention discloses a text semantic matching method for determining the consistency of the subject matter of a procurement and sales contract. Figure 1 As shown, the method includes the following steps:
[0047] Step S1: Set keywords related to the contract subject matter, extract the content corresponding to the keywords from the purchase and sales contract documents to obtain the purchase and sales contract subject matter text data, and pre-process the purchase and sales contract subject matter text data to construct the purchase and sales contract data sets;
[0048] Step S2: Construct a contract subject matter consistency comparison model to input sample pairs of purchase and sales contract subject matters and output consistency judgment results of the purchase and sales contract subject matters;
[0049] Step S3: training the contract subject matter consistency comparison model based on the purchase and sales contract dataset to obtain a trained contract subject matter consistency comparison model;
[0050] Step S4: input the pre-processed text data of the purchase and sales contract subject matter to be tested into the trained contract subject matter consistency comparison model to obtain the consistency judgment result of the text data of the purchase and sales contract subject matter to be tested.
[0051] Specifically, in step S1, the same number of purchase and sales contract documents are obtained from the business system, the terms of different parts of the contracts are analyzed, and keywords are selected from the terms corresponding to the subject matter of the contracts to set keywords related to the subject matter of the contracts. The keywords related to the subject matter of the contracts include "subject matter of the contract," "contents of the goods," "subject matter terms," and "product order details."
[0052] Specifically, the corresponding subject matter clauses are extracted from the purchase contract document and the sales contract document respectively through the keywords to obtain the purchase contract subject matter text data and the sales contract subject matter text data.
[0053] It should be noted that for Word-type contract files, the content of the contract subject matter clauses can be directly extracted; for PDF and image-type contract files, the content of the contract subject matter clauses is converted into text using OCR technology, and then the content of the contract subject matter clauses is extracted.
[0054] Furthermore, the pre-processing of the text data of the subject matter of the purchase and sales contracts to construct the purchase and sales contract datasets includes:
[0055] Clean and annotate the text data of the subject matter of purchase and sales contracts respectively;
[0056] The procurement contract dataset is constructed using the labeled text data of the procurement contract subject matter, and the sales contract dataset is constructed using the labeled text data of the sales contract subject matter.
[0057] Specifically, the text cleaning and annotation of the purchase and sales contract subject matter text data includes:
[0058] Remove symbols, blanks, line breaks, special symbols and other irrelevant characters from the text data of the subject matter of the purchase and sales contracts to complete the text cleaning;
[0059] According to the transaction content of the purchase and sales contracts, the text data of the subject matter of the purchase and sales contracts after text cleaning are marked respectively.
[0060] It should be noted that the transaction content of a purchase or sales contract refers to the goods or services involved in the contract, such as steel trading contracts, coal trading contracts, software trading contracts, etc.
[0061] Specifically, the procurement contract dataset is constructed using the labeled procurement contract subject matter text data, which is expressed as: D A =((X A1 ,Y A1 ),(X A2 ,Y A2 ),…,(X An ,Y An )), where X Ai ,i∈(1,n) represents the subject matter text data of the i-th procurement contract, Y Ai ,i∈(1,n) represents the label of the text data of the i-th purchase contract subject matter. The sales contract dataset is constructed using the labeled sales contract subject matter text data, which is expressed as: D B =((X B1 ,Y B1 ),(X B2 ,Y B2 ),…,(X Bn ,Y Bn )), where X Bi ,i∈(1,n) represents the subject matter text data of the i-th sales contract, Y Bi ,i∈(1,n) represents the label of the text data of the i-th sales contract subject matter.
[0062] Specifically, in step S2, if Figure 2As shown, the contract subject consistency comparison model includes a twin network, a cross-attention mechanism module, a similarity measurement module, and a consistency judgment module. The twin network is used to input the text data of the purchase and sales contract subject matter and output the fusion vector corresponding to the purchase and sales contract subject matter text data. The cross-attention mechanism module is used to input the fusion vector corresponding to the purchase and sales contract subject matter text data and output the global vector corresponding to the purchase and sales contract subject matter text data. The similarity measurement module is used to calculate the similarity between the global vectors corresponding to the purchase and sales contract subject matter text data. The consistency judgment module is used to obtain the consistency judgment result of the purchase and sales contract subject matter based on the calculation result of the similarity measurement module.
[0063] Furthermore, the twin network is composed of two sub-networks with the same structure and shared weights. Each sub-network is composed of a contract subject embedding representation learning module, which is used to represent the text data of the procurement and sales contract subject matter as a fusion vector.
[0064] Furthermore, if Figure 3 As shown, the contract subject matter embedding representation learning module includes a word segmentation module, a contract subject matter text representation vector learning layer, and a contract subject matter text representation vector fusion layer.
[0065] Furthermore, the word segmentation module is based on the Jieba tool, which is used to segment the input text data of the subject matter of the purchase and sales contract, cutting the continuous text into meaningful words or phrases, and providing a basis for subsequent efficient and accurate information processing and analysis.
[0066] Specifically, after word segmentation of the procurement contract dataset, it is represented as: w A1 ,w A2 ,…,w An =Jieba(X A1 ,X A2 ,…,X An ), where w Ai , i∈(1,n) represents the data of the i-th sample in the procurement contract dataset after word segmentation. After word segmentation of the sales contract dataset, it is expressed as: w B1 ,w B2 ,…,w Bn =Jieba(X B1 ,X B2 ,…,X Bn ), where w Bi ,i∈(1,n) represents the data after word segmentation of the i-th sample in the sales contract dataset.
[0067] Furthermore, the contract subject matter text representation vector learning layer is based on the pre-trained language model RoBERTa, which is used to input the procurement and sales contract subject matter text data after word segmentation and output the word vector corresponding to the procurement and sales contract subject matter text data.
[0068] Specifically, the segmented text data of the subject matter of the procurement and sales contract is input into the contract subject matter text representation vector learning layer, and after analysis and processing by the RoBERTa model, the word vector marked with [CLS] is output as the word vector corresponding to the text data of the subject matter of the procurement and sales contract.
[0069] Specifically, the procurement contract dataset after word segmentation is input into the contract subject matter text representation vector learning layer, and the word vector representation corresponding to the output procurement contract dataset is: H A =[H A1 ,H A2 ,…,H An ]=RoBERTa(w A1 ,w A2 ,…,w An ), where H Ai , i∈(1,n) represents the word vector corresponding to the i-th sample in the procurement contract dataset after word segmentation; the sales contract dataset after word segmentation is input into the contract subject matter text representation vector learning layer, and the word vector corresponding to the output sales contract dataset is represented as: H B =[H B1 ,H B2 ,…,H Bn ]=RoBERTa(w B1 ,w B2 ,…,w Bn ), where H Bi ,i∈(1,n) represents the word vector corresponding to the i-th sample in the sales contract dataset after word segmentation.
[0070] It should be noted that the RoBERTa natural language processing model has been pre-trained on a large amount of publicly available text data and is highly capable of understanding text semantics. However, since the contract subject matter text representation vector learning layer requires extensive data training to learn word semantic representations, and internal enterprise training data is limited, insufficient learning samples can lead to inadequate word semantic representation learning and model underfitting. To avoid this problem, the present invention uses RoBERTa for the contract subject matter text representation vector learning layer.
[0071] Furthermore, the contract subject matter text representation vector fusion layer includes a self-attention layer, a first residual connection and layer normalization module, a feedforward neural network layer, a second residual connection and layer normalization module, and a pooling layer connected in sequence; wherein the input of the contract subject matter text representation vector fusion layer is connected to the first residual connection and layer normalization module, and the output of the first residual connection and layer normalization module is connected to the second residual connection and layer normalization module.
[0072] Specifically, the self-attention layer is used to capture the global dependency between words in the word vectors corresponding to the text data of the purchase contract subject matter and the word vectors corresponding to the text data of the sales contract subject matter, and generate a context-aware representation of each word, including linear transformation, calculation of self-attention weights, and weighted summation. The linear transformation transforms the word vectors through the weight matrix W Q 、W K 、W V , mapped to query (Query), key (Key) and value (Value) vectors:
[0073] Q=H·W Q ,K=H·W K ,V=H·W V ,
[0074] Among them, H represents the word vector output by RoBERTa, W Q 、W K 、W V They represent the query weight matrix, key weight matrix, and value weight matrix respectively, and Q, K, and V represent the query vector, key vector, and value vector respectively.
[0075] The self-attention weight matrix is obtained by the following formula:
[0076]
[0077] Among them, K T represents the transpose of K, d k is the dimension of the key vector; the softmax function is used to convert the self-attention weight into a probability distribution, which represents the self-attention weight of the query vector Q for each key vector K, and realizes the normalization of the self-attention weight.
[0078] The output of the self-attention layer is obtained by the following formula:
[0079] O Attn =Attn·V.
[0080] Specifically, the first and second residual connections and layer normalization modules are used to alleviate gradient vanishing and improve the convergence of the model. The expressions of the first residual connection and layer normalization modules are:
[0081] Onorm1 =LayerNorm(H+O Attn ),
[0082] Among them, LayerNorm() represents layer normalization.
[0083] It can be understood that through the self-attention layer, the first residual connection and the layer normalization module, the contract subject consistency comparison model can dynamically focus on important information at different positions in the text of the procurement and sales contract subject matter, and enhance the semantic representation capability.
[0084] Specifically, the feedforward neural network layer includes two fully connected layers and a ReLU activation function, which is used to perform nonlinear transformation on the output of the self-attention layer, further extract features, enhance the expressive power of the contract subject consistency comparison model, and capture more complex semantic information.
[0085] The expression of the second residual connection and layer normalization module is:
[0086] O norm2 =LayerNorm( FFN +O norm1 ),
[0087] Among them, O FFN Represents the output of a feed-forward neural network layer.
[0088] Specifically, the pooling layer is used to perform a maximum pooling operation on the output of the feedforward neural network layer to generate a global vector representation of a fixed length and obtain the final fusion vector p∈R L×D :
[0089] p=Max Pooling(O norm2 ),
[0090] Where L represents the length of the fusion vector p, and D represents the dimension of the fusion vector p.
[0091] It should be noted that a fusion vector p integrates all attributes of the text data of the subject matter of a purchase or sales contract, including but not limited to: the name of the subject matter, model specifications, brand, and other characteristics that reflect the content of the contract subject matter.
[0092] Specifically, the procurement contract dataset D A The fusion vector corresponding to the output of the input twin network is expressed as: p A =[p A1 ,p A2 ,…,p An ], where p Ai , i∈(1,n) represents the fusion vector corresponding to the i-th sample in the purchase contract dataset; the sales contract dataset DB The fusion vector corresponding to the output of the input twin network is expressed as: p B =[p B1 ,p B2 ,…,p Bn ], where p Bi ,i∈(1,n) represents the fusion vector corresponding to the i-th sample in the sales contract dataset.
[0093] Furthermore, the cross-attention mechanism module is used to input the fusion vector corresponding to the text data of the subject matter of the procurement and sales contract, and output the global vector corresponding to the text data of the subject matter of the procurement and sales contract, including calculating the cross-attention weight, weighted summation, and splicing, so that the two sub-networks can pay attention to each other's important information, and thus capture the correlation between the text data of the subject matter of the procurement and sales contract.
[0094] Specifically, the cross attention weight matrix is obtained by the following formula:
[0095]
[0096] Among them, A AB A represents the cross attention weight of the text data features of the purchase contract subject matter with respect to the text data features of the sales contract subject matter, BA W represents the cross attention weight of the text data features of the sales contract subject matter with respect to the text data features of the purchase contract subject matter. QC and W KC represents the linear transformation matrix, P A represents the fusion vector corresponding to the text data of the procurement contract subject matter, P B represents the fusion vector corresponding to the text data of the sales contract subject matter, D k Indicates the dimension of the key vector.
[0097] The context vector corresponding to the text data of the purchase and sales contract subject matter is obtained by weighted summation using the following formula:
[0098] E A =p B ·A AB ,
[0099] E B =p A ·A BA ,
[0100] Among them, E A The context vector corresponding to the text data of the subject matter of the purchase contract is a contextual representation of the text data of the subject matter of the purchase contract based on the text data of the subject matter of the sales contract, and includes information related to the text data of the subject matter of the sales contract in the text data of the subject matter of the purchase contract; E BThe context vector corresponding to the text data of the subject matter of the sales contract is a contextual representation of the text data of the subject matter of the sales contract based on the text data of the subject matter of the purchase contract, and includes information in the text data of the subject matter of the sales contract that is related to the text data of the subject matter of the purchase contract.
[0101] Furthermore, the global vector corresponding to the text data of the purchase and sales contract subject matter is obtained by the following formula:
[0102] C A =Concatenate(p A +E A ),
[0103] C B =Concatenate(p B +E B ),
[0104] Among them, Concatenate() means concatenation.
[0105] Specifically, the fusion vector p corresponding to the procurement contract dataset A Input the global vector corresponding to the output of the cross attention mechanism module, expressed as: C A =(c a1 ,c a2 ,…,c an ), where c Ai , i∈(1,n) represents the global vector corresponding to the i-th sample in the procurement contract dataset; the fusion vector p corresponding to the sales contract dataset B Input the global vector corresponding to the output of the cross attention mechanism module, expressed as: C B =(c b1 ,c b2 ,…,c bn ), where c Bi ,i∈(1,n) represents the global vector corresponding to the i-th sample in the sales contract dataset.
[0106] It should be noted that the global vector corresponding to the text data of the subject matter of the procurement contract contains all the semantic information of the text data of the subject matter of the procurement contract and the relevant information in the text data of the subject matter of the sales contract; the global vector corresponding to the text data of the subject matter of the sales contract contains all the semantic information of the text data of the subject matter of the sales contract and the relevant information in the text data of the subject matter of the procurement contract.
[0107] Furthermore, the similarity measurement module is used to calculate the similarity between the text data of the subject matter of the purchase and sales contracts.
[0108] Specifically, the similarity between the text data of the subject matter of the purchase and sales contracts is calculated using the following formula:
[0109]
[0110] Where α and β are defined weights, and α + β = 1; n represents the total number of samples in the purchase / sales contract dataset, c Ai represents the global vector corresponding to the i-th sample in the procurement contract dataset, c Bi Represents the global vector corresponding to the i-th sample in the sales contract dataset.
[0111] Furthermore, the consistency judgment module is used to judge the calculation result of the similarity measurement module and output the consistency judgment result.
[0112] Specifically, when the calculation result of the similarity measurement module exceeds the preset threshold, it outputs 1, indicating that the text data of the subject matter of the procurement and sales contracts are consistent; otherwise, it outputs 0, indicating that the text data of the subject matter of the procurement and sales contracts are inconsistent.
[0113] Specifically, in step S3, the training of the contract subject matter consistency comparison model based on the procurement and sales contract dataset to obtain a trained contract subject matter consistency comparison model includes:
[0114] A sample set is constructed based on the procurement and sales contract datasets and annotated; a sample in the sample set includes a sample pair consisting of a sample in the procurement contract dataset and a sample in the sales contract dataset, as well as an annotated label;
[0115] The contract subject matter consistency comparison model is trained using the sample set until the loss function converges or a preset number of training times is reached, thereby obtaining a trained contract subject matter consistency comparison model.
[0116] Specifically, constructing and labeling a sample set based on a procurement and sales contract dataset includes:
[0117] Randomly select one sample from each of the purchase contract dataset and the sales contract dataset to form a sample pair, which is expressed as: {(X Ai ,Y Ai ),(X Bj ,Y Bj )}; if Y Ai =Y Bj , and X Ai With X Bj If the corresponding contract subject matter text data is consistent, let Y = 1, otherwise let Y = 0, and use Y to mark the sample pair, thus forming a sample in the sample set, which is expressed as: (X Ai ,XBj ,Y);
[0118] The samples in the purchase contract dataset and the sales contract dataset are traversed to form sample pairs and annotated to construct a sample set.
[0119] Specifically, the expression of the loss function is:
[0120]
[0121] Among them, L S The loss caused when the text data label of the subject matter of the purchase contract is consistent with the text data label of the subject matter of the sales contract, L D The loss caused by the inconsistency between the text data label of the purchase contract subject matter and the text data label of the sales contract subject matter, S n represents the similarity between the purchase contract dataset sample and the sales contract dataset sample corresponding to the nth sample in the sample set, m represents the set threshold; Y n A binary label indicating whether the purchase contract dataset sample and the sales contract dataset sample corresponding to the nth sample in the sample set are consistent. If they are consistent, Y = 1, otherwise Y = 0; N represents the total number of samples in the sample set.
[0122] Specifically, in step S4, the purchase and sales contracts to be tested are obtained. The text data of the subject matter of the purchase and sales contracts to be tested is obtained according to the method in step S1, and the text data of the subject matter of the purchase and sales contracts to be tested is cleaned. The cleaned text data of the subject matter of the purchase and sales contracts to be tested is input into the trained contract subject matter consistency comparison model to obtain a consistency judgment result of the text data of the subject matter of the purchase and sales contracts to be tested. If the text data of the subject matter of the purchase and sales contracts to be tested is consistent, the contract subject matter consistency comparison model outputs 1; otherwise, it outputs 0.
[0123] Another specific embodiment of the present invention discloses a text semantic matching system for judging the consistency of the subject matter of a procurement and sales contract. Figure 4 As shown, the system includes:
[0124] The data processing module is used to extract the content corresponding to the keywords in the purchase and sales contract documents to obtain the text data of the purchase and sales contract subjects, and pre-process the text data of the purchase and sales contract subjects to construct the purchase and sales contract data sets;
[0125] A contract subject matter consistency comparison model generation module is used to construct a contract subject matter consistency comparison model and train the contract subject matter consistency comparison model based on the purchase and sales contract data set to obtain a trained contract subject matter consistency comparison model;
[0126] The consistency judgment module is used to input the sample pairs of the purchase and sales contract subject matter to be tested into the trained contract subject matter consistency comparison model, and output the consistency judgment results of the purchase and sales contract subject matter.
[0127] Specifically, the contract subject matter consistency comparison model includes a twin network, a cross-attention mechanism module, a similarity measurement module, and a consistency judgment module. The twin network is composed of two sub-networks with identical structures and shared weights. Each sub-network is composed of a contract subject matter embedding representation learning module, which is used to represent the text data of the purchase and sales contract subject matter as a fusion vector. The contract subject matter embedding representation learning module includes a word segmentation module, a contract subject matter text representation vector learning layer, and a contract subject matter text representation vector fusion layer.
[0128] Compared with the prior art, the text semantic matching method and system for determining the consistency of the subject matter of a procurement and sales contract provided by the present invention has the following beneficial effects:
[0129] 1. The present invention analyzes and mines the text content of the subject matter of procurement and sales contracts, and learns the feature representation of the text data of the subject matter of procurement and sales contracts based on a pre-trained language model. It is not restricted by the type, style, or text type of the contract, and has a wide range of applications. It can meet the needs of enterprises for abnormal trade detection, promptly discover false transaction behaviors, improve the level of supervision, and protect the security of corporate assets.
[0130] 2. The present invention adopts a twin network structure to judge the consistency of the subject matter of procurement and sales contracts, and processes two contract texts at the same time, thereby improving processing efficiency; at the same time, it introduces a self-attention mechanism and a cross-attention mechanism to capture the key information in the text data of the subject matter of procurement and sales contracts and the difference information between the text data of the subject matter of procurement and sales contracts, thereby more effectively distinguishing the characteristics of different contract texts, thereby improving the accuracy and efficiency of the consistency judgment of the subject matter of procurement and sales contracts.
[0131] 3. The present invention improves the accuracy of similarity calculation results by weighted calculation of the similarity between the text data of the subject matter of procurement and sales contracts, and can identify subtle differences between the text data of the subject matter of contracts, thereby effectively identifying potential fraudulent transactions.
[0132] Those skilled in the art will appreciate that all or part of the process steps of the above-described embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, such as a magnetic disk, an optical disk, a read-only memory, or a random access memory.
[0133] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.
Claims
1. A text semantic matching method for determining the consistency of the subject matter of a procurement and sales contract, characterized in that: The method comprises the following steps: Set keywords related to the contract subject matter, extract the content corresponding to the keywords from the purchase and sales contract documents to obtain the purchase and sales contract subject matter text data, and pre-process the purchase and sales contract subject matter text data to construct the purchase and sales contract data sets; Construct a contract subject matter consistency comparison model to input sample pairs of purchase and sales contract subject matter and output consistency judgment results of the purchase and sales contract subject matter; Training the contract subject matter consistency comparison model based on the purchase and sales contract dataset to obtain a trained contract subject matter consistency comparison model; The pre-processed text data of the purchase and sales contract subject matter to be tested is input into the trained contract subject matter consistency comparison model to obtain the consistency judgment result of the text data of the purchase and sales contract subject matter to be tested.
2. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 1 is characterized in that: The contract subject consistency comparison model includes a twin network, a cross-attention mechanism module, a similarity measurement module, and a consistency judgment module; The twin network is used to input the text data of the subject matter of the procurement and sales contract and output the fusion vector corresponding to the text data of the subject matter of the procurement and sales contract. The cross-attention mechanism module is used to input the fusion vector corresponding to the text data of the subject matter of the procurement and sales contract and output the global vector corresponding to the text data of the subject matter of the procurement and sales contract. The similarity measurement module is used to calculate the similarity between the global vectors corresponding to the text data of the subject matter of the procurement and sales contract. The consistency judgment module is used to obtain the consistency judgment result of the subject matter of the procurement and sales contract based on the calculation result of the similarity measurement module.
3. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 2 is characterized in that: The twin network consists of two sub-networks with identical structures and shared weights. Each sub-network consists of a contract subject embedding representation learning module, which is used to represent the text data of the purchase and sales contract subject matter as a fusion vector. The contract subject matter embedding representation learning module includes a word segmentation module, a contract subject matter text representation vector learning layer, and a contract subject matter text representation vector fusion layer; The word segmentation module is based on the Jieba tool and is used to perform word segmentation on the input text data of the subject matter of the procurement and sales contract; the contract subject matter text representation vector learning layer is based on the pre-trained language model RoBERTa and is used to input the text data of the subject matter of the procurement and sales contract after word segmentation and output the word vector corresponding to the text data of the subject matter of the procurement and sales contract.
4. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 3 is characterized in that: The contract subject matter text representation vector fusion layer includes a self-attention layer, a first residual connection and layer normalization module, a feedforward neural network layer, a second residual connection and layer normalization module, and a pooling layer connected in sequence; wherein the input of the contract subject matter text representation vector fusion layer is connected to the first residual connection and layer normalization module, and the output of the first residual connection and layer normalization module is connected to the second residual connection and layer normalization module.
5. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 1 is characterized in that: The similarity between the text data of the subject matter of the purchase and sales contracts is calculated using the following formula: Where α and β are defined weights, and α + β = 1; n represents the total number of samples in the purchase / sales contract dataset, c Ai represents the global vector corresponding to the i-th sample in the procurement contract dataset, c Bi Represents the global vector corresponding to the i-th sample in the sales contract dataset.
6. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 1 is characterized in that: The step of training the contract subject matter consistency comparison model based on the procurement and sales contract dataset to obtain a trained contract subject matter consistency comparison model includes: A sample set is constructed based on the procurement and sales contract datasets and annotated; a sample in the sample set includes a sample pair consisting of a sample in the procurement contract dataset and a sample in the sales contract dataset, as well as an annotated label; The contract subject matter consistency comparison model is trained using the sample set until the loss function converges or a preset number of training times is reached, thereby obtaining a trained contract subject matter consistency comparison model.
7. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 6 is characterized in that: The construction and annotation of a sample set based on the procurement and sales contract dataset includes: Randomly select one sample from each of the purchase contract dataset and the sales contract dataset to form a sample pair, which is expressed as: {(X Ai ,Y Ai ),(X Bj ,Y Bj )}; if Y Ai =Y Bj , and X Ai With X Bj If the corresponding contract subject matter text data is consistent, let Y = 1, otherwise let Y = 0, and use Y to mark the sample pair, thus forming a sample in the sample set, which is expressed as: (X Ai ,X Bj ,Y); The samples in the purchase contract dataset and the sales contract dataset are traversed to form sample pairs and annotated to construct a sample set.
8. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 6 is characterized in that: The expression of the loss function is: Among them, L S The loss caused when the text data label of the subject matter of the purchase contract is consistent with the text data label of the subject matter of the sales contract, L D The loss caused by the inconsistency between the text data label of the purchase contract subject matter and the text data label of the sales contract subject matter, S n represents the similarity between the purchase contract dataset sample and the sales contract dataset sample corresponding to the nth sample in the sample set, m represents the set threshold; Y n A binary label indicating whether the purchase contract dataset sample and the sales contract dataset sample corresponding to the nth sample in the sample set are consistent. If they are consistent, Y = 1, otherwise Y = 0; N represents the total number of samples in the sample set.
9. The text semantic matching method for determining consistency of the subject matter of a procurement and sales contract according to claim 1 is characterized in that: The preprocessing of the text data of the subject matter of the purchase and sales contracts to construct the purchase and sales contract datasets includes: Clean and annotate the text data of the subject matter of purchase and sales contracts respectively; The procurement contract dataset is constructed using the labeled text data of the procurement contract subject matter, and the sales contract dataset is constructed using the labeled text data of the sales contract subject matter.
10. A text semantic matching system for judging the consistency of the subject matter of a procurement and sales contract, characterized in that: The system comprises: The data processing module is used to extract the content corresponding to the keywords in the purchase and sales contract documents to obtain the text data of the purchase and sales contract subjects, and pre-process the text data of the purchase and sales contract subjects to construct the purchase and sales contract data sets; A contract subject matter consistency comparison model generation module is used to construct a contract subject matter consistency comparison model and train the contract subject matter consistency comparison model based on the purchase and sales contract data set to obtain a trained contract subject matter consistency comparison model; The consistency judgment module is used to input the sample pairs of the purchase and sales contract subject matter to be tested into the trained contract subject matter consistency comparison model, and output the consistency judgment results of the purchase and sales contract subject matter.
Citation Information
Cited By
Bidding scene-oriented cross-document semantic consistency verification system
CN121543581A
A cross-document semantic consistency checking system for a bidding scene
CN121543581B