A text similarity calculation method, device, equipment and storage medium

By identifying and replacing mathematical symbols in the text, calculating primary representation vectors through word segmentation, and using a multi-semantic encoder to calculate similarity, the problem of accuracy and stability of text similarity calculation results in the existing technology is solved, and a more accurate and stable result is achieved. Stable similarity assessment.

CN113987115BActive Publication Date: 2024-10-15华润数字科技(西安)有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111129085.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-26
Publication Date
2024-10-15
Estimated Expiration
2041-09-26

AI Technical Summary

Technical Problem

When calculating text similarity, the existing technology calculates and assigns weights to text, numbers, and mathematical operation symbols separately, causing the accuracy and stability of the results to be affected by subjectivity and unable to globally reflect the actual similarity between texts.

Method used

By identifying the mathematical symbols in the text to be compared and replacing them with text descriptions, calculating the primary representation vector after word segmentation, using the semantic encoder to generate the final representation vector, and calculating the similarity through the multi-semantic encoder, avoiding the need for each part. Independent similarity calculation improves the accuracy and stability of calculation.

Benefits of technology

It improves the accuracy and stability of text similarity calculation, simplifies the calculation process, and enhances the overall understanding of text similarity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113987115B_ABST
    Figure CN113987115B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention belongs to the field of artificial intelligence, and in particular, relates to a method, device, equipment and storage medium for calculating text similarity, wherein the method comprises: identifying mathematical symbols in the text to be compared, searching for the text description corresponding to the mathematical symbols according to a preset symbol-text dictionary, and replacing the mathematical symbols in the text to be compared with the found text description; performing word segmentation on the text to be compared, and calculating the primary representation vector of each sentence in the text to be compared based on the word segmentation, wherein the text to be compared is at least two; inputting the primary representation vector of each sentence in different texts to be compared into a semantic encoder, calculating the final representation vector of the text to be compared by the semantic encoder, and the semantic encoder is at least two; and the semantic encoder inputs the final representation vector of the text to be compared into a similarity calculator to obtain the similarity of two different texts to be compared. The present invention improves the stability and accuracy of similarity calculation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a text similarity calculation method, device, equipment and storage medium. Background Art

[0002] As a classic task in the field of natural language processing, text similarity calculation has formed many methods in long-term practice. The main ideas can be divided into several categories. The first category is based on feature engineering. By extracting keywords, subject terms and other information from documents, various similarity methods are used to calculate the semantic similarity between the documents being compared. In order to overcome the defect of the first category of methods that only matches similarity at the character level, the second category of methods uses a deep neural network to map the original text into a vector at a higher semantic level, and then calculates the semantic similarity. This type of method has a higher degree of generalization and better robustness.

[0003] For the case where the text contains both text, numbers and mathematical symbols, the current mainstream method is to calculate the similarity of the text and number parts separately, then assign different weights to each method, and finally take the weighted sum as the final text similarity.

[0004] However, the inventors found that the similarity of each part cannot reflect the actual similarity between texts from a global perspective, and the setting of weights is highly subjective, which affects the accuracy and stability of the final result. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a text similarity calculation method, device, equipment and storage medium, which solves the problem in the prior art that the accuracy and stability of the similarity calculation results are affected by subjective setting parameters.

[0006] In order to solve the above technical problems, an embodiment of the present invention provides a method for calculating text similarity, including: identifying mathematical symbols in a text to be compared, searching for text descriptions corresponding to the mathematical symbols according to a preset symbol-text dictionary, and replacing the mathematical symbols in the text to be compared with the searched text descriptions; segmenting the text to be compared, and calculating a primary representation vector of each sentence in the text to be compared based on the word segmentation, wherein there are at least two texts to be compared; inputting the primary representation vector of each sentence in different texts to be compared into a semantic encoder, and obtaining a final representation vector of the text to be compared by calculating the corresponding semantic encoder, wherein there are at least two semantic encoders; and the semantic encoder inputting the final representation vector of the text to be compared into a similarity calculator to obtain the similarity of two different texts to be compared.

[0007] Furthermore, the step of calculating the primary representation vector of each sentence in the text to be compared based on the word segmentation specifically includes: obtaining the word embedding vector of the word segmentation according to the word vector model; obtaining the semantic role vector of the word segmentation according to the question bank model; obtaining the position vector of the word segmentation according to the index position of the word segmentation in the sentence; adding the elements of each dimension in the word embedding vector, semantic role vector and position vector of each sentence in the text to be compared after word segmentation, to obtain the primary representation vector of each sentence.

[0008] Furthermore, the question bank model presets the core arguments, auxiliary arguments and semantic roles of the words. The step of obtaining the semantic role vector of the word segmentation based on the question bank model specifically includes: counting the frequency of occurrence of each semantic role in the text to be compared, dividing it by the total frequency of occurrence of the semantic role, to obtain the semantic role weight; forming the semantic role vector based on the core arguments, auxiliary arguments and semantic role weights.

[0009] Furthermore, the step of forming the semantic role vector based on the core arguments, auxiliary arguments and semantic role weights specifically includes: identifying the types of semantic roles, mainly based on the types of the core arguments of the word and supplemented by the types of auxiliary arguments, and forming an N-dimensional vector in the form of one-hot encoding; adding the semantic role weights of the segmentation to the dimensions of the core arguments of the N-dimensional vector to form the semantic role vector.

[0010] Furthermore, the step of obtaining the position vector of the word segment according to the index position of the word segment in the sentence specifically includes: calculating the position vector according to the following formula:

[0011]

[0012]

[0013] Among them, pos indicates the word number of the word in the sentence, i is the dimension in the position vector, and dmodel indicates the dimension of the given position vector.

[0014] Furthermore, before the step of inputting the primary representation vector of each sentence in the different texts to be compared into the corresponding semantic encoder, it also includes: pre-building a text similarity calculation model in which multiple semantic encoders are imported into the similarity calculator, wherein there are at least two semantic encoders; and the semantic encoders have the same structure.

[0015] Furthermore, the semantic encoder inputs the final representation vector of the text to be compared into the similarity calculator to obtain the similarity between two different texts to be compared, which specifically includes: based on the text similarity calculation model imported into the similarity calculator by the multi-semantic encoder, each of the semantic encoders inputs the received final representation vector of the text to be compared into the similarity calculator, and the similarity calculator performs pairwise similarity calculations on different texts to be compared to obtain the similarity between two different texts to be compared.

[0016] In order to solve the above technical problems, an embodiment of the present invention further provides a text similarity calculation device, comprising: a first processing module, used to identify mathematical symbols in the text to be compared, search for the text description corresponding to the mathematical symbols according to a preset symbol-text dictionary, and replace the mathematical symbols in the text to be compared with the searched text description; a second processing module, used to segment the text to be compared, and calculate the primary representation vector of each sentence in the text to be compared based on the word segmentation, wherein the text to be compared is at least two; a third processing module, used to input the primary representation vector of each sentence in the different texts to be compared into a semantic encoder, and calculate the final representation vector of the text to be compared through the corresponding semantic encoder, wherein the semantic encoder is at least two; a text similarity calculation module, used to receive the final representation vector of the text to be compared input by at least two semantic encoders, and calculate the similarity of two different texts to be compared.

[0017] In order to solve the above technical problems, an embodiment of the present invention further provides a text similarity calculation device, which includes a processor, a memory, and a text similarity calculation program stored in the memory. When the text similarity calculation program is executed by the processor, the steps of the text similarity calculation method as described above are implemented.

[0018] In order to solve the above technical problem, an embodiment of the present invention further provides a computer-readable storage medium, on which a text similarity calculation program is stored. When the text similarity calculation program is executed by a processor, the steps of the text similarity calculation method as described above are implemented.

[0019] Compared with the prior art, the embodiments of the present invention mainly have the following beneficial effects: by identifying mathematical symbols in the text to be compared, searching for the text description corresponding to the mathematical symbols according to the symbol-text dictionary, and replacing the mathematical symbols in the text to be compared with the found text description, the disadvantages of the prior art that the compared text contains both text and numbers and mathematical operation symbols, which results in the need to perform independent similarity calculations on the text and number parts respectively, and subjectively setting the weights of each part, are avoided, thereby improving the accuracy and stability of the final result of the similarity calculation.

[0020] In addition, by segmenting the text to be compared, and calculating the primary representation vector of each sentence based on the word embedding vector, semantic role vector, and position vector after segmentation, especially through the semantic role vector, the importance of different words in the sentence is considered from the semantic role, which further improves the accuracy of the similarity calculation; the text similarity calculation model based on the multi-semantic encoder imported into the similarity calculator can easily compare different texts to be compared pairwise, which also improves the efficiency of the similarity calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the scheme in the present invention, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0022] Figure 1 A flowchart of an embodiment of a method for calculating text similarity according to the present invention;

[0023] Figure 2 is a structural schematic diagram of an embodiment of a text similarity calculation model according to the present invention;

[0024] Figure 3 is a structural schematic diagram of an embodiment of a text similarity calculation device according to the present invention;

[0025] Figure 4 1 is a schematic diagram of the structure of an embodiment of a text similarity calculation device according to the present invention. DETAILED DESCRIPTION

[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present invention; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention; the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present invention or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0027] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0028] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.

[0029] The embodiment of the present invention proposes a text similarity calculation method, device, equipment and storage medium. The text similarity calculation method of the embodiment of the present invention is generally executed by a terminal device, which can be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop portable computers and desktop computers, etc.

[0030] like Figure 1 FIG. 2 is a flowchart of an embodiment of a text similarity calculation method according to the present invention. The text similarity calculation method comprises the following steps:

[0031] Step 101, identifying mathematical symbols in the text to be compared, searching for text descriptions corresponding to the mathematical symbols according to a symbol-text dictionary, and replacing the mathematical symbols in the text to be compared with the searched text descriptions.

[0032] In an embodiment of the present invention, a correspondence between mathematical symbols and text descriptions is preset, and a symbol-text dictionary is formed based on the correspondence. Specifically, a set of mathematical operation symbols, such as addition, subtraction, multiplication, division, square, cube, etc., is obtained, and a text description corresponding to each mathematical symbol is set to form a pair of mathematical symbols and text descriptions, and all sets of mathematical symbols and text description pairs form a symbol-text dictionary. Taking addition as an example, the format of the symbol-text dictionary can be [symbol: +, text description: add, add]. The above is only an example, but not limited to this. Each text description can include all customary expressions, synonyms, near-synonymous descriptions, etc. for the symbol.

[0033] When there is a text to be compared, identify whether there are mathematical symbols in the text to be compared. If there are data symbols, find the text description corresponding to the mathematical symbols according to the preset symbol-text dictionary, and replace the mathematical symbols in the text to be compared with the found text description to form a text to be compared that only contains text descriptions.

[0034] Step 102: segment the text to be compared, and calculate a primary representation vector of each sentence in the text to be compared based on the segmentation, wherein there are at least two texts to be compared.

[0035] In an embodiment of the present invention, the comparison text is segmented according to a certain strategy. It can be a dictionary-based segmentation, for example, first divide the sentence into words according to the dictionary, and then find the best combination of words; the algorithm used can be a maximum matching segmentation algorithm, a shortest path segmentation algorithm, an n-grammodel-based segmentation algorithm, etc. It can also be a character-based segmentation, for example, forming words by characters, first divide the sentence into individual characters, and then combine the characters into words to find the optimal segmentation strategy, and it can also be converted into sequence annotation; the algorithm used can be a generative model segmentation algorithm, a discriminative model segmentation algorithm, a neural network segmentation algorithm, etc. The above various segmentation algorithms are only examples, but are not limited to this.

[0036] The primary representation vector of each sentence in the text to be compared is calculated based on the word segmentation, specifically: according to the word vector model, the word embedding vector of the word segmentation is obtained; according to the question bank model, the semantic role vector of the word segmentation is obtained, and the question bank model presets the core argument, auxiliary argument and semantic role of the word; according to the index position of the word segmentation in the sentence, the position vector of the word segmentation is obtained; the elements of each dimension in the word embedding vector, semantic role vector and position vector of each sentence in the text to be compared are added after the word segmentation, so as to obtain the primary representation vector of each sentence.

[0037] Among them, set SE ij is the word embedding vector corresponding to the jth word in the ith sentence. Embedding a language word into a vector space is called word embedding. In this embodiment, the word embedding model can use the word2vec word embedding vector open sourced by Google, or randomly initialized. Google's open source word2vec is a word embedding tool that can generate word vectors, through which the similarity between words can be measured.

[0038] Set SS ijis the semantic role vector corresponding to the jth word in the ith sentence. According to the theory of Chinese linguistics, each word in a sentence has its specific semantic role, and the semantic role can be divided into two categories: core arguments and auxiliary arguments. In this embodiment, the question bank model adopts the Chinese Proposition Bank, which defines the core arguments, auxiliary arguments and various semantic roles of words. Assuming that the type of semantic role is N, the type of core argument is Ncore, and the type of auxiliary argument is Naux, an N-dimensional vector can be formed in the form of one-hot encoding. One-hot encoding is a vector in which one dimension is 1 and the other dimensions are all 0, that is, [1, 0, 0, 0, ..., 0]. The difference in the embodiment of the present invention is that the semantic role weight is added to the dimension where the core argument is located. The method for calculating the semantic role weight is: counting the frequency of occurrence of each semantic role in the text to be compared, divided by the total frequency of occurrence of the semantic role. For example, if a core argument is given a weight of 0.2, the final vector will be [1.2, 0, 0, 0, ..., 0]. The dimension of the core argument is 1, and the dimension of the auxiliary argument is 0.

[0039] Setting SP ij is the position index of the jth word in the i-th sentence. The position vector corresponding to each position index is represented by PE, and the calculation formula is as follows:

[0040]

[0041]

[0042] Among them, pos indicates the word number of the word in the sentence, i is the dimension in the position vector, and dmodel indicates the dimension of the given position vector, for example, it can be represented by the numbers 512 or 1024.

[0043] Step 103, inputting the primary representation vector of each sentence in the different texts to be compared into a semantic encoder, and calculating the final representation vector of the texts to be compared through the corresponding semantic encoder, wherein there are at least two semantic encoders.

[0044] In an embodiment of the present invention, the semantic encoder is a pre-trained language model trained by a deep neural network, which may be BERT, RoBERTa, ALBERT, ERNIE, ELECTRA, etc., without specific limitation.

[0045] A text similarity calculation model in which multiple semantic encoders are pre-built and imported into a similarity calculator, wherein there are at least two semantic encoders, and the two encoders have the same structure, for example Figure 2As shown in the figure, the text similarity calculation model of the dual-tower encoder is that the two semantic encoders receive the primary representation vectors of each sentence in two different texts to be compared, such as Figure 2 The semantic encoder in receives the SS of each sentence in the text to be compared ij (the semantic role vector corresponding to the jth word in the i-th sentence), SE ij (the word embedding vector corresponding to the jth word in the i-th sentence) and SP ij (position index of the jth word in the ith sentence), and then the mean square error loss function can be used to train the primary representation vector of each sentence in the received text to be compared, and the SGD, Adam and other methods can be used to optimize the training results during the training process to obtain the final representation vector of the text to be compared.

[0046] In step 104, each of the semantic encoders inputs the final representation vector of the text to be compared into a similarity calculator to obtain the similarity between two different texts to be compared.

[0047] In an embodiment of the present invention, based on a text similarity calculation model in which multiple semantic encoders are imported into a similarity calculator, each of the semantic encoders inputs the final representation vector of the received text to be compared into the similarity calculator, and the similarity calculator performs pairwise similarity calculations on different texts to be compared to obtain the similarity of two different texts to be compared. The similarity calculation method of the similarity calculator can preferably be cosine similarity, and of course, Euclidean distance, Pearson correlation coefficient, modified cosine similarity, Hamming distance, Manhattan distance, etc. can also be used, without specific limitation.

[0048] In an embodiment of the present invention, by identifying mathematical symbols in the text to be compared, searching for the text description corresponding to the mathematical symbols according to the symbol-text dictionary, and replacing the mathematical symbols in the text to be compared with the found text description, the disadvantage of the prior art that the compared text contains both text and numbers and mathematical operation symbols, which requires independent similarity calculations for the text and number parts, and subjectively setting the weights of each part, is avoided, thereby improving the accuracy and stability of the final result of the similarity calculation. In addition, by segmenting the text to be compared, and calculating the primary representation vector of each sentence based on the word embedding vector, semantic role vector, and position vector after segmentation of each sentence, especially by considering the importance of different words in the sentence from the semantic role through the semantic role vector, the accuracy of the similarity calculation is further improved; the text similarity calculation model based on the multi-semantic encoder imported into the similarity calculator can easily compare different texts to be compared in pairs, and also improve the efficiency of the similarity calculation.

[0049] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0050] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0051] Further references Figure 3 , as a response to the above Figure 1 and 2 The present invention provides an embodiment of a text similarity calculation device 300, which is similar to Figure 1 The method embodiment shown corresponds to the embodiment shown in FIG. Figure 3 As shown, the embodiment of the present invention further provides a text similarity calculation device 300, comprising:

[0052] The first processing module 31 is used to identify mathematical symbols in the text to be compared, search for text descriptions corresponding to the mathematical symbols according to a preset symbol-text dictionary, and replace the mathematical symbols in the text to be compared with the searched text descriptions;

[0053] A second processing module 32 is used to perform word segmentation on the text to be compared, and calculate a primary representation vector of each sentence in the text to be compared based on the word segmentation, wherein there are at least two texts to be compared;

[0054] A third processing module 33 is used to input the primary representation vector of each sentence in the different to-be-compared texts into a semantic encoder, and calculate the final representation vector of the to-be-compared texts through the corresponding semantic encoder, and there are at least two semantic encoders;

[0055] The text similarity calculation module 34 is used to receive the final representation vectors of the texts to be compared input by at least two semantic encoders, and calculate the similarities between two different texts to be compared.

[0056] In some optional implementations of the present embodiment, the first processing module specifically includes: a setting submodule and a replacement submodule; wherein the setting submodule is used to pre-set the correspondence between mathematical symbols and text descriptions, and form a symbol-text dictionary based on the correspondence; the replacement submodule is used to identify mathematical symbols in the text to be compared, search for the text description corresponding to the mathematical symbols according to a preset symbol-text dictionary, and replace the mathematical symbols in the text to be compared with the found text description.

[0057] In some optional implementations of the present embodiment, the second processing module specifically includes: a vector generation submodule and a vector calculation submodule; wherein the vector generation submodule is used to obtain the word embedding vector of the segmented word according to the word vector model; obtain the semantic role vector of the segmented word according to the question bank model, and the question bank model presets the core arguments, auxiliary arguments and semantic roles of the words; obtain the position vector of the segmented word according to the index position of the segmented word in the sentence; the vector calculation submodule is used to add the elements of each dimension in the word embedding vector, semantic role vector and position vector of each sentence in the text to be compared after the segmentation, so as to obtain the primary representation vector of each sentence.

[0058] In some optional implementations of the present embodiment, the text similarity calculation device specifically includes: a construction submodule and a similarity calculation submodule; wherein the construction submodule is used to pre-construct a text similarity calculation model for multiple semantic encoders to be imported into a similarity calculator, wherein there are at least two semantic encoders and the semantic encoders have the same structure; the similarity calculation submodule is used to input the final representation vector of the text to be compared received by each of the semantic encoders into the similarity calculator, and the similarity calculator performs pairwise similarity calculations on different texts to be compared to obtain the similarity between two different texts to be compared.

[0059] The methods of vector generation, vector calculation, text similarity calculation, etc. involved in each module can refer to the various embodiments of the similarity calculation method described above in the text of the present invention, and will not be repeated here.

[0060] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0061] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0062] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0063] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the computer device 4. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the text similarity calculation method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0064] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the text similarity calculation method.

[0065] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0066] The embodiment of the present invention further provides a computer-readable storage medium, on which a text similarity calculation program is stored. When the text similarity calculation program is executed by a processor, the steps of the text similarity calculation method described above are implemented. The method implemented when the text similarity calculation program is executed can refer to the various embodiments of the text similarity calculation method of the present invention, which will not be repeated here.

[0067] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0068] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific embodiments, or to perform equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of the present invention, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.

Claims

1. A text similarity calculation method, It is characterized in that The steps include: Identify mathematical symbols in the text to be compared, search for text descriptions corresponding to the mathematical symbols according to a preset symbol-text dictionary, and replace the mathematical symbols in the text to be compared with the searched text descriptions; Segmenting the text to be compared, and calculating a primary representation vector of each sentence in the text to be compared based on the segmentation, wherein there are at least two texts to be compared, and the step of calculating a primary representation vector of each sentence in the text to be compared based on the segmentation specifically includes: According to the word vector model, obtain the word embedding vector of the word segmentation; According to the question bank model, a semantic role vector of the word segmentation is obtained; Obtaining a position vector of the word segmentation according to the index position of the word segmentation in the sentence; Adding the elements of each dimension in the word embedding vector, semantic role vector and position vector of each sentence in the compared text after word segmentation to obtain a primary representation vector of each sentence; Inputting the primary representation vector of each sentence in the different to-be-compared texts into a semantic encoder, and calculating the final representation vector of the to-be-compared texts through the semantic encoder, wherein there are at least two semantic encoders; and The semantic encoder inputs the final representation vector of the text to be compared into the similarity calculator to obtain the similarity between two different texts to be compared.

2. The text similarity calculation method according to claim 1, It is characterized in that The question bank model presets the core arguments, auxiliary arguments and semantic roles of words; the step of obtaining the semantic role vector of the word segmentation according to the question bank model specifically includes: Counting the frequency of occurrence of each semantic role in the text to be compared, and dividing it by the total frequency of occurrence of the semantic role, to obtain the semantic role weight; The semantic role vector is formed according to the core argument, the auxiliary argument and the semantic role weight.

3. The text similarity calculation method according to claim 2, It is characterized in that The step of forming the semantic role vector according to the core argument, the auxiliary argument and the semantic role weight specifically includes: Identify the types of semantic roles, mainly based on the types of core arguments of the word, supplemented by the types of auxiliary arguments, and use one-hot encoding to form an N-dimensional vector; The semantic role weights of the word segments are respectively added to the dimensions where the core argument of the N-dimensional vector is located to form the semantic role vector.

4. The text similarity calculation method according to claim 1, It is characterized in that The step of obtaining the position vector of the word segment according to the index position of the word segment in the sentence specifically includes: calculating the position vector PE according to the following formula: Among them, pos indicates the word number of the word in the sentence, i is the dimension in the position vector, and dmodel indicates the dimension of the given position vector.

5. The text similarity calculation method according to claim 2, It is characterized in that Before the step of inputting the primary representation vector of each sentence in the different texts to be compared into the semantic encoder, the method further includes: A text similarity calculation model in which multiple semantic encoders are pre-built and imported into a similarity calculator, wherein there are at least two semantic encoders and the semantic encoders have the same structure.

6. The text similarity calculation method according to claim 5, It is characterized in that The semantic encoder inputs the final representation vector of the text to be compared into the similarity calculator to obtain the similarity between two different texts to be compared, specifically including: Based on the text similarity calculation model imported by the multi-semantic encoder into the similarity calculator, the final representation vector of the text to be compared received by each semantic encoder is input into the similarity calculator, and the similarity calculator performs pairwise similarity calculation on different texts to be compared to obtain the similarity between two different texts to be compared.

7. A text similarity calculation device, It is characterized in that The text similarity calculation device is used to implement the steps of the text similarity calculation method according to any one of claims 1 to 6, and the text similarity calculation device includes: A first processing module is used to identify mathematical symbols in the text to be compared, search for text descriptions corresponding to the mathematical symbols according to a preset symbol-text dictionary, and replace the mathematical symbols in the text to be compared with the searched text descriptions; A second processing module is used to perform word segmentation on the text to be compared, and calculate a primary representation vector of each sentence in the text to be compared based on the word segmentation, wherein there are at least two texts to be compared; A third processing module is used to input the primary representation vector of each sentence in the different to-be-compared texts into a semantic encoder, and calculate the final representation vector of the to-be-compared texts through the corresponding semantic encoder, wherein there are at least two semantic encoders; The text similarity calculation module is used to receive the final representation vector of the text to be compared input by at least two semantic encoders, and calculate the similarity between two different texts to be compared.

8. A text similarity calculation device, It is characterized in that The text similarity calculation device comprises a processor, a memory and a text similarity calculation program stored in the memory. When the text similarity calculation program is executed by the processor, the steps of the text similarity calculation method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a text similarity calculation program, and when the text similarity calculation program is executed by the processor, the steps of the text similarity calculation method according to any one of claims 1 to 6 are implemented.