Document similarity comparison method and system based on deep semantics and shallow layout
By using a method based on twin networks and combining deep semantics and shallow layout features, the problem of low accuracy of document similarity comparison in the existing technology is solved, and more efficient plagiarism detection and identification are achieved.
Patent Information
- Application Number
- CN202411351691.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-21
AI Technical Summary
The prior art is difficult to effectively capture the deep semantic and shallow layout features of documents, resulting in low accuracy when dealing with complex plagiarism situations.
The method based on the twin network architecture is adopted to learn the deep semantic characteristics of the documentation and the shallow layout characteristics through the twin network model, and combined with the pre -trained two -class classification model.
It significantly improves the accuracy of document similarity comparison, can better identify plagiarism documents that have been rewritten or structural adjustment, reduce misjudgment rates, and adapt to various types of document types and plagiarism forms.
Smart Images

Figure CN119337856A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing and document analysis, and in particular to a document similarity comparison method and system based on deep semantics and shallow layout. The method uses deep learning technology, especially a twin network model, to analyze and compare the content and structure of documents to detect potential plagiarism. Background Art
[0002] With the rapid development of information technology, the degree of digitalization of documents is constantly improving, and document similarity comparison and plagiarism detection are becoming more and more important. Traditional document similarity comparison methods often use technologies such as keyword matching and string matching, which mainly focus on the surface features of the text and are difficult to capture the deep semantic information and structural layout features of the document. These methods often perform poorly when dealing with complex plagiarism situations, such as texts with similar meanings but different expressions, or carefully rewritten documents.
[0003] In recent years, deep learning technology has made significant progress in the field of natural language processing. However, most existing deep learning-based document similarity comparison methods still only focus on the semantic features of the text, ignoring the layout structure information of the document. This approach may lead to the inability to accurately identify plagiarized documents that have been carefully typeset or structured in some cases.
[0004] In summary, the inventors have found that traditional document duplication detection technology can only find literal similarities between documents, but cannot measure the semantic similarities between documents well. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a document similarity comparison method and system based on deep semantics and shallow layout, aiming to solve the problems existing in the prior art.
[0006] To achieve the above object, in a first aspect, the present invention provides a document similarity comparison method based on deep semantics and shallow layout, which comprises the following steps:
[0007] S1: Build a twin network model based on the twin network architecture;
[0008] S2: Obtain training data, wherein the training data includes annotated document sample groups, wherein each document sample group includes two training documents and their similarity annotation values;
[0009] S3: Using the training data to train the twin network model, so that the twin network model can simultaneously learn the deep semantic features and shallow layout features of the training document;
[0010] S4: Using the trained twin network model to perform feature extraction and similarity calculation on the two documents to be compared, to obtain the similarity of the documents to be compared;
[0011] S5: Based on the calculated similarity of the documents to be compared, use the pre-trained binary classification model to determine whether there is a plagiarism relationship between the two documents to be compared.
[0012] In some possible implementations, the twin network model includes two neural network branches with the same structure and a similarity calculation module, and each neural network branch includes:
[0013] A first sub-network for extracting deep semantic features of a document, wherein the first sub-network processes text in the document using a pre-trained XLNet model to obtain a semantic representation vector of the document, and uses the semantic representation vector of the document as the deep semantic feature of the document;
[0014] A second sub-network for extracting shallow layout features of a document, wherein the second sub-network uses a convolutional neural network (CNN) to obtain layout features of a local position of the document; uses a gated recurrent unit (GRU) to obtain global layout features of the document; and integrates the layout features of the local position of the document and the global layout features of the document to generate shallow layout features of the document;
[0015] A fusion layer for fusing the outputs of the first sub-network and the second sub-network, wherein the fusion layer fuses the deep semantic features and the shallow layout features of the document and outputs a comprehensive feature representation of the document;
[0016] The similarity calculation module is used to calculate the similarity between the comprehensive feature representations of the documents output by the two neural network branches respectively.
[0017] In some possible implementations, the training process of the twin network model includes:
[0018] S31: inputting two training documents in each document sample group into two neural network branches of the twin network model respectively;
[0019] S32: in each neural network branch, respectively extracting deep semantic features and shallow layout features of the input training document;
[0020] S33: combining the deep semantic features of the training document and the shallow layout features through the fusion layer to obtain a comprehensive feature representation of each training document;
[0021] S34: Calculate the similarity between the comprehensive feature representations output by the two neural network branches to obtain the prediction similarity;
[0022] S35: Optimizing the parameters of the twin network model by minimizing the difference between the predicted similarity and the similarity annotation value in the document sample group.
[0023] In some possible implementations, step S4 specifically includes:
[0024] S41: inputting two documents to be compared into two neural network branches of the twin network model respectively;
[0025] S42: Automatically extracting the deep semantic features and shallow layout features of each document to be compared through the two neural network branches, and obtaining a comprehensive feature representation of each document to be compared through the fusion layer, wherein the comprehensive feature representation includes fusion information of the deep semantic features and shallow layout features of the document to be compared;
[0026] S43: Based on the comprehensive feature representation of the two documents to be compared, the similarity between them is calculated to obtain the similarity of the documents to be compared.
[0027] In some possible implementations, the specific processing process of step S5 includes:
[0028] S51: using the similarity of the documents to be compared calculated in step S4 as an input feature of the binary classification model;
[0029] S52: using a pre-trained binary classification model to process input features, the binary classification model includes one of logistic regression, support vector machine or neural network, and outputs a probability value between 0 and 1, indicating the possibility that there is a plagiarism relationship between the two documents;
[0030] S53: setting a threshold value, if the probability value outputted in step S52 is greater than or equal to the threshold value, it is determined that there is a plagiarism relationship between the two documents to be compared, otherwise it is determined that there is no plagiarism relationship;
[0031] S54: Output the determination result, which includes a Boolean value of whether a plagiarism relationship exists and a corresponding probability value.
[0032] In some possible implementations, the XLNet model has the following features:
[0033] Adopting the Transformer-XL architecture, including: using a segment-level recursive mechanism, which is used to establish dependencies across multiple text segments by caching the hidden state of the previous segment; a module with a memory function, which is used to store and utilize the hidden state information of the previous text segments; using a relative position encoding mechanism instead of an absolute position encoding mechanism;
[0034] During the pre-training process, mask operations are not used, but rather permutation operations are used to achieve bidirectional capture of text context features; the text context features refer to the semantic associations and dependencies between words in the text, including word order, grammatical structure, and semantic connections; the text context features are part of the deep semantic features and are captured through the pre-training process of the XLNet model.
[0035] In some possible implementations, the method further includes S6: a step of performing incremental learning on the twin network model, specifically including:
[0036] S61: Regularly collect new document samples and corresponding similarity annotations;
[0037] S62: Use the collected new document samples to fine-tune the trained twin network model. The specific steps include:
[0038] Freeze the first 75% to 90% of the parameter layers of the Siamese network model and only update the last 10% to 25% of the parameter layers;
[0039] Use a learning rate no more than 1 / 5 to 1 / 20 of the initial learning rate for gradient updates;
[0040] A training strategy with batch sizes ranging from 16 to 64 was used, mixing new document samples with 10% to 30% randomly selected old document samples for training;
[0041] S63: Update the document index library and add the feature representation of the new document sample to the index; wherein the feature representation of the new document sample refers to the vector representation obtained by encoding the new document through the fine-tuned twin network model; the feature representation of the new document sample includes the semantic information, structural information and context information of the document, which is compressed into a vector of fixed dimension;
[0042] The process of obtaining the feature representation of a new document sample is as follows:
[0043] Input new document samples into the fine-tuned Siamese network model;
[0044] The fine-tuned twin network model processes new document samples and gradually extracts and combines features at different levels in each layer, including word-level features, sentence-level features, and document-level features;
[0045] The last layer of the fine-tuned twin network model outputs the feature representation vector of the new document sample. The feature representation vector is a comprehensive representation of all deep semantic features from word-level features to document-level features extracted by each layer of the fine-tuned twin network model.
[0046] In a second aspect, a document similarity comparison system based on deep semantics and shallow layout is provided, which includes:
[0047] The twin network model building module is used to build a twin network model based on the twin network architecture;
[0048] A training data acquisition module, used to acquire training data, wherein the training data includes annotated document sample groups, wherein each document sample group includes two training documents and their similarity annotation values;
[0049] A model training module, used to train the twin network model using the training data, so that the twin network model can simultaneously learn the deep semantic features and shallow layout features of the training documents;
[0050] A feature extraction and similarity calculation module is used to use the trained twin network model to perform feature extraction and similarity calculation on two documents to be compared, so as to obtain the similarity of the documents to be compared;
[0051] The plagiarism judgment module is used to judge whether there is a plagiarism relationship between two documents to be compared based on the calculated similarity of the documents to be compared and using a pre-trained binary classification model.
[0052] According to a third aspect, an electronic device is provided, the electronic device comprising:
[0053] at least one processor; and,
[0054] a memory communicatively connected to the at least one processor; wherein,
[0055] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the aforementioned document similarity comparison methods based on deep semantics and shallow layout.
[0056] In a fourth aspect, a non-transitory computer-readable storage medium is provided, which stores computer instructions for causing the computer to execute any one of the aforementioned document similarity comparison methods based on deep semantics and shallow layout.
[0057] The above technical solution has the following beneficial effects:
[0058] By considering both the deep semantic features and the shallow layout features of the document, the method can more comprehensively capture the content and structural information of the document. This comprehensive analysis can significantly improve the accuracy of similarity comparison, especially when dealing with plagiarized documents that have been cleverly rewritten or reformatted.
[0059] The use of the twin network model of the present invention enables the system to learn more complex and abstract document feature representations. Compared with traditional rule-based or simple statistical methods, this deep learning method has stronger generalization ability and robustness, and can better cope with various complex plagiarism situations.
[0060] By training the twin network model, the system can automatically learn and adapt to the characteristics of different types of documents. This adaptive ability makes the method widely applicable to document similarity comparison tasks in various fields, such as academic papers, news reports, legal documents, etc.
[0061] The present invention combines the analysis method of deep semantics and shallow layout features to better distinguish true plagiarism from legitimate citations or similar expressions, which helps to reduce the rate of false positives and reduce the number of false accusations against non-plagiarized documents.
[0062] The method of the present invention is based on a deep learning model and has good scalability. It can effectively process large-scale document repositories and meet the needs of massive document comparison in a modern information environment.
[0063] The present invention calculates the document similarity and uses a binary classification model to determine the plagiarism relationship. This method can not only determine whether there is plagiarism, but also provide a corresponding similarity score. This quantitative result helps users understand the basis for judgment and improves the interpretability of the system.
[0064] The method of the present invention realizes modular design (such as separate feature extraction, similarity calculation and plagiarism judgment steps) so that the system has good flexibility and scalability. Each module can be independently optimized or replaced according to specific needs to adapt to different application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] 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. It is obvious that 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.
[0066] Figure 1 is a flow chart of a document similarity comparison method based on deep semantics and shallow layout according to an embodiment of the present invention;
[0067] Figure 2 is a specific flow chart of step S3 of an embodiment of the present invention;
[0068] Figure 3 is a specific flow chart of step S4 of an embodiment of the present invention;
[0069] Figure 4 is a specific flow chart of step S5 of an embodiment of the present invention;
[0070] Figure 5 is a specific flow chart of step S6 of an embodiment of the present invention;
[0071] Figure 6 It is a functional block diagram of a document similarity comparison system based on deep semantics and shallow layout according to an embodiment of the present invention;
[0072] Figure 7 It is another functional block diagram of the document similarity comparison system based on deep semantics and shallow layout according to an embodiment of the present invention;
[0073] Figure 8 It is a functional block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not 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.
[0075] The model proposed in the embodiment of the present invention can learn deep semantic features and shallow layout features, thereby modeling documents and performing incremental learning, thereby improving the query speed for finding similar documents.
[0076] The embodiment of the present invention combines the semantic extraction technology in language representation learning based on semantic neural network to represent the potential grammatical or semantic features of the language in texts of different granularity with dense, low-dimensional, continuous vectors. The embodiment of the present invention divides the features of the document into deep semantic features based on the text and shallow features based on the document layout.
[0077] The embodiment of the present invention uses XLNet, a neural network language model pre-trained with a large amount of Chinese corpus, to extract the deep semantic features of the text. Similar documents usually have similar document layout features in addition to similar text semantic features. Therefore, in addition to the basic text semantic similarity, the model must also be able to effectively capture the ability of text paragraph structure and layout similarity.
[0078] For the shallow layout features of the document, the embodiment of the present invention uses a convolutional neural network to obtain the layout features of the local position of the document, and uses a gated recurrent unit to obtain the global layout features of the document, and then integrates the two to finally generate a feature vector representing the overall layout of the document. Based on the twin network model architecture, a binary classification training task is performed to determine whether two documents have a plagiarism relationship, so as to achieve the purpose of modeling and learning the deep semantics of the text and the shallow layout features of the document at the same time.
[0079] The XLNet model, which has been pre-trained with a large amount of Chinese corpus, can not only extract the deep semantic information of Chinese text very well, but also overcome the disadvantage of the ordinary BERT model when processing longer texts, that is, the complexity of the model increases with the increase of text length. This fatal disadvantage has very strict requirements on the hardware conditions of the computer, and even on extremely long texts, it is almost impossible to withstand such training pressure. In the BERT model, the maximum text length that can be processed by default is 512. If the length of the processed text sequence is less than this fixed length, it can be solved by adding preset padding characters. However, if the length of the processed text sequence is greater than this fixed length, it will be more troublesome to process. One way to deal with it is to cut the text into multiple fragments. When training the model, each fragment is processed separately, and there is no connection between different fragments. There are two problems with this processing method: on the one hand, because the segments are trained independently, the longest dependency between different characters is limited by the length of a single segment; on the other hand, since the efficiency of cutting the natural boundaries of the original text is relatively low, the natural boundaries of the original text are not taken into consideration when cutting the segments, but the segments are divided according to this fixed length. This will cause the segmented text segments to be semantically incomplete and the computational efficiency is still relatively low.
[0080] In view of the shortcomings of the above-mentioned BERT model, the XLNet model has made corresponding improvements. The XLNet model has the following features:
[0081] First of all, the XLNet model is based on the architecture of the Transformer_XL model and incorporates its advantages. It proposes a segment-level recursive mechanism and introduces a module with a memory function to establish connections between different text segments. This processing method makes it possible to "model long-distance dependencies" for words in the text, allowing semantic interactions between different text segments that have been segmented, maintaining the semantic integrity of the original text, overcoming the shortcomings of the BERT model in processing long text tasks, and perfectly solving the problem of context fragmentation caused by segmentation.
[0082] If absolute position encoding is used like the BERT model, the position encodings of different text fragments are the same, which is obviously unreasonable. Therefore, the Transformer_XL model introduces a relative position encoding mechanism to replace the absolute position encoding mechanism in the BERT model, making the encoding method more reasonable.
[0083] Secondly, the XLNet model combines the advantages of both autoregressive and autoencoder language models, while overcoming their respective shortcomings. It achieves bidirectional capture of text context features through permutation operations, and does not use the MASK operation during pre-training, thus overcoming the inconsistency problem between the BERT pre-training stage and the fine-tuning stage, and eliminating the incorrect assumption that "the positions being masked are independent of each other". The above technical solution is described in detail below.
[0084] Embodiment 1
[0085] The embodiment of the present invention proposes a document similarity comparison method based on deep semantics and shallow layout, which can effectively capture the content and structural features of the document, thereby achieving more accurate similarity comparison and plagiarism detection. Figure 1 As shown, the specific implementation steps of the method are described in detail below:
[0086] Step S1: Build a twin network model based on the twin network architecture.
[0087] A twin network is a special neural network structure consisting of two or more identical subnetworks that share the same parameters and weights. In this embodiment, the twin network model contains two identical subnetworks, each of which is used to process an input document. The main structure of the twin network model includes four key parts: first, the input layer, which receives the original representation of the document as the initial data for model processing; next is the feature extraction layer, which is responsible for extracting deep semantic features and shallow layout features from the input document to ensure that the model can capture the content and structural information of the document; then the feature fusion layer, which fuses the extracted deep semantic features with the shallow layout features to generate a richer feature representation; finally, the output layer, which is used to output the final feature representation of the document as the final result of the model.
[0088] Step S2: Acquire training data, wherein the training data includes annotated document sample groups, wherein each document sample group includes two training documents and their similarity annotation values.
[0089] This step collects and prepares training data sets, which include annotated document sample groups, each of which contains two training documents and their similarity annotation values. These document sample groups should cover various similarity levels, from completely dissimilar to highly similar or plagiarized. Similarity annotation values can be continuous values (such as decimals between 0 and 1) or discrete categories (such as dissimilar, partially similar, highly similar, etc.).
[0090] Step S3: Use the training data to train the twin network model so that the twin network model can simultaneously learn the deep semantic features and shallow layout features of the training documents.
[0091] Through this training process, the Siamese network model can learn how to effectively extract and fuse the deep semantic features and shallow layout features of documents, so as to accurately calculate the similarity between documents.
[0092] Step S4: Use the trained twin network model to perform feature extraction and similarity calculation on the two documents to be compared to obtain the similarity of the documents to be compared.
[0093] Step S5: Based on the calculated similarity of the documents to be compared, use a pre-trained binary classification model to determine whether there is a plagiarism relationship between the two documents to be compared.
[0094] The specific steps are as follows: The calculated document similarity is used as input and sent to the pre-trained binary classification model. The binary classification model outputs a judgment result, indicating whether there is a plagiarism relationship between the two documents. According to the output of the binary classification model, the final plagiarism judgment result is obtained.
[0095] Through the above steps, this method can effectively compare the similarity of documents and determine whether there is a plagiarism relationship. This method comprehensively considers the deep semantics and shallow layout features of the document, improving the accuracy of similarity comparison and the reliability of plagiarism detection. At the same time, due to the use of deep learning technology, this method has good adaptability and generalization ability, and can handle various types of documents and different forms of plagiarism.
[0096] In some embodiments, the twin network model proposed in the embodiments of the present invention includes two neural network branches with exactly the same structure and a similarity calculation module. Each neural network branch consists of three main parts: a first sub-network for extracting deep semantic features, a second sub-network for extracting shallow layout features, and a fusion layer for fusing these two features. Through this structure, the twin network model can fully capture the semantic information and layout features of the document, combine the processing results of the two neural network branches on the document, and output the final similarity score. The components and workflow of the twin network model are described in detail below.
[0097] The first subnetwork is responsible for extracting the deep semantic features of the document, using the pre-trained XLNet model to process the text in the document. XLNet is a powerful autoregressive pre-trained language model that can capture long-range dependencies and contextual information of text. Specifically, the document text is first input into the pre-trained XLNet model for processing, and the XLNet model will output a vector representing the semantics of the document. This semantic representation vector is used as the deep semantic features of the document, ensuring that the model can deeply understand the meaning and semantic structure of the text content.
[0098] The second subnetwork is used to extract the shallow layout features of the document. It combines the Convolutional Neural Network (CNN) and the Gated Recurrent Unit (GRU) to capture the local and global layout features of the document. First, the document is converted into a two-dimensional image representation, where each pixel represents a character or element in the document. Then, the CNN extracts the layout features of the local area through multiple layers of convolution operations and uses pooling layers to reduce the feature dimensions. Next, the local feature sequence extracted by the CNN is input into the GRU, which captures the global layout information of the document by processing the feature sequence and outputs the final global layout features. Finally, the local features and the global features are integrated by splicing or weighted fusion to generate the shallow layout features of the document. Splicing is to directly connect the local feature vector and the global feature vector to form a longer feature vector. Assume that the dimension of the local feature vector is m and the dimension of the global feature vector is n. The dimension of the spliced feature vector will be m+n. Weighted fusion is to assign different weights to the local features and the global features, and then weight them and sum them. The local features and the global features need to be converted to the same dimension (if the original dimensions are different). The weights assigned to each feature can be fixed or learned. This approach allows the model to adjust the importance of different types of features.
[0099] The fusion layer is responsible for fusing the deep semantic features extracted by the first sub-network and the shallow layout features generated by the second sub-network to generate a comprehensive feature representation of the document. In specific operations, the fusion layer receives the outputs of the two sub-networks as input, and optionally performs weighted fusion processing on the two features by using technologies such as attention mechanisms or multi-layer perceptrons. This process ensures that the twin network model can simultaneously consider the semantic information and layout information of the document, and the output comprehensive feature representation will contain key information from the content and structure of the document, providing a more comprehensive feature representation. The attention mechanism allows the model to dynamically assign weights to different features based on their importance to the current task. In this embodiment, the following fusion processing methods can be used: simple concatenation, which is the most direct fusion method, which is to directly connect the two feature vectors together. Assuming that the dimension of the deep semantic feature S is m and the dimension of the shallow layout feature L is n, the dimension of the concatenated feature vector will be m+n. Element-wise addition, this method requires that the two feature vectors have the same dimension, and then directly add them. S and L must have the same dimension, and each element of the result vector is the sum of the corresponding original vector elements. Element-wise multiplication, which is similar to addition, but uses multiplication operations. Weighted Sum, which assigns a weight to each eigenvector and then adds them up. A weight needs to be specified for each eigenvector, which can be set based on prior knowledge or obtained through learning. Maximum or minimum fusion, which takes the maximum or minimum value of the corresponding element.
[0100] The main task of the similarity calculation module is to calculate the similarity between the document comprehensive feature representations output by the two neural network branches. The similarity calculation module first receives the document comprehensive features from the two branches as input, and then uses an appropriate similarity measurement method (such as cosine similarity or Euclidean distance, etc.) to calculate the similarity between the two document feature representations. Finally, the similarity calculation module outputs a similarity score that represents the similarity between the two documents. This score can intuitively reflect the similarity between the two documents, thereby helping to determine whether the documents have similarities in content or layout.
[0101] The workflow is as follows: The workflow of the entire twin network model starts with the input of two documents to be compared, and the two documents are sent to two independent neural network branches of the twin network model. Each branch processes its own input document. The first sub-network extracts deep semantic features, and the second sub-network extracts shallow layout features. The two features are then weighted and fused through the fusion layer to generate a comprehensive feature representation. After the two branches are processed, the output comprehensive feature representation is passed to the similarity calculation module, which calculates and outputs the similarity scores of the two documents. In this way, the twin network model can consider the semantic content and layout structure of the document at the same time, so as to more comprehensively and accurately evaluate the similarity between documents. This method is particularly suitable for detecting plagiarism cases that are similar in content but different in layout or expression.
[0102] In some embodiments, the training process of the twin network model proposed in the present invention is an end-to-end supervised learning process, which aims to optimize the model parameters so that it can accurately predict the similarity between document pairs. The training process includes multiple steps, the first of which is data preparation, that is, preparing a document pair data set for training. Each training sample consists of two documents and their similarity annotation values. The document pairs can come from manually annotated plagiarism cases or document pairs with known similarities. These samples provide standard answers for the model to help the model learn how to judge the similarity between documents.
[0103] like Figure 2 As shown, during the training process, for each training batch, step S31 is first performed: the two training documents in each document sample group are respectively input into the two neural network branches of the twin network model. This step selects a batch of document pair samples from the training data set, and inputs the two documents in each document pair into the two neural network branches of the twin network model. Since the two neural network branches have the same structure and share weights, the two documents will be feature extracted in the same processing mode to ensure the consistency of processing, thereby ensuring the fairness and consistency of the similarity calculation between documents.
[0104] Then in S32: in each neural network branch, the deep semantic features and shallow layout features of the input training document are extracted respectively. This step belongs to the feature extraction stage, and the two neural network branches synchronously extract the deep semantic features and shallow layout features of each document. In terms of deep semantic feature extraction, the pre-trained XLNet model is used to process the document text to generate a semantic representation vector as the deep semantic feature of the document. In terms of shallow layout feature extraction, the local layout features of the document are first extracted through CNN, and then the output of CNN is processed through GRU to capture the global layout features of the document. Finally, the local and global layout features are integrated to generate the final shallow layout features of the document.
[0105] Next is S33: combining the deep semantic features of the training document and the shallow layout features through the fusion layer to obtain a comprehensive feature representation of each training document. In the fusion layer, the two features are weightedly fused using methods such as an attention mechanism or a multi-layer perceptron to ensure that the semantic and layout information are effectively combined. Through this fusion, the model can generate a comprehensive feature representation of each document, taking into account the semantic content and layout structure of the document.
[0106] Then, enter S34: calculate the similarity between the comprehensive feature representations output by the two neural network branches to obtain the predicted similarity. The model calculates the similarity between the two document feature representations through the selected similarity measurement method (such as cosine similarity) and outputs the predicted similarity value, which represents the model's estimate of the similarity of the current document pair. Through this process, the model is able to generate a prediction result for the similarity between document pairs.
[0107] In S35: Optimize the parameters of the twin network model by minimizing the difference between the predicted similarity and the similarity annotation value in the document sample group. Specifically, during the parameter optimization process, the model measures its performance by calculating the difference between the predicted similarity and the true similarity annotation value in the document pair. The loss function uses mean square error (MSE) or cross entropy, which reflects the error of the model prediction. Then, the back propagation algorithm is used to calculate the gradient of the loss function for the parameters of each layer of the model, and an optimizer (such as Adam (Adaptive Moment Estimation) or SGD (Stochastic Gradient Descent)) is used to update the model parameters to minimize the loss function, thereby gradually improving the prediction accuracy of the twin network model.
[0108] In the XLNet model, the parameters of the pre-trained model mainly include: the weight matrices of the self-attention layer, which are used to convert the input data into queries (Q), keys (K), and values (V), thereby realizing the self-attention mechanism between input sequences. The weights and biases of the feedforward neural network layer are used to perform further linear transformations and nonlinear activations on the features after each attention layer. The scaling and offset parameters of the layer normalization, which are used to normalize the output of each layer, making the training process more stable and efficient. These parameters can be fixed (in the case of using a pre-trained model without fine-tuning) or trainable (if fine-tuning the model is allowed).
[0109] In the convolutional neural network (CNN) part of the second subnetwork, the main parameters include the weights of the convolution kernels (filters), which are responsible for extracting local patterns of input features; and bias terms, which are used to adjust the output feature maps. The parameters of the pooling layer (if used) may exist, which can downsample the feature map to reduce computational complexity and retain important features.
[0110] GRU (Gated Recurrent Unit), another part of the second sub-network, contains multiple parameters: the weight matrix and bias vector of the update gate, which are used to control how the current hidden state is updated; the weight matrix and bias vector of the reset gate, which are used to determine how the information of the previous hidden state is retained at the current moment; and the weight matrix and bias vector of the candidate hidden state, which are used to generate a new hidden state that combines the current input and historical information to capture the temporal dependencies in the sequence.
[0111] The parameters of the fusion layer are used to combine deep semantic features and shallow layout features, mainly weight matrices and bias vectors. These parameters determine how to effectively fuse multiple feature representations in the network. In some cases, activation function parameters are also used to increase the nonlinear expression ability of the network.
[0112] The parameters of the similarity calculation module involve the weights used to calculate the similarity between the comprehensive feature representations of two documents. Through these weight matrices, the network can map the extracted features to the similarity space. In addition, it may also include normalization parameters to standardize the results of the similarity calculation and ensure output stability.
[0113] Finally, the iterative training phase begins, and the twin network model traverses the entire training data set by repeatedly executing the aforementioned steps (S31 to S35). After each complete training cycle (epoch), the model is evaluated on the validation set to test its performance. If the performance on the validation set does not meet expectations, it is necessary to adjust hyperparameters, such as the learning rate or batch size. After multiple rounds of training, the twin network model gradually converges and reaches the preset training goal.
[0114] After the training is completed, the model will enter the evaluation and preservation stage. The twin network model will be finally evaluated on an independent test set to ensure its generalization ability. If the test results meet the performance requirements, the model parameters will be saved for subsequent applications. Through this training process, the twin network model can effectively learn how to comprehensively utilize the semantic and layout features of the document to judge the document similarity, which is suitable for scenarios such as plagiarism detection and document clustering. In addition, in actual applications, the optimal hyperparameter configuration can be determined through multiple experiments, and cross-validation and other techniques can be used to enhance the generalization ability and robustness of the model to ensure the reliability of the model in various document similarity tasks.
[0115] like Figure 3 As shown, in some embodiments, the method proposed by the present invention uses the trained twin network model to calculate the similarity of the documents to be compared in step S4. The specific steps include:
[0116] S41: Input the two documents to be compared into the two neural network branches of the twin network model respectively. Specifically, prepare two documents that need to be compared for similarity. These documents can be text files in any format, such as TXT, DOC, PDF, etc. Perform necessary preprocessing on the documents, such as text extraction, format unification, etc. Input the two preprocessed documents into the two neural network branches of the twin network model respectively. Ensure that the input format received by the two branches is consistent to ensure consistency of processing.
[0117] S42: The deep semantic features and shallow layout features of each document to be compared are automatically extracted through two neural network branches, and a comprehensive feature representation of each document to be compared is obtained through a fusion layer, and the comprehensive feature representation includes fusion information of the deep semantic features and shallow layout features of the document to be compared.
[0118] Specifically, within each neural network branch, the following operations are performed:
[0119] Extracting deep semantic features, which includes: processing document text using a pre-trained XLNet model. The XLNet model outputs a semantic representation vector of the document as a deep semantic feature. This step can capture the semantic content, contextual relationships, and long-range dependencies of the document.
[0120] Extract shallow layout features, which includes: using CNN to process the two-dimensional representation of the document and extracting layout features at local locations. Using GRU to process the output of CNN to obtain the global layout features of the document. Integrate local and global layout features to generate the final shallow layout features. This step can capture the surface features of the document, such as structural information and format layout.
[0121] Feature fusion includes: inputting the extracted deep semantic features and shallow layout features into the fusion layer. The fusion layer uses methods such as attention mechanism or multi-layer perceptron to perform weighted fusion of the two features. Output the comprehensive feature representation of each document to be compared. This step organically combines semantic information and layout information to form a comprehensive representation of the document.
[0122] S43: Based on the comprehensive feature representation of the two documents to be compared, the similarity between them is calculated to obtain the similarity of the documents to be compared.
[0123] Specifically, this step obtains the comprehensive feature representation output by the two neural network branches. The similarity between the two comprehensive feature representations is calculated using a similarity calculation module. A variety of similarity measurement methods can be used, such as cosine similarity, Euclidean distance, etc. A numerical value representing the similarity between the two documents to be compared is output, ranging from 0 to 1. The higher the similarity value, the more similar the two documents are; the lower the similarity value, the greater the difference.
[0124] Through this method, the present invention can comprehensively consider the content and structure of the document and provide a more accurate similarity assessment. This has significant advantages for detecting complex plagiarism, especially those that change the document format or slightly modify the content. At the same time, this method is also suitable for application scenarios such as similarity analysis of large-scale document sets and document clustering.
[0125] In practical applications, similarity thresholds can be set according to specific needs to determine whether a document constitutes plagiarism or is highly similar. For example, document pairs with a similarity greater than 0.8 can be marked as highly similar and require further manual review. In addition, other auxiliary information, such as the creation time of the document, author information, etc., can also be combined to assist in determining the similarity of the document.
[0126] like Figure 4 As shown, in some embodiments, the present invention proposes a plagiarism relationship determination method based on a binary classification model in step S5. The specific processing process includes the following steps: S51: using the similarity of the documents to be compared calculated in step S4 as the input feature of the binary classification model; S52: using a pre-trained binary classification model to process the input feature, the binary classification model includes one of logistic regression, support vector machine or neural network, and outputting a probability value between 0 and 1, indicating the possibility that the two documents have a plagiarism relationship; S53: setting a threshold value, if the probability value output in step S52 is greater than or equal to the threshold value, it is determined that the two documents to be compared have a plagiarism relationship, otherwise it is determined that there is no plagiarism relationship; S54: outputting the determination result, which includes a Boolean value of whether there is a plagiarism relationship and a corresponding probability value.
[0127] In step S51, the similarity of the documents to be compared calculated by the twin network model in step S4 is used as an input feature. This similarity value is a floating point number between 0 and 1, representing the similarity between the two documents in terms of content and structure. In addition to the similarity value, other auxiliary features can also be considered, such as the length ratio of the document, the overlap of keywords, etc., to improve the accuracy of the judgment.
[0128] In step S52, a pre-trained binary classification model is selected. Optional models include: logistic regression (which is suitable for linearly separable situations, with fast calculation speed and easy to explain), support vector machine (SVM, which can handle nonlinear situations and performs well in high-dimensional space), neural network (can capture complex nonlinear relationships, but requires more training data). Input the input features prepared in step S51 into the selected binary classification model. The model outputs a probability value between 0 and 1, indicating the possibility that there is a plagiarism relationship between the two documents. The closer the probability value is to 1, the greater the possibility of a plagiarism relationship; the closer it is to 0, the smaller the possibility.
[0129] In step S53, a judgment threshold is set. The selection of this threshold needs to be determined according to the specific application scenario and requirements. The threshold can be 0.5, 0.7 or 0.8, etc. The specific value needs to be balanced between accuracy and recall. If the probability value output in step S52 is greater than or equal to the set threshold, it is determined that there is a plagiarism relationship between the two documents to be compared. If the probability value is less than the threshold, it is determined that there is no plagiarism relationship.
[0130] In step S54, the judgment result is output, which includes two main parts: a Boolean value (a binary judgment result indicating whether there is a plagiarism relationship) and a probability value (i.e., the probability value output by the model in step S52, which provides confidence information of the judgment). This output form not only gives a clear judgment, but also retains the uncertainty information of the judgment, which is conducive to subsequent manual review or further analysis.
[0131] In practical applications, the relationship between false positives and false negatives can be balanced by adjusting the threshold. At the same time, for cases close to the threshold, they can be marked as suspected plagiarism and sent to manual review for further review. In addition, metadata such as the creation time and author information of the document can be combined to further improve the accuracy of the judgment.
[0132] In some embodiments, the XLNet model used in the present invention has a unique architecture and pre-training method, which can effectively capture the deep semantic features of text. The core features of the XLNet model include its Transformer-XL-based architecture design and innovative pre-training strategy.
[0133] The XLNet model uses the Transformer-XL architecture, which contains several key components. First, it uses a segment-level recursive mechanism to establish dependencies across multiple text segments by caching the hidden state of the previous text segment. This mechanism enables the model to process long text sequences and capture long-distance dependencies. Second, the model contains modules with memory functions to store and utilize the hidden state information of the previous text segments. This design enhances the long-term memory capacity of the model, enabling it to better understand and utilize contextual information. In addition, the XLNet model uses a relative position encoding mechanism instead of the traditional absolute position encoding mechanism. Relative position encoding allows the model to handle inputs of different lengths more flexibly and performs better when processing long sequences.
[0134] During the pre-training process, the XLNet model uses an innovative approach to capture the contextual features of the text. Unlike traditional masked language models, XLNet does not use the MASK operation, but instead achieves bidirectional capture of text context features through permutation operations. This approach allows the model to consider all possible factorization orders during pre-training, thereby learning contextual dependencies more comprehensively. Text context features refer to the semantic associations and dependencies between words in a text, including word order, grammatical structure, and semantic connections. These features are important components of deep semantic features and are effectively captured through the pre-training process of the XLNet model.
[0135] This design of the XLNet model enables it to better understand and represent complex language structures. By considering all possible permutations, the model is able to learn richer contextual information, including bidirectional dependencies. This approach overcomes the limitations of traditional masked language models, such as inconsistencies between pre-training and fine-tuning, and reliance on independence assumptions.
[0136] In this invention, these features of the XLNet model make it particularly suitable for capturing the deep semantic features of documents. The model can understand complex language structures, capture long-distance dependencies, and effectively process long texts. These capabilities are crucial for accurately judging the semantic similarity between documents, especially when dealing with complex academic or technical documents.
[0137] By using the XLNet model, the present invention is able to generate high-quality document representations that contain not only surface vocabulary and syntactic information, but also deep semantic and contextual information. This rich representation provides a solid foundation for subsequent similarity calculations and plagiarism judgments, helping to improve the accuracy and reliability of the entire system.
[0138] In practical applications, the XLNet model can be fine-tuned according to the needs of specific tasks. For example, a document set in a specific field can be used for further pre-training to adapt to the language characteristics and terminology of the specific field. In addition, the performance and computational efficiency of the model can be balanced by adjusting the hyperparameters of the model, such as the number of layers, the number of attention heads, etc. This flexibility enables the present invention to adapt to different application scenarios and needs, thereby achieving optimal performance in various document similarity analysis and plagiarism detection tasks.
[0139] like Figure 5 As shown, in some embodiments, the present invention further includes a step of incrementally learning the twin network model to adapt to the changing document features and similarity judgment criteria. This step is marked as S6 and specifically includes the following sub-steps:
[0140] S61: Regularly collect new document samples and corresponding similarity annotations.
[0141] In this step, the system will regularly collect new document samples from actual application scenarios. These samples can come from the latest academic papers, newly generated technical reports or other types of documents. At the same time, these new samples are annotated with similarity, which can be done by manual annotation or semi-automatic methods. This process ensures that the model can continuously learn the latest document features and similarity judgment criteria.
[0142] S62: Use the collected new document samples to fine-tune the trained twin network model. The specific steps include: freezing the first 75% to 90% of the parameter layers of the twin network model and only updating the last 10% to 25% of the parameter layers; using a learning rate not exceeding 1 / 5 to 1 / 20 of the initial learning rate for gradient updates; using a training strategy with a batch size of 16 to 64, mixing the new document samples with 10% to 30% of randomly selected old document samples for training.
[0143] Specifically, by freezing the first 75% to 90% of the model’s parameter layers, most of the common features that the model has learned are retained, while allowing the last 10% to 25% of the parameter layers to be updated to adapt to new document features. This strategy balances the stability and adaptability of the model.
[0144] Second, use a smaller learning rate (no more than 1 / 5 to 1 / 20 of the initial learning rate) for gradient updates. This low learning rate strategy prevents the model from overfitting to new samples, causing the model to forget previously learned knowledge, while allowing the model to fine-tune to adapt to the new data distribution.
[0145] Finally, a training strategy with a batch size of 16 to 64 was adopted, and the new document samples were mixed with 10% to 30% of randomly selected old document samples for training. This mixed training strategy helps to keep the model's memory of old data while learning new features, thereby achieving a balance between new and old knowledge.
[0146] S63: Update the document index library and add the feature representation of the new document sample to the index; the feature representation of the new document sample refers to the vector representation obtained by encoding the new document through the fine-tuned twin network model; the feature representation of the new document sample includes the semantic information, structural information and contextual information of the document, which is compressed into a vector of fixed dimension.
[0147] In this step, the system adds feature representations of new document samples to the existing document index library. These feature representations are vectors obtained by encoding new documents through the fine-tuned twin network model. These vectors contain rich information about the document, including semantic information (the topic and content of the document), structural information (how the document is organized), and contextual information (the relationship between words and sentences). All this complex information is compressed into a fixed-dimensional vector, making subsequent similarity calculations and retrieval more efficient.
[0148] The feature representation acquisition process of new document samples is as follows: the new document samples are input into the fine-tuned twin network model; the fine-tuned twin network model processes the new document samples, and gradually extracts and combines features of different levels in each layer, including word-level features, sentence-level features, and document-level features; the last layer of the fine-tuned twin network model outputs the feature representation vector of the new document sample, and the feature representation vector is a comprehensive representation of all deep semantic features from word-level features to document-level features extracted by each layer of the fine-tuned twin network model.
[0149] Through this incremental learning method, the present invention can continuously optimize the twin network model to adapt it to the ever-changing document features and similarity judgment criteria. The advantage of this method is that by freezing most of the parameter layers, the common features that the model has learned are retained. Some parameters are allowed to be updated so that the model can learn new features. Mix new and old samples for training to prevent the model from forgetting previously learned knowledge. Only new samples need to be processed, and there is no need to retrain the entire model. By updating the document index library, the system can process the latest documents. This incremental learning method enables the present invention to maintain high performance in practical applications and to adapt to the ever-changing document features and similarity judgment requirements.
[0150] Embodiment 2
[0151] like Figure 6As shown, this embodiment provides a document similarity comparison system 200 based on deep semantics and shallow layout, which includes:
[0152] A twin network model construction module 210 is used to construct a twin network model based on a twin network architecture;
[0153] A training data acquisition module 220 is used to acquire training data, wherein the training data includes annotated document sample groups, wherein each document sample group includes two training documents and their similarity annotation values;
[0154] A model training module 230, used to train the twin network model using the training data, so that the twin network model can simultaneously learn the deep semantic features and shallow layout features of the training document;
[0155] A feature extraction and similarity calculation module 240 is used to use the trained twin network model to perform feature extraction and similarity calculation on two documents to be compared, so as to obtain the similarity of the documents to be compared;
[0156] The plagiarism determination module 250 is used to determine whether there is a plagiarism relationship between two documents to be compared based on the calculated similarity of the documents to be compared and using a pre-trained binary classification model.
[0157] Furthermore, the twin network model includes two neural network branches with the same structure and a similarity calculation module, and each neural network branch includes:
[0158] A first sub-network for extracting deep semantic features of a document, wherein the first sub-network processes text in the document using a pre-trained XLNet model to obtain a semantic representation vector of the document, and uses the semantic representation vector of the document as the deep semantic feature of the document;
[0159] A second sub-network for extracting shallow layout features of a document, wherein the second sub-network uses a convolutional neural network (CNN) to obtain layout features of a local position of the document; uses a gated recurrent unit (GRU) to obtain global layout features of the document; and integrates the layout features of the local position of the document and the global layout features of the document to generate shallow layout features of the document;
[0160] A fusion layer for fusing the outputs of the first sub-network and the second sub-network, wherein the fusion layer fuses the deep semantic features and the shallow layout features of the document and outputs a comprehensive feature representation of the document;
[0161] The similarity calculation module is used to calculate the similarity between the comprehensive feature representations of the documents output by the two neural network branches respectively.
[0162] Furthermore, the model training module 230 is specifically used to: input the two training documents in each document sample group into the two neural network branches of the twin network model respectively; in each neural network branch, extract the deep semantic features and shallow layout features of the input training documents respectively; combine the deep semantic features and the shallow layout features of the training documents through the fusion layer to obtain a comprehensive feature representation of each training document; calculate the similarity between the comprehensive feature representations output by the two neural network branches to obtain the predicted similarity; optimize the parameters of the twin network model by minimizing the difference between the predicted similarity and the similarity annotation value in the document sample group.
[0163] Furthermore, the feature extraction and similarity calculation module 240 is specifically used to input two documents to be compared into the two neural network branches of the twin network model respectively; the deep semantic features and shallow layout features of each document to be compared are automatically extracted through the two neural network branches, and a comprehensive feature representation of each document to be compared is obtained through the fusion layer, and the comprehensive feature representation includes fusion information of the deep semantic features and shallow layout features of the document to be compared; based on the comprehensive feature representation of the two documents to be compared, the similarity between them is calculated to obtain the similarity of the documents to be compared.
[0164] Furthermore, the plagiarism judgment module 250 is specifically used to use the similarity of the documents to be compared calculated in step S4 as the input feature of the binary classification model; use the pre-trained binary classification model to process the input feature, the binary classification model includes one of logistic regression, support vector machine or neural network, and output a probability value between 0 and 1, indicating the possibility that there is a plagiarism relationship between the two documents; set a threshold, if the output probability value is greater than or equal to the threshold, it is determined that the two documents to be compared have a plagiarism relationship, otherwise it is determined that there is no plagiarism relationship; output a judgment result, which includes a Boolean value of whether there is a plagiarism relationship and a corresponding probability value.
[0165] Furthermore, the XLNet model has the following features:
[0166] Adopting the Transformer-XL architecture, including: using a segment-level recursive mechanism, which is used to establish dependencies across multiple text segments by caching the hidden state of the previous segment; a module with a memory function, which is used to store and utilize the hidden state information of the previous text segments; using a relative position encoding mechanism instead of an absolute position encoding mechanism;
[0167] During the pre-training process, mask operations are not used, but rather permutation operations are used to achieve bidirectional capture of text context features; the text context features refer to the semantic associations and dependencies between words in the text, including word order, grammatical structure, and semantic connections; the text context features are part of the deep semantic features and are captured through the pre-training process of the XLNet model.
[0168] like Figure 7 As shown, further, the system also includes an incremental learning module 260 for performing incremental learning on the twin network model, and the incremental learning module 260 includes:
[0169] A sample collection unit, used to regularly collect new document samples and corresponding similarity annotations;
[0170] The model fine-tuning unit is used to fine-tune the trained twin network model using the collected new document samples, including:
[0171] The parameter freezing subunit is used to freeze the first 75% to 90% of the parameter layers of the twin network model and only update the last 10% to 25% of the parameter layers;
[0172] A learning rate adjustment subunit for performing gradient updates using a learning rate no greater than 1 / 5 to 1 / 20 of the initial learning rate;
[0173] A mixed training subunit, for adopting a training strategy with a batch size of 16 to 64, mixing new document samples with 10% to 30% of randomly selected old document samples for training;
[0174] An index update unit, which is used to update the document index library and add the feature representation of the new document sample to the index; the feature representation of the new document sample refers to the vector representation obtained by encoding the new document through the fine-tuned twin network model; the feature representation of the new document sample contains the semantic information, structural information and context information of the document, which is compressed into a vector of fixed dimension;
[0175] The feature representation acquisition unit is used to obtain the feature representation of the new document sample, specifically including:
[0176] The input subunit is used to input new document samples into the fine-tuned twin network model;
[0177] The feature extraction subunit is used to enable the fine-tuned twin network model to process new document samples, and gradually extract and combine features at different levels in each layer, including word-level features, sentence-level features, and document-level features;
[0178] The output subunit is used to make the last layer of the fine-tuned twin network model output the feature representation vector of the new document sample, and the feature representation vector is a comprehensive representation of all deep semantic features from word-level features to document-level features extracted by each layer of the fine-tuned twin network model.
[0179] The system achieves a multi-dimensional and comprehensive analysis of document similarity by combining deep semantic features and shallow layout features. This method can not only capture the content similarity of documents, but also identify the similarity of document structure and format, greatly improving the accuracy and reliability of similarity comparison.
[0180] The use of the twin network model enables the system to automatically learn and adapt to the characteristics of different types of documents. Through training with a large number of annotated document samples, the system can handle documents of various fields, formats and styles, showing strong versatility and adaptability.
[0181] The system can not only calculate document similarities, but also make plagiarism judgments based on these similarities. The pre-trained binary classification model can effectively distinguish between normal similarities and possible plagiarism, providing a powerful tool for academic integrity, copyright protection and other fields.
[0182] The twin network architecture allows the system to process two documents simultaneously, improving the efficiency of feature extraction and similarity calculation. This parallel processing capability enables the system to quickly process a large number of document pairs, making it suitable for large-scale document comparison tasks.
[0183] Using deep learning technology, the system can automatically discover and learn complex document features without manually designing feature extraction rules. This not only improves the performance of the system, but also enhances its adaptability to new document formats and content.
[0184] By considering both semantic content and document layout, the system is able to identify similarities that would be difficult to detect using content analysis alone, such as plagiarism that is masked by changing the order of paragraphs or adjusting the format.
[0185] The modular design of the system makes it easy to expand and optimize. As new training data is added, the model can continue to learn and improve, so that the performance of the system will continue to improve over time.
[0186] This comprehensive document similarity comparison system is not only suitable for checking for duplicate academic papers, but can also be applied to many fields such as legal document comparison, business document review, and news report originality verification. It has broad practical application value.
[0187] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0188] Embodiment 3
[0189] See also Figure 8 The embodiment of the present application further provides an electronic device 300, the electronic device comprising:
[0190] at least one processor; and,
[0191] A memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the document similarity comparison method based on deep semantics and shallow layout in the aforementioned method embodiment.
[0192] An embodiment of the present application also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the document similarity comparison method based on deep semantics and shallow layout in the aforementioned method embodiment.
[0193] An embodiment of the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the document similarity comparison method based on deep semantics and shallow layout in the aforementioned method embodiment.
[0194] Reference below Figure 3, which shows a schematic diagram of the structure of an electronic device 300 suitable for implementing the embodiment of the present application. The electronic device 300 in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 3 The electronic device 300 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0195] like Figure 3 As shown, the electronic device 30 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0196] Typically, the following devices may be connected to the I / O interface 305: input devices 306 including, for example, a touch screen, a touchpad, a key, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 308 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 309. The communication device 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Although the electronic device 300 with various devices is shown in the figure, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have alternatively.
[0197] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 309, or installed from the storage device 308, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0198] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above. The above computer readable medium may be contained in the above electronic device; or it may exist alone without being assembled into the electronic device.
[0199] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0200] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented by a dedicated hardware-based system that performs a specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions. The units described in the embodiments of the present application can be implemented by software or by hardware. Among them, the name of the unit does not constitute a limitation on the unit itself under certain circumstances.
[0201] The above is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A document similarity comparison method based on deep semantics and shallow layout, characterized in that: The following steps are involved: S1: Build a twin network model based on the twin network architecture; S2: Obtain training data, wherein the training data includes annotated document sample groups, wherein each document sample group includes two training documents and their similarity annotation values; S3: Using the training data to train the twin network model, so that the twin network model can simultaneously learn the deep semantic features and shallow layout features of the training document; S4: Using the trained twin network model to perform feature extraction and similarity calculation on the two documents to be compared, to obtain the similarity of the documents to be compared; S5: Based on the calculated similarity of the documents to be compared, use the pre-trained binary classification model to determine whether there is a plagiarism relationship between the two documents to be compared.
2. The method according to claim 1, characterized in that The twin network model includes two neural network branches with the same structure and a similarity calculation module, and each neural network branch includes: A first sub-network for extracting deep semantic features of a document, wherein the first sub-network processes text in the document using a pre-trained XLNet model to obtain a semantic representation vector of the document, and uses the semantic representation vector of the document as the deep semantic feature of the document; A second sub-network for extracting shallow layout features of a document, wherein the second sub-network uses a convolutional neural network (CNN) to obtain layout features of a local position of the document; uses a gated recurrent unit (GRU) to obtain global layout features of the document; and integrates the layout features of the local position of the document and the global layout features of the document to generate shallow layout features of the document; A fusion layer for fusing the outputs of the first sub-network and the second sub-network, wherein the fusion layer fuses the deep semantic features and the shallow layout features of the document and outputs a comprehensive feature representation of the document; The similarity calculation module is used to calculate the similarity between the comprehensive feature representations of the documents output by the two neural network branches respectively.
3. The method according to claim 2, characterized in that The training process of the twin network model includes: S31: inputting two training documents in each document sample group into two neural network branches of the twin network model respectively; S32: in each neural network branch, respectively extracting deep semantic features and shallow layout features of the input training document; S33: combining the deep semantic features of the training document and the shallow layout features through the fusion layer to obtain a comprehensive feature representation of each training document; S34: Calculate the similarity between the comprehensive feature representations output by the two neural network branches to obtain the prediction similarity; S35: Optimizing the parameters of the twin network model by minimizing the difference between the predicted similarity and the similarity annotation value in the document sample group.
4. The method according to claim 2 or 3, characterized in that: Step S4 specifically includes: S41: inputting two documents to be compared into two neural network branches of the twin network model respectively; S42: Automatically extracting the deep semantic features and shallow layout features of each document to be compared through the two neural network branches, and obtaining a comprehensive feature representation of each document to be compared through the fusion layer, wherein the comprehensive feature representation includes fusion information of the deep semantic features and shallow layout features of the document to be compared; S43: Based on the comprehensive feature representation of the two documents to be compared, the similarity between them is calculated to obtain the similarity of the documents to be compared.
5. The method according to claim 1, characterized in that The specific processing process of step S5 includes: S51: using the similarity of the documents to be compared calculated in step S4 as an input feature of the binary classification model; S52: using a pre-trained binary classification model to process input features, the binary classification model includes one of logistic regression, support vector machine or neural network, and outputs a probability value between 0 and 1, indicating the possibility that there is a plagiarism relationship between the two documents; S53: setting a threshold value, if the probability value outputted in step S52 is greater than or equal to the threshold value, it is determined that there is a plagiarism relationship between the two documents to be compared, otherwise it is determined that there is no plagiarism relationship; S54: Output the determination result, which includes a Boolean value of whether a plagiarism relationship exists and a corresponding probability value.
6. The method according to claim 2, characterized in that The XLNet model has the following features: Adopting the Transformer-XL architecture, including: using a segment-level recursive mechanism, which is used to establish dependencies across multiple text segments by caching the hidden state of the previous segment; A module with memory function, which is used to store and utilize the hidden state information of the previous text fragments; a relative position encoding mechanism is used to replace the absolute position encoding mechanism; During the pre-training process, mask operations are not used, but rather permutation operations are used to achieve bidirectional capture of text context features; the text context features refer to the semantic associations and dependencies between words in the text, including word order, grammatical structure, and semantic connections; the text context features are part of the deep semantic features and are captured through the pre-training process of the XLNet model.
7. The method according to claim 1, characterized in that It also includes S6: the step of incremental learning of the twin network model, specifically including: S61: Regularly collect new document samples and corresponding similarity annotations; S62: Use the collected new document samples to fine-tune the trained twin network model. The specific steps include: Freeze the first 75% to 90% of the parameter layers of the Siamese network model and only update the last 10% to 25% of the parameter layers; Use a learning rate no more than 1 / 5 to 1 / 20 of the initial learning rate for gradient updates; A training strategy with batch sizes ranging from 16 to 64 was used, mixing new document samples with 10% to 30% randomly selected old document samples for training; S63: Update the document index library and add the feature representation of the new document sample to the index; wherein the feature representation of the new document sample refers to the vector representation obtained by encoding the new document through the fine-tuned twin network model; the feature representation of the new document sample includes the semantic information, structural information and context information of the document, which is compressed into a vector of fixed dimension; The process of obtaining the feature representation of a new document sample is as follows: Input new document samples into the fine-tuned Siamese network model; The fine-tuned twin network model processes new document samples and gradually extracts and combines features at different levels in each layer, including word-level features, sentence-level features, and document-level features; The last layer of the fine-tuned twin network model outputs the feature representation vector of the new document sample. The feature representation vector is a comprehensive representation of all deep semantic features from word-level features to document-level features extracted by each layer of the fine-tuned twin network model.
8. A document similarity comparison system based on deep semantics and shallow layout, characterized in that: include: The twin network model building module is used to build a twin network model based on the twin network architecture; A training data acquisition module, used to acquire training data, wherein the training data includes annotated document sample groups, wherein each document sample group includes two training documents and their similarity annotation values; A model training module, used to train the twin network model using the training data, so that the twin network model can simultaneously learn the deep semantic features and shallow layout features of the training documents; A feature extraction and similarity calculation module is used to use the trained twin network model to perform feature extraction and similarity calculation on two documents to be compared, so as to obtain the similarity of the documents to be compared; The plagiarism judgment module is used to judge whether there is a plagiarism relationship between two documents to be compared based on the calculated similarity of the documents to be compared and using a pre-trained binary classification model.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the document similarity comparison method based on deep semantics and shallow layout as described in any one of the preceding claims 1-7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the document similarity comparison method based on deep semantics and shallow layout as described in any one of the preceding claims 1-7.
Citation Information
Cited By
Image job similarity detection method based on deep learning
CN120747555A
Abnormal event analyzing and monitoring method and system
CN121256628A
Dynamic multimedia data hash retrieval method and system based on extensible increment
CN121434420A