Answer retrieval method and device, equipment, readable storage medium and program product
By extracting keywords from user questions and using similarity search algorithms, the problem of low answer search accuracy in traditional answer search methods is solved, and efficient answer acquisition is achieved when user questions are not standardized or short.
Patent Information
- Application Number
- CN202411222494.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-11-26
AI Technical Summary
Traditional answer search methods are difficult to obtain relevant FAQ corpus when user questions are not standardized or too brief, resulting in low accuracy in answer search.
By extracting the question keywords from user questions, using the preset keyword database for matching, and using the similarity search algorithm to calculate the similarity between the statement pair and the question keywords, pushing the recommended answer based on the similarity results.
Improve the accuracy and user experience of answer retrieval, especially when user questions are not standardized or short, and can quickly and accurately obtain relevant answers.
Smart Images

Figure CN119025660A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent question answering technology, and in particular to an answer retrieval method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of intelligent business systems, the demand for question retrieval in business systems continues to increase. In traditional methods, for questions input by users, the user's question is compared with each question in the FAQ (Frequently Asked Questions) corpus for similarity, and the answer corresponding to the question with the highest similarity score is used as the answer to the user's question. However, this method is difficult to obtain relevant FAQ corpus when the user's question is not standardized or too short, and there is a problem of low answer retrieval accuracy. Summary of the invention
[0003] Based on this, it is necessary to provide an answer retrieval method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the accuracy of answer retrieval in response to the above technical problems.
[0004] In a first aspect, the present application provides an answer retrieval method, comprising:
[0005] Obtaining a user question and extracting at least one question keyword from the user question;
[0006] Retrieve keywords from a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer;
[0007] Using a preset similarity retrieval algorithm, calculate the similarity between the sentence pair and each question keyword;
[0008] In the case that any similarity calculation result exceeds a preset similarity threshold, a recommended answer is determined based on the sentence pair corresponding to the similarity calculation result, and the recommended answer is pushed to the user.
[0009] In one embodiment, there are multiple sentence pairs; determining a recommended answer based on the sentence pairs corresponding to the similarity calculation results includes:
[0010] Sort each sentence pair based on the similarity calculation results corresponding to each of the multiple sentence pairs;
[0011] A target sentence pair that meets a preset similarity condition is determined from among the sorted multiple sentence pairs, and a target answer in the target sentence pair is used as a recommended answer.
[0012] In one embodiment, the answer retrieval method further includes:
[0013] Obtain recommended sentence pairs that do not meet the preset similarity condition among the sorted multiple sentence pairs;
[0014] The recommended sentence pairs are added to the recommended question set, and the recommended questions in the recommended question set are pushed to the user; the recommended questions are used for user selection and re-asking.
[0015] In one embodiment, the answer retrieval method further includes:
[0016] In the case where the keywords in the preset keyword library do not match all the question keywords, searching the questions in the preset question library and the answers in the preset answer library to determine the search results that match any of the question keywords; the search results include candidate questions that match any of the question keywords or candidate answers that match any of the question keywords;
[0017] Determine candidate sentence pairs based on the search results;
[0018] Using a preset similarity retrieval algorithm, calculate the candidate similarity between the candidate sentence pairs and each question keyword;
[0019] When any candidate similarity exceeds a preset similarity threshold, a candidate recommended answer is determined based on the candidate sentence corresponding to the candidate similarity, and the candidate recommended answer is recommended to the user.
[0020] In one embodiment, determining candidate sentence pairs based on the search results includes:
[0021] When the search results include a candidate question that matches any of the question keywords, obtain an answer corresponding to the candidate question, and form a candidate sentence pair with the candidate question and the corresponding answer;
[0022] In the case where the search results include candidate answers that match any of the question keywords, the question corresponding to the candidate answer is obtained, and the candidate answer and the corresponding question are combined into a candidate sentence pair.
[0023] In one embodiment, the answer retrieval method further includes:
[0024] When the similarity between all sentence pairs and the keywords of each question does not exceed the preset similarity threshold, a preset reply is pushed to the user.
[0025] In a second aspect, the present application also provides an answer retrieval device, comprising:
[0026] An acquisition module, used to acquire user questions and extract at least one question keyword from the user questions;
[0027] A construction module is used to retrieve keywords in a preset keyword library, and when there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer;
[0028] A calculation module, used to calculate the similarity between the sentence pair and each question keyword using a preset similarity retrieval algorithm;
[0029] The push module is used to determine the recommended answer based on the sentence pair corresponding to the similarity calculation result when any similarity calculation result exceeds a preset similarity threshold, and push the recommended answer to the user.
[0030] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0031] Obtaining a user question and extracting at least one question keyword from the user question;
[0032] Retrieve keywords from a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer;
[0033] Using a preset similarity retrieval algorithm, calculate the similarity between the sentence pair and each question keyword;
[0034] In the case that any similarity calculation result exceeds a preset similarity threshold, a recommended answer is determined based on the sentence pair corresponding to the similarity calculation result, and the recommended answer is pushed to the user.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0036] Obtaining a user question and extracting at least one question keyword from the user question;
[0037] Retrieve keywords from a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer;
[0038] Using a preset similarity retrieval algorithm, calculate the similarity between the sentence pair and each question keyword;
[0039] In the case that any similarity calculation result exceeds a preset similarity threshold, a recommended answer is determined based on the sentence pair corresponding to the similarity calculation result, and the recommended answer is pushed to the user.
[0040] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0041] Obtaining a user question and extracting at least one question keyword from the user question;
[0042] Retrieve keywords from a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer;
[0043] Using a preset similarity retrieval algorithm, calculate the similarity between the sentence pair and each question keyword;
[0044] In the case that any similarity calculation result exceeds a preset similarity threshold, a recommended answer is determined based on the sentence pair corresponding to the similarity calculation result, and the recommended answer is pushed to the user.
[0045] The above-mentioned answer retrieval method, apparatus, computer equipment, computer-readable storage medium and computer program product extract at least one question keyword from the user's question, use the keyword matching method to retrieve the target keyword that matches any question keyword in the preset keyword library, and form a sentence pair with the target question and the target answer corresponding to the target keyword, and then use the preset similarity retrieval algorithm to calculate the similarity between the sentence pair and each question keyword, and then determine the recommended answer based on the sentence pair whose similarity results exceed the preset similarity threshold, and push it to the user. This method of implementing hierarchical filtering retrieval of answers through keyword matching and similarity retrieval algorithm is conducive to improving the accuracy of answer retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 A diagram of an application environment of an answer retrieval method in one embodiment;
[0048] Figure 2 A schematic diagram of a flow chart of an answer retrieval method in one embodiment;
[0049] Figure 3 is a schematic diagram of the overall flow of an answer retrieval method in one embodiment;
[0050] Figure 4 is a structural block diagram of an answer retrieval device in one embodiment;
[0051] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] The answer retrieval method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. This embodiment uses the method applied to the terminal 102 as an example. It can be understood that the method can also be applied to the server 104, and can also be applied to a system including the terminal 102 and the server 104, and is implemented through the interaction between the terminal 102 and the server 104. The terminal 102 obtains the user's question and extracts at least one question keyword from the user's question; retrieves the keywords in the preset keyword library, and in the case where there is a target keyword matching any question keyword in the preset keyword library, obtains the target question and target answer corresponding to the target keyword, and forms a sentence pair with the target question and the target answer; uses a preset similarity retrieval algorithm to calculate the similarity between the sentence pair and each question keyword; in the case where any similarity calculation result exceeds the preset similarity threshold, determines the recommended answer based on the sentence pair corresponding to the similarity calculation result, and pushes the recommended answer to the user. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.
[0054] In an exemplary embodiment, Figure 2 As shown, an answer retrieval method is provided, which is applied to Figure 1 The terminal 102 in the example is used as an example to illustrate, including the following steps 202 to 208. Among them:
[0055] Step 202: Obtain a user question and extract at least one question keyword from the user question.
[0056] Among them, user questions refer to questions raised by users received by the terminal. In some embodiments, the terminal includes a human-computer interaction interface, and the terminal obtains user questions input by the user in the human-computer interaction interface. User questions are often determined by the application scenario of the answer retrieval method. For example, the answer retrieval method is applied to a business system, and the user question may be a question about a business process in the business system, or a search for a business notification in the business system, etc. Through the answer retrieval method, the answer to the question can be pushed to the user. For another example, the answer retrieval method is applied to a fault diagnosis system, and the user question may be a description of the fault, or a fault code, etc. Through the answer retrieval method, the corresponding fault type can be pushed to the user.
[0057] Question keywords refer to the key words in user questions. Question keywords can describe the main content of user questions. One or more question keywords can be extracted from a user question.
[0058] Step 204, searching for keywords in the preset keyword library, and when there is a target keyword matching any question keyword in the preset keyword library, obtaining a target question and a target answer corresponding to the target keyword, and forming the target question and the target answer into a sentence pair.
[0059] Among them, the preset keyword library refers to a database connected to the terminal, or a database in the terminal. The preset keyword library pre-stores multiple keywords related to the application scenario. The terminal retrieves the keywords in the preset keyword library and compares the question keywords with each keyword respectively. The target keyword refers to the keyword that matches any keyword in the preset keyword library. The target keyword matches the question keyword means that the two are exactly the same, or the similarity between the two exceeds a preset threshold. In some embodiments, the Levenshtein distance algorithm or the text vector distance algorithm can be used to determine the target keyword that matches the question keyword.
[0060] The target question refers to the question corresponding to the target keyword in the preset question library. The target answer refers to the answer corresponding to the target keyword in the preset answer library.
[0061] There is a preset correspondence between each keyword in the preset keyword library, each question in the preset question library, and each answer in the preset answer library. The terminal queries the preset correspondence to determine the target question and target answer corresponding to the target keyword.
[0062] A sentence pair consists of a target question and a target answer.
[0063] Step 206: Use a preset similarity search algorithm to calculate the similarity between the sentence pair and each question keyword.
[0064] The preset similarity retrieval algorithm refers to a text similarity calculation algorithm. For example, the BM25 (Best Matching 25, an information retrieval algorithm) algorithm may be used. The BM25 algorithm calculates similarity by the matching degree between the query statement pair and each question keyword.
[0065] In some embodiments, for any question keyword, a first similarity between the target question in the sentence pair and the current question keyword is calculated, a second similarity between the target answer in the sentence pair and the current question keyword is calculated, and a preset coefficient is used to perform a weighted sum of the first similarity and the second similarity, and the result is used as the similarity between the sentence pair and the current question keyword.
[0066] Step 208: When any similarity calculation result exceeds a preset similarity threshold, a recommended answer is determined based on the sentence pair corresponding to the similarity calculation result, and the recommended answer is pushed to the user.
[0067] The similarity calculation result refers to the similarity between the sentences and the question keywords. If the similarity calculation result exceeds the preset similarity threshold, it indicates that the similarity between the sentence pair and the question keywords is high.
[0068] The recommended answer refers to the target answer in the sentence pair with a high similarity to the question keyword. The terminal pushes the recommended answer to the user. Since the recommended answer received by the user is obtained through hierarchical filtering and retrieval by keyword matching and similarity retrieval algorithm, the recommended answer has extremely high accuracy, which is conducive to significantly improving the overall user experience.
[0069] In the above-mentioned answer retrieval method, at least one question keyword is extracted from the user's question, and the target keyword matching method is used to retrieve the target keyword matching any question keyword in the preset keyword library, and the target question and target answer corresponding to the target keyword are combined into sentence pairs, and then the preset similarity retrieval algorithm is used to calculate the similarity between the sentence pairs and each question keyword, and then the recommended answer is determined based on the sentence pairs whose similarity results exceed the preset similarity threshold, and pushed to the user. This method of implementing hierarchical filtering retrieval of answers through keyword matching and similarity retrieval algorithms is conducive to improving the accuracy of answer retrieval.
[0070] In an exemplary embodiment, there are multiple sentence pairs; determining a recommended answer based on the sentence pairs corresponding to the similarity calculation results includes: sorting the sentence pairs based on the similarity calculation results corresponding to the multiple sentence pairs; determining a target sentence pair that meets a preset similarity condition among the sorted multiple sentence pairs, and using the target answer in the target sentence pair as the recommended answer.
[0071] If there are multiple target keywords matching the question keyword in the preset keyword library, the multiple target keywords can determine multiple sentence pairs.
[0072] For each sentence pair, the terminal obtains the similarity calculation result between the sentence pair and each question keyword, and sorts the multiple sentence pairs according to the order of the similarity calculation results.
[0073] Among the sorted multiple sentence pairs, the sentence pair with the highest similarity is used as the target sentence pair, and the target answer in the target sentence pair is used as the recommended answer.
[0074] In this embodiment, by sorting the sentence pairs according to the similarity calculation results when there are multiple sentence pairs, it is helpful to quickly and accurately determine the target sentence pairs, thereby improving the efficiency of obtaining recommended answers.
[0075] In an exemplary embodiment, the answer retrieval method also includes: obtaining recommended sentence pairs that do not meet preset similarity conditions from the sorted multiple sentence pairs; adding the recommended sentence pairs to a recommended question set, and pushing recommended questions in the recommended question set to the user; the recommended questions are used for user selection and are asked again.
[0076] Among them, the recommended sentence pairs refer to the sentence pairs among multiple sentence pairs that do not meet the preset similarity conditions. Since the similarity between the recommended sentence pairs and the file keywords is low, if the target answers in the recommended sentence pairs are directly pushed to the users, it may not meet the users' question needs.
[0077] The recommended question set refers to a set containing multiple recommended questions. The terminal pushes multiple recommended questions in the recommended question set to the user for the user to select. Since the user can select a target recommended question from multiple recommended questions and continue to extract based on the target recommended question, this helps the user to quickly find the answer to the requirement.
[0078] In this embodiment, by adding the sentence pairs that do not meet the preset similarity conditions to the recommended question set for user selection, it is helpful for the user to ask questions again based on the recommended questions, thereby helping the user to quickly find the answers to their needs.
[0079] In an exemplary embodiment, the answer retrieval method also includes: when the keywords in the preset keyword library do not match all the question keywords, searching the questions in the preset question library and the answers in the preset answer library to determine the retrieval results that match any of the question keywords; the retrieval results include candidate questions that match any of the question keywords or candidate answers that match any of the question keywords; determining candidate sentence pairs based on the retrieval results; using a preset similarity retrieval algorithm to calculate the candidate similarities between the candidate sentence pairs and each question keyword; when any candidate similarity exceeds a preset similarity threshold, determining candidate recommended answers based on the candidate sentences corresponding to the candidate similarities, and recommending the candidate recommended answers to the user.
[0080] If the keywords in the preset keyword library do not match all the question keywords, it indicates that there are no keywords matching the question keywords in the preset keyword library, and the terminal expands the search scope to the preset question library and the preset answer library. The question keywords are compared with each question in the preset question library and each answer in the preset answer library to obtain the search results.
[0081] The search results include candidate questions or candidate answers, and a candidate sentence pair consists of a candidate question and a corresponding answer, or consists of a candidate answer and a corresponding question.
[0082] After determining the candidate sentence pairs, the terminal uses a preset similarity retrieval algorithm to calculate the candidate similarities between the candidate sentence pairs and each question keyword, thereby determining candidate recommended answers whose candidate similarities exceed a preset similarity threshold, and recommends the candidate recommended answers to the user.
[0083] In this embodiment, when there are no keywords matching the question keywords in the preset keyword library, the search scope is expanded to increase the recall rate of the recommended answers, thereby improving the user experience.
[0084] In an exemplary embodiment, candidate sentence pairs are determined based on the retrieval results, including: when the retrieval results include candidate questions that match any question keywords, obtaining answers corresponding to the candidate questions, and combining the candidate questions and the corresponding answers into candidate sentence pairs; when the retrieval results include candidate answers that match any question keywords, obtaining questions corresponding to the candidate answers, and combining the candidate answers and the corresponding questions into candidate sentence pairs.
[0085] Among them, since the search scope is extended to the preset question library and the preset answer library, when the question keywords are matched in the preset question library, the search results include candidate questions that match any question keywords. The terminal obtains the answers corresponding to the candidate questions from the preset answer library, and combines the candidate questions and the corresponding answers into candidate sentence pairs.
[0086] When a question keyword is matched in the preset answer library, the search results include candidate answers that match any question keyword. The terminal obtains the question corresponding to the candidate answer from the preset question library and combines the candidate answer and the corresponding question into a candidate sentence pair.
[0087] In this embodiment, after the search scope is expanded, candidate sentence pairs are formed according to whether the matched question keywords are candidate questions or candidate answers, which is beneficial to improving the recall rate of sentence pairs and thus beneficial to improving the accuracy of answer retrieval.
[0088] In an exemplary embodiment, the answer retrieval method further includes: when the similarity between all sentence pairs and each question keyword does not exceed a preset similarity threshold, pushing a preset reply to the user.
[0089] The preset reply refers to the reply sentence preset in the terminal, such as "Sorry, I can't answer your question", etc. The similarity between all sentence pairs and each question keyword does not exceed the preset similarity threshold, indicating that no sentence pairs similar to the question keywords can be retrieved. Therefore, pushing the preset reply to the user is conducive to the user to understand the search status in time.
[0090] In this embodiment, when the similarity between all sentence pairs and each question keyword does not exceed the preset similarity threshold, a preset reply is pushed to the user, which helps the user to understand the search status in time, thereby improving the user experience.
[0091] To explain the answer retrieval method and effect in this solution in detail, a most detailed embodiment is described below:
[0092] This article will take the answer retrieval scenario of the business process in the business system as an example. Figure 3The figure shows a schematic diagram of the overall process of the answer retrieval method in one embodiment. Among them, a FAQ database for the current scenario is pre-established in the terminal, including a preset keyword library, a preset question library and a preset answer library. Among them, the preset keyword library needs to be added to the default keyword library so that the keywords extracted from the user question can be kept consistent with the keywords in the FAQ database as much as possible, so as to prevent the user question from being disassembled into more fine-grained keywords, affecting the subsequent retrieval effect.
[0093] The terminal obtains the user's question and extracts at least one question keyword from the user's question, searches for keywords in a preset keyword library, and determines whether the keyword search result is empty.
[0094] When the keywords in the preset keyword library do not match all the question keywords, that is, the keyword search result is empty, the entire FAQ database is selected as the search library, and a BM25 search is performed to obtain the BM25 search results.
[0095] When there is a target keyword matching any question keyword in the preset keyword library, it indicates that the keyword search result is not empty. The terminal obtains the target question and target answer corresponding to the target keyword, and combines the target question and the target answer into a sentence pair. A preset similarity retrieval algorithm, for example, the BM25 algorithm, is used to calculate the similarity between the sentence pair and each question keyword, obtain the BM25 search result, and determine whether the BM25 search result is empty.
[0096] When the similarity between all sentence pairs and each question keyword does not exceed the preset similarity threshold, that is, the BM25 search result is empty, the preset reply is pushed to the user.
[0097] When any similarity calculation result exceeds the preset similarity threshold, that is, the BM25 search result is not empty, the recommended answer is determined based on the sentence pair corresponding to the similarity calculation result, and the recommended answer is pushed to the user. If there are multiple sentence pairs, the sentence pairs are sorted based on the similarity calculation results corresponding to the multiple sentence pairs, and the target sentence pairs that meet the preset similarity conditions are determined from the sorted multiple sentence pairs, and the target answers in the target sentence pairs are used as recommended answers; the recommended sentence pairs that do not meet the preset similarity conditions from the sorted multiple sentence pairs are obtained, and the recommended sentence pairs are added to the recommended question set, and the recommended questions in the recommended question set are pushed to the user. The recommended questions are for the user to choose, and to ask again or learn about related extended knowledge. If the recommended question set is empty, the recommended questions are not pushed to the user. Based on the recommended questions selected by the user, a consistency search is performed, and the answers corresponding to the search results are pushed to the user.
[0098] The above-mentioned answer retrieval method extracts at least one question keyword from the user's question, uses the keyword matching method to retrieve the target keyword that matches any question keyword in the preset keyword library, and forms a sentence pair with the target question and the target answer corresponding to the target keyword, and then uses the preset similarity retrieval algorithm to calculate the similarity between the sentence pair and each question keyword, and then determines the recommended answer based on the sentence pair whose similarity result exceeds the preset similarity threshold, and pushes it to the user. This method realizes hierarchical filtering retrieval of answers through keyword matching and similarity retrieval algorithm, which is conducive to improving the accuracy of answer retrieval. In addition, through the above-mentioned answer retrieval process, hierarchical filtering retrieval of FAQ database is realized, and recommended questions are provided to users at the same time, so that users have the opportunity to reconfirm the questions and explore related extended information. This strategy not only improves the accuracy of retrieval, but also significantly improves the overall user experience.
[0099] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0100] Based on the same inventive concept, the embodiment of the present application also provides an answer retrieval device for implementing the answer retrieval method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more answer retrieval device embodiments provided below can refer to the limitations on the answer retrieval method above, and will not be repeated here.
[0101] In an exemplary embodiment, Figure 4 As shown, an answer retrieval device 100 is provided, comprising: an acquisition module 120, a construction module 140, a calculation module 160 and a push module 180, wherein:
[0102] An acquisition module 120 is used to acquire a user question and extract at least one question keyword from the user question;
[0103] A construction module 140 is used to retrieve keywords in a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer;
[0104] A calculation module 160 is used to calculate the similarity between the sentence pair and each question keyword using a preset similarity search algorithm;
[0105] The push module 180 is used to determine a recommended answer based on the sentence pair corresponding to the similarity calculation result when any similarity calculation result exceeds a preset similarity threshold, and push the recommended answer to the user.
[0106] The above-mentioned answer retrieval device extracts at least one question keyword from the user's question, uses the keyword matching method to retrieve the target keyword matching any question keyword in the preset keyword library, and combines the target question and the target answer corresponding to the target keyword into a sentence pair, and then uses the preset similarity retrieval algorithm to calculate the similarity between the sentence pair and each question keyword, and then determines the recommended answer based on the sentence pair whose similarity result exceeds the preset similarity threshold, and pushes it to the user. This method of realizing hierarchical filtering retrieval of answers through keyword matching and similarity retrieval algorithm is conducive to improving the accuracy of answer retrieval.
[0107] In one embodiment, there are multiple sentence pairs; based on the sentence pairs corresponding to the similarity calculation results, the recommended answer is determined, and the push module 180 is also used to: sort the sentence pairs based on the similarity calculation results corresponding to the multiple sentence pairs; determine the target sentence pairs that meet the preset similarity conditions among the sorted multiple sentence pairs, and use the target answer in the target sentence pair as the recommended answer.
[0108] In one embodiment, the answer retrieval device 100 also includes a first recommendation module, which is used to: obtain recommended sentence pairs that do not meet preset similarity conditions among the sorted multiple sentence pairs; add the recommended sentence pairs to a recommended question set, and push recommended questions in the recommended question set to the user; the recommended questions are used for user selection and re-asking.
[0109] In one embodiment, the answer retrieval device 100 also includes a second recommendation module, which is used to: when the keywords in the preset keyword library do not match all the question keywords, search the questions in the preset question library and the answers in the preset answer library to determine the retrieval results that match any question keyword; the retrieval results include candidate questions that match any question keyword or candidate answers that match any question keyword; determine candidate sentence pairs based on the retrieval results; use a preset similarity retrieval algorithm to calculate the candidate similarities between the candidate sentence pairs and each question keyword; when any candidate similarity exceeds a preset similarity threshold, determine candidate recommended answers based on the candidate sentences corresponding to the candidate similarity, and recommend the candidate recommended answers to the user.
[0110] In one embodiment, candidate sentence pairs are determined based on the retrieval results, and the second recommendation module is also used to: when the retrieval results include candidate questions that match any question keywords, obtain answers corresponding to the candidate questions, and combine the candidate questions and the corresponding answers into candidate sentence pairs; when the retrieval results include candidate answers that match any question keywords, obtain questions corresponding to the candidate answers, and combine the candidate answers and the corresponding questions into candidate sentence pairs.
[0111] In one embodiment, the answer search device 100 further includes a reply module, which is used to push a preset reply to the user when the similarity between all sentence pairs and each question keyword does not exceed a preset similarity threshold.
[0112] Each module in the above answer retrieval device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0113] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 5As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, an answer retrieval method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0114] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0115] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0116] Obtain user questions and extract at least one question keyword from the user questions; retrieve keywords in a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form the target question and the target answer into a sentence pair; use a preset similarity retrieval algorithm to calculate the similarity between the sentence pair and each question keyword; if any similarity calculation result exceeds a preset similarity threshold, determine a recommended answer based on the sentence pair corresponding to the similarity calculation result, and push the recommended answer to the user.
[0117] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0118] There are multiple sentence pairs; the sentence pairs are sorted based on the similarity calculation results corresponding to the multiple sentence pairs; a target sentence pair that meets the preset similarity condition is determined among the sorted multiple sentence pairs, and a target answer in the target sentence pair is used as a recommended answer.
[0119] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0120] Obtain recommended sentence pairs that do not meet the preset similarity conditions among the sorted multiple sentence pairs; add the recommended sentence pairs to a recommended question set, and push the recommended questions in the recommended question set to the user; the recommended questions are used for user selection and are asked again.
[0121] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0122] When the keywords in the preset keyword library do not match all the question keywords, search the questions in the preset question library and the answers in the preset answer library to determine the search results that match any of the question keywords; the search results include candidate questions that match any of the question keywords or candidate answers that match any of the question keywords; determine candidate sentence pairs based on the search results; use a preset similarity retrieval algorithm to calculate the candidate similarities between the candidate sentence pairs and each question keyword; when any candidate similarity exceeds a preset similarity threshold, determine candidate recommended answers based on the candidate sentences corresponding to the candidate similarity, and recommend the candidate recommended answers to the user.
[0123] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0124] When the search results include candidate questions that match any question keyword, the answers corresponding to the candidate questions are obtained, and the candidate questions and the corresponding answers are combined into candidate sentence pairs; when the search results include candidate answers that match any question keyword, the questions corresponding to the candidate answers are obtained, and the candidate answers and the corresponding questions are combined into candidate sentence pairs.
[0125] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0126] When the similarity between all sentence pairs and the keywords of each question does not exceed the preset similarity threshold, a preset reply is pushed to the user.
[0127] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0128] Obtain user questions and extract at least one question keyword from the user questions; retrieve keywords in a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form the target question and the target answer into a sentence pair; use a preset similarity retrieval algorithm to calculate the similarity between the sentence pair and each question keyword; if any similarity calculation result exceeds a preset similarity threshold, determine a recommended answer based on the sentence pair corresponding to the similarity calculation result, and push the recommended answer to the user.
[0129] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0130] There are multiple sentence pairs; the sentence pairs are sorted based on the similarity calculation results corresponding to the multiple sentence pairs; a target sentence pair that meets the preset similarity condition is determined among the sorted multiple sentence pairs, and a target answer in the target sentence pair is used as a recommended answer.
[0131] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0132] Obtain recommended sentence pairs that do not meet the preset similarity conditions among the sorted multiple sentence pairs; add the recommended sentence pairs to a recommended question set, and push the recommended questions in the recommended question set to the user; the recommended questions are used for user selection and are asked again.
[0133] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0134] When the keywords in the preset keyword library do not match all the question keywords, search the questions in the preset question library and the answers in the preset answer library to determine the search results that match any of the question keywords; the search results include candidate questions that match any of the question keywords or candidate answers that match any of the question keywords; determine candidate sentence pairs based on the search results; use a preset similarity retrieval algorithm to calculate the candidate similarities between the candidate sentence pairs and each question keyword; when any candidate similarity exceeds a preset similarity threshold, determine candidate recommended answers based on the candidate sentences corresponding to the candidate similarity, and recommend the candidate recommended answers to the user.
[0135] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0136] When the search results include candidate questions that match any question keywords, the answers corresponding to the candidate questions are obtained, and the candidate questions and the corresponding answers are combined into candidate sentence pairs; when the search results include candidate answers that match any question keywords, the questions corresponding to the candidate answers are obtained, and the candidate answers and the corresponding questions are combined into candidate sentence pairs.
[0137] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0138] When the similarity between all sentence pairs and the keywords of each question does not exceed the preset similarity threshold, a preset reply is pushed to the user.
[0139] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0140] Obtain user questions and extract at least one question keyword from the user questions; retrieve keywords in a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form the target question and the target answer into a sentence pair; use a preset similarity retrieval algorithm to calculate the similarity between the sentence pair and each question keyword; if any similarity calculation result exceeds a preset similarity threshold, determine a recommended answer based on the sentence pair corresponding to the similarity calculation result, and push the recommended answer to the user.
[0141] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0142] There are multiple sentence pairs; the sentence pairs are sorted based on the similarity calculation results corresponding to the multiple sentence pairs; a target sentence pair that meets the preset similarity condition is determined among the sorted multiple sentence pairs, and a target answer in the target sentence pair is used as a recommended answer.
[0143] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0144] Obtain recommended sentence pairs that do not meet the preset similarity conditions among the sorted multiple sentence pairs; add the recommended sentence pairs to a recommended question set, and push the recommended questions in the recommended question set to the user; the recommended questions are used for user selection and are asked again.
[0145] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0146] When the keywords in the preset keyword library do not match all the question keywords, search the questions in the preset question library and the answers in the preset answer library to determine the search results that match any of the question keywords; the search results include candidate questions that match any of the question keywords or candidate answers that match any of the question keywords; determine candidate sentence pairs based on the search results; use a preset similarity retrieval algorithm to calculate the candidate similarities between the candidate sentence pairs and each question keyword; when any candidate similarity exceeds a preset similarity threshold, determine candidate recommended answers based on the candidate sentences corresponding to the candidate similarity, and recommend the candidate recommended answers to the user.
[0147] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0148] When the search results include candidate questions that match any question keyword, the answers corresponding to the candidate questions are obtained, and the candidate questions and the corresponding answers are combined into candidate sentence pairs; when the search results include candidate answers that match any question keyword, the questions corresponding to the candidate answers are obtained, and the candidate answers and the corresponding questions are combined into candidate sentence pairs.
[0149] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0150] When the similarity between all sentence pairs and the keywords of each question does not exceed the preset similarity threshold, a preset reply is pushed to the user.
[0151] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0152] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0153] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0154] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for answer retrieval, characterized in that: The method comprises: Obtaining a user question, and extracting at least one question keyword from the user question; Retrieve keywords from a preset keyword library, and if there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer; Using a preset similarity search algorithm, calculate the similarity between the sentence pair and each question keyword; In the case that any similarity calculation result exceeds a preset similarity threshold, a recommended answer is determined based on the sentence pair corresponding to the similarity calculation result, and the recommended answer is pushed to the user.
2. The method according to claim 1, characterized in that There are multiple sentence pairs; and determining the recommended answer based on the sentence pairs corresponding to the similarity calculation results includes: Sort each sentence pair based on the similarity calculation results corresponding to each of the multiple sentence pairs; A target sentence pair that meets a preset similarity condition is determined from among the sorted plurality of sentence pairs, and a target answer in the target sentence pair is used as a recommended answer.
3. The method according to claim 2, characterized in that The method further comprises: Obtaining recommended sentence pairs that do not meet the preset similarity condition from the sorted plurality of sentence pairs; The recommended sentence pair is added to a recommended question set, and the recommended questions in the recommended question set are pushed to the user; the recommended questions are used for user selection and re-asking.
4. The method according to claim 1, characterized in that: The method further comprises: In the case that the keywords in the preset keyword library do not match all the question keywords, searching the questions in the preset question library and the answers in the preset answer library to determine the search results that match any of the question keywords; the search results include candidate questions that match any of the question keywords or candidate answers that match any of the question keywords; Determining candidate sentence pairs based on the search results; Using a preset similarity search algorithm, calculate the candidate similarity between the candidate sentence pair and each question keyword; In the case that any candidate similarity exceeds a preset similarity threshold, a candidate recommended answer is determined based on the candidate sentence corresponding to the candidate similarity, and the candidate recommended answer is recommended to the user.
5. The method according to claim 4, characterized in that The determining of candidate sentence pairs based on the search results includes: In the case where the search results include a candidate question matching any question keyword, obtaining an answer corresponding to the candidate question, and forming a candidate sentence pair with the candidate question and the corresponding answer; In the case where the search result includes a candidate answer that matches any question keyword, the question corresponding to the candidate answer is obtained, and the candidate answer and the corresponding question are combined into a candidate sentence pair.
6. The method according to claim 1, characterized in that The method further comprises: When the similarity between all sentence pairs and the keywords of each question does not exceed the preset similarity threshold, a preset reply is pushed to the user.
7. An answer search device, characterized in that: The device comprises: An acquisition module, used to acquire a user question and extract at least one question keyword from the user question; A construction module is used to retrieve keywords in a preset keyword library, and when there is a target keyword matching any question keyword in the preset keyword library, obtain a target question and a target answer corresponding to the target keyword, and form a sentence pair with the target question and the target answer; A calculation module, used to calculate the similarity between the sentence pair and each question keyword using a preset similarity retrieval algorithm; The push module is used to determine a recommended answer based on the sentence pair corresponding to any similarity calculation result when any similarity calculation result exceeds a preset similarity threshold, and push the recommended answer to the user.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
