Reply generation method and device, and electronic device

CN122655877APending Publication Date: 2026-08-28TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510217960.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

[0002]随着人工智能技术的发展,大语言模型在自动问答任务中的应用越来越广泛,相关技术中,大语言模型针对训练时涉及的问题的答复生成质量较高,但是,针对一些训练时涉及较少或者训练时未涉及的领域相关的问题的答复质量较低

Benefits of technology

[0019] This application provides a response generation method, apparatus, and electronic device. The method, upon receiving target input content, first classifies the question type based on the question content included in the target input content. Then, based on the question type identification result, it determines a target reference content acquisition strategy suitable for answering the question content. Different reference content acquisition strategies indicate obtaining reference contexts from different sources to assist in response generation. Next, according to the target reference content acquisition strategy, a target reference context for answering the question content is obtained. Clearly, the target reference context is also the context suitable for answering the question content. Finally, a large language model is invoked to generate a response based on the question content and the target reference context, resulting in a response to the question content. In the above process, for question content of different question types, suitable target reference contexts for answering the question content can be obtained from different sources. With the assistance of the target reference context, the large language model can obtain more reference information beneficial to answering the question content, thereby improving the quality of the generated response content. Furthermore, by setting different reference content acquisition strategies for different question types, it is ensured that the large language model can achieve good response results when facing question content of different question types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122655877A_ABST
    Figure CN122655877A_ABST
Patent Text Reader

Abstract

The application relates to the computer technical field, in particular to a reply generation method and device and electronic equipment, the method obtains target input content, classifies the question type according to the question content included in the target input content, and then determines the target reference content acquisition strategy suitable for answering the question content according to the question type identification result; then, the target reference context for answering the question content is acquired according to the target reference content acquisition strategy; finally, the reply generation is carried out according to the question content and the target reference context by calling a large language model, and the reply content of the question content is obtained; the method provided in the application sets different examination content acquisition strategies for different question types, so that the target reference context suitable for answering the question content can be acquired from different sources, and the large language model can ensure good reply effect when facing different question types of question content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a response generation method, apparatus, and electronic device. Background Technology

[0002] With the development of artificial intelligence technology, large language models are being used more and more widely in automatic question answering tasks. Among related technologies, large language models generate high-quality responses to questions that were involved during training, but the quality of responses to questions related to domains that were less involved or not involved during training is lower. Summary of the Invention

[0003] In view of this, embodiments of this application propose a response generation method, apparatus, and electronic device, which can ensure good response results for different types of questions.

[0004] The embodiments of this application are implemented using the following technical solutions:

[0005] In a first aspect, embodiments of this application provide a response generation method, comprising: acquiring target input content; the target input content including at least question content; classifying the question content into question types to obtain question type classification results; wherein, different question types correspond to different reference content acquisition strategies, and different reference content acquisition strategies indicate the acquisition of reference contexts for assisting in response generation from different sources; determining a target reference content acquisition strategy suitable for answering the question content based on the question type identification results; acquiring a target reference context for answering the question content according to the target reference content acquisition strategy; and calling a large language model to generate a response based on the question content and the target reference context to obtain a response to the question content.

[0006] Secondly, embodiments of this application provide a response generation apparatus, comprising: a first acquisition module, configured to acquire target input content; the target input content includes at least question content; a classification module, configured to classify the question content into question types to obtain question type classification results; wherein, different question types correspond to different reference content acquisition strategies, and different reference content acquisition strategies indicate the acquisition of reference contexts for assisting in response generation from different sources; a strategy determination module, configured to determine a target reference content acquisition strategy suitable for answering the question content based on the question type identification results; a second acquisition module, configured to acquire a target reference context for answering the question content according to the target reference content acquisition strategy; and a response generation module, configured to call a large language model to generate a response based on the question content and the target reference context to obtain response content for the question content.

[0007] In some implementations, the question type includes at least two of a first question type, a second question type, a third question type, and a fourth question type; the source indicated by the first reference content acquisition strategy corresponding to the first question type is empty; the source indicated by the second reference content acquisition strategy corresponding to the second question type is: the question reference content involved in the target input content; the source indicated by the third reference content acquisition strategy corresponding to the third question type is: public domain content obtained by searching the question content using a search engine; and the source indicated by the fourth reference content acquisition strategy corresponding to the fourth question type is: expert knowledge content matched in the expert knowledge base based on the question content.

[0008] In some embodiments, the response generation device further includes a vector retrieval module, used to perform vector retrieval in a vector library based on the embedded representation vector of the question content, to obtain vector retrieval results. The vector library is constructed based on at least multiple public domain contents and question reference content corresponding to the target input content. The public domain contents are searched using a search engine based on the question content. The strategy determination module is further used to determine a target reference content acquisition strategy suitable for answering the question content based on the question type identification result and the vector retrieval result.

[0009] In some implementations, the question type identification result includes the probability that the question content belongs to each of multiple question types; the strategy determination module is specifically used to, if the question type identification result includes a target question type with a probability higher than a probability threshold, use the reference content acquisition strategy corresponding to the target question type as a target reference content acquisition strategy suitable for answering the question content; if the probability of each question type in the question type identification result is not higher than the probability threshold, determine a target reference content acquisition strategy suitable for answering the question content based on the vector retrieval result.

[0010] In some implementations, the vector library includes a first sub-vector library and a second sub-vector library. The first sub-vector library includes text embedding vectors of each content fragment in the question reference content; the second sub-vector library includes text embedding vectors of each of the reference public domain contents; the vector retrieval result includes a first sub-retrieval result and a second sub-retrieval result. The first sub-retrieval result is obtained by retrieving the embedding representation vector of the question content in the first sub-vector library; the second sub-retrieval result is obtained by retrieving the embedding representation vector of the question content in the second sub-vector library; the question type includes a first question type, a second question type, a third question type, and a fourth question type; the strategy determination module is specifically used to determine that the question content belongs to the second question type if the first sub-retrieval result indicates that a target content fragment is retrieved in the first sub-vector library, and to use the second reference content acquisition strategy corresponding to the second question type as the target reference content acquisition strategy applicable to answering the question content; the target content fragment The first sub-vector library contains content segments whose similarity to the question content exceeds a first similarity threshold. If the first sub-search result indicates that no target content segment was found in the first sub-vector library, and the second sub-search result indicates that target public domain content was found in the second sub-vector library, the question content is determined to belong to a third question type. The third reference content acquisition strategy corresponding to the third question type is adopted as the target reference content acquisition strategy applicable to answering the question content. The target public domain content refers to reference public domain content in the second sub-vector library whose similarity to the question content exceeds a second similarity threshold. If the first sub-search result indicates that no target content segment was found in the first sub-vector library, and the second sub-search result indicates that no target public domain content was found in the second sub-vector library, the question content is determined to belong to a fourth question type. The fourth reference content acquisition strategy corresponding to the fourth question type is adopted as the target reference content acquisition strategy applicable to answering the question content.

[0011] In some implementations, the target reference content acquisition strategy is a second reference content acquisition strategy; the second acquisition module is specifically used to use the target content fragment as a target reference context for answering the question.

[0012] In some implementations, the target reference content acquisition strategy is a third reference content acquisition strategy; the second acquisition module is specifically used to use the target public domain content as the target reference context for answering the question.

[0013] In some implementations, the target reference content acquisition strategy is a fourth reference content acquisition strategy; the second acquisition module includes an expert database retrieval unit, used to perform vector retrieval in the expert knowledge base based on the embedded representation vector of the question content, to obtain target expert knowledge content whose similarity to the question content exceeds a third similarity threshold; the target expert knowledge content includes reference question content and multiple thought chain steps for answering the reference question content; a thought chain generation unit, used to generate a thought chain for the question content according to the reference question content and the multiple thought chain steps for answering the reference question content, to obtain multiple thought chain steps of the question content; a thought chain response unit, used to generate sub-response content under each thought chain step of the question content according to the multiple thought chain steps of the question content; and a collection unit, used to use the multiple thought chain steps of the question content and the sub-response content under the corresponding thought chain steps as target reference context for answering the question content.

[0014] In some implementations, the thought chain response unit is specifically used to input the first thought chain step of the question content into the large language model agent, which generates sub-response content under the first thought chain step of the question content; initialize i to 2; input the i-th thought step of the question content, each thought chain step of the question content before the i-th thought step, and the corresponding sub-response content into the large language model agent, which generates sub-response content under the i-th thought chain step of the question content; if i is less than N, increment i by 1, and return to execute the steps of inputting the i-th thought step of the question content, each thought chain step of the question content before the i-th thought step, and the corresponding sub-response content into the large language model agent, which generates sub-response content under the i-th thought chain step of the question content, until i = N; N is the total number of thought chain steps of the question content.

[0015] In some embodiments, the response generation device further includes a historical session retrieval module, used to search in a third vector library based on the embedding representation vector of the question content to obtain a third sub-retrieval result. The third vector library includes the text embedding vectors of the historical question-and-answer content of each round in the session in which the question content is located. If the third sub-retrieval result indicates that a target historical question-and-answer content with a similarity exceeding a fourth similarity threshold has been retrieved, the target historical question-and-answer content is used as auxiliary reference content for the large language model to respond to the question content.

[0016] Thirdly, embodiments of this application provide an electronic device, including: a processor; and a memory storing computer instructions, which, when executed by the processor, implement the above-described method.

[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the above-described method.

[0018] Fifthly, embodiments of this application provide a computer program product, including computer instructions that, when executed by a processor, implement the above-described method.

[0019] This application provides a response generation method, apparatus, and electronic device. The method, upon receiving target input content, first classifies the question type based on the question content included in the target input content. Then, based on the question type identification result, it determines a target reference content acquisition strategy suitable for answering the question content. Different reference content acquisition strategies indicate obtaining reference contexts from different sources to assist in response generation. Next, according to the target reference content acquisition strategy, a target reference context for answering the question content is obtained. Clearly, the target reference context is also the context suitable for answering the question content. Finally, a large language model is invoked to generate a response based on the question content and the target reference context, resulting in a response to the question content. In the above process, for question content of different question types, suitable target reference contexts for answering the question content can be obtained from different sources. With the assistance of the target reference context, the large language model can obtain more reference information beneficial to answering the question content, thereby improving the quality of the generated response content. Furthermore, by setting different reference content acquisition strategies for different question types, it is ensured that the large language model can achieve good response results when facing question content of different question types.

[0020] These or other aspects of this application will become more apparent from the description of the following embodiments. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 A schematic diagram of an application scenario involving an embodiment of this application is shown.

[0023] Figure 2A flowchart illustrating a response generation method provided in an embodiment of this application is shown.

[0024] Figure 3 A schematic diagram illustrating the training process of a problem classification model according to an embodiment of this application is shown.

[0025] Figure 4 This illustration shows a flowchart of obtaining a target reference context from an expert knowledge base according to an embodiment of this application.

[0026] Figure 5 An embodiment of this application is shown. Figure 4 A flowchart of step S430.

[0027] Figure 6 This illustration shows another flowchart of a response generation method provided in an embodiment of this application.

[0028] Figure 7 A schematic diagram of the structure of a robot question-answering system according to an embodiment of this application is shown.

[0029] Figure 8 A schematic diagram of a response generation apparatus according to an embodiment of this application is shown.

[0030] Figure 9 A schematic diagram of an electronic device according to an embodiment of this application is shown. Detailed Implementation

[0031] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.

[0033] In the following description, the terms "first" and "second" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0034] In this document, "multiple" refers to two or more. "And / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following associated objects are in an "or" relationship. In the following description, references to "some embodiments or some embodiment methods" describe a subset of all possible embodiments. However, it is understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict.

[0035] To facilitate understanding of this application, some terms will be explained below.

[0036] Large Language Model (LLM) is a computer model that can process and generate natural language.

[0037] Reinforcement Learning with Human Feedback (RLHF) is an extension of reinforcement learning that incorporates human feedback into the training process, providing machines with a natural and human-like interactive learning process. RLHF allows humans to directly guide machines and enables machines to grasp decision-making elements that are clearly embedded in human experience.

[0038] With the development of artificial intelligence technology, large language models are being used more and more widely in automatic question answering tasks. Among related technologies, large language models generate high-quality responses to questions that were involved during training, but the quality of responses to questions related to domains that were less involved or not involved during training is lower.

[0039] Please see Figure 1 , Figure 1 A schematic diagram of an application scenario involving an embodiment of this application is provided, including a terminal 10 and a server 20, wherein the terminal 10 and the server 20 are connected via a wired or wireless network.

[0040] Terminal 10 can install application software and display the application software's user interface. Users can input target content, i.e., the content that needs to be generated as a response, through the user interface displayed on terminal 10. Input methods include text input, voice input, etc. Server 20 is equipped with a large language model. Terminal 10 sends the received target input content to server 20, and the large language model deployed on server 20 generates a response, obtaining the response content of the target input content. The response content is then returned to terminal 10, and terminal 10 can display the response content to the user through screen display, voice broadcast, etc.

[0041] The process of server 20 generating a response includes: obtaining target input content; the target input content includes at least the question content; classifying the question content into question types to obtain question type classification results; different question types correspond to different reference content acquisition strategies, and different reference content acquisition strategies indicate that reference context used to assist in generating a response is obtained from different sources; based on the question type identification results, determining the target reference content acquisition strategy suitable for answering the question content; obtaining the target reference context used to answer the question content according to the target reference content acquisition strategy; and calling the large language model to generate a response based on the question content and the target reference context to obtain the response content to the question content.

[0042] Terminal 10 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smart TV, wearable device (such as a smartwatch), virtual reality device, in-vehicle terminal, smart TV, etc., but is not limited to these.

[0043] Server 30 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0044] In some embodiments, it can also be deployed on terminal 10, and the method of this application can also be executed by terminal 10. Terminal 10 can be deployed with a large language model, and then the answer content of the question content is generated by the method of this application.

[0045] The present application will now be described in detail with reference to the embodiments.

[0046] Please see Figure 2 , Figure 2A flowchart illustrating the response generation method provided in this application embodiment is given. The response generation method can be executed by an electronic device, which may be a terminal, server, etc., without specific limitations. The response generation method includes steps S110-S150:

[0047] S110. Obtain the target input content; the target input content shall include at least the question content.

[0048] The target input content may consist only of the question content, which is the question entered by the user.

[0049] In some implementations, the target input content may also involve question reference content; question reference content refers to the reference content provided by the user in response to the question content, such as the input document, image, video, etc.; furthermore, the question reference content involved in the target input content may be the content of the webpage pointed to by the URL included in the target input content.

[0050] S120. Classify the question content into question types to obtain question type classification results; among them, different question types correspond to different reference content acquisition strategies, and different reference content acquisition strategies indicate that reference context used to assist in generating answers is obtained from different sources.

[0051] In this application, multiple question types are predefined based on various reference content retrieval strategies. Each question type corresponds to a specific reference content retrieval strategy, and different question types correspond to different reference content retrieval strategies. These different strategies indicate the acquisition of reference context from different sources to assist in generating responses; in other words, different question types correspond to different sources for obtaining reference context.

[0052] In some embodiments, the question type includes at least two of a first question type, a second question type, a third question type, and a fourth question type. The source indicated by the first reference content retrieval strategy corresponding to the first question type is empty. That is, in the process of generating a response to a question, no additional reference context is needed; the response can be generated using only the question content.

[0053] The second reference content retrieval strategy for the second question type indicates that the source is the question reference content involved in the target input content. In other words, during the process of generating an answer to the question, it is necessary to obtain the target reference context from the question reference content involved in the target input content. The obtained target reference context can be the entirety or a portion of the question reference content involved in the target input content.

[0054] The third reference content retrieval strategy for the third question type indicates that the source is public domain content obtained by searching the question content using a search engine. In other words, during the process of generating an answer to a question, a search engine is invoked to search the question content and obtain the target reference context required for the answer from the public domain content retrieved. Similarly, the obtained target reference context can be all the searched public domain content or only a portion of it.

[0055] The fourth reference content acquisition strategy for the fourth question type indicates that the source is expert knowledge content matched in the expert knowledge base based on the question content. In other words, during the process of generating an answer to the question, the target reference context required for the answer needs to be obtained from the matched expert knowledge content.

[0056] The expert knowledge base is pre-built and contains expert knowledge content in one or more professional fields. This expert knowledge content can include reference questions and multiple thought processes for answering them. A professional field is relative to a general field. A general field can be understood as the area covered by common domain content. Professional fields involve more complex knowledge than general fields. Questions involving a professional field require a certain level of knowledge in the corresponding field to answer accurately. Examples of professional fields include medicine, law, and intelligent manufacturing. In some implementations, a question type classification model can be used to classify the questions to obtain the classification results.

[0057] The question type classification model is a neural network model used to classify the question content into question types among the multiple question types involved in this application. These multiple question types can be the first question type, the second question type, the third question type, and the fourth question type mentioned above. Please refer to [link / reference]. Figure 3 , Figure 3 The diagram illustrates the training process of a problem classification model. The training process of the problem type classification model includes steps S210-S240:

[0058] S210. Obtain sample question content and sample tags. The sample tags are used to indicate the reference question type to which the question content belongs.

[0059] In some implementations, the sample tags for the sample questions can be manually labeled, or the sample questions can be analyzed to obtain the question keywords, and the sample tags for the sample questions can be determined based on the question keywords. In this case, it is necessary to pre-build keyword sets corresponding to different sample tags, and use the sample tags corresponding to the keyword sets to which the question keywords belong as the sample tags for the sample questions.

[0060] In some embodiments, four different candidate question content sets can be pre-constructed. Each candidate question content set corresponds to a reference content acquisition strategy (different candidate question content sets use different reference content acquisition strategies). The reference context for each candidate question content in the candidate question content set is obtained, and a large language model is used to generate responses based on the candidate question content and the corresponding reference context to obtain candidate response content for each candidate question content. Then, feedback scores for the candidate response content of each candidate question content are collected (the feedback score is used to reflect the satisfaction with the candidate response content of the candidate question content). After that, for each candidate question content set, candidate question content with feedback scores exceeding a score threshold is selected as sample question content for training the question classification model, and the question type corresponding to the reference content acquisition strategy used to generate the reference context of the candidate question content is used as the sample label of the sample question content.

[0061] For example, if a set of candidate question content A is a reference context obtained using the fourth reference content acquisition strategy, and if a candidate question content (let's say candidate question content A1) in the set of candidate question content A is determined as a sample question content, then the fourth question type is used as the sample label corresponding to candidate question content A1.

[0062] S220. The question type classification model is used to classify the question content of the sample to obtain the predicted question type of the question content.

[0063] S230. Calculate the prediction loss based on the reference problem type and the prediction problem type.

[0064] The prediction loss can be calculated using a loss function, such as the cross-entropy loss function or the mean squared error loss function.

[0065] S240. Adjust the parameters of the problem type classification model based on the prediction loss until the training termination condition is met.

[0066] Specifically, the parameters of the problem type classification model can be adjusted using the gradient descent algorithm based on the predicted loss.

[0067] The training termination condition can be that the predicted loss is less than the loss threshold, the number of training iterations reaches the maximum number of iterations, or the evaluation metric (such as accuracy) of the problem type classification model reaches the preset metric threshold.

[0068] In some implementations, the trained question type classification model can be fine-tuned based on user feedback on responses to questions. Specifically, the classification results of the question type classification model are collected, along with user feedback scores on responses to the generated questions. It's understood that a higher response score indicates a more accurate response, suggesting a more accurate classification result for that question. Therefore, the response score can be considered a score for the classification result. This allows the combination of the question content, the question type indicated by the classification result, and the feedback score to obtain a training sample. This training sample can then be used to train a reward model (specifically, the reward model's analysis of the question content and the question type indicated by the classification result in the training sample). Scoring is performed to obtain the expected reward value. The model loss is calculated based on the expected reward value and the feedback scores in the training samples. Then, the parameters of the reward model are adjusted based on the calculated model loss until the training termination condition is met. After that, the question type classification model is fine-tuned through the reward model (specifically, the question type classification model outputs candidate classification results based on the sample question content, i.e., the question type of the sample question content. The reward model assigns reward values ​​to the candidate classification results output by the question type classification model and adjusts the parameters of the question type classification model based on the reward value in the direction of maximizing the reward value), thereby optimizing the question type classification model.

[0069] S130. Based on the question type identification results, determine the target reference content acquisition strategy suitable for answering the question.

[0070] Since a reference content acquisition strategy corresponding to each question type is predefined, the target reference content acquisition strategy suitable for answering the question is determined based on the question type identification result. That is, the reference content acquisition strategy corresponding to the question type indicated by the question type identification result is determined as the target reference content acquisition strategy suitable for answering the question.

[0071] S140. Obtain the target reference context for answering the question, according to the target reference content acquisition strategy.

[0072] The target reference content acquisition strategy indicates the source of the target reference context; thus, the target reference context used to answer the question can be obtained from the source indicated by the target reference content acquisition strategy, in accordance with the target reference content acquisition strategy.

[0073] In some implementations, the target reference context for answering the question can be determined from the sources indicated by the target reference content retrieval strategy using vector matching. Specifically, vector matching can be performed in the sources indicated by the target reference content retrieval strategy based on the embedded representation vector of the question content to obtain the vector matching degree between each piece of content in the sources indicated by the target reference content retrieval strategy and the question content. Then, the content with a vector matching degree greater than a matching degree threshold can be determined as the target reference context for answering the question.

[0074] S150. The large language model is invoked to generate a response based on the question content and the target reference context, thus obtaining the response content to the question content.

[0075] The large language model is a pre-trained model used for response generation. The question content and target reference context can be input into the large language model, which processes the information and outputs a response to the question. However, if the question belongs to the first question type and the target reference context is empty, in step S150, the question content is input into the large language model, which then outputs a response. It should be noted that the large language model has an inherent limitation: it can only memorize facts and knowledge contained in the training corpus and cannot update the integrated knowledge unless the large language model is retrained. In existing technologies, responses are typically generated directly based on facts and knowledge already stored in a large language model. Alternatively, different types of questions are addressed by obtaining contextual information in the same way (e.g., combining search engines or reference documents). However, the quality of the obtained contextual information is inconsistent across different question types, leading to poor response quality. For example, when obtaining contextual information through a search engine, relatively accurate content can be found as contextual information for fact-finding questions, resulting in highly accurate responses. However, for logical reasoning questions, the search results may not be directly relevant or may even contain errors. The contextual information determined based on the search results is inaccurate, leading to poor accuracy in the generated responses and affecting the overall response quality.

[0076] The method provided in this application first classifies the target input content into question types based on the question content it includes. Then, based on the question type identification results, it determines a target reference content acquisition strategy suitable for answering the question content. Different reference content acquisition strategies indicate the acquisition of reference contexts from different sources to assist in generating responses. Next, according to the target reference content acquisition strategy, the target reference context for answering the question content is acquired. Obviously, the target reference context is also the context suitable for answering the question content. Finally, the large language model is invoked to generate a response based on the question content and the target reference context, resulting in a response to the question content. In the above process, for question content of different question types, target reference contexts suitable for answering the question content can be acquired from different sources. With the assistance of the target reference context, the large language model can acquire more reference information that is beneficial to answering the question content, thereby improving the quality of the generated response content. Furthermore, by setting different reference content acquisition strategies for different question types, it is ensured that the large language model can achieve good response results when facing question content of different question types.

[0077] In some implementations, the response generation method may further include:

[0078] Based on the embedded representation vector of the question content, a vector retrieval is performed in a vector library to obtain the vector retrieval results. The vector library is constructed based on at least multiple public domain contents and question references corresponding to the target input content. The public domain contents are retrieved using a search engine based on the question content. Therefore, step S130 may specifically include:

[0079] Based on the question type identification results and vector retrieval results, a target reference content acquisition strategy suitable for answering the question is determined.

[0080] The embedded representation vector of the question content is obtained by embedding the question content; by performing vector retrieval in the vector library using the embedded representation vector of the question content, the public domain content or question reference content associated with the question content in the vector library can be identified.

[0081] In some implementations, since the vector library includes public domain content and question reference content, vector retrieval in the vector library based on the embedded representation vector of the question content can be performed simultaneously in the public domain content and question reference content included in the vector library. In this case, before performing vector retrieval in the vector library, it is necessary to first use a search engine to search based on the question content to obtain multiple public domain content entries.

[0082] In some implementations, the question type identification result includes the probability that the question content belongs to each of multiple question types; based on the question type identification result and the vector retrieval result, a target reference content acquisition strategy suitable for answering the question content is determined, which may specifically include:

[0083] If the question type identification result includes a target question type with a probability higher than the probability threshold, the reference content acquisition strategy corresponding to the target question type will be used as the target reference content acquisition strategy applicable to answering the question.

[0084] If the probability of each question type in the question type identification results is not higher than the probability threshold, a target reference content acquisition strategy suitable for answering the question content is determined based on the vector retrieval results.

[0085] Understandably, if the probability of the question content belonging to the target question type is higher than the probability threshold, it means that the identification result of the question content belonging to the target question type has a sufficiently high confidence level. Therefore, the reference content acquisition strategy corresponding to the target question type can be used as the target reference content acquisition strategy applicable to answering the question content. If the probability of each question type in the question type identification result is not higher than the probability threshold, it means that the question type identification result is not accurate enough. The question type identification result cannot accurately determine the question type of the question content. In this case, the reference content acquisition strategy corresponding to the question type indicated by the question type identification result is also likely not applicable to the generation of the answer to the question content. Therefore, when the question type identification result is not accurate enough, the target reference content acquisition strategy applicable to answering the question content can be determined based on the vector retrieval result.

[0086] In some implementations, the vector library includes a first sub-vector library and a second sub-vector library. The first sub-vector library includes text embedding vectors of each content fragment in the question's reference content; the second sub-vector library includes text embedding vectors of each referenced public domain content; the vector retrieval results include a first sub-retrieval result and a second sub-retrieval result. The first sub-retrieval result is obtained by retrieving the embedding representation vector of the question content from the first sub-vector library; the second sub-retrieval result is obtained by retrieving the embedding representation vector of the question content from the second sub-vector library; the question types include a first question type, a second question type, a third question type, and a fourth question type; based on this, step S312 specifically includes the following three cases:

[0087] Scenario 1: If the first sub-search result indicates that the target content fragment was found in the first sub-vector library, it is determined that the question content belongs to the second question type. The second reference content acquisition strategy corresponding to the second question type is used as the target reference content acquisition strategy applicable to answering the question content. The target content fragment refers to the content fragment in the first sub-vector library whose similarity to the question content exceeds the first similarity threshold.

[0088] Clearly, since the similarity between the target content fragment and the question content exceeds the first similarity threshold, it indicates that the target content fragment and the question content have a strong correlation. In other words, the target content fragment can provide a lot of useful information for generating an answer to the question content. Since the target content fragment is contained in the question reference content, the target content fragment can be directly determined from the question reference content. That is, the second reference content acquisition strategy can be determined as a target reference content acquisition strategy suitable for answering the question content.

[0089] When the target reference content acquisition strategy is the second reference content acquisition strategy, step S140 may specifically include: using the target content fragment as the target reference context for answering the question content.

[0090] Scenario 2: If the first sub-search result indicates that no target content fragment was found in the first sub-vector library, and the second sub-search result indicates that target public domain content was found in the second sub-vector library, it is determined that the question content belongs to the third question type. The third reference content acquisition strategy corresponding to the third question type is used as the target reference content acquisition strategy applicable to answering the question content. The target public domain content refers to the reference public domain content in the second sub-vector library whose similarity to the question content exceeds the second similarity threshold.

[0091] Similar to Case 1, since the similarity between the target public domain content and the question content exceeds the second similarity threshold, it means that the target public domain content and the question content have a strong correlation. In other words, the target public domain content can provide more useful information for generating answers to the question content. In this case, the third reference content acquisition strategy can be determined as the target reference content acquisition strategy suitable for answering the question content.

[0092] In some embodiments, to improve retrieval efficiency, a search can be performed first in the first sub-vector library to obtain the first sub-retrieval result. If the first sub-retrieval result indicates that the target content fragment was not found in the first sub-vector library, a search can then be performed in the second sub-vector library to obtain the second sub-retrieval result. If the first sub-retrieval result indicates that the target content fragment was found in the first sub-vector library, then there is no need to perform a search in the second sub-vector library, and the question type to which the question content belongs is determined to be the second question type.

[0093] In other embodiments, searches can be performed simultaneously in the first sub-vector library and the second sub-vector library to obtain the first sub-search result and the second sub-search result. In this case, the first sub-search result indicating that the target content fragment was found in the first sub-vector library can specifically include two cases: the first sub-search result indicates that the target content fragment was found in the first sub-vector library, and the second sub-search result indicates that the target public domain content was not found in the second sub-vector library; and the first sub-search result indicates that the target content fragment was found in the first sub-vector library, and the second sub-search result indicates that the target public domain content was found in the second sub-vector library.

[0094] If the first sub-search result indicates that the target content fragment was found in the first sub-vector library, and the second sub-search result indicates that the target public domain content was found in the second sub-vector library, then the process can be directly handled according to Case 1 above. Alternatively, the first and second sub-search results can be compared. If the first sub-search result is better than the second sub-search result, the process can be handled according to Case 1; if the second sub-search result is better than the first sub-search result, the process can be handled according to Case 3.

[0095] In some implementations, comparing the first sub-search result and the second sub-search result can involve determining a first number of target content fragments indicated in the first sub-search result and a second number of target public domain content indicated in the second sub-search result, and determining a better sub-search result based on the first and second numbers. Specifically, if the first number is greater than the second number, the first sub-search result is determined to be better than the second sub-search result; if the first number is not greater than the second number, the second sub-search result is determined to be better than the first sub-search result.

[0096] In other embodiments, based on determining the first quantity and the second quantity, a first similarity between each target content fragment in the first sub-retrieval result and the query content, and a second similarity between each target public domain content in the second sub-retrieval result and the query content, can also be determined. Then, based on the first quantity and the first similarity between each target content fragment and the query content, a first average similarity of the first sub-retrieval result is calculated; and based on the second quantity and the second similarity between each target public domain content and the query content, a second average similarity of the second sub-retrieval result is calculated. Finally, a superior sub-retrieval result is determined based on the first average similarity and the second average similarity. Specifically, if the first average similarity is greater than the second average similarity, the first sub-retrieval result is determined to be superior to the second sub-retrieval result; if the first average similarity is not greater than the second average similarity, the second sub-retrieval result is determined to be superior to the first sub-retrieval result.

[0097] When the target reference content acquisition strategy is the third reference content acquisition strategy, step S140 may specifically include: using the target public domain content as the target reference context for answering the question content.

[0098] Scenario 3: If the first sub-search result indicates that no target content fragment was found in the first sub-vector library, and the second sub-search result indicates that no target public domain content was found in the second sub-vector library, it is determined that the question content belongs to the fourth question type. The fourth reference content acquisition strategy corresponding to the fourth question type is used as the target reference content acquisition strategy applicable to answering the question content.

[0099] It is understandable that if no target content fragment or target public domain content is found, it means that the question is likely to be a relatively complex issue. In this case, expert knowledge content related to the question can be found in the expert knowledge base. In other words, the fourth reference content acquisition strategy can be determined as the target reference content acquisition strategy suitable for answering the question.

[0100] Please see Figure 4 , Figure 4 This illustration shows a flowchart of obtaining the target reference context from an expert knowledge base according to an embodiment of this application. When the target reference content acquisition strategy is the fourth reference content acquisition strategy, step S140 may specifically include:

[0101] S410. Based on the embedded representation vector of the question content, perform vector retrieval in the expert knowledge base to obtain target expert knowledge content whose similarity to the question content exceeds the third similarity threshold; the target expert knowledge content includes reference question content and multiple thought chain steps for answering the reference question content.

[0102] Specifically, when performing vector retrieval in the expert knowledge base, the retrieval is based on the embedding representation vector of the question content and the embedding representation vector of the reference question content included in the expert knowledge content in the expert knowledge base. This determines the reference question content that is similar to the question content, and then the expert knowledge content to which the reference question content belongs is used as the target expert knowledge content.

[0103] S420. Based on the reference question content and multiple thought chain steps used to answer the reference question content, generate a thought chain for the question content to obtain multiple thought chain steps for the question content.

[0104] The multiple thought processes used to answer the reference question can be called the thought process of the reference question. These thought processes have a sequential order; arranging them in the corresponding order forms the thought process of the reference question. It can be understood that by studying the reference question and the multiple thought processes used to answer it, one can learn the process of generating a thought process for the reference question. Since the reference question and the question have certain similarities or relevance, the multiple thought processes of the reference question can be used as a reference to generate a thought process for the question, resulting in multiple thought processes for the question.

[0105] In some implementations, a thought chain generation model or a large language model with thought chain planning capabilities can be used to generate a thought chain for the question content based on the reference question content and multiple thought chain steps used to answer the reference question content, thereby obtaining multiple thought chain steps for the question content.

[0106] S430. Generate sub-response content under each step of the thought chain of the question content, according to the multiple thought chain steps of the question content.

[0107] S440. Use the multiple thought chain steps of the question and the sub-response content under the corresponding thought chain steps as the target reference context for answering the question.

[0108] Understandably, by using multiple thought chain steps in the question content and the sub-response content under the corresponding thought chain steps, the large language model can better understand the response requirements of the question content, thereby improving the quality of the response content.

[0109] For example, the question is "Has XX Company's cash been illegally misappropriated?" This question falls under the fourth question type, meaning the target reference content acquisition strategy is the fourth reference content acquisition strategy. In this case, a search is performed on the expert knowledge base based on the question. Assuming the target expert's knowledge content is found, its reference question is "How to determine if a listed company's cash has been illegally misappropriated?" The thought process steps to answer this reference question include: "1. Obtain the company's rate of return on capital, rate of return = interest income / average cash balance; 2. Obtain the corresponding bank's fixed deposit interest rate and seven-day notice deposit interest rate; 3. If the company's fixed deposit rate of return is significantly lower than the corresponding bank's fixed deposit interest rate, it indicates that the company's fixed deposits may be illegally misappropriated."

[0110] At this point, a thought chain can be generated based on the retrieved target expert knowledge content to obtain multiple thought chain steps for the question content, and sub-response content under each thought chain step of the question content can be generated according to these multiple thought chain steps. Specifically, based on the question content "Has the cash of XX Company been illegally misappropriated?", the following content can be obtained, which is the target reference context corresponding to the question content:

[0111] Thinking step 1: Calculate the rate of return on cash, where the rate of return on cash = interest income / average cash balance.

[0112] Sub-response content 1: Search the document "[XX Company Interest Income and Cash and Cash Equivalents]" to confirm that the interest income is 1 million and the cash and cash deposits are 1 billion.

[0113] Thinking Step 2: With interest income of 1 million and cash fixed deposit of 1 billion, calculate the fixed deposit yield = interest income / fixed deposit.

[0114] Sub-response content 2: The fixed deposit yield is calculated as [100 / 100000].

[0115] Step 3: The fixed deposit interest rate is 0.196. Search for fixed deposit interest rates and bank seven-day notice deposit interest rates.

[0116] Sub-response 3: Search the web for "[fixed deposit interest rate, seven-day notice deposit interest rate]", and the search results show that the fixed deposit interest rate is 1.75% and the seven-day notice deposit interest rate is 0.3%.

[0117] Thinking Step 4: The one-year fixed deposit interest rate is 1.75%, and the seven-day notice deposit interest rate is 0.3%. XX Company's fixed deposit interest rates are low, which may indicate illegal misappropriation of cash.

[0118] Sub-response content 4: [XX Company's interest income is 1 million, cash time deposits are 1 billion, time deposit interest rates are 0.1% and 1.75%, seven-day notice deposit interest rate is 0.3%. XX Company's time deposit interest rate is slightly lower, which may indicate illegal appropriation of cash.]

[0119] Understandably, by retrieving reference questions from the expert knowledge base and understanding the multiple thought chain steps used to answer them, the process of generating thought chains for reference questions can be learned. Since reference questions and the question content share certain similarities or relevance, the multiple thought chain steps of the reference questions can be used to generate thought chains for the question content, resulting in multiple thought chain steps for the question content. Furthermore, based on these multiple thought chain steps and the sub-response content under each thought chain step, the large language model can better understand the response requirements of the question content, effectively enhancing its reasoning ability and the interpretability of the results, thereby improving the quality of the responses to the question content.

[0120] Please see Figure 5 , Figure 5 It shows Figure 4 A flowchart of step S430 is provided. Step S430 includes steps S510-S540:

[0121] S510. Input the first thought chain step of the question content into the large language model agent, and the large language model agent generates the sub-response content under the first thought chain step of the question content.

[0122] Among them, the large language model intelligent agent includes the large language model and the intelligent agent built on the large language model; specifically, the intelligent agent built on the large language model can call external tools according to the needs of the large language model, thereby realizing the collaborative cooperation between the large language model and external tools.

[0123] S520, initialize i to 2.

[0124] S530. Input the i-th thought step of the question, the thought chain steps of the question before the i-th thought step, and the corresponding sub-response content into the large language model agent, and the large language model agent generates the sub-response content under the i-th thought chain step of the question.

[0125] S540. If i is less than N, increment i by 1 and return to the large language model agent. Input the i-th thought step of the question, the thought chain steps of the question before the i-th thought step, and the corresponding sub-response content into the large language model agent. The large language model agent generates the steps of the sub-response content under the i-th thought chain step of the question, until i = N; N is the total number of thought chain steps of the question.

[0126] In some implementations, to further improve the efficiency of question type determination, the vector library may also include a first embedding vector corresponding to the question's referenced content and a second embedding vector jointly corresponding to multiple reference public domain contents; the vector retrieval results include a first sub-retrieval result and a second sub-retrieval result, wherein the first sub-retrieval result is determined based on the vector similarity between the embedding representation vector of the question content and the first embedding vector; and the second sub-retrieval result is determined based on the vector similarity between the embedding representation vector of the question content and the second embedding vector.

[0127] Specifically, if the vector similarity between the embedded representation vector of the question content and the first embedded vector is greater than the first preset threshold, it means that there is content related to the question content in the question reference content, and the question content is determined to belong to the second question type. The second reference content acquisition strategy corresponding to the second question type is then applied.

[0128] Next, the content cited in the question can be further split into multiple content fragments. Then, based on the embedding representation vector of the question content, vector retrieval can be performed among the multiple content fragments to determine the content fragments with high similarity to the question content as the target reference context.

[0129] If the vector similarity between the embedded representation vector of the question content and the first embedded vector is not greater than the first preset threshold, it means that there is no content related to the question content in the question reference content; at the same time, if the vector similarity between the embedded representation vector of the question content and the second embedded vector is greater than the second preset threshold, it means that there is content related to the question content in multiple reference public domains. It is determined that the question content belongs to the third question type, and the third reference content acquisition strategy corresponding to the third question type is used as the target reference content acquisition strategy applicable to answering the question content.

[0130] Then, based on the embedded representation vector of the question content, vector retrieval is performed in multiple reference public domain contents to determine the reference public domain contents with high similarity to the question content as the target reference context.

[0131] If the vector similarity between the embedded representation vector of the question content and the first embedded vector is not greater than the first preset threshold, and the vector similarity between the embedded representation vector of the question content and the second embedded vector is not greater than the second preset threshold, it means that there is no content related to the question content in the question reference content and no content related to the question content in multiple reference public domain contents. It is determined that the question content belongs to the fourth question type, and the fourth reference content acquisition strategy corresponding to the fourth question type is used as the target reference content acquisition strategy applicable to answering the question content.

[0132] Understandably, in the above process, retrieval based on the embedding vector of the question content will only be performed across multiple content segments if the vector similarity between the first embedding vectors corresponding to the question content and the question reference content is greater than a first preset threshold. If the vector similarity between the question content and the first embedding vectors corresponding to the question reference content is not greater than the first preset threshold, retrieval based on the embedding vector of the question content will not be performed across multiple content segments. Similarly, retrieval based on the embedding vector of the question content will only be performed across multiple reference public domain contents if the vector similarity between the question content and the second embedding vectors corresponding to multiple reference public domain contents is greater than a second preset threshold. If the vector similarity between the question content and the second embedding vectors corresponding to multiple reference public domain contents is not greater than the second preset threshold, retrieval based on the embedding vector of the question content will not be performed across multiple reference public domain contents. This reduces the number of searches required and improves retrieval efficiency.

[0133] In some implementations, please refer to Figure 6 , Figure 6 This illustration shows another flowchart of the response generation method provided in the embodiments of this application. The response generation method may further include steps S610-S620:

[0134] S610. Based on the embedding representation vector of the question content, perform a search in the third vector library to obtain the third sub-search result. The third vector library includes the text embedding vectors of the historical question and answer content of each round in the conversation in which the question content is located.

[0135] S620. If the third sub-retrieval result indicates that the target historical question and answer content with a similarity to the question content exceeds the fourth similarity threshold, the target historical question and answer content shall be used as auxiliary reference content for the large language model to answer the question content.

[0136] It is understandable that the historical question-and-answer sessions in the conversation containing the question are part of the data stored in the language model. Therefore, regardless of the reference content retrieval strategy used to obtain the target reference context, it is possible to obtain the target historical question-and-answer content with a similarity exceeding the fourth similarity threshold with the question content. This can assist the language model in generating responses to the question content, thereby further enriching the background information of the question content.

[0137] For easier understanding, please refer to Figure 7 , Figure 7 A schematic diagram of the structure of a robot question-answering system according to an embodiment of this application is shown.

[0138] The robot question-answering system includes a corpus collection module 100, a question-answering enhancement module 200, an output module 300, and an optimization module 400.

[0139] The corpus collection module 100 can collect various types of corpus data, such as machine-generated automatic question-and-answer corpus, manually annotated persona question-and-answer corpus, and corpus of profile style settings related to robot profile description and style description, etc. The collected corpus is sent to the question-and-answer enhancement module 200.

[0140] The question-answering enhancement module 200 includes a corpus processing unit, a fine-tuning training unit, and a question-answering processing unit.

[0141] After receiving the corpus data sent by the corpus collection module 100, the corpus processing unit processes the corpus data, for example, by converting various corpus data into single-turn or multi-turn dialogues to obtain dialogue data. On the other hand, the corpus processing unit can also establish a corpus database to store the processed corpus data. For ease of description, the corpus data in the corpus database is described as training corpus data.

[0142] Subsequently, the fine-tuning training unit can use training corpus data to fine-tune the base model. Through different training corpus data, on the one hand, a large language model for response generation can be trained, and on the other hand, a question type classification model for classifying question content can be trained.

[0143] The question-answering processing unit is used to execute the question-answering method provided in this application, namely, receiving the target input content input by the user, classifying the question content into question types through a question type classification model, determining the target reference content acquisition strategy suitable for answering the question content based on the question classification result, obtaining the target reference context for answering the question content according to the target reference content acquisition strategy, and calling the large language model to generate an answer based on the question content and the target reference context to obtain the initial answer content to the question content.

[0144] Depending on the different target reference content acquisition strategies, the target reference context can be target historical question and answer content in historical conversation content, target content fragments in question reference content, target public domain content in public domain content, and target expert knowledge content retrieved from the expert knowledge base.

[0145] Finally, the output module 300 performs post-processing on the initial response content output by the question-and-answer processing unit. Post-processing includes standardizing the response format, replacing sensitive words, and validating the validity. The post-processed initial response content is then displayed to the user as the response content.

[0146] Furthermore, the optimization module 400 can collect user feedback on the generated responses, construct labeled data based on this feedback, and perform reinforcement training on the large language model using this labeled data to obtain an updated large language model. This updated large language model is then used to replace the large language model in the question-answering unit, thus updating the robot question-answering system. Reinforcement training methods include, for example, the RLHF method and the Direct Preference Optimization (DPO) method; specific training methods are not limited here.

[0147] In the aforementioned robot question-answering system, the base model can be a neural network model using a Transformer structure. The Transformer structure, which fully utilizes attention mechanisms for sequence modeling, has achieved excellent results in machine translation tasks. It breaks the traditional pattern that encoder-decoder models must be combined with recurrent neural networks (RNNs), significantly improving model parallelism without sacrificing or even enhancing performance.

[0148] The Transformer architecture typically includes the following key components:

[0149] Multi-head self-attention layers are used to apply self-attention to the input sequence, thereby simultaneously mining the relationships between each element in the input sequence and all other elements. At the same time, through multi-head attention, information can be mined from different vector subspaces, thereby capturing richer information and improving the model's representational ability.

[0150] The Position-wise Feed-Forward Network, following the multi-head self-attention layer, is used to explore the interaction relationships between different dimensions.

[0151] The Transformer Layer consists of a multi-head self-attention layer and a position-prep network layer. A residual network structure is added at the output positions of the multi-head self-attention layer and the position-prep network layer, and the output is normalized.

[0152] Stacking Transformer Layers are used to combine the outputs of multiple transformer layers, allowing for the learning of more complex and higher-order interaction information.

[0153] It is worth mentioning that a large language model can be obtained by fine-tuning and training based on a base model.

[0154] In some implementations, the base model can be fine-tuned by constructing supervised fine-tuning (SFT) data. For example, supervised fine-tuning data can be constructed to enhance the model's ability to answer mathematical problems.

[0155] Instructions: Please answer the following math problem: A fruit store received 20 boxes of pears, each weighing 25 kilograms. After selling 315 kilograms, how many kilograms are left?

[0156] think:

[0157] Step 1: Find the initial total weight: 20 boxes × 25 kg / box = 500 kg;

[0158] Step 2: Subtract the weight sold, 500 kg - 315 kg = 185 kg;

[0159] Answer: 185 kilograms remain.

[0160] The process of fine-tuning the base model using the aforementioned business supervision fine-tuning data specifically includes: using the "instructions" and "thinking" in the business supervision fine-tuning data as training data, and the "answers" in the business supervision fine-tuning data as data labels. Then, the base model generates predicted answers based on the training data (i.e., "instructions" and "thinking"). The prediction loss is calculated based on the predicted answers and the answers in the data labels. The parameters of the base model are adjusted based on the prediction loss to achieve fine-tuning training of the base model and obtain a large language model.

[0161] Understandably, since the training data of the large language model includes training data for mathematical problems, the large language model can have a better response performance when faced with similar mathematical problems. By constructing business-supervised fine-tuning data under different business scenarios to train the base model, the trained large language model can have a good response performance in various business scenarios.

[0162] Furthermore, to improve the efficiency of fine-tuning data construction for business supervision, instructions can be cross-referenced and improved. For example, the initial instruction is: Xiaoming can read 8 pages of a book every 20 minutes, while Xiaohong writes a 3-page letter to two different friends every week. How many hours would it take Xiaoming to read the total number of pages Xiaohong writes in a year?

[0163] The initial instruction can evolve into instruction 1: Xiaoming can read 8 pages of a book in 20 minutes. How many hours would it take him to read 120 pages? The initial instruction can also evolve into instruction 2: Xiaohong writes a 3-page letter to two different friends every week. How many pages will he write in a year?

[0164] Clearly, by cross-referencing and improving the instructions, the number of instructions is greatly increased. For each instruction, corresponding business supervision fine-tuning data can be constructed, thereby increasing the amount of business supervision fine-tuning data. With a large amount of business supervision fine-tuning data, the training effect of business supervision fine-tuning data on the base model can be further improved.

[0165] In some implementations, to improve the large language model's ability to perform citation attribution, business supervision fine-tuning data with citation attribution can be constructed. For example, the instruction data format can be as follows:

[0166] Command: {Question content}.

[0167] Reference documents: {Document 1, Document 2, ... Document 3}.

[0168] Instructions: First, quickly select the most relevant and comprehensive references from the provided resources and list their numbers. Second, using the provided references, provide a comprehensive answer to the given questions. Ensure that the reference number is indicated after each sentence when citing a reference, such as [1][2][3][4]. Finally, please provide your own understanding.

[0169] Reply: {Reply content}.

[0170] The process of fine-tuning the base model using the aforementioned business supervision fine-tuning data specifically includes: using the "instructions," "reference documents," and "requirements" in the business supervision fine-tuning data as training data, and using the "responses" in the business supervision fine-tuning data as data labels. Then, the base model generates predicted responses based on the training data (i.e., "instructions," "reference documents," and "requirements"). The predicted responses include the content of the predicted responses and the numbers of the reference documents cited in the predicted responses. The prediction loss is calculated based on the predicted responses and the responses in the data labels. The parameters of the base model are adjusted according to the prediction loss to achieve fine-tuning training of the base model and obtain a large language model.

[0171] By fine-tuning the base model using the business-supervised data with attribution requirements, the trained large language model can be equipped with the ability to first filter and then refer to the answers, thereby increasing users' trust in the final response.

[0172] In the application scenarios of the aforementioned robot question-answering system, the system can identify the question type based on the target input content. This allows for the adoption of different target reference content acquisition strategies for different question types, resulting in more suitable target reference contexts. This enables the large language model to better answer user questions based on the question content and target reference context. To a certain extent, this reduces the cost of retraining the large language model in the robot question-answering system and the cost of collecting, processing, and deploying new training data. It also solves some of the illusion problems in the generated results of the large language model and avoids catastrophic forgetting to a certain extent. Especially for complex questions, effective target reference contexts can be obtained through search engines and expert knowledge bases, effectively enhancing the reasoning ability of the large language model in the robot question-answering system and improving the interpretability of the results. This increases the practical application of the robot question-answering system in more knowledge domains and effectively improves the question-answering results. Simultaneously, the reference question content and multiple thought chain steps for answering the reference question content provided by the expert knowledge base can guide and assist in the decomposition of the question content. For complex question content, step-by-step decomposition and processing improves the model's ability to answer various complex questions and increases user trust in the final result.

[0173] In some implementations, please refer to Figure 8 , Figure 8 A schematic diagram of a response generation apparatus provided in an embodiment of this application is given. The response generation apparatus 700 includes:

[0174] The first acquisition module 710 is used to acquire the target input content; the target input content includes at least the question content.

[0175] The classification module 720 is used to classify the question content into question types and obtain the question type classification results. Different question types have different reference content acquisition strategies, and different reference content acquisition strategies indicate that reference context used to assist in generating answers is obtained from different sources.

[0176] The strategy determination module 730 is used to determine the target reference content acquisition strategy suitable for answering the question based on the question type identification results.

[0177] The second acquisition module 740 is used to acquire the target reference context for answering the question content according to the target reference content acquisition strategy.

[0178] The response generation module 750 is used to call the large language model to generate a response based on the question content and the target reference context, thus obtaining the response content to the question content.

[0179] In some implementations, the question type includes at least two of a first question type, a second question type, a third question type, and a fourth question type; the source indicated by the first reference content acquisition strategy corresponding to the first question type is empty; the source indicated by the second reference content acquisition strategy corresponding to the second question type is: the question reference content involved in the target input content; the source indicated by the third reference content acquisition strategy corresponding to the third question type is: public domain content obtained by searching the question content using a search engine; and the source indicated by the fourth reference content acquisition strategy corresponding to the fourth question type is: expert knowledge content matched in the expert knowledge base based on the question content.

[0180] In some embodiments, the response generation device 700 further includes a vector retrieval module for performing vector retrieval in a vector library based on the embedded representation vector of the question content to obtain vector retrieval results. The vector library is constructed based on at least multiple public domain contents and question reference contents corresponding to the target input content. The public domain contents are searched using a search engine based on the question content. The strategy determination module 730 is also used to determine a target reference content acquisition strategy suitable for answering the question content based on the question type identification result and the vector retrieval result.

[0181] In some implementations, the question type identification result includes the probability that the question content belongs to each of the multiple question types; the strategy determination module 730 is specifically used to, if the question type identification result includes a target question type with a probability higher than the probability threshold, use the reference content acquisition strategy corresponding to the target question type as the target reference content acquisition strategy applicable to answering the question content; if the probability of each question type in the question type identification result is not higher than the probability threshold, determine the target reference content acquisition strategy applicable to answering the question content based on the vector retrieval result.

[0182] In some implementations, the vector library includes a first sub-vector library and a second sub-vector library. The first sub-vector library includes text embedding vectors of each content fragment in the question reference content; the second sub-vector library includes text embedding vectors of each reference public domain content; the vector retrieval results include a first sub-retrieval result and a second sub-retrieval result. The first sub-retrieval result is obtained by retrieving the embedding representation vector of the question content from the first sub-vector library; the second sub-retrieval result is obtained by retrieving the embedding representation vector of the question content from the second sub-vector library; the question types include a first question type, a second question type, a third question type, and a fourth question type; the strategy determination module 730 is specifically used to determine that the question content belongs to the second question type if the first sub-retrieval result indicates that a target content fragment is retrieved in the first sub-vector library, and to use the second reference content acquisition strategy corresponding to the second question type as the target reference content acquisition strategy applicable to answering the question content; the target content fragment... A segment refers to a content fragment in the first sub-vector library whose similarity to the question content exceeds a first similarity threshold. If the first sub-search result indicates that no target content fragment was found in the first sub-vector library, and the second sub-search result indicates that target public domain content was found in the second sub-vector library, the question content is determined to belong to the third question type, and the third reference content acquisition strategy corresponding to the third question type is used as the target reference content acquisition strategy applicable to answering the question content. Target public domain content refers to reference public domain content in the second sub-vector library whose similarity to the question content exceeds a second similarity threshold. If the first sub-search result indicates that no target content fragment was found in the first sub-vector library, and the second sub-search result indicates that no target public domain content was found in the second sub-vector library, the question content is determined to belong to the fourth question type, and the fourth reference content acquisition strategy corresponding to the fourth question type is used as the target reference content acquisition strategy applicable to answering the question content.

[0183] In some implementations, the target reference content acquisition strategy is a second reference content acquisition strategy; the second acquisition module 740 is specifically used to use the target content fragment as the target reference context for answering the question content.

[0184] In some implementations, the target reference content acquisition strategy is a third reference content acquisition strategy; the second acquisition module 740 is specifically used to use the target public domain content as the target reference context for answering the question content.

[0185] In some implementations, the target reference content acquisition strategy is a fourth reference content acquisition strategy; the second acquisition module 740 includes an expert database retrieval unit, used to perform vector retrieval in the expert knowledge base based on the embedded representation vector of the question content, to obtain target expert knowledge content whose similarity to the question content exceeds a third similarity threshold; the target expert knowledge content includes reference question content and multiple thought chain steps for answering the reference question content; a thought chain generation unit, used to generate a thought chain for the question content based on the reference question content and the multiple thought chain steps for answering the reference question content, to obtain multiple thought chain steps of the question content; a thought chain response unit, used to generate sub-response content under each thought chain step of the question content according to the multiple thought chain steps of the question content; and a collection unit, used to use the multiple thought chain steps of the question content and the sub-response content under the corresponding thought chain steps as target reference context for answering the question content.

[0186] In some implementations, the thought chain response unit is specifically used to input the first thought chain step of the question content into the large language model agent, which then generates sub-response content under the first thought chain step of the question content; initialize i to 2; input the i-th thought step of the question content, all thought chain steps of the question content before the i-th thought step, and the corresponding sub-response content into the large language model agent, which then generates sub-response content under the i-th thought chain step of the question content; if i is less than N, increment i by 1, and return to the step of inputting the i-th thought step of the question content, all thought chain steps of the question content before the i-th thought step, and the corresponding sub-response content into the large language model agent, which then generates sub-response content under the i-th thought chain step of the question content, until i = N; N is the total number of thought chain steps of the question content.

[0187] In some embodiments, the response generation device 700 further includes a historical session retrieval module, which is used to search in a third vector library based on the embedding representation vector of the question content to obtain a third sub-retrieval result. The third vector library includes the text embedding vectors of the historical question and answer content in each round of the session in which the question content is located. If the third sub-retrieval result indicates that a target historical question and answer content with a similarity to the question content exceeds a fourth similarity threshold, the target historical question and answer content is used as auxiliary reference content for the large language model to respond to the question content.

[0188] Figure 9 A schematic diagram of a computer system suitable for implementing an electronic device according to embodiments of this application is shown. This electronic device can be the terminal described above, used to implement the response generation method provided in this application. It should be noted that... Figure 9The computer system 1300 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0189] like Figure 9 As shown, the computer system 1300 includes a Central Processing Unit (CPU).

[0190] CPU 1301 can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on a program stored in read-only memory (ROM) 1302 or a program loaded from storage section 1308 into random access memory (RAM) 1303. RAM 1303 also stores various programs and data required for system operation. CPU 1301, ROM 1302, and RAM 1303 are interconnected via bus 1304. Input / output (I / O) interface 1305 is also connected to bus 1304.

[0191] The following components are connected to I / O interface 1305: an input section 1306 including a keyboard, mouse, microphone, etc.; an output section 1307 including a cathode ray tube (CRT), liquid crystal display (LCD), and speakers, etc.; a storage section 1308 including a hard disk, etc.; and a communication section 1309 including a network interface card such as a LAN (Local Area Network) card and a modem, etc. The communication section 1309 performs communication processing via a network such as the Internet. A drive 1310 is also connected to I / O interface 1305 as needed. Removable media 1311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1310 as needed so that computer instructions read from them can be loaded into storage section 1308 as needed.

[0192] In particular, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising computer instructions. When these computer instructions are executed by the central processing unit (CPU) 1301, various functions defined in the system of this application are performed.

[0193] This application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the methods described in any of the above method embodiments.

[0194] It should be noted that the computer-readable storage medium shown in the embodiments of this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable storage medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0195] In the embodiments of this application, the terms "module" or "unit" refer to computer instructions or a portion of computer instructions that have a predetermined function and work together with other related parts to achieve a predetermined goal. These instructions can be implemented, wholly or partially, using software, hardware (e.g., processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that functions as a whole.

[0196] The above are merely preferred embodiments of this application and are not intended to limit this application in any way. Although this application has disclosed preferred embodiments as above, it is not intended to limit this application. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the technical solution of this application. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of this application without departing from the scope of the technical solution of this application shall still fall within the scope of the technical solution of this application.

Claims

1. A response generation method, characterized in that, include: Obtain the target input content; The target input content includes at least the question content; The questions are categorized by question type to obtain question type classification results; different question types correspond to different reference content acquisition strategies, and different reference content acquisition strategies indicate that reference context used to assist in generating answers is obtained from different sources; Based on the question type identification results, a target reference content acquisition strategy suitable for answering the question is determined; According to the target reference content acquisition strategy, obtain the target reference context for answering the question. The large language model is invoked to generate a response based on the question content and the target reference context, thus obtaining the response content to the question content.

2. The method according to claim 1, characterized in that, The question types include at least two of the following: a first question type, a second question type, a third question type, and a fourth question type. The source indicated by the first reference content acquisition strategy corresponding to the first problem type is empty; The source indicated by the second reference content acquisition strategy corresponding to the second question type is: the question reference content involved in the target input content; The source indicated by the third reference content acquisition strategy corresponding to the third question type is: public domain content obtained by searching the question content using a search engine; The source indicated by the fourth reference content acquisition strategy corresponding to the fourth question type is: expert knowledge content matched in the expert knowledge base based on the question content.

3. The method according to claim 2, characterized in that, The method further includes: Based on the embedded representation vector of the question content, a vector retrieval is performed in a vector library to obtain vector retrieval results. The vector library is constructed based on at least multiple public domain contents and the question reference content corresponding to the target input content. The public domain contents are retrieved using a search engine based on the question content. The step of determining a target reference content acquisition strategy suitable for answering the question based on the question type identification result includes: Based on the question type identification results and the vector retrieval results, a target reference content acquisition strategy suitable for answering the question is determined.

4. The method according to claim 3, characterized in that, The question type identification result includes the probability that the question content belongs to each of the multiple question types; The step of determining a target reference content acquisition strategy suitable for answering the question based on the question type identification result and the vector retrieval result includes: If the question type identification result includes a target question type with a probability higher than the probability threshold, the reference content acquisition strategy corresponding to the target question type shall be used as the target reference content acquisition strategy applicable to answering the question content. If the probability of each question type in the question type identification result is not higher than the probability threshold, a target reference content acquisition strategy suitable for answering the question is determined based on the vector retrieval result.

5. The method according to claim 4, characterized in that, The vector library includes a first sub-vector library and a second sub-vector library. The first sub-vector library includes text embedding vectors of each content fragment in the question reference content. The second sub-vector library includes text embedding vectors of each of the referenced public domain contents. The vector retrieval results include a first sub-retrieval result and a second sub-retrieval result. The first sub-retrieval result is obtained by retrieving the embedding representation vector of the question content from the first sub-vector library. The second sub-retrieval result is obtained by retrieving the embedding representation vector of the question content from the second sub-vector library. The question types include a first question type, a second question type, a third question type, and a fourth question type; The step of determining a target reference content acquisition strategy suitable for answering the question based on the vector retrieval results includes: If the first sub-retrieval result indicates that a target content fragment is retrieved in the first sub-vector library, it is determined that the question content belongs to the second question type, and the second reference content acquisition strategy corresponding to the second question type is used as the target reference content acquisition strategy applicable to answering the question content; the target content fragment refers to a content fragment in the first sub-vector library whose similarity to the question content exceeds a first similarity threshold. If the first sub-search result indicates that no target content fragment was found in the first sub-vector library, and the second sub-search result indicates that target public domain content was found in the second sub-vector library, it is determined that the question content belongs to the third question type. The third reference content acquisition strategy corresponding to the third question type is used as the target reference content acquisition strategy applicable to answering the question content. The target public domain content refers to the reference public domain content in the second sub-vector library whose similarity to the question content exceeds the second similarity threshold. If the first sub-search result indicates that no target content fragment was found in the first sub-vector library, and the second sub-search result indicates that no target public domain content was found in the second sub-vector library, the question content is determined to belong to the fourth question type, and the fourth reference content acquisition strategy corresponding to the fourth question type is used as the target reference content acquisition strategy applicable to answering the question content.

6. The method according to claim 5, characterized in that, The target reference content acquisition strategy is the second reference content acquisition strategy; The step of obtaining the target reference context for answering the question according to the target reference content acquisition strategy includes: The target content fragment is used as the target reference context for answering the question.

7. The method according to claim 5, characterized in that, The target reference content acquisition strategy is a third reference content acquisition strategy; The step of obtaining the target reference context for answering the question according to the target reference content acquisition strategy includes: The target public domain content is used as the target reference context for answering the question.

8. The method according to claim 5, characterized in that, The target reference content acquisition strategy is the fourth reference content acquisition strategy; The step of obtaining the target reference context for answering the question according to the target reference content acquisition strategy includes: Based on the embedded representation vector of the question content, vector retrieval is performed in the expert knowledge base to obtain target expert knowledge content whose similarity to the question content exceeds a third similarity threshold; the target expert knowledge content includes reference question content and multiple thought chain steps for answering the reference question content; Based on the reference question content and multiple thought chain steps for answering the reference question content, a thought chain is generated for the question content to obtain multiple thought chain steps for the question content. Based on the multiple thought chain steps of the question content, generate sub-response content under each thought chain step of the question content; The multiple thought chain steps of the question and the sub-response content under the corresponding thought chain steps are used as the target reference context for answering the question.

9. The method according to claim 8, characterized in that, The step of generating sub-response content under each thought chain step of the question content according to multiple thought chain steps of the question content includes: The first thought chain step of the question is input into the large language model agent, which then generates the sub-response content under the first thought chain step of the question. Initialize i to 2; The i-th thought process step of the question, each thought chain step of the question before the i-th thought process step, and the corresponding sub-response content are input into the large language model agent, and the large language model agent generates the sub-response content under the i-th thought chain step of the question. If i is less than N, increment i by 1 and return to the step of inputting the i-th thought step of the question content, each thought chain step of the question content before the i-th thought step, and the corresponding sub-response content into the large language model agent, and having the large language model agent generate the sub-response content under the i-th thought chain step of the question content, until i = N; N is the total number of thought chain steps of the question content.

10. The method according to any one of claims 1 to 9, characterized in that, The method further includes: Based on the embedding representation vector of the question content, a search is performed in the third vector library to obtain the third sub-search result. The third vector library includes the text embedding vectors of the historical question and answer content of each round in the conversation in which the question content is located. If the third sub-retrieval result indicates that a target historical question-and-answer content with a similarity exceeding the fourth similarity threshold has been retrieved, the target historical question-and-answer content will be used as auxiliary reference content for the large language model to answer the question.

11. The method according to claim 1, characterized in that, The process of classifying the question content into question types to obtain question type classification results includes: The question content is classified into question types using a question type classification model to obtain the question type classification results; The training process of the problem type classification model includes: Obtain sample question content and sample tags, wherein the sample tags are used to indicate the reference question type to which the question content belongs; The question type classification model is used to classify the question content of the sample to obtain the predicted question type of the question content; Calculate the prediction loss based on the reference problem type and the prediction problem type; The parameters of the problem type classification model are adjusted based on the predicted loss until the training termination condition is met.

12. A response generation device, characterized in that, include: The first acquisition module is used to acquire the target input content; The target input content includes at least the question content; The classification module is used to classify the question content into question types and obtain question type classification results; wherein, different question types correspond to different reference content acquisition strategies, and different reference content acquisition strategies indicate that reference context used to assist in generating answers is obtained from different sources; The strategy determination module is used to determine a target reference content acquisition strategy suitable for answering the question based on the question type identification result. The second acquisition module is used to acquire the target reference context for answering the question content in accordance with the target reference content acquisition strategy. The response generation module is used to call the large language model to generate a response based on the question content and the target reference context, thereby obtaining the response content to the question content.

13. An electronic device, characterized in that, include: processor; A memory storing computer instructions that, when executed by the processor, implement the method as described in any one of claims 1-11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method as described in any one of claims 1-11.

15. A computer program product comprising computer instructions, characterized in that, When executed by a processor, the computer instructions implement the method described in any one of claims 1-11.