Text semantic matching methods, devices, equipment and storage media
By acquiring the target user's questions and their related text encodings from the FAQ system, and utilizing attention mechanisms and fusion processing techniques, the problems of low semantic matching accuracy and high deployment costs during deep learning model training were solved, achieving higher matching accuracy and reduced costs.
Patent Information
- Application Number
- CN202210988986.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-17
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-08-17
Smart Images

Figure CN115292468B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of artificial intelligence technology, and in particular to a text semantic matching method, apparatus, device and storage medium. Background Technology
[0002] With the development of artificial intelligence technology, question-and-answer systems applied to intelligent customer service have also experienced rapid growth. Frequently Asked Questions (FAQ) systems have become widely used as a type of question-and-answer system.
[0003] To continuously optimize the semantic matching performance of the FAQ question-answering system, it is necessary to continuously acquire historical questions raised by online users and similar questions identified as standard questions by domain experts to expand the training data of the deep learning model. The expanded training data is then used to retrain the deep learning model for semantic matching and deploy it.
[0004] Therefore, current semantic matching methods cannot promptly utilize the trained deep learning model for semantic matching, resulting in poor semantic matching accuracy during deep learning model training. Furthermore, redeploying the trained deep learning model leads to high costs. Summary of the Invention
[0005] This invention provides a text semantic matching method, apparatus, device, and storage medium to solve the technical problem that semantic matching cannot be performed in a timely manner using a trained deep learning model, resulting in poor accuracy of semantic matching during the training of the deep learning model, and that redeploying the trained deep learning model leads to high costs.
[0006] In a first aspect, embodiments of the present invention provide a text semantic matching method, including:
[0007] Obtain the target user question to be matched, at least one candidate standard question that matches the target user question field, and at least one empirical question corresponding to each candidate standard question;
[0008] The target user's question, the candidate standard question, and the experience question are encoded respectively to obtain the corresponding text codes;
[0009] Based on an attention mechanism, the text encoding of the target empirical question related to the target user's question is determined in the empirical question corresponding to each of the candidate standard questions;
[0010] The target experience question text codes are fused with the corresponding candidate standard question text codes to obtain the candidate fused question text codes;
[0011] The target user's question text encoding is matched and sorted with the candidate fused question text encodings to obtain a matching question that matches the target user's question.
[0012] In a second aspect, embodiments of the present invention provide a text semantic matching device, comprising:
[0013] The acquisition module is used to acquire the target user question to be matched, at least one candidate standard question that matches the target user question field, and at least one empirical question corresponding to each candidate standard question;
[0014] The encoding module is used to encode the target user's question, the candidate standard question, and the experience question respectively to obtain the corresponding text encoding;
[0015] The determination module is used to determine the target empirical question text encoding related to the target user question in the empirical questions corresponding to each of the candidate standard questions based on an attention mechanism;
[0016] The fusion module is used to fuse the text codes of each target experience question with the corresponding candidate standard question text codes to obtain the text codes of each candidate fused question.
[0017] The matching and sorting module is used to perform matching and sorting processing on the target user's question text encoding and the candidate fused question text encoding to obtain matching questions that match the target user's question.
[0018] Thirdly, embodiments of the present invention provide an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0019] The memory stores computer-executed instructions;
[0020] The processor executes computer execution instructions stored in the memory to implement the method as described in the first aspect.
[0021] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect.
[0022] This invention provides a text semantic matching method, apparatus, device, and storage medium. The method involves acquiring a target user question to be matched, at least one candidate standard question matching the target user question field, and at least one empirical question corresponding to each candidate standard question. The target user question, the candidate standard question, and the empirical question are encoded to obtain corresponding text codes. Based on an attention mechanism, the text codes of target empirical questions related to the target user question are determined from the empirical questions corresponding to each candidate standard question. The text codes of each target empirical question are fused with the corresponding candidate standard question text codes to obtain candidate fused question text codes. Finally, the target user question text codes and the candidate fused question text codes are matched and sorted to obtain matching questions that match the target user question. Because at least one empirical question corresponding to the candidate standard question is included when matching the target user question, and after encoding the target user question, candidate standard question, and the empirical question, the empirical question text code related to the target user question is extracted from the empirical question corresponding to each candidate standard question, and fused with the text code of the corresponding candidate standard question, the resulting candidate fused question text code is based on the original text code of each candidate standard question with the addition of the empirical question text code related to the target user question. Therefore, semantic matching of the target user question text code with each candidate fused question text code can obtain matching questions with higher semantic matching degree, and there is no need to redeploy the trained deep learning model, thus reducing costs. Attached Figure Description
[0023] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0024] Figure 1 This is an application scenario diagram illustrating the text semantic matching method of this invention embodiment;
[0025] Figure 2 This is a flowchart illustrating a text semantic matching method provided in an embodiment of the present invention;
[0026] Figure 3 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention;
[0027] Figure 4 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention;
[0028] Figure 5 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention;
[0029] Figure 6 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention;
[0030] Figure 7 This is a schematic diagram of the structure of a text semantic matching device provided in an embodiment of the present invention;
[0031] Figure 8 This is a schematic diagram of the structure of an electronic device used to implement the text semantic matching method of this invention.
[0032] The accompanying drawings have illustrated specific embodiments of this disclosure, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concepts of this disclosure to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0033] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0034] First, the terms used in the embodiments of this invention will be explained:
[0035] Encoding: A technique that uses deep learning networks to convert natural language into real number matrices.
[0036] BERT: A natural language understanding encoder model that takes a natural language sentence as input, encodes the natural language sentence, and obtains the encoded representation of each component unit in the natural language sentence.
[0037] Exponential function normalization (also known as softmax normalization): a K-dimensional vector z containing arbitrary real numbers is "compressed" into another K-dimensional real vector σ(z) such that each element is in the range (0,1) and the sum of all elements is 1.
[0038] The following is a detailed introduction to the existing technology:
[0039] FAQ question-answering systems match user-submitted questions with standard questions or similar questions in a knowledge base, and then return the corresponding standard answers as the answers to the user's questions. Current FAQ question-answering systems typically employ a combination of coarse field matching and fine semantic matching for question matching. First, the coarse field matching process involves matching the user's question with a large number of standard questions and their corresponding similar questions in the knowledge base, selecting the most similar standard questions or similar questions as candidate standard questions. Then, the fine semantic matching process uses a deep learning model to rank the user's questions against the candidate standard questions. After this process, candidate standard questions with the same semantic meaning as the user's question are selected, and their corresponding answers are returned to the user as the answers to the user's questions.
[0040] To continuously optimize the semantic matching performance of the FAQ question-answering system, it is necessary to continuously acquire historical questions raised by online users and similar questions identified as standard questions by domain experts to expand the training data of the deep learning model. The expanded training data is then used to retrain the deep learning model for semantic matching and deploy it.
[0041] Because the deep learning model for semantic matching is retrained and deployed using augmented training data, semantic matching cannot be performed promptly using the retrained deep learning model during the retraining process. This results in poor semantic matching accuracy, and the redeployment of the already trained deep learning model leads to high costs.
[0042] Therefore, in addressing the technical problems in existing technologies, to enable timely semantic matching of empirical questions with user questions, after initially screening out multiple candidate standard questions, relevant features of the empirical questions related to the user question can be extracted from each candidate standard question and its corresponding empirical question. These features are then fused with the corresponding candidate standard questions to form candidate fused questions. Subsequently, the target user question is semantically matched with each candidate fused question. To accurately extract the relevant features of the empirical questions related to the user question from the empirical questions corresponding to each candidate standard question, the target user question, the candidate standard questions, and the empirical questions can be encoded separately to obtain corresponding text codes. Based on an attention mechanism, the target empirical question text code related to the target user question is determined from the empirical questions corresponding to each candidate standard question. This target empirical question text code accurately represents the relevant features of the empirical questions related to the user question within the corresponding empirical question. To fuse the relevant features of user-associated experience questions with the corresponding candidate standard questions, the text encodings of each target experience question can be fused with the text encodings of the corresponding candidate standard questions to obtain the text encodings of each candidate fused question. Therefore, by using the text semantic matching method provided in this application to semantically match the text encodings of the target user questions with the text encodings of each candidate fused question, a matching question with a higher semantic matching degree can be obtained, and there is no need to redeploy the trained deep learning model, thus reducing costs.
[0043] The following describes the application scenarios corresponding to the text semantic matching method provided in the embodiments of this application. Specifically, the text semantic matching device provided in the embodiments of this application can be located in the second backend server 22 of the question-answering system 2. The question-answering system 2 may also include a first backend server 21 and a knowledge base 23. Figure 1 As shown, users can trigger a text semantic matching request by entering the target user's question in the question box 11 of the question-and-answer system client or webpage interface on user terminal 1. For example, as... Figure 1As shown, the target user's question is "I want to swipe my bus card". The first backend server 21 of the question-answering system 2 first coarsely filters out at least one candidate standard question based on the target user's statement and the pre-built knowledge base 23. The text semantic matching device of the second backend server 22 obtains the target user's question to be matched, at least one candidate standard question matching the target user's question field, and at least one empirical question corresponding to each candidate standard question. The matching question is determined using the text semantic matching method provided in this application, and the standard answer corresponding to the matching question is obtained from the knowledge base. The standard answer is sent to the client, and the client displays the standard answer. For example, the corresponding standard answer is "Open the bus card APP, click on the bus ride interface, and align the QR code on the interface with the card reader".
[0044] It should be noted that the text semantic matching method, apparatus, device, and storage medium provided in the embodiments of the present invention can be used in the field of artificial intelligence technology. They can also be used in any field other than artificial intelligence technology. The application fields of the text semantic matching method, apparatus, device, and storage medium provided in the embodiments of the present invention are not limited.
[0045] Furthermore, the collection, storage, use, processing, transmission, provision, and disclosure of user questions and other information involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0046] The technical solutions of the present invention and how they solve the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will now be described with reference to the accompanying drawings.
[0047] Figure 2 This is a flowchart illustrating a text semantic matching method provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the execution subject of this embodiment is a text semantic matching device. In practical applications, this text semantic matching device can be implemented by a computer program, or by a medium storing the relevant computer program, such as a USB flash drive and / or optical disc; or, it can be implemented by a physical device integrating or installing the relevant computer program, such as a chip. The text semantic matching method provided in this embodiment includes the following steps:
[0048] Step 201: Obtain the target user question to be matched, at least one candidate standard question that matches the target user question field, and at least one empirical question corresponding to each candidate standard question.
[0049] The target user question to be matched is the question entered by the user through the client or webpage of the question-and-answer system to search for an answer. The question-and-answer system can be a FAQ system or other question-and-answer systems; this embodiment does not limit this.
[0050] Specifically, in this embodiment, users can open the client or webpage of the question-and-answer system, enter the target user's question in the question box of the client or webpage operation interface, and trigger a question-and-answer request through a component so that the text semantic matching method can obtain the target user's question.
[0051] In this embodiment, the knowledge base corresponding to the question-answering system pre-stores high-frequency standard question-answer pairs. It can also store similar questions with different wording for each standard question. Therefore, candidate standard questions are those selected by the question-answering system after obtaining the target user's question, performing field-level similarity matching between the target user's question and multiple pre-stored standard questions and their corresponding similar questions in the knowledge base, and then filtering out the standard questions or similar questions with high similarity.
[0052] For example, the target user's question, the standard question, the similar questions corresponding to the standard question, and the standard answer can be represented as shown in Table 1:
[0053] Table 1: A table illustrating various questions and their standard answers
[0054]
[0055] In this embodiment, the experience questions corresponding to each candidate standard question are historical questions raised by online users and similar questions identified by domain experts as the corresponding standard questions.
[0056] In this embodiment, after domain experts identify similar questions from historical questions submitted by online users as standard questions, these similar questions can be marked as experience questions and stored in the knowledge base in association with standard statements. Then, when obtaining at least one experience question corresponding to each candidate standard question, the marked similar question can be retrieved from the similar questions stored in association with each candidate standard question by accessing the knowledge base, thus obtaining the experience question.
[0057] Understandably, the difference between experiential questions and similar questions in standard questions can be that experiential questions originate from historical questions raised by online users and are semantically consistent with standard questions. Similar questions, on the other hand, can be semantically consistent questions generated based on standard questions or semantically consistent questions configured by the business personnel of the question-and-answer system.
[0058] Step 202: Encode the target user's question, the candidate standard question, and the experience question respectively to obtain the corresponding text encoding.
[0059] In this embodiment, a preset text encoder can be used to encode the target user's question, the candidate standard question, and the experience question respectively to obtain the corresponding text encoding.
[0060] The text encoding corresponding to the target user's question can be called the target user's question text encoding. The text encoding corresponding to the candidate standard question can be called the candidate standard question text encoding. The text encoding corresponding to the experience question can be called the experience question text encoding.
[0061] The preset text encoder can be a Bert text encoder or other types of text encoders, and this embodiment does not limit this.
[0062] Step 203: Based on the attention mechanism, determine the target empirical question text encoding that is related to the target user's question in the empirical questions corresponding to each candidate standard question.
[0063] In this embodiment, for each candidate standard question, the text code of at least one corresponding empirical question can be obtained, and the relevance between the text code of at least one empirical question and the text code of the target user question can be calculated. The calculated relevance can be used as an attention weight, and the text code of the empirical question related to the target user question can be determined based on the attention weight.
[0064] Step 204: The text codes of each target experience question are fused with the corresponding candidate standard question text codes to obtain the text codes of each candidate fused question.
[0065] Among them, the candidate fusion question text encoding is the text encoding obtained by fusing the target experience question text encoding with the corresponding candidate standard question text encoding.
[0066] In this embodiment, both the target empirical question text code and the corresponding candidate standard question text code can be represented in matrix form. Therefore, when fusing each target empirical question text code with its corresponding candidate standard question text code, the fusion weights for each can be predetermined. Then, the target empirical question text code and the corresponding candidate standard question text code are weighted and summed according to their respective fusion weights to complete the fusion process. The result of the weighted summation can be used as the candidate fused question text code.
[0067] It should be noted that the method of fusing the text encoding of each target experience question with the corresponding candidate standard question text encoding can also be other, and this embodiment does not limit this method.
[0068] Step 205: Perform matching and sorting processing on the target user's question text encoding and the candidate fused question text encoding to obtain matching questions that match the target user's question.
[0069] In this embodiment, a preset deep learning model can be used to match and sort the target user's question text encoding with the candidate fused question text encodings to obtain matching questions that match the target user's question. The preset deep learning model can be a deployed deep learning model trained to convergence using standard questions and corresponding similar questions as training samples.
[0070] The preset deep learning model can be a neural network-based deep learning model.
[0071] Specifically, in this embodiment, the target user's question text encoding and the candidate fused question text encodings are input into a preset deep learning model. The preset deep learning model is used to perform semantic matching calculations on the target user's question text encoding and the candidate fused question text encodings respectively to obtain semantic matching results. The candidate standard questions corresponding to the candidate fused question text encodings are sorted according to the semantic matching results. The candidate standard question with the highest matching degree in the semantic matching results is determined as the matching question that matches the target user's question.
[0072] Alternatively, other methods can be used to match and sort the target user's question text encoding with the candidate fused question text encoding to obtain a matching question that matches the target user's question. This embodiment does not limit this method.
[0073] The text semantic matching method provided in this embodiment obtains the target user question to be matched, at least one candidate standard question that matches the target user question field, and at least one empirical question corresponding to each candidate standard question; encodes the target user question, candidate standard question, and empirical question respectively to obtain corresponding text codes; determines the target empirical question text code related to the target user question in the empirical questions corresponding to each candidate standard question based on an attention mechanism; fuses each target empirical question text code with the corresponding candidate standard question text code to obtain each candidate fused question text code; and performs matching and sorting processing on the target user question text code and each candidate fused question text code to obtain the matching question that matches the target user question. Because at least one empirical question corresponding to the candidate standard question is included when matching the target user question, and after encoding the target user question, candidate standard question, and the empirical question, the empirical question text code related to the target user question is extracted from the empirical question corresponding to each candidate standard question, and fused with the text code of the corresponding candidate standard question, the resulting candidate fused question text code is based on the original text code of each candidate standard question with the addition of the empirical question text code related to the target user question. Therefore, semantic matching of the target user question text code with each candidate fused question text code can obtain matching questions with higher semantic matching degree, and there is no need to redeploy the trained deep learning model, thus reducing costs.
[0074] Figure 3 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention, as shown below. Figure 3 As shown, the text semantic matching method provided in this embodiment is a further refinement of step 202 based on the text semantic matching method provided in Embodiment 1. Optionally, step 202 includes the following steps:
[0075] Step 2021: Obtain the preset first text encoder and second text encoder.
[0076] The first preset text encoder is an encoder that encodes the candidate standard questions and the experience questions. The second text encoder is an encoder that encodes the target user questions.
[0077] The preset first text encoder and second text encoder can be Bert text encoders, respectively.
[0078] In this embodiment, the first text encoder and the second text encoder are obtained by training the corresponding initial text encoder with semantically consistent questions.
[0079] Specifically, semantically consistent question pairs can be used as training samples. The first question in the question pair is input into the initial first text encoder, and the second question in the question pair is input into the initial second text encoder. The initial first text encoder and the initial second text encoder are trained respectively. The convergence condition is determined based on the cross-entropy loss function. The first text encoder and the second text encoder that meet the convergence condition are determined as the preset first text encoder and second text encoder.
[0080] In this embodiment, a preset first text encoder and a preset second text encoder can be stored in a preset storage area, and the preset first text encoder and the preset second text encoder can be obtained from the preset storage area.
[0081] Step 2022: Input the candidate standard question and the experience question into the first text encoder, and input the target user question into the second text encoder.
[0082] Step 2023: Encode each candidate standard question using the first text encoder and output the text encoding of each candidate standard question.
[0083] Specifically, in this embodiment, before inputting each candidate standard question into the preset first text encoder, each candidate standard question is concatenated into the string "[CLS]candidate standard question[SEP]", where [CLS] represents the start character of the string and [SEP] represents the end character of the string. Each string is then input into the preset first text encoder, which performs vector encoding on the candidate standard questions in each string and takes the output encoding at the [CLS] position as the text encoding of the corresponding candidate standard question.
[0084] The text encoding of the candidate standard questions can be represented as a vector. Therefore, the text encoding of each candidate standard question can be represented as a matrix E. c E c The dimension is N*h, where N is the number of candidate standard questions and h is the dimension of the text encoding of the candidate standard questions. h can take values such as 768 or 1024.
[0085] Step 2024: Use the first text encoder to encode the empirical questions corresponding to each candidate standard question, and output the text encoding of the empirical questions corresponding to each candidate standard question.
[0086] Specifically, in this embodiment, each candidate standard question can correspond to one or more empirical questions. Before inputting the empirical questions corresponding to each candidate standard question into the preset first text encoder, for each candidate standard question, at least one corresponding empirical question is concatenated into the string "[CLS]empirical question[SEP]", where [CLS] represents the start character of the string and [SEP] represents the end character of the string. Each string is input into the preset first text encoder, which performs vector encoding on the empirical questions in each string and takes the output encoding at the [CLS] position as the text encoding of the corresponding empirical question.
[0087] The text encoding of the empirical questions corresponding to each candidate standard question can be represented as a vector. The dimension of the vector is h. The value of h can be 768 or 1024. However, since the number of empirical questions corresponding to each candidate standard question is variable, concatenating the text encodings of the empirical questions corresponding to each candidate standard question can form L vectors, which can be represented as E. e Where L is an integer greater than 1.
[0088] For example, a candidate standard question corresponds to two empirical texts: "How to swipe a bus card" and "How to swipe a bus card using an app". These are concatenated into the strings "[CLS]How to swipe a bus card[SEP]" and "[CLS]How to swipe a bus card using an app[SEP]", respectively, and input into a preset first text encoder for vector encoding. The output encoding at the [CLS] position is taken as the text encoding of the empirical text. The text encodings of the empirical texts corresponding to each candidate standard question are saved sequentially to E according to the order of the candidate standard questions. e middle.
[0089] It should be noted that steps 2023 and 2024 can be encoded offline. Specifically, the standard question, similar question, and experience question are pre-encoded using a first text encoder to determine the text codes for the standard question, similar question, and experience question, and these codes are stored. Then, candidate standard question text codes and corresponding experience question text codes are obtained based on the target user's question.
[0090] Step 2025: Encode the target user's question using the second text encoder and output the target user's question text encoding.
[0091] Specifically, in this embodiment, the target user question can be concatenated into a string: "[CLS]target user question[SEP]" before being input into the preset text encoder. Here, [CLS] represents the start character of the string, and [SEP] represents the end character. The preset text encoder performs vector encoding on the target user question and can take the output encoding at the [CLS] position as the text encoding of the target user question.
[0092] The text encoding of the target user's question can be represented as a vector or matrix. The text encoding of the target user's question can be represented as E. u If it is a vector, then E u The dimension is h, and the value of h can be 768 or 1024.
[0093] For example, the text of the target user's question "I want to swipe my bus card" is concatenated into the string "[CLS]I want to swipe my bus card[SEP]", input into the Bert text encoder for vector encoding, and the output encoding at the [CLS] position is taken as the text encoding E of the target user's question. u .
[0094] The text semantic matching method provided in this embodiment involves: acquiring a preset first text encoder and a second text encoder; inputting the candidate standard questions and the empirical questions into the first text encoder, and inputting the target user question into the second text encoder; encoding each candidate standard question using the first text encoder and outputting the text encoding of each candidate standard question; encoding the empirical questions corresponding to each candidate standard question using the first text encoder and outputting the text encoding of the empirical questions corresponding to each candidate standard question; and encoding the target user question using the second text encoder and outputting the text encoding of the target user question. Because the target user question, the candidate standard questions, and the empirical questions are encoded using corresponding trained text encoders, accurate text encoding of the target user question, the candidate standard questions, and the empirical questions is achieved.
[0095] Figure 4 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention, as shown below. Figure 4 As shown, the text semantic matching method provided in this embodiment is a further refinement of step 203 based on the text semantic matching method provided in Embodiment 1 or Embodiment 2. Optionally, step 203 includes the following steps:
[0096] Step 2031: Obtain the empirical question text code corresponding to each candidate standard question; the empirical question text code and the target user question text code are represented in matrix form.
[0097] Specifically, in this embodiment, for each candidate standard question q c Extract the corresponding variable-length array containing the text-encoded representations of all experience questions. This variable-length array includes M vectors of dimension h, so it can be transformed into an M*h-dimensional matrix E. e (q c ), where M is the candidate standard question q c The total number of all corresponding empirical questions. The empirical question text encoding corresponding to each candidate standard question can be represented as E. e E e The dimension is L*h, where L is greater than M.
[0098] Step 2032: Calculate the attention weight of the empirical question text encoding corresponding to each candidate standard question relative to the target user question text encoding.
[0099] Specifically, in this embodiment, at least one empirical question text code E corresponding to each candidate standard question is calculated. e (q c Compared to the target user's question text encoding E u Attention weight W ecu .
[0100] As an optional implementation, in this embodiment, step 2032 includes the following steps:
[0101] Step 2032a: Calculate the matrix product of the empirical question text encoding and the target user question text encoding corresponding to each candidate standard question.
[0102] Specifically, calculate the text encoding E of at least one empirical question corresponding to each candidate standard question. e (q c ) and target user question text encoding E u The matrix product is obtained by multiplying matrices. It can be represented as: E e (q c )*E u The matrix multiplication result is an M*1 matrix. This matrix multiplication result can be used to represent the text encoding E of at least one empirical question corresponding to each candidate standard question. e (q c ) and target user question text encoding E u Relevance.
[0103] Step 2032b involves performing exponential function softmax normalization on the matrix product results based on the number of empirical questions in each candidate standard question, in order to obtain attention weights.
[0104] The number of empirical questions associated with each candidate standard question can be represented as M. Then, after normalizing the matrix multiplication result using an exponential function softmax along the M-dimensional axis, the attention weight W is obtained. ecu It can guarantee the attention weight W. ecu Each element in the array is a value between (0, 1).
[0105] In this embodiment, when calculating the attention weight of the empirical question text encoding corresponding to each candidate standard question relative to the target user question text encoding, the matrix product of the empirical question text encoding corresponding to each candidate standard question and the target user question text encoding is calculated. The matrix product is then normalized using an exponential function (softmax) on the dimension of the number of empirical questions in each candidate standard question to obtain the attention weight. Since the matrix product of the empirical question text encoding corresponding to each candidate standard question and the target user question text encoding can serve as a representation of the relevance between them, normalizing the matrix product using an exponential function (softmax) on the dimension of the number of empirical questions in each candidate standard question limits the relevance to a preset range, thus enabling the relevance to be used as the attention weight.
[0106] Step 2033: Calculate the correlation code based on attention weights for the empirical question text encoding corresponding to each candidate standard question.
[0107] Among them, the text encoding of the empirical question corresponding to each candidate standard question, based on the attention weight, can be represented as E. er (q c ).
[0108] As an optional implementation, step 2033 includes the following steps:
[0109] Step 2033a: Multiply the matrix of empirical question text encoding corresponding to each candidate standard question by the matrix of attention weights bitwise to obtain the bitwise product result.
[0110] In this embodiment, the matrix of empirical question text encoding corresponding to each candidate standard question is E. e (q c The attention weight matrix is W. ecu Multiplying two matrices by their positions is equivalent to multiplying E... e (q c The element corresponding to each row in ) and W ecu The elements corresponding to each row are multiplied together to form the corresponding matrix, which is the result of the element-wise product.
[0111] In this embodiment, the matrix of empirical question text encoding corresponding to each candidate standard question is multiplied bitwise with the matrix of attention weights. This is equivalent to weighting the empirical question text encoding corresponding to each candidate standard question with attention weights, highlighting that at least one empirical question text encoding corresponding to each candidate standard question is related to the text encoding of the target user's question.
[0112] Step 2033b involves summing the bitwise product results across the dimension of the number of empirical questions in each candidate standard question, and then transposing the result to obtain the attention-weighted correlation encoding of the empirical question text corresponding to each candidate standard question.
[0113] The dimension of the number of empirical questions that each candidate standard question has is M.
[0114] In this embodiment, the positional product results corresponding to each candidate standard question are summed in the M-dimensional matrix. This involves weighting the empirical question text encoding corresponding to each candidate standard question with attention weights and then summing the results. The summation result is then transposed. The matrix obtained after transposition is determined as the attention-weighted correlation encoding of the empirical question text encoding corresponding to each candidate standard question.
[0115] In this embodiment, when calculating the relevance encoding of the empirical question text encoding corresponding to each candidate standard question based on attention weights, the matrix of the empirical question text encoding corresponding to each candidate standard question is multiplied bitwise with the matrix of attention weights to obtain the bitwise product result. The bitwise product results are then summed along the dimension of the number of empirical questions in each candidate standard question, and transposed to obtain the relevance encoding of the empirical question text encoding corresponding to each candidate standard question based on attention weights. Calculating the relevance encoding in this way is equivalent to performing a weighted summation of the empirical question text encoding corresponding to each candidate standard question with the target user's question text encoding, thus effectively highlighting the text encodings that are related to the empirical question text encoding corresponding to each candidate standard question and the target user's question text encoding.
[0116] Step 2034: Determine each relevant code as the target empirical question text code that is related to the target user's question in the empirical questions corresponding to each candidate standard question.
[0117] In this embodiment, since the relevant encoding of the empirical question text corresponding to each candidate standard question is based on attention weight, it is able to highlight the text encoding of at least one empirical question text encoding corresponding to each candidate standard question that is related to the target user question text encoding. Therefore, each relevant encoding is determined as the target empirical question text encoding related to the target user question in each candidate standard question.
[0118] Then, the text encoding of the target experience questions related to the target user's questions in each candidate standard question can be represented as E. er .
[0119] The text semantic matching method provided in this embodiment, when determining the target empirical question text codes related to the target user's question in each candidate standard question based on an attention mechanism, obtains the empirical question text codes corresponding to each candidate standard question; the empirical question text codes and the target user's question text codes are represented in matrix form; the attention weight of the empirical question text codes corresponding to each candidate standard question relative to the target user's question text codes is calculated; the correlation codes of the empirical question text codes corresponding to each candidate standard question based on the attention weights are calculated; and each correlation code is determined as the target empirical question text code related to the target user's question in each candidate standard question. By calculating the attention weight of the empirical question text code corresponding to each candidate standard question relative to the target user question text code, the correlation between the empirical question text code corresponding to each candidate standard question and the target user question text code can be effectively extracted. By calculating the correlation code based on the attention weight of the empirical question text code corresponding to each candidate standard question, and determining each correlation code as the target empirical question text code related to the target user question in the empirical question corresponding to each candidate standard question, the text code related to the target user question text code in at least one empirical question text code corresponding to each candidate standard question can be effectively highlighted.
[0120] Figure 5 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention, as shown below. Figure 5 As shown, the text semantic matching method provided in this embodiment is a further refinement of step 204 based on the text semantic matching method provided in any of the above embodiments. Optionally, step 204 includes the following steps:
[0121] Step 2041: Determine the fusion weights.
[0122] The fusion weight can be represented by A. The fusion weight is a value less than 1.
[0123] In this embodiment, the fusion weight can be determined based on semantic matching results and experience.
[0124] Step 2042: Calculate the product of the text encoding of each target empirical question and the fusion weight, and sum each product with the corresponding candidate standard question text encoding to obtain the text encoding of each candidate fusion question.
[0125] In this embodiment, from E c Extract candidate standard question text encoding E from c (q c ), is an h-dimensional vector. From Eer Extract the corresponding target experience question text encoding E from the text. er (q c Let E be an h-dimensional vector. c (q c ) and E er (q c The text encoding of each candidate fused question can be represented as E. cn (q c ) = E c (q c )+A*E er (q c Let E be an h-dimensional vector. Then the text encoding of the candidate fused question corresponding to the N candidate standard questions can be represented as E. cn .
[0126] The text semantic matching method provided in this embodiment determines the fusion weight when fusing the text codes of each target empirical question with the corresponding candidate standard question text codes to obtain candidate fused question text codes; calculates the product of each target empirical question text code and the fusion weight, and sums each product with the corresponding candidate standard question text codes to obtain each candidate fused question text code. By using the weighted summation of the candidate standard question text codes and the target empirical question text codes, the method can effectively fuse the candidate standard question text codes and the target empirical question text codes.
[0127] Figure 6 This is a flowchart illustrating a text semantic matching method provided in another embodiment of the present invention, as shown below. Figure 6 As shown, the text semantic matching method provided in this embodiment further refines step 205 based on the text semantic matching method provided in any of the above embodiments. Optionally, step 205 of the text semantic matching method provided in this embodiment includes the following steps:
[0128] Step 2051: Calculate the semantic matching degree between the target user's question text encoding and each candidate fused question text encoding.
[0129] In this embodiment, for N candidate standard questions q c From E cn Extract the new code to represent E cn (q c Let E be an h-dimensional vector. Calculate the target user's question text encoding E. u With candidate standard question q c The corresponding candidate fusion question text encoding E cn (q c The semantic matching degree of ).
[0130] As an optional implementation, step 2051 includes the following steps:
[0131] Step 2051a: Calculate the inner product of the target user's question text encoding and the text encoding of each candidate fused question.
[0132] Step 2051b: Determine each inner product as its semantic matching degree.
[0133] Specifically, in this embodiment, the target user's question text encoding E is calculated. u With candidate standard question q c The corresponding candidate fusion question text encoding E cn (q c The inner product of E is the product of E's inner product. u With E cn (q c The bits are multiplied and summed to calculate a final value, which is then used as the semantic matching degree.
[0134] In this embodiment, when calculating the semantic matching degree between the target user's question text encoding and each candidate fused question text encoding, the inner product of the target user's question text encoding and each candidate fused question text encoding is calculated, and each inner product is determined as the semantic matching degree. Since the more semantically matched the target user's question text encoding and each candidate fused question text encoding are, the more similar the corresponding text encodings are, and the larger the value obtained after processing the inner product of the corresponding vectors is. Conversely, the less semantically matched the target user's question text encoding and each candidate fused question text encoding are, the less similar the corresponding text encodings are, and the smaller the value obtained after processing the inner product of the corresponding vectors is. Therefore, calculating the inner product of the target user's question text encoding and each candidate fused question text encoding can more accurately determine the semantic matching degree.
[0135] Step 2052: Normalize each semantic matching degree using the exponential function softmax to obtain the semantic matching degree probability distribution of each candidate fused question text encoding.
[0136] In this embodiment, each semantic matching degree is input into the softmax normalization layer. The exponential function in the softmax normalization layer is used to normalize each semantic matching degree, thereby obtaining the corresponding semantic matching degree probability distribution, which can make the corresponding semantic matching degree probability distribution between (0,1).
[0137] Step 2053: Sort the candidate standard questions corresponding to the text encoding of each candidate fusion question according to the probability distribution of semantic matching degree from large to small, and determine the candidate standard question at the top of the list as the matching question that matches the target user's question.
[0138] Specifically, in this embodiment, each candidate fused question text code corresponds to a semantic matching probability distribution, and each candidate fused question text code corresponds to a candidate standard question. The candidate standard questions corresponding to each candidate fused question text code are then sorted according to the semantic matching probability distribution from largest to smallest to obtain a sorting result. In the sorting result, the candidate standard question at the top of the list corresponds to the candidate fused question text code with the largest semantic matching probability distribution with the target user's question, therefore it is the most semantically matched with the target user's question. Thus, the candidate standard question at the top of the list is determined as the matching question that matches the target user's question.
[0139] The text semantic matching method provided in this embodiment calculates the semantic matching degree between the target user question text encoding and each candidate fused question text encoding when performing matching and sorting processing to obtain a matching question that matches the target user question. It then normalizes each semantic matching degree using an exponential function (softmax) to obtain the probability distribution of the semantic matching degree of each candidate fused question text encoding. Finally, it sorts the candidate standard questions corresponding to each candidate fused question text encoding according to the descending order of the semantic matching degree probability distribution, and determines the candidate standard question at the top of the sorted list as the matching question that matches the target user question. This method can accurately determine the matching question that matches the target user question based on the semantic matching degree between the target user question text encoding and each candidate fused question text encoding, ensuring that the matching question that matches the target user question has the highest semantic matching degree.
[0140] As an optional implementation, in this embodiment, step 2053, determining the candidate standard question ranked first as the matching question that matches the target user's question, includes:
[0141] If the semantic matching probability distribution of the candidate standard question ranked first is greater than the preset probability distribution threshold, then the candidate standard question ranked first is determined as the matching question that matches the target user's question.
[0142] The preset probability distribution threshold is a pre-set threshold for determining whether a target user's question has a matching question. Its value can be 0.8, 0.9, or other values less than 1; this embodiment does not impose any limitations on this.
[0143] Specifically, in this embodiment, the semantic matching probability distribution corresponding to the top-ranked candidate standard question is compared with a preset probability distribution threshold. If the semantic matching probability distribution corresponding to the top-ranked candidate standard question is greater than the preset probability distribution threshold, it indicates that the candidate fused question text encoding of the top-ranked candidate standard question has a high semantic matching probability distribution with the target user question text encoding. In this case, the top-ranked candidate standard question is determined as a matching question that matches the target user question. Conversely, if the semantic matching probability distribution corresponding to the top-ranked candidate standard question is less than or equal to the preset probability distribution threshold, it indicates that the candidate fused question text encoding of the top-ranked candidate standard question does not have a high semantic matching probability distribution with the target user question text encoding. In this case, it is determined that the target user question does not have a matching question.
[0144] The text semantic matching method provided in this embodiment, when determining that the top-ranked candidate standard question is a matching question that matches the target user's question, further determines that the top-ranked candidate standard question is a matching question that matches the target user's question if the probability distribution of the semantic matching degree corresponding to the top-ranked candidate standard question is greater than a preset probability distribution threshold. This ensures that the matching question that matches the target user's question is a question with a high probability distribution of semantic matching degree, thereby ensuring that the output standard answer is an answer that matches the user's question more closely.
[0145] Optionally, in this embodiment, after step 205, the following technical solution is also included:
[0146] Retrieve the standard answer corresponding to the matching question; send the standard answer to the user terminal.
[0147] Specifically, in this embodiment, the standard answer corresponding to the top-ranked candidate standard question is obtained from the knowledge base, and the standard answer is sent to the user terminal so that the user terminal can display the standard answer through the operation interface of the client or webpage, and the user can obtain the standard answer.
[0148] Figure 7 This is a schematic diagram of the structure of a text semantic matching device provided in an embodiment of the present invention, as shown below. Figure 7 As shown, the text semantic matching device 30 provided in this embodiment is located in an electronic device. The text semantic matching device 30 includes: an acquisition module 31, an encoding module 32, a determination module 33, a fusion module 34, and a matching sorting module 35.
[0149] The system comprises the following modules: Acquisition module 31, which acquires the target user question to be matched, at least one candidate standard question matching the target user question field, and at least one experience question corresponding to each candidate standard question. Encoding module 32, which encodes the target user question, the candidate standard question, and the experience question respectively to obtain corresponding text codes. Determination module 33, which determines the text codes of target experience questions related to the target user question in the experience questions corresponding to each candidate standard question based on an attention mechanism. Fusion module 34, which fuses the text codes of each target experience question with the corresponding candidate standard question text codes to obtain candidate fused question text codes. Matching and sorting module 35, which matches and sorts the target user question text codes with the candidate fused question text codes to obtain matching questions that match the target user question.
[0150] The text semantic matching device provided in this embodiment can execute the technical solution of the text semantic matching method provided in Embodiment 1. Its implementation principle and technical effect are similar to those of the method embodiment shown in Embodiment 1, and will not be described in detail here.
[0151] Optionally, the encoding module 32 is specifically used for:
[0152] Obtain a preset first text encoder and a second text encoder; the first text encoder and the second text encoder are obtained by training the corresponding initial text encoders with semantically consistent questions; input the candidate standard questions and the empirical questions into the first text encoder, and input the target user question into the second text encoder; encode each candidate standard question using the first text encoder, and output the text encoding of each candidate standard question; encode the empirical questions corresponding to each candidate standard question using the first text encoder, and output the text encoding of the empirical questions corresponding to each candidate standard question; encode the target user question using the second text encoder, and output the text encoding of the target user question.
[0153] Optionally, module 33 is defined, specifically for:
[0154] Obtain the empirical question text codes corresponding to each candidate standard question; represent the empirical question text codes and the target user question text codes in matrix form; calculate the attention weight of the empirical question text codes corresponding to each candidate standard question relative to the target user question text codes; calculate the correlation codes of the empirical question text codes corresponding to each candidate standard question based on the attention weights; determine each correlation code as the target empirical question text code related to the target user question in the empirical questions corresponding to each candidate standard question.
[0155] Optionally, the determining module 33, when calculating the attention weight of the empirical question text encoding corresponding to each candidate standard question relative to the target user question text encoding, is specifically used for:
[0156] Calculate the matrix product of the empirical question text encoding and the target user question text encoding corresponding to each candidate standard question; perform exponential function softmax normalization on the matrix product result in terms of the number of empirical questions in each candidate standard question to obtain attention weights.
[0157] Optionally, the determining module 33, when calculating the attention-weighted relevance encoding of the empirical question text encoding corresponding to each candidate standard question, is specifically used for:
[0158] The matrix of the empirical question text encoding corresponding to each candidate standard question is multiplied bitwise with the matrix of attention weights to obtain the bitwise multiplication result; the bitwise multiplication result is summed in the dimension of the number of empirical questions in each candidate standard question and then transposed to obtain the relevant encoding of the empirical question text encoding corresponding to each candidate standard question based on attention weights.
[0159] Optionally, the fusion module 34 is specifically used for:
[0160] Determine the fusion weights; calculate the product of the text encoding of each target empirical question and the fusion weight, and sum each product with the corresponding candidate standard question text encoding to obtain the text encoding of each candidate fusion question.
[0161] Optionally, the matching and sorting module 35 is specifically used for:
[0162] Calculate the semantic matching degree between the target user's question text encoding and each candidate fused question text encoding; normalize each semantic matching degree using the exponential function softmax to obtain the semantic matching degree probability distribution of each candidate fused question text encoding; sort the candidate standard questions corresponding to each candidate fused question text encoding according to the semantic matching degree probability distribution from largest to smallest, and determine the candidate standard question at the top of the sort as the matching question that matches the target user's question.
[0163] Optionally, the matching and sorting module 35, when calculating the semantic matching degree between the target user's question text encoding and each candidate fused question text encoding, is specifically used for:
[0164] Calculate the inner product between the target user's question text encoding and the text encoding of each candidate fused question; determine each inner product as the semantic matching degree.
[0165] Optionally, the matching and sorting module 35, when the candidate standard question ranked first is determined to be a matching question that matches the target user's question, is specifically used for:
[0166] If the semantic matching probability distribution of the candidate standard question ranked first is greater than the preset probability distribution threshold, then the candidate standard question ranked first is determined as the matching question that matches the target user's question.
[0167] Optionally, the text semantic matching device provided in this embodiment further includes a sending module.
[0168] The acquisition module 31 is also used to acquire the standard answer corresponding to the matching question. The sending module is used to send the standard answer to the user terminal.
[0169] The text semantic matching device provided in this embodiment can execute the technical solution of the text semantic matching method provided in any of the above embodiments. Its implementation principle and technical effect are similar to those of the method embodiment shown in Embodiment 1, and will not be described in detail here.
[0170] Figure 8 This is a schematic diagram of the structure of an electronic device used to implement the text semantic matching method of this invention, such as... Figure 8 As shown, the electronic device 40 provided in this embodiment includes a processor 42 and a memory 41 that is communicatively connected to the processor 42.
[0171] The memory 41 stores computer-executable instructions. The processor 42 executes the computer-executable instructions stored in the memory to implement the text semantic matching method provided in any embodiment of the present invention.
[0172] The memory 41 and the processor 42 are connected via a bus 43.
[0173] The relevant explanations can be understood by referring to the relevant descriptions and effects of the steps of the text semantic matching method provided in any embodiment, and will not be elaborated further here.
[0174] This invention also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the text semantic matching method provided in any embodiment.
[0175] This invention also provides a computer program product, including a computer program that is executed by a processor using the text semantic matching method provided in any of the above embodiments.
[0176] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0177] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0178] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0179] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.
[0180] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, an AI processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, storage units can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.
[0181] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0182] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
Claims
1. A text semantic matching method, characterized in that, include: Obtain the target user question to be matched, at least one candidate standard question that matches the target user question field, and at least one empirical question corresponding to each candidate standard question; the empirical question is a similar question to the corresponding candidate standard question. The target user's question, the candidate standard question, and the experience question are encoded respectively to obtain the corresponding text codes; Obtain the empirical question text encoding corresponding to each candidate standard question; the empirical question text encoding and the target user question text encoding are represented in matrix form; Calculate the attention weight of the empirical question text encoding corresponding to each candidate standard question relative to the target user question text encoding; The matrix of empirical question text encoding corresponding to each candidate standard question is multiplied bitwise with the matrix of attention weights to obtain the bitwise product result; The bitwise product results are summed in matrix form along the dimension of the number of empirical questions in each candidate standard question, and then transposed to obtain the relevant encoding of the empirical question text encoding corresponding to each candidate standard question based on attention weights. Each of the relevant codes is determined as the target empirical question text code that is related to the target user question in the empirical question corresponding to each candidate standard question; The target experience question text codes are fused with the corresponding candidate standard question text codes to obtain the candidate fused question text codes; The target user's question text encoding is matched and sorted with the candidate fused question text encodings to obtain a matching question that matches the target user's question.
2. The method according to claim 1, characterized in that, The process of encoding the target user question, the candidate standard question, and the experience question to obtain the corresponding text encoding includes: Obtain a preset first text encoder and a second text encoder; the first text encoder and the second text encoder are obtained by training the corresponding initial text encoders with semantically consistent questions; The candidate standard questions and the empirical questions are input into the first text encoder, and the target user questions are input into the second text encoder; The first text encoder is used to encode each candidate standard question, and the text encoding of each candidate standard question is output. The first text encoder is used to encode the empirical questions corresponding to each candidate standard question, and the text encoding of the empirical questions corresponding to each candidate standard question is output. The second text encoder is used to encode the target user's question and output the target user's question text encoding.
3. The method according to claim 1, characterized in that, The calculation of the attention weights for the empirical question text encodings corresponding to each candidate standard question relative to the target user question text encodings includes: Calculate the matrix product of the empirical question text encoding corresponding to each candidate standard question and the target user question text encoding; The matrix product result is normalized by an exponential function softmax on the dimension of the number of empirical questions in each candidate standard question to obtain the attention weight.
4. The method according to any one of claims 1-3, characterized in that, The step of fusing the text codes of each target experience question with the corresponding candidate standard question text codes to obtain candidate fused question text codes includes: Determine the fusion weights; Calculate the product of each target empirical question text code and the fusion weight, and sum each product with the corresponding candidate standard question text code to obtain each candidate fusion question text code.
5. The method according to any one of claims 1-3, characterized in that, The target user's question text encoding is matched and sorted with the candidate fused question text encodings to obtain matching questions that match the target user's question, including: Calculate the semantic matching degree between the target user's question text encoding and each candidate fused question text encoding; The semantic matching degrees are normalized using the exponential function softmax to obtain the semantic matching degree probability distribution of each candidate fused question text encoding. The candidate standard questions corresponding to the text encoding of each candidate fusion question are sorted in descending order of the semantic matching probability distribution, and the candidate standard question ranked first is determined as the matching question that matches the target user's question.
6. The method according to claim 5, characterized in that, The calculation of the semantic matching degree between the target user's question text encoding and each candidate fused question text encoding includes: Calculate the inner product between the target user's question text encoding and the text encodings of each candidate fused question; Each inner product is determined as a semantic matching degree.
7. The method according to claim 5, characterized in that, The candidate standard questions ranked first are determined as matching questions that match the target user's question, including: If the semantic matching probability distribution of the candidate standard question ranked first is greater than the preset probability distribution threshold, then the candidate standard question ranked first is determined as the matching question that matches the target user's question.
8. The method according to any one of claims 1-3, characterized in that, After performing matching and sorting processing on the target user's question text encoding and the candidate fused question text encodings to obtain matching questions that match the target user's question, the process further includes: Obtain the standard answer corresponding to the matched question; The standard answer is sent to the user's terminal.
9. A text semantic matching device, characterized in that, include: The acquisition module is used to acquire the target user's question to be matched, at least one candidate standard question that matches the target user's question field, and at least one empirical question corresponding to each candidate standard question; the empirical question is a similar question to the corresponding candidate standard question. The encoding module is used to encode the target user's question, the candidate standard question, and the experience question respectively to obtain the corresponding text encoding; The determination module is used to determine the target empirical question text encoding related to the target user question in the empirical questions corresponding to each of the candidate standard questions based on an attention mechanism; The fusion module is used to fuse the text codes of each target experience question with the corresponding candidate standard question text codes to obtain the text codes of each candidate fused question. The matching and sorting module is used to perform matching and sorting processing on the target user's question text encoding and the candidate fused question text encoding to obtain a matching question that matches the target user's question. The determining module is specifically used to obtain the empirical question text code corresponding to each candidate standard question; the empirical question text code and the target user question text code are represented in matrix form; calculate the attention weight of the empirical question text code corresponding to each candidate standard question relative to the target user question text code; multiply the matrix of the empirical question text code corresponding to each candidate standard question with the matrix of the attention weight by position to obtain the positional product result; sum the positional product results in the dimension of the number of empirical questions in each candidate standard question, and transpose them to obtain the relevant code of the empirical question text code corresponding to each candidate standard question based on the attention weight; Each of the relevant codes is determined as the target empirical question text code that is related to the target user question in the empirical question corresponding to each candidate standard question.
10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-8.
12. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, is used to implement the method as described in any one of claims 1-8.
Citation Information
Patent Citations
Semantic extraction method and device, computer equipment and storage medium
CN112364665A
Knowledge graph question and answer question entity linking method and device
CN114020931A
Intention recognition method and device, computer equipment and storage medium
CN114490996A