Intelligent response method, device and equipment and nonvolatile storage medium
By building a knowledge base and a problem database in the target field, dual-channel search enhancement is carried out, and accurate response information is outputted with scores, which solves the problem of inaccurate response information caused by low retrieval quality and improves the accuracy of artificial intelligence response information generation.
Patent Information
- Application Number
- CN202411379485.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-09-30
AI Technical Summary
When the search quality of existing search enhancement generation technologies is not high, the results of artificial intelligence response information generation are inaccurate, especially when searching for low recall, it cannot effectively improve the natural language processing capabilities of pre-trained language models in the field of proprietary knowledge.
By building a target domain knowledge base and a problem database, using a pre-trained language model for dual-channel search enhancement, generating the first and second response information, and scoring them for response accuracy, outputting response information with higher scores, thereby Improve the accuracy of response information.
It has achieved the accuracy of the results of artificial intelligence response information generation when the search quality is poor, and made up for the defects of the inaccurate response information when the relevance quality of related knowledge is poor, which meets the needs of natural language processing.
Smart Images

Figure CN119293175A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an intelligent response method, device, equipment and non-volatile storage medium. Background Art
[0002] Retrieval-augmented generation is an artificial intelligence technology that combines information retrieval technology with language generation models. It retrieves relevant information from an external knowledge base and inputs it as prompts into a pre-trained language model to enhance the model's ability to handle knowledge-intensive tasks such as question answering and content generation.
[0003] However, although the current retrieval enhancement generation technology can improve the natural language processing capabilities of pre-trained language models in the field of proprietary knowledge to a certain extent, it is limited by the retrieval quality. When the retrieval quality is not high and low recall retrieval occurs (such as less relevant information retrieved, or the relevant information retrieved does not match the user's question well), inaccurate results will still be generated.
[0004] How to improve the accuracy of the results of artificial intelligence response information generation is a technical problem that technical personnel in this field need to solve. Summary of the invention
[0005] The purpose of the present invention is to provide an intelligent response method, device, equipment and non-volatile storage medium for improving the accuracy of artificial intelligence response information generation results.
[0006] In order to solve the above technical problems, the present invention provides an intelligent response method, comprising: Use target domain knowledge to build a target domain knowledge base; Generate questions based on the target domain knowledge and build a target domain question library; Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions; Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge; The first response information and the second response information are scored for response accuracy according to the question information, and the response information with a higher response accuracy score is output as the result response information in response to the question information.
[0007] On the one hand, according to the question information input by the user, a related question is retrieved from the target domain question library, and a pre-trained language model is called to generate a first answer information according to the question information and the related question, including: Perform similarity matching in the target domain question library according to the question information to obtain a first preset number of related questions with the highest similarity to the question information; After expanding the context of the related question, the context is combined with the question information to generate a first prompt; The first prompt is input into the pre-trained language model to obtain the first response information.
[0008] On the other hand, according to the question information, related knowledge is retrieved from the target domain knowledge base, and the pre-trained language model is called to generate second response information according to the question information and the related knowledge, including: The second prompt generated by the question information is input into the pre-trained language model, and third response information is output; Performing similarity matching in the target domain knowledge base according to the third response information to obtain a second preset number of associated knowledge pieces having the highest similarity to the third response information; After context expansion of the associated knowledge, the associated knowledge 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.
[0009] On the other hand, scoring the accuracy of the first response information and the second response information according to the question information respectively includes: Calculating the answer accuracy score corresponding to the first answer information according to the similarity between the first answer information and the question information; The answer accuracy score corresponding to the second answer information is calculated based on the similarity between the second answer information and the question information.
[0010] On the other hand, calculating the answer accuracy score corresponding to the first answer information according to the similarity between the first answer information and the question information includes: Perform keyword extraction on the first response information to obtain a third preset number of first keyword information; calculating a first probability of coincidence between the first keyword information and a fourth preset number of second keyword information extracted from the question information; Calculating a first similarity coefficient between the first response information and the question information; Performing weighted calculation on the first coincidence probability and the first similarity coefficient to obtain the response accuracy score corresponding to the first response information; Calculating the answer accuracy score corresponding to the second answer information according to the similarity between the second answer information and the question information includes: Perform keyword extraction on the second response information to obtain a third preset number of third keyword information; Calculating a second coincidence probability between the third keyword information and the second keyword information; Calculating a second similarity coefficient between the second response information and the question information; A weighted calculation is performed on the second coincidence probability and the second similarity coefficient to obtain the response accuracy score corresponding to the second response information.
[0011] On the other hand, it also includes: The question information input by the user is enhanced according to the historical question and answer information to obtain enhanced question information; Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions, including: Retrieving the associated question from the target domain question library according to the enhanced question information, and calling the pre-trained language model to generate the first response information according to the enhanced question information and the associated question; Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge, including: The associated knowledge is retrieved from the target domain knowledge base according to the enhanced question information, and the pre-trained language model is called to generate the second response information according to the enhanced question information and the associated knowledge.
[0012] On the other hand, the target domain knowledge is used to construct a target domain knowledge base; questions are generated according to the target domain knowledge to construct a target domain question base, including: Acquire the document data of the target domain knowledge, and extract text blocks from the document data; Perform vector calculation on the text block to obtain a target domain knowledge vector, and store the target domain knowledge vector in a first target column of a vector database; After the text block is contextually expanded, it is input into the pre-trained language model to generate questions related to the target domain; Performing vector calculation on the target domain related problems to obtain a target domain problem vector, and storing the target domain problem vector in the second target column of the vector database; Smart response methods also include: The question information input by the user is enhanced according to the historical question and answer information to obtain enhanced question information; Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions, including: Performing similarity matching in the second target column according to the enhanced question information to obtain a first preset number of associated questions having the highest similarity to the enhanced question information; After expanding the context of the related question, the context is combined with the question information to generate a first prompt; Inputting the first prompt into the pre-trained language model to obtain the first response information; Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge, including: The enhanced question information generates a second prompt, which is input into the pre-trained language model, and outputs third answer information; Performing similarity matching in the target domain knowledge base according to the third response information to obtain a second preset number of associated knowledge pieces having the highest similarity to the third response information; After context expansion of the associated knowledge, the associated knowledge is combined with the enhanced question information to generate a third prompt; Inputting the third prompt into the pre-trained language model to obtain the second response information; Scoring the first response information and the second response information for response accuracy according to the question information, and outputting the response information with a higher response accuracy score as result response information in response to the question information, including: Calculating the answer accuracy score corresponding to the first answer information according to the similarity between the first answer information and the question information; Calculating the answer accuracy score corresponding to the second answer information according to the similarity between the second answer information and the question information; The answer information with a higher answer accuracy score is output as the result answer information in response to the question information.
[0013] In order to solve the above technical problems, the present invention further provides an intelligent response device, comprising: A database construction module is used to construct a target domain knowledge base using target domain knowledge; generate questions based on the target domain knowledge to construct a target domain question base; A user interaction module, used to accept question information input by the user and output result answer information corresponding to the question information to the user; A query module, used to retrieve related questions from the target domain question library according to the question information, and call the pre-trained language model to generate first response information according to the question information and the related questions; retrieve related knowledge from the target domain knowledge library according to the question information, and call the pre-trained language model to generate second response information according to the question information and the related knowledge; The answer evaluation module is used to score the answer accuracy of the first answer information and the second answer information respectively according to the question information, and determine the answer information with a higher answer accuracy score as the result answer information responding to the question information.
[0014] In order to solve the above technical problems, the present invention further provides an intelligent answering device, comprising: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the intelligent response method as described in any one of the above items are implemented.
[0015] In order to solve the above technical problems, the present invention also provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the intelligent response method as described in any one of the above items are implemented.
[0016] The intelligent answering method provided by the present invention has the beneficial effect that while using the target domain knowledge to construct a target domain knowledge base, questions are generated based on the target domain knowledge to construct a target domain question base. When generating answer information based on the question information input by the user, an associated search is performed from the target domain question base to obtain an associated question and a pre-trained language model is called to generate a first answer information. An associated search is performed from the target domain knowledge base to obtain associated knowledge and a pre-trained language model is called to generate a second answer information. The first answer information and the second answer information are scored for answer accuracy according to the question information, and the answer information with a higher answer accuracy score is output as the result answer information in response to the question information, thereby realizing a dual-channel retrieval enhancement scheme. The method of retrieving questions through questions is more in line with the requirements of natural language processing than the current retrieval enhancement technology, and makes up for the defect that the current retrieval enhancement technology generates inaccurate answer information when the quality of associated knowledge retrieval is poor, thereby improving the accuracy of the artificial intelligence answer information generation results.
[0017] 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 described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 A flowchart of an intelligent response method provided by an embodiment of the present invention; Figure 2 A flowchart of constructing a vector database provided by an embodiment of the present invention; Figure 3 A flowchart of a dual-channel retrieval method provided by an embodiment of the present invention; Figure 4 A schematic diagram of the structure of an intelligent response device provided by an embodiment of the present invention; Figure 5 A schematic diagram of the structure of an intelligent answering device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0020] The core of the present invention is to provide an intelligent response method, device, equipment and non-volatile storage medium for improving the accuracy of artificial intelligence response information generation results.
[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] Pre-trained Language Models (PLMs) are a powerful tool in the field of Natural Language Processing (NLP). They learn general language representations by pre-training on large amounts of text data, and then adapt them to specific downstream tasks through fine-tuning.
[0023] When using pre-trained language models to deal with problems in proprietary fields, the pre-trained language models can be fine-tuned through proprietary data to optimize the capabilities of the pre-trained language models in proprietary fields. However, this method is costly and requires sufficient computing power and data volume.
[0024] Therefore, when dealing with AI answering problems in proprietary fields, the method of combining pre-trained language models with knowledge bases is usually used to enhance the capabilities of pre-trained language models in proprietary fields. This does not require a lot of fine-tuning computing power or labeled data. It only requires constructing the knowledge of the proprietary field into a knowledge base as a tool for the pre-trained language model to assist the pre-trained language model in completing its capabilities in the proprietary field.
[0025] Retrieval enhancement generation technology is a technology that generates answer information by retrieving related knowledge that matches the question information entered by the user in the knowledge base, forming a prompt and inputting it into a pre-trained language model. It can effectively solve the problem of model hallucination and model unexplainability, allowing users to see the basis and source of the answer. However, the current retrieval enhancement technology is limited by the retrieval quality of related knowledge. Low recall retrieval will miss some information, resulting in inaccurate or incomplete generated results.
[0026] In order to improve the accuracy of the artificial intelligence response information generation structure, the embodiment of the present invention provides an innovative dual-channel retrieval enhancement scheme from the perspective of retrieval enhancement. While using the target domain knowledge to construct a target domain knowledge base, it also generates questions based on the target domain knowledge to construct a target domain question base. When generating response information based on the question information input by the user, an associated search is performed from the target domain question base to obtain an associated question and a pre-trained language model is called to generate a first response information. An associated search is performed from the target domain knowledge base to obtain associated knowledge and a pre-trained language model is called to generate a second response information. The first response information and the second response information are scored for response accuracy according to the question information, and the response information with a higher response accuracy score is output as the result response information in response to the question information. Compared with the current retrieval enhancement technology, the question-based retrieval method is more in line with the natural language processing requirements, and makes up for the defect that the current retrieval enhancement technology generates inaccurate response information when the quality of associated knowledge retrieval is poor, thereby improving the accuracy of the artificial intelligence response information generation result.
[0027] Based on the above architecture, the intelligent response method provided by the embodiment of the present invention is described below with reference to the accompanying drawings.
[0028] Figure 1 A flowchart of an intelligent response method provided by an embodiment of the present invention; Figure 2 A flowchart of building a vector database provided by an embodiment of the present invention.
[0029] like Figure 1 As shown, the intelligent response method provided by the embodiment of the present invention includes: S101: Use target domain knowledge to build a target domain knowledge base; S102: Generate questions based on target domain knowledge and build a target domain question library; S103: Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions; S104: Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge; S105: score the first response information and the second response information for response accuracy according to the question information, and output the response information with a higher response accuracy score as the result response information in response to the question information.
[0030] It should be noted that the "artificial intelligence response" in the embodiments of the present invention includes but is not limited to artificial intelligence question and answer, text classification response, text sentiment analysis response, knowledge retrieval, machine translation, summary generation and other tasks.
[0031] The intelligent answering method provided by the embodiment of the present invention can be implemented based on a server or server cluster to deploy a pre-trained language model, a target domain knowledge base, and a target domain question base. In practical applications, the pre-trained language model, the target domain knowledge base, and the target domain question base can be deployed in different locations. The pre-trained language model can be deployed on a cloud server, and the target domain knowledge base and the target domain question base can be deployed on a cloud server or a user terminal. After the user inputs the question information from the terminal device and uploads it to the cloud server, the result answer information is obtained after the retrieval and the reasoning calculation of the pre-trained language model are completed. The cloud server transmits the result answer information back to the user's terminal device to realize artificial intelligence answering.
[0032] In a specific implementation, S101 and S102 are used to construct an index for the pre-trained language model. In an embodiment of the present invention, not only an index of the target domain knowledge is constructed, but also an index of questions related to the target domain knowledge is constructed.
[0033] If Figure 2 As shown, S101 and S102 may include: obtaining 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 context expansion of the text blocks, inputting the 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.
[0034] When acquiring the file data of the target domain knowledge, the knowledge documents of the target domain can be collected, such as collecting unstructured / semi-structured data and collecting file data of various formats. The text blocks are extracted from the file data, that is, the text information is extracted from the collected file data, and the long text is segmented into blocks according to the semantic information to obtain the text blocks, which can be recorded as chunk_text.
[0035] In some optional implementations of the embodiments of the present invention, the long text is segmented into blocks according to semantic information to obtain text blocks, which may include: segmenting the long text by fixed length, such as segmenting the long text according to a fixed number of characters to obtain text blocks. In some other optional implementations of the embodiments of the present invention, the long text is segmented into blocks according to semantic information to obtain text blocks, which may also include: segmenting the long text according to fixed punctuation marks to obtain text blocks.
[0036] Perform vector calculation on the above text block, and store the obtained target domain knowledge vector into the first target column (such as column E1) of the vector database.
[0037] At the same time, context expansion is performed on the above text blocks to obtain the upper and lower two text blocks of each text block, which are combined with the original text block into a larger text block, and the pre-trained language model is used to generate target domain-related questions according to the context-expanded text block, and vector calculation is performed on the generated target domain-related questions, and the obtained target domain question vector is stored in the second target column (such as E2 column) of the vector database.
[0038] Thus, the process of constructing the vector database is completed, that is, the process of constructing the target domain knowledge base and the target domain question base is completed.
[0039] While utilizing the pre-trained language model in combination with the target domain knowledge base and the target domain question base to perform artificial intelligence answering tasks, the target domain knowledge base and the target domain question base can be kept updated.
[0040] When responding to the user's artificial intelligence answering task, the question information input by the user is received, and the dual-channel retrieval enhancement method provided by S103 and S104 is used to search based on the question information, so as to generate two types of answer information using the pre-trained language model, and finally, the two answer information are scored for answer accuracy, and the one with a higher score is the result answer information that responds to the question information.
[0041] Since the question information input by the user may be unclear or expressed in a non-common language, the intelligent answering method provided by the embodiment of the present invention may also include: enhancing the question information input by the user based on historical question and answer information to obtain enhanced question information.
[0042] Then, in S103, the related questions are retrieved from the target domain question library according to the question information input by the user, and the pre-trained language model is called to generate the first answer information according to the question information and the related questions, which may include: the related questions are retrieved from the target domain question library according to the enhanced question information, and the pre-trained language model is called to generate the first answer information according to the enhanced question information and the related questions. In S104, the related knowledge is retrieved from the target domain knowledge base according to the question information, and the pre-trained language model is called to generate the second answer information according to the question information and the related knowledge, which may include: the related knowledge is retrieved from the target domain knowledge base according to the enhanced question information, and the pre-trained language model is called to generate the second answer information according to the enhanced question information and the related knowledge.
[0043] In some optional implementations of the embodiments of the present invention, enhancing the question information input by the user according to the historical question and answer information to obtain the enhanced question information may include: constructing a question and answer database according to the historical question and answer information of the target field; matching the question information input by the user in the question and answer database to obtain the associated question and answer information; combining the question information, the associated question and answer information and the question information enhancement task to obtain the prompt input into the pre-trained language model to obtain the enhanced question information. Among them, the question information enhancement task may be: expanding and correcting the question information according to the associated question and answer information.
[0044] The intelligent answering method provided by the embodiment of the present invention, while using the target domain knowledge to construct a target domain knowledge base, also generates questions based on the target domain knowledge to construct a target domain question base. When generating answer information based on the question information input by the user, an associated search is performed from the target domain question base to obtain an associated question and a pre-trained language model is called to generate a first answer information. An associated search is performed from the target domain knowledge base to obtain associated knowledge and a pre-trained language model is called to generate a second answer information. The first answer information and the second answer information are scored for answer accuracy according to the question information, and the answer information with a higher answer accuracy score is output as the result answer information in response to the question information, thereby realizing a dual-channel retrieval enhancement scheme. The method of retrieving questions through questions is more in line with the requirements of natural language processing than the current retrieval enhancement technology, and makes up for the defect that the current retrieval enhancement technology generates inaccurate answer information when the quality of associated knowledge retrieval is poor, thereby improving the accuracy of the artificial intelligence answer information generation result.
[0045] Based on the above embodiment, the embodiment of the present invention further illustrates the dual-channel retrieval method.
[0046] Figure 3 A flowchart of a dual-channel retrieval method provided by an embodiment of the present invention.
[0047] In some optional implementations of the embodiments of the present invention, S103 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 the related questions, which 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; performing context expansion on 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 a first response information.
[0048] As described in the above-mentioned embodiment of the present invention, the question information input by the user can be enhanced according to the historical question and answer information to obtain the enhanced question information. Then, in S103, the related questions are retrieved from the target domain question library according to the question information input by the user, and the pre-trained language model is called to generate the first answer information according to the question information and the related questions. This may include: performing similarity matching in the second target column according to the enhanced question information to obtain the first preset number of related questions with the highest similarity to the enhanced question information; performing context expansion on the related questions and combining them with the question information to generate the first prompt; and inputting the first prompt into the pre-trained language model to obtain the first answer information.
[0049] In some optional implementations of the embodiments of the present invention, S104 retrieves related knowledge from the target domain knowledge base based on the question information, and calls a pre-trained language model to generate second response information based on the question information and the related knowledge, which 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 with the highest similarity to the question information; contextually expanding 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 a second response information.
[0050] As described in the above-mentioned embodiment of the present invention, the question information input by the user can be enhanced according to the historical question and answer information to obtain the enhanced question information. Then, in S104, the related knowledge is retrieved from the target domain knowledge base according to the question information, and the pre-trained language model is called to generate the second response information according to the question information and the related knowledge. This may include: performing similarity matching in the second target column according to the enhanced question information to obtain a second preset number of related knowledge with the highest similarity to the enhanced question information; performing context expansion on 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.
[0051] In some other optional implementations of the embodiments of the present invention, in order to further enhance the retrieval of the process of generating the second response information, S104 retrieves related knowledge from the target domain knowledge base according to the question information, and calls the pre-trained language model to generate the second response information according to the question information and the related knowledge. It can also include: inputting the second prompt generated by the question information into the pre-trained language model, and outputting the third response information; performing similarity matching in the target domain knowledge base according to the third response information to obtain a second preset number of related knowledge with the highest similarity to the third response information; after contextual expansion of the related knowledge, combining it with the question information to generate a third prompt; inputting the third prompt into the pre-trained language model to obtain the second response information.
[0052] In combination with the above-mentioned embodiments of the present invention, the question information input by the user can be enhanced according to the historical question and answer information to obtain the enhanced question information. Then, in S104, the related knowledge is retrieved from the target domain knowledge base according to the question information, and the pre-trained language model is called to generate the second response information according to the question information and the related knowledge. It can include: the second prompt generated by the enhanced question information is input into the pre-trained language model, and the third response information is output; the similarity matching is performed in the target domain knowledge base according to the third response information to obtain the second preset number of related knowledge with the highest similarity to the third response information; the related knowledge is contextually expanded and combined with the enhanced question information to generate the third prompt; the third prompt is input into the pre-trained language model to obtain the second response information.
[0053] In practical applications, such as Figure 3 As shown, when receiving the question information input by the user, the original question information can be first enhanced by combining the historical question and answer information and the pre-trained language model to obtain enhanced question information, so that the question intention is clearer and the expression is clearer.
[0054] The enhanced question information is vectorized, recorded as qE, and the vectors in the second target column (column E2) in the vector database are matched for similarity to obtain the top TOPK text segments with the highest similarity, which are combined with the enhanced question information and recorded as chunk_texts_A. K can be 3, that is, the enhanced question is vectorized using the vectorization model, and the vectorization result is similarly calculated with the vector data in the second target column (column E2) in the vector database to obtain the top 3 text blocks with the highest similarity, recorded as chunk_texts_A.
[0055] The enhanced question information is used to generate the third answer information A using the pre-trained language model, and then the third answer information is vectorized AE, and the calculated AE is matched with the vector of the first target column (such as column E1) in the vector database to obtain the text fragments with the highest similarity TOPK, which can be recorded as chunk_texts_B. K can be 3, that is, the enhanced question is vectorized using the vectorization model, and the vectorization result is similarly calculated with the vector data in the first target column (such as column E1) in the vector database to obtain the top 3 text blocks with the highest similarity, which are recorded as chunk_texts_B.
[0056] For chunk_texts_A and chunk_texts_B obtained in the above steps, context expansion is performed on n (n can be 2) segments respectively, and each is combined with the enhanced question information to obtain the first prompt and the third prompt respectively, and each is input into the pre-trained language model to obtain the first response information and the second response information, which can be recorded as A_A and A_C respectively.
[0057] In summary, the dual-channel retrieval process for the question information input by the user is completed.
[0058] Based on the above embodiment, the embodiment of the present invention continues to explain the method of scoring the accuracy of the response information.
[0059] In an embodiment of the present invention, S105 performs answer accuracy scores on the first answer information and the second answer information respectively according to the question information, which may include: calculating the answer accuracy score corresponding to the first answer information according to the similarity between the first answer information and the question information; calculating the answer accuracy score corresponding to the second answer information according to the similarity between the second answer information and the question information.
[0060] Among them, calculating the answer accuracy score corresponding to the first answer information based on the similarity between the first answer information and the question information may include: extracting keywords from the first answer information to obtain a third preset number of first keyword information; calculating a first probability of overlap between the first keyword information and a fourth preset number of second keyword information extracted from the question information; calculating a first similarity coefficient between the first answer information and the question information; and performing weighted calculation on the first overlap probability and the first similarity coefficient to obtain the answer accuracy score corresponding to the first answer information.
[0061] Calculating the response accuracy score corresponding to the second response information based on the similarity between the second response information and the question information may include: performing keyword extraction on the second response information to obtain a third preset number of third keyword information; calculating a second probability of overlap between the third keyword information and the second keyword information; calculating a second similarity coefficient between the second response information and the question information; and performing weighted calculation on the second overlap probability and the second similarity coefficient to obtain the response accuracy score corresponding to the second response information.
[0062] In practical applications, keywords can be extracted from the enhanced question information to obtain the first 5 keyword information. Keywords can be extracted from the first response information A_A and the second response information A_C to obtain the first 5 keyword information respectively.
[0063] The keyword coincidence probability k_p may be calculated by dividing the number of coincident keywords by the sum of the number of keywords, and corresponding to the first response information A_A and the second response information A_C, the keyword coincidence probabilities k_p_a and k_p_c are obtained respectively.
[0064] The similarity coefficients between the enhanced question information and the first response information A_A and the second response information A_C are calculated and recorded as the first similarity coefficient S_a and the second similarity coefficient S_c respectively. The similarity coefficients may adopt cosine similarity.
[0065] The accuracy score corresponding to the first response information and the accuracy score corresponding to the second response information are calculated in a weighted manner: Score = m*k_p + (1-m) * S. Where m is the weight, ranging from 0 to 1. Substituting the corresponding k_p value and S value for the first response information and the second response information, the corresponding response accuracy score can be calculated.
[0066] The two answer accuracy scores obtained above are compared, and the answer information with the higher score is output as the result answer information in response to the question information.
[0067] On the basis of the above embodiments, in the intelligent answering method provided in the embodiments of the present invention, target domain knowledge is used to construct a target domain knowledge base in S101 and S102; questions are generated according to the target domain knowledge to construct a target domain question base, which may include: obtaining 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 context expansion of the text blocks, inputting the pre-trained language model to generate target domain related questions; performing vector calculation on 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.
[0068] The intelligent answering method provided by the embodiment of the present invention may further include: enhancing the question information input by the user according to the historical question and answer information to obtain enhanced question information.
[0069] In the intelligent answering method provided in an embodiment of the present invention, in S103, related questions are retrieved from the target domain question library according to the question information input by the user, and a pre-trained language model is called to generate first answer information according to the question information and the related questions. It can include: performing similarity matching in the second target column according to 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, combining them with the question information, and generating a first prompt; inputting the first prompt into the pre-trained language model to obtain the first answer information.
[0070] In S104, related knowledge is retrieved from the target domain knowledge base according to the question information, and a pre-trained language model is called to generate second response information according to the question information and the related knowledge, which may include: generating a second prompt from the enhanced question information and inputting it into the pre-trained language model to output third response information; performing similarity matching in the target domain knowledge base according to the third response information to obtain a second preset number of related knowledge with the highest similarity to the third response information; performing context expansion on the related knowledge and combining it with the enhanced question information to generate a third prompt; and inputting the third prompt into the pre-trained language model to obtain second response information.
[0071] In S105, the first response information and the second response information are scored for response accuracy respectively according to the question information, and the response information with a higher response accuracy score is output as the result response information in response to the question information. This may include: calculating the response accuracy score corresponding to the first response information according to the similarity between the first response information and the question information; calculating the response accuracy score corresponding to the second response information according to the similarity between the second response information and the question information; and outputting the response information with a higher response accuracy score as the result response information in response to the question information.
[0072] The specific implementation of the embodiments of the present invention can refer to the introduction of the above embodiments.
[0073] It should be noted that in the embodiments of the intelligent response method of the present invention, some of the steps or features can be ignored or not executed. The hardware or software functional modules divided for the convenience of description are not the only implementation form of the intelligent response method provided in the embodiments of the present invention.
[0074] The above describes in detail various embodiments corresponding to the intelligent response method. On this basis, the present invention also discloses an intelligent response device, equipment, non-volatile storage medium and computer program product corresponding to the above method.
[0075] Figure 4 A schematic diagram of the structure of an intelligent response device provided in an embodiment of the present invention.
[0076] like Figure 4 As shown, the intelligent response device provided by the embodiment of the present invention includes: The database construction module 401 is used to construct a target domain knowledge base using target domain knowledge; generate questions based on the target domain knowledge to construct a target domain question base; The user interaction module 402 is used to accept question information input by the user and output result answer information corresponding to the question information to the user; The query module 403 is used to retrieve related questions from the target domain question library according to the question information, and call the pre-trained language model to generate first answer information according to the question information and the related questions; retrieve related knowledge from the target domain knowledge library according to the question information, and call the pre-trained language model to generate second answer information according to the question information and the related knowledge; The answer evaluation module 404 is used to score the answer accuracy of the first answer information and the second answer information respectively according to the question information, and determine the answer information with a higher answer accuracy score as the result answer information responding to the question information.
[0077] It should be noted that in each implementation of the intelligent response device provided by the embodiment of the present invention, the division of units is only a logical functional division, and other division methods can be used. The connection method between different units can be electrical, mechanical or other connection methods. Separated units can be located in the same physical location or distributed on multiple network nodes. Each unit can be implemented in the form of hardware or in the form of a software functional unit. That is, according to actual needs, part or all of the units provided in the embodiment of the present invention can be selected and the corresponding connection method or integration method can be adopted to achieve the purpose of the embodiment of the present invention.
[0078] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0079] Figure 5 A schematic diagram of the structure of an intelligent answering device provided in an embodiment of the present invention.
[0080] like Figure 5As shown, the intelligent answering device provided in the embodiment of the present invention includes: a memory 510, used to store a computer program 511; a processor 520, used to execute the computer program 511, and when the computer program 511 is executed by the processor 520, the steps of the intelligent answering method provided in any of the above embodiments are implemented.
[0081] Among them, the processor 520 may include one or more processing cores, such as a 3-core processor, an 8-core processor, etc. The processor 520 may be implemented in at least one hardware form of 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 is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 520 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 520 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0082] The memory 510 may include one or more non-volatile storage media, which may be non-transitory. The memory 510 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 510 is at least used to store the following computer program 511, wherein the computer program 511 is loaded and executed by the processor 520, and the relevant steps in the intelligent response method disclosed in any of the aforementioned embodiments can be implemented. In addition, the resources stored in the memory 510 may also include an operating system 512 and data 513, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 512 may be Windows or other types of operating systems. Data 513 may include, but is not limited to, the data involved in the above method.
[0083] In some embodiments, the smart answering 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 .
[0084] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the intelligent answering device, and may include more or less components than those shown in the figure.
[0085] The intelligent response device provided in the embodiment of the present 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.
[0086] An embodiment of the present invention provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the intelligent response method provided in any one of the above embodiments can be implemented.
[0087] The non-volatile storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0088] For the introduction of the non-volatile storage medium provided in the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the intelligent response method provided in the embodiment of the present invention, and the present invention will not elaborate on it here.
[0089] An embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the intelligent response method provided in any one of the above embodiments.
[0090] For an introduction to the computer program product provided by the embodiment of the present invention, please refer to the above-mentioned method embodiment, and the effect thereof is the same as the intelligent response method provided by the embodiment of the present invention, and the present invention will not elaborate on it here.
[0091] The above is a detailed introduction to an intelligent response method, device, equipment and non-volatile storage medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can refer to each other. For the devices, equipment, non-volatile storage media and computer program products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
[0092] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. An intelligent answering method, characterized in that: include: Use target domain knowledge to build a target domain knowledge base; Generate questions based on the target domain knowledge and build a target domain question library; Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions; Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge; The first response information and the second response information are scored for response accuracy according to the question information, and the response information with a higher response accuracy score is output as the result response information in response to the question information.
2. The intelligent response method according to claim 1, characterized in that: Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions, including: Performing similarity matching in the target domain question library according to the question information, obtaining a first preset number of associated questions having the highest similarity to the question information; After expanding the context of the related question, the context is combined with the question information to generate a 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: Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge, including: The second prompt generated by the question information is input into the pre-trained language model, and third response information is output; Performing similarity matching in the target domain knowledge base according to the third response information to obtain a second preset number of associated knowledge pieces having the highest similarity to the third response information; After context expansion of the associated knowledge, the associated knowledge 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: Scoring the first answer information and the second answer information for answer accuracy according to the question information respectively includes: Calculating the answer accuracy score corresponding to the first answer information according to the similarity between the first answer information and the question information; The answer accuracy score corresponding to the second answer information is calculated based on the similarity between the second answer information and the question information.
5. The intelligent answering method according to claim 4, characterized in that: Calculating the answer accuracy score corresponding to the first answer information according to the similarity between the first answer information and the question information includes: Perform keyword extraction on the first response information to obtain a third preset number of first keyword information; calculating a first probability of coincidence between the first keyword information and a fourth preset number of second keyword information extracted from the question information; Calculating a first similarity coefficient between the first response information and the question information; Performing weighted calculation on the first coincidence probability and the first similarity coefficient to obtain the response accuracy score corresponding to the first response information; Calculating the answer accuracy score corresponding to the second answer information according to the similarity between the second answer information and the question information includes: Perform keyword extraction on the second response information to obtain a third preset number of third keyword information; Calculating a second coincidence probability between the third keyword information and the second keyword information; Calculating a second similarity coefficient between the second response information and the question information; A weighted calculation is performed on the second coincidence probability and the second similarity coefficient to obtain the response accuracy score corresponding to the second response information.
6. The intelligent answering method according to claim 1, characterized in that: Also includes: The question information input by the user is enhanced according to the historical question and answer information to obtain enhanced question information; Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions, including: Retrieving the associated question from the target domain question library according to the enhanced question information, and calling the pre-trained language model to generate the first response information according to the enhanced question information and the associated question; Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge, including: The associated knowledge is retrieved from the target domain knowledge base according to the enhanced question information, and the pre-trained language model is called to generate the second response information according to the enhanced question information and the associated knowledge.
7. The intelligent answering method according to claim 1, characterized in that: Use target domain knowledge to build a target domain knowledge base; Generate questions based on the target domain knowledge and build a target domain question library, including: Acquire the document data of the target domain knowledge, and extract text blocks from the document data; Perform vector calculation on the text block to obtain a target domain knowledge vector, and store the target domain knowledge vector in a first target column of a vector database; After the text block is contextually expanded, it is input into the pre-trained language model to generate questions related to the target domain; Performing vector calculation on the target domain related problems to obtain a target domain problem vector, and storing the target domain problem vector in the second target column of the vector database; Smart response methods also include: The question information input by the user is enhanced according to the historical question and answer information to obtain enhanced question information; Retrieving related questions from the target domain question library according to the question information input by the user, and calling the pre-trained language model to generate first answer information according to the question information and the related questions, including: Performing similarity matching in the second target column according to the enhanced question information to obtain a first preset number of associated questions having the highest similarity to the enhanced question information; After expanding the context of the related question, the context is combined with the question information to generate a first prompt; Inputting the first prompt into the pre-trained language model to obtain the first response information; Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge, including: The enhanced question information generates a second prompt, which is input into the pre-trained language model, and outputs third answer information; Performing similarity matching in the target domain knowledge base according to the third response information to obtain a second preset number of associated knowledge pieces having the highest similarity to the third response information; After context expansion of the associated knowledge, the associated knowledge is combined with the enhanced question information to generate a third prompt; Inputting the third prompt into the pre-trained language model to obtain the second response information; Scoring the first response information and the second response information for response accuracy according to the question information, and outputting the response information with a higher response accuracy score as result response information in response to the question information, including: Calculating the answer accuracy score corresponding to the first answer information according to the similarity between the first answer information and the question information; Calculating the answer accuracy score corresponding to the second answer information according to the similarity between the second answer information and the question information; The answer information having a higher answer accuracy score is output as the result answer information in response to the question information.
8. An intelligent answering device, characterized in that: include: A database construction module is used to construct a target domain knowledge base using target domain knowledge; Generate questions based on the target domain knowledge and build a target domain question library; A user interaction module, used to accept question information input by the user and output result answer information corresponding to the question information to the user; A query module, configured to retrieve related questions from the target domain question library according to the question information, and call a pre-trained language model to generate first response information according to the question information and the related questions; Retrieving related knowledge from the target domain knowledge base according to the question information, and calling the pre-trained language model to generate second response information according to the question information and the related knowledge; The answer evaluation module is used to score the answer accuracy of the first answer information and the second answer information respectively according to the question information, and determine the answer information with a higher answer accuracy score as the result answer information responding to the question information.
9. An intelligent answering device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the intelligent response method as claimed in any one of claims 1 to 7 are implemented.
10. A non-volatile storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the intelligent response method according to any one of claims 1 to 7 are implemented.
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
Domain question-answering system, domain question-answering construction method, electronic equipment and storage medium
CN117909466A
Multi-source hybrid question answering method and system thereof
KR101662450B1
Cost-benefit approach to automatically composing answers to questions by extracting information from large unstructured corpora
US20050033711A1