Question and answer processing method and device, medium and equipment

By encoding the Q&A samples and target questions, generating hidden state sequences, and using these state sequences to predict answer fragments, the problem of insufficient answer output in the existing Q&A processing methods is solved, and more accurate answer prediction and generation is achieved.

CN119599030AActive Publication Date: 2025-03-11PING AN TECH (SHENZHEN) CO LTD

Patent Information

Application Number
CN202411667234.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-11
Estimated Expiration
2044-11-20

AI Technical Summary

Technical Problem

The existing question-and-answer processing methods have the problem that the answer output is not accurate and reasonable enough.

Method used

By obtaining target questions and several Q&A samples, the pre-trained target question and answer models are used to encode the samples, generate hidden state sequences, and predict answer fragments based on these state sequences and the initial sentence sequences of questions, and finally generate accurate target answers.

Benefits of technology

It improves the accuracy of answer prediction, making the prediction results of answer fragments more accurate and reasonable, thereby generating more accurate target answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119599030A_ABST
    Figure CN119599030A_ABST
Patent Text Reader

Abstract

The invention relates to the field of finance and the technical field of natural language processing, and particularly discloses a question and answer processing method and device, a medium and equipment, and the method comprises the steps: obtaining a target question and a plurality of question and answer samples; on the basis of a target question and answer model obtained by pre-training, encoding each question and answer sample to obtain a first hidden state sequence corresponding to each question and answer sample; on the basis of the target question and answer model, encoding the target question to obtain a second hidden state sequence corresponding to the target question; based on the second hidden state sequence, each first hidden state sequence and an initial sentence sequence corresponding to the target question, predicting and obtaining each answer fragment by using the target question and answer model; and generating a target answer corresponding to the target question based on each answer segment and outputting the target answer. The answer prediction accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of finance and natural language processing technology, and in particular to a question-answering processing method, device, medium and equipment. Background Art

[0002] Currently, various language models are driving the widespread development of natural language processing (NLP) applications. By using language models, human-computer interaction, intelligent customer service, intelligent question-and-answer functions, and other functions can be realized in various business scenarios. For example, in the field of money technology, language models can be used to answer questions about financial products raised by users to help buyers better understand product-related information.

[0003] However, the existing question-answering processing methods have the problem that the answer output is not accurate and reasonable enough. Summary of the invention

[0004] In view of this, the present invention provides a question-answering processing method, device, medium and equipment, the main purpose of which is to solve the problem that the answer output of the current question-answering processing method is not accurate and reasonable enough.

[0005] To solve the above problems, the present application provides a question-answering processing method, including:

[0006] Obtain the target question and several question and answer samples;

[0007] Based on the pre-trained target question-answering model, encoding each of the question-answering samples is performed to obtain a first hidden state sequence corresponding to each of the question-answering samples;

[0008] Based on the target question-answering model, encoding the target question to obtain a second hidden state sequence corresponding to the target question;

[0009] Based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question, using the target question-answering model, predict and obtain each answer fragment;

[0010] A target answer corresponding to the target question is generated based on each of the answer fragments and outputted.

[0011] Optionally, encoding each of the question and answer samples based on the pre-trained target question and answer model to obtain a first hidden state sequence corresponding to each of the question and answer samples specifically includes:

[0012] Generate a sample sentence sequence corresponding to each question and answer sample based on each of the question and answer samples;

[0013] Based on the target encoder in the target question-answering model, each of the sample sentence sequences is encoded to obtain a first hidden state sequence corresponding to each of the sample sentence sequences.

[0014] Optionally, encoding the target question based on the target question-answering model to obtain a second hidden state sequence corresponding to the target question specifically includes:

[0015] Generate an initial sentence sequence corresponding to the target question based on the target question;

[0016] Based on the target encoder in the target question-answering model, the initial sentence sequence is encoded to obtain the second hidden state sequence.

[0017] Optionally, the predicting and obtaining each answer fragment based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question using the target question-answering model specifically includes:

[0018] Based on each of the first hidden state sequences and the second hidden state sequences, splicing is performed to obtain a spliced ​​target hidden state sequence;

[0019] Using the target decoder in the target question-answering model, perform answer prediction processing on the concatenated target hidden state sequence and the initial sentence sequence corresponding to the target question to obtain a first answer fragment;

[0020] When it is determined based on the first answer fragment that the predetermined prediction end condition is not met, the initial sentence sequence is updated based on the first answer fragment to obtain a current sentence sequence for predicting the next answer fragment, until the nth answer fragment obtained based on the prediction is determined to meet the predetermined prediction end condition, the answer fragment prediction is stopped, and each of the answer fragments is obtained, where n is a positive integer.

[0021] Optionally, using the target decoder in the target question-answering model to perform answer prediction processing on the concatenated target hidden state sequence and the initial sentence sequence corresponding to the target question to obtain a first answer fragment specifically includes:

[0022] Based on the encoding-decoding attention module in the target decoder, performing attention calculation on the target hidden state sequence to obtain a target calculation result;

[0023] Based on the target calculation result and the initial sentence sequence, a prediction module in the target encoder is used to perform a first answer fragment prediction process to obtain the first answer fragment.

[0024] Optionally, the updating process of the initial sentence sequence based on the first answer segment to obtain a current sentence sequence for predicting the next answer segment specifically includes:

[0025] Processing the first answer fragment to obtain a state vector corresponding to the first answer fragment;

[0026] Based on the state vector and the initial sentence sequence, a concatenation process is performed to obtain the current sentence sequence.

[0027] Optionally, the predetermined prediction end condition is a predetermined end identifier;

[0028] The nth answer fragment obtained based on the prediction determines that a predetermined prediction end condition is satisfied, specifically including:

[0029] Comparing the nth answer segment with the predetermined end identifier;

[0030] When it is determined that the nth answer segment is consistent with the predetermined end identifier, determining that a predetermined prediction end condition is satisfied;

[0031] When it is determined that the nth answer segment is inconsistent with the predetermined end identifier, it is determined that the predetermined prediction end condition is not satisfied.

[0032] In order to solve the above problems, the present application provides a question-answering processing device, comprising:

[0033] The acquisition module is used to obtain the target question and several question and answer samples;

[0034] A first processing module is used to encode each of the question and answer samples based on the target question and answer model obtained by pre-training, so as to obtain a first hidden state sequence corresponding to each of the question and answer samples;

[0035] A second processing module is used to encode the target question based on the target question-answering model to obtain a second hidden state sequence corresponding to the target question;

[0036] A prediction module, configured to predict and obtain answer fragments based on the second hidden state sequence, each of the first hidden state sequences, and an initial sentence sequence corresponding to the target question using the target question-answering model;

[0037] A generation module is used to generate and output a target answer corresponding to the target question based on each of the answer fragments.

[0038] To solve the above problems, the present application provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned question and answer processing methods are implemented.

[0039] To solve the above problems, the present application provides a computer device, which includes at least a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of any of the above-mentioned question and answer processing methods when executing the computer program in the memory.

[0040] A question-and-answer processing method, device, medium and equipment in the present application obtain a hidden state sequence by encoding question-and-answer samples and target questions. Subsequently, answer fragments can be predicted based on the hidden state sequence and the initial sentence sequence corresponding to the target question, so that the prediction results of each answer fragment are more accurate and reasonable, and then the target answer can be accurately generated based on each answer fragment, thereby improving the accuracy of answer prediction.

[0041] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0043] Figure 1 A flowchart of a question-and-answer processing method according to an embodiment of the present application;

[0044] Figure 2 This is a structural block diagram of a question-and-answer processing device according to another embodiment of the present application;

[0045] Figure 3 This is a structural block diagram of a computer device according to an embodiment of the present application;

[0046] Figure 4 This is a structural block diagram of another computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0047] Various aspects and features of the present application are described herein with reference to the accompanying drawings.

[0048] It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present application will occur to those skilled in the art.

[0049] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.

[0050] These and other characteristics of the present application will become apparent from the following description of a preferred form of embodiment given as a non-limiting example with reference to the accompanying drawings.

[0051] It should also be understood that although the present application has been described with reference to some specific examples, those skilled in the art will be able to readily implement many other equivalent forms of the present application.

[0052] The above and other aspects, features and advantages of the present application will become more apparent in view of the following detailed description when taken in conjunction with the accompanying drawings.

[0053] Specific embodiments of the present application are described hereinafter with reference to the accompanying drawings; however, it should be understood that the embodiments applied for are merely examples of the present application, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that obscure the present application. Therefore, the specific structural and functional details applied for herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present application in a variety of ways with substantially any suitable detailed structure.

[0054] This specification may use the phrases "in one embodiment," "in another embodiment," "in yet another embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present application.

[0055] The embodiments of the present application provide a question-and-answer processing method that can be applied to computer devices such as terminals and servers. Taking the server of an insurance company / financial institution in the financial field as an example, the insurance company / financial institution server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. Take the application of the method in this application to the intelligent question-and-answer scenario in the insurance sales process as an example. Figure 1 As shown, the method in this embodiment includes the following steps:

[0056] Step S101, obtaining a target question and a number of question and answer samples;

[0057] In this step, the target question may be a question about an insurance product raised by a target user. The question and answer samples may be pre-collected sample questions about an insurance product and sample answers corresponding to each sample question. Specifically, historical question and answer data about an insurance product may be obtained, and then a number of sample questions and sample answers corresponding to each sample question may be extracted based on the historical question and answer data.

[0058] Step S102, encoding each of the question and answer samples based on the pre-trained target question and answer model to obtain a first hidden state sequence corresponding to each of the question and answer samples;

[0059] In the specific implementation process of this step, the target encoder in the target question-answering model can be used to encode each question-answering sample to obtain the first hidden state sequence corresponding to each question-answering sample.

[0060] Step S103, encoding the target question based on the target question-answering model to obtain a second hidden state sequence corresponding to the target question;

[0061] During the specific implementation of this step, the target encoder in the target question-answering model can be used to encode the target question to obtain a second hidden state sequence corresponding to the target question.

[0062] Step S104, predicting and obtaining answer fragments based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question using the target question-answering model;

[0063] In the specific implementation process of this step, the second hidden state sequence and each of the first hidden state sequences can be spliced ​​to obtain a target hidden state sequence, and then the target hidden state sequence and the initial sentence sequence are input into the target question-answering model, and an answer segment is predicted using the question-answering model, and the answer segment is spliced ​​with the initial sentence to update the initial sentence sequence, so as to predict the next round / next answer segment. In this step, the answer segment can specifically be a segment or a word.

[0064] Step S105: Generate and output a target answer corresponding to the target question based on each of the answer fragments.

[0065] In this step, after obtaining each answer fragment, the answer fragments can be combined to obtain a target answer, and the target answer is output according to a predetermined output method.

[0066] The question and answer processing method in this embodiment obtains a hidden state sequence by encoding the question and answer samples and the target question. Subsequently, the answer fragments can be predicted based on the hidden state sequence and the initial sentence sequence corresponding to the target question, so that the prediction results of each answer fragment are more accurate and reasonable, and then the target answer can be accurately generated based on each answer fragment, thereby improving the accuracy of answer prediction.

[0067] Based on the above embodiment, another embodiment of the present application provides a question-answering processing method, which specifically includes the following steps:

[0068] Step S201, obtaining a target question and a number of question and answer samples;

[0069] Step S202, generating a sample sentence sequence corresponding to each question and answer sample based on each question and answer sample;

[0070] In the specific implementation process of this step, each question and answer sample (x i ,y i ) into the predetermined template to obtain the sentence sequence z i . Among them, the predetermined template is a question and answer template, that is, the question and answer template contains a question field and an answer field, so that the question information in the question and answer sample can be matched with the question field in the question and answer template, and the answer information in the question and answer sample can be matched with the answer field in the question and answer template, so as to obtain a sentence sequence.

[0071] Step S203, encoding each of the sample sentence sequences based on the target encoder in the target question-answering model to obtain a first hidden state sequence corresponding to each of the sample sentence sequences;

[0072] In the specific implementation process of this step, after obtaining the sample sentence sequence z i After that, we can convert the sample sentence sequence z i Input T5 encoder to get the first hidden state sequence h i ,h i Represents the first hidden state sequence output by the encoder for the i-th question and answer sample.

[0073] Step S204, generating an initial sentence sequence corresponding to the target question based on the target question;

[0074] In the specific implementation process of this step, the target problem x test Put it into the predetermined template to get the initial sentence sequence z test .

[0075] Step S205, based on the target encoder in the target question-answering model, encoding the initial sentence sequence to obtain a second hidden state sequence;

[0076] In the specific implementation process of this step, after obtaining the initial sentence sequence z test After that, the initial sentence sequence z can be test The corresponding second hidden state sequence h is obtained by inputting the encoder of T5 test .

[0077] Step S206, performing splicing based on the first hidden state sequences and the second hidden state sequences to obtain a spliced ​​target hidden state sequence;

[0078] In the specific implementation process of this step, each first hidden state sequence obtained in step S203 can be and the second hidden state sequence h obtained in step S205 test Perform splicing to obtain the target hidden state sequence

[0079] Step S207, using the target decoder in the target question-answering model, performing answer prediction processing on the concatenated target hidden state sequence and the initial sentence sequence corresponding to the target question to obtain a first answer fragment;

[0080] In this step, the target question-answering model can be a large language model (LLMs) based on an encoder-decoder structure. By adopting the question-answering model in this application, bidirectional learning of in-context learning (ICL) reasoning can be achieved. In the question-answering model, by adopting an encoder-decoder structure, the sample / instance is input into the encoder, and then the target question is predicted and answered in the decoder stage.

[0081] In the specific implementation process, the decoder in the target question-answering model can be used to perform attention calculation on the target hidden state sequence to obtain the calculation result, and then the answer fragment is predicted based on the calculation result and the initial sentence sequence. That is, the specific process of answer fragment prediction is as follows:

[0082] Step S2071, based on the encoding-decoding attention module in the target decoder, performing attention calculation on the target hidden state sequence to obtain a target calculation result;

[0083] In this step, the target hidden state sequence can be used as a key-value pair to input the encoder-decoder attention module in the decoder to calculate the attention. The calculation formula is:

[0084]

[0085] Among them, K, V, and Q are matrices calculated through the target hidden state sequence.

[0086] Step S2072, based on the target calculation result and the initial sentence sequence, using the prediction module in the target encoder to perform a first answer segment prediction process to obtain the first answer segment;

[0087] In this step, the decoder is used to predict the target answer At the decoding stage, the initial sentence sequence z can be input into the decoder test , then the decoder can answer The first fragment Make a prediction to get the first answer snippet.

[0088] Step S208, when it is determined based on the first answer segment that the predetermined prediction end condition is not satisfied, the initial sentence sequence is updated based on the first answer segment to obtain a current sentence sequence for predicting the next answer segment, until the nth answer segment obtained based on the prediction is determined to satisfy the predetermined prediction end condition, answer segment prediction is stopped, and each answer segment is obtained, where n is a positive integer;

[0089] In the specific implementation process of this step, after the first answer fragment is predicted, the following steps are specifically adopted:

[0090] Step S2081, taking the first answer segment as the current answer segment;

[0091] Step S2082, compare the current answer segment with the predetermined end identifier to determine whether the predetermined prediction end condition is met.

[0092] That is, the current answer segment is compared with the predetermined end identifier. If the current answer segment is consistent with the predetermined end identifier, it is determined that the predetermined prediction end condition is met, and step S209 is executed; if the current answer segment is inconsistent with the predetermined end identifier, it is determined that the predetermined prediction end condition is not met, and step S2083 is executed. In this step, the predetermined end identifier can be <eos>.

[0093] Step S2083: Compare the predicted answer segments with the initial sentence sequence z test Perform concatenation to update the initial sentence sequence and obtain the current sentence sequence z t ' est .

[0094] In the specific implementation process of this step, the first answer segment can be processed to obtain the state vector corresponding to the first answer segment; when multiple answer segments have been predicted, each answer segment can be processed to obtain the state vector corresponding to each answer segment. Then, based on the state vectors of each answer segment and the initial sentence sequence, splicing processing is performed to obtain the current sentence sequence.

[0095] Step S2084: convert the current sentence sequence z t ' est Re-input to the target decoder to predict the nth answer segment and obtain the nth answer segment

[0096] Step S2085: The nth answer segment as the current answer fragment and return to step S2082.

[0097] In this step, the decoder outputs the predicted answer At the beginning of the decoding phase, z is input to the decoder. test , then the decoder starts to answer The first fragment Make a prediction; then, With z test After concatenation, we get the current sentence sequence z t ' est , and then proceed to the second fragment prediction, determine Whether the predetermined prediction end condition is met, and if the end condition is not met, With the current sentence sequence z t ' est Splice and get a new z t ' est ; Each subsequent step is automatically performed according to the above operation until the output fragment End the prediction and get the answer fragments.

[0098] Step S209: Generate and output a target answer corresponding to the target question based on each of the answer fragments.

[0099] In this step, after obtaining each answer fragment, each answer fragment can be spliced ​​in the predicted order to obtain the target answer. Finally, the target answer can be output in a predetermined target output mode, which can be a voice broadcast mode, a text display mode, etc.

[0100] The question and answer processing method in this embodiment obtains a hidden state sequence by encoding the question and answer samples and the target question. Subsequently, the answer fragments can be predicted round by round based on the hidden state sequence and the initial sentence sequence corresponding to the target question, so that the prediction results of each answer fragment are more accurate and reasonable, and then the target answer can be accurately generated based on each answer fragment, thereby improving the accuracy of answer prediction.

[0101] The method in this application uses LLMs based on the encoder-decoder structure, which can make fuller use of examples / question-answer samples, not only enriching the application field of LLM, but also improving the performance and user experience of the intelligent customer service system. This can not only enhance the targeted services of intelligent customer service, but also improve the user experience, thereby increasing user stickiness.

[0102] The method in this application uses a strategy of bidirectional learning examples in the encoder, not only to ensure that the model can deeply understand the full context when learning examples, but also to capture the rich bidirectional information in the examples, so that the model can understand the context of various aspects more comprehensively. Through this learning method, the model can better grasp the relevant information in the examples and improve its global understanding of the input sequence, so as to more effectively cope with complex tasks and reasoning requirements.

[0103] By learning each example separately, we not only ensure that the learning between examples is not interfered, but also because the examples / question-answer samples are independent of the query test / target question, the question-answering model can be prepared in advance when performing multiple downstream reasoning tasks, thereby accelerating the efficiency of actual deployment. This independent learning strategy enables the model to adapt to various input scenarios more flexibly, improves the versatility of the system, and makes it easier to meet the needs of different fields and application scenarios.

[0104] By learning the test query first and then learning from examples, the model can better understand the context and requirements of the test query. This learning method provides the model with a more targeted learning direction, enabling it to adapt to different types of queries and tasks more flexibly. The design of this order takes into account the prior knowledge and task characteristics in actual reasoning, which helps the model to use the learned knowledge more efficiently for reasoning and prediction, and improves performance in complex tasks.

[0105] Another embodiment of the present application provides a question-answer processing device, such as Figure 2 As shown, including:

[0106] An acquisition module 11 is used to acquire a target question and a number of question and answer samples;

[0107] A first processing module 12 is used to encode each of the question and answer samples based on a pre-trained target question and answer model to obtain a first hidden state sequence corresponding to each of the question and answer samples;

[0108] A second processing module 13 is used to encode the target question based on the target question-answering model to obtain a second hidden state sequence corresponding to the target question;

[0109] A prediction module 14 is used to predict and obtain answer fragments based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question using the target question-answering model;

[0110] The generating module 15 is used to generate and output a target answer corresponding to the target question based on each of the answer fragments.

[0111] In the specific implementation process of this embodiment, the first processing module is specifically used to:

[0112] Generate a sample sentence sequence corresponding to each question and answer sample based on each of the question and answer samples;

[0113] Based on the target encoder in the target question-answering model, each of the sample sentence sequences is encoded to obtain a first hidden state sequence corresponding to each of the sample sentence sequences.

[0114] In the specific implementation process of this embodiment, the second processing module is specifically used to:

[0115] Generate an initial sentence sequence corresponding to the target question based on the target question;

[0116] Based on the target encoder in the target question-answering model, the initial sentence sequence is encoded to obtain the second hidden state sequence.

[0117] In the specific implementation process of this embodiment, the prediction module specifically includes:

[0118] A splicing unit, configured to perform splicing based on the first hidden state sequences and the second hidden state sequences to obtain a spliced ​​target hidden state sequence;

[0119] A prediction unit, using a target decoder in the target question-answering model, performs answer prediction processing on the concatenated target hidden state sequence and the initial sentence sequence corresponding to the target question to obtain a first answer fragment;

[0120] An updating unit is used to update the initial sentence sequence based on the first answer fragment when it is determined that a predetermined prediction end condition is not met based on the first answer fragment, to obtain a current sentence sequence for predicting the next answer fragment, until the nth answer fragment obtained based on the prediction is determined to meet the predetermined prediction end condition, stop answer fragment prediction, and obtain each of the answer fragments, wherein n is a positive integer.

[0121] In the specific implementation process of this embodiment, the prediction unit is specifically used to:

[0122] Based on the encoding-decoding attention module in the target decoder, attention calculation is performed on the target hidden state sequence to obtain a target calculation result; based on the target calculation result and the initial sentence sequence, the prediction module in the target encoder is used to perform a first answer fragment prediction process to obtain the first answer fragment.

[0123] In the specific implementation process of this embodiment, the updating unit is specifically used to: process the first answer fragment to obtain the state vector corresponding to the first answer fragment; and perform splicing processing based on the state vector and the initial sentence sequence to obtain the current sentence sequence.

[0124] In the specific implementation process of this embodiment, the predetermined prediction end condition is a predetermined end identifier;

[0125] The prediction module also includes a determination unit, which is used to: compare the nth answer fragment with the predetermined end identifier; when it is determined that the nth answer fragment is consistent with the predetermined end identifier, determine that the predetermined prediction end condition is met; when it is determined that the nth answer fragment is inconsistent with the predetermined end identifier, determine that the predetermined prediction end condition is not met.

[0126] The question and answer processing device in this embodiment obtains a hidden state sequence by encoding the question and answer samples and the target question. Subsequently, each answer fragment can be predicted based on the hidden state sequence and the initial sentence sequence corresponding to the target question, so that the prediction results of each answer fragment are more accurate and reasonable, and then the target answer can be accurately generated based on each answer fragment, thereby improving the accuracy of answer prediction.

[0127] Another embodiment of the present application provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the following method steps are implemented:

[0128] Step 1: Obtain the target question and several question and answer samples;

[0129] Step 2: Based on the pre-trained target question-answering model, encode each of the question-answering samples to obtain a first hidden state sequence corresponding to each of the question-answering samples;

[0130] Step 3: Based on the target question-answering model, encode the target question to obtain a second hidden state sequence corresponding to the target question;

[0131] Step 4: Based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question, using the target question-answering model, predict and obtain each answer fragment;

[0132] Step 5: Generate and output a target answer corresponding to the target question based on each of the answer fragments.

[0133] The specific implementation process of the above method steps can be found in the embodiments of any of the above-mentioned question and answer processing methods, and this embodiment will not be repeated here.

[0134] The storage medium in the present application obtains a hidden state sequence by encoding the question and answer samples and the target question. Subsequently, each answer fragment can be predicted based on the hidden state sequence and the initial sentence sequence corresponding to the target question, so that the prediction results of each answer fragment are more accurate and reasonable, and then the target answer can be accurately generated based on each answer fragment, thereby improving the accuracy of answer prediction.

[0135] Another embodiment of the present application provides a computer device, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a service-side method for determining a product marketing strategy.

[0136] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, it implements the functions or steps of a client side of a product marketing strategy determination method.

[0137] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0138] Step 1: Obtain the target question and several question and answer samples;

[0139] Step 2: Based on the pre-trained target question-answering model, encode each of the question-answering samples to obtain a first hidden state sequence corresponding to each of the question-answering samples;

[0140] Step 3: Based on the target question-answering model, encode the target question to obtain a second hidden state sequence corresponding to the target question;

[0141] Step 4: Based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question, using the target question-answering model, predict and obtain each answer fragment;

[0142] Step 5: Generate and output a target answer corresponding to the target question based on each of the answer fragments.

[0143] The specific implementation process of the above method steps can be found in the embodiments of any of the above-mentioned question and answer processing methods, and this embodiment will not be repeated here.

[0144] The computer device in the present application obtains a hidden state sequence by encoding the question and answer samples and the target question. Subsequently, each answer fragment can be predicted based on the hidden state sequence and the initial sentence sequence corresponding to the target question, so that the prediction results of each answer fragment are more accurate and reasonable, and then the target answer can be accurately generated based on each answer fragment, thereby improving the accuracy of answer prediction.

[0145] The above embodiments are only exemplary embodiments of the present application and are not intended to limit the present application. The protection scope of the present application is defined by the claims. Those skilled in the art may make various modifications or equivalent substitutions to the present application within the essence and protection scope of the present application, and such modifications or equivalent substitutions shall also be deemed to fall within the protection scope of the present application. The non-Company software tools or components that appear in the embodiments of the present application are merely examples and do not represent actual use.< / eos>

Claims

1. A question-answering processing method, characterized in that: include: Obtain the target question and several question and answer samples; Based on the pre-trained target question-answering model, encoding each of the question-answering samples is performed to obtain a first hidden state sequence corresponding to each of the question-answering samples; Based on the target question-answering model, encoding the target question to obtain a second hidden state sequence corresponding to the target question; Based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question, using the target question-answering model, predict and obtain each answer fragment; A target answer corresponding to the target question is generated based on each of the answer fragments and outputted.

2. The method according to claim 1, characterized in that The target question-answering model obtained by pre-training, encoding each of the question-answering samples to obtain a first hidden state sequence corresponding to each of the question-answering samples, specifically includes: Generate a sample sentence sequence corresponding to each question and answer sample based on each of the question and answer samples; Based on the target encoder in the target question-answering model, each of the sample sentence sequences is encoded to obtain a first hidden state sequence corresponding to each of the sample sentence sequences.

3. The method according to claim 1, characterized in that The encoding process of the target question based on the target question-answering model to obtain a second hidden state sequence corresponding to the target question specifically includes: Generate an initial sentence sequence corresponding to the target question based on the target question; Based on the target encoder in the target question-answering model, the initial sentence sequence is encoded to obtain the second hidden state sequence.

4. The method according to claim 1, characterized in that The step of predicting and obtaining answer fragments based on the second hidden state sequence, each of the first hidden state sequences, and the initial sentence sequence corresponding to the target question using the target question-answering model specifically includes: Based on each of the first hidden state sequences and the second hidden state sequences, splicing is performed to obtain a spliced ​​target hidden state sequence; Using the target decoder in the target question-answering model, perform answer prediction processing on the concatenated target hidden state sequence and the initial sentence sequence corresponding to the target question to obtain a first answer fragment; When it is determined based on the first answer fragment that the predetermined prediction end condition is not met, the initial sentence sequence is updated based on the first answer fragment to obtain a current sentence sequence for predicting the next answer fragment, until the nth answer fragment obtained based on the prediction is determined to meet the predetermined prediction end condition, the answer fragment prediction is stopped, and each of the answer fragments is obtained, where n is a positive integer.

5. The method according to claim 4, characterized in that The target decoder in the target question-answering model is used to perform answer prediction processing on the concatenated target hidden state sequence and the initial sentence sequence corresponding to the target question to obtain a first answer fragment, specifically including: Based on the encoding-decoding attention module in the target decoder, performing attention calculation on the target hidden state sequence to obtain a target calculation result; Based on the target calculation result and the initial sentence sequence, a prediction module in the target encoder is used to perform a first answer fragment prediction process to obtain the first answer fragment.

6. The method according to claim 4, characterized in that The updating process of the initial sentence sequence based on the first answer segment to obtain a current sentence sequence for predicting the next answer segment specifically includes: Processing the first answer fragment to obtain a state vector corresponding to the first answer fragment; Based on the state vector and the initial sentence sequence, a concatenation process is performed to obtain the current sentence sequence.

7. The method according to any one of claims 4 to 6, characterized in that: The predetermined prediction end condition is a predetermined end identifier; The nth answer fragment obtained based on the prediction determines that a predetermined prediction end condition is satisfied, specifically including: Comparing the nth answer segment with the predetermined end identifier; When it is determined that the nth answer segment is consistent with the predetermined end identifier, determining that a predetermined prediction end condition is satisfied; When it is determined that the nth answer segment is inconsistent with the predetermined end identifier, it is determined that the predetermined prediction end condition is not satisfied.

8. A question-answer processing device, characterized in that: include: The acquisition module is used to obtain the target question and several question and answer samples; A first processing module is used to encode each of the question and answer samples based on the target question and answer model obtained by pre-training, so as to obtain a first hidden state sequence corresponding to each of the question and answer samples; A second processing module is used to encode the target question based on the target question-answering model to obtain a second hidden state sequence corresponding to the target question; A prediction module, configured to predict and obtain answer fragments based on the second hidden state sequence, each of the first hidden state sequences, and an initial sentence sequence corresponding to the target question using the target question-answering model; A generation module is used to generate and output a target answer corresponding to the target question based on each of the answer fragments.

9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the question and answer processing method described in any one of claims 1 to 7 are implemented.

10. A computer device, characterized in that: The system at least comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the question-answering processing method according to any one of claims 1 to 7 when executing the computer program on the memory.

Citation Information

Patent Citations

  • Transformer model-based question and answer method, question and answer device and storage device

    CN111881279A

  • Data processing method and device for machine reading understanding, equipment and medium

    CN114328883A

  • Medical question and answer method based on knowledge graph and related equipment

    CN115470327A

  • Translation method, translation model generation method and related equipment

    CN117010416A

  • Text generation method based on large model and training method of text generation model

    CN118940730A

Cited By

  • Question and answer processing method and device

    CN120687181A