Information retrieval method and device, storage medium and electronic device
By converting the question and answer information into multiple answer representation vectors, and using multi-mode matching method, the information loss problem in the question-and-answer retrieval model is solved, and the retrieval accuracy is improved.
Patent Information
- Application Number
- CN202210547123.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-19
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2042-05-19
AI Technical Summary
The traditional question-and-answer search model has information loss during the calculation process, resulting in the problem of low retrieval accuracy.
Through the target question and answer prediction model, the question information and answer information are converted into multiple answer representation vectors, and the matching degree is determined by multi-mode matching to avoid information loss.
The search accuracy of the Q&A search model is improved, and the problem of low search accuracy in traditional models is solved.
Smart Images

Figure CN115114418B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to an information retrieval method and device, a storage medium, and an electronic device. Background Art
[0002] Traditional question-answering retrieval models generally use unsupervised and supervised training models. Unsupervised training models require no training data, but essentially rely on matching words in the query and the answer. This makes it difficult to address semantic matching and generally yields poor results. Supervised training models, on the other hand, require a large amount of labeled training data. The model encodes the user's query and the retrieved complete paragraph into separate vectors to determine the similarity between the vectors.
[0003] However, since articles or paragraphs are generally long, encoding them into a vector will result in information loss. In addition, this method does not provide a more fine-grained match between the user's search questions and the retrieved complete paragraphs.
[0004] Therefore, there is a technical problem in the related art that information loss occurs during the calculation process of the question-answering retrieval model, resulting in a low retrieval accuracy of the question-answering retrieval model.
[0005] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0006] The embodiments of the present application provide an information retrieval method and device, a storage medium, and an electronic device to at least solve the technical problem of low retrieval accuracy of question-answering retrieval models in related technologies.
[0007] According to one aspect of an embodiment of the present application, an information retrieval method is provided, including: inputting the target question information and candidate answer information into a target question and answer prediction model, converting the target question information into a target question representation vector through the target question and answer prediction model, and converting the candidate answer information into an original answer representation vector; converting the original answer representation vector into multiple answer representation vectors through the target question and answer prediction model, and determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector; determining a matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector through the target question and answer prediction model; and determining whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information.
[0008] According to another aspect of the embodiment of the present application, an information retrieval device is also provided, including: an acquisition module for acquiring an information retrieval request, wherein the information retrieval request carries target question information; a conversion module for inputting the target question information and candidate answer information into a target question and answer prediction model, converting the target question information into a target question representation vector through the target question and answer prediction model, and converting the candidate answer information into an original answer representation vector; a processing module for converting the original answer representation vector into multiple answer representation vectors through the target question and answer prediction model, and determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector; a first determination module for determining the degree of matching between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector through the target question and answer prediction model; a second determination module for determining whether the candidate answer information is answer information that matches the target question information based on the degree of matching between the target question information and the candidate answer information. Acquire an information retrieval request, wherein the information retrieval request carries target question information;
[0009] Optionally, the device is used to convert the original answer representation vector into multiple answer representation vectors through the target question and answer prediction model in the following manner: obtaining a plurality of preset different transformation matrices, wherein each of the transformation matrices is used to perform a linear transformation on the original answer representation vector; multiplying each of the plurality of different transformation matrices by the original answer representation vector to obtain the plurality of answer representation vectors.
[0010] Optionally, the device is used to obtain a preset plurality of different conversion matrices in the following manner: determining a keyword attribute of the target question information according to the information retrieval request; when the keyword attribute represents the part of speech of the answer searched for by the target question information, obtaining a preset plurality of different part-of-speech conversion matrices; the device is used to multiply each of the plurality of different conversion matrices by the original answer representation vector in the following manner to obtain the plurality of answer representation vectors: multiplying each of the plurality of different part-of-speech conversion matrices by the original answer representation vector to obtain the plurality of answer representation vectors.
[0011] Optionally, the device is used to obtain a preset plurality of different transformation matrices in the following manner: splitting the candidate answer information into multiple sentences and identifying the semantic information of the multiple sentences; obtaining a plurality of different semantic transformation matrices corresponding to the semantic information of the multiple sentences; the device is used to multiply each of the multiple different transformation matrices with the original answer representation vector in the following manner to obtain the multiple answer representation vectors: multiplying each of the multiple different semantic transformation matrices with the original answer representation vector to obtain the multiple answer representation vectors.
[0012] Optionally, the device is used to determine a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors in the following manner: when the multiple answer representation vectors are n answer representation vectors, perform inner product operations on the target question representation vector and each of the n answer representation vectors, respectively, to obtain a total of n matching values, where n is a positive integer greater than or equal to 2; obtain the ratio of each of the n matching values to the target matching sum, to obtain n weight values, where the target matching sum is the sum of the n matching values; use the n weight values to perform weighted summation on the n answer representation vectors to obtain the target answer representation vector.
[0013] Optionally, the device is also used to: obtain a group of question and answer information sample pairs, a sample question information set and a sample answer information set, wherein each question and answer information sample pair in the group of question and answer information sample pairs includes sample question information and a labeled sample answer that matches the sample question information; use the group of question and answer information sample pairs, the sample question information set and the sample answer information set to perform multiple rounds of training on the question and answer prediction model to be trained, and when the value of the preset loss function corresponding to the question and answer prediction model to be trained meets a preset convergence condition, end the training, and determine the question and answer prediction model to be trained at the end of the training as the target question and answer prediction model.
[0014] Optionally, the device is used to perform multiple rounds of training on the question and answer prediction model to be trained using the set of question and answer information sample pairs, the sample question information set, and the sample answer information set in the following manner: in the i-th round of training in the multiple rounds of training, when the target sample question information input into the question and answer prediction model to be trained in the i-th round is the sample question information in the sample question information set, the sample question information set and the sample answer information set used in the i+1-th round of training are updated according to the target sample question information and the target sample answer information, the target sample answer information is the sample answer information obtained by labeling the answer information determined by the question and answer prediction model to be trained in the i-th round of training according to the sample answers of the set of question and answer information sample pairs, and i is a positive integer greater than or equal to 1.
[0015] Optionally, the device is used to perform multiple rounds of training on the question-answering prediction model to be trained using the set of question-answering information sample pairs, the sample question information set, and the sample answer information set in the following manner: in the i-th round of training, the sample question information used in the i-th round is selected from the sample question information set, and the following steps are performed for the sample question information used in the i-th round and each sample answer information in the sample answer information set, wherein, when performing the following steps, the sample question information used in the i-th round is the current sample question information, and each sample answer information is the current sample answer information: the current sample question information and the current sample answer information are input into the question-answering prediction model, and the question-answering prediction model obtained by the i-1-th round of training converts the current sample question information into a current sample question representation vector, and converts the current sample answer information into a current sample original answer representation vector; the question-answering prediction model obtained by the i-1-th round of training converts the The original answer representation vector of the current sample is converted into multiple current sample answer representation vectors, and the current sample target answer representation vector is determined based on the multiple current sample answer representation vectors, wherein the multiple current sample answer representation vectors are vectors obtained by performing different linear transformations on the current sample original answer representation vector; the question and answer prediction model obtained by the i-1 round of training determines the matching degree between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector; the value of the preset loss function is determined based on the matching degree between the current sample question information and the current sample answer information, and the training is terminated when the value of the preset loss function meets the preset convergence condition; when the value of the preset loss function does not meet the preset convergence condition, the parameters in the question and answer prediction model obtained by the i-1 round of training are adjusted to obtain the question and answer prediction model obtained by the i-1 round of training.
[0016] Optionally, the device is used to determine the degree of matching between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector using the question-answer prediction model obtained through the i-1th round of training in the following manner: obtaining a first distance between the current sample question representation vector and the current sample target answer representation vector, and determining the obtained first distance as the degree of matching between the current sample question information and the current sample answer information; the device is used to determine the value of the preset loss function based on the degree of matching between the current sample question information and the current sample answer information in the following manner: obtaining a second distance between the current sample question representation vector and the first sample target answer representation vector, wherein the multiple current sample answer representation vectors include the first sample answer representation vector; determining the value of the preset loss function based on the first distance and the second distance, wherein the multiple current sample answer representation vectors include the first sample answer representation vector.
[0017] Optionally, the device is used to determine the value of the preset loss function based on the first distance and the second distance in the following manner, including: splicing the current sample question representation vector and the current sample target answer representation vector to obtain a current splicing vector; determining the target probability that the current sample answer information is the marked answer information that matches the current sample question information based on the current splicing vector; and determining the value of the preset loss function based on the first distance, the second distance and the target probability.
[0018] Optionally, the device is used to determine whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information in the following manner: when the candidate answer information set includes N answer information, among the N matching degrees arranged from large to small, determine whether the ranking position of the matching degree between the target question information and the candidate answer information is in the top K, wherein the N matching degrees include the matching degrees between the target question information and each answer information in the candidate answer information set, the N answer information includes the candidate answer information, N is a positive integer greater than or equal to 2, K is a positive integer greater than or equal to 1, N is greater than K, and the method for determining the matching degree between the target question information and each answer information is the same as the method for determining the matching degree between the target question information and the candidate answer information; when it is determined that the ranking position of the matching degree between the target question information and the candidate answer information is in the top K, the candidate answer information is determined as the answer information that matches the target question information.
[0019] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned information retrieval method when running.
[0020] According to another aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including 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 above information retrieval method.
[0021] According to another aspect of the embodiments of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the information retrieval method through the computer program.
[0022] In an embodiment of the present application, an information retrieval request is obtained, wherein the information retrieval request carries target question information, the target question information and candidate answer information are input into a target question-answering prediction model, the target question information is converted into a target question representation vector through the target question-answering prediction model, and the candidate answer information is converted into an original answer representation vector, the original answer representation vector is converted into multiple answer representation vectors through the target question-answering prediction model, and based on the multiple answer representation vectors, a target answer representation vector for representing the candidate answer information is determined, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector, and the target question-answering prediction model is used to determine the target answer representation vector according to the target question. Representation vector and target answer representation vector, determine the matching degree between target question information and candidate answer information, and determine whether the candidate answer information is the answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information. Through the multi-mode vector question-answering retrieval model, a multi-mode matching method is adopted to generate multiple answer representation vectors for each candidate answer information, and then match them with the target question representation vector, and more accurately encode the candidate answer information into multiple answer representation vectors, thereby achieving the purpose of avoiding information loss, thereby realizing the technical effect of improving the retrieval accuracy of the question-answering retrieval model, and then solving the technical problem of low retrieval accuracy of the question-answering retrieval model in related technologies.
[0023] In addition, a large number of training samples (sample question information set and sample answer information set) are constructed through a set of question-answer information sample pairs, which solves the technical problem of high training costs caused by the difficulty in obtaining training samples when training supervised models.
[0024] In addition, in order to further improve the retrieval effect of the question-answering retrieval model, an interactive matching model is used to distill the matching degree during the training process of the question-answering retrieval model, which more significantly improves the retrieval accuracy of the question-answering retrieval module. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0026] Figure 1 is a schematic diagram of an application environment of an optional information retrieval method according to an embodiment of the present application;
[0027] Figure 2 is a flowchart of an optional information retrieval method according to an embodiment of the present application;
[0028] Figure 3 is a schematic diagram of an optional information retrieval method according to an embodiment of the present application;
[0029] Figure 4 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application;
[0030] Figure 5 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application;
[0031] Figure 6 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application;
[0032] Figure 7 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application;
[0033] Figure 8 is a schematic structural diagram of an optional information retrieval device according to an embodiment of the present application;
[0034] Figure 9 is a schematic structural diagram of an optional information retrieval product according to an embodiment of the present application;
[0035] Figure 10 It is a schematic structural diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0037] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0038] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following interpretations:
[0039] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to 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 seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0040] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0041] Natural language processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to the study of linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.
[0042] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, autonomous driving, drones, robots, smart medical care, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0043] The solutions provided in the embodiments of this application involve technologies such as artificial intelligence natural language processing, and are specifically described through the following embodiments:
[0044] According to one aspect of the embodiment of the present application, an information retrieval method is provided. Optionally, in this embodiment, the above information retrieval method can be applied to Figure 1 In the hardware environment composed of the server 101 and the terminal device 103 shown in FIG. Figure 1As shown, server 101 is connected to terminal 103 via a network and can be used to provide services for terminal devices or applications installed on the terminal devices. Applications can be video applications, instant messaging applications, browser applications, educational applications, game applications, etc. A database 105 can be set up on the server or independently of the server to provide data storage services for server 101, such as a game data storage server. The above-mentioned networks can include, but are not limited to, wired networks and wireless networks, wherein the wired networks include local area networks, metropolitan area networks, and wide area networks, and the wireless networks include Bluetooth, WIFI, and other networks that enable wireless communication. Terminal device 103 can be a terminal configured with an application and can include, but are not limited to, at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, a MID (Mobile Internet Device), a PAD, a desktop computer, a smart TV, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and other computer devices. The above-mentioned server can be a single server, a server cluster consisting of multiple servers, or a cloud server. Application 107 using the above-mentioned information retrieval method is displayed through terminal device 103 or other connected display devices.
[0045] Combine Figure 1 As shown, the above information retrieval method can be implemented in the terminal device 103 through the following steps:
[0046] S1, obtaining an information retrieval request on the terminal device 103, wherein the information retrieval request carries target question information;
[0047] S2, on the terminal device 103, inputting the target question information and the candidate answer information into the target question and answer prediction model, converting the target question information into a target question representation vector through the target question and answer prediction model, and converting the candidate answer information into an original answer representation vector;
[0048] S3, on the terminal device 103, converting the original answer representation vector into multiple answer representation vectors using the target question-answer prediction model, and determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector;
[0049] S4, determining the matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector using the target question answer prediction model on the terminal device 103;
[0050] S5 , determining on the terminal device 103 whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information.
[0051] Optionally, in this embodiment, the above information retrieval method can also be implemented by a server, for example, Figure 1 It is implemented in the server 101 shown; or it is implemented by the terminal device and the server together.
[0052] The above is only an example and is not specifically limited in this embodiment.
[0053] Alternatively, as an optional implementation, Figure 2 As shown, the above information retrieval method includes:
[0054] S202, obtaining an information retrieval request, wherein the information retrieval request carries target question information;
[0055] Optionally, in an embodiment of the present application, the above-mentioned information retrieval request may include but is not limited to information retrieval requests input by users through touch, voice, touch, etc. For example, it may include but is not limited to keywords, key words or entire sentences, wherein the above-mentioned target question information may include but is not limited to the semantic information corresponding to the above-mentioned information retrieval request after identification.
[0056] S204: Input the target question information and the candidate answer information into the target question-answering prediction model, and convert the target question information into a target question representation vector and the candidate answer information into an original answer representation vector through the target question-answering prediction model;
[0057] Optionally, in an embodiment of the present application, the candidate answer information may include but is not limited to answer information that can be retrieved, and may include but is not limited to web pages, electronic books, etc.
[0058] Optionally, in an embodiment of the present application, the above-mentioned target question and answer prediction model is a model obtained by training the question and answer prediction model to be trained, and may include but is not limited to being composed of an encoder, and may also include but is not limited to being composed of an LSTM / GRU model, or a BERT model.
[0059] Optionally, in an embodiment of the present application, the above-mentioned conversion of the target question information into a target question representation vector and the conversion of the candidate answer information into an original answer representation vector may include but is not limited to performing a word segmentation operation through an encoder, for example, the above-mentioned target question information or candidate answer information is tokenized, divided into individual words, and then two special tokens "[CLS]" and "[SEP]" are spliced together, and the output word vector (embedding) of the [CLS] token is taken as the target question representation vector or the original answer representation vector.
[0060] S206, converting the original answer representation vector into multiple answer representation vectors using the target question-answer prediction model, and determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector;
[0061] Optionally, in an embodiment of the present application, the above-mentioned conversion of the original answer representation vector into multiple answer representation vectors may include but is not limited to performing different linear transformations on the original answer representation vector to obtain the above-mentioned multiple answer representation vectors, and the method of performing the above-mentioned linear transformation may include but is not limited to multiplication or addition with a preset transformation matrix.
[0062] Optionally, in an embodiment of the present application, determining the target answer representation vector used to represent the candidate answer information based on multiple answer representation vectors may include but is not limited to normalizing the multiple answer representation vectors and then performing weighted aggregation to obtain the above-mentioned target answer representation vector.
[0063] S208, determining the matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector using the target question answer prediction model;
[0064] Optionally, in an embodiment of the present application, after obtaining multiple answer representation vectors, the target question representation vector is used to perform inner product on the multiple answer representation vectors, and then the multiple answer representation vectors are normalized. Finally, the multiple answer representation vectors are weighted and aggregated into a target answer representation vector to calculate the similarity between the target question representation vector and the target answer representation vector, and then determine the matching degree between the target question information and the candidate answer information.
[0065] S210 , determining whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information.
[0066] Optionally, in an embodiment of the present application, the above-mentioned determination of whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information may include but is not limited to determining whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information.
[0067] Specifically, it may include but is not limited to sorting multiple candidate answer information according to the matching degree, and determining the K candidate answer information with the highest matching degree as the answer information matching the target question information.
[0068] It should be noted that the above-mentioned answer information can be understood as the answer information corresponding to the answer that matches the target question information, that is, when the answer information is a paragraph, the answer is part or all of the answer information.
[0069] Optionally, in an embodiment of the present application, the above-mentioned information retrieval method may include but is not limited to application scenarios such as search engines and customer service questions and answers that require determining answer information that matches the retrieval request.
[0070] Figure 3 is a schematic diagram of an optional information retrieval method according to an embodiment of the present application, such as Figure 3 As shown, taking search engines as an example, search engines are a very important way to obtain information. Every day, a large number of users search for queries through search engines, including a large number of question-and-answer queries, such as "Who is XXX's wife?", "What are the four great classics?", "Who is the tallest person in the world", etc.
[0071] Intelligent question-and-answer technology allows users to submit natural language queries to the system, which directly returns answers that meet their needs, reducing manual intervention costs and transforming the process of acquiring information and knowledge into a one-question-one-answer format. This helps users get answers quickly and provides a better search experience. For content providers, placing answers at the top of the list increases exposure and traffic, contributing to the development of a content ecosystem.
[0072] Intelligent question-answering technology needs to directly return the answer to the user's question. That is to say, if the user enters "Who is the tallest person in the world" in the input box, the intelligent question-answering engine will analyze multiple user questions and extract the answer to the question from the massive text library: "Zhang San".
[0073] in, Figure 4 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application, such as Figure 4 As shown, it includes but is not limited to the following two modules: article retrieval module and answer extraction module. The specific process is as follows:
[0074] Article retrieval module, since the number of article libraries is very large, millions or tens of millions of articles, the retrieval module needs to retrieve the topK documents that are very relevant to the user's questions from such a large-scale document library.
[0075] S1, obtaining an information retrieval request, wherein the information retrieval request carries target question information (Q: Who launched the Chenqiao Mutiny in history?);
[0076] S2: Input the target question information (Q) and candidate answer information (Para1, Para2, ...) into the target question-answering prediction model, and convert the target question information into a target question representation vector through the target question-answering prediction model, and convert the candidate answer information into an original answer representation vector;
[0077] S3, converting the original answer representation vector into multiple answer representation vectors through the target question-answer prediction model, and determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector;
[0078] S4, using the target question-answering prediction model to determine the matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector;
[0079] S5, based on the matching degree between the target question information and the candidate answer information, determine whether the candidate answer information is answer information that matches the target question information, for example, Figure 4 As shown (Para1: Zhao Kuangyin, Para2: Zhao Kuangyin, Para3: Chai Shao, ...
[0080] Finally, the answer extraction module extracts Answer 1: Zhao Kuangyin, Answer 2: Chai Shao, Answer 3: Zhao Guangyi, ... from the answer information that matches the target question information. Among them, 0.9, 0.6, and 0.2 are the matching degrees between the target question information and the candidate answer information.
[0081] It should be noted that the “matching degree”, “matching score” and “similarity” described in this application have the same physical meaning.
[0082] The above is only an example and the embodiments of the present application do not impose any specific limitations.
[0083] in, Figure 5 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application, such as Figure 5 As shown, first, the two BERT models on the left are used to encode the user's target question and answer information and candidate answer information respectively.
[0084] Specifically, the target question and answer information and candidate answer information are tokenized and divided into individual words, and then two special tokens "[CLS]" and "[SEP]" are spliced together.
[0085] Then, a BERT model is used to take the output embedding vector of the [CLS] token as the representation vector of the target question and answer information (query) and the candidate answer information (doc).
[0086] However, since the candidate answer information is generally long, encoding it only into the original answer representation vector will definitely result in information loss. Therefore, the original answer representation vector is converted into multiple answer representation vectors through multiple linear transformations. The specific formula is as follows:
[0087] V k =W k V cls
[0088] Among them, V cls Represents the original answer representation vector, W k represents the transformation matrix (k=1,2,…), V k Represents multiple answer representation vectors after transformation.
[0089] After determining multiple answer representation vectors, use the target question representation vector to represent V k (k=1,2,…) is used for attention, and multiple answer representation vectors are weighted and aggregated into one vector:
[0090] S k = <V query , V k > (1)
[0091]
[0092] V doc =a k V1+…+a n V n (3)
[0093] Formula (1) is the inner product of the target question representation vector and the n answer representation vectors corresponding to the candidate answer information to obtain the matching score S k ; Formula (2) normalizes the matching score to obtain the weight a k , Formula (3) performs weighted summation on n answer representation vectors to obtain the final target answer representation vector.
[0094] Finally, the matching degree between the target question representation vector and the target answer representation vector is calculated to generate a loss. The loss can be determined by, but not limited to, a contrast loss function. In addition to calculating the matching degree (Score1) with the target answer representation vector, in order to allow subsequent retrieval to proceed in a quantitative retrieval manner, the target question representation vector and the first answer representation vector (V1) are also calculated for similarity (Score2) so that V1 can learn V. doc The main expression:
[0095] Score1=cos(V query , Vdoc )
[0096] Score2×cos(V query , V1)
[0097] The above is only an example and the embodiments of the present application do not impose any specific limitations.
[0098] Through this embodiment, an information retrieval request is obtained, wherein the information retrieval request carries target question information, the target question information and candidate answer information are input into a target question-answering prediction model, the target question information is converted into a target question representation vector through the target question-answering prediction model, and the candidate answer information is converted into an original answer representation vector, the original answer representation vector is converted into multiple answer representation vectors through the target question-answering prediction model, and based on the multiple answer representation vectors, a target answer representation vector for representing the candidate answer information is determined, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector, and the target question-answering prediction model is used to select the target question representation vector according to the target question representation vector. The feature vector and the target answer representation vector are used to determine the matching degree between the target question information and the candidate answer information. According to the matching degree between the target question information and the candidate answer information, it is determined whether the candidate answer information is the answer information that matches the target question information. Through the multi-mode vector question and answer retrieval model, a multi-mode matching method is adopted to generate multiple answer representation vectors for each candidate answer information, and then match them with the target question representation vector. The candidate answer information is more accurately encoded into multiple answer representation vectors, thereby achieving the purpose of avoiding information loss, thereby realizing the technical effect of improving the retrieval accuracy of the question and answer retrieval model, and then solving the technical problem of low retrieval accuracy of the question and answer retrieval model in related technologies.
[0099] As an optional solution, the target question-answering prediction model is used to convert the original answer representation vector into multiple answer representation vectors, including:
[0100] Obtaining a plurality of preset different transformation matrices, wherein each transformation matrix is used to perform a linear transformation on the original answer representation vector;
[0101] Each of the multiple different transformation matrices is multiplied by the original answer representation vector to obtain multiple answer representation vectors.
[0102] Optionally, in an embodiment of the present application, the above-mentioned different transformation matrices are multiple different parameter matrices preset by the system. During the training process, the parameters of the above-mentioned transformation matrices are adjusted so that the value of the loss function meets the preset convergence conditions.
[0103] Optionally, in an embodiment of the present application, multiplying each of the multiple different transformation matrices by the original answer representation vector may be implemented, including but not limited to, by the following formula:
[0104] V k =W k V cls
[0105] Among them, V cls Represents the original answer representation vector, W k represents the transformation matrix (k=1,2,…), V k Represents multiple answer representation vectors after transformation.
[0106] As an optional solution, obtaining a plurality of preset different conversion matrices includes: determining the keyword attribute of the target question information according to the information retrieval request; when the keyword attribute represents the part of speech of the answer searched for by the target question information, obtaining a plurality of preset different part-of-speech conversion matrices; multiplying each conversion matrix in the plurality of different conversion matrices by the original answer representation vector to obtain a plurality of answer representation vectors, including: multiplying each conversion matrix in the plurality of different part-of-speech conversion matrices by the original answer representation vector to obtain a plurality of answer representation vectors.
[0107] Optionally, in an embodiment of the present application, the above-mentioned keyword attributes may include but are not limited to being determined based on the semantics of the target question information. For example, when the above-mentioned target question information is used to search for nouns, the above-mentioned keyword attributes indicate that the part of speech of the searched answer is a noun. At this time, the parameters in the above-mentioned multiple different conversion matrices are configured as a conversion matrix for searching for nouns.
[0108] For example, the weight value of the conversion matrix used to search for nouns in multiple different conversion matrices can be increased, and the weight value of the conversion matrix used to search for verbs can be reduced, so as to obtain multiple answer representation vectors that meet the content searched for by the target question information based on keyword attributes.
[0109] As an optional solution, obtaining multiple preset different transformation matrices includes: splitting the candidate answer information into multiple sentences and identifying the semantic information of the multiple sentences; obtaining multiple different semantic transformation matrices corresponding to the semantic information of the multiple sentences; multiplying each transformation matrix in the multiple different transformation matrices by the original answer representation vector to obtain multiple answer representation vectors, including: multiplying each transformation matrix in the multiple different semantic transformation matrices by the original answer representation vector to obtain multiple answer representation vectors.
[0110] Optionally, in an embodiment of the present application, the above-mentioned splitting of the candidate answer information into multiple sentences may include but is not limited to splitting the paragraph corresponding to the candidate answer information into multiple sentences according to the semantics of the target question information, wherein a corresponding transformation matrix is configured for each matrix to realize multiplying each transformation matrix in multiple different semantic transformation matrices with the original answer representation vector to obtain multiple answer representation vectors. For example, when the above-mentioned candidate answer information includes 5 sentences, semantic recognition is performed on the candidate answer information to determine that the semantics recognized by 4 of the sentences belong to relevant content required by the business. At this time, a semantic transformation matrix is configured for each sentence, and the above-mentioned multiple answer representation vectors are determined from the above-mentioned 4 sentences with different weights.
[0111] For example, different weight values may be configured for different semantics in a plurality of different transformation matrices, so as to obtain a plurality of answer representation vectors that meet the content sought by the target question information according to the semantic information of the sentence.
[0112] As an optional solution, a target answer representation vector for representing candidate answer information is determined based on multiple answer representation vectors, including:
[0113] In the case where the multiple answer representation vectors are n answer representation vectors, performing an inner product operation on the target question representation vector and each of the n answer representation vectors, respectively, to obtain n matching values in total, where n is a positive integer greater than or equal to 2;
[0114] Obtain the ratio of each of the n matching values to the target matching sum to obtain n weight values, where the target matching sum is the sum of the n matching values;
[0115] Use n weight values to perform weighted summation on n answer representation vectors to obtain the target answer representation vector.
[0116] Optionally, in the embodiment of the present application, after determining multiple answer representation vectors, the target question representation vector is used to represent V k (k=1,2,…) perform attention (inner product operation) and aggregate multiple answer representation vectors into a weighted vector:
[0117] S k = <V query , V k > (1)
[0118]
[0119] V doc =a k V1+…+a n V n (3)
[0120] Formula (1) is the inner product of the target question representation vector and the n answer representation vectors corresponding to the candidate answer information to obtain the matching score S k ; Formula (2) normalizes the matching score to obtain the weight a k , Formula (3) performs weighted summation on n answer representation vectors to obtain the final target answer representation vector.
[0121] It should be noted that, in the case where the multiple answer representation vectors are n answer representation vectors, the inner product operation is performed on the target question representation vector and each of the n answer representation vectors, which is the content expressed by the above formula (1). The ratio of each matching value in the n matching values to the total target matching is obtained to obtain n weight values, which is the content expressed by the above formula (2). The weighted summation of the n answer representation vectors using n weight values to obtain the target answer representation vector is the content expressed by the above formula (3).
[0122] Through the embodiments of the present application, by using n weight values to perform weighted summation on n answer representation vectors, the information recorded in different answer representation vectors can be applied to the above-mentioned target answer representation vector with different weights, thereby ensuring that the candidate answer information corresponding to the target answer representation vector will not be lost too much, and the candidate answer information can be more accurately encoded into multiple answer representation vectors, thereby achieving the purpose of avoiding information loss, thereby realizing the technical effect of improving the retrieval accuracy of the question and answer retrieval model, and thus solving the technical problem of low retrieval accuracy of the question and answer retrieval model in related technologies.
[0123] As an optional solution, the above method further includes:
[0124] Obtaining a set of question-answer information sample pairs, a sample question information set, and a sample answer information set, wherein each question-answer information sample pair in the set of question-answer information sample pairs includes sample question information and annotated sample answer that matches the sample question information;
[0125] A set of question-answer information sample pairs, a sample question information set, and a sample answer information set are used to perform multiple rounds of training on the question-answer prediction model to be trained. When the value of the preset loss function corresponding to the question-answer prediction model to be trained meets the preset convergence condition, the training is terminated, and the question-answer prediction model to be trained at the end of the training is determined as the target question-answer prediction model.
[0126] Optionally, in an embodiment of the present application, the above-mentioned set of question-answer information sample pairs may include but is not limited to pre-collected <question, answer>, such as "<Who is Zhang San's brother?, Wang Wu>".
[0127] Optionally, in an embodiment of the present application, the above-mentioned preset loss function may include but is not limited to a contrast loss function, and the number of rounds of the above-mentioned multiple training rounds may be configured so that the value of the preset loss function satisfies a preset convergence condition, and may also include but is not limited to simultaneously setting the maximum number of rounds and the value of the preset loss function to satisfy any one of the preset convergence conditions.
[0128] As an optional solution, a set of question-answer information sample pairs, a sample question information set, and a sample answer information set are used to perform multiple rounds of training on the question-answer prediction model to be trained, including:
[0129] In the i-th round of training in multiple rounds of training, when the target sample question information in the question-answering prediction model to be trained input in the i-th round is the sample question information in the sample question information set, the sample question information set and the sample answer information set used in the i+1-th round of training are updated according to the target sample question information and the target sample answer information. The target sample answer information is the sample answer information obtained by labeling the answer information determined by the question-answering prediction model to be trained in the i-th round of training according to the sample answers of a set of question-answer information sample pairs, and i is a positive integer greater than or equal to 1.
[0130] Optionally, in an embodiment of the present application, the target sample question information used in the i-th round in the above-mentioned input question and answer prediction model to be trained is the sample question information in the sample question information set, which may include but is not limited to the target sample question information input into the question and answer prediction model in the i-th round is "Who is Zhang San's brother?", and the sample question information set includes the sample question information "Who is Zhang San's brother?". At this time, the sample question information set and the sample answer information set used in the i+1 round of training are updated according to the target sample question information and the target sample answer information. For example, the target sample answer information includes answer information including the answer "Wang Wu". At this time, the answer information including the answer "Wang Wu" is determined as the above-mentioned target sample answer information and updated to the sample answer information set as the sample answer information set used in the i+1 round of training.
[0131] For example, Figure 6 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application, such as Figure 6 As shown, first, according to the question information (Query: Who wrote the medical book Compendium of Materia Medica), the topK related answer information (answer information 602 and answer information 604) is retrieved from the answer information database, and then the answer to the question (Answer: Li Shizhen) is used to back-label these retrieved answer information. If the corresponding answer can be found and labeled, it is considered a positive sample (answer information 602). If the corresponding answer cannot be found and labeled, it is considered a negative sample (answer information 604), so as to construct a large amount of training data.
[0132] Through the embodiments of the present application, a set of question-answer information sample pairs is used to construct a large number of training samples (sample question information set and sample answer information set), which solves the technical problem of high training costs caused by the difficulty in obtaining training samples when training supervised models.
[0133] As an optional solution, a set of question-answer information sample pairs, a sample question information set, and a sample answer information set are used to perform multiple rounds of training on the question-answer prediction model to be trained, including:
[0134] In the i-th round of training, sample question information used in the i-th round is selected from a set of question-answer information sample pairs and a set of sample question information. The following steps are performed for each sample answer information in the set of sample question information and sample answer information used in the i-th round. When performing the following steps, the sample question information used in the i-th round is the current sample question information, and each sample answer information is the current sample answer information:
[0135] Input the current sample question information and the current sample answer information into the question-answering prediction model. The question-answering prediction model obtained through the i-1th round of training converts the current sample question information into the current sample question representation vector, and converts the current sample answer information into the current sample original answer representation vector;
[0136] The question-answer prediction model obtained through the i-1th round of training converts the current sample original answer representation vector into multiple current sample answer representation vectors, and determines the current sample target answer representation vector based on the multiple current sample answer representation vectors, wherein the current sample target answer representation vector is used to represent the current sample answer information, and the multiple current sample answer representation vectors are vectors obtained by performing different linear transformations on the current sample original answer representation vector;
[0137] The question-answer prediction model obtained through the i-1th round of training determines the matching degree between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector;
[0138] According to the matching degree between the current sample question information and the current sample answer information, the value of the preset loss function is determined, and the training is terminated when the value of the preset loss function meets the preset convergence condition; when the value of the preset loss function does not meet the preset convergence condition, the parameters in the question-answering prediction model obtained in the i-1th round of training are adjusted to obtain the question-answering prediction model obtained in the i-th round of training.
[0139] Optionally, in an embodiment of the present application, the 0th round of training may be performed, but is not limited to, in the following manner. The question-answer prediction model obtained by the 0th round of training is an untrained question-answer prediction model to be trained, which may include but is not limited to the bm25 model, which is fast, unsupervised, does not require training data, and implements a relatively low-cost question-answer prediction model.
[0140] Optionally, in an embodiment of the present application, the current sample question information and the current sample answer information are input into the question and answer prediction model, and the question and answer prediction model obtained through the i-1th round of training converts the current sample question information into a current sample question representation vector, and converts the current sample answer information into a current sample original answer representation vector, which may include but is not limited to converting the sample question information and sample answer information used in the i-1th round of training through the question and answer prediction model obtained through the i-1th round of training to obtain the above-mentioned current sample question representation vector and current sample original answer representation vector.
[0141] Optionally, in an embodiment of the present application, the above-mentioned adjustment of parameters in the question and answer prediction model obtained in the i-1 round of training to obtain the question and answer prediction model obtained in the i-th round of training may include but is not limited to adjusting multiple different transformation matrices in the question and answer prediction model to obtain the question and answer prediction model obtained in the i-th round of training.
[0142] For example, Figure 7 is a schematic diagram of another optional information retrieval method according to an embodiment of the present application, such as Figure 7 As shown, in the i-1th round of training:
[0143] 1. Use the current model model i-1 right<q,a> pair (corresponding to a question-answer information sample pair in the aforementioned set of question-answer information sample pairs) q recall topK sample answer information (the initial model model0 can use the unsupervised algorithm such as bm25), where,<q,p> Indicates the above current sample question information and the above current sample answer information;
[0144] 2. Use a to retrieve the sample answer information of the label recall to obtain distant supervision positive and negative samples;
[0145] 3. Combine training data to train a new model and get the model i .
[0146] Through the above iterative training method, the quality of the constructed distant supervision training data can be continuously improved, making the matching effect of the question-answering retrieval model better.
[0147] It should be noted that each round of training process may include but is not limited to the following: Figure 5As shown in the figure, first, the two BERT models on the left are used to encode the current sample question information and the current sample answer information respectively.
[0148] Specifically, the current sample question information and the current sample answer information are tokenized, divided into individual words, and two special tokens "[CLS]" and "[SEP]" are spliced before and after.
[0149] Then, through a BERT model, the output embedding vector of [CLS] token is taken as the current sample question representation vector and the current sample original answer representation vector.
[0150] However, since the sample answer information in the sample answer information set is generally long, encoding it only into the current sample original answer representation vector will definitely result in information loss. Therefore, the current sample original answer representation vector is converted into multiple current sample answer representation vectors through multiple linear transformations. The specific formula is as follows:
[0151] V k =W k V cls
[0152] Among them, V cls Represents the original answer representation vector of the current sample, W k represents the transformation matrix (k=1,2,…), V k Represents multiple current sample answer representation vectors after conversion.
[0153] After determining multiple current sample answer representation vectors, use the current sample question representation vector to represent V k (k=1,2,…) is used for attention, and multiple current sample answer representation vectors are weighted and aggregated into one vector:
[0154] S k = <V query , V k > (1)
[0155]
[0156] V doc =a k V1+…+a n V n (3)
[0157] Formula (1) is the inner product of the current sample question representation vector and the n current sample answer representation vectors corresponding to the sample answer information to obtain the matching score S k ; Formula (2) normalizes the matching score to obtain the weight a k, Formula (3) performs weighted summation on the n answer representation vectors to obtain the final current sample target answer representation vector.
[0158] Finally, the matching degree between the current sample question representation vector and the current sample target answer representation vector is calculated to generate Loss. Loss can be determined by, but not limited to, the contrast loss function. In addition to calculating the matching degree (Score1) with the target answer representation vector, in order to allow subsequent retrieval to proceed to the quantitative retrieval method, the target question representation vector and the first answer representation vector (V1) are also calculated with similarity (Score2) so that V1 can learn V. doc The main expression:
[0159] The above is only an example, and the embodiments of the present application do not impose any specific limitations.
[0160] As an optional solution,
[0161] The question-answer prediction model obtained through the i-1th round of training determines the matching degree between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector, including: obtaining a first distance between the current sample question representation vector and the current sample target answer representation vector, and determining the obtained first distance as the matching degree between the current sample question information and the current sample answer information;
[0162] Based on the degree of matching between the current sample question information and the current sample answer information, the value of the preset loss function is determined, including: obtaining the second distance between the current sample question representation vector and the first sample target answer representation vector, wherein the multiple current sample answer representation vectors include the first sample answer representation vector; based on the first distance and the second distance, the value of the preset loss function is determined, wherein the multiple current sample answer representation vectors include the first sample answer representation vector.
[0163] Optionally, in an embodiment of the present application, the first distance between the current sample question representation vector and the current sample target answer representation vector may include but is not limited to determining the first distance based on the cosine value between the current sample question representation vector and the current sample target answer representation vector, and the second distance between the current sample question representation vector and the first sample target answer representation vector may include but is not limited to determining the second distance based on the cosine value between the current sample question representation vector and the first sample target answer representation vector, wherein the multiple current sample answer representation vectors include the first sample answer representation vector, and the value of the preset loss function determined based on the first distance and the second distance may include but is not limited to determining by the following formula:
[0164] Score1=cos(V query , Vdoc )
[0165] Score2=cos(V query , V1)
[0166] Loss1=max(0,1-(Score1 + -Score 1 - ))
[0167] Loss2=max(0,1-(Score2 + -Score2 - ))
[0168] Loss match =Loss1+Loss2
[0169] Among them, Score1 represents the matching degree determined according to the first distance, Score2 represents the matching degree determined according to the second distance, and Loss match Represents the value of the above preset loss function, Loss match is the sum of Loss1 and Loss2, Score + Indicates the matching degree between the sample question and answer information and the positive sample answer information, Score - The matching degree between the sample question and answer information and the negative sample answer information.
[0170] As an optional solution, determining the value of the preset loss function according to the first distance and the second distance includes:
[0171] Concatenate the current sample question representation vector and the current sample target answer representation vector to obtain the current concatenated vector;
[0172] Determine the target probability that the current sample answer information is the labeled answer information that matches the current sample question information based on the current splicing vector;
[0173] The value of the preset loss function is determined according to the first distance, the second distance and the target probability.
[0174] Optionally, in an embodiment of the present application, the above-mentioned splicing of the current sample question representation vector and the current sample target answer representation vector may include but is not limited to adding special tokens: [CLS] and [SEP] before and after the current sample question representation vector and the current sample target answer representation vector, respectively, to obtain the above-mentioned current splicing vector (CLS vector), performing a binary classification operation on the above-mentioned CLS vector, and using the binary classification probability to distill the matching score Score:
[0175] Loss distill =(Prob-Score) 2
[0176] Prob is the probability that the binary classification output by the teacher model is a positive example, and Score is the matching score between the query (question representation vector) and doc (target answer representation vector) mentioned above (since the value range of cosine is [-1, 1], the value range will be converted to [0, 1], for example, (Score+1) / 2 is executed on Score).
[0177] Finally, the value of the preset loss function is determined by the following formula:
[0178] Loss final =Loss match +Loss distill
[0179] Through the embodiments of the present application, in order to further improve the retrieval effect of the question-answer retrieval model, an interactive matching model is used to distill the matching degree during the training process of the question-answer retrieval model, which more significantly improves the retrieval accuracy of the question-answer retrieval module.
[0180] As an optional solution, determining whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information includes:
[0181] In a case where the candidate answer information set includes N answer information, determining whether the ranking position of the matching degree between the target question information and the candidate answer information is in the top K among the N matching degrees arranged from largest to smallest according to the matching degree, wherein the N matching degrees include the matching degrees between the target question information and each piece of answer information in the candidate answer information set, the N answer information includes the candidate answer information, N is a positive integer greater than or equal to 2, K is a positive integer greater than or equal to 1, N is greater than K, and the matching degree between the target question information and each piece of answer information is determined in the same manner as the matching degree between the target question information and the candidate answer information;
[0182] When it is determined that the ranking position of the matching degree between the target question information and the candidate answer information is in the top K, the candidate answer information is determined as the answer information matching the target question information.
[0183] Optionally, in the embodiment of the present application, the above determination of whether the ranking position of the matching degree between the target question information and the candidate answer information is in the top K can be understood as inputting the target question information into the above pre-trained target question-answer prediction model to obtain multiple answer information and corresponding matching degrees, such as Figure 4As shown, by judging whether the ranking position of the matching degree of the candidate answer information is in the top K, it is determined whether the candidate answer information is the answer information that matches the target question information, and then the candidate answer information is input into the downstream task module for subsequent processing.
[0184] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0185] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0186] According to another aspect of the embodiment of the present application, an information retrieval device for implementing the above-mentioned information retrieval method is also provided. Figure 8 As shown, the device includes:
[0187] An acquisition module 802 is configured to acquire an information retrieval request, wherein the information retrieval request carries target question information;
[0188] A conversion module 804 is configured to input the target question information and candidate answer information into a target question-answering prediction model, convert the target question information into a target question representation vector, and convert the candidate answer information into an original answer representation vector through the target question-answering prediction model;
[0189] a processing module 806 configured to convert the original answer representation vector into multiple answer representation vectors using the target question-answer prediction model, and determine a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector;
[0190] A first determination module 808 is configured to determine a matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector using the target question and answer prediction model;
[0191] The second determining module 810 is configured to determine whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information. An information retrieval request is obtained, wherein the information retrieval request carries the target question information;
[0192] As an optional solution, the apparatus is configured to convert the original answer representation vector into multiple answer representation vectors using the target question-answer prediction model in the following manner:
[0193] Acquire a plurality of preset different transformation matrices, wherein each of the transformation matrices is used to perform a linear transformation on the original answer representation vector;
[0194] Each of the multiple different transformation matrices is multiplied by the original answer representation vector to obtain the multiple answer representation vectors.
[0195] As an optional solution, the apparatus is configured to obtain a plurality of preset different conversion matrices by: determining a keyword attribute of the target question information according to the information retrieval request; and obtaining a plurality of preset different part-of-speech conversion matrices when the keyword attribute represents the part of speech of the answer to be searched for by the target question information;
[0196] The device is used to multiply each of the multiple different transformation matrices by the original answer representation vector in the following manner to obtain the multiple answer representation vectors: multiply each of the multiple different part-of-speech transformation matrices by the original answer representation vector to obtain the multiple answer representation vectors.
[0197] As an optional solution, the device is used to obtain a plurality of preset different transformation matrices by: splitting the candidate answer information into a plurality of sentences, identifying semantic information of the plurality of sentences; obtaining a plurality of different semantic transformation matrices corresponding to the semantic information of the plurality of sentences;
[0198] The device is used to multiply each of the multiple different transformation matrices by the original answer representation vector in the following manner to obtain the multiple answer representation vectors: multiply each of the multiple different semantic transformation matrices by the original answer representation vector to obtain the multiple answer representation vectors.
[0199] As an optional solution, the apparatus is configured to determine a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors in the following manner:
[0200] In a case where the plurality of answer representation vectors is n answer representation vectors, performing an inner product operation on the target question representation vector and each of the n answer representation vectors to obtain a total of n matching values, where n is a positive integer greater than or equal to 2;
[0201] Obtaining a ratio of each of the n matching values to a target matching sum to obtain n weight values, wherein the target matching sum is the sum of the n matching values;
[0202] The n answer representation vectors are weightedly summed using the n weight values to obtain the target answer representation vector.
[0203] As an optional solution, the device is also used for:
[0204] Obtaining a set of question-answer information sample pairs, a sample question information set, and a sample answer information set, wherein each question-answer information sample pair in the set of question-answer information sample pairs includes sample question information and a marked sample answer that matches the sample question information;
[0205] The question-answer prediction model to be trained is trained for multiple rounds using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set. When the value of the preset loss function corresponding to the question-answer prediction model to be trained meets the preset convergence condition, the training is terminated, and the question-answer prediction model to be trained at the end of the training is determined as the target question-answer prediction model.
[0206] As an optional solution, the apparatus is configured to perform multiple rounds of training on the question-answer prediction model to be trained using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set in the following manner:
[0207] In the i-th round of training in the multiple rounds of training, when the target sample question information input into the question and answer prediction model to be trained in the i-th round is the sample question information in the sample question information set, the sample question information set and the sample answer information set used in the i+1-th round of training are updated according to the target sample question information and the target sample answer information, and the target sample answer information is the sample answer information obtained by labeling the answer information determined by the question and answer prediction model to be trained in the i-th round of training according to the sample answers of the set of question and answer information sample pairs, and i is a positive integer greater than or equal to 1.
[0208] As an optional solution, the apparatus is configured to perform multiple rounds of training on the question-answer prediction model to be trained using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set in the following manner:
[0209] In the i-th round of training, sample question information used in the i-th round is selected from the sample question information set, and the following steps are performed for the sample question information used in the i-th round and each sample answer information in the sample answer information set, wherein when performing the following steps, the sample question information used in the i-th round is current sample question information, and each sample answer information is current sample answer information:
[0210] Input the current sample question information and the current sample answer information into the question-answer prediction model, and convert the current sample question information into a current sample question representation vector and the current sample answer information into a current sample original answer representation vector through the question-answer prediction model obtained by the i-1th round of training;
[0211] The question-answer prediction model obtained by the i-1th round of training converts the current sample original answer representation vector into multiple current sample answer representation vectors, and determines the current sample target answer representation vector based on the multiple current sample answer representation vectors, wherein the multiple current sample answer representation vectors are vectors obtained by performing different linear transformations on the current sample original answer representation vector;
[0212] The question-answer prediction model obtained through the i-1th round of training determines the matching degree between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector;
[0213] According to the matching degree between the current sample question information and the current sample answer information, the value of the preset loss function is determined, and when the value of the preset loss function meets the preset convergence condition, the training is terminated; when the value of the preset loss function does not meet the preset convergence condition, the parameters in the question and answer prediction model obtained by the i-1th round of training are adjusted to obtain the question and answer prediction model obtained by the i-1th round of training.
[0214] As an optional solution,
[0215] The device is used to determine the matching degree between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector by using the question-answer prediction model obtained through the i-1th round of training in the following manner: obtaining a first distance between the current sample question representation vector and the current sample target answer representation vector, and determining the obtained first distance as the matching degree between the current sample question information and the current sample answer information; the device is used to determine the value of the preset loss function based on the matching degree between the current sample question information and the current sample answer information in the following manner: obtaining a second distance between the current sample question representation vector and the first sample target answer representation vector, wherein the multiple current sample answer representation vectors include the first sample answer representation vector; determining the value of the preset loss function based on the first distance and the second distance, and the multiple current sample answer representation vectors include the first sample answer representation vector.
[0216] As an optional scheme, the device is used to determine the value of the preset loss function based on the first distance and the second distance in the following manner, including: splicing the current sample question representation vector and the current sample target answer representation vector to obtain a current splicing vector; determining the target probability that the current sample answer information is the marked answer information that matches the current sample question information based on the current splicing vector; determining the value of the preset loss function based on the first distance, the second distance and the target probability.
[0217] As an optional solution, the device is used to determine the matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector through the target question and answer prediction model in the following manner: obtaining the distance between the target question representation vector and the target answer representation vector, and determining the obtained distance as the matching degree between the target question information and the candidate answer information.
[0218] As an optional solution, the device is used to determine whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information in the following manner: when the candidate answer information set includes N answer information, among the N matching degrees arranged from large to small according to the matching degree, determine whether the ranking position of the matching degree between the target question information and the candidate answer information is in the top K, wherein the N matching degrees include the matching degrees of the target question information and each answer information in the candidate answer information set respectively, the N answer information includes the candidate answer information, N is a positive integer greater than or equal to 2, K is a positive integer greater than or equal to 1, N is greater than K, and the method for determining the matching degree between the target question information and each answer information is the same as the method for determining the matching degree between the target question information and the candidate answer information; when it is determined that the ranking position of the matching degree between the target question information and the candidate answer information is in the top K, the candidate answer information is determined as the answer information that matches the target question information.
[0219] According to one aspect of the present application, a computer program product is provided, comprising a computer program / instructions containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication portion 909 and / or installed from a removable medium 911. When the computer program is executed by the central processing unit 901, the various functions provided in the embodiments of the present application are performed.
[0220] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0221] Figure 9 The block diagram schematically shows a computer system structure of an electronic device used to implement an embodiment of the present application.
[0222] It should be noted that Figure 9 The computer system 900 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0223] like Figure 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage part 908 into the random access memory (RAM) 903. Various programs and data required for system operation are also stored in the random access memory 903. The CPU 901, the read-only memory 902, and the random access memory 903 are connected to each other via a bus 904. An input / output interface 905 (i.e., an I / O interface) is also connected to the bus 904.
[0224] The following components are connected to the input / output interface 905: an input section 906 including a keyboard, a mouse, and the like; an output section 907 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a local area network card or a modem. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the input / output interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like, is installed in the drive 910 as needed so that a computer program read therefrom can be installed into the storage section 908 as needed.
[0225] In particular, according to an embodiment of the present application, the processes described in the various method flow charts can be implemented as computer software programs. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods shown in the flow charts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909 and / or installed from a removable medium 911. When the computer program is executed by the central processing unit 901, the various functions defined in the system of the present application are performed.
[0226] According to another aspect of the embodiment of the present application, an electronic device for implementing the above information retrieval method is also provided. The electronic device may be Figure 1 The terminal device or server shown in FIG. This embodiment is described by taking the electronic device as a terminal device as an example. Figure 10As shown, the electronic device includes a memory 1002 and a processor 1004. The memory 1002 stores a computer program, and the processor 1004 is configured to execute the steps in any of the above method embodiments through the computer program.
[0227] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0228] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0229] S1, obtaining an information retrieval request, wherein the information retrieval request carries target question information;
[0230] S2, input the target question information and candidate answer information into the target question answering prediction model, and convert the target question information into a target question representation vector through the target question answering prediction model, and convert the candidate answer information into an original answer representation vector;
[0231] S3, converting the original answer representation vector into multiple answer representation vectors through the target question-answer prediction model, and determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector;
[0232] S4, using the target question-answering prediction model to determine the matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector;
[0233] S5: Determine whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information.
[0234] Alternatively, those skilled in the art will appreciate that Figure 10 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 10 It does not limit the structure of the electronic device. For example, the electronic device may also include Figure 10 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 10 Different configurations shown.
[0235] Among them, the memory 1002 can be used to store software programs and modules, such as program instructions / modules corresponding to the information retrieval method and device in the embodiments of the present application. The processor 1004 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002, that is, realizing the above-mentioned information retrieval method. The memory 1002 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1002 may further include a memory remotely located relative to the processor 1004, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1002 can be used for, but is not limited to, training data and other information. As an example, Figure 10 As shown, the memory 1002 may include, but is not limited to, the acquisition module 802, conversion module 804, processing module 806, first determination module 808, and second determination module 810 in the information retrieval device. Furthermore, the memory 1002 may also include, but is not limited to, other module units in the information retrieval device, which will not be described in detail in this example.
[0236] Optionally, the transmission device 1006 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1006 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1006 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0237] In addition, the electronic device further includes: a display 1008 for displaying the information retrieval request; and a connection bus 1010 for connecting various module components in the electronic device.
[0238] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes through network communication. The nodes may form a peer-to-peer (P2P) network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0239] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the information retrieval method provided in various optional implementations of the above-mentioned information retrieval aspects.
[0240] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0241] S1, obtaining an information retrieval request, wherein the information retrieval request carries target question information;
[0242] S2, input the target question information and candidate answer information into the target question answering prediction model, and convert the target question information into a target question representation vector through the target question answering prediction model, and convert the candidate answer information into an original answer representation vector;
[0243] S3, converting the original answer representation vector into multiple answer representation vectors through the target question-answer prediction model, and determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors, wherein the multiple answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector;
[0244] S4, using the target question-answering prediction model to determine the matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector;
[0245] S5: Determine whether the candidate answer information is answer information that matches the target question information based on the matching degree between the target question information and the candidate answer information.
[0246] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0247] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0248] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application.
[0249] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0250] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, and can be electrical or other forms.
[0251] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0252] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0253] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. An information retrieval method, characterized in that: include: Obtaining an information retrieval request, wherein the information retrieval request carries target question information; Inputting the target question information and candidate answer information into a target question-answering prediction model, converting the target question information into a target question representation vector through the target question-answering prediction model, and converting the candidate answer information into an original answer representation vector; The original answer representation vector is converted into multiple answer representation vectors through the target question-answer prediction model, including: obtaining a plurality of preset different transformation matrices, wherein each of the transformation matrices is used to perform a linear transformation on the original answer representation vector, and the plurality of different transformation matrices include a semantic transformation matrix configured for each sentence after splitting the paragraph corresponding to the candidate answer information into multiple sentences according to the semantics of the target question information; multiplying each of the plurality of different transformation matrices by the original answer representation vector to obtain the plurality of answer representation vectors, and determining a target answer representation vector for representing the candidate answer information based on the plurality of answer representation vectors, wherein the plurality of answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector; Determining the matching degree between the target question information and the candidate answer information according to the target question representation vector and the target answer representation vector by the target question answer prediction model; According to the matching degree between the target question information and the candidate answer information, it is determined whether the candidate answer information is answer information that matches the target question information.
2. The method according to claim 1, characterized in that The obtaining of a plurality of preset different conversion matrices includes: determining a keyword attribute of the target question information according to the information retrieval request; and obtaining a plurality of preset different part-of-speech conversion matrices when the keyword attribute represents the part of speech of the answer to the target question information; The multiplying each of the multiple different conversion matrices by the original answer representation vector to obtain the multiple answer representation vectors includes: multiplying each of the multiple different part-of-speech conversion matrices by the original answer representation vector to obtain the multiple answer representation vectors.
3. The method according to claim 1, characterized in that The obtaining of the preset multiple different conversion matrices includes: splitting the candidate answer information into multiple sentences, identifying semantic information of the multiple sentences; obtaining multiple different semantic conversion matrices corresponding to the semantic information of the multiple sentences; The multiplying each of the multiple different transformation matrices by the original answer representation vector to obtain the multiple answer representation vectors includes: multiplying each of the multiple different semantic transformation matrices by the original answer representation vector to obtain the multiple answer representation vectors.
4. The method according to claim 1, wherein The step of determining a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors includes: In a case where the plurality of answer representation vectors is n answer representation vectors, performing an inner product operation on the target question representation vector and each of the n answer representation vectors to obtain a total of n matching values, where n is a positive integer greater than or equal to 2; Obtaining a ratio of each of the n matching values to a target matching sum to obtain n weight values, wherein the target matching sum is the sum of the n matching values; The n answer representation vectors are weightedly summed using the n weight values to obtain the target answer representation vector.
5. The method according to claim 1, wherein The method further comprises: Obtaining a set of question-answer information sample pairs, a sample question information set, and a sample answer information set, wherein each question-answer information sample pair in the set of question-answer information sample pairs includes sample question information and a marked sample answer that matches the sample question information; The question-answer prediction model to be trained is trained for multiple rounds using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set. When the value of the preset loss function corresponding to the question-answer prediction model to be trained meets the preset convergence condition, the training is terminated, and the question-answer prediction model to be trained at the end of the training is determined as the target question-answer prediction model.
6. The method according to claim 5, characterized in that The step of performing multiple rounds of training on the question-answer prediction model to be trained using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set includes: In the i-th round of training in the multiple rounds of training, when the target sample question information input into the question and answer prediction model to be trained in the i-th round is the sample question information in the sample question information set, the sample question information set and the sample answer information set used in the i+1-th round of training are updated according to the target sample question information and the target sample answer information, and the target sample answer information is the sample answer information obtained by labeling the answer information determined by the question and answer prediction model to be trained in the i-th round of training according to the sample answers of the set of question and answer information sample pairs, and i is a positive integer greater than or equal to 1.
7. The method according to claim 5, characterized in that The step of performing multiple rounds of training on the question-answer prediction model to be trained using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set includes: In an i-th round of training among the multiple rounds of training, sample question information used in the i-th round is selected from the sample question information set, and the following steps are performed for the sample question information used in the i-th round and each sample answer information in the sample answer information set, wherein i is a positive integer greater than or equal to 1. When performing the following steps, the sample question information used in the i-th round is current sample question information, and each sample answer information is current sample answer information: Input the current sample question information and the current sample answer information into the question-answer prediction model, and convert the current sample question information into a current sample question representation vector and the current sample answer information into a current sample original answer representation vector through the question-answer prediction model obtained by the i-1th round of training; The question-answer prediction model obtained by the i-1th round of training converts the current sample original answer representation vector into multiple current sample answer representation vectors, and determines the current sample target answer representation vector based on the multiple current sample answer representation vectors, wherein the multiple current sample answer representation vectors are vectors obtained by performing different linear transformations on the current sample original answer representation vector; The question-answer prediction model obtained through the i-1th round of training determines the matching degree between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector; According to the matching degree between the current sample question information and the current sample answer information, the value of the preset loss function is determined, and when the value of the preset loss function meets the preset convergence condition, the training is terminated; when the value of the preset loss function does not meet the preset convergence condition, the parameters in the question and answer prediction model obtained by the i-1th round of training are adjusted to obtain the question and answer prediction model obtained by the i-1th round of training.
8. The method according to claim 7, characterized in that The question-answer prediction model obtained through the i-1th round of training determines the degree of match between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector, including: obtaining a first distance between the current sample question representation vector and the current sample target answer representation vector, and determining the obtained first distance as the degree of match between the current sample question information and the current sample answer information; The method of determining the value of the preset loss function based on the degree of matching between the current sample question information and the current sample answer information includes: obtaining a second distance between the current sample question representation vector and the first sample target answer representation vector, wherein the multiple current sample answer representation vectors include the first sample answer representation vector; and determining the value of the preset loss function based on the first distance and the second distance.
9. The method according to claim 8, characterized in that The determining a value of the preset loss function according to the first distance and the second distance includes: Splicing the current sample question representation vector and the current sample target answer representation vector to obtain a current splicing vector; Determining, based on the current splicing vector, a target probability that the current sample answer information is the labeled answer information that matches the current sample question information; The value of the preset loss function is determined according to the first distance, the second distance and the target probability.
10. The method according to any one of claims 1 to 9, characterized in that The determining, based on the degree of matching between the target question information and the candidate answer information, whether the candidate answer information is answer information matching the target question information includes: In the case where the candidate answer information set includes N answer information, determining whether the ranking position of the matching degree between the target question information and the candidate answer information is in the top K among the N matching degrees arranged from largest to smallest according to the matching degree, wherein the N matching degrees include the matching degrees between the target question information and each piece of answer information in the candidate answer information set, the N answer information includes the candidate answer information, N is a positive integer greater than or equal to 2, K is a positive integer greater than or equal to 1, N is greater than K, and the matching degree between the target question information and each piece of answer information is determined in the same manner as the matching degree between the target question information and the candidate answer information; When it is determined that the ranking position of the matching degree between the target question information and the candidate answer information is in the top K, the candidate answer information is determined as the answer information matching the target question information.
11. An information retrieval device, characterized in that: include: An acquisition module, configured to acquire an information retrieval request, wherein the information retrieval request carries target question information; a conversion module, configured to input the target question information and candidate answer information into a target question-answering prediction model, convert the target question information into a target question representation vector through the target question-answering prediction model, and convert the candidate answer information into an original answer representation vector; A processing module, configured to convert the original answer representation vector into a plurality of answer representation vectors through the target question-answer prediction model, comprising: obtaining a plurality of preset different transformation matrices, wherein each of the transformation matrices is used to perform a linear transformation on the original answer representation vector, and the plurality of different transformation matrices include a semantic transformation matrix configured for each sentence after splitting the paragraph corresponding to the candidate answer information into a plurality of sentences according to the semantics of the target question information; multiplying each of the plurality of different transformation matrices by the original answer representation vector to obtain the plurality of answer representation vectors, and determining a target answer representation vector for representing the candidate answer information based on the plurality of answer representation vectors, wherein the plurality of answer representation vectors are vectors obtained by performing different linear transformations on the original answer representation vector; A first determination module is configured to determine a matching degree between the target question information and the candidate answer information based on the target question representation vector and the target answer representation vector using the target question and answer prediction model; The second determining module is configured to determine whether the candidate answer information is answer information that matches the target question information based on a matching degree between the target question information and the candidate answer information.
12. The device according to claim 11, characterized in that The device is configured to obtain a plurality of preset different conversion matrices by: determining a keyword attribute of the target question information according to the information retrieval request; and obtaining a plurality of preset different part-of-speech conversion matrices when the keyword attribute represents the part of speech of the answer to the target question information; The device is used to multiply each of the multiple different transformation matrices by the original answer representation vector in the following manner to obtain the multiple answer representation vectors: multiply each of the multiple different part-of-speech transformation matrices by the original answer representation vector to obtain the multiple answer representation vectors.
13. The device according to claim 11, characterized in that The device is used to obtain a plurality of preset different transformation matrices by: splitting the candidate answer information into a plurality of sentences, identifying semantic information of the plurality of sentences; obtaining a plurality of different semantic transformation matrices corresponding to the semantic information of the plurality of sentences; The device is used to multiply each of the multiple different transformation matrices by the original answer representation vector in the following manner to obtain the multiple answer representation vectors: multiply each of the multiple different semantic transformation matrices by the original answer representation vector to obtain the multiple answer representation vectors.
14. The device according to claim 11, characterized in that The apparatus is configured to determine a target answer representation vector for representing the candidate answer information based on the multiple answer representation vectors in the following manner: In a case where the plurality of answer representation vectors is n answer representation vectors, performing an inner product operation on the target question representation vector and each of the n answer representation vectors to obtain a total of n matching values, where n is a positive integer greater than or equal to 2; Obtaining a ratio of each of the n matching values to a target matching sum to obtain n weight values, wherein the target matching sum is the sum of the n matching values; The n answer representation vectors are weightedly summed using the n weight values to obtain the target answer representation vector.
15. The device according to claim 11, characterized in that The device is also used for: Obtaining a set of question-answer information sample pairs, a sample question information set, and a sample answer information set, wherein each question-answer information sample pair in the set of question-answer information sample pairs includes sample question information and a marked sample answer that matches the sample question information; The question-answer prediction model to be trained is trained for multiple rounds using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set. When the value of the preset loss function corresponding to the question-answer prediction model to be trained meets the preset convergence condition, the training is terminated, and the question-answer prediction model to be trained at the end of the training is determined as the target question-answer prediction model.
16. The device according to claim 15, characterized in that The apparatus is configured to perform multiple rounds of training on the question-answer prediction model to be trained using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set in the following manner: In the i-th round of training in the multiple rounds of training, when the target sample question information input into the question and answer prediction model to be trained in the i-th round is the sample question information in the sample question information set, the sample question information set and the sample answer information set used in the i+1-th round of training are updated according to the target sample question information and the target sample answer information, and the target sample answer information is the sample answer information obtained by labeling the answer information determined by the question and answer prediction model to be trained in the i-th round of training according to the sample answers of the set of question and answer information sample pairs, and i is a positive integer greater than or equal to 1.
17. The device according to claim 15, characterized in that The apparatus is configured to perform multiple rounds of training on the question-answer prediction model to be trained using the set of question-answer information sample pairs, the sample question information set, and the sample answer information set in the following manner: In an i-th round of training among the multiple rounds of training, sample question information used in the i-th round is selected from the sample question information set, and the following steps are performed for the sample question information used in the i-th round and each sample answer information in the sample answer information set, wherein i is a positive integer greater than or equal to 1. When performing the following steps, the sample question information used in the i-th round is current sample question information, and each sample answer information is current sample answer information: Input the current sample question information and the current sample answer information into the question-answer prediction model, and convert the current sample question information into a current sample question representation vector and the current sample answer information into a current sample original answer representation vector through the question-answer prediction model obtained by the i-1th round of training; The question-answer prediction model obtained by the i-1th round of training converts the current sample original answer representation vector into multiple current sample answer representation vectors, and determines the current sample target answer representation vector based on the multiple current sample answer representation vectors, wherein the multiple current sample answer representation vectors are vectors obtained by performing different linear transformations on the current sample original answer representation vector; The question-answer prediction model obtained through the i-1th round of training determines the matching degree between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector; According to the matching degree between the current sample question information and the current sample answer information, the value of the preset loss function is determined, and when the value of the preset loss function meets the preset convergence condition, the training is terminated; when the value of the preset loss function does not meet the preset convergence condition, the parameters in the question and answer prediction model obtained by the i-1th round of training are adjusted to obtain the question and answer prediction model obtained by the i-1th round of training.
18. The device according to claim 17, characterized in that The apparatus is configured to determine the degree of matching between the current sample question information and the current sample answer information based on the current sample question representation vector and the current sample target answer representation vector using the question-answer prediction model obtained through the i-1th round of training in the following manner: obtaining a first distance between the current sample question representation vector and the current sample target answer representation vector, and determining the obtained first distance as the degree of matching between the current sample question information and the current sample answer information; The device is used to determine the value of the preset loss function based on the matching degree between the current sample question information and the current sample answer information in the following manner: obtaining a second distance between the current sample question representation vector and the first sample target answer representation vector, wherein the multiple current sample answer representation vectors include the first sample answer representation vector; and determining the value of the preset loss function based on the first distance and the second distance.
19. The device according to claim 18, characterized in that The device is configured to determine a value of the preset loss function according to the first distance and the second distance in the following manner: Splicing the current sample question representation vector and the current sample target answer representation vector to obtain a current splicing vector; Determining, based on the current splicing vector, a target probability that the current sample answer information is the labeled answer information that matches the current sample question information; The value of the preset loss function is determined according to the first distance, the second distance and the target probability.
20. The device according to any one of claims 11 to 19, characterized in that The device is configured to determine whether the candidate answer information is answer information that matches the target question information based on a degree of matching between the target question information and the candidate answer information in the following manner: In the case where the candidate answer information set includes N answer information, determining whether the ranking position of the matching degree between the target question information and the candidate answer information is in the top K among the N matching degrees arranged from largest to smallest according to the matching degree, wherein the N matching degrees include the matching degrees between the target question information and each piece of answer information in the candidate answer information set, the N answer information includes the candidate answer information, N is a positive integer greater than or equal to 2, K is a positive integer greater than or equal to 1, N is greater than K, and the matching degree between the target question information and each piece of answer information is determined in the same manner as the matching degree between the target question information and the candidate answer information; When it is determined that the ranking position of the matching degree between the target question information and the candidate answer information is in the top K, the candidate answer information is determined as the answer information matching the target question information.
21. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein the program can be executed by a terminal device or a computer to execute the method described in any one of claims 1 to 10.
22. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
23. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 10 through the computer program.
Citation Information
Patent Citations
A machine reading comprehension method based on threshold convolution neural network
CN109460553A
Question and answer matching method and device based on K-means clustering algorithm, equipment and medium
CN113918696A