A text matching method, device, electronic device and storage medium
By determining the keyword characteristics and non-keyword characteristics of the text to be matched and candidate text in text matching, and using interactive matching methods, the problem of wrong placement of attention mechanism is solved and the accuracy of text matching is improved.
Patent Information
- Application Number
- CN202210527823.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-16
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-05-16
AI Technical Summary
In the existing text matching technology, since the attention mechanism focuses on common words with part-of-words, the text matching model outputs incorrect matching results, which is not very accurate.
By determining the keyword characteristics and non-keyword characteristics of the text to be matched and candidate text, using interactive matching methods, combining keyword characteristics and non-keyword characteristics, the text matching results are determined to avoid incorrect placement of attention mechanisms.
Improve the accuracy of text matching, ensure that the attention mechanism focuses on keyword characteristics, reduce the impact of non-keyword characteristics, and enhance the accuracy of text matching.
Smart Images

Figure CN115130461B_ABST
Abstract
Description
Background Art
[0002] With the development of natural language processing technology, the application scope of text matching has become increasingly wide. For example, text matching can be applied to paraphrase recognition, answer selection, etc.
[0003] In related technologies, when performing text matching, generally, the text to be matched and the candidate text can be input into a trained text matching model to determine the word similarity corresponding to each word that matches between the text to be matched and the candidate text, and through the attention mechanism, combining the determined word similarities, the text matching result between the text to be matched and the candidate text can be obtained.
[0004] However, in related technologies, since the attention mechanism usually focuses on words of common parts of speech, such as nouns, verbs, etc., therefore, in the process of text matching, assuming that the text to be matched and the candidate text are related texts, and in the candidate text, there are no words of common parts of speech similar to those in the text to be matched. If the attention mechanism focuses on the words of common parts of speech in the text to be matched, it will lead to an incorrect matching result that the text matching model outputs that the text to be matched and the candidate text are irrelevant due to the incorrect placement of the attention mechanism.
[0005] For example, assuming that the text to be matched is "A land rover is being driven across a river" and the candidate text is "A land rover is splashing water as it crosses a river", the text matching model can identify that "across a river" in the text to be matched and "as it crosses a river" in the candidate text are in a matching relationship. However, if the text matching model focuses the attention mechanism on "being driven" in the text to be matched, then the text matching model cannot find similar words in the candidate text, thus giving an incorrect matching result that the text to be matched and the candidate text are irrelevant.
[0006] Therefore, the accuracy of this text matching method in related technologies is not high. Summary of the Invention
[0007] Embodiments of the present application provide a text matching method, apparatus, electronic device, and storage medium to improve the accuracy of text matching.
[0008] The specific technical solutions provided by the embodiments of the present application are as follows:
[0009] On the one hand, embodiments of the present application provide a text matching method, including:
[0010] Determine a first keyword feature and a first non-keyword feature corresponding to the text to be matched based on first word dimension features corresponding to each word to be matched included in the text to be matched in at least one word dimension;
[0011] Determine a second keyword feature and a second non-keyword feature corresponding to the candidate text based on second word dimension features corresponding to each candidate word included in the candidate text in the at least one word dimension;
[0012] Taking the candidate words as a benchmark, perform interactive matching on the words to be matched to obtain a first matching feature corresponding to the text to be matched, and taking the words to be matched as a benchmark, perform interactive matching on the candidate words to obtain a second matching feature corresponding to the text to be matched;
[0013] Based on the first keyword feature, the first non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature and the second matching feature, determine a text matching result between the text to be matched and the candidate text.
[0014] On the one hand, an embodiment of the present application provides a text matching device, including:
[0015] A first extraction module, configured to determine a first keyword feature and a first non-keyword feature corresponding to the text to be matched based on first word dimension features corresponding to each word to be matched included in the text to be matched in at least one word dimension;
[0016] A second extraction module, configured to determine a second keyword feature and a second non-keyword feature corresponding to the candidate text based on second word dimension features corresponding to each candidate word included in the candidate text in the at least one word dimension;
[0017] A third extraction module, configured to perform interactive matching on the words to be matched with the candidate words as a benchmark to obtain a first matching feature corresponding to the text to be matched, and perform interactive matching on the candidate words with the words to be matched as a benchmark to obtain a second matching feature corresponding to the text to be matched;
[0018] A matching module, configured to determine a text matching result between the text to be matched and the candidate text based on the first keyword feature, the first non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature and the second matching feature.
[0019] Optionally, when obtaining the first keyword feature, the first non-keyword feature, the second keyword feature and the second non-keyword feature, the first extraction module and the second extraction module are further configured to:
[0020] Determine the word features corresponding to each word included in each text;
[0021] Perform the following operations respectively for each of the above-mentioned words: Based on the word features of a word, determine the word dimension features corresponding to the word in at least one word dimension, and based on the obtained at least one dimension feature and the dimension weights corresponding to the at least one word dimension, determine the word fusion feature of the word;
[0022] According to the obtained word fusion features of each word, determine the keyword features and non-keyword features corresponding to each text respectively;
[0023] Wherein, when the one text is a text to be matched, the word feature is a to-be-matched word feature, the keyword feature is a first keyword feature, and the non-keyword feature is a second non-keyword feature; when the one text is a candidate text, the word feature is a candidate word feature, the keyword feature is a second keyword feature, and the non-keyword feature is a second non-keyword feature.
[0024] Optionally, when determining the word dimension features corresponding to a word in at least one word dimension based on the word features of the word, the first extraction module and the second extraction module are further configured to:
[0025] Reduce the number of dimensions corresponding to the word features of a word to a standard number to obtain the dimension-reduced word features;
[0026] Perform the following operations respectively for at least one word dimension: Use the convolution processing method corresponding to a word dimension to perform convolution processing on the dimension-reduced word features to obtain the word dimension features corresponding to the word in the word dimension.
[0027] Optionally, the matching module is further configured to:
[0028] Perform feature splicing on the first keyword feature, the first non-keyword feature, and the first matching feature to obtain the first text feature corresponding to the text to be matched;
[0029] Perform feature splicing on the second keyword feature, the second non-keyword feature, and the second matching feature to obtain the second text feature corresponding to the candidate text;
[0030] Based on the first text feature, the second text feature, and a preset keyword weight set, determine the text matching result between the text to be matched and the candidate text.
[0031] Optionally, when determining the text matching result between the text to be matched and the candidate text based on the first text feature, the second text feature, and a preset keyword weight set, the matching module is further configured to:
[0032] Perform feature fusion on the first text feature, the second text feature, a preset keyword weight set, and a first feature difference between the first text feature and the second text feature to obtain a to-be-matched fusion feature of the to-be-matched text;
[0033] Perform feature fusion on the first text feature, the second text feature, the keyword weight set, and a second feature difference between the second text feature and the first text feature to obtain a candidate fusion feature of the candidate text;
[0034] Based on the to-be-matched fusion feature and the candidate fusion feature, determine a text matching result between the to-be-matched text and the candidate text.
[0035] Optionally, when obtaining the to-be-matched fusion feature of the to-be-matched text, the matching module is further configured to:
[0036] Based on a first activation function, a first weight matrix corresponding to the first activation function, the first text feature, the second text feature, and the first feature difference, determine a first initial to-be-matched feature;
[0037] Perform the following operations for each of at least one second weight matrix corresponding to a second activation function: Based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the first feature difference, determine a second initial to-be-matched feature;
[0038] Based on the first initial to-be-matched feature, the determined at least one second initial to-be-matched feature, and the first text feature, determine the to-be-matched fusion feature corresponding to the to-be-matched text.
[0039] Optionally, when obtaining the candidate fusion feature of the candidate text, the matching module is further configured to:
[0040] Based on the first activation function, the first weight matrix, the first text feature, the second text feature, and the second feature difference, obtain a first initial candidate feature;
[0041] Perform the following operations for each of the at least one second weight matrix: Based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the second feature difference, determine a second initial candidate feature;
[0042] Based on the first initial candidate feature, the determined at least one second initial candidate feature, and the second text feature, determine the candidate fusion feature corresponding to the candidate text.
[0043] Optionally, when determining the text matching result between the text to be matched and the candidate text based on the to-be-matched fusion feature and the candidate fusion feature, the matching module is further configured to:
[0044] Determine the difference between the to-be-matched fusion feature and the candidate fusion feature;
[0045] Concatenate the to-be-matched fusion feature, the candidate fusion feature, the difference between the fusion features, and the cross-fusion feature between the first text feature and the second text feature to obtain a to-be-predicted feature;
[0046] Based on the to-be-predicted feature, in combination with the correspondence between each to-be-predicted feature and the corresponding text matching result, determine the text matching result corresponding to the to-be-predicted feature.
[0047] On the one hand, an embodiment of the present application provides an electronic device, which includes a processor and a memory. Among them, the memory stores program code, and when the program code is executed by the processor, the processor is caused to execute the steps of any one of the above text matching methods.
[0048] On the one hand, an embodiment of the present application provides a computer storage medium, which stores computer instructions, and when the computer instructions run on a computer, the computer is caused to execute the steps of any one of the above text matching methods.
[0049] On the one hand, an embodiment of the present application provides a computer program product, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; when a processor of an electronic device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, causing the electronic device to execute the steps of any one of the above text matching methods.
[0050] Since the embodiment of the present application adopts the above technical solutions, it has at least the following technical effects:
[0051] Determine the first keyword features and the first non-keyword features corresponding to the text to be matched, and determine the second keyword features and the second non-keyword features corresponding to the candidate text. At the same time, taking each candidate word as a benchmark, perform interactive matching on each word to be matched, so as to obtain the first matching features corresponding to the text to be matched. Taking each word to be matched as a benchmark, perform interactive matching on each candidate word, so as to obtain the second matching features corresponding to the candidate text. Then, based on the first keyword features, the first non-keyword features, the second keyword features, the second non-keyword features, the first matching features and the second matching features, determine the text matching result between the text to be matched and the candidate text. In this way, by separately determining the keyword features and non-keyword features of the text to be matched and the candidate text, the attention mechanism can be focused on the keyword features of the text to be matched and the candidate text, ensuring that the attention mechanism can be correctly placed on the corresponding words, enhancing the proportion of keyword features in determining the text matching result, weakening the proportion of non-keyword features in determining the text matching result, avoiding the text matching model from outputting wrong matching results, and improving the accuracy of text matching. Description of the Drawings
[0052] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:
[0053] Figure 1 It is a schematic diagram of the application scenario in the embodiment of the present application;
[0054] Figure 2A It is a schematic diagram of the structure of the text matching model in the embodiment of the present application;
[0055] Figure 2B It is a schematic diagram of the structure of the word encoding layer in the embodiment of the present application;
[0056] Figure 2C It is a schematic diagram of the structure of the RE2 layer in the embodiment of the present application;
[0057] Figure 3A It is a schematic diagram of the flow of the text matching method in the embodiment of the present application;
[0058] Figure 3B It is a schematic diagram of the flow of determining keyword features and non-keyword features in the embodiment of the present application;
[0059] Figure 3C It is an example diagram of determining word features in the embodiment of the present application;
[0060] Figure 3D It is a schematic diagram of the flow of determining word dimension features in the embodiment of the present application;
[0061] Figure 3E It is an exemplary diagram for determining the word fusion feature in the embodiment of this application;
[0062] Figure 3F It is an exemplary diagram for determining the first matching feature and the second matching feature in the embodiment of this application;
[0063] Figure 3G It is the first process schematic diagram for determining the text matching result in the embodiment of this application;
[0064] Figure 3H It is the second process schematic diagram for determining the text matching result in the embodiment of this application;
[0065] Figure 3I It is the third process schematic diagram for determining the text matching result in the embodiment of this application;
[0066] Figure 4 It is an exemplary diagram for the text matching method in the embodiment of this application;
[0067] Figure 5 It is the structural schematic diagram of the text matching device in the embodiment of this application;
[0068] Figure 6 It is a schematic diagram of a hardware composition structure of an electronic device applying the embodiment of this application. Detailed implementation manners
[0069] Next, the technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of this application.
[0070] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are a part of the technical solutions of this application, rather than all the embodiments. Based on the embodiments recorded in this application document, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the technical solutions of this application.
[0071] Terms such as "first" and "second" in the specification, claims, and the above-mentioned accompanying drawings of this application are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here.
[0072] The following explains some terms in the embodiments of the present application to facilitate understanding by those skilled in the art.
[0073] Text to be matched: The text to be matched is the text information input by the user into the client. For example, when it is necessary to identify the paraphrase of a target object, the text input by the user into the paraphrase recognition area.
[0074] Candidate text: The candidate text is the text information selected from a preset candidate text library.
[0075] Word dimension: The word dimension represents the characteristic dimension corresponding to a word. For example, the word dimension can be text meaning, context, etc., which is not limited in the embodiments of the present application.
[0076] First dimension feature: It represents the word feature of the word to be matched in any word dimension. For example, when the word dimension is context, the first dimension feature is the context feature corresponding to the word to be matched.
[0077] First keyword feature: It represents the keyword feature in the text feature corresponding to the text to be matched.
[0078] First non-keyword feature: It represents the non-keyword feature in the text feature corresponding to the text to be matched.
[0079] Second dimension feature: It represents the word feature of the candidate word in any word dimension.
[0080] Second keyword feature: It represents the keyword feature in the candidate text feature corresponding to the candidate text.
[0081] Second non-keyword feature: It represents the non-keyword feature in the candidate text feature corresponding to the candidate text.
[0082] Convolutional neural network: It consists of an input layer, a convolutional layer, a pooling layer, and a fully connected layer. Among them, the convolutional layer is the core part, which is used to extract local features. The determined local features contain two typical features, namely weight sharing and local connection. Weight sharing is to process the input vector with a convolutional kernel of a fixed size, which can significantly reduce the parameters. Local connection means that a node is only connected to the nodes in the adjacent layer, and local features can be obtained.
[0083] Attention mechanism: The attention mechanism is used to give greater weight to the keyword feature.
[0084] The following briefly introduces the design concept of the embodiments of the present application:
[0085] With the continuous development of deep learning, the application scope of text matching has become increasingly wide. For example, it can be applied to information retrieval, paraphrase recognition, answer selection, etc. These application scopes can be regarded as specific tasks of the text matching problem, and the goal of text matching is to estimate the similarity between two input texts.
[0086] In related technologies, when performing text matching, usually the text to be matched and the candidate text are input into a trained text matching model to determine each word that matches between the text to be matched and the candidate text. Then, based on the word similarity between the aligned words, the text matching result between the text to be matched and the candidate text is determined.
[0087] However, in related technologies, although through the alignment mechanism, each word that matches between the text to be matched and the candidate text can be identified, if the attention mechanism of the text matching model is placed on words with common parts of speech, it may lead to incorrect matching results between the output text to be matched and the candidate text due to the incorrect placement of the attention mechanism.
[0088] For example, assume that the text to be matched in a natural language inference task is "A land rover is splashing water as it crosses a river", and the candidate text is "A land rover is being driven across a river". Although the text matching model can identify that "across a river" in the text to be matched and "as it crosses a river" in the candidate text are in a matching relationship, if the text matching model focuses its attention on "being driven" in the candidate text, then the text matching model cannot find a similar word in the text to be matched and will give an incorrect matching result that the text to be matched and the candidate text are irrelevant.
[0089] Therefore, the accuracy of this text matching method in related technologies is not high.
[0090] In view of this, embodiments of the present application propose a text matching method, apparatus, electronic device, and storage medium. Determine the first keyword feature and the first non-keyword feature corresponding to the text to be matched, and determine the second keyword feature and the second non-keyword feature corresponding to the candidate text. At the same time, taking each candidate word as a benchmark, perform interactive matching on each word to be matched, so as to obtain the first matching feature corresponding to the text to be matched. Taking each word to be matched as a benchmark, perform interactive matching on each candidate word, so as to obtain the second matching feature corresponding to the candidate text. Then, based on the first keyword feature, the first non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature, and the second matching feature, determine the text matching result between the text to be matched and the candidate text. In this way, by determining the first keyword feature and the first non-keyword feature of the text to be matched, and determining the second keyword feature and the second non-keyword feature corresponding to the candidate text, the attention mechanism can be focused on the keyword features of the text to be matched and the candidate text, thereby avoiding the situation of text matching errors caused by the wrong placement of the attention mechanism, and improving the accuracy of text matching.
[0091] The preferred embodiments of the present application will be described below with reference to the accompanying drawings of the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. And without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other.
[0092] Refer to Figure 1 As shown, it is a schematic diagram of an application scenario in an embodiment of the present application. The application scenario schematic diagram includes a client 110 and a server 120. The client 110 and the server 120 can communicate through a communication network.
[0093] In an embodiment of the present application, the client 110 can be used to identify the meaning of text, and can also be used for paraphrase recognition. Of course, it can also be used for answer selection, and this is not limited.
[0094] A target application with text matching function is pre-installed in the client 110, and the function of the target application is not limited to text matching. The target application can be a pre-installed client application, a web version application, a small program, etc. The client 110 can include one or more processors, a memory, an I / O interface for interacting with the server 120, and a display screen, etc. The client 110 includes, but is not limited to, a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc.
[0095] The server is the background server corresponding to the target application and provides services for the target application. The server 120 may include one or more processors, a memory, and an I / O interface for interacting with the client 110, etc. The server 120 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The client 110 and the server 120 may be directly or indirectly connected through wired or wireless communication methods, and the embodiments of the present application do not limit this here.
[0096] Among them, the text matching method in the embodiments of the present application may be performed on the client 110 or on the server 120. When the text matching is performed by the client 110, the client 110 obtains the text to be matched, determines the first keyword feature and the first non-keyword feature corresponding to the text to be matched based on the first-dimensional features corresponding to each word to be matched included in the text to be matched in at least one word dimension. At the same time, from the preset candidate text database, a candidate text is selected, and the second keyword feature and the second non-keyword feature corresponding to the candidate text are determined based on the second-dimensional features corresponding to each candidate word included in the candidate text in at least one word dimension. At the same time, with each candidate word as a reference, each word to be matched is interactively matched to obtain the first matching feature corresponding to the text to be matched, and with each word to be matched as a reference, each candidate word is interactively matched to obtain the second matching feature corresponding to the text to be matched. Finally, based on the first keyword feature, the second non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature, and the second matching feature, the text matching result between the text to be matched and the candidate text is determined.
[0097] When text matching is performed by server 120, the client 110 obtains the text to be matched, and sends the obtained text to be matched to server 120. Then, server 120 determines the first keyword feature and the first non-keyword feature corresponding to the text to be matched based on the first-dimensional features corresponding to each word to be matched included in the text to be matched in at least one word dimension. At the same time, from the preset candidate text database, a candidate text is selected, and the second keyword feature and the second non-keyword feature corresponding to the candidate text are determined based on the second-dimensional features corresponding to each candidate word included in the candidate text in at least one word dimension. At the same time, taking each candidate word as a reference, the words to be matched are interactively matched to obtain the first matching feature corresponding to the text to be matched, and taking each word to be matched as a reference, the candidate words are interactively matched to obtain the second matching feature corresponding to the text to be matched. Finally, based on the first keyword feature, the second non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature and the second matching feature, the text matching result between the text to be matched and the candidate text is determined, and the text matching result is fed back to client 110.
[0098] The text matching method in the embodiments of the present application can be applied to the application scenario of answer selection. First, the first keyword feature and the first non-keyword feature corresponding to the question to be matched are determined. At the same time, from the preset answer database, a candidate question is selected, and the second keyword feature and the second non-keyword feature corresponding to the candidate question are determined. At the same time, the first matching feature corresponding to the question to be matched is obtained, and the second matching feature corresponding to the question to be matched is obtained. Finally, based on the first keyword feature, the second non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature and the second matching feature, the text matching result between the question to be matched and the candidate question is determined. If it is determined that the text matching result is a match, the answer corresponding to the candidate question is used as the answer to the question to be matched.
[0099] The text matching method in the embodiments of the present application can also be applied to the application scenario of identifying the meaning of text. First, the first keyword feature and the first non-keyword feature corresponding to the text to be matched are determined. At the same time, from the preset text database, a candidate text is selected, and the second keyword feature and the second non-keyword feature corresponding to the candidate text are determined. At the same time, the first matching feature corresponding to the text to be matched is obtained, and the second matching feature corresponding to the text to be matched is obtained. Finally, based on the first keyword feature, the second non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature and the second matching feature, the text matching result between the text to be matched and the candidate text is determined. If it is determined that the text matching result is a match, the text meaning corresponding to the candidate text is used as the text meaning of the text to be matched.
[0100] 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. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines to enable machines to have the functions of perception, reasoning, and decision-making.
[0101] Artificial intelligence technology is an interdisciplinary subject with a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0102] Computer Vision Technology (CV) Computer vision is a science that studies how to enable machines to "see". Further, it refers to using cameras and computers to replace human eyes for object recognition, measurement, and other machine vision, and further performing graphic processing to make the computer process images that are more suitable for human eyes to observe or be transmitted to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies and attempts to build artificial intelligence systems that can obtain information from images or multi-dimensional data. Computer vision technology usually includes technologies such as image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, and also includes common biometric recognition technologies such as face recognition and fingerprint recognition.
[0103] The key technologies of speech technology include automatic speech recognition technology (ASR), text-to-speech technology (TTS), and voiceprint recognition technology. Enabling computers to listen, see, speak, and feel is the future development direction of human-computer interaction, and among them, speech has become one of the most promising human-computer interaction methods in the future.
[0104] 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 humans and computers in natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, the research in this field will involve natural language, that is, the language people use in daily life, so it has a close connection with the research of linguistics. Natural language processing technologies usually include text processing, semantic understanding, machine translation, robot question answering, knowledge graph, and other technologies.
[0105] Machine Learning (ML) is an interdisciplinary subject that involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent, and its applications cover all fields of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and rote learning.
[0106] Autopilot technology usually includes technologies such as high-precision maps, environmental perception, behavior decision-making, path planning, and motion control. Autopilot technology has a wide range of application prospects.
[0107] With the research and progress of artificial intelligence technology, artificial intelligence technology has been studied and applied in multiple fields. For example, common ones include smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, driverless, autopilot, drones, robots, smart healthcare, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0108] The solution provided in the embodiments of this application involves technologies such as text matching, and will be specifically described through the following embodiments:
[0109] The text matching method in the embodiments of this application can be implemented through a text matching model. Next, in combination with the accompanying drawings, the structure of the text matching model in the embodiments of this application will be described. Refer to Figure 2A As shown, it is a schematic structural diagram of the text matching model in the embodiments of this application, specifically including:
[0110] 1. Encoding layer.
[0111] In the embodiments of the present application, the input parameters of the encoding layer are the text to be matched and the candidate text, and the output parameters are the word features of the text to be matched and the word features of the candidate text. The encoding layer uses a convolutional neural network as the encoder.
[0112] In the embodiments of the present application, the BERT model can also be used as the encoder, and the text matching model can also learn the semantic features of the teacher model BERT through the method of knowledge distillation, so as to improve the generalization of the text matching model.
[0113] 2. Word encoding layer.
[0114] In the embodiments of the present application, the input parameters of the word encoding layer are the output parameters of the encoding layer, that is, the word features corresponding to the text to be matched and the word features corresponding to the candidate text. The word encoding layer uses an enhanced convolutional neural network, which consists of multiple layers of convolution, and is used to capture the keyword features of the text to be matched and the keyword features of the candidate text.
[0115] The structure of the word encoding layer in the embodiments of the present application will be described below. Refer to Figure 2B As shown in the figure, it is a schematic diagram of the structure of the word encoding layer in the embodiments of the present application. Among them, the word encoding layer consists of three layers, namely, a one-dimensional convolutional layer, a multi-channel convolutional layer, and a pooling layer.
[0116] Among them, the one-dimensional convolutional layer is the first layer of the word encoding layer. The input parameters are the word features of the text to be matched and the word features of the candidate text output by the encoding layer, and the output parameters are the reduced-dimensional word features corresponding to the text to be matched and the reduced-dimensional word features corresponding to the candidate text. The one-dimensional convolution can reduce the dimension of the word vector output by the encoding layer, thereby reducing the number of parameters of the text matching model.
[0117] The multi-channel convolutional layer is the second layer of the word encoding layer. The input parameters are the reduced-dimensional word features corresponding to the text to be matched and the reduced-dimensional word features corresponding to the candidate text, and the output parameters are the word dimension features corresponding to the text to be matched and the word dimension features corresponding to the candidate text. The multi-channel convolutional layer is a convolutional layer containing at least one channel, and the weights corresponding to at least one channel are obtained during training, so as to achieve the purpose of capturing the keywords and phrase information of the text.
[0118] The pooling layer is the third layer of the word encoding layer. The input parameters are the word dimension features corresponding to the text to be matched and the word dimension features corresponding to the candidate text, and the output parameters are the first keyword features and the first non-keyword features corresponding to the text to be matched, and the second keyword features and the second non-keyword features corresponding to the candidate text.
[0119] Among them, the pooling layer in the embodiments of the present application can be average pooling or max pooling, which is used to generate a vector of a fixed size, so as to splice the word dimension features determined by each channel as the output parameter of the word m in the word encoding layer, that is, the word fusion feature.
[0120] 3. RE2 layer.
[0121] In the embodiments of the present application, the input parameter of the RE2 layer is the output parameter of the encoding layer, that is, the word features corresponding to the text to be matched and the word features corresponding to the candidate text. Refer to Figure 2C As shown, it is a schematic structural diagram of the RE2 layer in the embodiments of the present application. Among them, the input parameter and the output parameter of the encoding layer are spliced together in a residual connection manner to form a long matrix and input into the alignment layer. The text matching model obtains an alignment vector containing context features in the alignment layer. Similarly, the input parameter and the output parameter of the alignment layer are input into the comparison layer together. There are three comparison operations in the comparison layer, namely splicing, subtraction, and multiplication operations. The output of the comparison layer is a vector containing rich matching features. If the current block encoding layer is the last layer, the vector output at this time is the final matching feature. Otherwise, it is used as the input parameter of the next block encoding layer in a residual connection manner.
[0122] 4. Feature fusion layer.
[0123] In the embodiments of the present application, the feature fusion layer is used to perform feature fusion on the first matching feature and the second matching feature output by the RE2 layer, as well as the first keyword feature, the first non-keyword feature, the second keyword feature, and the second non-keyword feature output by the word encoding layer, so as to obtain the to-be-matched fusion feature corresponding to the text to be matched and the candidate fusion feature corresponding to the candidate text. Therefore, through the feature fusion layer, the sentence feature expressions of the text to be matched and the candidate text can be better fused, which is convenient for calculating the similarity between the text to be matched and the candidate text in the subsequent process.
[0124] 5. Prediction layer.
[0125] In the embodiments of the present application, the prediction layer is used to predict the text matching result between the text to be matched and the candidate text based on the to-be-matched fusion feature and the candidate fusion feature.
[0126] After introducing the structure of the text matching model in the embodiments of the present application, the process of training the text matching model in the embodiments of the present application will be described below.
[0127] First, obtain the sample data set of the text matching model.
[0128] Optionally, the sample data set in the embodiments of the present application uses the Stanford Natural Language Inference (SNLI) and Quora question pair data sets.
[0129] Among them, SNLI is a large benchmark data set for natural language inference. In natural language inference tasks, the input text to be matched and the candidate text are often asymmetric. The text to be matched is the "premise", and the candidate text is the "hypothesis". The text matching model needs to infer the relationship between the text to be matched and the candidate text. The SNL data set contains a total of 570,000 text pairs, and each text pair has a label, and the labels are "entailment", "neutral", "contradiction" and "-".
[0130] Quora question pair is a large data set for paraphrase recognition, which contains a total of 400,000 question pairs. A question pair contains two question sentences. The model needs to judge whether one question is a paraphrase of another question, that is, to judge whether the two question sentences express the same meaning. Each question pair has a label, and there are two labels: "similar" and "dissimilar".
[0131] Then, the initial text matching model is trained using the sample data set. Specifically, the training of the text matching model is carried out in a Linux environment, and the Pytorch deep learning framework is used for construction. Each text sample to be matched is input into the initial text matching model respectively to determine the sample text matching result, and the error between the sample text matching result and the label is used to update the parameters of the initial text matching model until the loss function is minimized, so as to obtain the trained text matching model.
[0132] Among them, the word encoding layer is initialized with 840B-300d Glove word vectors, which are fixed during the training of the 840B-300d Glove model. Also, the natural language processing toolkit (NLTK) is used to tokenize the text samples to be matched, convert the words in the text samples to lowercase letters, and remove all punctuation marks. All parameter initializations adopt He initialization and use weight normalization. Among them, the optimization method selects Adam, the exponential decay rate of the first-order matrix estimation is set to 0.9, the exponential decay rate of the second-order matrix estimation is set to 0.999, the initial learning rate is 0.002, and the activation function selects the GeLU function. To avoid overfitting, a dropout strategy with a probability of 0.8 is adopted before both the fully connected layer and the convolutional layer. In the SNLI and Quora question pair datasets, the number of blocks in the RE2 block is set to 3 and 2 respectively, and the number of convolutional layers in the encoding layer is set to 3 and 2 respectively. The Batch Size is set to 64, the dimension of the word vector is 300. In the encoding layer, the size of the hidden layer is set to 200, the input dimension of the convolutional layer is 300, the size of the hidden layer of the word encoding layer is 64, and the size of the hidden layer of the RE2 layer is 200.
[0133] It should be noted that the text matching model in the embodiments of this application can be a short text matching model (Enhanced Sequential Inference Model, ESIM), which uses a single-layer text alignment layer based on the attention mechanism to highlight the local information of two sentences through three operations: splicing, dot product, and difference.
[0134] The text matching model in the embodiments of this application can also be a DINN model, which uses word vectors, character vectors, and part-of-speech feature vectors to obtain sentence expression vectors through a Highway network and forms a matching matrix by pairwise matching of the expression vectors.
[0135] The text matching model in the embodiments of this application can also be a Multiway Attention Networks (MwAN) model, which adopts multiple attention mechanisms to obtain 4 different vectors through connection attention, linear attention, dot product attention, and difference attention, and uses a gating network to complete the aggregation of the 4 vectors.
[0136] The text matching model in the embodiments of this application can also be The model calculates alignment features using both self-attention and co-attention methods, and aggregates them as the final alignment expression features; the stacked attention network (SAN) adopts a multi-step reasoning method, and iteratively optimizes by maintaining a state and passing it multiple times between the premise and the hypothesis to make predictions.
[0137] The text matching model in the embodiments of the present application can also be a sentence matching model based on recursive joint attention (Densely-connected Recurrent and Co-attentive Information, DRCN), which uses a densely-connected stacked recurrent neural network (Recurrent Neural Network, RNN) and an attention layer, and adopts an autoencoder for dimensionality reduction.
[0138] The text matching model in the embodiments of the present application can also be the RE2 model, which stacks multiple blocks in a residual connection manner, and uses multi-layer inter-sentence alignment to enable the model to more fully understand the matching relationship between two texts.
[0139] Next, the experimental results of different text matching models in the embodiments of the present application are used to illustrate the accuracy of the text matching method in the embodiments of the present application.
[0140] Among them, the ESIM model, the DIIN model, the RE2 model, etc. are selected as baseline models, and some models are reproduced. During the implementation process, the parameters of the related technology and the open-source code on its Github community are referred to. The datasets involved in the experiment are all open-source. Using the NLTK tool, the words in the dataset are converted to lowercase and punctuation marks are removed. In the single-GPU environment, the accuracy rate of the ESIM model in the SNLI dataset is 87.6%, and after multiple experiments, it is slightly lower than 88.0%. The data in the embodiments of the present application are referred to the data in the related technology; the RE2 model is consistent with 88.9% in the SNLI dataset. As shown in Table 1, it is a comparison table of the experimental results of different models in the SNLI dataset in the embodiments of the present application.
[0141] Table 1
[0142]
[0143] According to the data in Table 1, the RMFTM model proposed in the embodiments of the present application improves the accuracy rate to 89.3% on the SNLI dataset. Compared with the ESIM model, the accuracy rate is improved by 1.3%, and compared with RE2, the accuracy rate is improved by 0.4%. Therefore, the text matching method proposed in the embodiments of the present application is superior to the performance of RE2. That is, introducing a word encoding layer to capture keyword information within a sentence, fusing matching features between sentences, and then using the method of a feature fusion layer based on a gating mechanism can better predict the similarity between the text to be matched and the candidate text.
[0144] Based on the above embodiments, the text matching method in the embodiments of the present application will be described below with reference to the accompanying drawings. The text matching method in the embodiments of the present application can be applied to Figure 1 the client 110 or the server 120 shown in Figure 3A As shown, it is a schematic flowchart of the text matching method in the embodiments of the present application. The specific text matching process is as follows:
[0145] S30: Based on the first word dimension features corresponding to each word to be matched in the text to be matched in at least one word dimension, determine the first keyword feature and the first non-keyword feature corresponding to the text to be matched.
[0146] In the embodiments of the present application, the text to be matched is segmented to obtain each word to be matched included in the text to be matched. Then, the first word dimension features corresponding to each word to be matched in at least one word dimension are respectively determined, and based on the first word dimension features, the first keyword feature and the first non-keyword feature corresponding to the text to be matched are determined.
[0147] S31: Based on the second word dimension features corresponding to each candidate word in the candidate text in at least one word dimension, determine the second keyword feature and the second non-keyword feature corresponding to the candidate text.
[0148] In the embodiments of the present application, the candidate text is segmented to obtain each candidate word included in the candidate text. Then, the second word dimension features corresponding to each candidate word in at least one word dimension are respectively determined, and based on the second word dimension features, the second keyword feature and the second non-keyword feature corresponding to the candidate text are determined.
[0149] In the embodiments of the present application, the execution order of S30 and S31 is not limited.
[0150] Optionally, in the embodiments of the present application, when the text is the text to be matched, each word included in the text is each word to be matched, the word feature is the word feature to be matched, the keyword feature is the first keyword feature, and the non-keyword feature is the first non-keyword feature. When the text is the candidate text, each word included in the text is each candidate word, the word feature is the candidate word feature, the keyword feature is the second keyword feature, and the non-keyword feature is the second non-keyword feature. Next, in the embodiments of the present application, the process of determining the keyword feature and the non-keyword feature will be described. Refer to Figure 3B As shown, it is a schematic flowchart of determining the keyword feature and the non-keyword feature in the embodiments of the present application, which specifically includes:
[0151] S311: Determine the word feature corresponding to each word included in each text.
[0152] Among them, when the text is the text to be matched, the word feature is the word feature to be matched, and when the text is the candidate text, the word feature is the candidate word feature.
[0153] In the embodiments of the present application, for each text, the following operations are respectively performed: perform word segmentation on a text to obtain each word included in the text, and respectively perform feature extraction on each word to obtain the word feature corresponding to each word.
[0154] For example, refer to Figure 3C As shown, it is an example diagram of determining the word feature in the embodiments of the present application. Assume that the text is "Aland rover is being driven across a river", then after performing word segmentation on the text, the words included in the text are respectively "a land rover", "is", "being driven", and "across a river". And perform feature extraction on "aland rover" to obtain the corresponding word feature (a,1), perform feature extraction on "is" to obtain the corresponding word feature (a,2), perform feature extraction on "being driven" to obtain the corresponding word feature (a,3), and perform feature extraction on "across ariver" to obtain the corresponding word feature (a,4).
[0155] Among them, in the embodiments of the present application, the process of obtaining the word feature can be implemented by Figure 2A the encoding layer of the text matching model in.
[0156] It should be noted that in the embodiments of the present application, the words to be matched corresponding to the text to be matched a can form a text sequence {a1, a2, a3,..., a la}, and the candidate words corresponding to the candidate text b can form a text sequence {b1, b2, b3,..., b lb}, therefore, the word feature corresponding to the text a to be matched in the embodiments of the present application can be expressed as:
[0157]
[0158] Wherein, is the word feature corresponding to the text a to be matched, (a, i) represents the i-th word to be matched in the text a to be matched, and a i ∈R k is a k-dimensional vector.
[0159] The word feature corresponding to the candidate text b can be expressed as:
[0160]
[0161] Wherein, is the word feature corresponding to the candidate text b, (b, j) represents the j-th candidate word in the candidate text b, and b j ∈R k is a k-dimensional vector.
[0162] It should be noted that in the embodiments of the present application, first, the pre-trained word vectors are used for initialization, and then, a convolutional neural network is used as the encoder of the word vectors to encode the text to be matched and the candidate text to obtain the corresponding word features to be matched and candidate word features. A recurrent neural network can also be used as the word encoder, and a convolutional neural network can also be used as the word encoder. Preferably, a convolutional neural network is used as the word encoder in the embodiments of the present application because the number of parameters to be trained by the convolutional neural network is less than the number of parameters to be trained by the recurrent neural network.
[0163] S312: Perform the following operations for each word respectively: Based on the word feature of a word, determine the word dimension features corresponding to the word in at least one word dimension, and based on the obtained at least one dimension feature and the dimension weights corresponding to at least one word dimension, determine the word fusion feature of the word.
[0164] In the embodiments of the present application, the word fusion features corresponding to each word are obtained respectively. Taking any word (hereinafter referred to as word m) as an example, the process of determining the word fusion feature in the embodiments of the present application is as follows: Determine the word dimension features corresponding to word m in at least one word dimension respectively, and then, based on the determined at least one word dimension feature and the dimension weight corresponding to each word dimension feature, determine the word fusion feature corresponding to word m.
[0165] Wherein, in the embodiments of the present application, when determining the word fusion feature, it can be implemented through the word encoding layer of the text matching model in Figure 2A .
[0166] Optionally, in the embodiments of the present application, a possible implementation manner is provided for determining the word dimension features of each word in at least one word dimension. Refer to Figure 3D As shown, it is a schematic flowchart of determining the word dimension features in the embodiments of the present application, specifically including:
[0167] S3121: Reduce the number of dimensions corresponding to the word features of word m to the standard number to obtain the dimension-reduced word features.
[0168] In the embodiments of the present application, when determining the number of dimensions corresponding to the word features of word m and determining that the number of dimensions is greater than the preset standard number, perform dimension reduction processing on the word features to reduce the number of dimensions of the word features to the standard number, thereby obtaining the dimension-reduced word features.
[0169] S3122: For each of at least one word dimension, perform the following operations: Adopt the convolution processing method corresponding to a word dimension to perform convolution processing on the dimension-reduced word features to obtain the word dimension features corresponding to word m in a word dimension.
[0170] In the embodiments of the present application, for each word dimension, obtain the word dimension features corresponding to word m in at least one word dimension. Taking any one word dimension (hereinafter referred to as word dimension n) as an example, the process of obtaining word features in the embodiments of the present application is introduced as follows: Determine the convolution processing method corresponding to word dimension n, and adopt the determined convolution processing method to perform convolution processing on the dimension-reduced word features to obtain the word dimension features corresponding to word m in word dimension n. In this way, by reducing the dimensions of the word features, the parameters of the text matching model can be reduced, and by performing convolution processing through the convolution processing method corresponding to the word dimension, the word dimension features corresponding to the word can be obtained, improving the accuracy of subsequent text matching.
[0171] For example, refer to Figure 3EAs shown in the figure, it is an example diagram for determining the word fusion feature in the embodiment of the present application. Among them, through a one-dimensional convolutional layer, the number of dimensions corresponding to the word feature of the word "as it crosses a river" is reduced to the standard number 10 to obtain the dimension-reduced word feature. Then, through the convolutional channel corresponding to the word dimension "context", and adopting the convolutional processing method corresponding to the word dimension "context", the dimension-reduced word feature is subjected to convolutional processing to obtain the word dimension feature p1 corresponding to the word "as it crosses a river" in the word dimension "context", and adopting the convolutional processing method corresponding to the word dimension "context", the dimension-reduced word feature is subjected to convolutional processing to obtain the word dimension feature p1 corresponding to the word "as it crosses a river" in the word dimension "context", and, through the convolutional channel corresponding to the word dimension "meaning", and adopting the convolutional processing method corresponding to the word dimension "meaning", the dimension-reduced word feature is subjected to convolutional processing to obtain the word dimension feature p2 corresponding to the word "as it crosses a river" in the word dimension "meaning". Then, through the dimension weight corresponding to the word dimension "context", the word dimension feature p1 corresponding to the word dimension "context", the dimension weight corresponding to the word dimension "meaning", and the word dimension feature p2 corresponding to the word dimension "meaning", the word fusion feature of the word "as it crosses a river" is determined.
[0172] S313: According to the obtained word fusion features, respectively determine the keyword features and non-keyword features corresponding to each text.
[0173] Among them, when a text is a text to be matched, the word feature is the word feature to be matched, the keyword feature is the first keyword feature, and the non-keyword feature is the second non-keyword feature. When a text is a candidate text, the word feature is the candidate word feature, the keyword feature is the second keyword feature, and the non-keyword feature is the second non-keyword feature.
[0174] In the embodiment of the present application, after obtaining the word fusion features, the keyword features and non-keyword features corresponding to each text can be respectively determined based on the word fusion features. In this way, different weights are assigned to different word dimensions, and the keyword features and non-keyword features can be obtained more accurately. In the subsequent processing process, a higher weight can be assigned to the keyword features, so that the attention mechanism can focus on the keyword features. Since the keyword features can reflect the key parts of the text, improving the attention mechanism can further improve the accuracy of text matching.
[0175] Therefore, the first keyword feature and the first non-keyword feature corresponding to the text a to be matched in the embodiment of the present application can be expressed as:
[0176]
[0177] Among them, is the text feature corresponding to the text a to be matched, including the first keyword feature and the first non-keyword feature corresponding to the text a to be matched. is the word feature of the text a to be matched, and ImprovedCNN() is an enhanced convolutional neural network.
[0178] The second keyword feature and the second non-keyword feature corresponding to the candidate text b can be expressed as:
[0179]
[0180] Among them, is the text feature corresponding to the candidate text b, including the second keyword feature and the second non-keyword feature corresponding to the candidate text b. is the word feature of the candidate text b.
[0181] It should be noted that in the embodiments of the present application, the keyword feature and the non-keyword feature corresponding to each text are included in the text feature, that is, the text feature corresponding to the text to be matched includes the first keyword feature and the first non-keyword feature, and the text feature corresponding to the candidate text includes the second keyword feature and the second non-keyword feature.
[0182] S32: Based on each candidate word, perform interactive matching on each word to be matched to obtain the first matching feature corresponding to the text to be matched, and based on each word to be matched, perform interactive matching on each candidate word to obtain the second matching feature corresponding to the text to be matched.
[0183] In the embodiments of the present application, based on each candidate word, perform interactive matching on each word to be matched, so as to obtain the first matching feature corresponding to the text to be matched. At the same time, based on each word to be matched, perform interactive matching on each candidate word, so as to obtain the second matching feature corresponding to the candidate text.
[0184] It should be noted that in the embodiments of the present application, the execution order between S30-31 and S32 is not limited.
[0185] Optionally, in the embodiments of the present application, the first matching feature and the second matching feature can be obtained through the RE2 layer in the text matching model.
[0186] For example, refer to Figure 3FAs shown in the figure, it is an example diagram for determining the first matching feature and the second matching feature in the embodiment of the present application. Among them, the text to be matched is: A land rover is splashing water as it crosses a river, and the candidate text is: A land rover is being driven across a river. After segmenting the text to be matched, the words to be matched obtained are "A land rover", "is", "splashing water", and "as it crossesa river". After segmenting the candidate text, the candidate words obtained are "A land rover", "is", "beingdriven", and "across a river". Thus, it is determined that "A land rover" and "A land rover" are matching words, "is" and "is" are matching words, "as it crosses a river" and "across a river" are matching words, and no matching words are found for "splashing water" and "being driven". Therefore, based on the matching words "A landrover", "is", "as it crosses a river" and the non-matching word "splashing water", the first matching feature is determined, and based on the matching words "A land rover", "is", "across a river" and the non-matching word "beingdriven", the second matching feature is determined.
[0187] It should be noted that in the embodiment of the present application, when determining the words in the candidate text that match the words to be matched in the text to be matched, the word similarity between the word to be matched and the candidate word can be calculated. When the word similarity is greater than the similarity threshold, the corresponding word to be matched and the candidate word are used as mutually matching words.
[0188] S33: Based on the first keyword feature, the second non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature, and the second matching feature, determine the text matching result between the text to be matched and the candidate text.
[0189] In the embodiment of the present application, the final text matching result can be determined based on the first keyword feature, the first non-keyword feature, the first matching feature, the second keyword feature, the second non-keyword feature, and the second matching feature.
[0190] Optionally, in the embodiment of the present application, a possible implementation manner is provided for determining the text matching result. Refer toFigure 3G As shown in the figure, it is the first flowchart for determining the text matching result in an embodiment of the present application, specifically including:
[0191] S331: Concatenate the first keyword feature, the first non-keyword feature, and the first matching feature to obtain the first text feature corresponding to the text to be matched.
[0192] In an embodiment of the present application, the first keyword feature and the first non-keyword feature are fused to obtain the initial text feature corresponding to the text to be matched. Then, the initial text feature of the text to be matched is concatenated with the first matching feature to obtain the first text feature corresponding to the text to be matched.
[0193] It should be noted that in an embodiment of the present application, the process of obtaining the first text feature corresponding to the text to be matched can be implemented through the fusion layer in the text matching model.
[0194] Among them, the first text feature corresponding to the text to be matched can be expressed as:
[0195]
[0196] Among them, v a is the first matching feature, which includes the interaction feature between the text to be matched and the candidate text. is the initial text feature after fusing the first keyword feature and the first non-keyword feature, and o a is the first text feature.
[0197] S332: Concatenate the second keyword feature, the second non-keyword feature, and the second matching feature to obtain the second text feature corresponding to the candidate text.
[0198] In an embodiment of the present application, the second keyword feature and the second non-keyword feature are fused to obtain the initial text feature corresponding to the candidate text. Then, the initial text feature of the candidate text is concatenated with the second matching feature to obtain the second text feature corresponding to the candidate text.
[0199] Therefore, the second text feature in an embodiment of the present application can be expressed as:
[0200]
[0201] Among them, v b is the second matching feature, which includes the interaction feature between the text to be matched and the candidate text. is the initial text feature after fusing the second keyword feature and the second non-keyword feature, and o b is the second text feature.
[0202] It should be noted that in the embodiments of the present application, the process of obtaining the second text feature corresponding to the candidate text can be implemented by Figure 2A the feature fusion layer of the text matching model in
[0203] S333: Based on the first text feature, the second text feature, and a preset keyword weight set, determine the text matching result between the text to be matched and the candidate text.
[0204] In the embodiments of the present application, after obtaining the first text feature and the second text feature, obtain a preset keyword weight set, and based on the first text feature, the second text feature, and the keyword weight set, determine the text matching result between the text to be matched and the candidate text. In this way, through the keyword weight set, higher weights can be given to keyword features, so as to ensure that the attention mechanism can be accurately placed in keyword features, weaken local information irrelevant to the matching text, and improve the accuracy of text matching.
[0205] Optionally, in the embodiments of the present application, a possible implementation manner is provided for determining the text matching result between the text to be matched and the candidate text based on the text feature and the keyword weight set. Refer to Figure 3H shown, which is the second process schematic diagram for determining the text matching result in the embodiments of the present application, and specifically includes:
[0206] S3331: Perform feature fusion on the first text feature, the second text feature, the preset keyword weight set, and the first feature difference between the first text feature and the second text feature to obtain the to-be-matched fusion feature of the text to be matched.
[0207] In the embodiments of the present application, first, subtract the second text feature from the first text feature to obtain the first feature difference between the first text feature and the second text feature. Then, perform feature fusion on the first text feature, the second text feature, the keyword weight set, and the first feature difference, so as to obtain the to-be-matched fusion feature corresponding to the text to be matched.
[0208] Optionally, in the embodiments of the present application, a possible implementation manner is provided for determining the to-be-matched fusion feature. The process of determining the to-be-matched fusion feature in the embodiments of the present application is described below, and specifically includes:
[0209] S3331-1: Based on the first activation function, the first weight matrix corresponding to the first activation function, the first text feature, the second text feature, and the first feature difference, determine the first initial to-be-matched feature.
[0210] In the embodiments of the present application, first, the first text feature and the second text feature are multiplied point - by - point to obtain a text fusion feature between the first text feature and the second text feature. Then, the first text feature, the second text feature, the text fusion feature, and the first feature difference are concatenated to obtain a concatenated feature. Then, based on the first activation function, the first weight matrix corresponding to the first activation function included in the keyword weight set, and the first bias term corresponding to the first activation function, the first initial feature to be matched corresponding to the text to be matched is determined.
[0211] Among them, the first activation function in the embodiments of the present application can be, for example, tanh, ReLu, etc., and the embodiments of the present application do not limit this.
[0212] For example, when the first activation function in the embodiments of the present application is tanh, the first initial feature to be matched can be expressed as:
[0213]
[0214] Among them, m(o a ,o b ) is the first initial feature to be matched, tanh is the first activation function, W m is the first weight matrix corresponding to the first activation function tanh, ";" is the concatenation operation, is the element - wise product, o a is the first text feature; o b is the second text feature, o a -o b is the first feature difference, b m is the first bias term.
[0215] S3331 - 2: Perform the following operations respectively for at least one second weight matrix corresponding to the second activation function: Based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the first feature difference, determine the second initial feature to be matched.
[0216] In the embodiments of the present application, the first text feature and the second text feature are multiplied point - by - point to obtain a text fusion feature between the first text feature and the second text feature. Then, the first text feature, the second text feature, the text fusion feature, and the first feature difference are concatenated to obtain a concatenated feature. Then, respectively based on at least one second weight matrix corresponding to the second activation function, perform the following operations: Based on the second activation function, one second weight matrix, the first text feature, the second text feature, the text fusion feature, the first feature difference, and the second bias term corresponding to the second weight matrix, determine the second initial feature to be matched corresponding to the text to be matched.
[0217] Among them, the second activation function in the embodiments of the present application can be, for example, σ, ReLu, etc., and the embodiments of the present application do not limit this.
[0218] For example, when the second activation function in the embodiments of the present application is σ and the second weight matrix is W f , and the second bias term is b f , the second initial feature to be matched can be expressed as:
[0219]
[0220] Among them, σ is the second activation function, W f is the second weight matrix corresponding to the second activation function σ, and g f (o a , o b ) is the second initial feature to be matched corresponding to the second weight matrix W f , and b f is the second bias term corresponding to the second weight matrix W f .
[0221] When the second activation function in the embodiments of the present application is σ, the second weight matrix is W u , and the second bias term is b u , the second initial feature to be matched can be expressed as:
[0222]
[0223] Among them, W u is another second weight matrix corresponding to the second activation function σ, and g u (o a , o b ) is the second initial feature to be matched corresponding to the second weight matrix W u , and b u is the second bias term corresponding to the second weight matrix W u .
[0224] S3331-3: Determine the fusion feature to be matched corresponding to the text to be matched based on the first initial feature to be matched, the determined at least one second initial feature to be matched, and the first text feature.
[0225] In the embodiments of the present application, after obtaining the first initial feature to be matched and at least one second initial feature to be matched, the fusion feature to be matched corresponding to the text to be matched can be determined based on the first initial feature to be matched, the determined at least one second initial feature to be matched, and the first text feature.
[0226] Specifically, calculate the first product between the first initial feature to be matched and the second initial feature to be matched, and calculate the second product between the third initial feature to be matched and the first text feature, and add the first product and the second product to obtain the fused feature to be matched corresponding to the text to be matched.
[0227] Therefore, the fused feature to be matched in the embodiments of the present application can be expressed as:
[0228] o' a = g f (o a , o b ) * m(o a , o b ) + g u (o a , o b ) * o a
[0229] wherein, o' a is the fused feature to be matched corresponding to the text to be matched a.
[0230] By performing feature fusion on the first text feature, the second text feature, and the first feature difference, in combination with different activation functions and weight matrices, the initial features to be matched under different activation functions and weight matrices can be obtained. In this way, the fused feature to be matched obtained can further reflect the weight of the keyword feature in the text, thereby improving the accuracy of text matching.
[0231] S3332: Perform feature fusion on the first text feature, the second text feature, the keyword weight set, and the second feature difference between the second text feature and the first text feature to obtain the candidate fused feature of the candidate text.
[0232] Optionally, in the embodiments of the present application, a possible implementation manner is provided for determining the candidate fused feature, which specifically includes:
[0233] S3332-1: Obtain the first initial candidate feature based on the first activation function, the first weight matrix, the first text feature, the second text feature, and the second feature difference.
[0234] In the embodiments of the present application, first, perform a dot product on the first text feature and the second text feature to obtain the text fused feature between the first text feature and the second text feature. Then, splice the first text feature, the second text feature, the text fused feature, and the second feature difference to obtain the spliced feature. Then, based on the first activation function, the first weight matrix corresponding to the first activation function included in the keyword weight set, and the first bias term corresponding to the first activation function, determine the first initial candidate feature corresponding to the candidate text.
[0235] Among them, when determining the first initial candidate feature corresponding to the candidate text, the first activation function used may be the same as the first activation function used when determining the first initial to-be-matched feature corresponding to the text to be matched.
[0236] Therefore, when the first activation function in the embodiments of the present application is tanh, the first initial candidate feature can be expressed as:
[0237]
[0238] Where m(o b , o a ) is the first initial candidate feature, and o b -o a is the second feature difference.
[0239] S3332-2: Perform the following operations on at least one second weight matrix respectively: Determine the second initial candidate feature based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the second feature difference.
[0240] In the embodiments of the present application, the first text feature and the second text feature are multiplied pointwise to obtain a text fusion feature between the first text feature and the second text feature. Then, the first text feature, the second text feature, the text fusion feature, and the second feature difference are concatenated to obtain a concatenated feature. Then, respectively based on at least one second weight matrix corresponding to the second activation function, perform the following operations: Determine the second initial candidate feature corresponding to the candidate text based on the second activation function, one second weight matrix, the first text feature, the second text feature, the text fusion feature, the second feature difference, and the second bias term corresponding to the second weight matrix.
[0241] Among them, when determining at least one second initial candidate feature corresponding to the candidate text, the second activation function used may be the same as the second activation function used when determining the second initial to-be-matched feature corresponding to the text to be matched.
[0242] For example, when the second activation function in the embodiments of the present application is σ, the second weight matrix is W f , and the second bias term is b f , the second initial candidate feature can be expressed as:
[0243]
[0244] Where g f (o b , o a ) is the second initial candidate feature corresponding to the second weight matrix W f .
[0245] When the second activation function in the embodiments of the present application is σ and the second weight matrix is W u , and the second bias term is b u , the second initial candidate feature can be expressed as:
[0246]
[0247] where g u (o b , o a ) is the second initial candidate feature corresponding to the second weight matrix W u .
[0248] It should be noted that in the first weight matrix and each second weight matrix in the embodiments of the present application, the weight of the keyword feature is greater than the weight of the non-keyword feature.
[0249] S3332-3: Determine the candidate fusion feature corresponding to the candidate text based on the first initial candidate feature, at least one determined second initial candidate feature, and the second text feature.
[0250] In the embodiments of the present application, after obtaining the first initial candidate feature and at least one second initial candidate feature, the candidate fusion feature corresponding to the text to be matched can be determined based on the first initial candidate feature, at least one determined second initial candidate feature, and the second text feature.
[0251] Specifically, calculate the first product between the first initial candidate feature and the second initial candidate feature, and calculate the second product between the third initial candidate feature and the second text feature, and add the first product and the second product to obtain the candidate fusion feature corresponding to the candidate text.
[0252] For example, the candidate fusion feature in the embodiments of the present application can be expressed as:
[0253] o' b = g f (o a , o b ) * m(o a , o b ) + g u (o a , o b ) * o b
[0254] Furthermore, when determining the candidate fusion feature, the first initial candidate feature and at least one second initial candidate feature can also be directly feature-stitched to obtain the final candidate fusion feature, and there is no limitation to this.
[0255] In the embodiments of the present application, by performing feature fusion on the first text feature, the second text feature, and the second feature difference, in combination with different activation functions and weight matrices, initial candidate features under different activation functions and weight matrices can be obtained, so that the obtained candidate fusion features can further reflect the weight of keyword features in the text, thereby improving the accuracy of text matching.
[0256] S3333: Based on the to-be-matched fusion feature and the candidate fusion feature, determine the text matching result between the to-be-matched text and the candidate text.
[0257] In the embodiments of the present application, since the to-be-matched fusion feature and the candidate fusion feature can more accurately reflect the interactive matching features between the to-be-matched text and the candidate text, rich matching features can be obtained, thereby improving the accuracy of text matching.
[0258] In the embodiments of the present application, when executing S3333, refer to Figure 3I As shown, it is the third process schematic diagram for determining the text matching result in the embodiments of the present application, specifically including:
[0259] S3333-1: Determine the fusion feature difference between the to-be-matched fusion feature and the candidate fusion feature.
[0260] In the embodiments of the present application, the to-be-matched fusion feature and the candidate fusion feature are subtracted from each other to obtain the fusion feature difference between the to-be-matched fusion feature and the candidate fusion feature.
[0261] Therefore, the fusion feature difference in the embodiments of the present application can be expressed as: o' a -o' b .
[0262] S3333-2: Concatenate the to-be-matched fusion feature, the candidate fusion feature, the fusion feature difference, and the cross-fusion feature between the first text feature and the second text feature to obtain the to-be-predicted feature.
[0263] In the embodiments of the present application, first calculate the cross-fusion feature between the first text feature and the second text feature, and then concatenate the to-be-matched fusion feature, the candidate fusion feature, the fusion feature difference, and the cross-fusion feature to obtain the to-be-predicted feature.
[0264] It should be noted that in the embodiments of the present application, the process of obtaining the to-be-predicted feature can be implemented through the prediction layer in the text matching model.
[0265] S3333-3: Based on the to-be-predicted feature, in combination with the correspondence between each to-be-predicted feature and the corresponding text matching result, determine the text matching result corresponding to the to-be-predicted feature.
[0266] In the embodiments of the present application, the corresponding relationship between each feature to be predicted and the text matching result is pre-learned. Then, based on the feature to be predicted, in combination with the corresponding relationship between each feature to be predicted and the corresponding text matching result, the text matching result corresponding to the feature to be predicted is determined from each text matching result, and the determined text matching result is used as the text matching result between the text to be matched and the candidate text.
[0267] Optionally, in the embodiments of the present application, the corresponding matching score can also be determined based on the feature to be predicted, in combination with the corresponding relationship between each feature to be predicted and the corresponding matching score, so as to determine the text matching result between the text to be matched and the candidate text based on the matching score. For example, assuming the matching score is 80, the corresponding text matching result is "matched".
[0268] Among them, the matching score can be expressed as:
[0269]
[0270] Among them, H is a multi-layer perceptron.
[0271] In this way, the text to be matched fusion feature and the candidate fusion feature are converted into a feature vector with a fixed length, and the fixed length vectors of the text to be matched and the candidate text with the fusion feature difference are input into the prediction layer for prediction, which can improve the accuracy of text matching.
[0272] In the embodiments of the present application, after the encoding layer, the interaction features between the text to be matched and the candidate text are captured through a multi-layer alignment mechanism to obtain the matching features of the text to be matched and the candidate text; at the same time, an enhanced CNN is used to obtain the keyword features within the text to be matched and the candidate text to further capture the key features of the text to be matched and the candidate text; then, through a fusion method based on a gating mechanism, the key features within the text and the matching features between the texts are fused, and the gating network selects to strengthen the key matching information and weaken the local information irrelevant to the matching text, so as to improve the accuracy of text matching.
[0273] Based on the above embodiments, a specific example is used below to illustrate the text matching method in the embodiments of the present application. Refer to Figure 4 As shown, it is an example diagram of the text matching method in the embodiments of the present application, which specifically includes:
[0274] First, the text to be matched "Where is the restroom" is tokenized, and the words to be matched obtained are "restroom", "where", and "is". The candidate text "The location of the toilet" is tokenized, and the candidate words obtained are "toilet", "of", and "location".
[0275] Then, through the encoding layer, the word features corresponding to "washroom", "in", and "where" are determined respectively, and the word features corresponding to "toilet", "of", and "location" are determined respectively. And through the word encoding layer, the first keyword feature and the first non-keyword feature of "where is the washroom" are determined, and the second keyword feature and the second non-keyword feature of "the location of the toilet" are determined.
[0276] Meanwhile, by performing interactive matching on "where is the washroom" and "the location of the toilet", the first matching feature corresponding to the text to be matched "where is the washroom" is determined, and the second matching feature corresponding to the candidate text "the location of the toilet" is determined.
[0277] Then, through the feature fusion layer, the first keyword feature, the first non-keyword feature, the first matching feature, the second keyword feature, the second non-keyword feature, and the second matching feature are fused to obtain the fused feature to be matched corresponding to the text to be matched "where is the washroom", and the candidate fused feature corresponding to the candidate text "the location of the toilet" is obtained.
[0278] Finally, through the fusion layer, based on the fused feature to be matched and the candidate fused feature, it is determined that the text matching result between the text to be matched "where is the washroom" and the candidate text "the location of the toilet" is a match.
[0279] Based on the same inventive concept, the embodiment of the present application also provides a text matching device. Refer to Figure 5 As shown in the figure, it is a schematic structural diagram of the text matching device in the embodiment of the present application, which may include:
[0280] The first extraction module 500 is used to determine the first keyword feature and the first non-keyword feature corresponding to the text to be matched based on the first word dimension features corresponding to each word to be matched included in the text to be matched in at least one word dimension;
[0281] The second extraction module 510 is used to determine the second keyword feature and the second non-keyword feature corresponding to the candidate text based on the second word dimension features corresponding to each candidate word included in the candidate text in at least one word dimension;
[0282] The third extraction module 520 is used to perform interactive matching on each word to be matched with each candidate word as a reference to obtain the first matching feature corresponding to the text to be matched, and perform interactive matching on each candidate word with each word to be matched as a reference to obtain the second matching feature corresponding to the text to be matched;
[0283] The matching module 530 is used to determine the text matching result between the text to be matched and the candidate text based on the first keyword feature, the first non-keyword feature, the second keyword feature, the second non-keyword feature, the first matching feature, and the second matching feature.
[0284] Optionally, when obtaining the first keyword feature, the first non-keyword feature, the second keyword feature, and the second non-keyword feature, the first extraction module 500 and the second extraction module 510 are further configured to:
[0285] Determine the word features corresponding to each word included in each text;
[0286] Perform the following operations for each word respectively: Based on the word feature of a word, determine the word dimension feature corresponding to the word in at least one word dimension, and based on the obtained at least one dimension feature and the dimension weights corresponding to at least one word dimension, determine the word fusion feature of the word;
[0287] According to the obtained word fusion features of each word, respectively determine the keyword feature and the non-keyword feature corresponding to each text;
[0288] Wherein, when a text is a text to be matched, the word feature is the word feature to be matched, the keyword feature is the first keyword feature, and the non-keyword feature is the second non-keyword feature; when a text is a candidate text, the word feature is the candidate word feature, the keyword feature is the second keyword feature, and the non-keyword feature is the second non-keyword feature.
[0289] Optionally, when determining the word dimension feature corresponding to a word in at least one word dimension based on the word feature of the word, the first extraction module 500 and the second extraction module 510 are further configured to:
[0290] Reduce the number of dimensions corresponding to the word feature of a word to a standard number to obtain the dimension-reduced word feature;
[0291] Perform the following operations for each of at least one word dimension respectively: Use the convolution processing method corresponding to a word dimension to perform convolution processing on the dimension-reduced word feature to obtain the word dimension feature corresponding to the word in a word dimension.
[0292] Optionally, the matching module 530 is further configured to:
[0293] Perform feature splicing on the first keyword feature, the first non-keyword feature, and the first matching feature to obtain the first text feature corresponding to the text to be matched;
[0294] Perform feature splicing on the second keyword feature, the second non-keyword feature, and the second matching feature to obtain the second text feature corresponding to the candidate text;
[0295] Based on the first text feature, the second text feature, and the preset keyword weight set, determine the text matching result between the text to be matched and the candidate text.
[0296] Optionally, when determining the text matching result between the text to be matched and the candidate text based on the first text feature, the second text feature, and a preset keyword weight set, the matching module 530 is further configured to:
[0297] Perform feature fusion on the first text feature, the second text feature, the preset keyword weight set, and the first feature difference between the first text feature and the second text feature to obtain a to-be-matched fusion feature of the text to be matched;
[0298] Perform feature fusion on the first text feature, the second text feature, the keyword weight set, and the second feature difference between the second text feature and the first text feature to obtain a candidate fusion feature of the candidate text;
[0299] Determine the text matching result between the text to be matched and the candidate text based on the to-be-matched fusion feature and the candidate fusion feature.
[0300] Optionally, when obtaining the to-be-matched fusion feature of the text to be matched, the matching module 530 is further configured to:
[0301] Determine a first initial to-be-matched feature based on a first activation function, a first weight matrix corresponding to the first activation function, the first text feature, the second text feature, and the first feature difference;
[0302] Perform the following operations for each of at least one second weight matrix corresponding to a second activation function: determine a second initial to-be-matched feature based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the first feature difference;
[0303] Determine the to-be-matched fusion feature corresponding to the text to be matched based on the first initial to-be-matched feature, the determined at least one second initial to-be-matched feature, and the first text feature.
[0304] Optionally, when obtaining the candidate fusion feature of the candidate text, the matching module 530 is further configured to:
[0305] Obtain a first initial candidate feature based on the first activation function, the first weight matrix, the first text feature, the second text feature, and the second feature difference;
[0306] Perform the following operations for each of at least one second weight matrix: determine a second initial candidate feature based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the second feature difference;
[0307] Determine the candidate fusion feature corresponding to the candidate text based on the first initial candidate feature, the determined at least one second initial candidate feature, and the second text feature.
[0308] Optionally, when determining the text matching result between the text to be matched and the candidate text based on the feature to be matched for fusion and the candidate feature for fusion, the matching module 530 is further configured to:
[0309] Determine the difference between the feature to be matched for fusion and the candidate feature for fusion;
[0310] Concatenate the feature to be matched for fusion, the candidate feature for fusion, the difference between the features for fusion, and the cross-fusion feature between the first text feature and the second text feature to obtain the feature to be predicted;
[0311] Based on the feature to be predicted, and in combination with the correspondence between each feature to be predicted and the corresponding text matching result, determine the text matching result corresponding to the feature to be predicted.
[0312] Those skilled in the art can understand that various aspects of the present application can be implemented as a system, a method, or a program product. Therefore, various aspects of the present application can be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, which can be collectively referred to as "circuitry", "module", or "system" here.
[0313] In some possible implementation manners, the text matching device according to the present application may at least include a processor and a memory. Wherein, the memory stores program code, and when the program code is executed by the processor, the processor is caused to execute the steps in the text matching method according to various exemplary implementation manners of the present application described in this specification. For example, the processor may execute the steps as Figure 3A shown.
[0314] Based on the same inventive concept as the above method embodiment, an electronic device is further provided in an embodiment of the present application. In one embodiment, the electronic device may be a client, such as Figure 1 the client 110 shown, and the electronic device may also be a server, such as Figure 1 the server 120 shown. In this embodiment, the structure of the electronic device may be as Figure 6 shown, including a memory 601, a communication module 603, and one or more processors 602.
[0315] The memory 601 is used to store the computer program executed by the processor 602. The memory 601 may mainly include a program storage area and a data storage area. Among them, the program storage area may store an operating system and programs required to run the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0316] The memory 601 can be a volatile memory, such as a random-access memory (RAM); the memory 601 can also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 601 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 601 can be a combination of the above memories.
[0317] The processor 602 can include one or more central processing units (CPUs) or be a digital processing unit, etc. The processor 602 is used to implement the above text matching method when calling the computer program stored in the memory 601.
[0318] The communication module 603 is used to communicate with the terminal device and other servers.
[0319] In the embodiments of the present application, the specific connection medium between the above memory 601, communication module 603 and processor 602 is not limited. In the embodiments of the present application Figure 6 it is described that the memory 601 and the processor 602 are connected through a bus 604, and the bus 604 is described in thick lines in Figure 6 The connection manners between other components are only for illustrative purposes and are not limiting. The bus 604 can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of description, Figure 6 only a thick line is used to describe it in
[0320] The memory 601 stores a computer storage medium, and the computer storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the text matching method of the embodiments of the present application. The processor 602 is used to execute the above text matching method, as Figure 3A shown.
[0321] In some possible implementation manners, various aspects of the text matching method provided by the present application can also be implemented in the form of a program product, which includes program code. When the program product runs on a computer device, the program code is used to cause the computer device to execute the steps in the text matching method according to various exemplary embodiments of the present application described above in this specification. For example, the computer device can execute the steps as Figure 3A shown in
[0322] The program product can adopt any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having 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.
[0323] The program product of the embodiments of the present application can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can run on a computing device. However, the program product of the present application is not limited to this. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with a command execution system, apparatus, or device.
[0324] The readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries the readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium can also be any readable medium other than the readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.
[0325] The program code contained on the readable medium can be transmitted by any appropriate medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination of the above.
[0326] The program code for performing the operations of the present application can be written in any combination of one or more programming languages. The programming languages include object-oriented programming languages - such as Java, C++, etc., and also include conventional procedural programming languages - such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, executed as an independent software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, by using an Internet service provider to connect through the Internet).
[0327] It should be noted that although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more of the above-described units can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.
[0328] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the shown operations must be performed to achieve the desired result. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution.
[0329] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0330] Although the preferred embodiments of the present application have been described, those skilled in the art can make additional changes and modifications once they know the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications falling within the scope of the present application.
[0331] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these changes and modifications.
Claims
1. A text matching method, characterized in that Including: Determining a first keyword feature and a first non-keyword feature corresponding to the text to be matched based on first word dimension features corresponding to each word to be matched included in the text to be matched in at least one word dimension; Determining a second keyword feature and a second non-keyword feature corresponding to the candidate text based on second word dimension features corresponding to each candidate word included in the candidate text in the at least one word dimension; the first keyword feature, the first non-keyword feature, the second keyword feature, and the second non-keyword feature are obtained in the following manner: determining word features corresponding to each word included in each text; Performing the following operations respectively for each of the words: based on the word feature of a word, determining word dimension features corresponding to the word in at least one word dimension, and based on the obtained at least one dimension feature and dimension weights corresponding to the at least one word dimension, determining a word fusion feature of the word; according to the obtained word fusion features of the words, respectively determining keyword features and non-keyword features corresponding to each of the texts; wherein when a text is a text to be matched, the word feature is a word feature to be matched, the keyword feature is the first keyword feature, and the non-keyword feature is the first non-keyword feature, and when the text is a candidate text, the word feature is a candidate word feature, the keyword feature is the second keyword feature, and the non-keyword feature is the second non-keyword feature; Taking each of the candidate words as a reference, performing interactive matching on each of the words to be matched to obtain a first matching feature corresponding to the text to be matched, and taking each of the words to be matched as a reference, performing interactive matching on each of the candidate words to obtain a second matching feature corresponding to the text to be matched; Performing feature splicing on the first keyword feature, the first non-keyword feature, and the first matching feature to obtain a first text feature corresponding to the text to be matched; Performing feature splicing on the second keyword feature, the second non-keyword feature, and the second matching feature to obtain a second text feature corresponding to the candidate text; Determining a text matching result between the text to be matched and the candidate text based on the first text feature, the second text feature, and a preset keyword weight set.
2. The method according to claim 1, characterized in that, Determining word dimension features corresponding to a word in at least one word dimension based on the word feature of the word includes: Reducing the number of dimensions corresponding to the word feature of a word to a standard number to obtain a dimension-reduced word feature; Performing the following operations respectively for at least one word dimension: performing convolution processing on the dimension-reduced word feature using a convolution processing method corresponding to a word dimension to obtain a word dimension feature corresponding to the word in the word dimension.
3. The method according to claim 1, wherein Determining a text matching result between the text to be matched and the candidate text based on the first text feature, the second text feature, and a preset keyword weight set includes: Perform feature fusion on the first text feature, the second text feature, a preset keyword weight set, and a first feature difference between the first text feature and the second text feature to obtain a to-be-matched fusion feature of the to-be-matched text; Perform feature fusion on the first text feature, the second text feature, the keyword weight set, and a second feature difference between the second text feature and the first text feature to obtain a candidate fusion feature of the candidate text; Based on the to-be-matched fusion feature and the candidate fusion feature, determine a text matching result between the to-be-matched text and the candidate text.
4. The method according to claim 3, wherein The to-be-matched fusion feature of the to-be-matched text is obtained in the following manner: Based on a first activation function, a first weight matrix corresponding to the first activation function, the first text feature, the second text feature, and the first feature difference, determine a first initial to-be-matched feature; Perform the following operations respectively for at least one second weight matrix corresponding to a second activation function: Based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the first feature difference, determine a second initial to-be-matched feature; Based on the first initial to-be-matched feature, the determined at least one second initial to-be-matched feature, and the first text feature, determine the to-be-matched fusion feature corresponding to the to-be-matched text.
5. The method according to claim 4, characterized in that, The candidate fusion feature of the candidate text is obtained in the following manner: Based on the first activation function, the first weight matrix, the first text feature, the second text feature, and the second feature difference, obtain a first initial candidate feature; Perform the following operations respectively for the at least one second weight matrix: Based on the second activation function, one second weight matrix, the first text feature, the second text feature, and the second feature difference, determine a second initial candidate feature; Based on the first initial candidate feature, the determined at least one second initial candidate feature, and the second text feature, determine the candidate fusion feature corresponding to the candidate text.
6. The method according to any one of claims 3-5, characterized in that Based on the to-be-matched fusion feature and the candidate fusion feature, determining the text matching result between the to-be-matched text and the candidate text includes: Determine a fusion feature difference between the to-be-matched fusion feature and the candidate fusion feature; Concatenate the to-be-matched fusion feature, the candidate fusion feature, the fusion feature difference, and a cross-fusion feature between the first text feature and the second text feature to obtain a to-be-predicted feature; Based on the to-be-predicted feature, in combination with the corresponding relationship between each to-be-predicted feature and the corresponding text matching result, determine the text matching result corresponding to the to-be-predicted feature.
7. A text matching device, characterized in that, Including: A first extraction module, configured to determine a first keyword feature and a first non-keyword feature corresponding to the to-be-matched text based on first word dimension features corresponding to each to-be-matched word included in the to-be-matched text in at least one word dimension; A second extraction module, configured to determine a second keyword feature and a second non-keyword feature corresponding to the candidate text based on second word dimension features corresponding to each candidate word included in the candidate text in each of the at least one word dimension; A third extraction module, configured to perform interactive matching on each word to be matched based on each candidate word to obtain a first matching feature corresponding to the text to be matched, and perform interactive matching on each candidate word based on each word to be matched to obtain a second matching feature corresponding to the text to be matched; A matching module, configured to splice the first keyword feature, the first non-keyword feature, and the first matching feature to obtain a first text feature corresponding to the text to be matched; splice the second keyword feature, the second non-keyword feature, and the second matching feature to obtain a second text feature corresponding to the candidate text; and determine a text matching result between the text to be matched and the candidate text based on the first text feature, the second text feature, and a preset keyword weight set; Wherein, when obtaining the first keyword feature, the first non-keyword feature, the second keyword feature, and the second non-keyword feature, the first extraction module and the second extraction module are further configured to: determine word features corresponding to each word included in each text; respectively perform the following operations on each word: based on the word feature of a word, determine word dimension features corresponding to the word in at least one word dimension, and based on the obtained at least one dimension feature and dimension weights corresponding to the at least one word dimension, determine a word fusion feature of the word; and respectively determine a keyword feature and a non-keyword feature corresponding to each text according to the obtained word fusion features of each word; wherein, when a text is a text to be matched, the word feature is a word feature to be matched, the keyword feature is a first keyword feature, and the non-keyword feature is a first non-keyword feature, and when the text is a candidate text, the word feature is a candidate word feature, the keyword feature is a second keyword feature, and the non-keyword feature is a second non-keyword feature.
8. The device according to claim 7, characterized in that, When determining word dimension features corresponding to a word in at least one word dimension based on the word feature of the word, the first extraction module and the second extraction module are further configured to: Reduce the number of dimensions corresponding to the word feature of a word to a standard number to obtain a dimension-reduced word feature; Respectively perform the following operations on at least one word dimension: perform convolution processing on the dimension-reduced word feature by using a convolution processing method corresponding to a word dimension to obtain a word dimension feature corresponding to the word in the word dimension; 9. An electronic device, characterized in that, It includes a processor and a memory. Wherein, the memory stores program code, and when the program code is executed by the processor, the processor is caused to execute the steps of the method according to any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, It includes program code, and when the program code runs on an electronic device, the program code is used to cause the electronic device to execute the steps of the method according to any one of claims 1-6.
11. A computer program product, characterized in that, It includes computer instructions stored in a computer-readable storage medium; when a processor of an electronic device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, causing the electronic device to perform the steps of any one of claims 1-6.
Citation Information
Patent Citations
Real-time text sentiment analysis method, device and apparatus based on deep learning
CN110321565A
Text data processing method, device and equipment and storage medium
CN111444326A