Question and answer method and device, electronic equipment and storage medium
By using reinforcement learning on a large language model, a second large language model suitable for answering complex questions is generated, which solves the problem that intelligent assistants cannot handle complex questions in enterprise office scenarios, realizes flexible and accurate personalized answers, and improves the scalability of the question-answering system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2026-04-28
AI Technical Summary
Existing intelligent assistants are unable to effectively handle the reasoning and personalized needs of complex problems in enterprise office scenarios, and can only meet the simple question-answering needs with a single intent.
By leveraging a large language model for reinforcement learning, a second large language model suitable for solving complex problems is generated by identifying target example texts from an example text library, enabling reasoning decomposition and personalized solutions to problems.
It improves the flexibility and accuracy of answering complex questions, reduces the implementation cost of complex question decomposition patterns, and enhances the scalability and flexibility of the question-answering system.
Smart Images

Figure CN116955561B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and in particular to the fields of natural language processing, large language models, and smart office technology. Background Technology
[0002] In intelligent enterprise office scenarios, enterprises can build intelligent assistants that allow users to ask questions or issue task commands through natural language interaction. The intelligent assistants can then answer user questions or execute user command tasks through natural language understanding. Summary of the Invention
[0003] This disclosure provides a question-and-answer method, apparatus, electronic device, and storage medium.
[0004] According to one aspect of this disclosure, a question-answering method is provided, comprising: responding to a question-answering request, determining a plurality of first target example texts from a plurality of example texts included in an example text library based on question text included in the question-answering request; performing reinforcement learning on a first large language model using the plurality of first target example texts to obtain a second large language model; and inputting the question text into the second large language model to obtain an answer text for the question text.
[0005] According to another aspect of this disclosure, a question-answering apparatus is provided, comprising: a first determining module, configured to, in response to a question-answering request, determine a plurality of first target example texts from a plurality of example texts included in an example text library based on question text included in the question-answering request; a first processing module, configured to perform reinforcement learning on a first large language model using the plurality of first target example texts to obtain a second large language model; and an answering module, configured to input the question text into the second large language model to obtain an answer text for the question text.
[0006] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method as described above.
[0007] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform the method described above.
[0008] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described above.
[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0010] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0011] Figure 1 An exemplary system architecture for applying question-answering methods and apparatus according to embodiments of this disclosure is illustrated.
[0012] Figure 2 A flowchart illustrating a question-and-answer method according to an embodiment of the present disclosure is shown schematically.
[0013] Figure 3 A schematic diagram of a serial decomposition process according to an embodiment of the present disclosure is shown.
[0014] Figure 4 The illustration shows a schematic diagram of a process for generating answer text using a second language model according to an embodiment of the present disclosure.
[0015] Figure 5 The illustration shows a schematic diagram of the implementation flow of a question-and-answer method according to another embodiment of the present disclosure.
[0016] Figure 6 A block diagram of a question-and-answer device according to an embodiment of the present disclosure is shown schematically.
[0017] Figure 7 A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0018] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0019] In traditional enterprise office scenarios, users typically need to manually search for answers or complete tasks on various platforms when faced with different problems or needs. To improve user efficiency, related technologies have proposed intelligent office solutions based on smart assistants. By building smart assistants, enterprises can enable users to ask questions or issue task commands through natural language interaction. The smart assistant can then answer user questions or execute user commands through natural language understanding. However, smart assistants in these technologies usually rely on rule or intent classification models to identify user intent before retrieving answers or executing tasks. This approach can only satisfy simple questions with single intents and cannot meet the reasoning and personalized needs of complex problems.
[0020] In view of this, embodiments of the present disclosure provide a question-answering method, apparatus, electronic device, and storage medium that can utilize a Large Language Model (LLM) as a foundation and, through thought chain technology, guide the large model to reason and decompose a user's complex question before answering it. Specifically, the question-answering method includes: responding to a question-answering request, determining multiple first target example texts from multiple example texts included in an example text library based on the question text included in the question-answering request; performing reinforcement learning on a first large language model using the multiple first target example texts to obtain a second large language model; and inputting the question text into the second large language model to obtain an answer text for the question text.
[0021] Figure 1 An exemplary system architecture for applying question-answering methods and apparatus according to embodiments of this disclosure is illustrated.
[0022] It is important to note that Figure 1 The examples shown are merely examples of system architectures that can be applied to embodiments of this disclosure, intended to help those skilled in the art understand the technical content of this disclosure. However, they do not imply that embodiments of this disclosure cannot be used in other devices, systems, environments, or scenarios. For example, in another embodiment, an exemplary system architecture to which the question-answering method and apparatus can be applied may include a terminal device, but the terminal device may implement the question-answering method and apparatus provided by embodiments of this disclosure without interacting with a server.
[0023] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the terminal devices 101, 102, and 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0024] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc.
[0025] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients, and / or social media platforms (for example only). The communication client applications installed on terminal devices 101, 102, and 103 can provide text boxes where users can enter questions they need answered.
[0026] Server 105 can be a server providing various services, such as a backend management server (for example only) that supports the content browsed by users using terminal devices 101, 102, and 103. The backend management server can analyze and process received user requests and other data, and feed back the processing results (such as web pages, information, or data obtained or generated based on user requests) to the terminal devices. Server 105 can be configured with a large language model, or server 105 can have a large language model calling interface.
[0027] It should be noted that the question-and-answer method provided in this embodiment can generally be executed by terminal devices 101, 102, or 103. Accordingly, the question-and-answer device provided in this embodiment can also be disposed in terminal devices 101, 102, or 103.
[0028] Alternatively, the question-and-answer method provided in this embodiment can generally be executed by server 105. Correspondingly, the question-and-answer device provided in this embodiment can generally be located in server 105. The question-and-answer method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the question-and-answer device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.
[0029] For example, a user can enter a question text in a text box provided by a communication client application installed on terminal devices 101, 102, and 103. Terminal devices 101, 102, and 103 can then send the question text to server 105 via network 104. Server 105 can invoke a large language model to decompose and solve the received question text to obtain the answer text. Server 105 can then return the answer text to terminal devices 101, 102, and 103 so that terminal devices 101, 102, and 103 can display the answer text on their displays.
[0030] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0031] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of user personal information comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and there is no violation of public order and good morals.
[0032] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.
[0033] Figure 2 A flowchart illustrating a question-and-answer method according to an embodiment of the present disclosure is shown schematically.
[0034] like Figure 2 As shown, the method includes operations S210 to S230.
[0035] In operation S210, in response to a question answering request, based on the question text included in the question answering request, a plurality of first target example texts are determined from a plurality of example texts included in the example text library.
[0036] In operation S220, reinforcement learning is performed on the first large language model using multiple first target example texts to obtain the second large language model.
[0037] In operation S230, the question text is input into the second language model to obtain the answer text for the question text.
[0038] According to embodiments of this disclosure, a question-answering request can be a request message sent by a front-end device based on any communication protocol. Such a communication protocol could be, for example, HTTP (Hypertext Transfer Protocol), FTP (File Transfer Protocol), etc. The question-answering request can include a request line, a request header, and a request body. The request line can include information such as the request method, the communication protocol used, and its version. The request header can include information about the front-end device, such as its device identifier. The request body can include data sent by the front-end device, such as the text of the question to be answered.
[0039] According to embodiments of this disclosure, the example text library may include multiple example texts, each of which can be represented as a text pair. That is, each example text may include an example question text and an example reasoning result text, where the example reasoning result text may indicate whether the question text needs to be decomposed. For example, the example question text may be represented as "What is X?", and the corresponding example reasoning result text may be represented as "No decomposition required". Furthermore, for example texts representing complex questions, the example text may also include a reasoning process for the example question text. For example, the example question text may be represented as "Functional differences between item A and item B", and the corresponding example reasoning result text may be represented as "Parallel decomposition required". The corresponding reasoning process may include the sub-questions "What is the function of item A?" and "What is the function of item B?" obtained by parallel decomposing the example question text. The methods for determining multiple first target example texts from multiple example texts may include, but are not limited to, random selection, semantic matching, intent matching, etc., and are not limited thereto.
[0040] According to embodiments of this disclosure, the sources of the multiple sample texts included in the sample text library are not limited herein. For example, they may include questions and breakdown solutions defined by developers, or questions and breakdown solutions recorded in the databases of various business systems during the business implementation process, and are not limited herein.
[0041] According to embodiments of this disclosure, reinforcement learning of a first large language model using multiple first target example texts can leverage the small-sample learning capability of the large language model to guide it in learning the reasoning decomposition methods for example question texts shown in the first target example texts, thereby obtaining a second large language model suitable for completing question reasoning and answering tasks. The model parameters of the generated second large language model can remain unchanged compared to the first large language model.
[0042] According to embodiments of this disclosure, after inputting the question text into the second language model, the second language model can process the question text by referring to the question reasoning and answering method for the example question text in the first target example text, so as to obtain the answer text for the question text.
[0043] According to embodiments of this disclosure, before answering a question text, a first large language model can be used to perform reinforcement learning on a first example text related to the question text, so that the resulting second large language model can be suitable for reasoning and answering the question text. This can effectively improve the stability and accuracy of the large language model in complex question-answering scenarios, fully utilize the reasoning ability of the large language model, reduce the need for manual configuration of complex question decomposition pattern rules, and improve the flexibility and scalability of complex question answering.
[0044] The following is for reference. Figures 3-5 In conjunction with specific embodiments, Figure 2 The method shown will be further explained.
[0045] According to embodiments of this disclosure, multiple first target example texts can be determined from multiple example texts through semantic matching. Specifically, the question text can be semantically parsed to obtain the semantic information of the question text; the semantic information of the question text can be matched with the semantic information of the example question texts included in each of the multiple example texts to obtain multiple matching results; and based on the multiple matching results, multiple first target example texts can be determined from the multiple example texts.
[0046] According to embodiments of this disclosure, the semantic information of the question text can be its word embedding features. The question text can be segmented to obtain multiple words, and then word vectors can be embedded into each word to obtain an embedding vector for each word. The embedding vectors of multiple words can be concatenated to obtain the word embedding features of the question text. Correspondingly, the semantic information of the example question text included in the example text can be the word embedding features of that example question text.
[0047] According to embodiments of this disclosure, the semantic information of the question text can also be its encoded features. The question text can be directly encoded using an encoder to obtain its encoded features.
[0048] According to embodiments of this disclosure, when matching the semantic information of the question text with the semantic information of the example question text, a similarity index can be calculated between the semantic information of the question text and the semantic information of the example question text. The degree of matching between the semantic information of the question text and the semantic information of the example question text can be determined based on this similarity index. This similarity index may include, but is not limited to, Euclidean distance, Mahalanobis distance, Chebyshev distance, cosine similarity, correlation coefficient, root mean square error, etc., and is not limited thereto.
[0049] According to an embodiment of this disclosure, as an optional implementation, when matching question text and example text, the semantic information of the question text and the semantic information of the example answer text included in the example text can also be used to match in order to determine multiple first target example texts from multiple example texts.
[0050] According to embodiments of this disclosure, the matching result may include matching results indicating a match and matching results indicating a non-match. When determining multiple first target example texts from multiple example texts based on the matching result, multiple first target example texts may be determined by random selection from the multiple example texts whose matching results indicate a match. Alternatively, the matching result may be a numerical value determined based on the similarity index. When determining multiple first target example texts from multiple example texts based on the matching result, the multiple example texts may be sorted according to the numerical values of their respective matching results, and the multiple example texts with the highest matching result values may be selected as the multiple first target example texts.
[0051] According to embodiments of this disclosure, when multiple example texts can be divided into multiple categories, one or more first target example texts can be selected from the example texts of each category. For example, the multiple example texts included in the example text library can be classified according to the question type to which the example question texts included in each of the multiple example texts belong, to obtain multiple example text sets. Each example text set can correspond to a question type, and each example text set can include multiple example texts. When determining multiple first target example texts from multiple example texts based on matching results, at least one first target example text can be determined from the multiple example texts associated with each question type, i.e., the example text set associated with each question type, based on the multiple matching results and the question type to which each of the multiple example texts belongs, thus obtaining multiple first target example texts.
[0052] According to embodiments of this disclosure, as an optional implementation, other features or information of the question text can also be used for matching with the example text. For example, an intent recognition model can be used to perform intent recognition on the question text to obtain intent recognition information of the question text. Then, the intent recognition information of the question text can be used to match the intent recognition information of multiple example texts to obtain multiple matching results. Based on the multiple matching results, multiple first target example texts can be determined from the multiple example texts.
[0053] According to embodiments of this disclosure, after determining multiple first target example texts, reinforcement learning is performed on a first large language model using the multiple first target example texts to obtain a second large language model, which may include the following operations:
[0054] Based on multiple first-target example texts, a prompt instance is generated; and the prompt instance is input into the first large language model to perform reinforcement learning on the first large language model to obtain the second large language model.
[0055] According to embodiments of this disclosure, for example, multiple first target example texts may include text A, text B, and text C. Text A may be represented as "Question: What is X? Decomposition: No decomposition required." Text B may be represented as "Question: Functional differences between item A and item B. Decomposition: Parallel decomposition required. Sub-questions: What is the function of item A; what is the function of item B?" Text C may be represented as "Question: Does item A have the function of item B? Decomposition: Serial decomposition required. Sub-question: What is the function of item B? Sub-question answer: Item B has function C. Sub-question: Does item A have function C? Sub-question answer: Item A does not have function C. Sub-question: End." The instruction text and texts A, B, and C can be concatenated, and the concatenated text can be formatted to obtain a prompt instance suitable for input into the first major language model. The instruction text may be text indicating a learning purpose; for example, the instruction text may be represented as "You are an internal enterprise intelligent assistant. Your task is to infer whether employee questions need to be decomposed and how to decompose and answer them based on employee questions. Please complete the dialogue according to the example."
[0056] According to embodiments of this disclosure, the generated prompt instance can be input into a first large language model to achieve reinforcement learning of the first large language model and obtain a second large language model.
[0057] According to embodiments of this disclosure, inputting the question text into a second language model to obtain the answer text for the question text may include the following operations:
[0058] The question text is input into the second language model to obtain the first output information; and the question text is processed based on the question type information included in the first output information to obtain the answer text for the question text.
[0059] According to embodiments of this disclosure, problem type information can be used to represent the problem type of the problem text. Problem types can include standard problem types, serial problem types, and parallel problem types. Standard problem types can be represented as problem types that do not require problem decomposition. Serial problem types can be represented as problem types that require serial decomposition. Parallel problem types can be represented as problem types that require parallel decomposition.
[0060] According to embodiments of this disclosure, similar in structure to the example text, the first output information output by the second language model may include fields from the example text other than the "question" field. Specifically, the first output information may include at least a "decomposition" field and a "sub-question" field. If the question type of the question text is a standard question type, the content of the "sub-question" field may be empty or may be the original question text.
[0061] According to embodiments of this disclosure, when the question type information indicates that the question text has a standard question type, processing the question text based on the question type information included in the first output information to obtain the answer text for the question text may include the following operations:
[0062] The question text is matched with intent to obtain the answer text.
[0063] According to embodiments of this disclosure, intent matching of question text can be performed using an intent recognition model to identify the intent of the question text and obtain its intent information. This intent recognition model can be configured with a QA (Question-Answer) text library. After obtaining the intent information of the question text, intent matching can be performed based on the QA text library by performing intent matching on either the question texts or the answer texts in the QA text library. After determining the text object that has been matched in the QA text library, the answer text of that text object can be taken as the answer text for that question text.
[0064] According to embodiments of this disclosure, when the question type information indicates that the question text is a serial question type, sub-questions can be generated and answered iteratively to obtain the answer text. Specifically, processing the question text based on the question type information included in the first output information to obtain the answer text for the question text can include the following operations:
[0065] Parse the first output information to obtain the first sub-question text; if the first sub-question text does not contain end marker information, perform intent matching on the first sub-question text to obtain the first sub-answer text for the first sub-question text; write the first sub-answer text into the initial answer text; and input the first sub-answer text into the second language model to obtain new first output information.
[0066] According to embodiments of this disclosure, the first output information may include only one decomposed sub-problem. When the second language model decomposes a question text of a serial question type, other sub-problems may be unable to be output due to incomplete components. For example, for the question text "Does item A have the function of item B?", the second language model, guided by the example text, can decompose the question text into the first sub-problem text "What is the function of item B?". However, another first sub-problem text that should exist, "Does item A have this function?", lacks one of the elements of item B's function. Therefore, this first sub-problem cannot be output by the second language model at this time.
[0067] According to embodiments of this disclosure, intent matching of the first sub-question text can be achieved using the same or similar schemes as intent matching of the question text to obtain the answer text, which will not be elaborated here.
[0068] According to embodiments of this disclosure, the end-of-line identifier information can be represented as a piece of text, for example, the text represented by the end-of-line identifier information can be "end". Alternatively, the end-of-line identifier information can be represented as a string, for example, the string represented by the end-of-line identifier information can be "end", etc. The form of the end-of-line identifier information is not limited here.
[0069] According to embodiments of this disclosure, if it is determined that the first sub-problem text contains end identifier information, it can be determined that all sub-problems that should exist have been output, that is, the serial splitting process of the problem text has ended.
[0070] According to embodiments of this disclosure, if it is determined that the first sub-question text does not contain end marker information, it can be determined that the original question text may also include decomposable sub-questions. In this case, the first sub-answer text for the previous first sub-question text can be input into the second large language model so that the second large language model can extract element information from the first sub-answer text and supplement the decomposable sub-question with the element information, and output new first output information, which may include the new first sub-question text.
[0071] Figure 3 A schematic diagram of a serial decomposition process according to an embodiment of the present disclosure is shown.
[0072] like Figure 3 As shown, the serial decomposition process may include operations S301 to S306.
[0073] In operation S301, the first output information is parsed to obtain the text of the first sub-problem.
[0074] In operation S302, determine whether the first sub-problem text contains end-of-problem marker information. If it is determined that the first sub-problem text contains end-of-problem marker information, proceed to operation S303. If it is determined that the first sub-problem text does not contain end-of-problem marker information, proceed to operation S306.
[0075] In operation S303, intent matching is performed on the first sub-question text to obtain the first sub-answer text for the first sub-question text.
[0076] In operation S304, the first sub-answer text is written into the initial answer text.
[0077] In operation S305, the first sub-answer text is input into the second large language model to obtain new first output information. After completing operation S305, based on the new first output information, the process returns to execute operation S301.
[0078] In operation S306, the serial decomposition of the problem text is completed.
[0079] According to the embodiments of this disclosure, if it is determined that the first sub-question text contains end identifier information, it can be determined that all sub-questions that should exist have been output and answered, and the first sub-answer texts of all sub-questions have been written into the initial answer text. At this time, the initial answer text can be input into the second language model, and the second language model can be used to summarize the multiple first sub-answer texts in the initial answer text to obtain the answer text.
[0080] According to embodiments of this disclosure, when the question type information indicates that the question text represents a parallel question type, the second large language model can generate all sub-questions at once. Specifically, processing the question text based on the question type information included in the first output information to obtain the answer text for the question text can include the following operations:
[0081] Parse the first output information to obtain multiple second sub-question texts; perform intent matching on each of the multiple second sub-question texts to obtain multiple second sub-answer texts for each of the multiple second sub-question texts; and input the multiple second sub-answer texts into the second large language model to obtain the answer text.
[0082] According to embodiments of this disclosure, intent matching for multiple second sub-question texts can be achieved using the same or similar schemes when performing intent matching on the question texts to obtain the answer texts, which will not be elaborated further here.
[0083] According to embodiments of this disclosure, a second major language model can be used to summarize multiple second sub-answer texts to obtain the answer text.
[0084] According to the embodiments of this disclosure, the serial and parallel decomposition methods for complex problems provided by the embodiments of this disclosure can eliminate the need to traverse and set decomposition pattern rules for complex problems, thereby effectively reducing the implementation cost of complex problem decomposition and improving the flexibility and scalability of question-answering system applications.
[0085] Figure 4 The illustration shows a schematic diagram of a process for generating answer text using a second language model according to an embodiment of the present disclosure.
[0086] like Figure 4 As shown, the question text 401 can be input into the second large language model 402. The second large language model 402 can determine the question type of the question text 401, classifying it as a question that does not need to be decomposed, a question that needs to be decomposed sequentially, or a question that needs to be decomposed in parallel.
[0087] When it is determined that the question text 401 is a question that does not need to be decomposed, intent matching can be performed directly on the question text 401 to obtain the answer text 403 for the question text 401.
[0088] When the question text 401 is determined to be a question requiring serial decomposition, the second large language model 402 can output a first sub-question text 404 with complete elements. It can be determined whether the first sub-question text 404 is "ending". If it is determined that the first sub-question text 404 is not "ending", intent matching can be performed on the first sub-question text 404 to obtain the first sub-answer text 405 for the first sub-question text 404. The second large language model 402 can then continue processing the first sub-answer text 405 to extract element information and generate new first sub-question texts 404 based on this element information. The first sub-answer text 405 for each first sub-question text 404 can be recorded in the initial answer text 406. If it is determined that the first sub-question text 404 represents "ending", the initial answer text 406 can be input into the second large language model 402 to obtain the answer text 403.
[0089] When the question text 401 is determined to be a question requiring parallel decomposition, the second large language model 402 can output multiple second sub-question texts 407. Intent matching can be performed on each of the multiple second sub-question texts 407 to obtain multiple second sub-answer texts 408. These multiple second sub-answer texts 408 can be input into the second large language model 402 to obtain the answer text 403.
[0090] According to embodiments of this disclosure, optionally, the intent matching of the question text, the first question subtext, or the second question subtext as described above can also be implemented by invoking a downstream intent recognition system of the current system. Specifically, taking the question text as an example, the question text can be sent to the downstream intent recognition system, which can use the intent recognition model configured in the system to perform intent matching on the question text to obtain the answer text, which will not be elaborated further here. The downstream intent recognition system can feed back the answer text to the current system so that the current system can obtain the answer text from the feedback information of the downstream intent recognition system.
[0091] According to embodiments of this disclosure, optionally, the intent matching of the question text, the first question subtext, or the second question subtext as described above to obtain the corresponding answer text can be replaced by semantic matching of the question text, the first question subtext, or the second question subtext to obtain the corresponding answer text. When performing semantic matching, a semantic recognition model can be used, a QA text library can be configured to complete the semantic matching, or a downstream semantic recognition system can be used to complete the semantic matching; no limitation is made here.
[0092] According to embodiments of this disclosure, due to the diversity of user questions and their rich expressions, the effectiveness of reinforcement learning through prompt examples is unstable. Therefore, as an optional implementation, more sample data can be used to fine-tune the large language model, making the inference decomposition of the large language model more stable and accurate. Specifically, multiple second target sample texts can be determined from multiple sample texts; and based on the multiple second target sample texts, the initial large language model can be fine-tuned to obtain a first large language model.
[0093] According to embodiments of this disclosure, similar to the selection of multiple first target example texts, multiple second target example texts may also include example texts belonging to various problem types, which will not be elaborated here.
[0094] According to embodiments of this disclosure, the model fine-tuning process can be implemented using various large model fine-tuning tools, including Open Delta, MindSpore PET, etc., which are not limited thereto.
[0095] According to an embodiment of this disclosure, as an optional implementation, the process of generating the answer text can also be optimized using summary example text, which may include input text consisting of multiple example sub-answers for multiple example sub-questions, and output text representing the final answer.
[0096] Figure 5 The illustration shows a schematic diagram of the implementation flow of a question-and-answer method according to another embodiment of the present disclosure.
[0097] like Figure 5 As shown, after receiving the question text 501, reinforcement learning can be performed on the first large language model 503 using multiple first target example texts 502 to obtain the second large language model 504. Simultaneously, reinforcement learning can be performed on the first large language model 503 using multiple summary example texts 505 to obtain the third large language model 506. The obtained third large language model 506 is suitable for summarizing and generalizing multiple input texts to obtain the final output text.
[0098] The question text 501 can be input into the second large language model 504 to obtain the question type information 507 of the question text 501. If the question type information 507 indicates that no decomposition is needed, intent matching can be performed on the question text 501 to obtain the answer text 508. If the question type information 507 indicates that decomposition is needed, the second large language model 504 can obtain the sub-answer texts 509 of the multiple sub-question texts obtained from the decomposition of the question text 501. The multiple sub-answer texts 509 can be input into the third large language model 506 to obtain the answer text 508.
[0099] According to embodiments of this disclosure, specifically, when the question type information of the question text indicates that the question type of the question text is a serial question type, the third major language model can be used to process multiple first sub-answer texts included in the initial answer text to obtain the answer text for the question text. Correspondingly, when the question type information of the question text indicates that the question type of the question text is a parallel question type, the third major language model can be used to process multiple second sub-answer texts to obtain the answer text for the question text.
[0100] Figure 6 A block diagram of a question-and-answer device according to an embodiment of the present disclosure is shown schematically.
[0101] like Figure 6 As shown, the question-and-answer device 600 may include a first determining module 610, a first processing module 620, and an answering module 630.
[0102] The first determining module 610 is configured to, in response to a question answering request, determine a plurality of first target example texts from a plurality of example texts included in an example text library based on the question text included in the question answering request.
[0103] The first processing module 620 is used to perform reinforcement learning on the first large language model using multiple first target example texts to obtain the second large language model.
[0104] The answer module 630 is used to input the question text into the second language model and obtain the answer text for the question text.
[0105] According to embodiments of this disclosure, the solution module 630 includes a first solution unit and a second solution unit.
[0106] The first solution unit is used to input the question text into the second large language model and obtain the first output information.
[0107] The second answering unit is used to process the question text based on the question type information included in the first output information to obtain the answer text for the question text.
[0108] According to embodiments of this disclosure, the second solution unit includes a first solution subunit, a second solution subunit, a third solution subunit, and a fourth solution subunit.
[0109] The first solution subunit is used to parse the first output information and obtain the first sub-problem text when the problem type information indicates that the problem text is a serial problem type.
[0110] The second solution subunit is used to perform intent matching on the first sub-question text when it is determined that the first sub-question text does not contain end marker information, so as to obtain the first sub-answer text for the first sub-question text.
[0111] The third solution sub-unit is used to write the first sub-answer text into the initial answer text.
[0112] The fourth solution sub-unit is used to input the first sub-answer text into the second large language model to obtain new first output information.
[0113] According to embodiments of this disclosure, the second solution unit further includes a fifth solution subunit.
[0114] The fifth solution subunit is used to input the initial answer text into the second large language model to obtain the answer text, provided that the first sub-question text contains end marker information.
[0115] According to embodiments of this disclosure, the second solution unit includes a sixth solution subunit, a seventh solution subunit, and an eighth solution subunit.
[0116] The sixth solution subunit is used to parse the first output information and obtain multiple second sub-problem texts when the problem type of the problem text represented by the problem type information is a parallel problem type.
[0117] The seventh solution subunit is used to perform intent matching on multiple second sub-question texts to obtain multiple second sub-answer texts for each of the multiple second sub-question texts.
[0118] The eighth solution sub-unit is used to input multiple second sub-answer texts into the second large language model to obtain the answer text.
[0119] According to embodiments of this disclosure, the second solution unit includes a ninth solution subunit.
[0120] The ninth solution subunit is used to perform intent matching on the question text to obtain the answer text when the question type information indicates that the question text is a standard question type.
[0121] According to embodiments of this disclosure, the first determining module 610 includes a first determining unit, a second determining unit, and a third determining unit.
[0122] The first determining unit is used to perform semantic parsing on the question text to obtain the semantic information of the question text.
[0123] The second determining unit is used to match the semantic information of the question text with the semantic information of the example question text included in each of the multiple example texts, and obtain multiple matching results.
[0124] The third determining unit is used to determine at least one first target example text from multiple example texts related to each question type based on multiple matching results and the question types to which each example text belongs, thereby obtaining multiple first target example texts.
[0125] According to embodiments of this disclosure, the first processing module 620 includes a first processing unit and a second processing unit.
[0126] The first processing unit is used to generate prompt instances based on multiple first target example texts.
[0127] The second processing unit is used to input the prompt instance into the first language model, perform reinforcement learning on the first language model, and obtain the second language model.
[0128] According to embodiments of this disclosure, the question-answering device 600 further includes a second determining module and a second processing module.
[0129] The second determination module is used to determine multiple second target example texts from multiple example texts.
[0130] The second processing module is used to fine-tune the initial large language model based on multiple second target example texts to obtain the first large language model.
[0131] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0132] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method described above.
[0133] According to embodiments of the present disclosure, a non-transitory computer-readable storage medium stores computer instructions, wherein the computer instructions are used to cause a computer to perform the method described above.
[0134] According to an embodiment of this disclosure, a computer program product includes a computer program that, when executed by a processor, implements the method described above.
[0135] Figure 7 A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0136] like Figure 7 As shown, device 700 includes a computing unit 701, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 702 or a computer program loaded from storage unit 708 into random access memory (RAM) 703. RAM 703 may also store various programs and data required for the operation of device 700. The computing unit 701, ROM 702, and RAM 703 are interconnected via bus 704. Input / output (I / O) interface 705 is also connected to bus 704.
[0137] Multiple components in device 700 are connected to input / output (I / O) interface 705, including: input unit 706, such as keyboard, mouse, etc.; output unit 707, such as various types of monitors, speakers, etc.; storage unit 708, such as disk, optical disk, etc.; and communication unit 709, such as network card, modem, wireless transceiver, etc. Communication unit 709 allows device 700 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0138] The computing unit 701 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as question-and-answer methods. For example, in some embodiments, the question-and-answer method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the question-and-answer method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform question-and-answer methods by any other suitable means (e.g., by means of firmware).
[0139] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0140] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0141] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0142] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0143] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0144] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, distributed system servers, or servers incorporating blockchain technology.
[0145] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0146] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A question-and-answer method, comprising: In response to a question answering request, based on the question text included in the question answering request, a plurality of first target example texts are determined from a plurality of example texts included in the example text library. The example texts include example question texts and example reasoning result texts, and the example reasoning result texts represent whether the example question texts need to be decomposed. The first language model is reinforced using the multiple first target example texts to obtain the second language model; Input the question text into the second large language model to obtain the first output information; as well as The question text is processed based on the question type information included in the first output information to obtain the answer text for the question text. The question type information indicates the question type, including standard question type, serial question type and parallel question type.
2. The method according to claim 1, wherein, The step of processing the question text based on the question type information included in the first output information to obtain the answer text for the question text includes: If the question type information indicates that the question text is a serial question type, the first output information is parsed to obtain the first sub-question text; If it is determined that the first sub-question text does not contain end marker information, intent matching is performed on the first sub-question text to obtain the first sub-answer text for the first sub-question text; Write the first sub-answer text into the initial answer text; and Input the first sub-answer text into the second large language model to obtain the new first output information.
3. The method according to claim 2, further comprising: If it is determined that the first sub-question text contains the end identifier information, the initial answer text is input into the second large language model to obtain the answer text.
4. The method according to claim 1, wherein, The step of processing the question text based on the question type information included in the first output information to obtain the answer text for the question text includes: If the question type information indicates that the question text is a parallel question type, the first output information is parsed to obtain multiple second sub-question texts; Intent matching is performed on each of the plurality of second sub-question texts to obtain a plurality of second sub-answer texts for each of the plurality of second sub-question texts; and The multiple second sub-answer texts are input into the second large language model to obtain the answer text.
5. The method according to claim 1, wherein, The step of processing the question text based on the question type information included in the first output information to obtain the answer text for the question text includes: If the question type information indicates that the question text is a standard question type, then intent matching is performed on the question text to obtain the answer text.
6. The method according to claim 1, wherein, Based on the question text included in the question-answering request, multiple first target example texts are determined from multiple example texts included in the example text library, including: Semantic parsing is performed on the question text to obtain its semantic information; The semantic information of the question text is matched with the semantic information of the example question text included in each of the plurality of example texts, resulting in multiple matching results; and Based on the multiple matching results and the question types to which the multiple example texts belong, at least one first target example text is determined from the multiple example texts associated with each question type, thus obtaining the multiple first target example texts.
7. The method according to claim 1, wherein, The process of using the multiple first target example texts to perform reinforcement learning on the first large language model to obtain the second large language model includes: Based on the multiple first target example texts, generate prompt instances; and The prompt instance is input into the first large language model, and reinforcement learning is performed on the first large language model to obtain the second large language model.
8. The method according to claim 1, further comprising: From the plurality of example texts, determine a plurality of second target example texts; as well as Based on the multiple second target example texts, the initial large language model is fine-tuned to obtain the first large language model.
9. A question-and-answer device, comprising: The first determining module is configured to, in response to a question answering request, determine a plurality of first target example texts from a plurality of example texts included in an example text library based on the question text included in the question answering request. The example texts include example question texts and example reasoning result texts, and the example reasoning result texts represent whether the example question texts need to be decomposed. The first processing module is used to perform reinforcement learning on the first large language model using the multiple first target example texts to obtain the second large language model. as well as The solution module includes: The first solution unit is used to input the question text into the second large language model to obtain the first output information; The second solution unit is used to process the question text based on the question type information included in the first output information to obtain the answer text for the question text. The question type information indicates the question type, including standard question type, serial question type and parallel question type.
10. The apparatus according to claim 9, wherein, The second solution unit includes a first solution subunit, a second solution subunit, a third solution subunit, and a fourth solution subunit; The first solution subunit is used to parse the first output information to obtain the first sub-problem text when the problem type information indicates that the problem text is a serial problem type; The second answer subunit is used to perform intent matching on the first sub-question text when it is determined that the first sub-question text does not contain end identifier information, so as to obtain the first sub-answer text for the first sub-question text. The third solution subunit is used to write the first sub-answer text into the initial answer text; as well as The fourth solution subunit is used to input the first sub-answer text into the second large language model to obtain new first output information.
11. The apparatus according to claim 10, wherein the second solution unit further comprises a fifth solution subunit; The fifth solution subunit is used to input the initial answer text into the second large language model to obtain the answer text when it is determined that the first sub-question text contains the end identifier information.
12. The apparatus according to claim 9, wherein, The second solution unit includes a sixth solution subunit, a seventh solution subunit, and an eighth solution subunit; The sixth solution subunit is used to parse the first output information to obtain multiple second sub-problem texts when the problem type information indicates that the problem text is a parallel problem type; The seventh answer subunit is used to perform intent matching on the plurality of second sub-question texts respectively, to obtain a plurality of second sub-answer texts for the plurality of second sub-question texts respectively; as well as The eighth solution subunit is used to input the multiple second sub-answer texts into the second large language model to obtain the answer text.
13. The apparatus according to claim 9, wherein, The second solution unit includes the ninth solution subunit; The ninth answer subunit is used to perform intent matching on the question text to obtain the answer text when the question type information indicates that the question text is a standard question type.
14. The apparatus according to claim 9, wherein, The first determining module includes a first determining unit, a second determining unit, and a third determining unit; The first determining unit is used to perform semantic parsing on the question text to obtain the semantic information of the question text; The second determining unit is used to match the semantic information of the question text with the semantic information of the example question text included in each of the plurality of example texts, so as to obtain a plurality of matching results; as well as The third determining unit is used to determine at least one first target example text from multiple example texts related to each of the multiple matching results and the question types to which the multiple example texts belong, thereby obtaining the multiple first target example texts.
15. The apparatus according to claim 9, wherein, The first processing module includes a first processing unit and a second processing unit; The first processing unit is configured to generate a prompt instance based on the plurality of first target example texts; as well as The second processing unit is used to input the prompt instance into the first large language model, perform reinforcement learning on the first large language model, and obtain the second large language model.
16. The apparatus according to claim 9, further comprising a second determining module and a second processing module; The second determining module is used to determine a plurality of second target example texts from the plurality of example texts; as well as The second processing module is used to fine-tune the initial large language model based on the multiple second target example texts to obtain the first large language model.
17. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
18. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-8.
19. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-8.
Citation Information
Patent Citations
Intelligent interaction method, device and equipment
CN112100355A
Intelligent customer service chat robot implementation method and system based on deep learning
CN112527972A