An intelligent answering method, device, equipment and nonvolatile storage medium
By constructing a target domain knowledge base and a question base, using a dual-channel retrieval enhancement scheme to generate response information, and performing accuracy scoring, the problem of inaccurate responses caused by low retrieval quality in existing technologies is solved, and the accuracy of response information is improved.
Patent Information
- Application Number
- CN202411379485.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-09-30
AI Technical Summary
Existing search enhancement generation technologies suffer from low search quality in proprietary domains, leading to inaccurate AI-generated response information.
A target domain knowledge base and a question base are constructed. A dual-channel retrieval enhancement scheme is used to retrieve related questions from the target domain question base and generate the first response information, and retrieve related knowledge from the target domain knowledge base and generate the second response information. The response information is generated by combining the pre-trained language model, and the most accurate response information is output through response accuracy scoring.
It improves the accuracy of AI response information generation results, makes up for the shortcomings of inaccurate response information caused by poor quality of related knowledge retrieval in existing technologies, and meets the needs of natural language processing.
Smart Images

Figure CN119293175B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to an intelligent response method, apparatus, device, and non-volatile storage medium. Background Technology
[0002] Retrieval-enhanced generation is an artificial intelligence technique that combines information retrieval technology with language generation models. It retrieves relevant information from external knowledge bases and uses it as prompts to input into a pre-trained language model, thereby enhancing the model's ability to handle knowledge-intensive tasks such as question answering and content generation.
[0003] However, while current retrieval augmentation techniques can improve the natural language processing capabilities of pre-trained language models in knowledge domains to some extent, they are limited by retrieval quality. When retrieval quality is low, resulting in low recall (such as few relevant results or poor matching between retrieved information and the user's question), inaccurate results can still be generated.
[0004] Improving the accuracy of AI-generated response information is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this invention is to provide an intelligent response method, apparatus, device, and non-volatile storage medium to improve the accuracy of artificial intelligence response information generation results.
[0006] To address the aforementioned technical problems, this invention provides an intelligent response method, comprising:
[0007] Utilize target domain knowledge to construct a target domain knowledge base;
[0008] Based on the knowledge of the target domain, questions are generated, and a target domain question library is constructed.
[0009] Based on the question information input by the user, the system retrieves related questions from the target domain question database and calls a pre-trained language model to generate first response information based on the question information and the related questions.
[0010] Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge.
[0011] Based on the question information, the accuracy scores of the first response information and the second response information are calculated respectively, and the response information with the higher accuracy score is output as the result response information in response to the question information.
[0012] On the one hand, based on the question information input by the user, related questions are retrieved from the target domain question database, and a pre-trained language model is invoked to generate first response information based on the question information and the related questions, including:
[0013] Based on the question information, a similarity match is performed in the target domain question database to obtain a first preset number of associated questions that have the highest similarity to the question information;
[0014] After expanding the context of the related question, it is combined with the question information to generate the first prompt;
[0015] The first prompt is input into the pre-trained language model to obtain the first response information.
[0016] On the other hand, based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge, including:
[0017] The question information is used to generate a second prompt, which is then input into the pre-trained language model to output a third response.
[0018] Based on the third response information, a similarity match is performed in the target domain knowledge base to obtain the second preset number of related knowledge items with the highest similarity to the third response information;
[0019] After expanding the context of the related knowledge, it is combined with the question information to generate a third prompt.
[0020] The third prompt is input into the pre-trained language model to obtain the second response information.
[0021] On the other hand, based on the question information, the accuracy of the first response information and the second response information is scored, including:
[0022] Based on the similarity between the first response information and the question information, the accuracy score of the response corresponding to the first response information is calculated;
[0023] The accuracy score of the response is calculated based on the similarity between the second response information and the question information.
[0024] On the other hand, based on the similarity between the first response information and the question information, the accuracy score of the response corresponding to the first response information is calculated, including:
[0025] Keyword extraction is performed on the first response information to obtain a third preset number of first keyword information;
[0026] Calculate the first overlap probability between the first keyword information and the fourth preset number of second keyword information extracted from the question information;
[0027] Calculate the first similarity coefficient between the first response information and the question information;
[0028] The first overlap probability and the first similarity coefficient are weighted and calculated to obtain the response accuracy score corresponding to the first response information;
[0029] Based on the similarity between the second response information and the question information, the accuracy score of the response corresponding to the second response information is calculated, including:
[0030] Keyword extraction is performed on the second response information to obtain a third preset number of third keyword information;
[0031] Calculate the second overlap probability between the third keyword information and the second keyword information;
[0032] Calculate a second similarity coefficient between the second response information and the question information;
[0033] The second overlap probability and the second similarity coefficient are weighted and calculated to obtain the response accuracy score corresponding to the second response information.
[0034] On the other hand, it also includes:
[0035] The question information input by the user is enhanced based on historical question and answer information to obtain enhanced question information;
[0036] Based on the question information input by the user, related questions are retrieved from the target domain question database, and a pre-trained language model is invoked to generate first response information based on the question information and the related questions, including:
[0037] The associated question is retrieved from the target domain question library based on the enhanced question information, and the pre-trained language model is invoked to generate the first response information based on the enhanced question information and the associated question.
[0038] Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge, including:
[0039] The relevant knowledge is retrieved from the target domain knowledge base based on the enhanced question information, and the pre-trained language model is invoked to generate the second response information based on the enhanced question information and the relevant knowledge.
[0040] On the other hand, a target domain knowledge base is constructed using target domain knowledge; questions are generated based on the target domain knowledge to construct a target domain question base, including:
[0041] Obtain file data containing knowledge of the target domain, and extract text blocks from the file data;
[0042] The text block is subjected to vector calculation to obtain the target domain knowledge vector, and the target domain knowledge vector is stored in the first target column of the vector database;
[0043] After the text block is augmented with context, it is input into the pre-trained language model to generate questions related to the target domain;
[0044] Vector calculations are performed on the relevant issues in the target domain to obtain the target domain issue vector, and the target domain issue vector is stored in the second target column of the vector database;
[0045] Intelligent response methods also include:
[0046] The question information input by the user is enhanced based on historical question and answer information to obtain enhanced question information;
[0047] Based on the question information input by the user, related questions are retrieved from the target domain question database, and a pre-trained language model is invoked to generate first response information based on the question information and the related questions, including:
[0048] Based on the enhanced question information, a similarity match is performed in the second target column to obtain a first preset number of associated questions that have the highest similarity to the enhanced question information;
[0049] After expanding the context of the related question, it is combined with the question information to generate the first prompt;
[0050] The first prompt is input into the pre-trained language model to obtain the first response information;
[0051] Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge, including:
[0052] The enhanced question information is used to generate a second prompt, which is then input into the pre-trained language model to output a third response.
[0053] Based on the third response information, a similarity match is performed in the target domain knowledge base to obtain the second preset number of related knowledge items with the highest similarity to the third response information;
[0054] After the contextual knowledge is expanded, it is combined with the enhanced question information to generate a third prompt.
[0055] The third prompt is input into the pre-trained language model to obtain the second response information;
[0056] Based on the question information, the accuracy of the first response information and the second response information is scored, and the response information with the higher accuracy score is output as the result response information to the question information, including:
[0057] Based on the similarity between the first response information and the question information, the accuracy score of the response corresponding to the first response information is calculated;
[0058] Based on the similarity between the second response information and the question information, the accuracy score of the response corresponding to the second response information is calculated;
[0059] The response information with the higher accuracy score is output as the result response information in response to the question information.
[0060] To address the aforementioned technical problems, the present invention also provides an intelligent response device, comprising:
[0061] The database construction module is used to build a target domain knowledge base using target domain knowledge; and to generate questions based on the target domain knowledge to build a target domain question base.
[0062] The user interaction module is used to accept question information input by the user and output the result response information corresponding to the question information to the user.
[0063] The query module is used to retrieve related questions from the target domain question base based on the question information, and call a pre-trained language model to generate first response information based on the question information and the related questions; and to retrieve related knowledge from the target domain knowledge base based on the question information, and call the pre-trained language model to generate second response information based on the question information and the related knowledge.
[0064] The answer evaluation module is used to score the accuracy of the first response information and the second response information based on the question information, and to determine the response information with the higher accuracy score as the result response information in response to the question information.
[0065] To address the aforementioned technical problems, the present invention also provides an intelligent response device, comprising:
[0066] Memory, used to store computer programs;
[0067] A processor for executing the computer program, which, when executed by the processor, implements the steps of the smart response method as described in any of the preceding descriptions.
[0068] To address the aforementioned technical problems, the present invention also provides a non-volatile storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of the intelligent response method as described in any of the above claims.
[0069] The intelligent response method provided by this invention has the advantage of simultaneously constructing a target domain knowledge base using target domain knowledge and generating a target domain question base based on that knowledge. When generating response information based on user-input question information, it performs a correlation search from the target domain question base to obtain related questions and calls a pre-trained language model to generate the first response information. It also performs a correlation search from the target domain knowledge base to obtain related knowledge and calls a pre-trained language model to generate the second response information. The accuracy of the first and second response information is scored based on the question information, and the response information with the higher accuracy score is output as the result response to the question information. This achieves a dual-channel retrieval enhancement scheme. Compared to current retrieval enhancement techniques, this question-based approach better meets the needs of natural language processing, compensating for the inaccuracy of response information generated when the quality of related knowledge retrieval is poor, thereby improving the accuracy of AI-generated response information.
[0070] The intelligent response device, equipment, and non-volatile storage medium provided by the present invention have the above-mentioned beneficial effects, which will not be elaborated further here. Attached Figure Description
[0071] To more clearly illustrate the technical solutions of the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0072] Figure 1 A flowchart of an intelligent response method provided in an embodiment of the present invention;
[0073] Figure 2 A flowchart for constructing a vector database is provided as an embodiment of the present invention;
[0074] Figure 3 A flowchart of a dual-channel retrieval method provided in an embodiment of the present invention;
[0075] Figure 4 This is a schematic diagram of the structure of an intelligent response device provided in an embodiment of the present invention;
[0076] Figure 5 This is a schematic diagram of the structure of an intelligent response device provided in an embodiment of the present invention. Detailed Implementation
[0077] The core of this invention is to provide an intelligent response method, apparatus, device, and non-volatile storage medium to improve the accuracy of artificial intelligence response information generation results.
[0078] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0079] Pre-trained language models (PLMs) are a powerful tool in the field of natural language processing (NLP). They learn general representations of language by pre-training on large amounts of text data and then fine-tuning them to adapt them to specific downstream tasks.
[0080] When using pre-trained language models to handle domain-specific problems, the pre-trained language model can be fine-tuned using domain-specific data to optimize its capabilities in that domain. However, this approach is costly and requires sufficient computing power and a large amount of data.
[0081] Therefore, when dealing with domain-specific AI response problems, the common approach is to combine pre-trained language models with knowledge bases to enhance the capabilities of the pre-trained language models in the domain. This approach does not require significant fine-tuning computation or labeled data; it simply requires constructing a knowledge base within the domain as a tool for the pre-trained language model, assisting it in fulfilling its domain-specific capabilities.
[0082] Retrieval augmentation technology generates responses by retrieving relevant knowledge from a knowledge base that matches the user's input question, forming a prompt, and then inputting this prompt into a pre-trained language model. This effectively addresses the problems of model illusion and model uninterpretability, allowing users to see the basis and source of the answer. However, current retrieval augmentation techniques are limited by the quality of relevant knowledge retrieval; low recall can miss some information, leading to inaccurate or incomplete results.
[0083] To improve the accuracy of AI-generated response information, this invention provides an innovative dual-channel retrieval enhancement scheme from a retrieval enhancement perspective. While constructing a target domain knowledge base using target domain knowledge, it also generates a target domain question base based on this knowledge. When generating response information based on user-inputted question information, it performs a correlation search from the target domain question base to obtain related questions and uses a pre-trained language model to generate the first response information. It also performs a correlation search from the target domain knowledge base to obtain related knowledge and uses the pre-trained language model to generate the second response information. The accuracy of the first and second response information is scored based on the question information, and the response information with the higher accuracy score is output as the result response to the question information. This question-based approach is more in line with the needs of natural language processing than current retrieval enhancement techniques, overcoming the shortcomings of current retrieval enhancement techniques in generating inaccurate response information when the quality of related knowledge retrieval is poor, thereby improving the accuracy of AI-generated response information.
[0084] Based on the above architecture, the intelligent response method provided by the embodiments of the present invention will be described below with reference to the accompanying drawings.
[0085] Figure 1 A flowchart of an intelligent response method provided in an embodiment of the present invention; Figure 2 This is a flowchart of constructing a vector database provided in an embodiment of the present invention.
[0086] like Figure 1 As shown, the intelligent response method provided in this embodiment of the invention includes:
[0087] S101: Construct a target domain knowledge base using target domain knowledge;
[0088] S102: Generate questions based on target domain knowledge and build a target domain question library;
[0089] S103: Based on the question information input by the user, retrieve related questions from the target domain question database, and call the pre-trained language model to generate the first response information based on the question information and related questions;
[0090] S104: Retrieve relevant knowledge from the target domain knowledge base based on the question information, and call the pre-trained language model to generate a second response based on the question information and relevant knowledge;
[0091] S105: Based on the question information, score the accuracy of the first and second response information respectively, and output the response information with the higher accuracy score as the result response information to the question information.
[0092] It should be noted that the "artificial intelligence response" in the embodiments of the present invention includes, but is not limited to, tasks such as artificial intelligence question answering, text classification response, text sentiment analysis response, knowledge retrieval, machine translation, and summary generation.
[0093] The intelligent response method provided in this invention can be implemented by deploying a pre-trained language model, a target domain knowledge base, and a target domain question base on a single server or server cluster. In practical applications, the pre-trained language model, target domain knowledge base, and target domain question base can be deployed in different locations. Specifically, the pre-trained language model can be deployed on a cloud server, while the target domain knowledge base and target domain question base can be deployed on a cloud server or a user terminal. After the user inputs question information from their terminal device, it is uploaded to the cloud server. After retrieval and inference calculations by the pre-trained language model, the resulting response information is obtained. The cloud server then transmits the response information back to the user's terminal device, achieving artificial intelligence-based response.
[0094] In specific implementation, S101 and S102 are used to build an index for the pre-trained language model. In this embodiment of the invention, not only is an index of target domain knowledge built, but also an index of questions related to the target domain knowledge is built.
[0095] Then as Figure 2 As shown, S101 and S102 may include: acquiring file data of target domain knowledge, extracting text blocks from the file data; performing vector calculation on the text blocks to obtain target domain knowledge vectors, and storing the target domain knowledge vectors in the first target column of the vector database. After contextualizing the text blocks, input them into a pre-trained language model to generate target domain-related questions; performing vector calculation on the target domain-related questions to obtain target domain question vectors, and storing the target domain question vectors in the second target column of the vector database.
[0096] When acquiring file data related to a target domain, knowledge documents in that domain can be collected, such as unstructured / semi-structured data and file data in various formats. Text chunks are extracted from the file data; this involves extracting text information from the collected file data and segmenting long texts into chunks based on semantic information to obtain text chunks, which can be denoted as chunk_text.
[0097] In some optional embodiments of the present invention, segmenting long text into blocks according to semantic information to obtain text blocks may include: segmenting the long text with a fixed length, such as segmenting the long text with a fixed number of characters to obtain text blocks. In other optional embodiments of the present invention, segmenting long text into blocks according to semantic information to obtain text blocks may also include: segmenting the long text according to a fixed number of punctuation marks to obtain text blocks.
[0098] Perform vector calculations on the above text blocks and store the obtained target domain knowledge vectors in the first target column (e.g., column E1) of the vector database.
[0099] Meanwhile, the above text blocks are expanded with context. This can be done by obtaining the two text blocks above and below each text block and combining them with the original text block to form a larger text block. The pre-trained language model generates target domain-related questions based on the context-expanded text block, and performs vector calculation on the generated target domain-related questions. The obtained target domain question vectors are then stored in the second target column (e.g., column E2) of the vector database.
[0100] Thus, the process of constructing the vector database is completed, namely, the process of constructing the target domain knowledge base and the target domain question base.
[0101] While using a pre-trained language model in conjunction with a target domain knowledge base and a target domain question base to perform AI response tasks, the target domain knowledge base and the target domain question base can be kept updated.
[0102] When responding to a user's AI-powered response task, the system receives the user's input question information and uses the dual-channel retrieval enhancement methods provided by S103 and S104 to retrieve information based on the question information. This allows the system to generate two types of response information using a pre-trained language model. Finally, the system scores the two responses based on their accuracy, and the one with the higher score is the response to the question information.
[0103] Since the question information input by the user may be vague or expressed in non-common language, the intelligent response method provided in this embodiment of the invention may further include: enhancing the question information input by the user based on historical question and answer information to obtain enhanced question information.
[0104] In step S103, based on the user-input question information, related questions are retrieved from the target domain question base, and a pre-trained language model is invoked to generate a first response based on the question information and related questions. This step may include: retrieving related questions from the target domain question base based on the enhanced question information, and invoking the pre-trained language model to generate the first response based on the enhanced question information and related questions. In step S104, related knowledge is retrieved from the target domain knowledge base based on the question information, and a pre-trained language model is invoked to generate a second response based on the question information and related knowledge. This step may include: retrieving related knowledge from the target domain knowledge base based on the enhanced question information, and invoking the pre-trained language model to generate the second response based on the enhanced question information and related knowledge.
[0105] In some optional embodiments of the present invention, enhancing the user-inputted question information based on historical question-and-answer information to obtain enhanced question information may include: constructing a question-and-answer database based on historical question-and-answer information of the target domain; matching the user-inputted question information in the question-and-answer database to obtain related question-and-answer information; and combining the question information, related question-and-answer information, and the question information enhancement task to obtain a pre-trained language model for prompt input, thereby obtaining the enhanced question information. The question information enhancement task may include: expanding and correcting the question information based on related question-and-answer information.
[0106] The intelligent response method provided in this invention not only constructs a target domain knowledge base using target domain knowledge, but also generates questions based on the target domain knowledge to construct a target domain question base. When generating response information based on user-input question information, it performs a correlation search from the target domain question base to obtain related questions and calls a pre-trained language model to generate first response information. It also performs a correlation search from the target domain knowledge base to obtain related knowledge and calls a pre-trained language model to generate second response information. Based on the question information, it scores the accuracy of the first and second response information respectively, and outputs the response information with the higher accuracy score as the result response information to the question information. This achieves a dual-channel retrieval enhancement scheme. Compared with current retrieval enhancement techniques, the question-based question retrieval method is more in line with the needs of natural language processing, and makes up for the defect of inaccurate response information generated by current retrieval enhancement techniques when the quality of related knowledge retrieval is poor, thereby improving the accuracy of artificial intelligence response information generation results.
[0107] Based on the above embodiments, the present invention further describes the dual-channel retrieval method.
[0108] Figure 3 This is a flowchart of a dual-channel retrieval method provided in an embodiment of the present invention.
[0109] In some optional embodiments of the present invention, step S103, which involves retrieving related questions from a target domain question library based on the question information input by the user, and calling a pre-trained language model to generate first response information based on the question information and related questions, may include: performing similarity matching in the target domain question library based on the question information to obtain a first preset number of related questions with the highest similarity to the question information; expanding the context of the related questions and combining them with the question information to generate a first prompt; and inputting the first prompt into the pre-trained language model to obtain the first response information.
[0110] As described in the above embodiments of the present invention, the question information input by the user can be enhanced based on historical question-and-answer information to obtain enhanced question information. Then, in S103, related questions are retrieved from the target domain question library based on the question information input by the user, and a pre-trained language model is called to generate first response information based on the question information and related questions. This can include: performing similarity matching in a second target column based on the enhanced question information to obtain a first preset number of related questions with the highest similarity to the enhanced question information; expanding the context of the related questions and combining them with the question information to generate a first prompt; and inputting the first prompt into the pre-trained language model to obtain the first response information.
[0111] In some optional embodiments of the present invention, step S104, which involves retrieving related knowledge from the target domain knowledge base based on the question information and calling a pre-trained language model to generate second response information based on the question information and related knowledge, may include: performing similarity matching in the target domain knowledge base based on the question information to obtain a second preset number of related knowledge items with the highest similarity to the question information; expanding the context of the related knowledge and combining it with the question information to generate a second prompt; and inputting the second prompt into the pre-trained language model to obtain the second response information.
[0112] As described in the above embodiments of the present invention, the question information input by the user can be enhanced based on historical question-and-answer information to obtain enhanced question information. Then, in S104, relevant knowledge is retrieved from the target domain knowledge base based on the question information, and a pre-trained language model is called to generate second response information based on the question information and relevant knowledge. This can include: performing similarity matching on the second target column based on the enhanced question information to obtain a second preset number of relevant knowledge items with the highest similarity to the enhanced question information; expanding the context of the relevant knowledge and combining it with the question information to generate a second prompt; and inputting the second prompt into the pre-trained language model to obtain the second response information.
[0113] In some optional embodiments of the present invention, to further enhance the retrieval of the process of generating the second response information, S104 may further include: retrieving related knowledge from the target domain knowledge base based on the question information, and calling a pre-trained language model to generate the second response information based on the question information and related knowledge; inputting the question information to generate a second prompt into the pre-trained language model and outputting the third response information; performing similarity matching in the target domain knowledge base based on the third response information to obtain a second preset number of related knowledge items with the highest similarity to the third response information; expanding the context of the related knowledge and combining it with the question information to generate the third prompt; and inputting the third prompt into the pre-trained language model to obtain the second response information.
[0114] As described in the above embodiments of the present invention, the question information input by the user can be enhanced based on historical question-and-answer information to obtain enhanced question information. Then, in step S104, relevant knowledge is retrieved from the target domain knowledge base based on the question information, and a pre-trained language model is invoked to generate a second response information based on the question information and the relevant knowledge. This can include: inputting the enhanced question information into a second prompt into the pre-trained language model and outputting a third response information; performing similarity matching in the target domain knowledge base based on the third response information to obtain a second preset number of relevant knowledge items with the highest similarity to the third response information; combining the relevant knowledge with the enhanced question information after contextual expansion to generate a third prompt; and inputting the third prompt into the pre-trained language model to obtain the second response information.
[0115] In practical applications, such as Figure 3 As shown, when the user inputs a question, the original question information is first enhanced by combining historical question-and-answer information and a pre-trained language model to obtain enhanced question information, making the question intent clearer and the expression more concise.
[0116] The enhanced question information is vectorized, denoted as qE. This qE is then compared with the vectors in the second target column (E2 column) of the vector database to obtain the top K text fragments with the highest similarity. These fragments are then combined with the enhanced question information and denoted as chunk_texts_A. Here, K can be 3, meaning the enhanced question is vectorized using a vectorization model, and the vectorized result is compared with the vector data in the second target column (E2 column) of the vector database to obtain the top 3 text blocks with the highest similarity, denoted as chunk_texts_A.
[0117] The enhanced question information is used to generate a third response information A using a pre-trained language model. Then, vector calculation AE is performed on the third response information. The similarity of AE with the vectors in the first target column (e.g., column E1) of the vector database is calculated to obtain the top K text fragments with the highest similarity, which can be denoted as chunk_texts_B. Here, K can be 3, that is, the enhanced question is vectorized using a vectorization model, and the vectorization result is compared with the vector data in the first target column (e.g., column E1) of the vector database to obtain the top 3 text blocks with the highest similarity, denoted as chunk_texts_B.
[0118] The chunk_texts_A and chunk_texts_B obtained in the above steps are respectively expanded into n (n can be 2) fragments. Each fragment is combined with the enhanced question information to obtain the first prompt and the third prompt, respectively. Each prompt is input into the pre-trained language model to obtain the first response information and the second response information, which can be denoted as A_A and A_C, respectively.
[0119] In summary, the dual-channel retrieval process for the user-input question information was completed.
[0120] Based on the above embodiments, the present invention will further describe the method for scoring the accuracy of response information.
[0121] In this embodiment of the invention, S105, which scores the accuracy of the first response information and the second response information based on the question information, may include: calculating the accuracy score of the first response information based on the similarity between the first response information and the question information; and calculating the accuracy score of the second response information based on the similarity between the second response information and the question information.
[0122] The process of calculating the accuracy score of the response based on the similarity between the first response information and the question information may include: extracting keywords from the first response information to obtain a third preset number of first keyword information; calculating the first overlap probability between the first keyword information and a fourth preset number of second keyword information extracted from the question information; calculating the first similarity coefficient between the first response information and the question information; and performing a weighted calculation on the first overlap probability and the first similarity coefficient to obtain the accuracy score of the response based on the first response information.
[0123] The accuracy score of the response is calculated based on the similarity between the second response information and the question information. This may include: extracting keywords from the second response information to obtain a third preset number of third keyword information; calculating the second overlap probability between the third keyword information and the second keyword information; calculating the second similarity coefficient between the second response information and the question information; and weighting the second overlap probability and the second similarity coefficient to obtain the accuracy score of the response corresponding to the second response information.
[0124] In practical applications, keywords can be extracted from the enhanced question information to obtain the first five keywords. Keyword extraction is then performed on the first response information A_A and the second response information A_C, yielding the first five keywords for each.
[0125] The keyword overlap probability k_p can be calculated by dividing the number of overlapping keywords by the sum of the number of keywords. The keyword overlap probabilities k_p_a and k_p_c are obtained for the first response information A_A and the second response information A_C, respectively.
[0126] Calculate the similarity coefficients between the enhanced question information and the first response information A_A and the second response information A_C, denoted as the first similarity coefficient S_a and the second similarity coefficient S_c, respectively. The similarity coefficients can be calculated using cosine similarity.
[0127] The accuracy scores for the first and second response information are calculated using a weighted method: Score = m * k_p + (1-m) * S. Here, m is the weight, ranging from 0 to 1. By substituting the corresponding k_p and S values for the first and second response information respectively, the corresponding response accuracy scores can be calculated.
[0128] The accuracy scores of the two responses obtained above are compared, and the response with the higher score is output as the result response information for the response question.
[0129] Based on the above embodiments, in the intelligent response method provided by the embodiments of the present invention, S101 and S102 utilize target domain knowledge to construct a target domain knowledge base; generate questions based on target domain knowledge to construct a target domain question base, which may include: acquiring file data of target domain knowledge, extracting text blocks from the file data; performing vector calculation on the text blocks to obtain target domain knowledge vectors, and storing the target domain knowledge vectors in the first target column of the vector database; after contextual expansion of the text blocks, inputting them into a pre-trained language model to generate target domain-related questions; performing vector calculation on the target domain-related questions to obtain target domain question vectors, and storing the target domain question vectors in the second target column of the vector database.
[0130] The intelligent response method provided in this embodiment of the invention may further include: enhancing the user-inputted question information based on historical question-and-answer information to obtain enhanced question information.
[0131] In the intelligent response method provided in this embodiment of the invention, step S103, which retrieves related questions from the target domain question library based on the question information input by the user, and calls a pre-trained language model to generate first response information based on the question information and related questions, may include: performing similarity matching on the second target column based on the enhanced question information to obtain a first preset number of related questions with the highest similarity to the enhanced question information; expanding the context of the related questions and combining them with the question information to generate a first prompt; and inputting the first prompt into the pre-trained language model to obtain the first response information.
[0132] In step S104, relevant knowledge is retrieved from the target domain knowledge base based on the question information, and a pre-trained language model is invoked to generate a second response based on the question information and the relevant knowledge. This may include: inputting the enhanced question information into a second prompt into the pre-trained language model and outputting a third response; performing similarity matching in the target domain knowledge base based on the third response to obtain a second preset number of relevant knowledge items with the highest similarity to the third response; combining the relevant knowledge with the enhanced question information after contextual expansion to generate a third prompt; and inputting the third prompt into the pre-trained language model to obtain the second response.
[0133] In step S105, the accuracy scores of the first and second response information are calculated based on the question information, and the response information with the higher accuracy score is output as the result response information for responding to the question information. This can include: calculating the accuracy score of the first response information based on the similarity between the first response information and the question information; calculating the accuracy score of the second response information based on the similarity between the second response information and the question information; and outputting the response information with the higher accuracy score as the result response information for responding to the question information.
[0134] For specific implementation details of the embodiments of the present invention, please refer to the description of the above embodiments.
[0135] It should be noted that in the embodiments of the various intelligent response methods of the present invention, some steps or features may be ignored or not executed. The hardware or software functional modules described are for ease of explanation and are not the only implementation of the intelligent response methods provided in the embodiments of the present invention.
[0136] The various embodiments of the intelligent response method have been described in detail above. Based on this, the present invention also discloses intelligent response devices, equipment, non-volatile storage media and computer program products corresponding to the above methods.
[0137] Figure 4 This is a schematic diagram of the structure of an intelligent response device provided in an embodiment of the present invention.
[0138] like Figure 4 As shown, the intelligent response device provided in this embodiment of the invention includes:
[0139] Database construction module 401 is used to build a target domain knowledge base using target domain knowledge; and to generate questions based on target domain knowledge to build a target domain question base.
[0140] User interaction module 402 is used to accept question information input by the user and output the corresponding result response information to the user.
[0141] The query module 403 is used to retrieve related questions from the target domain question database based on the question information, and call a pre-trained language model to generate first response information based on the question information and related questions; and to retrieve related knowledge from the target domain knowledge database based on the question information, and call a pre-trained language model to generate second response information based on the question information and related knowledge.
[0142] The answer evaluation module 404 is used to score the accuracy of the first response information and the second response information according to the question information, and to determine the response information with the higher accuracy score as the result response information for responding to the question information.
[0143] It should be noted that in the various embodiments of the intelligent response device provided in this invention, the division of units is only a logical functional division, and other division methods can be used. The connection between different units can be electrical, mechanical, or other connection methods. Separate units can be located in the same physical location or distributed across multiple network nodes. Each unit can be implemented in hardware or as a software functional unit. That is, some or all of the units provided in this invention can be selected according to actual needs, and corresponding connection or integration methods can be used to achieve the purpose of the solution in this invention.
[0144] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0145] Figure 5 This is a schematic diagram of the structure of an intelligent response device provided in an embodiment of the present invention.
[0146] like Figure 5 As shown, the intelligent response device provided in this embodiment of the invention includes: a memory 510 for storing a computer program 511; and a processor 520 for executing the computer program 511, wherein the computer program 511, when executed by the processor 520, implements the steps of the intelligent response method provided in any of the above embodiments.
[0147] The processor 520 may include one or more processing cores, such as a 3-core processor or an 8-core processor. The processor 520 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 520 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 520 may integrate a Graphics Processing Unit (GPU) responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 520 may also include an Artificial Intelligence (AI) processor for handling computational operations related to machine learning.
[0148] The memory 510 may include one or more non-volatile storage media, which may be non-transitory. The memory 510 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 510 is used to store at least the following computer program 511, wherein, after being loaded and executed by the processor 520, the computer program 511 is able to implement the relevant steps in the intelligent response method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 510 may also include an operating system 512 and data 513, and the storage method may be temporary storage or permanent storage. The operating system 512 may be Windows or other types of operating systems. The data 513 may include, but is not limited to, the data involved in the above methods.
[0149] In some embodiments, the smart response device may further include a display screen 530, a power supply 540, a communication interface 550, an input / output interface 560, a sensor 570, and a communication bus 580.
[0150] Those skilled in the art will understand that Figure 5 The structure shown does not constitute a limitation on the smart response device and may include more or fewer components than illustrated.
[0151] The intelligent response device provided in this embodiment of the invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the steps of the intelligent response method provided in the above embodiment, and the effect is the same as above.
[0152] This invention provides a non-volatile storage medium storing a computer program thereon, which, when executed by a processor, can implement the steps of the smart response method provided in any of the above embodiments.
[0153] The non-volatile storage medium may include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks or optical disks, and other media that can store program code.
[0154] For a description of the non-volatile storage medium provided in the embodiments of the present invention, please refer to the above method embodiments, and its effect is the same as that of the smart response method provided in the embodiments of the present invention. The present invention will not repeat the details here.
[0155] This invention provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the intelligent response method provided in any of the above embodiments.
[0156] For a description of the computer program product provided in the embodiments of the present invention, please refer to the above method embodiments. The effects it achieves are the same as those of the intelligent response method provided in the embodiments of the present invention, and the present invention will not repeat them here.
[0157] The present invention has provided a detailed description of an intelligent response method, apparatus, device, and non-volatile storage medium. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus, device, non-volatile storage medium, and computer program products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to the present invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the present invention.
[0158] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
Claims
1. An intelligent response method, characterized in that, include: Utilize target domain knowledge to construct a target domain knowledge base; Based on the knowledge of the target domain, questions are generated, and a target domain question library is constructed. Based on the question information input by the user, the system retrieves related questions from the target domain question database and calls a pre-trained language model to generate first response information based on the question information and the related questions. Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge. Based on the question information, the accuracy scores of the first response information and the second response information are calculated respectively, and the response information with the higher accuracy score is output as the result response information in response to the question information; The accuracy of the responses to the first and second responses is scored based on the question information, including: Based on the similarity between the first response information and the question information, the accuracy score of the response corresponding to the first response information is calculated; Based on the similarity between the second response information and the question information, the accuracy score of the response corresponding to the second response information is calculated; Based on the similarity between the first response information and the question information, the accuracy score of the response corresponding to the first response information is calculated, including: Keyword extraction is performed on the first response information to obtain a third preset number of first keyword information; Calculate the first overlap probability between the first keyword information and the fourth preset number of second keyword information extracted from the question information; Calculate the first similarity coefficient between the first response information and the question information; The first overlap probability and the first similarity coefficient are weighted and calculated to obtain the response accuracy score corresponding to the first response information; Based on the similarity between the second response information and the question information, the accuracy score of the response corresponding to the second response information is calculated, including: Keyword extraction is performed on the second response information to obtain a third preset number of third keyword information; Calculate the second overlap probability between the third keyword information and the second keyword information; Calculate a second similarity coefficient between the second response information and the question information; The second overlap probability and the second similarity coefficient are weighted and calculated to obtain the response accuracy score corresponding to the second response information.
2. The intelligent response method according to claim 1, characterized in that, Based on the question information input by the user, related questions are retrieved from the target domain question database, and a pre-trained language model is invoked to generate first response information based on the question information and the related questions, including: Based on the question information, a similarity match is performed in the target domain question database to obtain a first preset number of associated questions that have the highest similarity to the question information; After expanding the context of the related question, it is combined with the question information to generate the first prompt; The first prompt is input into the pre-trained language model to obtain the first response information.
3. The intelligent response method according to claim 1, characterized in that, Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge, including: The question information is used to generate a second prompt, which is then input into the pre-trained language model to output a third response. Based on the third response information, a similarity match is performed in the target domain knowledge base to obtain the second preset number of related knowledge items with the highest similarity to the third response information; After expanding the context of the related knowledge, it is combined with the question information to generate a third prompt. The third prompt is input into the pre-trained language model to obtain the second response information.
4. The intelligent response method according to claim 1, characterized in that, Also includes: The question information input by the user is enhanced based on historical question and answer information to obtain enhanced question information; Based on the question information input by the user, related questions are retrieved from the target domain question database, and a pre-trained language model is invoked to generate first response information based on the question information and the related questions, including: The associated question is retrieved from the target domain question library based on the enhanced question information, and the pre-trained language model is invoked to generate the first response information based on the enhanced question information and the associated question. Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge, including: The relevant knowledge is retrieved from the target domain knowledge base based on the enhanced question information, and the pre-trained language model is invoked to generate the second response information based on the enhanced question information and the relevant knowledge.
5. The intelligent response method according to claim 1, characterized in that, Utilize target domain knowledge to construct a target domain knowledge base; Based on the knowledge of the target domain, questions are generated, and a target domain question library is constructed, including: Obtain file data containing knowledge of the target domain, and extract text blocks from the file data; The text block is subjected to vector calculation to obtain the target domain knowledge vector, and the target domain knowledge vector is stored in the first target column of the vector database; After the text block is augmented with context, it is input into the pre-trained language model to generate questions related to the target domain; Vector calculations are performed on the relevant issues in the target domain to obtain the target domain issue vector, and the target domain issue vector is stored in the second target column of the vector database; Intelligent response methods also include: The question information input by the user is enhanced based on historical question and answer information to obtain enhanced question information; Based on the question information input by the user, related questions are retrieved from the target domain question database, and a pre-trained language model is invoked to generate first response information based on the question information and the related questions, including: Based on the enhanced question information, a similarity match is performed in the second target column to obtain a first preset number of associated questions that have the highest similarity to the enhanced question information; After expanding the context of the related question, it is combined with the question information to generate the first prompt; The first prompt is input into the pre-trained language model to obtain the first response information; Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge, including: The enhanced question information is used to generate a second prompt, which is then input into the pre-trained language model to output a third response. Based on the third response information, a similarity match is performed in the target domain knowledge base to obtain the second preset number of related knowledge items with the highest similarity to the third response information; After the contextual knowledge is expanded, it is combined with the enhanced question information to generate a third prompt. The third prompt is input into the pre-trained language model to obtain the second response information.
6. A smart response device, characterized in that, include: The database construction module is used to build a target domain knowledge base using target domain knowledge. Based on the knowledge of the target domain, questions are generated, and a target domain question library is constructed. The user interaction module is used to accept question information input by the user and output the result response information corresponding to the question information to the user. The query module is used to retrieve related questions from the target domain question library based on the question information, and call a pre-trained language model to generate first response information based on the question information and the related questions; Based on the question information, relevant knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is invoked to generate second response information based on the question information and the relevant knowledge. The answer evaluation module is used to score the accuracy of the first response information and the second response information based on the question information, and to determine the response information with the higher accuracy score as the result response information in response to the question information; The accuracy of the responses to the first and second responses is scored based on the question information, including: Based on the similarity between the first response information and the question information, the accuracy score of the response corresponding to the first response information is calculated; Based on the similarity between the second response information and the question information, the accuracy score of the response corresponding to the second response information is calculated; Based on the similarity between the first response information and the question information, the accuracy score of the response corresponding to the first response information is calculated, including: Keyword extraction is performed on the first response information to obtain a third preset number of first keyword information; Calculate the first overlap probability between the first keyword information and the fourth preset number of second keyword information extracted from the question information; Calculate the first similarity coefficient between the first response information and the question information; The first overlap probability and the first similarity coefficient are weighted and calculated to obtain the response accuracy score corresponding to the first response information; Based on the similarity between the second response information and the question information, the accuracy score of the response corresponding to the second response information is calculated, including: Keyword extraction is performed on the second response information to obtain a third preset number of third keyword information; Calculate the second overlap probability between the third keyword information and the second keyword information; Calculate a second similarity coefficient between the second response information and the question information; The second overlap probability and the second similarity coefficient are weighted and calculated to obtain the response accuracy score corresponding to the second response information.
7. A smart response device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program, which, when executed by the processor, implements the steps of the smart response method as described in any one of claims 1 to 5.
8. A non-volatile storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the intelligent response method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Intelligent question and answer method and system combining retrieval and generation
CN112364150A
Intelligent customer service response method, device and equipment and readable storage medium
CN117453895A