Text similarity determination method and device, storage medium and electronic device
By calculating text similarity using the target model and the vector index of the preset database in a large data volume scenario, the problem of inaccurate text matching is solved and the accuracy of text matching is improved.
Patent Information
- Application Number
- CN202210302015.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-25
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-03-25
AI Technical Summary
The existing technology has the problem of inaccurate text matching in large data scenarios.
By inputting the target text into the first target model, extracting feature variables and converting them into target vectors, using the vector index and vector index in the preset database to calculate the distance and determine the similarity, the text matching is performed by combining the multi-head attention network and the embedding layer.
The text matching accuracy is improved in large data volume scenarios by accurately matching the similarities between texts.
Smart Images

Figure CN114742139B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing, and more specifically, to a method, device, storage medium, and electronic device for determining text similarity. Background Art
[0002] In today's big data era, vast quantities of structured and unstructured data are generated daily. Text data, particularly in search and conversation, is experiencing exponential growth. In the internet age, algorithms are gradually transforming our lives and lifestyles. In the natural language realm, text similarity algorithms are becoming increasingly important in this era of massive text volumes. They are used in any context involving knowledge and information. Currently, they are widely used in search engines, recommendation systems, paper authentication, machine translation, automated answering, and spelling correction. Traditional text retrieval and similarity calculation algorithms are struggling to cope with such large data volumes. Summary of the Invention
[0003] Embodiments of the present invention provide a method, device, storage medium, and electronic device for determining text similarity, so as to at least solve the problem of inaccurate text matching in related technologies.
[0004] According to one embodiment of the present invention, a method for determining text similarity is provided, comprising: inputting an acquired target text into a first target model to obtain a target vector of the target text output by the first target model; obtaining N vectors from a preset database based on the target vector, wherein N is a natural number greater than or equal to 1; and using the N vectors and the target vector, determining the similarity between the text corresponding to each of the N vectors and the target text.
[0005] According to another embodiment of the present invention, a device for determining text similarity is provided, including: a first input module, used to input the acquired target text into a first target model to obtain a target vector of the target text output by the above-mentioned first target model; a first acquisition module, used to obtain N vectors from a preset database based on the above-mentioned target vector, wherein the above-mentioned N is a natural number greater than or equal to 1; a first determination module, used to use the above-mentioned N vectors and the above-mentioned target vector to determine the similarity between the text corresponding to each vector in the above-mentioned N vectors and the above-mentioned target text.
[0006] In an exemplary embodiment, the above-mentioned first input module includes: a first extraction unit, used to extract the feature variables of the above-mentioned target text through the multi-head attention network in the above-mentioned first target model; a first conversion unit, used to use the embedding layer Embedding in the above-mentioned first target model to convert the above-mentioned feature variables into feature vectors to obtain the target vector of the above-mentioned target text.
[0007] In an exemplary embodiment, the above-mentioned first acquisition module includes: a first determination unit, used to determine the vector index of the above-mentioned target vector stored in the above-mentioned preset database; a first calculation unit, used to calculate the distance between the vector index of the above-mentioned target vector and the vector index of each vector in the above-mentioned preset database, and determine M distances, wherein the above-mentioned M is a natural number greater than or equal to the above-mentioned N; a second determination unit, used to determine the vectors corresponding to the distances greater than the preset threshold among the above-mentioned M distances as the above-mentioned N vectors.
[0008] In an exemplary embodiment, the above-mentioned first determination module includes: a third determination unit, used to determine the text corresponding to each of the above-mentioned N vectors, and determine N texts; a first input unit, used to input the above-mentioned target text and the above-mentioned N texts into the second target model, and obtain a similarity result between the text corresponding to each of the above-mentioned vectors output by the above-mentioned second target model and the above-mentioned target text.
[0009] In an exemplary embodiment, the above-mentioned first input unit includes: a first input subunit, used to input the above-mentioned target text and the above-mentioned N texts into the entity structure in the above-mentioned second target model to obtain the target embedding vector of the above-mentioned target text and the N embedding vectors of the above-mentioned N texts; a first calculation subunit, used to calculate the difference between the above-mentioned target embedding vector and each of the above-mentioned N embedding vectors; a first splicing subunit, used to splice the above-mentioned target embedding vector, each of the above-mentioned embedding vectors, and the difference between the above-mentioned target embedding vector and each of the above-mentioned embedding vectors to determine N splicing vectors; a first output subunit, used to output the above-mentioned similarity result based on the above-mentioned N splicing vectors.
[0010] In an exemplary embodiment, the above-mentioned first output sub-unit includes: a first input sub-module, used to input each of the above-mentioned splicing vectors into the fully connected layer in the above-mentioned second target model, and obtain the probability value of the above-mentioned fully connected layer output for binary classification of each of the above-mentioned splicing vectors; a first output sub-module, used to output the above-mentioned similarity result based on the above-mentioned probability value.
[0011] In an exemplary embodiment, the similarity result is output based on the probability value in the following manner: comparing the probability value with a second preset threshold; and outputting the similarity result using the comparison result.
[0012] In an example embodiment, the device further comprises: a first extraction module configured to extract feature variables of the M texts by a multi-head attention network in the first target model before the N vectors are obtained from the preset database based on the target vector, wherein M is a natural number greater than or equal to N; a first conversion module configured to convert the feature variables of the M texts into feature vectors by an embedding layer in the first target model to obtain the M vectors; and a first storage module configured to store the M vectors into the preset database according to indexes and vectorized representations of the M texts.
[0013] According to another embodiment of the present application, a computer readable storage medium is also provided, and the computer readable storage medium stores a computer program, wherein the computer program is configured to execute the steps in any of the method embodiments when running.
[0014] According to another embodiment of the present application, an electronic device is also provided, and the electronic device comprises a memory and a processor, the memory stores a computer program, and the processor is configured to execute the computer program to execute the steps in any of the method embodiments.
[0015] According to the present application, the target text obtained is input into the first target model to obtain a target vector of the target text output by the first target model; N vectors are obtained from a preset database based on the target vector, wherein N is a natural number greater than or equal to 1; and the similarity between the text corresponding to each of the N vectors and the target text is determined by using the N vectors and the target vector. Instead of extracting keywords for recall calculation in a large amount of text, the present application matches from the text level to achieve accurate matching between texts. Therefore, the problem of inaccurate text matching in the related art can be solved, and the accuracy of text matching can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and serve to explain the principles of the present application together with the specification.
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0018] Figure 1 is a hardware environment schematic diagram of a text similarity determination method according to an embodiment of the present application;
[0019] Figure 2is a flow chart of a method for determining text similarity according to an embodiment of the present invention;
[0020] Figure 3 is an overall flow chart of a method for determining text similarity according to an embodiment of the present invention;
[0021] Figure 4 4 is a structural block diagram of a device for determining text similarity according to an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] According to one aspect of the embodiment of the present application, a method for determining text similarity is provided. The method for determining text similarity is widely used in text retrieval scenarios. Optionally, in this embodiment, the above-mentioned method for determining text similarity can be applied to Figure 1 In the hardware environment shown in FIG. 1 , which is composed of a terminal device 102 and a server 104. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or the client installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0025] The aforementioned network may include, but is not limited to, at least one of the following: a wired network and a wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, and a local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity) and Bluetooth. The terminal device 102 may be, but is not limited to, a PC, a mobile phone, a tablet computer, etc.
[0026] In this embodiment, a method for determining text similarity is provided. Figure 2 is a flow chart of a method for determining text similarity according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0027] Step S202: input the acquired target text into the first target model to obtain a target vector of the target text output by the first target model;
[0028] For example, the obtained “artificial intelligence technology” is input into the first target model, and the first target model outputs “0010100110”.
[0029] Step S204: Obtain N vectors from a preset database based on the target vector, where N is a natural number greater than or equal to 1;
[0030] For example, by using the vector index stored in the preset database, you can search for vectors matching "0010100110". For example, by using the Faiss and HNSWLib vector indexes, you can achieve a search efficiency of milliseconds for millions of short texts.
[0031] Step S206 : using the N vectors and the target vector, determining the similarity between the text corresponding to each of the N vectors and the target text.
[0032] The execution subject of the above steps may be a terminal, etc., but is not limited thereto.
[0033] Through the above steps, the acquired target text is input into the first target model to obtain a target vector for the target text output by the first target model; based on the target vector, N vectors are retrieved from a preset database, where N is a natural number greater than or equal to 1; and the similarity between the text corresponding to each of the N vectors and the target text is determined using the N vectors and the target vector. Matching is performed at the text level, achieving precise matching between texts. Therefore, the problem of inaccurate text matching in related technologies can be resolved, achieving improved text matching accuracy.
[0034] In an exemplary embodiment, inputting the acquired target text into the first target model to obtain a target vector of the target text output by the first target model includes:
[0035] S11, extracting the feature variables of the target text through the multi-head attention network in the first target model;
[0036] S12, using the embedding layer in the first target model to convert the feature variable into a feature vector to obtain a target vector of the target text.
[0037] For example, the target text is passed into the first target model, and the text feature extraction of the multi-head attention network is performed, and the fixed-length vectorized result after embedding is output.
[0038] In an exemplary embodiment, obtaining N vectors from a preset database based on a target vector includes:
[0039] S31, determining a vector index for storing the target vector in a preset database;
[0040] For example, after building the first target model, optimize the attention mechanism within it. Pass massive amounts of historical text into the first target model, perform text feature extraction using a multi-head attention network, and output a fixed-length vectorized result after embedding. The index of the massive amount of historical text is used as the key, and the vectorized representation is stored as the value in a columnar database.
[0041] S32, calculating the distance between the vector index of the target vector and the vector index of each vector in the preset database, and determining M distances, where M is a natural number greater than or equal to N;
[0042] For example, vector indexing can be used to calculate Euclidean distances between vectors with massive text data in columnar databases. During the calculation and retrieval process, vector indexing calculations are optimized using the open source libraries Faiss (Facebook AI Similarity Search) and HNSWLib (a Java library for approximate nearest neighbor search using a hierarchical navigable small-world graph). This allows for millisecond-level search efficiency for millions of short texts.
[0043] S33: Determine the vectors corresponding to the distances greater than a preset threshold among the M distances as N vectors.
[0044] In an exemplary embodiment, using N vectors and a target vector, determining the similarity between a text corresponding to each of the N vectors and the target text includes:
[0045] S41, determining the text corresponding to each vector in the N vectors, thereby determining N texts;
[0046] S42: Input the target text and N texts into the second target model to obtain a similarity result between the text corresponding to each vector output by the second target model and the target text.
[0047] For example, the vectors corresponding to the distances greater than a preset threshold among the M distances are determined as N vectors. Afterwards, the similar texts that meet the preset threshold in the calculation results are recalled and matched, and the result set is output as the input value of the matching degree prediction stage.
[0048] In an exemplary embodiment, the target text and N texts are input into the second target model, and a similarity result between the text corresponding to each vector output by the second target model and the target text is obtained, including:
[0049] S51, inputting the target text and N texts into the entity structure in the second target model to obtain a target embedding vector of the target text and N embedding vectors of the N texts;
[0050] S52, calculating the difference between the target embedding vector and each of the N embedding vectors;
[0051] S53, concatenating the target embedding vector, each embedding vector, and the difference between the target embedding vector and each embedding vector to determine N concatenated vectors;
[0052] S54: output similarity results based on the N concatenated vectors.
[0053] For example, the target text is combined with each of the N texts and respectively passed into the Encoder structure with an entity structure for forward propagation calculation of the multi-head attention network, and finally the entity-level tag token output is obtained, and the two embedding vectors and the difference between them are spliced and input to the convolution layer.
[0054] In an exemplary embodiment, outputting a similarity result based on the N concatenation vectors includes:
[0055] S61, inputting each splicing vector into a fully connected layer in the second target model, and obtaining a probability value of binary classification of each splicing vector output by the fully connected layer;
[0056] S62: Output similarity results based on the probability value.
[0057] For example, by connecting a Softmax layer network structure after the fully connected layer and outputting the binary classification probability value of the input concatenated embedding vector, the similarity probability of the two sentences can be obtained.
[0058] In an exemplary embodiment, outputting similar results based on the probability value includes:
[0059] S71, comparing the probability value with a second preset threshold;
[0060] S72: Output a similarity result based on the comparison result, that is, finally determine whether the two texts are similar based on a set similarity probability threshold.
[0061] In an exemplary embodiment, before obtaining N vectors from a preset database based on the target vector, the method further includes:
[0062] S81, extracting feature variables of M texts through the multi-head attention network in the first target model, where M is a natural number greater than or equal to N;
[0063] S82, using the embedding layer in the first target model to convert the feature variables of the M texts into feature vectors to obtain M vectors;
[0064] S83: Store the M vectors in a preset database according to the indexes and vectorized representations of the M texts.
[0065] This embodiment uses a vector storage method to store text.
[0066] The present invention will be described below in conjunction with specific embodiments:
[0067] like Figure 3 As shown, this specific embodiment includes the following specific steps:
[0068] S301: Build a pre-trained language model (corresponding to the first target model mentioned above) and optimize the Attention component. A large amount of historical text is fed into the pre-trained language model, and text features are extracted using a multi-head attention network. The model then outputs a fixed-length vectorized result after embedding.
[0069] S302: The index of the massive text is used as the key, and the vectorized representation is used as the value to store it in a columnar storage database.
[0070] S303: Input the search statement (corresponding to the target text mentioned above), pass it into the pre-trained language model according to the same processing flow, perform text feature extraction using the multi-head attention network, and output the fixed-length vectorized result after embedding.
[0071] S304 begins to calculate the Euclidean distance between vectors using vector indexes and the massive text data in the columnar database (corresponding to the preset database mentioned above). During the calculation and retrieval process, the calculation optimization of Faiss and HNSWLib vector indexes can achieve a search efficiency of millions of short texts in milliseconds.
[0072] S305: Set a similarity threshold for the final calculation result, recall similar texts that reach the threshold and output a matching result set as an input value for the matching prediction stage.
[0073] In S306-309, the original input sentence is combined with each text in the matching result set and respectively passed into the ENcoder structure with an entity structure for forward propagation calculation of the multi-head attention network, and finally the entity-level token output is obtained (S307). The two embedding vectors and the difference between them are spliced and input to the convolution layer and the fully connected layer (v) (S308-309).
[0074] S310-S311, after the fully connected layer, the Softmax layer network structure is connected to output the probability value of binary classification of the input concatenated embedding vector, so as to obtain the similarity probability of the two sentences. The similarity of the two texts is finally determined based on the set similarity probability threshold (S311).
[0075] In summary, this embodiment uses an optimized Attention structure and a language model pre-trained on massive amounts of short text to extract features from short texts. This avoids the problem of hashing algorithms ignoring semantic features when converting text, resulting in recall results lacking semantic similarity. Furthermore, keyword extraction and other processes are not required, avoiding the loss of accuracy caused by excessive processing steps. In terms of recall calculation, an advanced columnar database is used to store vectors, while a vector indexing framework is used for ultra-fast calculations on massive amounts of text. This allows for recall responses in the order of millions of milliseconds on a CPU. During the text similarity matching stage, by optimizing the training model, introducing a knowledge structure into the Attention structure, and incorporating forward propagation into the Attention structure, a semantically embedded vector is constructed for the input sentence, fundamentally reflecting the semantic feature meaning. Traditional distance calculations, such as Euclidean distance and Hamming distance, are avoided, and a binary classification neural network model is used instead to generate binary classification outputs, achieving highly accurate and efficient semantically similar text matching in massive text scenarios.
[0076] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially 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, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0077] In this embodiment, a device for determining text similarity is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments. The details that have been described will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0078] Figure 4 is a structural block diagram of a device for determining text similarity according to an embodiment of the present invention. Figure 4 As shown, the device includes:
[0079] A first input module 42 is configured to input the acquired target text into the first target model to obtain a target vector of the target text output by the first target model;
[0080] A first acquisition module 44 is configured to acquire N vectors from a preset database based on the target vector, where N is a natural number greater than or equal to 1;
[0081] The first determining module 46 is configured to determine the similarity between the text corresponding to each of the N vectors and the target text using the N vectors and the target vector.
[0082] In an exemplary embodiment, the first input module includes:
[0083] A first extraction unit is configured to extract feature variables of the target text through a multi-head attention network in the first target model;
[0084] The first conversion unit is used to convert the above-mentioned feature variables into feature vectors by using the embedding layer Embedding in the above-mentioned first target model to obtain the target vector of the above-mentioned target text.
[0085] In an exemplary embodiment, the first acquisition module includes:
[0086] The first determining unit is configured to determine a vector index of the target vector stored in the preset database.
[0087] The first calculating unit is configured to calculate distances between the vector index of the target vector and vector indexes of each vector in the preset database, and determine M distances, where M is a natural number greater than or equal to N.
[0088] The second determining unit is configured to determine, as the N vectors, vectors corresponding to distances greater than a preset threshold in the M distances.
[0089] In an example embodiment, the first determining module includes:
[0090] The third determining unit is configured to determine texts corresponding to each of the N vectors, and determine N texts.
[0091] The first input unit is configured to input the target text and the N texts into the second target model to obtain a similarity result between the text corresponding to each of the vectors output by the second target model and the target text.
[0092] In an example embodiment, the first input unit includes:
[0093] The first input subunit is configured to input the target text and the N texts into an entity structure in the second target model to obtain a target embedding vector of the target text and N embedding vectors of the N texts.
[0094] The first calculating subunit is configured to calculate a difference between the target embedding vector and each of the N embedding vectors.
[0095] The first concatenating subunit is configured to concatenate the target embedding vector, each of the embedding vectors, and the difference between the target embedding vector and each of the embedding vectors to determine N concatenated vectors.
[0096] The first output subunit is configured to output the similarity result based on the N concatenated vectors.
[0097] In an example embodiment, the first output subunit includes:
[0098] The first input submodule is configured to input each of the concatenated vectors into a fully connected layer in the second target model to obtain a probability value of binary classification of each of the concatenated vectors output by the fully connected layer.
[0099] The first output submodule is configured to output the similarity result based on the probability value.
[0100] In an exemplary embodiment, the similarity result is output based on the probability value in the following manner: comparing the probability value with a second preset threshold; and outputting the similarity result using the comparison result.
[0101] In an exemplary embodiment, the apparatus further comprises:
[0102] A first extraction module is configured to extract feature variables of M texts using a multi-head attention network in the first target model before obtaining N vectors from a preset database based on the target vector, where M is a natural number greater than or equal to N.
[0103] A first conversion module is configured to convert the feature variables of the M texts into feature vectors using the embedding layer in the first target model to obtain the M vectors;
[0104] The first storage module is used to store the M vectors in the preset database according to the index and vector representation of the M texts.
[0105] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when run.
[0106] According to another embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments.
[0107] It should be noted that the above modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0108] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for determining text similarity, characterized in that: include: Inputting the acquired target text into a first target model to obtain a target vector of the target text output by the first target model; Obtaining N vectors from a preset database based on the target vector, wherein N is a natural number greater than or equal to 1; Using the N vectors and the target vector, determine the similarity between the text corresponding to each vector in the N vectors and the target text; Utilizing the N vectors and the target vector, determining the similarity between the text corresponding to each vector in the N vectors and the target text, including: determining the text corresponding to each vector in the N vectors, determining N texts; inputting the target text and the N texts into the entity structure in the second target model to obtain a target embedding vector of the target text and N embedding vectors of the N texts; calculating the difference between the target embedding vector and each embedding vector in the N embedding vectors; splicing the target embedding vector, each embedding vector, and the difference between the target embedding vector and each embedding vector to determine N splicing vectors; and outputting a similarity result based on the N splicing vectors.
2. The method according to claim 1, characterized in that Inputting the acquired target text into a first target model to obtain a target vector of the target text output by the first target model includes: Extracting feature variables of the target text through a multi-head attention network in the first target model; The embedding layer in the first target model is used to convert the feature variable into a feature vector to obtain a target vector of the target text.
3. The method according to claim 1 or 2, characterized in that Obtaining N vectors from a preset database based on the target vector includes: Determine the vector index where the target vector is stored in the preset database; Calculating the distance between the vector index of the target vector and the vector index of each vector in the preset database to determine M distances, where M is a natural number greater than or equal to N; The vectors corresponding to the distances greater than a preset threshold among the M distances are determined as the N vectors.
4. The method according to claim 1, wherein Outputting the similarity result based on the N splicing vectors includes: Inputting each splicing vector into a fully connected layer in the second target model, and obtaining a probability value of binary classification of each splicing vector output by the fully connected layer; comparing the probability value with a second preset threshold; The similarity result is outputted using the comparison result.
5. The method according to claim 1, wherein Before obtaining N vectors from a preset database based on the target vector, the method further includes: Extracting feature variables of M texts through the multi-head attention network in the first target model, where M is a natural number greater than or equal to N; Using the embedding layer in the first target model to convert the feature variables of the M texts into feature vectors to obtain M vectors; According to the index and vector representation of the M texts, the M vectors are stored in the preset database.
6. A device for determining text similarity, characterized in that: include: A first input module, configured to input the acquired target text into a first target model to obtain a target vector of the target text output by the first target model; A first acquisition module is configured to acquire N vectors from a preset database based on the target vector, where N is a natural number greater than or equal to 1; A first determining module is configured to determine the similarity between a text corresponding to each of the N vectors and the target text using the N vectors and the target vector; The first determination module is further used to determine the text corresponding to each vector in the N vectors, and determine N texts; input the target text and the N texts into the entity structure in the second target model to obtain the target embedding vector of the target text and N embedding vectors of the N texts; calculate the difference between the target embedding vector and each embedding vector in the N embedding vectors; splice the target embedding vector, each embedding vector, and the difference between the target embedding vector and each embedding vector to determine N splicing vectors; and output a similarity result based on the N splicing vectors.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 5 when executed.
8. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 5 through the computer program.
Citation Information
Patent Citations
Text processing method and device based on comparison model, equipment and storage medium
CN113836937A