Question and answer method, device and equipment based on knowledge base, medium and program product

Through the question and answer method based on the knowledge base, the use of similarity matching and retrieval technology of preset questions and text libraries solves the problem of low efficiency of interactive question and answer and achieves quick response and high-quality reply.

CN118627618APending Publication Date: 2024-09-10PICC INFORMATION TECH CO LTD

Patent Information

Application Number
CN202410749333.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Model-based interactive question and answer is inefficient when processing large batches of questions, has a long response time, and cannot generate effective answers in a timely manner.

Method used

Adopting a question and answer method based on the knowledge base, by obtaining the question to be answered and determining the similarity matching result with the preset question, if the matching result meets the conditions, the answer is provided directly; otherwise, the relevant text is retrieved in the text library to generate the answer, reducing Inference burden on large language models.

Benefits of technology

It improves the efficiency of Q&A responses, shortens the response time, and ensures the quality of responses, especially when processing large batches of questions. It can respond quickly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118627618A
    Figure CN118627618A
Patent Text Reader

Abstract

The invention provides a knowledge base-based question and answer method, apparatus and device, a medium and a program product, and relates to the field of natural language processing. The method comprises the steps of obtaining a to-be-answered question, determining a similarity matching result of the to-be-answered question and a preset question, and directly obtaining an answer for the to-be-answered question if a result meeting a condition is matched, without consuming a time matching text and occupying a model reasoning ability, so that the question and answer reply efficiency can be improved, and the response speed can be improved. Besides, if the result meeting the condition cannot be matched, the text matched with the to-be-answered question can be continuously retrieved in the text library, so that the model can perform reasoning on the to-be-answered question according to the text to generate a corresponding answer, and the reply quality is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and in particular to a question-answering method, apparatus, device, medium and program product based on a knowledge base. Background Art

[0002] Interactive question-and-answer is an important technology in the field of natural language processing and is widely used in many fields such as education and sales. In particular, with the continuous advancement of artificial intelligence technology, large language models are becoming more and more capable of processing human language. Answering questions input by users through models has gradually replaced manual question-and-answer and become the mainstream.

[0003] Currently, model-based interactive question-answering usually requires retrieving relevant text from a large-scale raw text dataset based on the question, and then integrating the retrieved text information online through a large language model to infer the answer to the question. However, this question-answering method has low overall efficiency and long response time when processing large batches of questions. Summary of the invention

[0004] The present application provides a knowledge base-based question-answering method, apparatus, device, medium and program product to solve the technical problems of low question-answering efficiency and long response time.

[0005] In a first aspect, the present application provides a question-answering method based on a knowledge base, wherein the knowledge base includes a question-answering library and a text library, wherein the question-answering library includes a plurality of preset questions and answers corresponding to the preset questions, and the text library includes a plurality of knowledge texts, and the question-answering method includes:

[0006] Get questions to be answered;

[0007] Determine a similarity matching result between the question to be answered and the preset question;

[0008] If the similarity matching result meets the preset similarity condition, determining that the answer corresponding to the preset question in the question and answer library is the answer to the question to be answered;

[0009] If the similarity matching result does not meet the preset similarity condition, the text matching the question to be answered is retrieved from the text library, and an answer to the question to be answered is generated according to the matched text.

[0010] In a possible implementation, the knowledge base is established in the following manner:

[0011] Generate knowledge text according to preset questions and answers in the question and answer library, and store the generated knowledge text in the text library;

[0012] and / or,

[0013] Questions and answers are generated according to the knowledge text in the text library, and the generated questions and answers are stored in the question and answer library.

[0014] In a possible implementation, generating knowledge text according to the questions and answers in the question-and-answer database includes:

[0015] After determining that the answer corresponding to the preset question in the question and answer library is the answer to the question to be answered, the question to be answered and the answer to the question to be answered are processed by a large language model to generate a knowledge text.

[0016] In a possible implementation, generating questions and answers based on the knowledge text in the text library, and storing the generated questions and answers in the question and answer library includes:

[0017] After generating an answer to the question to be answered based on the matched text, the question to be answered and the answer to the question to be answered are stored in the question and answer library.

[0018] In a possible implementation, determining a similarity matching result between the question to be answered and the preset question includes:

[0019] Constructing a word vector according to the text content of the question to be answered, and calculating a question vector of the question to be answered based on the word vector;

[0020] The similarity between the question vector corresponding to the preset question and the question vector of the question to be answered is calculated, and the preset question with the maximum similarity is selected as the similarity matching result.

[0021] In a possible implementation, generating an answer to the question to be answered based on the matched text includes:

[0022] Generate prompt words according to the matched text and the question to be answered;

[0023] The prompt word is input into a large language model to obtain an answer to the question to be answered output by the large language model.

[0024] In a second aspect, the present application provides a question-answering device based on a knowledge base, wherein the knowledge base includes a question-answering library and a text library, wherein the question-answering library includes a plurality of preset questions and answers corresponding to the preset questions, and the text library includes a plurality of knowledge texts, and the question-answering device includes:

[0025] An acquisition module is used to obtain questions to be answered;

[0026] A matching module, used to determine a similarity matching result between the question to be answered and the preset question;

[0027] A first answering module, configured to determine, when the similarity matching result satisfies a preset similarity condition, that the answer corresponding to the preset question in the question-and-answer database is the answer to the question to be answered;

[0028] The second answering module is used to retrieve text matching the question to be answered in the text library when the similarity matching result does not meet the preset similarity condition, and generate an answer to the question to be answered according to the matched text.

[0029] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0030] The memory stores computer-executable instructions;

[0031] The processor executes the computer-executable instructions stored in the memory to implement the question-answering method based on the knowledge base as described in any one of the first aspects.

[0032] In a fourth aspect, the present application provides a computer-readable storage medium, comprising: the computer-readable storage medium stores computer execution instructions, and when the computer execution instructions are executed by a processor, they are used to implement the knowledge base-based question-answering method as described in any one of the first aspects.

[0033] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the knowledge base-based question-answering method as described in any one of the first aspects.

[0034] The knowledge-based question-answering method, device, equipment, medium, and program product provided by the present application can determine the similarity matching result between the question to be answered and the preset question after obtaining the question to be answered. If a result that meets the conditions is matched, the answer to the question to be answered can be directly obtained without wasting time matching text and occupying the model reasoning ability, thereby improving the efficiency of question-answering responses and improving the response speed. In addition, if no result that meets the conditions is matched, the text matching the question to be answered can continue to be searched in the text library, so that the model can reason about the question to be answered based on the text to generate the corresponding answer to ensure the quality of the response. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0036] Figure 1 This is a schematic diagram of an application scenario of a question-answering method based on a knowledge base provided in an embodiment of the present application;

[0037] Figure 2 It is a flowchart of a question-answering method based on a knowledge base provided in an embodiment of the present application;

[0038] Figure 3 It is a flowchart of a method for determining a similarity matching result provided in an embodiment of the present application;

[0039] Figure 4 It is a flowchart of a method for generating an answer to a question to be answered provided in an embodiment of the present application;

[0040] Figure 5 It is a schematic diagram of the operating principle of a question-and-answer system provided in an embodiment of the present application;

[0041] Figure 6 is a schematic diagram of the structure of a question-answering device based on a knowledge base provided in an embodiment of the present application;

[0042] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0043] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0044] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0045] The terms "comprises", "includes" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, product or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, product or device. In the absence of further restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or device including the elements. For example, if the words first, second, etc. are used to indicate names, they do not indicate any particular order.

[0046] First, the terms involved in this application are explained:

[0047] LLM (Large Language Model): A large language model (LLM) is a neural network that involves a large number of parameters. The large language model has "human-like" language understanding, knowledge memory, and logical reasoning capabilities.

[0048] Embedding: Embedding is a technique for converting high-dimensional data (such as text, images) into low-dimensional dense vectors. In natural language processing, embedding can include text embedding, which converts text into vectors to capture semantic relationships and similarities between texts through vectors.

[0049] Prompt: Also known as a prompt word, it refers to the text input provided to the large language model LLM to guide the model to generate specific outputs or perform specific tasks.

[0050] At present, interactive question and answer has always been a research hotspot in the field of natural language processing. In particular, the interactive question and answer method combined with large language models and other means can effectively reduce the dependence on manual work in the question and answer process, and help improve the efficiency of question and answer responses. However, although large language models can respond to questions raised by users, they still need to use auxiliary information to generate answers for responses. These auxiliary information are usually related texts retrieved from large-scale original text datasets based on user questions. Whether it is retrieving text related to the question or answering questions based on text reasoning, it takes a lot of time. This results in the inability to generate effective answers in a timely manner when processing large quantities of user questions, and the response time is long.

[0051] In response to the above problems, the present application provides a question-and-answer method, device, equipment, medium and program product based on a knowledge base. The question-and-answer method can be based on a pre-established knowledge base, which includes a question-and-answer library and a text library. The question-and-answer library contains multiple preset questions and answers corresponding to the preset questions, and the text library contains multiple knowledge texts. The question-and-answer method includes: obtaining the question to be answered, and determining the similarity matching result between the question to be answered and the preset question in the question-and-answer library. If the result meets the preset conditions, the answer corresponding to the preset question is determined to be the answer corresponding to the question to be answered. If the result does not meet the preset conditions, the text matching the question to be answered is retrieved in the text library, and the answer corresponding to the question to be answered is generated according to the text. In this way, the preset questions and answers in the question-and-answer library can be used to match the question to be answered. If the result that meets the conditions is matched, the answer to the question to be answered can be directly obtained without wasting time matching text and occupying the model reasoning ability, thereby improving the efficiency of question-and-answer responses and improving the response speed. In addition, if no matching result is found, the text library can continue to be searched for text that matches the question to be answered, so that the large language model can infer the question to be answered based on the text to generate a corresponding answer to ensure the quality of the response.

[0052] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0053] Figure 1 A schematic diagram of an application scenario provided by this application. Figure 1 As shown, the terminal 102 communicates with the server 101 through the network. The data storage system can store the data that the server 101 needs to process. The data storage system can be integrated on the server 101, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 101 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0054] The application scenarios involved above are only some examples. Those skilled in the art may expand the application to specific business scenarios, and the embodiments of the present application do not impose any specific limitations on this.

[0055] Combine the following Figure 1 For application scenarios, refer to Figures 2 to 5The question-answering method based on the knowledge base according to the exemplary embodiment of the present application is described. The question-answering method based on the knowledge base can be applied to Figure 1 The server 101 or terminal 102 in the embodiment of the present invention comprises a question-and-answer library and a text library, wherein the question-and-answer library comprises a plurality of preset questions and answers corresponding to the preset questions, and the text library comprises a plurality of knowledge texts. It should be noted that the above application scenarios are only shown for the purpose of facilitating the understanding of the spirit and principle of the present application, and the implementation methods of the present application are not limited in this respect. On the contrary, the implementation methods of the present application can be applied to any applicable scenario.

[0056] Figure 2 is a flow chart of a question-answering method based on a knowledge base provided in an embodiment of the present application. Figure 2 As shown, the question-answering method includes:

[0057] Step S201, obtaining questions to be answered.

[0058] The question to be answered may be a question raised by a user in a specific application scenario. For example, for some applications, an application client running on a user terminal may provide an interactive interface to the user to obtain questions input by the user in the form of voice or text through the interactive interface.

[0059] Step S202, determining the similarity matching result between the question to be answered and the preset question.

[0060] Specifically, for multiple preset questions in the question-and-answer database, the similarity between each preset question and the question to be answered can be calculated respectively, and at least one preset question can be selected from these preset questions as a similarity matching result according to the similarity and preset rules. For example, these preset questions can be sorted in descending order according to the similarity between each preset question and the question to be answered, and one or more preset questions with the highest ranking can be selected as the similarity matching result.

[0061] In some possible implementations, the similarity between the answer corresponding to each preset question and the question to be answered may be calculated respectively, and at least one of the answers may be selected as a similarity matching result according to the similarity and preset rules.

[0062] Step S203: If the similarity matching result meets the preset similarity condition, the answer corresponding to the preset question in the question and answer database is determined to be the answer to the question to be answered.

[0063] Specifically, after obtaining the similarity matching result, we can further calculate whether the similarity between the preset question corresponding to the similarity result and the question to be answered reaches a preset similarity threshold. If the threshold is reached, the answer corresponding to the preset question can be used as the answer to the question to be answered and output.

[0064] Step S204: if the similarity matching result does not meet the preset similarity condition, a text matching the question to be answered is searched in the text library, and an answer to the question to be answered is generated according to the matched text.

[0065] Specifically, after obtaining the similarity matching result, if the similarity between each preset question corresponding to the similarity result and the question to be answered does not reach the preset similarity threshold, the knowledge text related to the question to be answered can be retrieved from the text library, and the answer to the question to be answered can be generated based on the retrieved text. For example, the question to be answered and the related text retrieved from the text library can be processed by an artificial intelligence model to obtain the answer to the question to be answered.

[0066] In the above embodiment, after obtaining the question to be answered, the similarity matching result between the question to be answered and the preset question can be determined. If a result that meets the conditions is matched, the answer to the question to be answered can be directly obtained without wasting time matching text and occupying the model reasoning ability, thereby improving the efficiency of question and answer responses and improving the response speed. In addition, if no result that meets the conditions is matched, the text library can continue to be searched for text matching the question to be answered, so that the model can reason about the question to be answered based on the text to generate a corresponding answer to ensure the quality of the response. In this way, in the case of a large number of questions that need to be answered, the questions can be diverted through the question and answer library matching method, so that some questions can be answered based on the question and answer library method with a faster response speed, reducing the pressure of large model responses based on knowledge texts, thereby improving the overall question and answer efficiency.

[0067] In one embodiment, the knowledge base may be established by collecting user-related questions from user channels or third-party channels, and compiling corresponding standard answers based on each collected question, so as to establish a question-and-answer library in the knowledge base based on these questions and answers. The user channel may be a question-and-answer system provided by an application to users, and the third-party channel may include public accounts, newspapers, and think tanks.

[0068] In some possible implementations, the embedding vector of the preset question may be used as an index to store the preset question and the corresponding answer in the question and answer library.

[0069] In some possible implementations, a data set containing knowledge texts may be obtained from channels such as the Internet, and a text library in the knowledge base may be established based on the obtained knowledge texts.

[0070] In some possible implementations, the text library may be directly stored using the embedding vector of the text segment as an index.

[0071] In one embodiment, the method of establishing the knowledge base may further include: generating knowledge text according to preset questions and answers in the question and answer base, and storing the generated knowledge text in the text base.

[0072] Specifically, for the preset questions and answers in the question-answer database, the knowledge organization model can be used to convert the data in the form of questions and answers into complete knowledge texts and then store them in the text database. For example, for "Question: Why is the sky blue? Answer: The sky is blue because of the atmospheric scattering...", the result of the conversion can be "The sky is blue mainly due to the scattering effect of the atmosphere on sunlight..."

[0073] Among them, the knowledge organization model can be implemented by writing a large language model after a specific prompt.

[0074] In one embodiment, the method of establishing the knowledge base may further include: generating questions and answers based on the knowledge texts in the text base, and storing the generated questions and answers in the question and answer base.

[0075] Specifically, the QAG model can be used to extract multiple question-answer pairs from the knowledge text and store these question-answer pairs in a question-answer library with the embedding vector of the question as the index. QAG (Question-Answer Generation) is a natural language processing algorithm that can automatically generate questions and answers based on a given text and output them in the form of question-answer pairs, which include questions and their corresponding answers. The QAG model can be implemented using a large language model after writing a specific prompt.

[0076] For example, there is a knowledge text that says "The solar system consists of the sun and celestial bodies that revolve around the sun directly or indirectly, including the eight planets, asteroids, comets, stardust in the sky, solar wind, etc. The center of the system is the sun, whose mass accounts for 99.86% of the total mass of the solar system." The extracted results are "Question: What are the main parts of the solar system? Answer:... ", "Question: What is the position of the sun in the solar system? Answer:... ".

[0077] In the above embodiment, the work of extracting question-answer pairs from the knowledge text using the QAG model can be regarded as a high-level summary and semantic extraction method of the original text. Compared with the current interactive question-answering process in which the large language model is only used for reasoning in the answer generation stage, the method in the above embodiment can transfer the original real-time online large model reasoning operation part to the offline stage, thereby reducing the computing pressure and delay of the system's real-time response.

[0078] In one embodiment, generating knowledge text based on questions and answers in a question and answer library may also include: after determining that the answer corresponding to a preset question in the question and answer library is the answer to the question to be answered, processing the question to be answered and the answer to the question to be answered through a large language model to generate knowledge text.

[0079] Specifically, in the process of answering a single response to a user's question, if the similarity matching result obtained from the question-and-answer library meets the preset similarity condition and it is determined that the answer corresponding to the preset question is the answer to the question to be answered, then the question to be answered and the answer can be converted into knowledge text through a large language model, and the converted knowledge text can be added to the text library.

[0080] In one embodiment, questions and answers are generated based on knowledge text in a text library, and the generated questions and answers are stored in a question and answer library, including: after generating answers to questions to be answered based on matched text, storing the questions to be answered and the answers to the questions to be answered in the question and answer library.

[0081] Specifically, in the process of answering a single question in response to a user's question, if the similarity matching result obtained from the question and answer library does not meet the preset similarity condition, the question to be answered and the answer to the question to be answered generated based on the matched text can be added to the question and answer library as a question and answer pair.

[0082] In the above embodiment, for the process of responding to questions to be answered in real time, the questions to be answered and the final answers generated for the questions can be directly added to the question and answer library, or the questions to be answered and the final answers generated for the questions can be converted into knowledge texts and added to the text library. In this way, the questions raised by users in real time and the answers responded to in real time can be used to supplement the knowledge reserves in the question and answer library and the text library, improve data utilization, and further enhance the accuracy of question and answer responses.

[0083] In one embodiment, Figure 3 As shown, determining the similarity matching result between the question to be answered and the preset question may include:

[0084] Step S301, constructing a word vector according to the text content of the question to be answered, and calculating the question vector of the question to be answered based on the word vector.

[0085] Specifically, the question to be answered can be segmented, a word vector can be constructed for the segmentation result, and the question vector of the question to be answered can be calculated based on the value of each word vector. For example, "It rained today", after segmentation, it becomes "today", "raining", and "did". After the question is segmented, the word vectors of all words are added together to serve as the question vector of the question. For example, the word vector of "today" is (0.5,0), the word vector of "raining" is (0.5,0.5), and the word vector of "did" is (0,0.1), then the question vector of "It rained today" is (0.5+0.5+0,0+0.5+0.1), that is, (1,0.6).

[0086] Step S302, calculating the similarity between the question vector corresponding to the preset question and the question vector of the question to be answered, and selecting the preset question with the maximum similarity as the similarity matching result.

[0087] Specifically, the question vector of the question to be answered can be compared with the question vectors of all preset questions in the question-answering database to find the preset question with the greatest similarity, and the preset question is used as the similarity matching result of the question to be answered. The similarity comparison can use the cosine similarity between the question vectors.

[0088] In one embodiment, Figure 4 As shown, generating an answer to the question to be answered based on the matched text may include:

[0089] Step S401, generating prompt words according to the matched text and the question to be answered.

[0090] Step S402: input the prompt word into the large language model to obtain an answer to the question to be answered output by the large language model.

[0091] Specifically, the text matched from the text library can be used as background knowledge, combined with the question to be answered to build the prompt word of the large language model, and the prompt word is passed to the large language model to generate the answer and serve as the response to the user's question. By using the large language model's ability to understand complex texts, questions with irregular expressions can be effectively interpreted, and questions that require reasoning from multiple knowledge points can be deeply analyzed and comprehensively answered, thereby improving the quality of answers to interactive questions and answers.

[0092] In order to further reflect the application scenarios and beneficial effects of the present application solution, a question-answering system is also provided, which includes a serial retrieval module and an offline QA enhancement module. The serial retrieval module may include a QA database and a knowledge text database. The QA database stores multiple QAs (Question-Answer pairs) using the embedding vector of the question as an index, and the knowledge text database directly stores multiple knowledge texts using the embedding vector of the text segment as an index.

[0093] Figure 5 FIG. 1 is a schematic diagram showing the operating principle of the question-answering system in an exemplary embodiment. Figure 5 As shown, the question-answering system can receive user questions and return corresponding answers. After receiving user questions, the system can calculate the embedding vector of the user's question and perform similarity matching between the embedding vector and the question embedding vector index in the QA database. If there is at least one matching item that meets the preset similarity threshold range, the answer text corresponding to the question is returned to achieve a quick response to the user's question. If there is no matching item that meets the conditions, the embedding vector of the user's question can be matched with the text embedding vector index in the knowledge text data for similarity. If there is no matching related text within the preset similarity range, the system returns a message refusing to answer; if there is a matching item that meets the conditions, the matching related text can be used as background knowledge, combined with the user's question to build a prompt, and passed into the large language model LLM to generate an answer and serve as a response answer to the user's question.

[0094] In addition, if Figure 5 As shown, the offline QA enhancement module in the question-answering system can run offline when not processing user questions, including using the knowledge organization model to convert the data in the form of question and answer pairs in the question and answer library into complete knowledge texts and then storing them in the knowledge text database, and including using the QAG model to extract multiple QA data from the text of the knowledge text database and store them in the QA database with the embedding vector of the question as the index.

[0095] The above-mentioned question-answering system introduces an offline QA enhancement module based on the large language model to process user questions. After pre-processing the QA data and knowledge text data, the QA database and the knowledge text database are maintained respectively, which can improve the efficiency of data utilization. In addition, a serial retrieval module based on the QA database and the knowledge text database is introduced to improve the instant response speed of common questions and improve the long text retrieval effect to ensure the quality of complex question answers, thereby improving the overall response speed of the question-answering system and user experience.

[0096] Figure 6The structure diagram of a question-answering device based on a knowledge base provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the knowledge base-based question-answering device 600 may include:

[0097] The acquisition module 601 is used to acquire questions to be answered.

[0098] The matching module 602 is used to determine the similarity matching result between the question to be answered and the preset question.

[0099] The first answering module 603 is used to determine that the answer corresponding to the preset question in the question and answer database is the answer to the question to be answered when the similarity matching result meets the preset similarity condition.

[0100] The second answering module 604 is used to retrieve text matching the question to be answered in the text library when the similarity matching result does not meet the preset similarity condition, and generate an answer to the question to be answered according to the matched text.

[0101] In one embodiment, the knowledge base-based question-answering device 600 may further include:

[0102] The first storage module can be used to generate knowledge text according to preset questions and answers in the question and answer library, and store the generated knowledge text in the text library.

[0103] In one embodiment, the knowledge base-based question-answering device 600 may further include:

[0104] The second storage module can be used to generate questions and answers based on the knowledge text in the text library, and store the generated questions and answers in the question and answer library.

[0105] In one embodiment, the first storage module may include:

[0106] The question and answer processing unit can be used to process the question to be answered and the answer to the question to be answered through a large language model to generate a knowledge text after determining that the answer corresponding to the preset question in the question and answer library is the answer to the question to be answered.

[0107] In one embodiment, the second storage module may include:

[0108] The text processing unit may be configured to store the question to be answered and the answer to the question to be answered in the question and answer library after generating an answer to the question to be answered according to the matched text.

[0109] In one embodiment, the matching module 602 may include:

[0110] The vector calculation unit can be used to construct a word vector according to the text content of the question to be answered, and calculate the question vector of the question to be answered based on the word vector.

[0111] The similarity calculation unit can be used to calculate the similarity between the question vector corresponding to the preset question and the question vector of the question to be answered, and select the preset question with the maximum similarity as the similarity matching result.

[0112] In one embodiment, the second answer module 604 may include:

[0113] The prompt word generating unit can be used to generate prompt words according to the matched text and the question to be answered.

[0114] The model processing unit can be used to input the prompt word into the large language model to obtain an answer to the question to be answered output by the large language model.

[0115] The knowledge base-based question-answering device provided in this embodiment is used to execute the technical solution in any of the aforementioned method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.

[0116] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0117] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0118] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device 70 may include:

[0119] Processor 71, memory 72, and communication interface 73;

[0120] The memory 72 is used to store executable instructions of the processor 71; the executable instructions may be computer-executable instructions;

[0121] The processor 71 is configured to execute the technical solution in any of the aforementioned method embodiments by executing the executable instructions.

[0122] Optionally, the memory 72 can be independent or integrated with the processor 71.

[0123] Optionally, when the memory 72 is a device independent of the processor 71, the electronic device 70 may further include:

[0124] The bus 74 , the memory 72 and the communication interface 73 are connected to the processor 71 via the bus 74 and communicate with each other. The communication interface 73 is used to communicate with other devices.

[0125] Optionally, the communication interface 73 may be implemented by a transceiver. The communication interface is used to implement communication between the database access device and other devices (such as a client, a read-write library, and a read-only library). The memory may include a random access memory (RAM) and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.

[0126] The bus 74 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0127] The above-mentioned processor can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0128] The electronic device is used to execute the technical solution in any of the aforementioned method embodiments, and its implementation principle and technical effect are similar and will not be repeated here.

[0129] An embodiment of the present application also provides a readable storage medium, which may be a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the technical solution provided by any of the aforementioned method embodiments is implemented.

[0130] An embodiment of the present application also provides a computer program product, including a computer program, which is used to implement the technical solution provided by any of the aforementioned method embodiments when executed by a processor.

[0131] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0132] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not 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 specification.

[0133] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0134] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A question-answering method based on a knowledge base, characterized in that: The knowledge base includes a question-and-answer base and a text base, wherein the question-and-answer base includes a plurality of preset questions and answers corresponding to the preset questions, and the text base includes a plurality of knowledge texts, and the question-and-answer method includes: Get questions to be answered; Determine a similarity matching result between the question to be answered and the preset question; If the similarity matching result meets the preset similarity condition, determining that the answer corresponding to the preset question in the question and answer library is the answer to the question to be answered; If the similarity matching result does not meet the preset similarity condition, the text matching the question to be answered is retrieved from the text library, and an answer to the question to be answered is generated according to the matched text.

2. The question-answering method according to claim 1, characterized in that: The knowledge base is established in the following ways: Generate knowledge text according to preset questions and answers in the question and answer library, and store the generated knowledge text in the text library; and / or, Questions and answers are generated according to the knowledge text in the text library, and the generated questions and answers are stored in the question and answer library.

3. The question-answering method according to claim 2, characterized in that: Generating knowledge text according to the questions and answers in the question-answer database includes: After determining that the answer corresponding to the preset question in the question and answer library is the answer to the question to be answered, the question to be answered and the answer to the question to be answered are processed by a large language model to generate a knowledge text.

4. The question-answering method according to claim 2, characterized in that: The step of generating questions and answers based on the knowledge text in the text library, and storing the generated questions and answers in the question-answer library, comprises: After generating an answer to the question to be answered based on the matched text, the question to be answered and the answer to the question to be answered are stored in the question and answer library.

5. The question-answering method according to any one of claims 1 to 4, characterized in that: The determining of the similarity matching result between the question to be answered and the preset question includes: Constructing a word vector according to the text content of the question to be answered, and calculating a question vector of the question to be answered based on the word vector; The similarity between the question vector corresponding to the preset question and the question vector of the question to be answered is calculated, and the preset question with the maximum similarity is selected as the similarity matching result.

6. The question-answering method according to any one of claims 1 to 4, characterized in that: Generating an answer to the question to be answered according to the matched text includes: Generate prompt words according to the matched text and the question to be answered; The prompt word is input into a large language model to obtain an answer to the question to be answered output by the large language model.

7. A question-answering device based on a knowledge base, characterized in that: The knowledge base includes a question-and-answer base and a text base, wherein the question-and-answer base includes a plurality of preset questions and answers corresponding to the preset questions, and the text base includes a plurality of knowledge texts. The question-and-answer device includes: An acquisition module is used to obtain questions to be answered; A matching module, used to determine a similarity matching result between the question to be answered and the preset question; A first answering module, configured to determine, when the similarity matching result satisfies a preset similarity condition, that the answer corresponding to the preset question in the question-and-answer database is the answer to the question to be answered; The second answering module is used to retrieve text matching the question to be answered in the text library when the similarity matching result does not meet the preset similarity condition, and generate an answer to the question to be answered according to the matched text.

8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.

10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.

Citation Information

Patent Citations

  • A method and system for constructing an intelligent tourist customer service system

    CN109446305A

  • Method and device for realizing intelligent question answering system based on question matching

    CN115114493A

  • Question and answer method and device, electronic equipment and storage medium

    CN116719918A

  • Knowledge graph generation type question answering method and system based on large language model

    CN117033608A

  • LLM-based intelligent question and answer reply method, system and device

    CN117972216A

Cited By

  • Knowledge question-answering method and device based on large model and intelligent agent

    CN119150991A