A question-answering method, device, medium and equipment based on a large language model

Through the collaborative work of multiple large language models and the use of prompt word templates, the problem of poor generalization of Q&A in professional fields is solved, and the reliability and accuracy of Q&A results are improved.

CN118568242BActive Publication Date: 2024-12-10CHINA COMM INFORMATION TECH GRP CO LTD HANGZHOU BRANCH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411041146.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-12-10
Estimated Expiration
2044-07-31

AI Technical Summary

Technical Problem

Large language models are weak in generalization when facing complex problems in professional fields, and a single model is difficult to ensure the reliability of Q&A results.

Method used

By inputting target questions and preset prompt words into multiple large language models, multiple initial results are obtained and their reliability is evaluated, and the most reliable results are selected based on the problem context and model capabilities.

Benefits of technology

The accuracy and reliability of Q&A results are improved, and the most matching answers are selected through comprehensive information and model capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568242B_ABST
    Figure CN118568242B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of data processing, and in particular to a question-answering method, device, medium and equipment based on a large language model, comprising: obtaining a target context corresponding to a target question based on a target large language model, inputting a second prompt word including the target question and the target context into the target large language model and N preset large language models respectively, obtaining N+1 initial results, screening to obtain P candidate results and a corresponding reliability set, inputting the N+1 initial results and a third prompt word including the target question, the target context, the P candidate results and the reliability set into the target large language model, obtaining the reliability corresponding to each initial result and screening to obtain the target result, and analyzing the comprehensive information of question information, target context knowledge information, result information and result reliability information based on the target large language model with a high degree of matching with the target question and the best model capability, thereby improving the reliability of the target result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a question-answering method, device, medium and equipment based on a large language model. Background Art

[0002] With the continuous development of science and technology, artificial intelligence technology has become a current research hotspot. Large language models (LLMs) continue to emerge and have shown good performance in natural language processing tasks such as answering questions, writing articles, and writing codes.

[0003] Generally speaking, LLMs have achieved outstanding performance in various NLP tasks by gradually learning the laws of language through a large amount of corpus training. However, when faced with complex problems in professional fields, due to the relatively small number of learning samples or the direct lack of them, LLMs have weak generalization in most cases and their performance is greatly limited.

[0004] At the same time, due to objective differences in technical architecture, training corpus, etc., the functional characteristics and scenarios in which LLMs are suitable are not the same. Directly using a single LLM to assist in question and answering is often difficult to achieve the best results, and the reliability of the question and answer results is difficult to guarantee.

[0005] Therefore, how to improve the reliability of question-answering results based on large language models has become an urgent problem to be solved. Summary of the invention

[0006] In view of the above technical problems, the technical solution adopted by the present invention is a question-answering method based on a large language model, and the question-answering method based on a large language model comprises the following steps:

[0007] S100, input the target question input by the target user and the preset first prompt word into the trained target large language model, and obtain the target context corresponding to the target question, wherein the preset first prompt word includes the target intent, keyword set and target field corresponding to the target question.

[0008] S200, obtaining a second prompt word according to a target question, a target context and a preset second prompt word template.

[0009] S300, inputting the second prompt word into the target large language model and the trained N preset large language models respectively, and obtaining N+1 initial results corresponding to the target question, where N is an integer greater than 0.

[0010] S400, obtaining P candidate results and reliability sets corresponding to the P candidate results according to N+1 initial results, where P is an integer greater than 0.

[0011] S500: Acquire a third prompt word according to a target question, a target context, P candidate results, a reliability set, and a preset third prompt word template.

[0012] S600: Input the N+1 initial results and the third prompt word into the target large language model to obtain the reliability corresponding to each initial result.

[0013] S700, determining the initial result corresponding to the maximum reliability as the target result corresponding to the target problem.

[0014] The present invention also provides a question-answering device based on a large language model, the question-answering device based on a large language model comprises:

[0015] The target context acquisition module is used to input the target question input by the target user and the preset first prompt word into the trained target large language model to obtain the target context corresponding to the target question, wherein the preset first prompt word includes the target intent, keyword set and target field corresponding to the target question.

[0016] The second prompt word acquisition module is used to acquire the second prompt word according to the target question, the target context and the preset second prompt word template.

[0017] The initial result acquisition module is used to input the second prompt word into the target large language model and the trained N preset large language models respectively, and obtain N+1 initial results corresponding to the target question, where N is an integer greater than 0.

[0018] The reliability acquisition module is used to obtain P candidate results and the reliability sets corresponding to the P candidate results based on N+1 initial results, where P is an integer greater than 0.

[0019] The third prompt word acquisition module is used to acquire the third prompt word according to the target question, the target context, the P candidate results, the reliability set and the preset third prompt word template.

[0020] The reliability acquisition module is used to input the N+1 initial results and the third prompt word into the target large language model to obtain the reliability corresponding to each initial result.

[0021] The target result acquisition module is used to determine the initial result corresponding to the maximum reliability as the target result corresponding to the target problem.

[0022] The present invention also provides a non-transitory computer-readable storage medium, in which at least one instruction or at least one program is stored, and the at least one instruction or at least one program is loaded and executed by a processor to implement the above-mentioned question-answering method based on a large language model.

[0023] The present invention also provides an electronic device, comprising a processor and the above-mentioned non-transitory computer-readable storage medium.

[0024] The present invention has at least the following beneficial effects: a target question input by a target user and a preset first prompt word are input into a trained target large language model, a target context corresponding to the target question is obtained, the target question is analyzed by a target large language model with a high degree of matching with the target question and the best model capability, thereby improving the reliability of the target context; a second prompt word is obtained according to the target question, the target context and a preset second prompt word template, the second prompt word is respectively input into the target large language model and N trained preset large language models, N+1 initial results corresponding to the target question are obtained, and the problem information and the target context information are integrated to provide each large language model with richer information data, thereby improving the accuracy of the initial results; according to the N+1 initial results The result is obtained, P candidate results and the reliability set corresponding to the P candidate results are obtained, and the third prompt word is obtained according to the target question, the target context, the P candidate results, the reliability set and the preset third prompt word template, and the N+1 initial results and the third prompt word are input into the target large language model to obtain the reliability corresponding to each initial result, and the initial result corresponding to the maximum reliability is determined as the target result corresponding to the target question, and the third prompt word is obtained by comprehensively combining the problem information, the target context knowledge information, the result information and the reliability information of the result, which provides a rich data basis for screening the target result, and the target result is screened according to the target large language model with a high degree of matching with the target question and the best model capability, thereby improving the screening accuracy and reliability of the target result. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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 creative work.

[0026] Figure 1 A flowchart of a question-answering method based on a large language model provided in Embodiment 1 of the present invention;

[0027] Figure 2 A schematic diagram of the structure of a question-answering device based on a large language model provided in Embodiment 2 of the present invention. DETAILED DESCRIPTION

[0028] 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It is understood that, where appropriate, the above-mentioned terms used to distinguish similar objects can be interchanged so that the present invention can also implement other embodiments other than the above-mentioned illustrated embodiments or described embodiments. In addition, the terms "including" and "having" and any variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] Embodiment 1

[0031] This embodiment 1 provides a question-answering method based on a large language model, and the question-answering method based on a large language model includes the following steps: Figure 1 As shown:

[0032] S100, input the target question input by the target user and the preset first prompt word into the trained target large language model, and obtain the target context corresponding to the target question, wherein the preset first prompt word includes the target intent, keyword set and target field corresponding to the target question.

[0033] Among them, a large language model refers to a language model trained on a large-scale text corpus and containing tens of billions of parameters or more, which has good application effects in tasks such as language generation tasks, knowledge utilization tasks, and complex reasoning tasks. Therefore, this embodiment uses a large language model to answer questions input by the target user.

[0034] The target large language model is a large language model that has a high degree of match with the target question and has the best model capability. The target question is analyzed based on the target large language model to obtain the target context corresponding to the target question, which improves the reliability of the target context and further provides a richer data basis for answering the target question, thereby improving the reliability of question and answer.

[0035] In a specific implementation, S100 further includes the following steps:

[0036] S110, obtaining N+1 trained initial large language models, trained intent recognition models, M types of preset model capabilities, R types of preset initial intents, and preset capability scores of each initial large language model corresponding to each type of model capability, preset capability importance of each type of model capability, and preset model matching degree of each initial large language model corresponding to each type of initial intent, where M and R are integers greater than 0;

[0037] S120, inputting the target question into the trained intent recognition model to obtain the classification probability of the target question corresponding to each type of initial intent;

[0038] S130, according to the preset capability score of each initial large language model corresponding to each type of model capability, the preset capability importance corresponding to each type of model capability, the preset model matching degree of each initial large language model corresponding to each type of initial intent, and the classification probability of the target question corresponding to each type of initial intent, the matching degree between the target question and each initial large language model is obtained;

[0039] S140, according to the matching degree between the target question and all the initial large language models, the initial large language model corresponding to the maximum matching degree is determined as the target large language model, and N initial large language models other than the target large language model are determined as preset large language models.

[0040] Among them, the trained intent recognition model includes a first encoder and a first fully connected layer, wherein the first encoder is used to extract features of the target question and characterize the intent information contained in the target question according to the extracted intent features, and the first fully connected layer is used to map and classify the extracted intent features, thereby obtaining the probability of the target question being classified into each type of initial intent.

[0041] Different initial large language models have different data sets and different training focuses, resulting in different matching degrees between different initial large language models and different initial intents, and different initial large language models have different scores for various model capabilities. Therefore, in order to screen out the large language model that best matches the target problem and has the best model capability, this embodiment first extracts and analyzes features of the target problem according to the trained intent recognition model, and obtains the probability of the target problem being classified into each type of initial intent, and then combines the preset capability score of each initial large language model corresponding to each type of model capability, the preset capability importance corresponding to each type of model capability, the preset model matching degree of each initial large language model corresponding to each type of initial intent, and the classification probability of the target problem corresponding to each type of initial intent, to obtain the matching degree between the target problem and each initial large language model, and then obtain the target large language model with the greatest matching degree, which is used to obtain the target context corresponding to the target problem, thereby improving the reliability of the target context.

[0042] The specific categories of model capabilities can be set by the implementer according to the actual situation. The score of each initial large language model corresponding to each type of model capability and the ability importance corresponding to each type of model capability can be manually set and statistically obtained by technicians in related fields.

[0043] In a specific implementation, the matching degree F between the target question and the i-th initial large language model is i Meet the following conditions:

[0044] F i =α1×Σ j=1 M (C j ×B ij )+α2×Σ k=1 R (E k ×D ik ).

[0045] Among them, α1 refers to the preset first weight, α2 refers to the preset second weight, C j It refers to the importance of the preset capability corresponding to the j-th model capability, B ij It refers to the preset ability score of the i-th initial large language model corresponding to the j-th model ability, D ik It refers to the matching degree of the preset model of the i-th initial large language model corresponding to the k-th type of initial intent, E k It refers to the classification probability of the target problem corresponding to the kth type of initial intent, i=1, 2, ..., N+1, N+1 refers to the total number of initial large language models, j=1, 2, ..., M, M refers to the number of categories of model capability, k=1, 2, ..., R, R refers to the number of categories of initial intent.

[0046] In the above, the probability of classifying the target question into each type of initial intent is obtained according to the trained intent recognition model, and then combined with the preset capability score of each initial large language model corresponding to each type of model capability, the preset capability importance corresponding to each type of model capability, the preset model matching degree of each initial large language model corresponding to each type of initial intent and the classification probability of the target question corresponding to each type of initial intent, the matching degree between the target question and each initial large language model is obtained, which improves the calculation accuracy of the matching degree, thereby improving the screening accuracy of the target large language model and the reliability of the obtained target context.

[0047] In a specific implementation, the categories of model capabilities include at least semantic understanding capability, logical reasoning capability, domain generalization capability, and security.

[0048] In a specific implementation, S100 further includes the following steps:

[0049] S1100, obtaining a trained domain classification model;

[0050] S1200, determining the initial intention corresponding to the maximum matching degree as the target intention corresponding to the target question.

[0051] S1300: extract keywords from the target question to obtain a keyword set corresponding to the target question.

[0052] S1400, input the target intent and keyword set into the trained domain classification model to obtain the target domain corresponding to the target question.

[0053] S1500: Fill the target intention, the keyword set and the target field into the preset position of the preset first prompt word template to obtain the preset first prompt word.

[0054] Among them, the trained domain classification model includes a second encoder and a second fully connected layer, wherein the second encoder is used to extract features of the target intent and keyword set, and characterize the domain information contained in the target problem according to the extracted domain features, and the second fully connected layer is used to map and classify the extracted domain features, so as to obtain the probability that the target problem belongs to each type of preset domain, and then determine the preset domain corresponding to the largest probability as the target domain corresponding to the target problem.

[0055] Among them, those skilled in the art know that any keyword extraction algorithm in the prior art falls within the protection scope of the present invention, and will not be described in detail here.

[0056] Among them, the specific categories of the preset fields can be set by the implementers according to actual conditions.

[0057] The specific content of the preset first prompt word template can be set by the implementer according to the actual situation. The preset first prompt word template may include a first preset position corresponding to the target intent, a second preset position corresponding to the keyword set, and a third preset position corresponding to the target field. The target intent, keyword set, and target field are filled into the preset first prompt word template according to the corresponding preset positions to obtain the preset first prompt word. Therefore, the preset first prompt word includes the intent information, keyword information, and field information corresponding to the target question, thereby improving the reliability of the target context when the target question input by the target user and the preset first prompt word are input into the trained target large language model and the target context corresponding to the target question is obtained.

[0058] For example, the specific content of the preset first prompt word template may be "#Description: You are an expert in the target context, well-read, and know-it-all. You are good at identifying intent, extracting keywords, refining knowledge points, and forming target context descriptions based on actual user problems. #Intentions are as follows:. #Keywords are as follows:. #Fields are as follows:.". Correspondingly, the first preset position may refer to the position between the first ":" and the first "." in the preset first prompt word template, the second preset position may refer to the position between the second ":" and the second "." in the preset first prompt word template, and the third preset position may refer to the position between the third ":" and the third "." in the preset first prompt word template.

[0059] As described above, the target intent, keyword set and target domain corresponding to the target question are comprehensively considered to obtain the preset first prompt word, so that the trained target large language model can comprehensively consider the target question and the intent information, keyword information and domain information corresponding to the target question, thereby improving the reliability of the target context.

[0060] In a specific implementation, S100 further includes the following steps:

[0061] S1600, obtaining a preset knowledge base set, wherein the preset knowledge base set includes a plurality of preset knowledge bases;

[0062] S1700, according to the target domain, obtain a target knowledge base corresponding to the target problem from a preset knowledge base set.

[0063] S1800: Input a target question input by a target user, a preset first prompt word, and a target knowledge base into a trained target large language model to obtain a target context corresponding to the target question.

[0064] The preset knowledge base set includes a preset knowledge base corresponding to each preset field.

[0065] As described above, the target knowledge base corresponding to the target problem is extracted according to the target domain, which improves the efficiency and reliability of obtaining the target context corresponding to the target problem.

[0066] S200, obtaining a second prompt word according to a target question, a target context and a preset second prompt word template.

[0067] In a specific implementation, S200 further includes the following steps:

[0068] The target question and the target context are filled into the preset position of the preset second prompt word template to obtain the second prompt word.

[0069] The specific content of the preset second prompt word template can be set by the implementer according to the actual situation. The preset second prompt word template can include a fourth preset position corresponding to the target question and a fifth preset position corresponding to the target context. Then, the target question and the target context are filled into the preset second prompt word template according to the fourth preset position and the fifth preset position, and the second prompt word is obtained, which comprehensively represents the question information and the target context knowledge information, and provides a rich data basis for answering the target question, thereby improving the accuracy and reliability of the initial results.

[0070] For example, the specific content of the preset second prompt word template may be “#Description: You are a senior expert. Please answer specific questions based on the target context information. #Specific questions are as follows:. #Target context information is as follows:.”. Correspondingly, the fourth preset position may refer to the position between the first “:” and the first “.” in the preset second prompt word template, and the fifth preset position may refer to the position between the second “:” and the second “.” in the preset second prompt word template.

[0071] As mentioned above, the second prompt word integrates the question information and the target context knowledge information, providing a rich data basis for answering the target question, thereby improving the accuracy and reliability of the initial results.

[0072] S300, inputting the second prompt word into the target large language model and the trained N preset large language models respectively, and obtaining N+1 initial results corresponding to the target question, where N is an integer greater than 0.

[0073] S400, obtaining P candidate results and reliability sets corresponding to the P candidate results according to N+1 initial results, where P is an integer greater than 0.

[0074] In a specific implementation, S400 further includes the following steps:

[0075] S410, performing consistency judgment on the N+1 initial results, grouping the N+1 initial results according to the judgment result, and obtaining P candidate results and the number of initial results corresponding to each candidate result.

[0076] S420, acquiring a reliability set corresponding to each candidate result according to the number of initial results corresponding to each candidate result;

[0077] S430, forming a reliability set according to the reliabilities corresponding to the P candidate results.

[0078] Among them, the N+1 initial results include consistent results and inconsistent results, so the consistency of the N+1 initial results is judged. If any two initial results are consistent, the two initial results are grouped into the same initial result set, and the consistent initial result corresponding to each initial result set is determined as a candidate result. Based on this, all the initial results are traversed to obtain P candidate results and the number of initial results corresponding to each candidate result.

[0079] Correspondingly, the more initial results the candidate results correspond to, that is, the more large language models that output the corresponding initial results, the higher the reliability of the candidate results.

[0080] In the above, the consistency judgment results between N+1 initial results are grouped to obtain P candidate results, and the reliability of each candidate result is characterized according to the number of initial results corresponding to each candidate result, which serves as the basis for screening to obtain the target result, thereby improving the accuracy of the target result.

[0081] S500: Acquire a third prompt word according to a target question, a target context, P candidate results, a reliability set, and a preset third prompt word template.

[0082] Among them, the specific content of the preset third prompt word template can be set by the implementer according to the actual situation. The preset third prompt word template may include the sixth preset position corresponding to the target question, the seventh preset position corresponding to the target context, the eighth preset position corresponding to the P candidate results, and the ninth preset position corresponding to the reliability set. Then, according to the sixth preset position, the seventh preset position, the eighth preset position, and the ninth preset position, the target question, the target context, the P candidate results, and the reliability set H are filled into the preset third prompt word template, and the third prompt word is obtained. The comprehensive problem information, the target context knowledge information, the result information, and the reliability information of the result provide a rich data basis for screening the target result, thereby improving the screening accuracy and reliability of the target result.

[0083] For example, the specific content of the preset third prompt word template may be “#Description: You are a senior expert. The following is a specific question, relevant target context information, multiple answers to the question, and the reliability of each answer result. Please comprehensively consider aspects such as logic and comprehensiveness, review the multiple answers, and give the reliability of each answer result. #The specific question is as follows:. #The target context information is as follows:. #The answer results are as follows:. #The reliability is as follows:.”. Correspondingly, the sixth preset position may refer to the position between the first “:” and the first “.” in the preset third prompt word template, the seventh preset position may refer to the position between the second “:” and the second “.” in the preset third prompt word template, the eighth preset position may refer to the position between the third “:” and the third “.” in the preset third prompt word template, and the ninth preset position may refer to the position between the fourth “:” and the fourth “.” in the preset third prompt word template.

[0084] As described above, the third prompt word is obtained by integrating the question information, target context knowledge information, result information and result reliability information, which provides a rich data basis for screening target results, thereby improving the screening accuracy and reliability of the target results.

[0085] S600: Input the N+1 initial results and the third prompt word into the target large language model to obtain the reliability corresponding to each initial result.

[0086] S500, determining the initial result corresponding to the maximum reliability as the target result corresponding to the target problem.

[0087] As described above, the N+1 initial results and the third prompt word are input into the target large language model. The reliability corresponding to each initial result is obtained through the target large language model that best matches the target question and has the best performance, which serves as the basis for screening the target question with the highest reliability, thereby improving the screening accuracy and reliability of the target results.

[0088] In the above, the target question input by the target user and the preset first prompt word are input into the trained target large language model, the target context corresponding to the target question is obtained, and the target question is analyzed by the target large language model with a high degree of matching with the target question and the best model capability, thereby improving the reliability of the target context; according to the target question, the target context and the preset second prompt word template, the second prompt word is obtained, and the second prompt word is respectively input into the target large language model and the trained N preset large language models to obtain N+1 initial results corresponding to the target question, and the problem information and the target context information are integrated to provide richer information data for each large language model, thereby improving the accuracy of the initial results; according to the N+1 initial results, P candidate results and the reliability sets corresponding to the P candidate results, obtain the third prompt word according to the target question, target context, P candidate results, the reliability set and the preset third prompt word template, input N+1 initial results and the third prompt word into the target large language model, obtain the reliability corresponding to each initial result, determine the initial result corresponding to the maximum reliability as the target result corresponding to the target question, obtain the third prompt word by comprehensively considering the question information, target context knowledge information, result information and the reliability information of the result, provide a rich data basis for screening the target result, and screen the target result according to the target large language model with a high degree of match with the target question and the best model capability, thereby improving the screening accuracy and reliability of the target result.

[0089] Embodiment 2

[0090] The second embodiment provides a question-answering device based on a large language model, and the question-answering device based on a large language model includes: Figure 2 As shown:

[0091] The target context acquisition module 21 is used to input the target question input by the target user and the preset first prompt word into the trained target large language model to obtain the target context corresponding to the target question, wherein the preset first prompt word includes the target intent, keyword set and target field corresponding to the target question.

[0092] The second prompt word acquisition module 22 is used to acquire the second prompt word according to the target question, the target context and the preset second prompt word template.

[0093] The initial result acquisition module 23 is used to input the second prompt word into the target large language model and the trained N preset large language models respectively, and obtain N+1 initial results corresponding to the target question, where N is an integer greater than 0.

[0094] The reliability acquisition module 24 is used to acquire P candidate results and reliability sets corresponding to the P candidate results according to the N+1 initial results, where P is an integer greater than 0.

[0095] The third prompt word acquisition module 25 is used to acquire the third prompt word according to the target question, the target context, the P candidate results, the reliability set and the preset third prompt word template.

[0096] The reliability acquisition module 26 is used to input the N+1 initial results and the third prompt word into the target large language model to acquire the reliability corresponding to each initial result.

[0097] The target result acquisition module 27 is used to determine the initial result corresponding to the maximum reliability as the target result corresponding to the target problem.

[0098] In a specific implementation, the target context acquisition module 21 includes:

[0099] The first data acquisition submodule is used to obtain N+1 trained initial large language models, a trained intent recognition model, M types of preset model capabilities, R types of preset initial intents, and a preset capability score of each initial large language model corresponding to each type of model capability, a preset capability importance corresponding to each type of model capability, and a preset model matching degree of each initial large language model corresponding to each type of initial intent, where M and R are integers greater than 0.

[0100] The intent recognition submodule is used to input the target question into the trained intent recognition model and obtain the classification probability of the target question corresponding to each type of initial intent.

[0101] The matching degree calculation submodule is used to obtain the matching degree between the target question and each initial large language model according to the preset capability score of each initial large language model corresponding to each type of model capability, the preset capability importance corresponding to each type of model capability, the preset model matching degree of each initial large language model corresponding to each type of initial intent, and the classification probability of the target question corresponding to each type of initial intent.

[0102] The large language model classification submodule is used to determine the initial large language model corresponding to the maximum matching degree as the target large language model according to the matching degree between the target problem and all the initial large language models, and determine N initial large language models other than the target large language model as the preset large language models.

[0103] In a specific implementation, the categories of model capabilities include at least semantic understanding capability, logical reasoning capability, domain generalization capability, and security.

[0104] In a specific implementation, the target context acquisition module 21 further includes:

[0105] The second data acquisition submodule is used to obtain the trained domain classification model;

[0106] The target intent determination submodule is used to determine the initial intent corresponding to the maximum matching degree as the target intent corresponding to the target question.

[0107] The keyword extraction submodule is used to extract keywords for the target question and obtain the keyword set corresponding to the target question.

[0108] The target domain acquisition submodule is used to input the target intent and keyword set into the trained domain classification model to obtain the target domain corresponding to the target question.

[0109] The first prompt word acquisition submodule is used to fill the target intention, keyword set and target field into the preset position of the preset first prompt word template to acquire the preset first prompt word.

[0110] In a specific implementation, the target context acquisition module 21 further includes:

[0111] A second data acquisition submodule is used to acquire a preset knowledge base set, wherein the preset knowledge base set includes a plurality of preset knowledge bases;

[0112] The knowledge base screening submodule is used to obtain the target knowledge base corresponding to the target problem from the preset knowledge base set according to the target field.

[0113] The target context acquisition submodule is used to input the target question input by the target user, the preset first prompt word and the target knowledge base into the trained target large language model to obtain the target context corresponding to the target question.

[0114] In a specific implementation, the second prompt word acquisition module 22 includes:

[0115] The second prompt word acquisition submodule is used to fill the target question and the target context into the preset position of the preset second prompt word template to obtain the second prompt word.

[0116] In a specific implementation, the reliability acquisition module 24 includes:

[0117] The initial result grouping submodule is used to make consistency judgment on N+1 initial results, group the N+1 initial results according to the judgment result, obtain P candidate results, and the number of initial results corresponding to each candidate result.

[0118] The reliability calculation submodule is used to obtain the reliability corresponding to each candidate result according to the number of initial results corresponding to each candidate result;

[0119] The reliability set acquisition submodule is used to form a reliability set according to the reliabilities corresponding to the P candidate results.

[0120] It should be noted that the information interaction, execution process and other contents between the above modules are based on the same concept as the embodiment of the method of the present invention. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0121] Embodiment 3

[0122] Embodiment 3 of the present invention provides a non-transitory computer-readable storage medium, wherein at least one instruction or at least one program is stored in the non-transitory computer-readable storage medium, and the at least one instruction or at least one program is loaded and executed by a processor to implement the steps:

[0123] S100, input the target question input by the target user and the preset first prompt word into the trained target large language model, and obtain the target context corresponding to the target question, wherein the preset first prompt word includes the target intent, keyword set and target field corresponding to the target question.

[0124] S200, obtaining a second prompt word according to a target question, a target context and a preset second prompt word template.

[0125] S300, inputting the second prompt word into the target large language model and the trained N preset large language models respectively, and obtaining N+1 initial results corresponding to the target question, where N is an integer greater than 0.

[0126] S400, obtaining P candidate results and reliability sets corresponding to the P candidate results according to N+1 initial results, where P is an integer greater than 0.

[0127] S500: Acquire a third prompt word according to a target question, a target context, P candidate results, a reliability set, and a preset third prompt word template.

[0128] S600: Input the N+1 initial results and the third prompt word into the target large language model to obtain the reliability corresponding to each initial result.

[0129] S700, determining the initial result corresponding to the maximum reliability as the target result corresponding to the target problem.

[0130] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronization link DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0131] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0132] Embodiment 4

[0133] A fourth embodiment of the present invention provides an electronic device, which includes a processor and the non-transitory computer-readable storage medium in the third embodiment of the present invention.

[0134] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.

Claims

1. A question-answering method based on a large language model, characterized in that: The question answering method based on the large language model comprises the following steps: S100, inputting a target question input by a target user and a preset first prompt word into a trained target large language model, and acquiring a target context corresponding to the target question, wherein the preset first prompt word includes a target intent, a keyword set, and a target field corresponding to the target question, and S100 further includes the following steps: S110, obtaining N+1 trained initial large language models, trained intent recognition models, M types of preset model capabilities, R types of preset initial intents, and preset capability scores of each initial large language model corresponding to each type of model capability, preset capability importance of each type of model capability, and preset model matching degree of each initial large language model corresponding to each type of initial intent, where M and R are integers greater than 0; S120, inputting the target question into the trained intent recognition model to obtain the classification probability of the target question corresponding to each type of initial intent; S130, according to the preset capability score of each initial large language model corresponding to each type of model capability, the preset capability importance corresponding to each type of model capability, the preset model matching degree of each initial large language model corresponding to each type of initial intent, and the classification probability of the target question corresponding to each type of initial intent, the matching degree between the target question and each initial large language model is obtained; S140, according to the matching degree between the target question and all the initial large language models, determining the initial large language model corresponding to the maximum matching degree as the target large language model, and determining N initial large language models other than the target large language model as preset large language models; S200, acquiring a second prompt word according to the target question, the target context and a preset second prompt word template; S300, inputting the second prompt word into the target large language model and the trained N preset large language models respectively, to obtain N+1 initial results corresponding to the target question, where N is an integer greater than 0; S400, obtaining P candidate results and reliability sets corresponding to the P candidate results according to the N+1 initial results, where P is an integer greater than 0; S500, acquiring a third prompt word according to the target question, the target context, the P candidate results, the reliability set and a preset third prompt word template; S600, inputting the N+1 initial results and the third prompt word into the target large language model to obtain the reliability corresponding to each initial result; S700: Determine the initial result corresponding to the maximum reliability as the target result corresponding to the target problem.

2. The question-answering method based on a large language model according to claim 1, characterized in that: The categories of model capabilities include at least semantic understanding capability, logical reasoning capability, domain generalization capability and security.

3. The question-answering method based on a large language model according to claim 1, characterized in that: S100 also includes the following steps: S1100, obtaining a trained domain classification model; S1200, determining the initial intention corresponding to the maximum matching degree as the target intention corresponding to the target question; S1300, extracting keywords from the target question to obtain a keyword set corresponding to the target question; S1400, inputting the target intent and the keyword set into the trained domain classification model to obtain the target domain corresponding to the target question; S1500: Fill the target intent, the keyword set, and the target field into a preset position of a preset first prompt word template to obtain a preset first prompt word.

4. The question-answering method based on a large language model according to claim 3, characterized in that: S100 also includes the following steps: S1600, obtaining a preset knowledge base set, wherein the preset knowledge base set includes a plurality of preset knowledge bases; S1700, acquiring a target knowledge base corresponding to the target problem from the preset knowledge base set according to the target domain; S1800, inputting a target question input by a target user, a preset first prompt word, and the target knowledge base into a trained target large language model, and acquiring a target context corresponding to the target question.

5. The question-answering method based on a large language model according to claim 1, characterized in that: S200 also includes the following steps: The target question and the target context are filled into a preset position of a preset second prompt word template to obtain a second prompt word.

6. The question-answering method based on a large language model according to claim 1, characterized in that: S400 also includes the following steps: S410, performing consistency judgment on the N+1 initial results, grouping the N+1 initial results according to the judgment result, and obtaining P candidate results and the number of initial results corresponding to each candidate result; S420, obtaining the reliability corresponding to each candidate result according to the number of initial results corresponding to each candidate result; S430, forming a reliability set according to the reliabilities corresponding to the P candidate results.

7. A question-answering device based on a large language model, characterized in that: The question-answering device based on the large language model includes: A target context acquisition module is used to input the target question input by the target user and the preset first prompt word into the trained target large language model to obtain the target context corresponding to the target question, wherein the preset first prompt word includes the target intent, keyword set and target field corresponding to the target question, and the target context acquisition module also includes: The first data acquisition submodule is used to obtain N+1 trained initial large language models, trained intent recognition models, M types of preset model capabilities, R types of preset initial intents, and preset capability scores of each initial large language model corresponding to each type of model capability, preset capability importance corresponding to each type of model capability, and preset model matching degree of each initial large language model corresponding to each type of initial intent, where M and R are integers greater than 0; An intention recognition submodule, used to input the target question into the trained intention recognition model to obtain the classification probability of the target question corresponding to each type of initial intention; A matching degree calculation submodule, for obtaining the matching degree between the target question and each initial large language model according to the preset capability score of each initial large language model corresponding to each type of model capability, the preset capability importance corresponding to each type of model capability, the preset model matching degree of each initial large language model corresponding to each type of initial intent, and the classification probability of the target question corresponding to each type of initial intent; A large language model classification submodule is used to determine, according to the matching degree between the target question and all the initial large language models, the initial large language model corresponding to the maximum matching degree as the target large language model, and determine N initial large language models other than the target large language model as the preset large language models; A second prompt word acquisition module, used to acquire a second prompt word according to the target question, the target context and a preset second prompt word template; an initial result acquisition module, used to input the second prompt word into the target large language model and the trained N preset large language models respectively, to obtain N+1 initial results corresponding to the target question, where N is an integer greater than 0; A reliability acquisition module, used to acquire P candidate results and reliability sets corresponding to the P candidate results according to the N+1 initial results, where P is an integer greater than 0; A third prompt word acquisition module, configured to acquire a third prompt word according to the target question, the target context, the P candidate results, the reliability set and a preset third prompt word template; A reliability acquisition module, used for inputting the N+1 initial results and the third prompt word into the target large language model to acquire the reliability corresponding to each initial result; The target result acquisition module is used to determine the initial result corresponding to the maximum reliability as the target result corresponding to the target problem.

8. A non-transitory computer-readable storage medium, wherein at least one instruction or at least one program is stored in the non-transitory computer-readable storage medium, characterized in that: The at least one instruction or the at least one program is loaded and executed by the processor to implement the question-answering method based on a large language model as described in any one of claims 1-6.

9. An electronic device, characterized in that: The invention comprises a processor and the non-transitory computer-readable storage medium as claimed in claim 8.