Question and answer method and device, equipment and medium
By finding matching text blocks and Q&A pairs in the knowledge base and historical high-quality Q&A library, and using large language models for analysis, the problem of inaccurate Q&A in massive information is solved, and accurate information acquisition is achieved.
Patent Information
- Application Number
- CN202510282523.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-07-04
AI Technical Summary
The prior art cannot accurately obtain the content you want to pay attention to in massive information, and insufficient manual reading and model training lead to inaccurate questions and answers.
By finding target text blocks and historical high-quality question-and-answer pairs that match the questions to be answered in the pre-configured knowledge base, populating them into the prompt word template, and entering the large language model to obtain accurate reply information, the semantic understanding ability of the large language model is analyzed.
It realizes accurate Q&A in massive information, improves the accuracy and efficiency of Q&A, and reduces the cumbersome steps of manual preprocessing.
Smart Images

Figure CN120256559A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular, to a question-answering method, device, equipment and medium. Background Art
[0002] In daily life, people usually need to pay timely attention to the latest information released in certain fields. For example, the user manuals of some newly released chips, the policy information of some fields, etc., so as to adjust the current work in a timely manner according to the obtained latest information. However, with the rapid development of various fields, the number of information released every day is extremely large and updated frequently.
[0003] In the related art, generally, the information collected is read manually, relevant keywords are extracted, and then a knowledge graph is constructed or stored in other forms. Then, appropriate expansion is performed based on the extracted keywords, and the extracted keywords and the expanded keywords are saved. During the question-answering process, the answer information to the question to be answered is retrieved by means of keyword matching. This method has a very heavy workload for information preprocessing and keyword annotation, and there will be a problem that the keywords summarized manually are inaccurate, which will lead to inaccurate question answering.
[0004] There is also a question-answering method in the related art that performs question answering through a trained model. During question answering, the question to be answered received is input into the trained model, and the model uses the knowledge learned during the training phase to determine the answer information to the question to be answered. Since the data for training the model is limited, and now the speed of information release is extremely fast, the trained model may not be able to accurately answer the question to be answered because it has not learned some knowledge during the training phase.
[0005] Therefore, how to obtain the content that one hopes to pay attention to from a large amount of information has become an urgent problem to be solved. Summary of the Invention
[0006] Embodiments of this application provide a question-answering method, device, equipment and medium, which are used to solve the problem in the prior art that it is impossible to accurately obtain the content that one hopes to pay attention to from a large amount of information.
[0007] In a first aspect, embodiments of this application provide a question-answering method, and the method includes:
[0008] In a pre-configured knowledge base, search for a target text block that matches the received question to be answered;
[0009] In a historical high-quality question-answering database, search for a target high-quality question-answering pair that matches the question to be answered;
[0010] Fill the to-be-answered question, the target text block, and the target high-quality Q&A pair into the prompt template to obtain the target prompt;
[0011] Input the target prompt into the large language model to obtain the reply information for the to-be-answered question.
[0012] In the above manner, find the target text block and the target high-quality Q&A pair that match the to-be-answered question, determine the target prompt input into the large language model according to the to-be-answered question, the target text block, and the target high-quality Q&A pair, and then utilize the powerful semantic understanding ability of the large language model to determine the reply information for the to-be-answered question. As long as the information collected in the knowledge base and the historical high-quality Q&A library is timely and comprehensive, and the target text block and the target high-quality Q&A pair that match the to-be-answered question can be retrieved, the large language model can accurately analyze by referring to the content recorded in the target text block and the target high-quality Q&A pair, obtain an accurate answer, and achieve the purpose of accurate Q&A in a vast amount of information.
[0013] In a possible implementation manner, after finding the target text block that matches the received to-be-answered question in the pre-configured knowledge base and before filling the to-be-answered question, the target text block, and the target high-quality Q&A pair into the prompt template, the method further includes:
[0014] If there are multiple target text blocks, for each target text block, obtain other text blocks adjacent to the target text block in the complete reference information where the target text block is located; respectively determine the similarity between the to-be-answered question and the target text block, and each other text block; according to each similarity, determine the target similarity between the to-be-answered question and the target text block;
[0015] Delete the target text blocks that do not meet the preset similarity requirement according to each target similarity.
[0016] In the above manner, when there are multiple determined target text blocks, for each target text block, obtain other text blocks adjacent to the target text block in the complete reference information where the target text block is located, and then respectively determine the similarity between the to-be-answered question and the target text block, and each other text block, so as to determine the target similarity of the target text block. After obtaining the target similarity of each target text block, the target text blocks that meet the preset similarity requirement can be selected by sorting, ensuring that the target text block is highly similar to the to-be-answered question, and thus improving the accuracy of Q&A.
[0017] In a possible implementation manner, the target high-quality Q&A pair includes a historical question, the answer corresponding to the historical question, and the reasoning process for obtaining the answer;
[0018] The process by which the large language model obtains the reply information for the question to be replied according to the target prompt includes:
[0019] The large language model learns the reasoning idea of the reasoning process according to the requirements of the target prompt, and performs reasoning analysis on the target text block based on the learned reasoning idea to obtain the reply information for the question to be replied.
[0020] In the above manner, the target high-quality question-answer pair includes the historical question, the answer corresponding to the historical question, and the reasoning process for obtaining the answer. The large language model learns the reasoning idea of the reasoning process in the target high-quality question-answer pair through the target prompt. After learning the high-quality reasoning idea, based on this reasoning idea, reasoning analysis is performed on the target text block, improving the accuracy of reasoning analysis and thus the accuracy of question answering.
[0021] In a possible implementation manner, the knowledge base also stores the title included in each text block and the title level corresponding to the title;
[0022] After finding the target text block that matches the received question to be replied, and before filling the question to be replied, the target text block, and the target high-quality question-answer pair into the prompt template, the method further includes:
[0023] Obtain the target title and title level corresponding to the target text block, and all the target titles and title levels before the target text block in the complete reference information where the target text block is located;
[0024] Sort each target title according to the title level of each target title and the order of each target title in the reference information to obtain a reference table of contents;
[0025] The step of filling the question to be replied, the target text block, and the target high-quality question-answer pair into the prompt template to obtain a target prompt includes:
[0026] Fill the question to be replied, the target text block, the target high-quality question-answer pair, and the reference table of contents into the prompt template to obtain a target prompt.
[0027] In the above manner, according to the target title of the target text block and all the target titles before the target text block, a reference table of contents is determined, and the target prompt including the question to be replied, the target text block, the input of the target high-quality question-answer pair, and the reference table of contents is input into the large language model. The large language model is used to refer to the content included in the target text block, the input of the target high-quality question-answer pair, and the reference table of contents during analysis, thereby enabling the large language model to analyze more comprehensive knowledge and improving the accuracy of question answering.
[0028] In a possible implementation, the method further includes:
[0029] If no target text block and target high-quality Q&A pair matching the question to be answered are found, a prompt word including an example question is output, and the prompt word is used to prompt to adjust the question content according to the example question and re-enter the question to be answered.
[0030] In the above manner, when no target text block and target high-quality Q&A pair matching the question to be answered are found, it is considered that the input question to be answered may be irregular, and a prompt word including an example question is output, so as to facilitate the user to adjust the question content based on the example question. Through this method, the question to be answered can be standardized, thereby improving the Q&A accuracy.
[0031] In a possible implementation, the method further includes:
[0032] Obtain the evaluation made by the user for the reply information;
[0033] If the evaluation meets the requirements of the preset high-quality Q&A evaluation criteria, add the reply information corresponding to the question to be answered to the historical high-quality Q&A library.
[0034] In the above manner, after the Q&A is completed, the user is invited to evaluate the reply information, and then according to the user's evaluation, the high-quality Q&A pair is added to the historical high-quality Q&A library, realizing the real-time update of the historical high-quality Q&A library, making the content covered by the high-quality Q&A pairs included in the historical high-quality Q&A library more comprehensive, and thus improving the accuracy of subsequent Q&A.
[0035] In a possible implementation, the process of determining the knowledge base includes:
[0036] Collect the published reference information and identify each title included in the reference information;
[0037] Divide the reference information into multiple text blocks according to the position of each title in the reference information and save them to the knowledge base.
[0038] In the above manner, when determining the knowledge base, the electronic device is used to automatically identify each title included in the reference information and automatically divide the reference information into multiple text blocks according to the position of the title in the reference information, eliminating the cumbersome steps of manual preprocessing of the reference information and improving the efficiency of information processing.
[0039] In a second aspect, an embodiment of the present application further provides a Q&A device, and the device includes:
[0040] A retrieval module, configured to search for a target text block that matches the received question to be answered in a pre-configured knowledge base; and search for a target high-quality Q&A pair that matches the question to be answered in a historical high-quality Q&A database.
[0041] A determination module, configured to fill the question to be answered, the target text block, and the target high-quality Q&A pair into a prompt template to obtain a target prompt.
[0042] A Q&A module, configured to input the target prompt into a large language model to obtain a reply message for the question to be answered.
[0043] In a third aspect, an embodiment of the present application further provides an electronic device, which at least includes a processor and a memory. When the processor executes a computer program stored in the memory, the steps of the Q&A method described in any one of the above are implemented.
[0044] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the Q&A method described in any one of the above are implemented.
[0045] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes computer program code. When the computer program code runs on a computer, the computer is caused to execute the steps of the Q&A method described in any one of the above in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] To more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0047] Figure 1 A schematic diagram of a Q&A process provided by an embodiment of the present application;
[0048] Figure 2 A schematic diagram of a Q&A process provided by an embodiment of the present application;
[0049] Figure 3 A schematic diagram of the structure of a Q&A device provided by an embodiment of the present application;
[0050] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0051] To make the objectives and implementation manners of this application clearer, the following will clearly and completely describe the exemplary implementation manners of this application with reference to the accompanying drawings in the exemplary embodiments of this application. Apparently, the described exemplary embodiments are only a part rather than all of the embodiments of this application.
[0052] It should be noted that the brief description of the terms in this application is only for facilitating the understanding of the subsequent described implementation manners, rather than intending to limit the implementation manners of this application. Unless otherwise specified, these terms should be understood in their ordinary and common meanings.
[0053] The terms "first", "second", "third", etc. in the description, claims and the above accompanying drawings of this application are used to distinguish similar or like objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that such terms can be interchanged under appropriate circumstances.
[0054] The terms "comprising" and "having" and any variations thereof are intended to cover but not be exclusive of inclusion. For example, a product or device comprising a series of components does not necessarily have to be limited to all the components clearly listed, but may include other components not clearly listed or inherent to these products or devices.
[0055] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or a combination of hardware or / and software code that can perform functions related to that element.
[0056] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, rather than to limit them; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of this application.
[0057] For the sake of convenience of explanation, the above description has been made in conjunction with specific implementation manners. However, the above exemplary discussion is not intended to be exhaustive or to limit the implementation manners to the specific forms disclosed above. According to the above teachings, various modifications and variations can be obtained. The selection and description of the above implementation manners are for better explaining the principles and practical applications, so that those skilled in the art can better use the implementation manners and various different variations of the implementation manners suitable for specific use considerations.
[0058] The embodiments of the present application provide a question-and-answer method, device, equipment, and medium. This method retrieves relevant information that matches the question to be answered using a knowledge base, and then inputs the retrieved relevant information into a large language model according to a specific prompt template for question and answer, which can effectively utilize the existing knowledge and the summarization ability of the large model to give corresponding analysis. Specifically, in this method, in a pre-configured knowledge base, a target text block that matches the received question to be answered is searched for; in a historical high-quality question-and-answer library, a target high-quality question-and-answer pair that matches the question to be answered is searched for; the question to be answered, the target text block, and the target high-quality question-and-answer pair are filled into the prompt template to obtain a target prompt; the target prompt is input into the large language model to obtain the answer information for the question to be answered. In the embodiments of the present application, a target text block and a target high-quality question-and-answer pair that match the question to be answered are searched for, and the target prompt input into the large language model is determined based on the question to be answered, the target text block, and the target high-quality question-and-answer pair. Then, by using the powerful semantic understanding ability of the large language model, the answer information for the question to be answered is determined. As long as the information collected in the knowledge base and the historical high-quality question-and-answer library is timely and comprehensive, and a target text block and a target high-quality question-and-answer pair that match the question to be answered can be retrieved, the large language model can refer to the content recorded in the target text block and the target high-quality question-and-answer pair for accurate analysis and obtain an accurate answer, achieving the purpose of accurate question and answer in a vast amount of information.
[0059] Embodiment 1:
[0060] Figure 1 FIG. is a schematic diagram of a question-and-answer process provided by the embodiments of the present application. This process includes:
[0061] S101: In a pre-configured knowledge base, search for a target text block that matches the received question to be answered.
[0062] The question-and-answer method provided by the embodiments of the present application is applied to an electronic device, which can be a computer (Personal Computer, PC), a server, etc.
[0063] When hoping to pay attention to a certain piece of information, a question to be answered can be input to the electronic device so that the electronic device can make a corresponding answer based on the received question to be answered. Exemplarily, the question to be answered can be: "What is the highest temperature today?", "Tell me what the article 'XXXX' is mainly about", or any other question. Among them, the question to be answered can be directly input by the user or sent by other electronic devices connected to the electronic device. The embodiments of the present application do not limit this.
[0064] After obtaining the question to be answered, a target text block that matches the received question to be answered can be searched for in a pre-configured knowledge base. The knowledge base can be a local knowledge base or an Internet knowledge base. Information in various fields is stored in the knowledge base. Relevant personnel can regularly collect the latest released information and store it in the knowledge base to ensure that the information stored in the knowledge base is comprehensive and up-to-date. In the embodiments of the present application, each piece of information collected can be stored as a text block in the knowledge base respectively; or each piece of information can be segmented into multiple text blocks according to a preset segmentation rule and then stored in the knowledge base.
[0065] The target text block that matches the question to be answered can be understood as one or more target text blocks with a relatively high semantic similarity to the question to be answered. In the embodiments of the present application, the question to be answered and the text block can be vectorized first to obtain the vector matrix of the question to be answered and the vector matrix of the text block. When determining the similarity, the similarity between the vector matrix of the question to be answered and the vector matrix of the text block can be determined. It should be noted that how to vectorize the text is a prior art, and the embodiments of the present application do not limit this, as long as the method used to determine the vector matrix corresponding to each text is the same.
[0066] S102: Search for a target high-quality question-and-answer pair that matches the question to be answered in the historical high-quality question-and-answer library.
[0067] In order to improve the accuracy of question answering, in the embodiments of the present application, a historical high-quality question-and-answer library can be pre-configured. High-quality question-and-answer pairs are saved in the historical high-quality question-and-answer library. The high-quality question-and-answer pairs can be pre-written manually or high-quality question-and-answer pairs selected from historical question-and-answer conversations.
[0068] In the embodiments of the present application, the semantic similarity between the question to be answered and each high-quality question-and-answer pair in the historical high-quality question-and-answer library can be determined, so as to determine a target high-quality question-and-answer pair that matches the question to be answered according to each semantic similarity.
[0069] In a possible implementation manner, the semantic similarity between the question to be answered and the historical question included in the high-quality question-and-answer pair can be determined. This semantic similarity is determined as the semantic similarity between the question to be answered and this high-quality question-and-answer pair.
[0070] In a possible implementation manner, all the content of a high-quality question-and-answer pair can be used as a whole piece of information, and the semantic similarity between the question to be answered and the information corresponding to all the content of the high-quality question-and-answer can be determined. This similarity is determined as the semantic similarity between the question to be answered and this high-quality question-and-answer pair.
[0071] S103: Fill the question to be answered, the target text block, and the target high-quality Q&A pair into the prompt template to obtain a target prompt; input the target prompt into a large language model to obtain the answer information for the question to be answered.
[0072] In order to enable the large language model to accurately generate the answer information for the question to be answered, in the embodiments of the present application, a prompt template is pre-configured. After obtaining the target text block and the target high-quality Q&A pair, the question to be answered, the target text block, and the target high-quality Q&A pair can be filled into the prompt template to obtain a target prompt. The target prompt is used to prompt the large language model to analyze the target text block and the target high-quality Q&A pair, so as to obtain the answer information for the question to be answered. It should be noted that those skilled in the art can configure the prompt template according to needs.
[0073] After obtaining the target prompt, the target prompt can be input into the large language model. Based on the characteristics of the large language model, after receiving the input target prompt, the large language model will analyze the information included in the target prompt, so as to output the answer information for the question to be answered. Even if the large language model does not learn relevant knowledge during training, due to the powerful semantic understanding ability of the large language model, the large language model can also accurately generate the answer information for the question to be answered by analyzing the target text block and the target high-quality Q&A pair during the Q&A process.
[0074] When determining the answer information, the large language model can, based on the prompt of the received target prompt, compare the rationality between the answer information included in the target high-quality Q&A pair and the answer information to be given for the question to be answered. If the rationality between the two answer information is relatively low, the large language model can re-analyze the question to be answered. For example, the question to be answered is "Analyze the average temperature in Changping District, Beijing in the summer of 2024", and the found target high-quality Q&A pair is "Analyze the average temperature in Changping District, Beijing in the summer of 2023-----The average temperature in Changping District, Beijing in the summer of 2023 was 28.6°C". The large language model analyzes the found target text block and initially determines that the answer information corresponding to this question to be answered is "The average temperature in Changping District, Beijing in the summer of 2024 was 24.2°C". Since the average temperatures in the same area between the two answer information differ significantly and the rationality is relatively low, the large language model can re-analyze the target text block to obtain new answer information. Of course, it is also possible to re-search for a matching target text block in the knowledge base and re-determine the answer information for the question to be answered based on the newly found target text block.
[0075] In the embodiments of the present application, a target text block and a target high-quality Q&A pair that match the question to be answered are found, and a target prompt word input into the large language model is determined based on the question to be answered, the target text block, and the target high-quality Q&A pair. Then, by leveraging the powerful semantic understanding ability of the large language model, the answer information for the question to be answered is determined. As long as the information collected in the knowledge base and the historical high-quality Q&A database is timely and comprehensive, and the target text block and the target high-quality Q&A pair that match the question to be answered can be retrieved, the large language model can accurately analyze by referring to the content recorded in the target text block and the target high-quality Q&A pair, obtain an accurate answer, and achieve the purpose of accurate question answering in a vast amount of information.
[0076] Embodiment 2:
[0077] In order to further improve the accuracy of question answering, based on the above embodiments, in the embodiments of the present application, after finding a target text block that matches the received question to be answered in a pre-configured knowledge base, before filling the question to be answered, the target text block, and the target high-quality Q&A pair into a prompt word template, the method further includes:
[0078] If there are multiple target text blocks, for each target text block, obtain other text blocks adjacent to the target text block in the complete reference information where the target text block is located; respectively determine the similarity between the question to be answered and the target text block, and each other text block; according to each similarity, determine the target similarity between the question to be answered and the target text block;
[0079] Delete the target text blocks that do not meet the preset similarity requirement according to each target similarity.
[0080] If the number of determined target text blocks is multiple, in order to screen out the most matching and relevant target text blocks among the multiple target text blocks, thereby improving the accuracy of the provided answer information, in the embodiments of the present application, after determining the target text blocks, before filling the question to be answered, the target text blocks, and the target high-quality Q&A pair into the prompt word template, for each target text block, other text blocks adjacent to the target text block in the complete reference information where the target text block is located can be obtained. In the embodiments of the present application, if the target text block is a fragment in an article, then the complete reference information where the target text block is located is this article; if the target text block is a fragment in a certain news report, then the complete reference information where the target text block is located is this news report.
[0081] In a possible implementation, the source of each text block can be saved in a pre-configured knowledge base. Among them, the source can be information such as the article name, web page address, storage address, etc. When determining other text blocks adjacent to the target text block, the target source corresponding to the target text block can be determined according to the corresponding relationship between each saved text block and its source, and the complete reference information corresponding to the target source can be searched for. In the embodiments of the present application, the complete reference information corresponding to the source can be searched for on the Internet according to the identified source; or the complete reference information corresponding to the source can be searched for in a pre-saved database. That is to say, the complete reference information where each text block is located can exist on the Internet or be saved in the local database. After obtaining the complete reference information, the location where the target text block is located can be found in the complete reference information, and the text of a preset length before this location and the text of a preset length after this location can be determined as other text blocks. Exemplarily, if the target text block is in the 26th paragraph of the complete reference information, then the text of the 25th paragraph and the 27th paragraph in the complete reference information can be determined as other text blocks.
[0082] In a possible implementation, in a pre-configured knowledge base, the source of each text block, as well as the location of the text block in the complete reference information corresponding to the source, can be saved. For the convenience of subsequent searching, in the embodiments of the present application, the text blocks with the same source can be saved centrally. Exemplarily, the text blocks can be saved in sequence according to the order of their locations in the corresponding complete reference information. For example, if the 56th row in data table A saves the relevant information of the 22nd paragraph of the article "XXX", then the 57th row in data table A saves the relevant information of the 23rd paragraph of the article "XXX". When determining other text blocks adjacent to the target text block, the location where the target text block is located can be obtained in the knowledge base, and based on this location, other text blocks adjacent to the target text block can be found in the knowledge base.
[0083] After determining other text blocks adjacent to the target text block, the similarities between the question to be answered and the target text block, as well as each other text block, can be determined respectively. After obtaining each similarity, the target similarity between the question to be answered and the target text block can be determined according to each similarity. In the embodiments of the present application, when determining the target similarity according to multiple similarities, the sum value of all similarities can be determined as the target similarity, or the average value of all similarities can be determined as the target similarity. The embodiments of the present application do not limit this.
[0084] Specifically, assume that the similarity between the question to be answered and the target text block is 0.97, the similarity between the question to be answered and another text block A is 0.86, and the similarity between the question to be answered and another text block B is 0.77. Then, it can be determined that the target similarity between the question to be answered and the target text block is (0.97 + 0.86 + 0.77) / 3 = 0.87.
[0085] After determining the target similarity between the question to be answered and each target text block, the target text blocks that do not meet the preset similarity requirement can be deleted according to each target similarity. Among them, the preset similarity requirement can be a preset threshold, or it can be to sort all the target text blocks according to the target similarity, and the first N target text blocks in the sorting are the text blocks that meet the requirements. Those skilled in the art can configure the preset similarity requirement according to needs.
[0086] In the embodiment of the present application, when there are multiple determined target text blocks, for each target text block, other text blocks adjacent to the target text block in the complete reference information where the target text block is located are obtained, and then the similarity between the question to be answered and the target text block, as well as each other text block, is determined respectively, so as to determine the target similarity of the target text block. After obtaining the target similarity of each target text block, the target text blocks that meet the preset similarity requirement can be selected by sorting, ensuring that the target text block is highly similar to the question to be answered, thereby improving the accuracy of question answering.
[0087] Embodiment 3:
[0088] In order to further improve the accuracy of question answering, on the basis of the above embodiments, in the embodiment of the present application, the target high-quality question-answer pair includes a historical question, the answer corresponding to the historical question, and the reasoning process for obtaining the answer;
[0089] The process by which the large language model obtains the answer information to the question to be answered according to the target prompt includes:
[0090] The large language model learns the reasoning idea of the reasoning process according to the requirements of the target prompt, and performs reasoning analysis on the target text block based on the learned reasoning idea to obtain the answer information to the question to be answered.
[0091] In order to improve the accuracy of question answering, in the embodiments of the present application, the determined target high-quality question-answer pairs may include historical questions, the answers corresponding to the historical questions, and the reasoning process for obtaining the answers. Among them, the reasoning process may be pre-written and stored in an electronic device by relevant personnel. The reasoning process may be a text for describing which analyses the large language model has performed based on existing knowledge to obtain the answer corresponding to the historical question. Since the target high-quality question-answer pairs include the reasoning process for obtaining the answers, in the embodiments of the present application, when the large language model determines the reply information for the question to be answered according to the received target prompt, the large language model may learn the reasoning idea of the reasoning process according to the requirements in the target prompt, and perform reasoning analysis on the target text block based on the learned reasoning idea to obtain the reply information for the question to be answered. How the large language model performs corresponding processing based on the received target prompt is prior art, and the embodiments of the present application will not elaborate on this process.
[0092] In the embodiments of the present application, the target high-quality question-answer pairs include historical questions, the answers corresponding to the historical questions, and the reasoning process for obtaining the answers. The large language model learns the reasoning idea of the reasoning process in the target high-quality question-answer pairs through the target prompt. After learning the high-quality reasoning idea, based on this reasoning idea, the target text block is subjected to reasoning analysis, which improves the accuracy of the reasoning analysis and further improves the accuracy of question answering.
[0093] Embodiment 4:
[0094] In order to further improve the accuracy of question answering, on the basis of the above embodiments, in the embodiments of the present application, the knowledge base also stores the title included in each text block and the title level corresponding to the title;
[0095] After finding the target text block that matches the received question to be answered, before filling the question to be answered, the target text block, and the target high-quality question-answer pair into the prompt template, the method further includes:
[0096] Obtain the target title and title level corresponding to the target text block, and all the target titles and title levels before the target text block in the complete reference information where the target text block is located;
[0097] Sort each target title according to the title level of each target title and the order of each target title in the reference information to obtain a reference table of contents;
[0098] Filling the question to be answered, the target text block, and the target high-quality question-answer pair into the prompt template to obtain a target prompt includes:
[0099] Fill the to-be-answered question, the target text block, the target high-quality Q&A pair, and the reference table of contents into the prompt template to obtain the target prompt.
[0100] Since the title of the whole article can summarize the content to be expressed in the whole article, in the embodiments of the present application, the title included in each text block and the title level corresponding to the title can also be stored in the knowledge base.
[0101] After determining the target text block that matches the to-be-answered question, before filling the to-be-answered question, the target text block, and the target high-quality Q&A pair into the prompt template, the target title and title level corresponding to the target text block, and all the target titles and title levels before the target text block in the complete reference information where the target text block is located can be obtained. After obtaining each target title and the corresponding title level, each target title can be sorted according to the title level of each target title and the order of each target title in the complete reference information, so as to obtain the reference table of contents. Since the titles in the reference table of contents can reflect the content to be expressed in the complete reference information, the reference table of contents can be understood as an abstract of the target text block and all the content before the target text block. In the embodiments of the present application, when determining the target prompt, the to-be-answered question, the target text block, the target high-quality Q&A pair, and the reference table of contents can be filled into the prompt template to obtain the target prompt. So that when the large language model obtains the reply information, it can refer to the content recorded in the target text block, the target high-quality Q&A pair, and the reference table of contents for reply.
[0102] In the embodiments of the present application, according to the target title of the target text block and all the target titles before the target text block, the reference table of contents is determined, and the target prompt including the to-be-answered question, the target text block, the target high-quality Q&A pair input, and the reference table of contents is input into the large language model. The large language model refers to the content included in the target text block, the target high-quality Q&A pair input, and the reference table of contents during analysis, thereby enabling the large language model to analyze more comprehensive knowledge and improving the Q&A accuracy.
[0103] To further improve the Q&A accuracy, on the basis of the above embodiments, in the embodiments of the present application, the target high-quality Q&A pair includes a historical question, the answer corresponding to the historical question, and the reasoning process for obtaining the answer;
[0104] The process by which the large language model obtains the reply information for the to-be-answered question according to the target prompt includes:
[0105] The large language model learns the reasoning idea of the reasoning process according to the requirements of the target prompt, and performs reasoning analysis on the target text block and the reference directory based on the learned reasoning idea to obtain the reply information of the question to be answered.
[0106] To improve the accuracy of question answering, in the embodiments of the present application, the determined target high-quality question-answer pairs may include historical questions, the answers corresponding to the historical questions, and the reasoning process for obtaining the answers. Since the target high-quality question-answer pairs include the reasoning process for obtaining the answers, in the embodiments of the present application, when the large language model determines the reply information of the question to be answered according to the received target prompt, the large language model can learn the reasoning idea of the reasoning process according to the requirements in the target prompt, and perform reasoning analysis on the target text block and the reference directory based on the learned reasoning idea to obtain the reply information of the question to be answered. How the large language model performs corresponding processing based on the received target prompt is the prior art, and the embodiments of the present application will not elaborate on this process.
[0107] In the embodiments of the present application, the large language model is enabled to learn the reasoning idea of the reasoning process in the target high-quality question-answer pairs through the target prompt. After learning the high-quality reasoning idea, the target text block and the reference directory are subjected to reasoning analysis based on this reasoning idea, improving the accuracy of the reasoning analysis, and thus improving the accuracy of question answering.
[0108] Embodiment 5:
[0109] To further improve the accuracy of question answering, on the basis of the above embodiments, in the embodiments of the present application, the method further includes:
[0110] If no target text block and target high-quality question-answer pair matching the question to be answered are found, a prompt containing sample questions is output, and the prompt is used to prompt to adjust the question content according to the sample questions and re-enter the question to be answered.
[0111] Due to the uncertainty of the input question to be answered, it is very likely that the input question to be answered is not standardized, and the accuracy of the reply information obtained based on such a question to be answered is also not high. Therefore, in the embodiments of the present application, when it is determined that there is a problem with the question to be answered, sample questions can be output for the user to refer to.
[0112] If no target text block and target high-quality Q&A pair matching the question to be answered are found, it may be due to the non-standard input of the question to be answered. In the embodiments of the present application, a prompt word containing example questions can be output. The prompt word is used to prompt the user to adjust the question content according to the displayed example questions and re-enter the question to be answered. In the embodiments of the present application, professional personnel can pre-write example questions corresponding to possible question contents. When outputting the prompt word containing example questions, the example questions matching the question to be answered can be searched in the pre-saved example questions, and the found matching example questions can be carried in the prompt word for output; or all the pre-written example questions can be carried in the example questions for output.
[0113] In the embodiments of the present application, when no target text block and target high-quality Q&A pair matching the question to be answered are found, it is considered that the input question to be answered may be non-standard, and a prompt word containing example questions is output to facilitate the user to adjust the question content based on the example questions. Through this method, the question to be answered can be standardized, thereby improving the Q&A accuracy rate.
[0114] Embodiment 6:
[0115] To further improve the Q&A accuracy rate, based on the above embodiments, in the embodiments of the present application, the method further includes:
[0116] Obtaining an evaluation made by the user for the reply information;
[0117] If the evaluation meets the requirements of the preset high-quality Q&A evaluation criteria, the reply information corresponding to the question to be answered is added to the historical high-quality Q&A library.
[0118] In the embodiments of the present application, each high-quality Q&A pair included in the historical high-quality Q&A library can be screened according to user evaluations. After the response information for the question to be answered determined by the large language model is output, a prompt message for inviting the user to evaluate the accuracy of the response information can be output. If the user makes a corresponding evaluation based on the prompt message, it can be determined whether to save the question to be answered and the response information as a high-quality Q&A pair in the historical high-quality Q&A library based on this evaluation and a preset high-quality Q&A evaluation criterion. If the evaluation made by the user meets the requirements of the preset high-quality Q&A evaluation criterion, the response information corresponding to the question to be answered can be added to the historical high-quality Q&A library. If not, the question to be answered and the response information can be discarded. Exemplarily, the high-quality Q&A evaluation criterion can be that the user's score for this Q&A is greater than a score threshold. For example, when the user's score is greater than 9, it is confirmed that the requirements of the preset high-quality Q&A evaluation criterion are met. The high-quality Q&A evaluation criterion can also be to perform semantic analysis on the evaluation made by the user, and if the analyzed semantics is "satisfied", it is confirmed that the requirements of the preset high-quality Q&A evaluation criterion are met.
[0119] In the embodiments of the present application, after the Q&A is completed, the user is invited to evaluate the response information, and then according to the user's evaluation, the high-quality Q&A pair is added to the historical high-quality Q&A library, realizing the real-time update of the historical high-quality Q&A library, making the content covered by the high-quality Q&A pairs included in the historical high-quality Q&A library more comprehensive, and thus improving the accuracy of subsequent Q&A.
[0120] In a possible implementation manner, after the number of high-quality Q&A pairs in the historical high-quality Q&A library accumulates to a certain amount, in order for the large language model to perform better Q&A subsequently, the large language model can be fine-tuned based on the historical high-quality Q&A library. How to fine-tune the large language model is prior art, and the embodiments of the present application will not elaborate on this process.
[0121] Embodiment 7:
[0122] To further improve the accuracy of Q&A, based on the above embodiments, in the embodiments of the present application, the process of determining the knowledge base includes:
[0123] Collect the published reference information and identify each title included in the reference information;
[0124] Divide the reference information into multiple text blocks according to the position of each title in the reference information and save them to the knowledge base.
[0125] At present, in the case of inconvenient communication with the outside world, the private deployment of large language models has become an essential method. Since the training data of large models is very large, the answers to questions in certain fields may not be very professional. At this time, it is necessary to train the model or load some knowledge bases to optimize the answers to questions. In order to avoid the leakage of knowledge base information, general enterprises or units are reluctant to upload private information. Therefore, it is necessary to build a local knowledge base to obtain relevant knowledge, and then input it into the large model for question answering or summarization. In related technologies, in order to build a knowledge base, it is usually necessary to manually go to the designated policy website to view or collect relevant policies, and then assign them to relevant personnel for processing. For policy fields with frequent releases, this process may need to be carried out weekly, resulting in personnel being unable to free themselves from repetitive work and wasting a lot of manpower.
[0126] In the embodiment of the present application, when determining the knowledge base, published reference information can be collected, such as relevant policy data issued on the Internet and internal relevant policy data. For the convenience of subsequent data query, the obtained reference information can be preprocessed. Each collected reference information can be classified and sorted according to the category of the reference information, and then the reference information can be sorted in the Markdown format.
[0127] Specifically, after collecting the published reference information, each title included in the reference information can be identified.
[0128] In a possible implementation manner, when identifying the titles included in the reference information, the titles can be determined according to whether the set position of the paragraph contains specific characters. Exemplarily, if the opening of a certain paragraph has specific characters such as "1.", "2.", "3." or "one", "two", "three", etc., the content included in the paragraph can be determined as the title.
[0129] In a possible implementation manner, when identifying the titles included in the reference information, the titles can be determined according to the number of characters included in the paragraph. Exemplarily, if the total number of characters in a certain paragraph does not exceed 10, the content included in the paragraph can be determined as the title.
[0130] After obtaining each title included in the reference information, the reference information can be divided into multiple text blocks according to the position of each title in the reference information, so that the required fragments can be better hit when determining the target text block in the future. After obtaining each text block, the text block can be saved to the knowledge base.
[0131] In a possible implementation manner, for each title, the article content before the title and the next adjacent title can be divided into a text block.
[0132] In a possible implementation, since there may be multiple adjacent titles, in this embodiment of the present application, if the next paragraph adjacent to any title is the main text of the article, then the title and the main text of the article before the next title adjacent to the title are divided into the same text block; if the next paragraph adjacent to any title is a title, then the title and the next title adjacent to the title are divided into the same text block.
[0133] Since the knowledge base also needs to store the title level corresponding to the title included in each text block, in the embodiment of the present application, the format template corresponding to each title level can be pre-configured, that is, for each title level, the possible formats are exhaustively listed based on experience. For example, the first-level title: use "一." to mark, the font is bold, the font size is 3, and it is bold; the second-level title: use "(一)" to mark, the font is Kaiti GB2312, the font size is 3, and it is bold; the third-level title: use "1." to mark, the font is Fangsong_GB2312, the font size is 3, and it is bold; the fourth-level title: use "(1)" to mark, the font is Fangsong_GB2312, the font size is 3, and it is bold.
[0134] When determining the title level corresponding to each title, for each title, the title level corresponding to the title can be determined according to the pre-saved format template corresponding to each title level and saved in the knowledge base.
[0135] In a possible implementation, since the amount of information included in the knowledge base is extremely large, each text block may be stored in the form of a vector for easy subsequent retrieval.
[0136] In an embodiment of the present application, when determining a knowledge base, an electronic device is used to automatically identify each title contained in the reference information, and automatically divide the reference information into multiple text blocks according to the position of the title in the reference information, thereby eliminating the tedious steps of manually preprocessing the reference information and improving the efficiency of information processing.
[0137] Embodiment 8:
[0138] For ease of understanding, the question-answering process is described below with reference to a specific embodiment. Figure 2 A schematic diagram of a question-and-answer process provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the process includes the following steps:
[0139] S201: receiving a question to be answered input by a user.
[0140] S202: Searching for a target text block that matches the question to be answered in a pre-configured knowledge base, and searching for a target high-quality question-answer pair that matches the question to be answered in a historical high-quality question-answer database.
[0141] S203: Determine whether a target text block and a target high-quality Q&A pair are found. If not, execute S204; if so, execute S205.
[0142] S204: Output a prompt word containing an example question, and wait for the user to re-enter the question to be answered, then continue to execute S201.
[0143] S205: Determine whether the number of target text blocks is multiple. If so, execute S206; if not, execute S207.
[0144] S206: For each target text block, obtain other text blocks adjacent to the target text block in the complete reference information where the target text block is located, respectively determine the similarity between the question to be answered and the target text block, and each other text block, and determine the target similarity of the target text block according to each similarity; delete the target text blocks that do not meet the preset similarity requirement according to the target similarity of each target text block.
[0145] S207: For each target text block, obtain the target title and title level corresponding to the target text block, and all the target titles and title levels before the target text block in the complete reference information where the target text block is located; sort each target title according to the title level of each target title and the order of each target title in the reference information to obtain a reference table of contents.
[0146] S208: Fill the question to be answered, the target high-quality Q&A pair, the target text block, and the reference table of contents corresponding to the target text block into the prompt word template to obtain a target prompt word.
[0147] S209: Input the target prompt word into a large language model to obtain the answer information for the question to be answered.
[0148] Embodiment 9:
[0149] Based on the same technical concept, on the basis of the above embodiments, the present application provides a Q&A device. Figure 3 As shown in Figure 3 the structure schematic diagram of a Q&A device provided by an embodiment of the present application,
[0150] A retrieval module 301, configured to search for a target text block matching the received question to be answered in a pre-configured knowledge base; search for a target high-quality Q&A pair matching the question to be answered in a historical high-quality Q&A database.
[0151] A determination module 302, configured to fill the question to be answered, the target text block, and the target high-quality question-and-answer pair into a prompt template to obtain a target prompt;
[0152] A question-and-answer module 303, configured to input the target prompt into a large language model to obtain a reply message for the question to be answered.
[0153] In a possible implementation manner, the apparatus further includes:
[0154] A screening module 304, configured to, if there are multiple target text blocks, for each target text block, obtain other text blocks adjacent to the target text block in the complete reference information where the target text block is located; respectively determine the similarity between the question to be answered and the target text block and each other text block; according to each similarity, determine the target similarity between the question to be answered and the target text block; and delete the target text blocks that do not meet the preset similarity requirement according to each target similarity.
[0155] In a possible implementation manner, the target high-quality question-and-answer pair includes a historical question, an answer corresponding to the historical question, and an inference process for obtaining the answer;
[0156] The question-and-answer module 303 is specifically configured to enable the large language model to learn the inference idea of the inference process according to the requirements of the target prompt, and perform inference analysis on the target text block based on the learned inference idea to obtain a reply message for the question to be answered.
[0157] In a possible implementation manner, the knowledge base further stores a title included in each text block and a title level corresponding to the title;
[0158] The determination module 302 is further configured to obtain the target title and title level corresponding to the target text block, and all target titles and title levels before the target text block in the complete reference information where the target text block is located; sort each target title according to the title level of each target title and the order of each target title in the reference information to obtain a reference table of contents; and fill the question to be answered, the target text block, the target high-quality question-and-answer pair, and the reference table of contents into a prompt template to obtain a target prompt.
[0159] In a possible implementation manner, the apparatus further includes:
[0160] A prompt module 305, configured to output a prompt containing sample questions if no target text block and target high-quality question-and-answer pair matching the question to be answered are found, where the prompt is used to prompt to adjust the question content according to the sample questions and re-enter the question to be answered.
[0161] In a possible implementation, the screening module 304 is further configured to obtain an evaluation made by a user for the reply information; if the evaluation meets the requirements of a preset high-quality Q&A evaluation criterion, add the reply information corresponding to the question to be replied to the historical high-quality Q&A library.
[0162] In a possible implementation, the determination module 302 is further configured to collect published reference information and identify each title included in the reference information; divide the reference information into multiple text blocks according to the position of each title in the reference information, and save them to the knowledge base.
[0163] Example 10:
[0164] Based on the same technical concept, the present application further provides an electronic device, Figure 4 which is a schematic structural diagram of an electronic device provided in an embodiment of the present application, as Figure 4 shown, including: a processor 401, a communication interface 402, a memory 403, and a communication bus 404. Among them, the processor 401, the communication interface 402, and the memory 403 complete communication with each other through the communication bus 404;
[0165] A computer program is stored in the memory 403. When the program is executed by the processor 401, the processor 401 is caused to execute the following steps:
[0166] In a pre-configured knowledge base, search for a target text block that matches the received question to be replied;
[0167] In the historical high-quality Q&A library, search for a target high-quality Q&A pair that matches the question to be replied;
[0168] Fill the question to be replied, the target text block, and the target high-quality Q&A pair into a prompt template to obtain a target prompt;
[0169] Input the target prompt into a large language model to obtain a reply information for the question to be replied.
[0170] In a possible implementation, the processor 401 is further configured to, if there are multiple target text blocks, for each target text block, obtain other text blocks adjacent to the target text block in the complete reference information where the target text block is located; respectively determine the similarity between the question to be replied and the target text block, and each other text block; according to each similarity, determine the target similarity between the question to be replied and the target text block; and delete the target text blocks that do not meet the preset similarity requirement according to each target similarity.
[0171] In a possible implementation, the target high-quality Q&A pair includes a historical question, the answer corresponding to the historical question, and the reasoning process for obtaining the answer; the processor 401 is further configured to enable the large language model to learn the reasoning idea of the reasoning process according to the requirements of the target prompt word, and perform reasoning analysis on the target text block based on the learned reasoning idea to obtain the reply information for the question to be answered.
[0172] In a possible implementation, the knowledge base further stores the title included in each text block and the title level corresponding to the title; the processor 401 is further configured to obtain the target title and title level corresponding to the target text block, and all the target titles and title levels before the target text block in the complete reference information where the target text block is located; sort each target title according to the title level of each target title and the order of each target title in the reference information to obtain a reference table of contents; fill the question to be answered, the target text block, the target high-quality Q&A pair, and the reference table of contents into the prompt word template to obtain the target prompt word.
[0173] In a possible implementation, the processor 401 is further configured to output a prompt word containing an example question if no target text block and target high-quality Q&A pair matching the question to be answered are found, and the prompt word is used to prompt to adjust the question content according to the example question and re-enter the question to be answered.
[0174] In a possible implementation, the processor 401 is further configured to obtain the evaluation made by the user on the reply information.
[0175] If the evaluation meets the requirements of the preset high-quality Q&A evaluation criteria, add the reply information corresponding to the question to be answered to the historical high-quality Q&A library.
[0176] In a possible implementation, the processor 401 is further configured to collect the published reference information and identify each title included in the reference information.
[0177] Split the reference information into multiple text blocks according to the position of each title in the reference information and store them in the knowledge base.
[0178] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0179] The communication interface 402 is used for communication between the above electronic device and other devices.
[0180] The memory may include a Random Access Memory (RAM), or may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0181] The above processor may be a general-purpose processor, including a central processing unit, a Network Processor (NP), etc.; it may also be a Digital Signal Processing (DSP), an application-specific integrated circuit, a field-programmable gate array, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0182] Embodiment 11:
[0183] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program executable by an electronic device. When the program runs on the electronic device, it enables the electronic device to implement any of the above embodiments when executed.
[0184] The above computer-readable storage medium may be any available medium or data storage device accessible by the processor in the electronic device, including but not limited to magnetic memories such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical memories such as CDs, DVDs, BDs, HVDs, etc., and semiconductor memories such as ROM, EPROM, EEPROM, Non-Volatile Memory (NANDFLASH), Solid State Drives (SSD), etc.
[0185] Based on the same inventive concept, an embodiment of the present application also provides a computer program product, which includes computer program code. When the computer program code runs on a computer, it causes the computer to execute any of the above embodiments. Since the principle of the above computer program product for solving problems is similar to that of the Q&A method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be elaborated here.
[0186] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0187] The present application is described with reference to the flowcharts and / or block diagrams of the method, device (system), and computer program product according to the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the specified functions in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0188] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implements the specified functions in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0189] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0190] Obviously, those skilled in the art can make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application is also intended to include these changes and modifications.
Claims
1. A question-and-answer method, characterized in that The method includes: In a pre-configured knowledge base, searching for a target text block that matches the received question to be answered; In a historical high-quality Q&A database, searching for a target high-quality Q&A pair that matches the question to be answered; Filling the question to be answered, the target text block, and the target high-quality Q&A pair into a prompt template to obtain a target prompt; Inputting the target prompt into a large language model to obtain the answer information for the question to be answered.
2. The method according to claim 1, characterized in that, After searching for a target text block that matches the received question to be answered in the pre-configured knowledge base and before filling the question to be answered, the target text block, and the target high-quality Q&A pair into the prompt template, the method further includes: If there are multiple target text blocks, for each target text block, obtaining other text blocks adjacent to the target text block in the complete reference information where the target text block is located; respectively determining the similarity between the question to be answered and the target text block, and each other text block; according to each similarity, determining the target similarity between the question to be answered and the target text block; Deleting the target text blocks that do not meet the preset similarity requirement according to each target similarity.
3. The method according to claim 1, wherein The target high-quality Q&A pair includes a historical question, the answer corresponding to the historical question, and the reasoning process for obtaining the answer; The process by which the large language model obtains the answer information for the question to be answered according to the target prompt includes: The large language model learns the reasoning idea of the reasoning process according to the requirements of the target prompt, and performs reasoning analysis on the target text block based on the learned reasoning idea to obtain the answer information for the question to be answered.
4. The method according to claim 1, wherein The knowledge base also stores the title included in each text block and the title level corresponding to the title; After searching for a target text block that matches the received question to be answered and before filling the question to be answered, the target text block, and the target high-quality Q&A pair into the prompt template, the method further includes: Obtaining the target title and title level corresponding to the target text block, and all the target titles and title levels before the target text block in the complete reference information where the target text block is located; Sorting each target title according to the title level of each target title and the order of each target title in the reference information to obtain a reference table of contents; Filling the question to be answered, the target text block, the target high-quality Q&A pair into the prompt template to obtain a target prompt, includes: Filling the question to be answered, the target text block, the target high-quality Q&A pair, and the reference table of contents into the prompt template to obtain a target prompt.
5. The method according to claim 1, characterized in that The method further includes: If no target text block and target high-quality Q&A pair that match the question to be answered are found, outputting a prompt containing sample questions, where the prompt is used to prompt to adjust the question content according to the sample questions and re-enter the question to be answered.
6. The method according to claim 1, wherein The method further includes: Obtaining the evaluation made by the user for the answer information; If the evaluation meets the requirements of the preset high-quality Q&A evaluation criteria, add the reply information corresponding to the question to be replied to the historical high-quality Q&A library.
7. The method according to claim 1, characterized in that, The process of determining the knowledge base includes: Collect the published reference information and identify each title contained in the reference information; According to the position of each title in the reference information, split the reference information into multiple text blocks and save them to the knowledge base.
8. A question-and-answer device, characterized in that, The device includes: A retrieval module, configured to search for a target text block that matches the received question to be replied in a pre-configured knowledge base; search for a target high-quality Q&A pair that matches the question to be replied in the historical high-quality Q&A library; A determination module, configured to fill the question to be replied, the target text block, and the target high-quality Q&A pair into a prompt template to obtain a target prompt; A Q&A module, configured to input the target prompt into a large language model to obtain a reply information for the question to be replied.
9. An electronic device, characterized in that, The electronic device includes at least a processor and a memory. When the processor executes the computer program stored in the memory, it implements the steps of the Q&A method according to any one of claims 1-7.
10. A computer storage medium, characterized in that, It stores a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device is caused to execute the steps of the Q&A method according to any one of claims 1-7.
Citation Information
Patent Citations
Conversation method and device, storage medium, terminal and computer program product
CN118132731A
Financial domain knowledge question answering method and device, computer equipment, readable storage medium and program product
CN118467704A
Question and answer method and electronic equipment
CN118484519A
Vector knowledge base-based large-model question-answer dialogue method and system and storage medium
CN118484526A
Display device, question and answer method and medium
CN118760743A
Cited By
Question and answer method and device based on artificial intelligence
CN121480528A