Response processing method, device, equipment and storage medium based on large language model
Through the response processing method combined with large language models, abnormal topics are identified and handled, which improves the accuracy and credibility of the response, and solves the problem of deviating from the topic and generating inappropriate content in large language models applications.
Patent Information
- Application Number
- CN202411155499.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-22
AI Technical Summary
Large language models have the risk of deviating from the topic, generating improper content, or being susceptible to malicious prompt injection during response processing, resulting in low credibility and controllability of the application.
By receiving input questions and correlating them with context information, the pre-trained large language model is used to respond; when the response fails, identify the question and determine whether it is an abnormal topic. If so, generate feedback information to guide the user to ask questions again. Until a compliant response is obtained.
It improves the accuracy and credibility of response processing, prevents the generation of sensitive or inappropriate content, enhances the sensitivity to the question-asked topics, and ensures the controllability of the response results.
Smart Images

Figure CN118689998B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of response processing, and in particular to a response processing method, device, electronic device and storage medium based on a large language model. Background Art
[0002] The rapid development of large language models (LLMs) has also brought many challenges and risks. For example, due to inappropriate guidance from users, large language models may deviate from the topic and discuss or answer sensitive topics, or generate wrong or fictitious responses due to inappropriate wording and language style, or be susceptible to malicious prompt injection, etc., which leads to potential risks in the application of large language models.
[0003] Therefore, there is an urgent need for a response processing method that ensures that large language models improve the credibility and controllability of responses in customer-oriented applications. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a response processing method, device, electronic device and storage medium based on a large language model to solve the technical problem of low reliability and controllability of the response processing process in the related art.
[0005] In a first aspect, an embodiment of the present application provides a response processing method based on a large language model, comprising:
[0006] receiving a first question inputted, and associating the first question with context information to obtain a first question including the context information;
[0007] Using a pre-trained large language model to answer a first question containing context information, and obtaining a first topic of the first question when the answer fails;
[0008] Performing topic detection based on the first topic to determine whether the first topic is an abnormal topic;
[0009] When it is determined that the first topic is an abnormal topic, generating feedback information of abnormal topic, and receiving a second question input in response to the feedback information;
[0010] The large language model is used to perform answer processing on the second question, and when the answer is successful, an answer result corresponding to the second question is obtained.
[0011] In a second aspect, an embodiment of the present application provides a response processing device based on a large language model, including:
[0012] an association processing module, configured to receive a first question inputted, and associate the first question with context information to obtain a first question containing context information;
[0013] A first answering module, configured to answer a first question containing context information using a pre-trained large language model, and obtain a first topic of the first question when the answer fails;
[0014] a topic determination module, configured to perform topic detection based on the first topic to determine whether the first topic is an abnormal topic;
[0015] a question supplementing module, for generating feedback information of abnormal topic when the first topic is determined to be an abnormal topic, and receiving a second question input in response to the feedback information;
[0016] The second answering module is used to answer the second question using the large language model, and obtain an answer result corresponding to the second question when the answer is successful.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned methods for response processing based on a large language model when executing the computer program.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned large language model-based response processing methods are implemented.
[0019] The embodiment of the present application provides a response processing method, device, electronic device and storage medium based on a large language model. In the response process of the question-answering system, after receiving the first question input, the first question is spliced into the current context to associate context information with the first question, and then the first question associated with the context information is answered using the pre-trained large language model. If the answer is successful, the corresponding answer result is output. When the answer fails, it is determined whether the first topic of the first question is an abnormal topic. Then, when it is determined to be an abnormal topic, a second question that meets the specification is received through interactive feedback, and then the corresponding answer result is obtained by answering the second question. In the response processing process of the question-answering system, the accuracy of the answer is improved by combining the context information. At the same time, when answering, the sensitivity judgment of the topic to which the question belongs is increased to prevent the generation of sensitive or inappropriate content, and improve the credibility and controllability of the answer processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a flow chart of a response processing method based on a large language model provided in an embodiment of the present application;
[0021] Figure 2 It is a flowchart of the steps of answering the first question provided in the embodiment of the present application;
[0022] Figure 3 It is another flowchart of the response processing method based on the large language model provided in the embodiment of the present application;
[0023] Figure 4 This is a flowchart of the steps of obtaining the parsing status of the first question provided in an embodiment of the present application;
[0024] Figure 5 It is a block diagram of a response processing method based on a large language model provided in an embodiment of the present application;
[0025] Figure 6 It is a structural diagram of a response processing device based on a large language model provided in an embodiment of the present application;
[0026] Figure 7 is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0027] Figure 8 This is another structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0030] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0031] In related technologies, with the rapid development of large language models (LLM), many challenges and risks have also been brought about. For example, due to inappropriate guidance from users, large language models may deviate from the topic and discuss or answer sensitive topics, or generate wrong or fictitious responses due to inappropriate wording and language style, or be susceptible to malicious prompt injection, etc., which leads to potential risks in the application of large language models.
[0032] In order to solve the technical problems existing in the related art, the embodiment of the present application provides a response processing method based on a large language model, see Figure 1 , Figure 1 It is a flow chart of a response processing method based on a large language model provided in an embodiment of the present application, and the method includes steps 101 to 105.
[0033] Step 101 : receiving a first question inputted, and associating the first question with context information to obtain the first question including the context information.
[0034] In one embodiment, during the interaction between the user and the question-answering system, the user inputs a corresponding question to the question-answering system, and then the question-answering system identifies and processes the received question, and then outputs a response result corresponding to the received question. Specifically, a first question input is received, and the received first question is spliced into the context, that is, the current context information is associated with the first question to obtain the spliced first question.
[0035] Exemplarily, during the process of interaction with the user, the question-answering system receives questions input by the user, identifies and processes the questions, and then responds and outputs corresponding question-answering results. Therefore, during the entire interactive question-answering process, when the first question input by the user is received, before answering the question, the question-answering system places the first question in the context so that the first question has a certain background, and then the answering process can be performed more accurately.
[0036] In actual applications, during the interaction between the user and the question-answering system, the question-answering system will respond to each question input by the user and output the corresponding answer result of each question through corresponding processing. In the uninterrupted interaction process, there is a certain correlation between the questions input by the user, because when the question-answering system responds to the first question received, it needs to place the first question in the context, that is, to combine all the interactive information of the interaction between the user and the question-answering system for processing, so as to obtain a more accurate answer result.
[0037] Step 102: Use the pre-trained large language model to answer the first question containing context information, and obtain the first topic of the first question when the answer fails.
[0038] In one embodiment, after receiving the first question input and splicing it into the context, the pre-trained large language model LLM is used to answer the first question containing context information, and then subsequent processing is performed according to the response result after the answer processing. Specifically, in the answering process, since there may be a situation where the answer fails, when using the large language model to answer the processed first question, if it is determined that the answer fails, it is necessary to determine the reason for the answer failure in order to better process and complete the answering work. When determining the reason for the answer failure, the first topic corresponding to the first question is identified, so as to further judge and process according to the identified first topic. Among them, the pre-trained large language model is configured in the question-answering system for processing the received questions.
[0039] For example, when the question-and-answer system is answering the question, it may be unable to give the corresponding answer result in time due to the reasons of the question raised by the user itself, such as incomplete question, insufficient question authority, and question involving sensitive information. Therefore, when using the pre-trained large language model to answer the first question, the answer fails. In order to improve the user experience, the first question can be processed, and based on the interaction with the user, the user can be guided to ask the question again, and then the answer process is performed again to output the answer result required by the user.
[0040] In actual applications, when answering a user's question, the question-answering system analyzes the first question and then matches and generates an answer result based on the obtained analysis result. Figure 2 , Figure 2 It is a flowchart diagram of the steps of answering the first question provided in an embodiment of the present application, wherein the steps include steps 201 to 203.
[0041] Step 201, using a pre-trained large language model to parse a first question containing context information, and obtain a first prompt word corresponding to the first question containing context information;
[0042] Step 202, performing answer judgment according to the first prompt word to determine whether there is an answer result corresponding to the first prompt word;
[0043] Step 203: When it is determined that there is no answer result corresponding to the first prompt word, it is determined that the answer fails, and the first prompt word is identified as a topic to obtain the first topic corresponding to the first question.
[0044] Specifically, when processing the first question after splicing the context, the first question is processed using a pre-trained large language model LLM, and firstly, parsing is performed to obtain a first prompt word corresponding to the first question, wherein the first prompt word is used to instruct the question-answering system to work, and then a response judgment is performed based on the obtained first prompt word to determine whether there is a response result corresponding to the first prompt word. When it is determined that no corresponding response result is obtained based on the first prompt word, it is determined that the response has failed. At this time, the first prompt word will be further identified as a topic to obtain the first topic corresponding to the first question, so as to determine the reason for the response failure.
[0045] Exemplarily, a pre-trained large language model can be used for answering, and when processing the received and processed first question, the first question is parsed, specifically, word segmentation is performed, key information in the first question is extracted as a first prompt word, and then an answer is given according to the first prompt word to obtain an answer result corresponding to the first question.
[0046] When answering the first prompt word obtained based on the analysis, it may be impossible to output a corresponding answer result for the first question due to limitations of the question itself, the question-and-answer system itself, or the database. In this case, further processing will be required to output the information required by the user through interaction with the user.
[0047] Specifically, after determining that the answer fails, it includes: performing domain analysis based on the processed first question to obtain domain information of the processed first question; performing topic analysis on the first question based on the domain information to obtain a first topic corresponding to the first question.
[0048] Since there are many reasons for answering failure, when the question-answering system cannot respond to the first question, it is necessary to determine the specific reason for the failure to answer. At this time, by performing a domain analysis on the processed first question, the domain information corresponding to the first question is obtained, and then the first question is analyzed on the topic in combination with the domain information to obtain the first topic corresponding to the first question. In actual applications, the same question has different meanings in different fields and scenarios. For example, "Xiaomi" is a mobile phone brand and also a crop. If the domain information to which the first question belongs is not considered, there will be deviations in the identification of the topic. By determining the domain information after associating the context of the first question, the first topic corresponding to the first question can be more accurately determined.
[0049] Step 103: Perform topic detection based on the first topic to determine whether the first topic is an abnormal topic.
[0050] In one embodiment, after the answer fails and it is identified that the first question locks the corresponding first topic, it is determined whether the first topic is compliant, that is, the first topic is tested to determine whether it is an abnormal topic, where the abnormal topic can be a sensitive topic, such as a political topic, a specific topic, etc.
[0051] Exemplarily, for abnormal topics, in addition to conventional abnormal topics, they can also be pre-set and customized. Therefore, when determining whether the first topic is an abnormal topic, the first topic can be directly matched with the set abnormal topics to determine whether the first topic exists in the set abnormal topics. If it exists in the set abnormal topics, the first topic is determined to be an abnormal topic, otherwise, the first topic is determined to be a normal topic.
[0052] It should be noted that the judgment of whether a topic is sensitive can be achieved by training a large language model. When using a large language model, conventional sensitive topics (such as political topics) already exist in the large language model and have been labeled accordingly. When sensitive labels are required for specific topics, the large language model can be customized for training so that customized sensitive topics can be identified in a timely and effective manner during use. In other words, sensitive topics and specific topics that are set are both abnormal topics.
[0053] Step 104: when it is determined that the first topic is an abnormal topic, feedback information of the abnormal topic is generated, and a second question input in response to the feedback information is received.
[0054] In one embodiment, after determining that the first topic is abnormal, if it is determined that the first topic is an abnormal topic, it means that the question-answering system cannot answer the first question, and at this time, the user will be guided to ask the question again through interaction with the user. Specifically, after determining that the first topic is an abnormal topic, feedback information of the abnormal topic is generated to inform the user that the first question cannot be answered, and the second question re-entered by the user is received in a timely manner to answer the re-received second question.
[0055] For example, because the first topic corresponding to the first question is an abnormal topic, the question-and-answer system cannot output an answer to the first question. At this time, the user is informed through interaction with the user. The user can then re-enter the corresponding question, and the question-and-answer system will respond to the re-received question.
[0056] In actual applications, the question-answering system fails to answer the first question. In addition to the first topic corresponding to the first question being an abnormal topic, there may be other reasons, such as incomplete question, incomplete question-answering system parsing, question parsing failure, and permission restrictions. Therefore, after analyzing and processing the first topic and determining that the first topic is a normal topic, further analysis is required to determine the reason for the failure to answer.
[0057] Reference Figure 3 , Figure 3 This is another flow chart of the response processing method based on the large language model provided in an embodiment of the present application, wherein the step includes steps 301 to 303.
[0058] Step 301, when it is determined that the first topic is a normal topic, obtaining the parsing status of the first question processed by the large language model, wherein the parsing status includes partial parsing and zero parsing;
[0059] Step 302, when it is determined that the parsing state is a partial parsing, performing a question supplement process on the processed first question to obtain a processed third question;
[0060] Step 303: Use the large language model to answer the third question and obtain an answer result corresponding to the third question.
[0061] Exemplarily, when it is determined that the first topic corresponding to the first question is a normal topic, the parsing state of the processed first question processed by the large language model is obtained, wherein the parsing state includes partial parsing and zero parsing, and zero parsing is completely unparsed, and then further processing is performed according to the obtained solution state. When the parsing state is partial parsing, question supplement processing is performed on the processed first question to obtain a processed third question, and then the large language model is used to perform answer processing on the third question to obtain an answer result corresponding to the third question.
[0062] In actual applications, when the first topic corresponding to the first question is not a sensitive topic, and the question-answering system does not promptly respond to the first question, it means that there may be parsing abnormalities in the first question, such as parsing failure or incomplete parsing. Therefore, when it is determined that the first topic is not an abnormal topic, the parsing of the first question by the large language model is determined, and then the first question is reasonably processed according to the parsing situation.
[0063] For example, the first question input by the user is "How is the weather in Beijing today?" At this time, after analysis and processing, the first prompt word can be: Check the weather in Beijing today. Since the first topic corresponding to the first question is a normal topic and can be fully analyzed, the question-answering system can obtain the relevant data of "Beijing weather" stored in the system itself to provide feedback, such as the answer output: Beijing's temperature today is 20℃, humidity is 50%, and south wind is level 3. This is a complete analysis and answer.
[0064] The first question input by the user is "How is the weather?". When the first prompt word is obtained during analysis and processing, the first prompt word is: conduct a weather query. At this time, even if the context information is combined, the time and place of the weather to be queried cannot be determined. At this time, an accurate answer may not be given, but the first question can be fully parsed. Therefore, this situation is a partial analysis, and it will be necessary to supplement the questions through interaction.
[0065] It should be noted that the parsing status of the received question by the large language model can be understood as the response to the question. When the parsing is completed, it means that there is no problem with the first question, including the first topic is normal. At this time, the large language model can respond to the first question and obtain the correct response result. When the parsing is not normal, including partial parsing and zero parsing, the large language model cannot directly output the response result corresponding to the first question. It is necessary to re-ask or supplement the first question through interaction with the user before the response processing can be obtained.
[0066] For different parsing states, when the parsing state is partial parsing, it means that some questions are not parsed in time during the parsing process. For example, the first question contains more instructions, but only some of the instructions are recognized, or the parsing is incomplete due to incomplete instruction information. Therefore, when the parsing state is partial parsing, the first question is supplemented based on the specific parsing situation. For example, the first question is: send the photos just taken to A via WeChat. At this time, when the parsing is performed, the complete parsing result includes "open the gallery to select photos", "open WeChat to enter the chat interface with A" and "send the photos to A". If the parsing is incomplete at this time, the parsed action includes "open the gallery to select photos", that is, partial parsing. At this time, after completing the selection of photos, further processing needs to be determined by interaction with the user. For example, the question-answering system feedbacks: how to deal with the photos. At this time, the user can ask supplementary questions based on the feedback of the question-answering system, and the supplementary question can be "send the photos to A via WeChat", so that the question-answering system can parse and answer the supplementary question.
[0067] In addition, when the parsing status is zero parsing, it means that during the parsing process, the question-and-answer system cannot answer the first question entered by the user. For example, the answering authority for the first question is subject to certain restrictions. For example, the first question is: Check A's salary in the past year. At this time, during the parsing, the question-and-answer system can obtain the corresponding prompt words, but when obtaining the specific content, because the user does not have the authority to view the salary, even if the question-and-answer system can obtain the first prompt word corresponding to the first question, it cannot display A's salary in the past year to the user.
[0068] That is, when determining the parsing status, it is first necessary to determine whether the first question can be parsed in time. If a complete parsing cannot be performed in time, so that some information cannot be parsed, the parsing status is partial parsing. If a complete parsing can be performed in time, further judgment is required based on the user's permissions to determine the specific parsing situation.
[0069] When the first question can be fully parsed, you can refer to the parsing status of the first question. Figure 4 , Figure 4 It is a flowchart diagram of the steps of obtaining the parsing status of the first question provided in an embodiment of the present application, wherein the steps include steps 401 to 403.
[0070] Step 401, when it is determined that the first topic is a normal topic, obtaining a required authority to respond to the first prompt word;
[0071] Step 402, obtaining user information of the user who inputs the first question, and obtaining authority based on the user information to obtain the answer authority for answering the first question;
[0072] Step 403, determining the parsing status of the processed first question by the large language model according to the requirement authority and the answer authority;
[0073] Among them, if the required authority and the response authority have no authority intersection, the resolution state is determined to be zero resolution; if some of the required authority does not belong to the response authority, the resolution state is determined to be partial resolution.
[0074] Exemplarily, taking the case where the large language model can parse the first question in a timely manner as an example, when determining the parsing status, the parsing status of the first question is determined according to the question-answering system's permission requirement for answering the first question. When the first topic is determined to be a normal topic, the question-answering system's permission requirement for responding to the first prompt word is obtained, and at the same time, the user information of the user who input the first question is obtained to obtain the answering permission for answering the first question, wherein the answering permission is the user's available permission, and the required permission is the permission requirement for answering the first question, and then the parsing status of the first question is determined by comparing the required permission with the answering permission.
[0075] Among them, when there is no intersection between the required authority and the response authority, the resolution state is determined to be zero resolution. When there are some permissions in the required authority that do not belong to the response authority, the resolution state is determined to be partial resolution. For the case where the response authority includes both the required authority, if it can be resolved in time, the response result corresponding to the first question can be output.
[0076] Furthermore, regardless of whether the first question can be completely parsed, when the parsing status is determined to be partial parsing or zero parsing, the subsequent processing is similar. For example, when the parsing status is determined to be partial parsing based on the method of steps 401 to 403, the question can be supplemented with reference to the processing method of steps 302 to 303, and then the question-answering system based on the large language model is used again to perform answer processing and output the corresponding answer result.
[0077] When it is determined that the resolution status is zero resolution, it is also necessary to supplement the questions through interaction with the user. However, the difference from the partial resolution is that there is no need to consider the relevance of the first question itself. As described above, the first question is: send the photos just taken to A via WeChat. At this time, due to incomplete resolution, the resolved actions include "open the gallery and select photos". At this time, when the user interacts, it is necessary to interact based on the resolved actions. Therefore, the interaction at this time can be: how to deal with the photos, and then the supplementary question input by the user can be "send the photos to A via WeChat."
[0078] Therefore, when determining that the parsing state is zero parsing, it includes: when determining that the parsing state is zero parsing, generating feedback information of parsing failure, and receiving a fourth question input in response to the feedback information; associating context information with the fourth question, and using a large language model to answer the fourth question associated with the prime number context information, to obtain an answer result corresponding to the fourth question.
[0079] Specifically, at zero resolution, there is no need to consider the relevance to the first question. At this time, the feedback information of the question-and-answer system may be: no access permission. After viewing the feedback information, the user will ask the question again according to his or her own needs, such as entering the fourth question. Then, when the question-and-answer system answers the fourth question, it will need to combine the contextual information of the entire conversation, that is, execute step 101, and then complete the answer processing of the fourth question.
[0080] Step 105: Use the large language model to answer the second question, and obtain the answer result corresponding to the second question when the answer is successful.
[0081] In one embodiment, when the first topic of the first question is an abnormal topic, after receiving the second question input by the user through interactive processing, the second question is answered using a large language model, and when it is determined that the answer is successful, the answer result corresponding to the second question is obtained and feedback is provided.
[0082] Exemplarily, after receiving the second question, the specific processing method is the same as that of the first question, including parsing the second question, detecting the second topic corresponding to the second question, and outputting the answer result corresponding to the second question based on the parsing result, etc., so it will not be repeated here.
[0083] Further, refer to Figure 5 , Figure 5 It is a block diagram of a response processing method based on a large language model provided in an embodiment of the present application.
[0084] Specifically, during the interaction between the user and the question-and-answer system, the user inputs a corresponding question. At this time, the question-and-answer system associates and splices the received question with the context, and then uses the large language model LLM to perform analysis and judgment. If it is determined that it can be completely analyzed, an answer result corresponding to the question is obtained. If it is determined that it cannot be completely analyzed for answer processing, a topic check will be performed on the topic corresponding to the received question to determine whether the topic meets the requirements. The determination of whether the topic meets the requirements is based on whether the topic is a sensitive topic. If the topic is a sensitive topic, it is determined that the topic does not meet the requirements. Otherwise, it is determined that the topic meets the requirements.
[0085] Furthermore, when it is determined that the topic does not meet the requirements, that is, when it is determined that the topic is an abnormal topic such as a sensitive topic, the user will be redirected to input the question, that is, feedback is given to the user that the topic currently input cannot be answered and processed, and the user is prompted whether to re-enter the question and receive the question re-entered by the user. When it is determined that the topic meets the requirements, that is, the topic is not an abnormal topic such as a sensitive topic, the large language model will be used to determine whether the prompt can be partially resolved or completely unresolvable (that is, zero resolution). When it is determined that it can be partially resolved, the user can continue to interact with the user based on the currently received question to complete the question supplement. Specifically, the large language model is used to generate corresponding question supplement information based on the current parsed result, so that the user can input the question again based on the current question supplement information; when it is determined that it is completely unresolvable, it may be due to the problem of user permissions that the question-answering system cannot execute the prompt word corresponding to the question. At this time, it is also necessary to use the large language model to supplement the question so that the user can input the question again. For example, the large language model feedback: insufficient access rights, please ask again, then at this time, after seeing the feedback of the question-answering system, the user can adjust the question according to his own needs and input it again.
[0086] In one embodiment, for Figure 5 The response processing flow shown can be expressed using a function. Let F be the function collect_msg, then the entire response processing process can be expressed as: F:(S,D,C)→(C′,S′,F′,U), where S is the initial system message, D is the prompt for changing the topic, C is the check rule, C′ is the final context, S′ is the system status, F′ is the functional status, and U is the user's final input.
[0087] During the processing, the context initial S can be defined. During the continuous interaction between the user and the question-answering system, the context S can be changed. At the same time, the initialization of sys_status and func_status are both set to None. During the interaction, the initialization output user_reply of the question-answering system can be "How can I help you?", and then the user's input is received and processed accordingly. The specific processing process can be an iterative process.
[0088] The iterative process is:
[0089] Repeat the steps until sys_status≠None and func_status≠None;
[0090] U←get_chat_session().send_answer_and_get_question(user_reply);
[0091] Concatenate U, R←llm(context);
[0092] (S′,F′)←get_status(R)
[0093] If (S′, F′) = None:
[0094] background←diverter(U,D);
[0095] Update context and concatenate R;
[0096] user_reply←topic_check(U,user_reply,C);
[0097] Output: F returns (context,sys_status,func_status,U).
[0098] That is, during the processing, the user's input during the interaction is received, and it is associated and spliced with the context. For the user input after the splicing process, if there is no corresponding response result (that is, the response result is empty None), the topic will be judged and the user's input question will be received again to perform the response processing again. Through continuous loop processing, the final response result is obtained.
[0099] Furthermore, when looping based on the above function, the question after the association and concatenation context is first parsed, and when parsing, the topic corresponding to the question is also identified and judged to determine whether the topic meets the requirements. In general, whether the topic is standardized is to determine whether the topic is an abnormal topic such as a sensitive topic, that is, if the topic is a sensitive topic, it is determined to be unqualified, otherwise it is determined to be compliant. When judging whether the topic meets the requirements, a pre-trained related model can be used for processing, and when processing, it can be equivalent to a binary classification task.
[0100] When it is necessary to control the topic, a standardized workflow is first standardized. Specifically, by defining the process, several possible expressions in each process are listed as few shot samples using methods such as few shots. When judging whether the user instruction belongs to the instruction in the definition, the following loss function is used. For binary classification tasks, Few-Shot Learning often uses the cross entropy loss function, where the loss function L can be expressed as:
[0101] ;
[0102] in, is the number of samples, It is a sample The actual label, is the predicted probability.
[0103] In the Few-Shot Learning process, the samples provided will be used as the support set, and the user's input will be used as the query set. The support set is used for model learning, and the query set is used for model judgment. The goal of the model is to minimize the loss function on the query set, which can be expressed as follows:
[0104] ;
[0105] in, is the learned model, are model parameters.
[0106] Furthermore, after obtaining a model for judging whether a topic meets the requirements based on the above method, after receiving a question input by the user, the topic corresponding to the question is obtained through topic recognition, and then the judgment processing of the model is used to determine whether the topic corresponding to the question meets the requirements, so as to perform further processing based on the judgment result.
[0107] Furthermore, when further processing is performed based on the judgment result, if it is determined that the topic meets the requirements, it is necessary to complete the supplement of the questions through interaction with the user, and then realize the answer processing. When it is determined that the topic does not meet the requirements, that is, it is determined that the topic is a sensitive topic, the large language model will prompt and redirect the user so that the user can enter questions that meet the requirements.
[0108] In addition, when the topic corresponding to the question meets the requirements, it is not necessarily possible to get the answer corresponding to the question entered by the user. The main reason is that different users have different system permissions, which can be understood as different users have different access rights to the system. When users ask questions that are not related to their own permission configuration, it is necessary to limit the large model to answer additional information and guide the correct permission information. For example, employee A checks the salary of other employees in the company, but employee A does not have this permission. At this time, the question and answer system cannot give an answer to employee A's question about the salary situation. Obviously, even if the topic of the question meets the requirements, it cannot give a corresponding answer. Therefore, at this time, the question and answer system will also prompt and guide users to enter appropriate questions.
[0109] In summary, the present application discloses a response processing method based on a large language model. In the response process of the question-answering system, after receiving the first question input, the first question is spliced into the current context to associate context information with the first question, and then the first question associated with the context information is answered using a pre-trained large language model. If the answer is successful, the corresponding answer result is output. When the answer fails, it is determined whether the first topic of the first question is an abnormal topic. Then, when it is determined to be an abnormal topic, a second question that meets the specification is received through interactive feedback, and then the corresponding answer result is obtained by answering the second question. In the response processing process of the question-answering system, the accuracy of the answer is improved by combining the context information. At the same time, when answering, the sensitivity judgment of the topic to which the question belongs is increased to prevent the generation of sensitive or inappropriate content, and improve the credibility and controllability of the answer processing.
[0110] According to the method described in the above embodiment, this embodiment will be further described from the perspective of a response processing device based on a large language model. The response processing device based on a large language model can be implemented as an independent entity or integrated into an electronic device, such as a terminal. The terminal may include a mobile phone, a tablet computer, etc.
[0111] See also Figure 6 , Figure 6 is a structural diagram of a response processing device based on a large language model provided in an embodiment of the present application, such as Figure 6 As shown, the response processing device 600 based on the large language model provided in the embodiment of the present application includes:
[0112] The association processing module 601 is used to receive a first question input, and associate the first question with context information to obtain the first question containing the context information;
[0113] A first answering module 602 is used to answer the first question containing context information using a pre-trained large language model, and obtain a first topic of the first question when the answer fails;
[0114] A topic determination module 603 is used to perform topic detection based on the first topic to determine whether the first topic is an abnormal topic;
[0115] The question supplement module 604 is used to generate feedback information of topic abnormality when the first topic is determined to be an abnormal topic, and receive a second question input in response to the feedback information;
[0116] The second answering module 605 is used to answer the second question using the large language model, and obtain the answer result corresponding to the second question when the answer is successful.
[0117] In one embodiment, the first response module 602 is further configured to:
[0118] The first question containing the context information is parsed using a pre-trained large language model to obtain a first prompt word corresponding to the first question containing the context information;
[0119] Performing answer judgment according to the first prompt word to determine whether there is an answer result corresponding to the first prompt word;
[0120] When it is determined that there is no answer result corresponding to the first prompt word, it is determined that the answer fails, and topic recognition is performed on the first prompt word to obtain a first topic corresponding to the first question.
[0121] In one embodiment, the first response module 602 is further configured to:
[0122] Performing domain analysis according to the processed first question to obtain domain information of the processed first question;
[0123] A topic analysis is performed on the first question according to the domain information to obtain a first topic corresponding to the first question.
[0124] In one embodiment, the question supplement module 604 is further configured to:
[0125] When it is determined that the first topic is a normal topic, obtaining a parsing state of the first question processed by the large language model, wherein the parsing state includes a partial parsing and a zero parsing;
[0126] When it is determined that the parsing state is a partial parsing, performing a question supplement process on the processed first question to obtain a processed third question;
[0127] The third question is answered using the large language model to obtain an answer result corresponding to the third question.
[0128] In one embodiment, the question supplement module 604 is further configured to:
[0129] When it is determined that the first topic is a normal topic, obtaining a request permission to respond to the first prompt word;
[0130] Obtaining user information of the user who inputs the first question, and obtaining authority based on the user information to obtain the answer authority for answering the first question;
[0131] According to the requirement authority and the answer authority, the parsing status of the first question processed by the large language model is determined.
[0132] In one embodiment, the question supplement module 604 is further configured to:
[0133] If the required authority and the answer authority have no authority intersection, the resolution status is determined to be zero resolution;
[0134] If some of the required permissions do not belong to the answered permissions, the resolution status is determined to be partial resolution.
[0135] In one embodiment, the question supplement module 604 is further configured to:
[0136] When it is determined that the parsing state is zero parsing, generating parsing failure feedback information, and receiving a fourth question input in response to the feedback information;
[0137] The fourth question is associated with context information, and the large language model is used to perform answer processing on the fourth question associated with the prime number context information to obtain an answer result corresponding to the fourth question.
[0138] Also, see Figure 7 , Figure 7is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, and the electronic device may be a mobile terminal such as a smart phone, a tablet computer, or the like. Figure 7 As shown, the electronic device 700 includes a processor 701 and a memory 702. The processor 701 is electrically connected to the memory 702.
[0139] The processor 701 is the control center of the electronic device 700. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device 700 and processes data by running or loading applications stored in the memory 702 and calling data stored in the memory 702, thereby monitoring the electronic device 700 as a whole.
[0140] In this embodiment, the processor 701 in the electronic device 700 will load the instructions corresponding to the processes of one or more applications into the memory 702 according to the following steps, and the processor 701 will run the application stored in the memory 702, thereby implementing any step in the response processing method based on the large language model provided in the above embodiment.
[0141] The electronic device 700 can implement the steps in any embodiment of the response processing method based on a large language model provided in the embodiments of the present application. Therefore, it can achieve the beneficial effects that can be achieved by any response processing method based on a large language model provided in the embodiments of the present application. For details, please refer to the previous embodiments and will not be repeated here.
[0142] See also Figure 8 , Figure 8 is another structural schematic diagram of an electronic device provided in an embodiment of the present application, such as Figure 8 As shown, Figure 8 The specific structural block diagram of the electronic device provided in the embodiment of the present application is shown, and the electronic device can be used to implement the answer processing method based on the large language model provided in the above embodiment. The electronic device 800 can be a mobile terminal such as a smart phone or a laptop computer.
[0143] The RF circuit 810 is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, and thus communicate with a communication network or other devices. The RF circuit 810 may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity module (SIM) cards, memories, etc. The RF circuit 810 can communicate with various networks such as the Internet, corporate intranets, wireless networks, or communicate with other devices through wireless networks. The above-mentioned wireless networks may include cellular telephone networks, wireless local area networks, or metropolitan area networks. The above-mentioned wireless networks may use various communication standards, protocols and technologies, including but not limited to Global System for Mobile Communication (GSM), Enhanced Data GSM Environment (EDGE), Wideband Code Division Multiple Access (WCDMA), Code Division Access (CDMA), Time Division Multiple Access (TDMA), Wireless Fidelity (Wi-Fi) (such as Institute of Electrical and Electronics Engineers standards IEEE 802.11a, IEEE 802.11b, IEEE802.11g and / or IEEE802.11n), Voice over Internet Protocol (VoIP), Worldwide Interoperability for Microwave Access (Wi-Max), other protocols for email, instant messaging and short messages, and any other suitable communication protocols, even those that have not yet been developed.
[0144] The memory 820 can be used to store software programs and modules, such as the program instructions / modules corresponding to the response processing method based on the large language model in the above-mentioned embodiment. The processor 880 executes various functional applications and the response processing method based on the large language model by running the software programs and modules stored in the memory 820.
[0145] The memory 820 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 820 may further include a memory remotely arranged relative to the processor 880, and these remote memories may be connected to the electronic device 800 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0146] The input unit 830 can be used to receive uploaded digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, the input unit 830 may include a touch-sensitive surface 831 and other input devices 832. The touch-sensitive surface 831, also known as a touch display screen or touchpad, can collect user touch operations on or near it (such as operations performed by users using fingers, styluses, or any other suitable objects or accessories on or near the touch-sensitive surface 831), and drive corresponding connection devices according to a pre-set program. Optionally, the touch-sensitive surface 831 may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into touch point coordinates, and then sends it to the processor 880, and can receive and execute commands sent by the processor 880. In addition, the touch-sensitive surface 831 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch-sensitive surface 831, the input unit 830 may further include other input devices 832. Specifically, the other input devices 832 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
[0147] The display unit 840 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device 800, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit 840 may include a display panel 841, and optionally, the display panel 841 may be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc. Further, the touch-sensitive surface 831 may cover the display panel 841, and when the touch-sensitive surface 831 detects a touch operation on or near it, it is transmitted to the processor 880 to determine the type of the touch event, and then the processor 880 provides corresponding visual output on the display panel 841 according to the type of the touch event. Although in the figure, the touch-sensitive surface 831 and the display panel 841 are implemented as two independent components to implement input and output functions, in some embodiments, the touch-sensitive surface 831 can be integrated with the display panel 841 to implement input and output functions.
[0148] The electronic device 800 may also include at least one sensor 850, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 841 according to the brightness of the ambient light, and the proximity sensor may generate an interrupt when the flip cover is closed or closed. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that can also be configured in the electronic device 800, they will not be repeated here.
[0149] The audio circuit 860, the speaker 861, and the microphone 862 can provide an audio interface between the user and the electronic device 800. The audio circuit 860 can transmit the electrical signal converted from the received audio data to the speaker 861, which is converted into a sound signal for output; on the other hand, the microphone 862 converts the collected sound signal into an electrical signal, which is received by the audio circuit 860 and converted into audio data, and then the audio data is output to the processor 880 for processing, and then sent to another terminal through the RF circuit 810, or the audio data is output to the memory 820 for further processing. The audio circuit 860 may also include an earplug jack to provide communication between an external headset and the electronic device 800.
[0150] The electronic device 800 can help the user receive requests, send information, etc. through the transmission module 870 (such as a Wi-Fi module), which provides the user with wireless broadband Internet access. Although the transmission module 870 is shown in the figure, it can be understood that it is not a necessary component of the electronic device 800 and can be omitted as needed without changing the essence of the invention.
[0151] The processor 880 is the control center of the electronic device 800. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 820, and calling data stored in the memory 820, it executes various functions of the electronic device 800 and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 880 may include one or more processing cores; in some embodiments, the processor 880 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into the processor 880.
[0152] The electronic device 800 also includes a power supply 890 (such as a battery) for supplying power to various components. In some embodiments, the power supply can be logically connected to the processor 880 through a power management system, so that the power management system can manage charging, discharging, and power consumption management. The power supply 890 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0153] Although not shown, the electronic device 800 also includes a camera (such as a front camera, a rear camera), a Bluetooth module, etc., which will not be described in detail here. Specifically in this embodiment, the display unit of the electronic device is a touch screen display, and the mobile terminal also includes a memory, and one or more programs, wherein one or more programs are stored in the memory, and are configured to be executed by one or more processors to implement any step of the answer processing method based on the large language model provided in the above embodiment.
[0154] In specific implementation, the above modules can be implemented as independent entities, or can be arbitrarily combined and implemented as the same or several entities. The specific implementation of the above modules can be found in the previous method embodiments, which will not be repeated here.
[0155] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling related hardware through instructions, and the instructions can be stored in a computer-readable storage medium and loaded and executed by a processor. To this end, an embodiment of the present application provides a storage medium, in which a plurality of instructions are stored, and when the instructions are executed by the processor, any step in the response processing method based on a large language model provided in the above embodiments can be implemented.
[0156] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0157] Since the instructions stored in the storage medium can execute the steps in any embodiment of the response processing method based on a large language model provided in the embodiments of the present application, the beneficial effects that can be achieved by any response processing method based on a large language model provided in the embodiments of the present application can be achieved. For details, please refer to the previous embodiments and will not be repeated here.
[0158] The above is a detailed introduction to a response processing method, device, electronic device and storage medium based on a large language model provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application. Moreover, for those of ordinary skill in the art, without departing from the principles of the present application, several improvements and modifications can be made, and these improvements and modifications are also regarded as the scope of protection of the present application.
Claims
1. A response processing method based on a large language model, characterized in that: include: receiving a first question inputted, and associating the first question with context information to obtain a first question including the context information; Using a pre-trained large language model to answer a first question containing context information, and obtaining a first topic of the first question when the answer fails; Performing topic detection based on the first topic to determine whether the first topic is an abnormal topic; When it is determined that the first topic is an abnormal topic, generating feedback information of abnormal topic, and receiving a second question input in response to the feedback information; Using the large language model to answer the second question, and obtaining an answer result corresponding to the second question when the answer is successful; Wherein, after performing topic detection based on the first topic and determining whether the first topic is an abnormal topic, the method further includes: When it is determined that the first topic is a normal topic, obtaining a parsing state of the first question processed by the large language model, wherein the parsing state includes a partial parsing and a zero parsing; When it is determined that the parsing state is a partial parsing, performing a question supplement process on the processed first question to obtain a processed third question; Using the large language model to perform answer processing on the third question, and obtain an answer result corresponding to the third question; Furthermore, when it is determined that the first topic is a normal topic, obtaining the parsing status of the processed first question by the large language model includes: When it is determined that the first topic is a normal topic, obtaining a required authority to respond to a first prompt word corresponding to the first question; Acquire user information of the user who inputs the first question, and acquire authority according to the user information to obtain the answer authority for answering the first question; Determining, according to the requirement authority and the answer authority, a parsing status of the large language model for the processed first question; Furthermore, the step of determining the parsing status of the processed first question by the large language model according to the demand authority and the answer authority further includes: If the demand authority and the response authority have no authority intersection, determining that the resolution state is zero resolution; If some of the required permissions do not belong to the answered permissions, the resolution state is determined to be partial resolution.
2. The method according to claim 1, characterized in that The method of answering the first question containing context information by using the pre-trained large language model and identifying the first topic of the first question when the answer fails includes: The first question containing the context information is parsed using a pre-trained large language model to obtain a first prompt word corresponding to the first question containing the context information; Performing answer judgment according to the first prompt word to determine whether there is an answer result corresponding to the first prompt word; When it is determined that there is no answer result corresponding to the first prompt word, it is determined that the answer fails, and topic identification is performed on the first prompt word to obtain a first topic corresponding to the first question.
3. The method according to claim 2, characterized in that The performing topic identification on the first prompt word to obtain a first topic corresponding to the first question includes: Performing domain analysis according to the processed first question to obtain domain information of the processed first question; The first question is subjected to topic analysis according to the field information to obtain a first topic corresponding to the first question.
4. The method according to claim 1, characterized in that When it is determined that the first topic is a normal topic, after obtaining the parsing status of the first question processed by the large language model, the method further includes: When it is determined that the parsing state is zero parsing, generating parsing failure feedback information, and receiving a fourth question input in response to the feedback information; The fourth question is associated with the context information, and the large language model is used to perform answer processing on the fourth question associated with the prime number context information to obtain an answer result corresponding to the fourth question.
5. A response processing device based on a large language model, characterized in that: include: an association processing module, configured to receive a first question inputted, and associate the first question with context information to obtain a first question containing context information; A first answering module, configured to answer a first question containing context information using a pre-trained large language model, and obtain a first topic of the first question when the answer fails; a topic determination module, configured to perform topic detection based on the first topic to determine whether the first topic is an abnormal topic; a question supplementing module, for generating feedback information of abnormal topic when the first topic is determined to be an abnormal topic, and receiving a second question input in response to the feedback information; A second answering module, configured to answer the second question using the large language model, and obtain an answer result corresponding to the second question when the answer is successful; Wherein, the question supplement module is also used for: When it is determined that the first topic is a normal topic, obtaining a parsing state of the first question processed by the large language model, wherein the parsing state includes a partial parsing and a zero parsing; When it is determined that the parsing state is a partial parsing, performing a question supplement process on the processed first question to obtain a processed third question; Using the large language model to perform answer processing on the third question, and obtain an answer result corresponding to the third question; Furthermore, the question supplement module is also used for: When it is determined that the first topic is a normal topic, obtaining a required authority to respond to a first prompt word corresponding to the first question; Acquire user information of the user who inputs the first question, and acquire authority according to the user information to obtain the answer authority for answering the first question; Determining, according to the requirement authority and the answer authority, a parsing status of the large language model for the processed first question; Furthermore, the question supplement module is also used for: If the demand authority and the response authority have no authority intersection, determining that the resolution state is zero resolution; If some of the required permissions do not belong to the answered permissions, the resolution state is determined to be partial resolution.
6. An electronic device, characterized in that: The electronic device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the steps in the method according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 4 are implemented.
