Answer selection method and apparatus, device, and storage medium
By encoding candidate answers and weighting them based on similarity, an updated semantic vector is generated, which solves the problem of low answer selection accuracy in existing question-answering systems and achieves higher answer selection accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-02-17
- Publication Date
- 2026-05-05
AI Technical Summary
Existing text-based question-answering systems rely solely on the grammatical or semantic matching between candidate answers and questions during the answer selection phase, resulting in low accuracy of the best answer.
By encoding multiple candidate answers, an initial semantic vector is generated. Then, based on the similarity between the candidate answers and other candidate answers, an intermediate semantic vector is generated. Finally, the initial semantic vector and the intermediate semantic vector are concatenated to form an updated semantic vector to determine the target answer.
It improves the accuracy of answer selection, ensures a high degree of certainty for the target answer, and enhances the accuracy of answer selection by combining supporting evidence from other candidate answers.
Smart Images

Figure CN114510561B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Natural Language Processing (NLP), and in particular to an answer selection method, apparatus, device, and storage medium. Background Technology
[0002] In recent years, text-based question answering (QA) systems have been widely used in various fields of life (such as the medical field). For questions submitted by users in text form, these systems can return concise and accurate matching answers by retrieving corpora, knowledge graphs, or question-answering knowledge bases.
[0003] In related technologies, the process of determining a matching answer in a text-based question-answering system generally includes three stages: retrieval, extraction, and answer selection. In the retrieval stage, the question-answering system retrieves multiple documents containing answers. In the extraction stage, the system identifies multiple candidate answers from the retrieved documents. Then, in the answer selection stage, the system determines the correctness of each candidate answer based on its grammatical or semantic match with the question, and selects the candidate answer with the highest correctness as the best answer.
[0004] However, the correctness of a candidate answer cannot be accurately determined solely by its degree of matching with the question, and the accuracy of the best answer determined by the above answer selection method is relatively low. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for answer selection, which can effectively improve the accuracy of the best answer determined by the answer selection method. The technical solution is as follows:
[0006] On the one hand, a method for selecting answers is provided, the method including:
[0007] Encode each candidate answer from multiple candidate answers to the target question to obtain an initial semantic vector for each candidate answer;
[0008] For each of the plurality of candidate answers, the initial semantic vectors of the other candidate answers are weighted based on the similarity between the candidate answer and the other candidate answers to obtain the intermediate semantic vector of the candidate answer;
[0009] For each of the plurality of candidate answers, the initial semantic vector of the candidate answer is concatenated with the intermediate semantic vector to obtain the updated semantic vector of the candidate answer;
[0010] The target answer is determined from the multiple candidate answers by updating the semantic vectors of the multiple candidate answers.
[0011] On the other hand, a training method for an answer selection model is provided, the method comprising:
[0012] Obtain multiple answer samples for a question sample, and a label for each answer sample, the label being used to indicate whether the answer sample is the correct answer to the question sample;
[0013] Encode each of the multiple answer samples to obtain an initial semantic vector for each answer sample;
[0014] For each of the multiple answer samples, the initial semantic vectors of the other answer samples are weighted based on the similarity between the answer sample and the other answer samples to obtain the intermediate semantic vector of the answer sample;
[0015] For each of the multiple answer samples, the initial semantic vector and the intermediate semantic vector of the answer sample are concatenated to obtain the updated semantic vector of the answer sample;
[0016] The answer selection model is trained based on the updated semantic vectors of the multiple answer samples and the labels of the multiple answer samples.
[0017] In another aspect, an answer selection device is provided, the device comprising:
[0018] The encoding module is used to encode each candidate answer among multiple candidate answers to the target question, and obtain an initial semantic vector for each candidate answer;
[0019] The weighting module is used to weight the initial semantic vectors of the other candidate answers based on the similarity between the candidate answer and the other candidate answers for each candidate answer among the plurality of candidate answers, so as to obtain the intermediate semantic vector of the candidate answer;
[0020] The concatenation module is used to concatenate the initial semantic vector of each candidate answer with the intermediate semantic vector to obtain the updated semantic vector of the candidate answer for each of the plurality of candidate answers;
[0021] The determination module is used to determine the target answer from the multiple candidate answers based on the updated semantic vector of the multiple candidate answers.
[0022] Furthermore, a training device for an answer selection model is provided, the device comprising:
[0023] An acquisition module is used to acquire multiple answer samples of a question sample, and a label for each answer sample, wherein the label is used to indicate whether the answer sample is the correct answer to the question sample;
[0024] The encoding module is used to encode each of the multiple answer samples to obtain an initial semantic vector for each answer sample;
[0025] The weighting module is used to weight the initial semantic vectors of the other answer samples based on the similarity between the answer sample and the other answer samples for each of the plurality of answer samples, so as to obtain the intermediate semantic vector of the answer sample.
[0026] The concatenation module is used to concatenate the initial semantic vector and the intermediate semantic vector of the answer sample for each of the multiple candidate answers to obtain the updated semantic vector of the answer sample.
[0027] The training module is used to train the answer selection model based on the updated semantic vectors of the multiple answer samples and the labels of the multiple answer samples.
[0028] In another aspect, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the answer selection method as provided above, or the training method for the answer selection model as provided above.
[0029] In another aspect, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the answer selection method provided above, or the training method for the answer selection model provided above.
[0030] In another aspect, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the answer selection method provided in the preceding aspects, or the training method for the answer selection model provided in the preceding aspects.
[0031] The beneficial effects of the technical solution provided in this application include at least the following:
[0032] This application provides a method, apparatus, device, and storage medium for answer selection. For each candidate answer, the solution provided in this application can obtain an intermediate semantic vector of the candidate answer based on its similarity to other candidate answers, and then concatenate this intermediate semantic vector with the initial semantic vector to obtain an updated semantic vector of the candidate answer. Since the updated semantic vector not only contains information about the candidate answer itself, but also contains supporting evidence information from other candidate answers, it can ensure that the target answer determined from multiple candidate answers based on the updated semantic vectors of multiple candidate answers has high accuracy. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 This is a schematic diagram of the structure of a question-and-answer system provided in an embodiment of this application;
[0035] Figure 2 This is a flowchart of an answer selection method provided in an embodiment of this application;
[0036] Figure 3 This is a flowchart of another answer selection method provided in the embodiments of this application;
[0037] Figure 4 This is a structural block diagram of a server provided in an embodiment of this application;
[0038] Figure 5 This is a schematic diagram of the structure of a BERT model provided in an embodiment of this application;
[0039] Figure 6 This is a flowchart of yet another answer selection method provided in the embodiments of this application;
[0040] Figure 7 This is a flowchart illustrating a training method for an answer selection model provided in an embodiment of this application;
[0041] Figure 8 This is a structural block diagram of an answer selection device provided in an embodiment of this application;
[0042] Figure 9 This is a structural block diagram of another answer selection device provided in an embodiment of this application;
[0043] Figure 10This is a structural block diagram of a training device for an answer selection model provided in an embodiment of this application;
[0044] Figure 11 This is a structural block diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0046] The solutions provided in this application can be applied to various scenarios such as cloud technology, artificial intelligence, or smart transportation. First, a brief introduction to the terms used in the embodiments of this application will be given.
[0047] Artificial Intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0048] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0049] With the research and advancement of artificial intelligence (AI) technology, AI is being studied and applied in various fields, such as smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, drones, robots, smart healthcare, and smart customer service. It is believed that with the development of technology, AI will be applied in more fields and play an increasingly important role.
[0050] Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instruction-based learning.
[0051] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close relationship with linguistic research. NLP technologies typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0052] Question answering systems: For a user's question in free text format, a question answering system returns a concise and accurate matching answer by searching a corpus, knowledge graph, or question-and-answer knowledge base. Question answering systems can be divided into: structured data-based question answering systems, such as knowledge graph-based question answering (KBQA); text-based question answering (DocQA) systems, such as machine reading comprehension (MRC); and question-and-answer pair-based question answering systems, such as frequently asked questions (FAQ) systems.
[0053] Machine reading comprehension is a technology that uses algorithms to enable computers to understand the semantics of articles and answer related questions. Common question types include fill-in-the-blank, multiple-choice, and open-ended questions. In DocQA, a fragment extraction-based reading comprehension technique is often used to extract consecutive fragments from relevant documents as candidate answers. Machine reading comprehension can be divided into single-document MRC and multi-document MRC. Single-document MRC extracts consecutive fragments from a single recall document as answers to a single question. Multi-document MRC extracts consecutive fragments from multiple recall documents as answers to a single question. Unlike single-document MRC, multi-document MRC utilizes answer information extracted from different documents for the same question.
[0054] Answer selection: Determine whether the candidate answers obtained from the retrieval and extraction steps (there are usually multiple such answers) are the true answers to the corresponding questions, and select one of these true answers as the best answer.
[0055] For answer selection, relevant technologies generally determine the correctness of each candidate answer based on the degree of grammatical or semantic matching between the question and the candidate answers, and then select the best answer based on the correctness of each candidate answer. However, in many question-and-answer scenarios, the degree of grammatical or semantic matching between a question and its best answer is not high. For example, for the question "Why is staying up late very harmful to the body?", the keywords in the correct answer (or best answer) could include "acne," "large pores," and "panda eyes," etc., which do not match the question semantically and grammatically. Furthermore, the same question can have multiple synonyms, but the keywords included in the corresponding candidate answers are generally fixed. For example, for a question about a certain disease, the disease usually has multiple alternative names, but the candidate answers for that disease (such as symptoms, causes, and treatments) are basically fixed. This also leads to a low degree of semantic and grammatical matching between the candidate answers and the question.
[0056] Based on the above analysis, it can be seen that there is generally a causal relationship between a question and its corresponding correct answer. Therefore, relying solely on the semantic relationship between the question and the candidate answer cannot accurately determine the correctness of the candidate answer.
[0057] Figure 1 This is a schematic diagram of the structure of a question-and-answer system provided in an embodiment of this application. See also... Figure 1 The system includes a server 110 and a terminal device 120. A wired or wireless communication connection is established between the server 110 and the terminal device 120. Optionally, the server 110 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device 120 can be a personal computer (PC), in-vehicle terminal, tablet computer, smartphone, wearable device, intelligent robot, or other terminal with data computing, processing, and storage capabilities.
[0058] As a first possible example, terminal device 120 in the question-answering system can be used to obtain a target question and send it to server 110. Server 110 can then retrieve and extract candidate answers for the target question from a relevant database based on the target question. Afterwards, server 110 can select the target answer (i.e., the best answer) from the multiple candidate answers and send the best answer back to terminal device 120.
[0059] For example, this question-answering system could be a medical knowledge question-answering system within the medical field. Accordingly, the target question is a text querying a specific medical question. The system can then select the best answer to the target question from a medical database (containing various medical journals or papers).
[0060] As a second possible example, the question-answering system may consist only of terminal device 120. After obtaining the target question, terminal device 120 can directly retrieve and extract multiple candidate answers to the target question from the relevant database. After selecting the target answer from these multiple candidate answers, terminal device 120 directly outputs the target answer.
[0061] Alternatively, in the two examples above, the question-answering system can use an answer selection model to determine the best answer from multiple candidate answers. The training process of this answer selection model is briefly described below.
[0062] In the first possible example described above, server 110 pre-stores an initial model. Server 110 can acquire multiple training data sets, each including a question sample, multiple corresponding answer samples, and a label for each answer sample. Server 110 can process the multiple answer samples in each training data set and use the processed answer samples and their labels to train the initial model, thereby obtaining an answer selection model capable of performing the answer selection task. The multiple training data sets can be pre-stored in server 110 or sent to server 110 by terminal device 120.
[0063] In the second possible example described above, server 110 can train an answer selection model using training data and send the trained answer selection model to terminal device 120. Terminal device 120 can then use the answer selection model to determine the best answer to the target question from multiple candidate answers.
[0064] Based on the above description of terms and application scenarios, the answer selection method provided in this application embodiment will be explained. This method can be applied to computer devices, which can be... Figure 1The scenario shown is either server 110 or terminal device 120. The following explanation uses the example of an answer selection method applied to a server. Figure 2 As shown, the method includes the following steps.
[0065] Step 101: Encode each candidate answer among the multiple candidate answers to the target question to obtain the initial semantic vector of each candidate answer.
[0066] In this embodiment, after obtaining the target question, the server can search the database based on the target question to obtain multiple documents containing text that can answer the target question. Then, the server can extract a fragment from each document that can answer the target question as a candidate answer, thereby obtaining multiple candidate answers to the target question.
[0067] After obtaining multiple candidate answers to the target question, the server can encode each candidate answer sequentially. Encoding converts the text-based candidate answers into vector form, thus obtaining an initial semantic vector for each candidate answer. Optionally, the server can use a Bidirectional Encoder Representations from Transformers (BERT) model as the encoder, inputting the multiple candidate answers into this encoder to obtain the initial semantic vector for each candidate answer.
[0068] Step 102: For each candidate answer among multiple candidate answers, based on the similarity between the candidate answer and other candidate answers, the initial semantic vectors of the other candidate answers are weighted to obtain the intermediate semantic vector of the candidate answer.
[0069] In this embodiment, for every two candidate answers, the server can determine the similarity between the two candidate answers based on the dot product of their initial semantic vectors. Furthermore, for each candidate answer, the server can use the similarity between the candidate answer and all other candidate answers as weights to weight the initial semantic vectors of the other candidate answers, thereby obtaining the intermediate semantic vector of the candidate answer.
[0070] Optionally, the server can employ an attention mechanism to weight the initial semantic vectors of other candidate answers based on their similarity to each other, in order to obtain the updated semantic vector of the candidate answer.
[0071] Understandably, for each pair of candidate answers, the server can also use methods such as cosine similarity, Gaussian distance, or similarity matrix to determine the similarity between the two candidate answers.
[0072] It's also understandable that for the same target question, the correct answers retrieved by the server from different documents are similar (i.e., different correct answers contain a lot of similar content), while the incorrect answers are all different. Therefore, the higher the similarity between a candidate answer and other candidate answers, the higher the probability that the candidate answer is the correct answer; conversely, the lower the similarity between a candidate answer and other candidate answers, the lower the probability that the candidate answer is the correct answer.
[0073] Based on this, the server can use the similarity between a candidate answer and other candidate answers to weight the initial semantic vectors of the other candidate answers, obtaining an intermediate semantic vector. This intermediate semantic vector can serve as supporting evidence for the candidate answers.
[0074] Step 103: For each candidate answer among multiple candidate answers, concatenate the initial semantic vector of the candidate answer with the intermediate semantic vector to obtain the updated semantic vector of the candidate answer.
[0075] For each candidate answer among multiple candidate answers, the server can concatenate the initial semantic vector and the intermediate semantic vector of that candidate answer to obtain the updated semantic vector of that candidate answer. It is understandable that the updated semantic vector of each candidate answer obtained after concatenation includes not only the information of the candidate answer itself, but also supporting evidence from other candidate answers.
[0076] Step 104: Based on the updated semantic vectors of multiple candidate answers, determine the target answer from the multiple candidate answers.
[0077] After the server determines the updated semantic vectors of multiple candidate answers, it can predict the probability that each candidate answer can correctly answer the target question based on these updated semantic vectors, and take the candidate answer with the highest probability as the target answer (i.e., the best answer) for the target question.
[0078] Alternatively, the server can use a classifier (also known as a decoder) to predict the probability that each candidate answer correctly answers the target question.
[0079] In this embodiment, the updated semantic vector of each candidate answer among multiple candidate answers includes not only the information of the candidate answer itself, but also supporting evidence information from other candidate answers. Since the supporting evidence information in the updated semantic vector can help the classifier more accurately determine the correctness of each candidate answer, the accuracy of the target answer determined by the server from multiple candidate answers is higher.
[0080] In summary, this application provides an answer selection method. For each candidate answer, the method obtains an intermediate semantic vector based on the similarity between the candidate answer and other candidate answers, and concatenates this intermediate semantic vector with the initial semantic vector to obtain an updated semantic vector for the candidate answer. Since this updated semantic vector contains not only information about the candidate answer itself, but also supporting evidence from other candidate answers, it ensures that the target answer determined from multiple candidate answers based on their updated semantic vectors is highly accurate.
[0081] Figure 3 This is a flowchart of another answer selection method provided in an embodiment of this application. This method can be applied to a computer device, which may be... Figure 1 The scenario shown refers to either server 110 or terminal device 120. The following explanation uses the application of an answer selection method to a server as an example; see [link to documentation]. Figure 3 The method includes:
[0082] Step 201: Based on the target question, obtain multiple documents related to the target question.
[0083] In this embodiment of the application, after the server obtains the target question, it can search the database based on the target question to obtain multiple documents associated with the target question, and use these multiple documents as recall documents for the target question.
[0084] Optionally, when retrieving multiple documents associated with the target question, the server can also paraphrase the target question, that is, rewrite the target question into text with the same meaning but different expressions. The server can then use the paraphrased text to search the database to retrieve as many documents as possible associated with the target question.
[0085] Alternatively, the database can be a search engine. For example, in a medical question-and-answer system, the search engine could be one that covers various types of medical knowledge. The documents related to the target question retrieved by the server from this search engine could be journal articles, research papers, or articles from relevant forums and websites on the Internet.
[0086] Understandably, searching can effectively narrow down the range of documents containing answers to the target question, thereby making the subsequent answer selection process more efficient.
[0087] Example, Figure 4 This is a schematic diagram of the structure of a server provided in an embodiment of this application, such as... Figure 4 As shown, the server may include a pre-processing module and an answer selection module. The pre-processing module includes a retrieval module 11, which is capable of retrieving multiple documents associated with the target question from the database 10.
[0088] Step 202: For each document in the multiple documents, obtain one candidate answer to the target question, resulting in multiple candidate answers.
[0089] For each of the multiple documents retrieved, the server can extract a concise fragment from that document that answers the target question as a candidate answer. For example, the server can use multi-document MRC technology to retrieve multiple candidate answers from multiple documents associated with the target question. For each of these multiple documents, the server can use single-document MRC technology to retrieve one candidate answer from that document.
[0090] Understandably, selecting paragraphs within each document that match the target question is a text matching process. For example, the server could use a short-text-to-long-text matching method to select paragraphs (i.e., long text) in each document that match the target question (short text) and can answer the target question as candidate answers. During the selection of candidate answers, the server can choose multiple segments from the document as candidate answers based on the semantic and knowledge information between each paragraph and the target question.
[0091] like Figure 4 As shown, the preceding module may also include an extraction module 12. For the multiple documents obtained by the retrieval module 11, the extraction module 12 can extract a concise fragment that can answer the target question from each document as a candidate answer.
[0092] Step 203: For each candidate answer among the multiple candidate answers to the target question, concatenate the target question with the candidate answer to obtain the concatenated text.
[0093] The server can concatenate the target question with multiple candidate answers to obtain concatenated text for each candidate answer. In this embodiment, when encoding the candidate answers, the semantic matching and interaction information between the target question and each candidate answer needs to be considered. Therefore, the target question and each candidate answer can be concatenated separately, and the concatenated text can be input into the encoder for encoding.
[0094] Optionally, continue to refer to Figure 4 To improve the efficiency of subsequent answer selection, the extraction module 113 in the server can select the top n (e.g., 5) candidate answers with the highest relevance from the multiple candidate answers obtained in step 202 and concatenate them, based on the relevance between the target question and the candidate answers. For example, the server can determine the relevance between the candidate answers and the target question based on their semantic and syntactic matching degree, as well as their matching degree at the knowledge level.
[0095] If the server uses the BERT model as the encoder, then as follows Figure 5 As shown, before encoding candidate answers, the server can concatenate the target question and each candidate answer in the format "[CLS]target question[SEP]candidate answer". Here, "[SEP]" is a special separator used by the BERT model to distinguish between the target question and candidate answers. "[CLS]" is a special marker that combines the semantic information contained in the target question and the semantic information contained in the candidate answers into a unified semantic whole.
[0096] Step 204: Encode the concatenated text to obtain the initial semantic vector of the candidate answers.
[0097] The server can input the concatenated text corresponding to multiple candidate answers into the encoder for sequential encoding. Through encoding, the concatenated text in text form can be converted into vector form, thereby obtaining the initial semantic vector of each candidate answer.
[0098] Optionally, the server can use the BERT model as an encoder, inputting multiple concatenated texts into the encoder to obtain an initial semantic vector for each candidate answer. The encoder can encode each token (Tok) of the target question and each token of the candidate answer separately.
[0099] Example, reference Figure 5Assuming the text of the target question has N blocks (also called characters), the embedded text of the target question can be represented as: [Tok1, Tok2, ..., TokN]. If the text of a candidate answer to the target question has M blocks, then the embedded text of the candidate answer can be represented as: [Tok1, Tok2, ..., TokM]. Here, M and N are both positive integers greater than 1.
[0100] Understandably, the BERT model includes multiple Transformer models that can use a multi-head self-attention mechanism to interact with and encode the concatenated text in order to obtain matching information between the target question and candidate answers in the concatenated text, and to make the "[CLS]" in the concatenated text notice the global semantic information of the concatenated text.
[0101] Continue to refer to Figure 4 The answer selection module may include a semantic encoding module 13. For each candidate answer among the multiple candidate answers output by the preceding module, the semantic encoding module 13 can encode the concatenated text corresponding to each candidate answer to obtain the initial semantic vector of the candidate answer.
[0102] Step 205: For each candidate answer, determine the similarity between the candidate answer and each other based on the dot product of the initial semantic vector of the candidate answer and the initial semantic vector of each other candidate answer.
[0103] In this embodiment, for each candidate answer among multiple candidate answers, the server can calculate the dot product of the initial semantic vector of that candidate answer with the initial semantic vector of each of the other candidate answers. Wherein, the initial semantic vector of the i-th candidate answer... semantic vector of the j-th candidate answer dot product s i,j The calculation formula can be expressed as:
[0104]
[0105] Where T is the transpose symbol, and i ≠ j, i and j are both positive integers not greater than n, n is the total number of candidate answers to the target problem, and n is an integer greater than 1.
[0106] As a first possible example, for each candidate answer among multiple candidate answers, the server can directly use the dot product of the initial semantic vector of that candidate answer and the initial semantic vectors of each of the other candidate answers as the similarity between that candidate answer and the other candidate answers. That is, the similarity between the i-th candidate answer and the j-th candidate answer is s.i,j .
[0107] As a second possible example, for each candidate answer among multiple candidate answers, the server can normalize the dot product of the initial semantic vector of that candidate answer and the initial semantic vectors of all other candidate answers, and use the normalized result as the similarity between that candidate answer and all other candidate answers. Here, the server normalizes the initial semantic vector of the i-th candidate answer. semantic vector of the j-th candidate answer dot product s i,j The result obtained after normalization (i.e., the similarity α between the i-th candidate answer and the j-th candidate answer) i,j This can be represented as:
[0108]
[0109] Among them, s i,k Let e be the dot product of the initial semantic vector of the i-th candidate answer and the initial semantic vector of the k-th candidate answer, where e is the natural constant (i.e., the base of the natural logarithm) and k is a positive integer not greater than n.
[0110] Understandably, in the two examples above, the server can set the similarity between each candidate answer and itself to 0, meaning the server doesn't need to calculate the similarity between a candidate answer and itself. Therefore, for the first example, when i = j, s i,j =0, for the second example, when i = j, α i,j =0.
[0111] It is also understandable that by normalizing the dot product of the initial semantic vectors of any two candidate answers, the result of the dot product (i.e., the similarity) can be mapped to the range of 0 to 1. In other words, through normalization, the similarity between any two candidate answers can be made to fall within the range of 0 to 1, thus making subsequent processing more efficient and convenient.
[0112] Step 206: For each candidate answer among multiple candidate answers, based on the similarity between the candidate answer and other candidate answers, the initial semantic vectors of the other candidate answers are weighted to obtain the intermediate semantic vector of the candidate answer.
[0113] In this embodiment, for the i-th candidate answer among multiple candidate answers, the server can use the similarity of this candidate answer to the other candidate answers as weights to perform a weighted summation of the initial semantic vectors of the other answers, thereby obtaining the intermediate semantic vector of the i-th candidate answer. Wherein, the intermediate semantic vector of the i-th candidate answer The calculation formula can be expressed as:
[0114]
[0115] Based on step 205 above, it can be seen that when j = i, α i,j =0. Therefore, for the i-th candidate answer among multiple candidate answers, the server does not need to weight the initial semantic vector of the i-th candidate answer with its similarity to itself. Alternatively, it can be understood as weighting the intermediate semantic vector of the i-th candidate answer. In the calculation formula, j≠i.
[0116] Optionally, such as Figure 6 As shown, the server can use an Attention mechanism to transform the initial semantic vector of each candidate answer into an intermediate semantic vector. See also... Figure 6 The Attention mechanism can determine the intermediate semantic vector of each of the n candidate answers based on the initial semantic vectors of the n candidate answers. This intermediate semantic vector can serve as supporting evidence for the candidate answer.
[0117] Step 207: For each of the multiple candidate answers, concatenate the initial semantic vector and the intermediate semantic vector of the candidate answer to obtain the updated semantic vector of the candidate answer.
[0118] Continue to refer to Figure 6 For each of the n candidate answers, the server can concatenate (fuse) the initial semantic vector and the intermediate semantic vector of each candidate answer to obtain the updated semantic vector of that candidate answer. Here, the initial semantic vector of the i-th candidate answer... and intermediate semantic vectors The updated semantic vector obtained after concatenation It can be represented as:
[0119]
[0120] It is understandable that the updated semantic vector of each candidate answer obtained after concatenation includes not only the information of the candidate answer itself, but also the supporting evidence information of other candidate answers.
[0121] Optionally, to better facilitate semantic interaction between candidate answers, for each candidate answer, the server can concatenate its initial semantic vector, intermediate semantic vector, and product vector to obtain its updated semantic vector. The product vector is the vector product of the initial and intermediate semantic vectors. Correspondingly, the updated semantic vector of the i-th candidate answer is... It can be represented as:
[0122]
[0123] For example, such as Figure 4 As shown, the answer selection module of the server may also include a multi-answer comparison module 14, which can implement the methods shown in steps 205 to 207 above.
[0124] Step 208: Input the updated semantic vectors of multiple candidate answers into the answer selection model.
[0125] After the server determines the updated semantic vectors of multiple candidate answers, it can input these updated semantic vectors into the answer selection model. This answer selection model can be a binary classification model, and it can also be called a decoder.
[0126] In this embodiment of the application, the answer selection model can determine whether each candidate answer is the correct answer to the target answer based on the updated semantic vector of each candidate answer, and predict the probability that each candidate answer is the correct answer.
[0127] Step 209: Based on the output of the answer selection model, determine the target answer from multiple candidate answers.
[0128] In this embodiment of the application, for each candidate answer among multiple candidate answers, the output of the answer selection model may include the predicted probability and predicted label of that candidate answer. Specifically, for candidate answers with a predicted probability greater than or equal to a probability threshold, the predicted label output by the answer selection model may be a first label; for candidate answers with a predicted probability less than the probability threshold, the predicted label output by the answer selection model may be a second label.
[0129] The probability threshold can be a pre-configured probability value in the server, which can be a value greater than or equal to 0.5. Both the first label and the second label can be numerical values; for example, the first label can be 1 and the second label can be 0.
[0130] The server can identify candidate answers with a predicted label of the first label (e.g., 1) as the correct answer to the target question, and candidate answers with a predicted label of the second label (e.g., 0) as incorrect answers to the target question. Furthermore, the server can identify the correct answer with the highest predicted probability among at least one correct answer with a predicted label of the first label as the target answer to the target question.
[0131] See Figure 6 The server can input the updated semantic vectors of the n concatenated candidate answers into the decoder for decoding (also known as prediction). The decoder can then output the predicted probability of each candidate answer, or the predicted probability and predicted label of each candidate answer. For example, assuming the probability threshold is 0.5, the first label is 1, and the second label is 0. For a certain candidate answer, if the predicted probability output by the answer selection model is 0.6, then the answer selection model can also output the predicted label of that candidate answer: 1. For a certain candidate answer, if the predicted probability output by the answer selection model is 0.4, then the answer selection model can also output the predicted label of that candidate answer: 0.
[0132] For example, such as Figure 4 As shown, the answer selection module may also include a result classification module 15, which can implement the methods shown in steps 208 to 209 above. That is, the process of determining the correctness of candidate answers is a binary classification task. Through the binary classification task, multiple candidate answers can be divided into correct answers and incorrect answers.
[0133] Table 1 shows the comparison results of the answer selection model provided in this application and the baseline model in terms of precision, recall, and F-measure in determining whether a candidate answer is correct. As shown in Table 1, for the correct answer among the candidate answers, the answer selection model provided in this application has higher precision, recall, and F-measure than the baseline model.
[0134] Table 1
[0135]
[0136] It is understood that, in this embodiment, the updated semantic vector input to the answer selection model includes not only information about the candidate answer itself, but also supporting evidence information from other candidate answers. Therefore, the answer selection model can more accurately determine the correctness of each candidate answer based on this supporting evidence information. Referring to Table 1, the answer selection method provided in this embodiment can improve the accuracy of the answer selection model in determining candidate answers as correct answers while ensuring the recall rate of correct answers. As can be seen from the data in Table 1, the accuracy of the answer selection model provided in this embodiment in determining candidate answers as correct answers is 10% higher than that of the basic reference model.
[0137] Based on the above analysis, it can be seen that the answer selection method provided in this application can introduce knowledge verification information through supporting evidence information between candidate answers, thereby effectively improving the accuracy of selecting the correct answer from the candidate answers, so that the correctness of the candidate answers determined by the answer selection model is more accurate.
[0138] Optionally, the answer selection method provided in this application embodiment can be applied to the medical field. For example, it can be used as part of the offline data collection module in a medical encyclopedia search. Furthermore, the target answer (i.e., the best answer) selected by the answer selection method provided in this application embodiment can be applied to the online direct question-and-answer module of a medical question-and-answer system, or to modules such as question-and-answer summary modules of a medical question-and-answer system. The answer selection method provided in this application embodiment can also be applied to other fields, such as financial knowledge question-and-answer in the financial field, and agricultural encyclopedic knowledge question-and-answer in the agricultural field, etc., and this application does not limit its application.
[0139] It is understood that the order of steps in the answer selection method provided in this application embodiment can be appropriately adjusted, and steps can be added or removed as needed. For example, step 203 can be deleted as needed, that is, the server can only encode candidate answers. Any variations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and therefore will not be elaborated further.
[0140] In summary, this application provides an answer selection method. For each candidate answer, an intermediate semantic vector is obtained based on its similarity to other candidate answers. This intermediate semantic vector is then concatenated with the initial semantic vector to obtain an updated semantic vector for the candidate answer. Since this updated semantic vector contains not only information about the candidate answer itself but also supporting evidence from other candidate answers, it ensures that the target answer determined from multiple candidate answers based on their updated semantic vectors is highly accurate.
[0141] This application also provides a training method for an answer selection model, which can be used to train the answer selection model described in the above embodiments. Furthermore, this training method for the answer selection model can be applied to a computer device, which can be... Figure 1 Server 110 in the scenario shown. See also Figure 7 The training process of the model selected by this answer includes the following steps.
[0142] Step 301: Obtain multiple answer samples for the question sample, and the label for each answer sample.
[0143] The server can obtain multiple question samples corresponding to a specific application scenario of the answer selection model, as well as multiple answer samples for each question sample. Each answer sample has a manually labeled tag, which indicates whether the answer sample is the correct answer to a question sample. If an answer sample is the correct answer, its label is the first label (e.g., 1); if an answer sample is the incorrect answer, its label is the second label (e.g., 0).
[0144] It is understandable that the multiple question samples and the answer samples for each question sample in the multiple question samples can be pre-stored in the server or sent to the server by the terminal device.
[0145] Step 302: Encode each answer sample from the multiple answer samples to obtain the initial semantic vector of each answer sample.
[0146] Step 303: For each answer sample among multiple answer samples, based on the similarity between the answer sample and other answer samples, the initial semantic vectors of the other answer samples are weighted to obtain the intermediate semantic vector of the answer sample.
[0147] Step 304: For each answer sample among multiple answer samples, concatenate the initial semantic vector and the semantic vector of the answer sample to obtain the updated semantic vector of the answer sample.
[0148] The implementation process of steps 302 to 304 can refer to the implementation process of steps 101 to 103 and steps 203 to 207. The embodiments of this application will not be described again here.
[0149] Step 305: Train the answer selection model based on the updated semantic vectors of multiple answer samples and the labels of multiple answer samples.
[0150] In this embodiment, an initial model is pre-stored in the server. The server can train this initial model using the updated semantic vectors of multiple answer samples and the labels of multiple answer samples to obtain an answer selection model. Alternatively, the server can update the already trained answer selection model using the updated semantic vectors of multiple answer samples and the labels of multiple answer samples.
[0151] Optionally, the server can use a binary cross-entropy function as the loss function for the answer selection model, and can train the answer selection model using an end-to-end training method. The loss function L can be expressed as:
[0152] L=-(y·logp+(1-y)·log(1-p));
[0153] Where y represents the label of the answer sample, for example, y=1 indicates that the answer sample is the correct answer to the question sample, and y=0 indicates that the answer sample is the incorrect answer to the question sample. p represents the predicted probability of the answer sample output by the answer selection model, that is, the probability that the answer sample is the correct answer.
[0154] During the training of the answer selection model, the server can adjust the relevant parameters of the model based on the error between the predicted probability of the answer sample output by the model and the label of that answer sample. The server can stop training the answer selection model when the loss function L converges or when the training effect of the model reaches the expected level.
[0155] Understandably, the updated semantic vectors of the answer samples used for training contain not only information about the answer sample itself, but also supporting evidence from other answer samples. Therefore, during training, the answer selection model can effectively learn the semantic information of each candidate answer, as well as the relevance of that answer sample to the question sample. This ensures good training performance for the answer selection model.
[0156] For example, assuming this answer selection model is applied to a medical scenario, relevant medical questions can be used as question samples, and relevant medical knowledge related to those question samples can be used as answer samples. Referring to Table 2, for the question sample "Does removing one ovary from the uterus have any impact on the body?", the four answer samples with a true label of 1 do not match the question sample semantically and syntactically.
[0157] Correspondingly, if the baseline reference model is used to predict the correctness of these four answer samples, as shown in Table 2, the labels output by the baseline reference model for these four answer samples are all 0. That is, the baseline reference model judges all four answer samples as incorrect answers, and the labels output by the baseline reference model are inconsistent with the true labels of these four answer samples.
[0158] When using the answer selection model provided in this application, the updated semantic vector of the answer sample input to the model includes not only the information of the answer sample itself, but also supporting evidence information from other answer samples. Referring to Table 2, this supporting evidence information can be the bolded text in each answer sample. Since the answer selection model can more accurately determine the correctness of an answer sample based on the supporting evidence information of each answer sample, the label output by the answer selection model for the four answer samples shown in Table 2 is 1. That is, the label output by the answer selection model is consistent with the true labels of the four answer samples.
[0159] Table 2
[0160]
[0161]
[0162] In summary, this application provides a training method for an answer selection model. For each answer sample, an intermediate semantic vector is obtained based on its similarity to other answer samples. This intermediate semantic vector is then concatenated with the initial semantic vector to obtain an updated semantic vector for the answer sample. Since this updated semantic vector includes not only information about the answer sample itself but also supporting evidence from other answer samples, the answer selection model can effectively learn the semantic information of each candidate answer and the relevance of the answer sample to the question sample during training. This ensures that the answer selection model can accurately judge the accuracy of answer samples, resulting in better training performance.
[0163] Figure 8 This is a schematic diagram of the structure of an answer selection device provided in an embodiment of this application. This answer selection device can be applied to a computer device, which may be... Figure 1 Server 110 in the scenario shown. (As shown) Figure 8 As shown, the device includes:
[0164] The encoding module 401 is used to encode each candidate answer among multiple candidate answers to the target question to obtain an initial semantic vector for each candidate answer.
[0165] The encoding module 401 can be Figure 4 The semantic encoding module 13 shown.
[0166] The weighting module 402 is used to weight the initial semantic vectors of each of the multiple candidate answers based on the similarity between the candidate answer and the other candidate answers, so as to obtain the intermediate semantic vector of the candidate answer.
[0167] The concatenation module 403 is used to concatenate the initial semantic vector of each candidate answer with the intermediate semantic vector for each of the multiple candidate answers, so as to obtain the updated semantic vector of the candidate answer.
[0168] Among them, the weighting module 402 and the splicing module 403 mentioned above can both belong to Figure 4 The multi-answer comparison module 14 is shown.
[0169] The determination module 404 is used to update the semantic vector based on multiple candidate answers and determine the target answer from multiple candidate answers.
[0170] The determining module 404 can be... Figure 4 The results are categorized in module 15.
[0171] Optionally, the concatenation module 403 is used to concatenate the initial semantic vector, the intermediate semantic vector, and the product vector of the candidate answer for each of the multiple candidate answers to obtain the updated semantic vector of the candidate answer; wherein the product vector is the vector product of the initial semantic vector and the intermediate semantic vector of the candidate answer.
[0172] Optionally, the weighting module 402 is used to determine the similarity between each candidate answer and each other among a plurality of candidate answers, based on the dot product of the initial semantic vector of the candidate answer and the initial semantic vector of each other candidate answer.
[0173] Optionally, among these multiple candidate answers, the similarity α between the i-th candidate answer and the j-th candidate answer is... i,j satisfy:
[0174]
[0175] Among them, s i,j Let s be the dot product of the initial semantic vector of the i-th candidate answer and the initial semantic vector of the j-th candidate answer. i,k Let e be the dot product of the initial semantic vector of the i-th candidate answer and the initial semantic vector of the k-th candidate answer, where e is a natural constant, n is the total number of candidate answers, and i, j, and k are all positive integers not greater than n.
[0176] Optionally, the encoding module 401 is used to concatenate the target question with each of the multiple candidate answers to the target question to obtain concatenated text; and to encode the concatenated text to obtain the initial semantic vector of the candidate answer.
[0177] Optionally, such as Figure 9 As shown, the answer selection device may further include a first acquisition module 405, which is used to acquire multiple documents associated with the target question based on the target question; and for each of the multiple documents, acquire a candidate answer to the target question to obtain multiple candidate answers.
[0178] Optionally, the determining module 404 is used to input the updated semantic vectors of multiple candidate answers into the answer selection model; and to determine the target answer from the multiple candidate answers based on the output of the answer selection model.
[0179] Optionally, continue to refer to Figure 9 The answer selection device may further include a second acquisition module 406, which is used to acquire multiple answer samples of the question sample and a label for each answer sample, the label being used to indicate whether the answer sample is the correct answer to the question sample.
[0180] The encoding module 401 is also used to encode each answer sample among multiple answer samples to obtain an initial semantic vector for each answer sample.
[0181] The weighting module 402 is also used to weight the initial semantic vectors of the other answer samples based on the similarity between the answer sample and the other answer samples for each answer sample among the multiple answer samples, so as to obtain the intermediate semantic vector of the answer sample.
[0182] The splicing module 403 is used to splice the initial semantic vector and the intermediate semantic vector of each answer sample among multiple answer samples to obtain the updated semantic vector of the answer sample.
[0183] Continue to refer to Figure 9 The answer selection device may also include a training module 407, which is used to train the answer selection model based on the updated semantic vectors of multiple answer samples and the labels of multiple answer samples.
[0184] In summary, this application provides an answer selection device. For each candidate answer, the device can obtain an intermediate semantic vector of the candidate answer based on its similarity to other candidate answers, and concatenate the intermediate semantic vector with the initial semantic vector to obtain an updated semantic vector of the candidate answer. Since the updated semantic vector not only contains information about the candidate answer itself, but also contains supporting evidence information from other candidate answers, it can ensure that the target answer determined from multiple candidate answers based on the updated semantic vectors of multiple candidate answers has high accuracy.
[0185] Figure 10 This is a structural block diagram of a training device for an answer selection model provided in an embodiment of this application. This answer selection device can be applied to a computer device, which may be... Figure 1 Server 110 in the scenario shown. (As shown) Figure 10 As shown, the device includes:
[0186] The acquisition module 501 is used to acquire multiple answer samples of the question sample, as well as a label for each answer sample. The label is used to indicate whether the answer sample is the correct answer to the question sample.
[0187] The encoding module 502 is used to encode each answer sample among multiple answer samples to obtain an initial semantic vector for each answer sample.
[0188] The weighting module 503 is used to weight the initial semantic vectors of the other answer samples based on the similarity between the answer sample and the other answer samples, and obtain the intermediate semantic vector of the answer sample.
[0189] The concatenation module 504 is used to concatenate the initial semantic vector of the answer sample and the intermediate semantic vector of the answer sample to obtain the updated semantic vector of the answer sample.
[0190] Training module 505 is used to train the answer selection model based on the updated semantic vectors and labels of multiple answer samples.
[0191] In summary, this application provides a training device for an answer selection model. For each candidate answer, the device obtains an intermediate semantic vector of the answer sample based on its similarity to other answer samples, and concatenates this intermediate semantic vector with the initial semantic vector to obtain an updated semantic vector of the answer sample. Since this updated semantic vector contains not only information about the answer sample itself but also supporting evidence from other answer samples, the answer selection model can effectively learn the semantic information of each candidate answer and the relevance of the answer sample to the question sample during training. This ensures that the answer selection model can accurately judge the accuracy of answer samples, resulting in better training performance.
[0192] It is understood that the answer selection device and the answer selection model training device provided in the above embodiments are only illustrative examples of the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0193] Furthermore, the answer selection device and answer selection method embodiments provided in the above embodiments belong to the same concept, and the training device and training method embodiments of the answer selection model belong to the same concept. For details of their specific implementation process, please refer to the method embodiments, which will not be repeated here.
[0194] Figure 11 This is a structural block diagram of a computer device provided in an embodiment of this application. The computer device may be... Figure 1 The server 110 in the scenario shown will be referred to as server 110 in the following description.
[0195] Specifically, server 110 includes a central processing unit (CPU) 111, a system memory 112 including random access memory (RAM) 1121 and read-only memory (ROM) 1122, and a system bus 113 connecting the system memory 112 and the CPU 111. Server 110 also includes a mass storage device 114 for storing the operating system 1141, application programs 1142, and other program modules 1143.
[0196] Mass storage device 114 is connected to central processing unit 111 via a mass storage controller (not shown) connected to system bus 113. Mass storage device 114 and its associated computer-readable media provide non-volatile storage for server 110. That is, mass storage device 114 may include computer-readable media (not shown) such as hard disk or compact disc read-only memory (CD-ROM) drives.
[0197] Without loss of generality, computer-readable media can include computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state storage technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that computer storage media are not limited to the above-mentioned types. The system memory 112 and mass storage device 114 described above can be collectively referred to as memory.
[0198] According to various embodiments of this application, server 110 can also be connected to a remote computer on a network, such as the Internet. That is, server 110 can be connected to network 116 via network interface unit 115 connected to system bus 113, or it can also use network interface unit 115 to connect to other types of networks or remote computer systems (not shown).
[0199] The aforementioned memory also includes one or more programs, which are stored in the memory and configured to be executed by the CPU.
[0200] This application also provides a computer device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, code set, or instruction set. The processor loads and executes the at least one instruction, at least one program, code set, or instruction set to implement the answer selection method or the answer selection model training method provided in the above-described method embodiments.
[0201] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set. The at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the answer selection method or the answer selection model training method provided in the above-described method embodiments.
[0202] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the answer selection methods or answer selection model training methods described in the above embodiments.
[0203] Optionally, the computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), solid-state drives (SSDs), or optical discs, etc. The random access memory may include resistive random access memory (ReRAM) and dynamic random access memory (DRAM). The sequence numbers of the embodiments in this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0204] It is understood that in this application, the term "at least one" means one or more, and "multiple" means two or more.
[0205] It is also understood that the information and data involved in this application (including but not limited to data used for training the model and data used to provide candidate answers) have all been authorized by the user or by all parties in full, and the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the documents related to the target question and the answer samples involved in this application were obtained with full authorization.
[0206] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. The embodiments provided in this application can be applied to various scenarios such as cloud technology, artificial intelligence, and intelligent transportation, and are not limited thereto.
[0207] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for selecting answers, characterized in that, The method includes: Encode each candidate answer from multiple candidate answers to the target question to obtain an initial semantic vector for each candidate answer; For each of the plurality of candidate answers, based on the similarity between the candidate answer and the other candidate answers, the initial semantic vectors of the other candidate answers are weighted to obtain the intermediate semantic vector of the candidate answer. The intermediate semantic vector of the candidate answer is the supporting evidence information of the other candidate answers to the candidate answer. For each of the plurality of candidate answers, the initial semantic vector of the candidate answer is concatenated with the intermediate semantic vector to obtain the updated semantic vector of the candidate answer; The target answer is determined from the multiple candidate answers by updating the semantic vectors of the multiple candidate answers.
2. The method according to claim 1, characterized in that, For each of the plurality of candidate answers, the initial semantic vector of the candidate answer is concatenated with the intermediate semantic vector to obtain the updated semantic vector of the candidate answer, including: For each of the multiple candidate answers, the initial semantic vector of the candidate answer, the intermediate semantic vector of the candidate answer, and the product vector of the candidate answer are concatenated to obtain the updated semantic vector of the candidate answer; The product vector is the vector product of the initial semantic vector of the candidate answer and the intermediate semantic vector of the candidate answer.
3. The method according to claim 1, characterized in that, The method further includes: For each of the plurality of candidate answers, the similarity between the candidate answer and the other candidate answers is determined by the dot product of the initial semantic vector of the candidate answer and the initial semantic vectors of the other candidate answers.
4. The method according to any one of claims 1 to 3, characterized in that, Encoding each candidate answer from multiple candidate answers to the target question to obtain an initial semantic vector for each candidate answer includes: For each candidate answer among multiple candidate answers to the target question, the target question and the candidate answer are concatenated to obtain concatenated text; The concatenated text is encoded to obtain the initial semantic vector of the candidate answer.
5. The method according to any one of claims 1 to 3, characterized in that, Before encoding each of the multiple candidate answers to the target question, the method further includes: Based on the target question, obtain multiple documents associated with the target question; For each of the multiple documents, obtain one candidate answer to the target question, resulting in multiple candidate answers.
6. The method according to any one of claims 1 to 3, characterized in that, The step of updating the semantic vector based on the multiple candidate answers to determine the target answer from the multiple candidate answers includes: The updated semantic vectors of the multiple candidate answers are input into the answer selection model; Based on the output of the answer selection model, the target answer is determined from the multiple candidate answers.
7. The method according to claim 6, characterized in that, The method further includes: Obtain multiple answer samples for a question sample, and a label for each answer sample, the label being used to indicate whether the answer sample is the correct answer to the question sample; Encode each of the multiple answer samples to obtain an initial semantic vector for each answer sample; For each of the multiple answer samples, the initial semantic vectors of the other answer samples are weighted based on the similarity between the answer sample and the other answer samples to obtain the intermediate semantic vector of the answer sample; For each of the multiple answer samples, the initial semantic vector and the intermediate semantic vector of the answer sample are concatenated to obtain the updated semantic vector of the answer sample; The answer selection model is trained based on the updated semantic vectors of the multiple answer samples and the labels of the multiple answer samples.
8. An answer selection device, characterized in that, The device includes: The encoding module is used to encode each candidate answer among multiple candidate answers to the target question, and obtain an initial semantic vector for each candidate answer; The weighting module is used to, for each of the plurality of candidate answers, perform weighted processing on the initial semantic vectors of the other candidate answers based on the similarity between the candidate answer and the other candidate answers, to obtain the intermediate semantic vector of the candidate answer. The intermediate semantic vector of the candidate answer is the supporting evidence information of the other candidate answers to the candidate answer. The concatenation module is used to concatenate the initial semantic vector of each candidate answer with the intermediate semantic vector to obtain the updated semantic vector of the candidate answer for each of the plurality of candidate answers; The determination module is used to determine the target answer from the multiple candidate answers based on the updated semantic vector of the multiple candidate answers.
9. The apparatus according to claim 8, characterized in that, The concatenation module is used to concatenate the initial semantic vector, the intermediate semantic vector, and the product vector of each candidate answer among the plurality of candidate answers to obtain the updated semantic vector of the candidate answer; wherein the product vector is the vector product of the initial semantic vector and the intermediate semantic vector of the candidate answer.
10. The apparatus according to claim 8, characterized in that, The weighting module is further configured to, for each of the plurality of candidate answers, determine the similarity between the candidate answer and the other candidate answers based on the dot product of the initial semantic vector of the candidate answer and the initial semantic vectors of the other candidate answers.
11. The apparatus according to any one of claims 8 to 10, characterized in that, The encoding module is used to concatenate the target question with each of the multiple candidate answers to the target question to obtain concatenated text. The concatenated text is encoded to obtain the initial semantic vector of the candidate answer.
12. The apparatus according to any one of claims 8 to 10, characterized in that, The device further includes a first acquisition module; The first acquisition module is used to acquire multiple documents associated with the target question based on the target question; and for each of the multiple documents, acquire a candidate answer to the target question to obtain multiple candidate answers.
13. The apparatus according to any one of claims 8 to 10, characterized in that, The determining module is used to input the updated semantic vectors of the multiple candidate answers into the answer selection model; and to determine the target answer from the multiple candidate answers based on the output of the answer selection model.
14. The apparatus according to claim 13, characterized in that, The device further includes a second acquisition module and a training module; The second acquisition module is used to acquire multiple answer samples of a question sample, and a label for each answer sample, wherein the label is used to indicate whether the answer sample is the correct answer to the question sample; The encoding module is also used to encode each of the plurality of answer samples to obtain an initial semantic vector for each answer sample; The weighting module is further configured to, for each of the plurality of answer samples, perform weighted processing on the initial semantic vectors of the other answer samples based on the similarity between the answer sample and the other answer samples, to obtain the intermediate semantic vector of the answer sample; The splicing module is also used to splice the initial semantic vector and the intermediate semantic vector of each of the plurality of answer samples to obtain the updated semantic vector of the answer sample; The training module is used to train an answer selection model based on the updated semantic vectors of the multiple answer samples and the labels of the multiple answer samples.
15. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one instruction, at least one program, a code set, or an instruction set, the at least one instruction, the at least one program, the code set, or the instruction set being loaded and executed by the processor to implement the answer selection method as described in any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or instruction set is loaded and executed by a processor to implement the answer selection method as described in any one of claims 1 to 7.
17. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium, wherein a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to implement the answer selection method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Multi-text analysis method and device
CN110929015A
System and Method for Identifying Answer Key Problems in a Natural Language Question and Answering System
US20170116250A1