Document similarity analysis method and device, equipment, storage medium and product
Generate representations through document extraction and hashing algorithms, quickly match and analyze similar objects, solve the problem of low efficiency of document similarity analysis in the existing technology, and achieve efficient document similarity analysis.
Patent Information
- Application Number
- CN202410755621.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-20
AI Technical Summary
Existing document similarity analysis methods are inefficient, especially when processing long tender documents, and the calculation time is long, making it difficult to meet the needs for rapid evaluation.
By extracting text segments and images from documents, the objects to be analyzed are determined, and a hash algorithm is used to generate representations, conduct preliminary similarity matching, quickly locate similar objects, and then perform content-based similarity analysis to generate document similarity analysis results.
Significantly improves the efficiency of document similarity processing, avoids similarity calculations for all content one by one, and improves analysis efficiency.
Smart Images

Figure CN118673340A
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing technology, and in particular to a document similarity analysis method, device, equipment, storage medium and product. Background Art
[0002] As information systems are gradually improved, the demand for document similarity assessment in various industries is increasing. However, document similarity analysis generally converts the bid documents into text documents (such as txt format) for similarity comparison. However, bid documents are usually hundreds of pages long, which makes the similarity calculation time longer and the efficiency lower. Summary of the invention
[0003] In order to solve the above problems, the present application proposes a document similarity analysis method, device, equipment, storage medium and product, which can significantly improve the efficiency of document similarity processing.
[0004] According to a first aspect of an embodiment of the present application, a document similarity analysis method is provided, comprising:
[0005] Extracting text segments and images from the first document and the second document respectively, and determining objects to be analyzed in the first document and the second document, wherein each text segment and each image in the document is regarded as an object to be analyzed;
[0006] Determining representations of each object to be analyzed in the first document and the second document respectively;
[0007] Determining similar objects to be analyzed by comparing the representations of each object to be analyzed in the first document with the representations of each object to be analyzed in the second document;
[0008] By performing content-based similarity analysis on the similar objects to be analyzed, a similarity analysis result of the first document and the second document is obtained.
[0009] As an optional implementation manner, the respectively determining the representations of the objects to be analyzed in the first document and the second document includes:
[0010] For the text segments in the first document and the second document, determining the representation of the text segments by using a first hash algorithm;
[0011] and / or,
[0012] For the images in the first document and the second document, a representation of the image is determined by a second hash algorithm.
[0013] As an optional implementation manner, comparing the representation of each object to be analyzed in the first document with the representation of each object to be analyzed in the second document to determine similar objects to be analyzed includes:
[0014] For a first object to be analyzed in the first document and a second object to be analyzed in the second document, calculating a ratio of an intersection of a representation of the first object to be analyzed and a representation of the second object to be analyzed to a union of a representation of the first object to be analyzed and a representation of the second object to be analyzed, to obtain a similarity between the first object to be analyzed and the second object to be analyzed;
[0015] When the similarity between the first object to be analyzed and the second object to be analyzed is greater than a first similarity threshold, the first object to be analyzed and the second object to be analyzed are determined to be similar objects to be analyzed.
[0016] As an optional implementation, the obtaining the similarity analysis result of the first document and the second document by performing content-based similarity analysis on the similar objects to be analyzed includes:
[0017] In the case where the similar objects to be analyzed are similar text segments, determining text similarity information of the similar objects to be analyzed by comparing text contents of the similar objects to be analyzed;
[0018] In the case where the similar objects to be analyzed are similar images, determining image similarity information of the similar objects to be analyzed by comparing image contents of the similar objects to be analyzed;
[0019] The similarity analysis result of the first document and the second document is determined by using the text similarity information and / or the image similarity information.
[0020] As an optional implementation, determining text similarity information of the similar objects to be analyzed by comparing text contents of the similar objects to be analyzed includes:
[0021] By comparing the text contents of the similar objects to be analyzed, determining the common text contents and edit distances of the similar objects to be analyzed;
[0022] and / or,
[0023] Determining image similarity information of the similar objects to be analyzed by comparing image contents of the similar objects to be analyzed includes:
[0024] Acquire the image contents of the similar objects to be analyzed respectively through the large language model;
[0025] By comparing the image contents of the similar objects to be analyzed, similar image contents of the similar objects to be analyzed are determined.
[0026] As an optional implementation, the method further includes: determining the position of each of the similar objects to be analyzed in the document to which it belongs;
[0027] Determining similarity analysis results of the first document and the second document by using the text similarity information and / or the image similarity information includes:
[0028] The similarity analysis results of the first document and the second document are generated by using the text similarity information and / or the image similarity information and the positions of the similar objects to be analyzed in the documents to which they belong.
[0029] According to a second aspect of an embodiment of the present application, there is provided a document similarity analysis device, comprising:
[0030] An extraction module, used to extract text segments and images from the first document and the second document respectively, and determine objects to be analyzed in the first document and the second document, wherein each text segment and each image in the document is respectively regarded as an object to be analyzed;
[0031] A processing module, configured to respectively determine representations of each object to be analyzed in the first document and the second document;
[0032] A comparison module, configured to determine similar objects to be analyzed by comparing the representations of the objects to be analyzed in the first document with the representations of the objects to be analyzed in the second document;
[0033] The analysis module is used to obtain similarity analysis results of the first document and the second document by performing content-based similarity analysis on the similar objects to be analyzed.
[0034] A third aspect of the present application provides an electronic device, including:
[0035] Memory and processor;
[0036] The memory is connected to the processor and is used to store programs;
[0037] The processor implements the above-mentioned document similarity analysis method by running the program in the memory.
[0038] A fourth aspect of the present application provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned document similarity analysis method is implemented.
[0039] A fifth aspect of the present application provides a computer program product, including a computer program, which implements the above-mentioned document similarity analysis method when executed by a processor.
[0040] One embodiment of the above application has the following advantages or beneficial effects:
[0041] The first document and the second document are respectively subjected to text segment and image extraction to determine the objects to be analyzed in the first document and the second document, wherein each text segment and each image in the document is respectively regarded as an object to be analyzed; the representation of each object to be analyzed in the first document and the second document is respectively determined; similar objects to be analyzed are determined by comparing the representation of each object to be analyzed in the first document with the representation of each object to be analyzed in the second document; similarity analysis results of the first document and the second document are obtained by performing content-based similarity analysis on similar objects to be analyzed. It can be seen that, a preliminary similarity match is first performed based on the representation of each object to be analyzed in the first document and the representation of each object to be analyzed in the second document, so as to quickly locate similar objects to be analyzed in the first document and the second document, and then similarity analysis is performed on the content of the similar objects to be analyzed to determine the similarity analysis results of the first document and the second document, thereby avoiding the similarity calculation of all the contents in the documents one by one, thereby improving the analysis efficiency of document similarity analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0043] Figure 1 A flowchart of a document similarity analysis method provided in an embodiment of the present application;
[0044] Figure 2 A schematic diagram of a process for determining text similarity information in a document similarity analysis method provided in an embodiment of the present application;
[0045] Figure 3 A schematic diagram of a process for determining image similarity information in a document similarity analysis method provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of the structure of a document similarity analysis device provided in an embodiment of the present application;
[0047] Figure 5A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0049] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence software technology mainly includes several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0050] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph and other technologies. Without departing from the principles of this application, the method and device provided in this application can also be used to extract text information from any imaged information. The method and device provided in this application are applicable to multiple application scenarios, such as bid verification, document duplication checking, and other scenarios where it is necessary to perform targeted similarity comparison of texts in documents.
[0051] At present, taking the bidding scene as an example, the current bidding is gradually being online, more and more bidding platforms are being built and launched, and more and more companies are understanding and participating in bidding. Through online methods, the bidding process is becoming more and more standardized, and the process is also greatly optimized and streamlined.
[0052] In the process of evaluating bids, it is necessary to conduct similarity analysis on the bid documents of all participants. Bids are usually hundreds of pages long and the format is relatively complex, so cross-comparison is required. With the increase in the number of participants, the similarity analysis of bid documents has fallen into the dilemma of low efficiency.
[0053] Based on this, the present application proposes a document similarity analysis method, device, equipment, storage medium and product. The technical solution first performs preliminary similarity matching based on the representation of each object to be analyzed in the first document and the representation of each object to be analyzed in the second document, so as to quickly locate the similar objects to be analyzed in the first document and the second document, and then performs similarity analysis on the contents of the similar objects to be analyzed themselves to determine the similarity analysis results of the first document and the second document, avoiding the similarity calculation of all the contents in the documents one by one, thereby improving the analysis efficiency of the document similarity analysis.
[0054] Exemplary Methods
[0055] Figure 1 1 is a flowchart of a document similarity analysis method according to an embodiment of the present application. In an exemplary embodiment, a document similarity analysis method is provided, comprising:
[0056] S110, extracting text segments and images from the first document and the second document respectively, and determining objects to be analyzed in the first document and the second document, wherein each text segment and each image in the document is regarded as an object to be analyzed respectively;
[0057] S120, respectively determining representations of each object to be analyzed in the first document and the second document;
[0058] S130, determining similar objects to be analyzed by comparing the representation of each object to be analyzed in the first document with the representation of each object to be analyzed in the second document;
[0059] S140: Obtain similarity analysis results for the first document and the second document by performing content-based similarity analysis on the similar objects to be analyzed.
[0060] In step S110, illustratively, the first document and the second document may be documents containing image information and non-image information. In this embodiment, each document is composed of text and images. The first document and the second document may be documents in any scenario. For example, in a bidding scenario, the first document and the second document are bid documents corresponding to a certain subject; in a document scenario, the first document and the second document are documents. The first document and the second document may be uploaded by a user, or may be obtained from a database that pre-stores documents, which is not limited here. The first document and the second document may both be designated documents; or both may be randomly obtained documents; or one document may be a designated document and the other may be randomly obtained, which is not limited here.
[0061] Optionally, the first document and the second document may be subjected to image extraction first to obtain images and the first document and the second document with the images filtered out, and the images may be used as objects to be analyzed. The first document and the second document with the images filtered out may then be subjected to segmentation processing to obtain text segments, and the text segments may be used as objects to be analyzed. Optionally, the first document and the second document may be subjected to image extraction and segmentation processing simultaneously, and the images and text segments may be output simultaneously, and the images and text segments may be used as objects to be analyzed.
[0062] It should be noted that text segmentation is a key task in natural language processing, which involves dividing long texts into smaller, meaningful units, such as sentences or paragraphs. The text segmentation algorithms that can be used include machine learning-based methods (such as decision trees, support vector machines, and random forests, etc.), deep learning-based methods (such as long short-term memory networks combined with conditional random fields, BERT (Bidirectional Encoder Representations from Transformers) models, etc.), and rule-based methods (such as using predefined rules to identify separators in text, such as spaces, punctuation marks, or specific vocabulary patterns).
[0063] In step S120, the representation of the object to be analyzed is used to represent the message digest of the object to be analyzed. Optionally, when the object to be analyzed is a text segment, the representation represents the message digest of the text segment; when the object to be analyzed is an image, the representation represents the message digest of the image.
[0064] Exemplarily, different methods can be used to characterize different types of objects to be analyzed. Optionally, the GIST descriptor is used to characterize the image, and the global structural information of the image is captured to obtain the GIST descriptor, and it is used as the characterization of the image. The text segment is processed using a pre-trained language model such as BERT, and the characterization of the text segment is output. Optionally, the text segment and the image can be characterized in the form of a vector. Specifically, the text segment is represented using algorithms such as TF-IDF, Word2Vec, GloVe or FastText, and the corresponding representation of the text segment is obtained. The key features of the image, such as edges, corners, etc., can be extracted, and then these feature vectors are used as the representation of the image.
[0065] Optionally, since a hash algorithm is a method of converting an input (such as text) into an output summary of a fixed length, it is suitable for scenarios of fast comparison and retrieval, so a hash algorithm can be used to characterize images and segmented text. A hash algorithm, also known as a hash function or a hash function, is a one-way cryptographic system that maps a message of any length into a shorter and fixed-length value, called a hash value, hash value, or message digest. Among them, hash algorithms include Average Hash Algorithm (aHash), Difference Hash Algorithm (dHash), Perceptual Hash Algorithm (pHash), Locality Sensitive Hashing (LSH), etc.
[0066] In step S130, illustratively, similar objects to be analyzed represent objects to be analyzed with similar semantics, and the similar objects to be analyzed are composed of an object to be analyzed in the first document and an object to be analyzed in the second document.
[0067] Exemplarily, when the objects to be analyzed in the first document and the second document are both text segments, the similarity between the representation of the text segment in the first document and the representation of the text segment in the second document is calculated to determine similar text segments in the first document and the second document. The similar text segments in the first document and the second document are taken as similar objects to be analyzed.
[0068] Exemplarily, when the objects to be analyzed in the first document and the second document are both images, the representation of the image in the first document and the representation of the image in the second document are similarly calculated to determine similar images in the first document and the second document, and the similar images in the first document and the second document are used as similar objects to be analyzed.
[0069] Exemplarily, when the objects to be analyzed in the first document and the second document are text segments and images, optionally, a similarity calculation is performed between the representation of the text segment in the first document and the representation of the text segment in the second document to determine similar text segments in the first document and the second document; and then a similarity calculation is performed between the representation of the image in the first document and the representation of the image in the second document to determine similar images in the first document and the second document. Similar text segments in the first document and the second document and similar images in the first document and the second document are both regarded as similar objects to be analyzed.
[0070] Optionally, the representation of the text segment in the first document is respectively calculated with the representation of the text segment and the representation of the image in the second document to determine a first group of similar objects in the first document and the second document. The representation of the image in the first document is respectively calculated with the representation of the text segment and the representation of the image in the second document to determine a second group of similar objects in the first document and the second document. The first group of similar objects and the second group of similar objects are used as similar objects to be analyzed. The similarity calculation can be an algorithm for calculating similarity such as cosine similarity calculation, edit distance, and Euclidean distance.
[0071] In step S140, exemplarily, content-based similarity analysis means performing a similarity comparison on the object to be analyzed itself. Optionally, when the similar objects to be analyzed are similar text segments, the text contents of the similar text segments are similarly calculated to obtain text similarity information. Optionally, when the similar objects to be analyzed are similar images, the image contents of the similar images are similarly calculated to obtain image similarity information. Finally, the text similarity information and / or the image similarity information are fused (e.g., spliced) to obtain a similarity analysis result of the first document and the second document.
[0072] Exemplarily, when the similar objects to be analyzed are obtained by comparing the representation of a text segment with the representation of an image, the text content in the image can be first identified, and then the similarity between the identified text content and the text segment can be calculated to obtain similarity information, and the similarity information can be used as the similarity analysis result of the first document and the second document.
[0073] In the technical solution of the present application, the text segments and images are extracted from the first document and the second document respectively, and the objects to be analyzed in the first document and the second document are determined, wherein each text segment and each image in the document is respectively regarded as an object to be analyzed; the representation of each object to be analyzed in the first document and the second document is respectively determined; similar objects to be analyzed are determined by comparing the representation of each object to be analyzed in the first document with the representation of each object to be analyzed in the second document; and the similarity analysis results of the first document and the second document are obtained by performing content-based similarity analysis on similar objects to be analyzed. It can be seen that, a preliminary similarity match is first performed based on the representation of each object to be analyzed in the first document and the representation of each object to be analyzed in the second document, so as to quickly locate the similar objects to be analyzed in the first document and the second document, and then a similarity analysis is performed on the content of the similar objects to be analyzed to determine the similarity analysis results of the first document and the second document, thereby avoiding the similarity calculation of all the contents in the documents one by one, thereby improving the analysis efficiency of the document similarity analysis.
[0074] In one embodiment, the step S120 of respectively determining the representations of the objects to be analyzed in the first document and the second document includes:
[0075] For the text segments in the first document and the second document, determining the representation of the text segments by using a first hash algorithm;
[0076] And / or, for the images in the first document and the second document, determining the representation of the image by a second hash algorithm.
[0077] Exemplarily, due to the different types of text segments and images, different hash algorithms are used. The first hash algorithm uses a local sensitive hash algorithm, and the second hash algorithm uses a perceptual hash algorithm.
[0078] Specifically, after determining the object to be analyzed in the first document and the second document, if it is determined that only text segments exist in the object to be analyzed, the hash value corresponding to each text segment is calculated using the local sensitive hashing algorithm, and the hash value corresponding to each text segment is used as the representation of each text segment, thereby determining the representation of the object to be analyzed.
[0079] Specifically, after determining the objects to be analyzed in the first document and the second document, if it is determined that only images exist in the objects to be analyzed, the perceptual hash algorithm is used to calculate the hash values corresponding to each image, and the hash values corresponding to each image are used as representations of each image, thereby determining the representation of the objects to be analyzed.
[0080] In this embodiment, after determining the objects to be analyzed in the first document and the second document, each text segment and each image in the objects to be analyzed are determined. For the text segments, a local sensitive hash algorithm is used to calculate the hash value corresponding to each text segment, and the hash value corresponding to each text segment is used as the representation of each text segment. For the images, a perceptual hash algorithm is used to calculate the hash value corresponding to each image, and the hash value corresponding to each image is used as the representation of each image. In this way, the hash value is used as the representation of each object to be analyzed, and the similarity between the objects to be analyzed can be quickly compared through the hash value.
[0081] In one embodiment, comparing the representation of each object to be analyzed in the first document with the representation of each object to be analyzed in the second document to determine similar objects to be analyzed includes:
[0082] For a first object to be analyzed in the first document and a second object to be analyzed in the second document, calculating a ratio of an intersection of a representation of the first object to be analyzed and a representation of the second object to be analyzed to a union of a representation of the first object to be analyzed and a representation of the second object to be analyzed, to obtain a similarity between the first object to be analyzed and the second object to be analyzed;
[0083] When the similarity between the first object to be analyzed and the second object to be analyzed is greater than a first similarity threshold, the first object to be analyzed and the second object to be analyzed are determined to be similar objects to be analyzed.
[0084] Exemplarily, the first object to be analyzed in the first document may be an object to be analyzed specified in the first document, or may be an object to be analyzed selected randomly. The second object to be analyzed in the second document may be an object to be analyzed specified in the second document, or may be an object to be analyzed selected randomly. Optionally, starting from the representation of the first object to be analyzed in the first document, similarity calculations are performed with the representations of all objects to be analyzed in the second document in sequence, until the representation of the last object to be analyzed in the first document completes the similarity calculations with the representations of all objects to be analyzed in the second document. The calculated similarity is compared with the first similarity threshold, and the objects to be analyzed whose similarity is greater than the first similarity threshold are determined as similar objects to be analyzed. Among them, the first similarity threshold for images and text segments may be the same or different, and the first similarity threshold is set according to actual conditions and is not limited here.
[0085] Specifically, when the object to be analyzed includes a text segment and an image, the representation of the text segment in the first document and the second document may be calculated, and the representation of the image in the first document and the second document may be calculated simultaneously.
[0086] For the text segment, the local sensitive hashing algorithm is used to calculate the hash value corresponding to each text segment, and the hash value corresponding to each text segment is used as the characterization of each text segment. Taking the first text segment in the first document and the second text segment in the second document as an example, the intersection of the hash value of the first text segment in the first document and the hash value of the second text segment in the second document is calculated, and then the union of the hash value of the first text segment and the hash value of the second text segment is calculated. The ratio of the intersection to the union is used as the similarity between the first text segment in the first document and the second text segment in the second document. According to the above steps, the characterization of each text segment of the first document is calculated, and the similarity with the characterization of each text segment of the second document is obtained. For the image and the text segment, the first similarity threshold is the same, which is 80%. Each similarity is compared with the first similarity threshold, and the text segment corresponding to the similarity greater than the first similarity threshold is extracted, and it is determined as a similar text segment.
[0087] The formula for calculating text segment similarity is as follows:
[0088] Text segment similarity = (Hash_a∩Hash_b) / (Hash_a∪Hash_b)
[0089] Among them, Hash_a represents the hash value of the first text segment of the first document, and Hash_b represents the hash value of the second text segment of the second document.
[0090] For images, the perceptual hash algorithm is used to calculate the hash value corresponding to each image, and the hash value corresponding to each image is used as the representation of each image. Taking the first image in the first document and the second image in the second document as an example, the intersection of the hash value of the first image in the first document and the hash value of the second image in the second document is calculated, and then the union of the hash value of the first image and the hash value of the second image is calculated. The ratio of the intersection to the union is used as the similarity between the first image in the first document and the second image in the second document. According to the above steps, the representation of each image in the first document is calculated, and the similarity with the representation of each image in the second document is obtained. For images, the first similarity threshold is the same, which is 80%. Each similarity is compared with the first similarity threshold, and the images corresponding to the similarity greater than the first similarity threshold are extracted, and they are determined as similar images.
[0091] The image similarity calculation formula is as follows:
[0092] Image similarity = (Hash_c∩Hash_d) / (Hash_c∪Hash_d)
[0093] Here, Hash_c represents the hash value of the first image of the first document, and Hash_d represents the hash value of the second image of the second document.
[0094] In the case where the objects to be analyzed include text segments and images, similar images and similar text segments are determined as similar objects to be analyzed. In this way, the similarity between the objects to be analyzed can be more accurately determined by the ratio of the intersection and union of the representations of the objects to be analyzed.
[0095] In one implementation, the obtaining of similarity analysis results of the first document and the second document by performing content-based similarity analysis on the similar objects to be analyzed includes:
[0096] In the case where the similar objects to be analyzed are similar text segments, determining text similarity information of the similar objects to be analyzed by comparing text contents of the similar objects to be analyzed;
[0097] In the case where the similar objects to be analyzed are similar images, determining image similarity information of the similar objects to be analyzed by comparing image contents of the similar objects to be analyzed;
[0098] The similarity analysis result of the first document and the second document is determined by using the text similarity information and / or the image similarity information.
[0099] Exemplarily, when the similar objects to be analyzed are similar text segments, similarity (e.g., cosine similarity) is calculated for the text contents of the similar texts, and the calculation results exceeding the second similarity threshold are determined as specific similar parts between the text contents of the two similar texts, and the similar parts are determined as text similarity information. The second similarity threshold is set according to actual conditions and is not limited here.
[0100] In the case where the similar objects to be analyzed are similar images, comparing the image contents of the similar objects to be analyzed may be to calculate the similarity (e.g., cosine similarity) of the image contents of the similar images, determine the calculation results exceeding the third similarity threshold as specific similar parts between the image contents of the two similar images, and determine the similar parts as image similarity information. The third similarity threshold is set according to actual conditions and is not limited here.
[0101] When the object to be analyzed only includes a text segment, the text similarity information is determined as the similarity analysis result of the first document and the second document; when the object to be analyzed only includes an image, the image similarity information is determined as the similarity analysis result of the first document and the second document; when the object to be analyzed only includes a text segment and an image, the text similarity information and the image similarity information are determined as the similarity analysis result of the first document and the second document.
[0102] Preferably, determining the text similarity information of the similar objects to be analyzed by comparing the text contents of the similar objects to be analyzed includes:
[0103] By comparing the text contents of the similar objects to be analyzed, the common text contents and edit distances of the similar objects to be analyzed are determined.
[0104] Specifically, Figure 2 As shown, the first document and the second document are respectively subjected to text segment and image extraction to determine the objects to be analyzed in the first document and the second document. The objects to be analyzed in the first document and the second document are characterized according to the hash values. The hash values of the objects to be analyzed in the first document and the second document are calculated according to the text segment similarity calculation formula and the image similarity calculation formula, respectively, and the calculated similarity is screened according to the first similarity threshold, and the objects to be analyzed corresponding to the similarity greater than the first similarity threshold are used as similar objects to be analyzed. In the case where the similar objects to be analyzed are similar text segments, the sentences in the similar text segments are calculated according to the Longest Common Subsequence algorithm to obtain the longest common subsequence corresponding to each sentence. The corresponding longest common subsequence corresponding to each sentence is then calculated according to the edit distance algorithm to determine the similarity of each sentence between the similar text segments, and the calculation results exceeding the second similarity threshold are determined as similar sentences of two similar texts, and the similar sentences are determined as text similarity information. In this way, the text similarity information in similar texts can be more accurately determined by the common text content and the edit distance.
[0105] And / or, determining the image similarity information of the similar objects to be analyzed by comparing the image contents of the similar objects to be analyzed, including:
[0106] Acquire the image contents of the similar objects to be analyzed respectively through the large language model;
[0107] By comparing the image contents of the similar objects to be analyzed, similar image contents of the similar objects to be analyzed are determined.
[0108] It should be noted that the large language model is a deep learning model trained based on massive text data. The large language model has three important capabilities: contextual learning, instruction following, and chain of thought reasoning. Contextual learning: LLMs can understand and utilize contextual information by learning from a large amount of text data. This means that the model can interpret the following content based on the previous content, so as to better understand and generate coherent language. For example, in a dialogue system, LLMs can generate more accurate responses based on the previous dialogue history, taking into account the context and user intentions in the context. Instruction following: LLMs can follow instructions provided by humans to perform specific tasks or generate specific types of outputs. By providing clear instructions as prompts to the model, it can generate results that are consistent with the instructions. For example, in a question-answering system, by explicitly specifying the type of question and the required answer format, LLMs can generate accurate answers that meet the requirements. Chain of thought reasoning: LLMs have certain logical reasoning capabilities and can infer new conclusions by linking multiple concepts and information. By triggering the memory and semantic connections within the model, LLMs can reason, summarize, and synthesize information to generate more organized and creative outputs. This makes them excellent at generating stories, articles, and creative content. These three capabilities enable LLMs to not only generate natural language text, but also to deeply understand the meaning of the text and handle various natural language tasks. Prompt is to drive the large model to express text description. Prompt can be a phrase, a sentence, a paragraph, or even a complete question. It is usually created by staff to clarify and convey specific intentions or task requirements. The purpose of prompt is to guide the large language model to perform specific operations or generate specific types of outputs. This can include answering questions, completing tasks, writing articles, generating code, etc. Prompt needs to clearly guide the expected behavior of the large language model to ensure that the generated results meet expectations. Prompt can contain contextual information so that the model understands and generates content related to it. The context can be previous conversation history, background knowledge, or constraints in a specific field. By providing relevant context, prompt helps the model better understand the input and generate output. In this embodiment, the large language model can be a large language model that has been pre-trained for classification and fine-tuned.
[0109] Specifically, Figure 3As shown, the text segment and image extraction are performed on the first document and the second document respectively, and the objects to be analyzed in the first document and the second document are determined. The objects to be analyzed in the first document and the second document are characterized according to the hash value. The hash values of the objects to be analyzed in the first document and the second document are calculated according to the text segment similarity calculation formula and the image similarity calculation formula respectively, and then the calculated similarity is screened according to the first similarity threshold, and the objects to be analyzed corresponding to the similarity greater than the first similarity threshold are used as similar objects to be analyzed. In the case where the similar objects to be analyzed are similar images, image recognition is performed on the similar images respectively according to the large language model, and the image content is output, and then the image content of the similar images is calculated. The calculation result exceeding the third similarity threshold is determined as a specific similar part between the image content of the two similar images, and the similar part is determined as image similarity information. In this way, the content in the image can be more accurately identified through the large language model, so that the image similarity information can be more accurately determined.
[0110] In one embodiment, the method further comprises: determining the position of each of the similar objects to be analyzed in the document to which it belongs;
[0111] Determining similarity analysis results of the first document and the second document by using the text similarity information and / or the image similarity information includes:
[0112] The similarity analysis results of the first document and the second document are generated by using the text similarity information and / or the image similarity information and the positions of the similar objects to be analyzed in the documents to which they belong.
[0113] Exemplarily, when determining the representation of each object to be analyzed in the first document and the second document, the representation is associated with the position in the document to which each object to be analyzed belongs, and the associated information is stored. Furthermore, the associated information also includes the specific content of the object to be analyzed. The position includes the document page number and line number of the object to be analyzed.
[0114] Specifically, after determining the text similarity information and / or image similarity information, the position of the similar object to be analyzed in the document to which it belongs is determined in the association relationship according to the representation of the similar object to be analyzed. The similar objects to be analyzed of the first document and the second document are retrieved according to the position, and the text similarity information and / or image similarity information are marked on the similar objects to be analyzed. Finally, the marked documents and the similarity analysis results are displayed on the display screen. In this way, the similarity analysis results of the first document and the second document can be more intuitively displayed to the user.
[0115] Exemplary Devices
[0116] Accordingly, Figure 4 1 is a schematic diagram of a document similarity analysis device according to an embodiment of the present application. In an exemplary embodiment, a document similarity analysis device is provided, comprising:
[0117] An extraction module 410 is used to extract text segments and images from the first document and the second document respectively, and determine objects to be analyzed in the first document and the second document, wherein each text segment and each image in the document is regarded as an object to be analyzed respectively;
[0118] A processing module 420, configured to respectively determine representations of each object to be analyzed in the first document and the second document;
[0119] A comparison module 430, configured to determine similar objects to be analyzed by comparing the representations of each object to be analyzed in the first document with the representations of each object to be analyzed in the second document;
[0120] The analysis module 440 is used to obtain similarity analysis results of the first document and the second document by performing content-based similarity analysis on the similar objects to be analyzed.
[0121] In one implementation, the processing module 420 is further configured to:
[0122] For the text segments in the first document and the second document, determining the representation of the text segments by using a first hash algorithm;
[0123] and / or,
[0124] For the images in the first document and the second document, a representation of the image is determined by a second hash algorithm.
[0125] In one embodiment, comparing the representation of each object to be analyzed in the first document with the representation of each object to be analyzed in the second document to determine similar objects to be analyzed includes:
[0126] For a first object to be analyzed in the first document and a second object to be analyzed in the second document, calculating a ratio of an intersection of a representation of the first object to be analyzed and a representation of the second object to be analyzed to a union of a representation of the first object to be analyzed and a representation of the second object to be analyzed, to obtain a similarity between the first object to be analyzed and the second object to be analyzed;
[0127] When the similarity between the first object to be analyzed and the second object to be analyzed is greater than a first similarity threshold, the first object to be analyzed and the second object to be analyzed are determined to be similar objects to be analyzed.
[0128] In one implementation, the analysis module 440 is further configured to:
[0129] In the case where the similar objects to be analyzed are similar text segments, determining text similarity information of the similar objects to be analyzed by comparing text contents of the similar objects to be analyzed;
[0130] In the case where the similar objects to be analyzed are similar images, determining image similarity information of the similar objects to be analyzed by comparing image contents of the similar objects to be analyzed;
[0131] The similarity analysis result of the first document and the second document is determined by using the text similarity information and / or the image similarity information.
[0132] In one embodiment, determining text similarity information of the similar objects to be analyzed by comparing text contents of the similar objects to be analyzed includes:
[0133] By comparing the text contents of the similar objects to be analyzed, determining the common text contents and edit distances of the similar objects to be analyzed;
[0134] and / or,
[0135] Determining image similarity information of the similar objects to be analyzed by comparing image contents of the similar objects to be analyzed includes:
[0136] Acquire the image contents of the similar objects to be analyzed respectively through the large language model;
[0137] By comparing the image contents of the similar objects to be analyzed, similar image contents of the similar objects to be analyzed are determined.
[0138] In one embodiment, the device further comprises: a position determination module, configured to determine the position of each of the similar objects to be analyzed in the document to which it belongs;
[0139] Determining similarity analysis results of the first document and the second document by using the text similarity information and / or the image similarity information includes:
[0140] The similarity analysis results of the first document and the second document are generated by using the text similarity information and / or the image similarity information and the positions of the similar objects to be analyzed in the documents to which they belong.
[0141] The document similarity analysis device provided in this embodiment belongs to the same application concept as the document similarity analysis method provided in the above embodiment of this application, and can execute the document similarity analysis method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the document similarity analysis method. For technical details not fully described in this embodiment, please refer to the specific processing content of the document similarity analysis method provided in the above embodiment of this application, and will not be repeated here.
[0142] The functions implemented by the above extraction module 410, processing module 420, comparison module 430 and analysis module 440 may be implemented by the same or different processors respectively, which is not limited in the embodiment of the present application.
[0143] It should be understood that the modules in the above devices can be implemented in the form of a processor calling software. For example, the device includes a processor, the processor is connected to a memory, and instructions are stored in the memory. The processor calls the instructions stored in the memory to implement any of the above methods or realize the functions of each unit of the device, wherein the processor can be a general-purpose processor, such as a CPU or a microprocessor, etc., and the memory can be a memory in the device or a memory outside the device. Alternatively, the unit in the device can be implemented in the form of a hardware circuit, and the functions of some or all units can be realized by designing the hardware circuit. The hardware circuit can be understood as one or more processors; for example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are realized by designing the logical relationship of the components in the circuit; for another example, in another implementation, the hardware circuit can be implemented by PLD, taking FPGA as an example, which can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured by a configuration file, so as to realize the functions of some or all of the above units. All units of the above devices can be implemented in the form of a processor calling software, or in the form of a hardware circuit, or in part by a processor calling software, and the remaining part is implemented in the form of a hardware circuit.
[0144] In an embodiment of the present application, a processor is a circuit with the ability to process signals. In one implementation, the processor may be a circuit with the ability to read and run instructions, such as a CPU, a microprocessor, a GPU, or a DSP; in another implementation, the processor may implement certain functions through the logical relationship of a hardware circuit, and the logical relationship of the hardware circuit is fixed or reconfigurable, such as a hardware circuit implemented by an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document to implement the hardware circuit configuration can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as an NPU, TPU, DPU, etc.
[0145] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.
[0146] In addition, all or part of the units in the above device can be integrated together, or can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a SOC. The SOC may include at least one processor for implementing any of the above methods or implementing the functions of each unit of the device. The type of the at least one processor may be different, for example, including a CPU and an FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.
[0147] Exemplary Electronic Devices
[0148] Another embodiment of the present application also provides an electronic device, see Figure 5 As shown, the device includes:
[0149] Memory 500 and processor 510;
[0150] The memory 500 is connected to the processor 510 and is used to store programs;
[0151] The processor 510 is used to implement the document similarity analysis method disclosed in any of the above embodiments by running the program stored in the memory 500.
[0152] Specifically, the electronic device may further include: a bus, a communication interface 520 , an input device 530 and an output device 540 .
[0153] The processor 510, the memory 500, the communication interface 520, the input device 530 and the output device 540 are connected to each other via a bus.
[0154] A bus may include a pathway that transfers information between components of a computer system.
[0155] The processor 510 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the scheme of the present invention. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0156] The processor 510 may include a main processor, and may also include a baseband chip, a modem, and the like.
[0157] The memory 500 stores a program for executing the technical solution of the present invention, and may also store an operating system and other key services. Specifically, the program may include a program code, and the program code includes a computer operation instruction. More specifically, the memory 500 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk storage, a flash, and the like.
[0158] The input device 530 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.
[0159] Output device 540 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0160] The communication interface 520 may include any transceiver or the like to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0161] The processor 510 executes the program stored in the memory 500 and calls other devices, which can be used to implement each step of any document similarity analysis method provided in the above embodiments of the present application.
[0162] Exemplary computer program products and storage media
[0163] In addition to the above methods and devices, the embodiments of the present application may also be a computer program product, which includes computer program instructions. When the computer program instructions are executed by a processor, the processor executes each step of the document similarity analysis method provided in the above embodiments.
[0164] The computer program product may be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages such as Java, C++, etc., and also conventional procedural programming languages such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0165] In addition, the embodiment of the present application may also be a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the processor executes each step of the document similarity analysis method provided in the above embodiment.
[0166] The computer readable storage medium may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable 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.
[0167] Specifically, the specific working contents of each part of the above-mentioned electronic device, computer program product and storage medium, as well as the specific processing contents when the computer program product or the computer program on the above-mentioned storage medium is executed by the processor, can all be found in the contents of the various embodiments of the above-mentioned document similarity analysis method, and will not be repeated here.
[0168] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.
[0169] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0170] The steps in the methods of each embodiment of the present application can be adjusted in order, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.
[0171] The modules and sub-modules in the devices and terminals in the various embodiments of the present application can be combined, divided and deleted according to actual needs.
[0172] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, such as multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0173] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0174] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.
[0175] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0176] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0177] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including a..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0178] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A document similarity analysis method, It is characterized in that include: Extracting text segments and images from the first document and the second document respectively, and determining objects to be analyzed in the first document and the second document, wherein each text segment and each image in the document is regarded as an object to be analyzed; Determining representations of each object to be analyzed in the first document and the second document respectively; Determining similar objects to be analyzed by comparing the representations of each object to be analyzed in the first document with the representations of each object to be analyzed in the second document; By performing content-based similarity analysis on the similar objects to be analyzed, a similarity analysis result of the first document and the second document is obtained.
2. The method according to claim 1, It is characterized in that The step of respectively determining the representations of the objects to be analyzed in the first document and the second document includes: For the text segments in the first document and the second document, determining the representation of the text segments by using a first hash algorithm; and / or, For the images in the first document and the second document, a representation of the image is determined by a second hash algorithm.
3. The method according to claim 1, It is characterized in that The determining similar objects to be analyzed by comparing the representations of each object to be analyzed in the first document with the representations of each object to be analyzed in the second document includes: For a first object to be analyzed in the first document and a second object to be analyzed in the second document, calculating a ratio of an intersection of a representation of the first object to be analyzed and a representation of the second object to be analyzed to a union of a representation of the first object to be analyzed and a representation of the second object to be analyzed, to obtain a similarity between the first object to be analyzed and the second object to be analyzed; When the similarity between the first object to be analyzed and the second object to be analyzed is greater than a first similarity threshold, the first object to be analyzed and the second object to be analyzed are determined to be similar objects to be analyzed.
4. The method according to any one of claims 1 to 3, It is characterized in that The obtaining of similarity analysis results of the first document and the second document by performing content-based similarity analysis on the similar objects to be analyzed includes: In the case where the similar objects to be analyzed are similar text segments, determining text similarity information of the similar objects to be analyzed by comparing text contents of the similar objects to be analyzed; In the case where the similar objects to be analyzed are similar images, determining image similarity information of the similar objects to be analyzed by comparing image contents of the similar objects to be analyzed; The similarity analysis result of the first document and the second document is determined by using the text similarity information and / or the image similarity information.
5. The method according to claim 4, It is characterized in that Determining text similarity information of the similar objects to be analyzed by comparing the text contents of the similar objects to be analyzed includes: By comparing the text contents of the similar objects to be analyzed, determining the common text contents and edit distances of the similar objects to be analyzed; and / or, Determining image similarity information of the similar objects to be analyzed by comparing image contents of the similar objects to be analyzed includes: Acquire the image contents of the similar objects to be analyzed respectively through the large language model; By comparing the image contents of the similar objects to be analyzed, similar image contents of the similar objects to be analyzed are determined.
6. The method according to claim 4, It is characterized in that The method further comprises: determining the position of each of the similar objects to be analyzed in the document to which it belongs; Determining similarity analysis results of the first document and the second document by using the text similarity information and / or the image similarity information includes: The similarity analysis results of the first document and the second document are generated by using the text similarity information and / or the image similarity information and the positions of the similar objects to be analyzed in the documents to which they belong.
7. A document similarity analysis device, It is characterized in that include: An extraction module, used to extract text segments and images from the first document and the second document respectively, and determine objects to be analyzed in the first document and the second document, wherein each text segment and each image in the document is respectively regarded as an object to be analyzed; A processing module, configured to respectively determine representations of each object to be analyzed in the first document and the second document; A comparison module, configured to determine similar objects to be analyzed by comparing the representations of the objects to be analyzed in the first document with the representations of the objects to be analyzed in the second document; The analysis module is used to obtain similarity analysis results of the first document and the second document by performing content-based similarity analysis on the similar objects to be analyzed.
8. An electronic device, It is characterized in that include: Memory and processor; The memory is connected to the processor and is used to store programs; The processor implements the document similarity analysis method according to any one of claims 1 to 6 by running the program in the memory.
9. A storage medium, It is characterized in that The storage medium stores a computer program, and when the computer program is executed by the processor, the document similarity analysis method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the document similarity analysis method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Large-scale document similarity detection method
CN108595517A
Image-text duplicate removal method and device
CN114328884A
Image-text combined document similarity discrimination method and system
CN117350269A
