A question and answer processing method, apparatus, medium, and device

By encoding the target question and question-answer samples, using the question-answering model to generate hidden state sequences and predict answer fragments, the problem of inaccurate answers in existing question-answering processing methods is solved, and more accurate answer generation is achieved.

CN119599030BActive Publication Date: 2025-10-17PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The answer output in existing question-answering processing methods is not accurate and reasonable enough.

Method used

By obtaining the target question and question-answer samples, the pre-trained target question-answer model is used for encoding processing to generate hidden state sequences, and the answer fragments are predicted based on these state sequences and the initial sentence sequence to finally generate the target answer.

Benefits of technology

The accuracy of answer prediction is improved, making the prediction results of answer fragments more accurate and reasonable, and the generated target answers more precise.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119599030B_ABST
    Figure CN119599030B_ABST
Patent Text Reader

Abstract

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

Description

TECHNICAL FIELD

[0001] The present application relates to the field of finance and the field of natural language processing technology, and in particular to a question and answer processing method, device, medium and equipment. BACKGROUND

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

[0003] However, the existing question and answer processing method has the problem that the answer output is not accurate and reasonable enough. SUMMARY

[0004] Therefore, the present application provides a question and answer processing method, device, medium and equipment, which mainly aims to solve the problem that the current question and answer processing method has the problem that the answer output is not accurate and reasonable enough.

[0005] To solve the above problems, the present application provides a question and answer processing method, comprising:

[0006] obtaining a target question and a plurality of question and answer samples;

[0007] encoding and processing each of the question and answer samples based on a target question and answer model obtained by pre-training, to obtain a first hidden state sequence corresponding to each of the question and answer samples;

[0008] encoding and processing the target question based on the target question and answer model, 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 sequence, and an initial sentence sequence corresponding to the target question, using the target question and answer model to predict and obtain each answer fragment;

[0010] generating and outputting a target answer corresponding to the target question based on each of the answer fragments.

[0011] Optionally, the encoding and processing of each of the question and answer samples based on the target question and answer model obtained by pre-training to obtain the first hidden state sequence corresponding to each of the question and answer samples specifically comprises:

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

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

[0014] Optionally, the target question is encoded based on the target question and answer model to obtain a second hidden state sequence corresponding to the target question, specifically including:

[0015] Based on the target question, an initial sentence sequence corresponding to the target question is generated.

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

[0017] Optionally, based on the second hidden state sequence, each first hidden state sequence, and the initial sentence sequence corresponding to the target question, each answer fragment is predicted using the target question and answer model, specifically including:

[0018] Based on each first hidden state sequence and the second hidden state sequence, a spliced target hidden state sequence is obtained.

[0019] Using a target decoder in the target question and answer model, the spliced target hidden state sequence and the initial sentence sequence corresponding to the target question are processed to obtain a first answer fragment.

[0020] When the predetermined prediction end condition is not met based on the first answer fragment, the initial sentence sequence is updated based on the first answer fragment to obtain a current sentence sequence for predicting a next answer fragment, until the predetermined prediction end condition is met based on the n-th answer fragment obtained by prediction, and the answer fragment prediction is stopped, obtaining each answer fragment, wherein n is a positive integer.

[0021] Optionally, the spliced target hidden state sequence and the initial sentence sequence corresponding to the target question are processed using a target decoder in the target question and answer model to obtain a first answer fragment, specifically including:

[0022] Based on an encoding-decoding attention module in the target decoder, attention calculation is performed 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 first answer fragment prediction processing to obtain the first answer fragment.

[0024] Optionally, the updating processing is performed on the initial sentence sequence based on the first answer segment, and a current sentence sequence used for predicting a next answer segment is obtained, and the updating processing specifically comprises:

[0025] The first answer segment is processed, and a state vector corresponding to the first answer segment is obtained.

[0026] The state vector and the initial sentence sequence are spliced, and the current sentence sequence is obtained.

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

[0028] The n th answer segment obtained through prediction is determined to satisfy the predetermined prediction end condition, and the determination specifically comprises:

[0029] The n th answer segment and the predetermined end identifier are compared.

[0030] When the n th answer segment is determined to be consistent with the predetermined end identifier, it is determined that the predetermined prediction end condition is satisfied.

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

[0032] To solve the above problems, the present application provides a question and answer processing device, comprising:

[0033] An acquisition module is configured to acquire a target question and a plurality of question and answer samples.

[0034] A first processing module is configured to perform encoding processing on each of the question and answer samples based on a target question and answer model obtained through pre-training, and obtain a first hidden state sequence corresponding to each of the question and answer samples.

[0035] A second processing module is configured to perform encoding processing on the target question based on the target question and answer model, and obtain a second hidden state sequence corresponding to the target question.

[0036] A prediction module is configured to predict each answer segment based on the second hidden state sequence, each of the first hidden state sequences, an initial sentence sequence corresponding to the target question, and the target question and answer model.

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

[0038] To solve the above problems, the present application provides a storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the question and answer processing method described in any of the above embodiments are implemented.

[0039] To solve the above problems, the present application provides a computer device, at least comprising a memory and a processor, the memory stores a computer program, and the processor implements the steps of the question and answer processing method according to any one of the above when executing the computer program on the memory.

[0040] The question and answer processing method, device, medium and equipment provided in the present application can obtain a hidden state sequence by encoding the question and answer sample and the target question, and then predict the answer fragments 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 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 a summary of the technical solutions of the present application. In order to enable the technical means of the present application to be more clearly understood, the present application can be implemented according to the content of the specification, and in order to enable the above and other purposes, characteristics and advantages of the present application to be more apparent and easy to understand, the specific embodiments of the present application are described below. BRIEF DESCRIPTION OF DRAWINGS

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

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

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

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

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

[0047] The various solutions and features of the present application are described herein with reference to the accompanying drawings.

[0048] It should be understood that various modifications can 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 the embodiments. Those skilled in the art will think of other modifications within the scope and spirit of the present application.

[0049] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the application and, together with the general description of the 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 the preferred forms of the application given, by way of non-limiting example, with reference to the accompanying drawings.

[0051] It should also be understood that, although the present application has been described above with reference to particular means, materials and embodiments, the present application is by no means limited to the particulars described and as such extends to all alternative constructions falling within the scope of the application.

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

[0053] Specific embodiments of the present application are described hereinafter, by way of non-limiting example; however, it should be understood that the claimed embodiments are merely examples of the present application, which can be implemented in numerous ways. Well-known and / or repetitive functions and structures are not described in detail to avoid obscuring the present application unnecessarily. Therefore, specific structural and functional details disclosed herein are not intended to limit the claimed embodiments, but merely to set forth representative structures and functions for purposes of the claims and the enabling disclosure for the skilled artisan.

[0054] The specification can use phrases such as "in one embodiment", "in another embodiment", "in yet another embodiment", or "in other embodiments", which can refer to one or more of the same or different embodiments under the present application.

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

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

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

[0058] In step S102, each of the question and answer samples is encoded based on the target question and answer model obtained by pre-training to obtain a first hidden state sequence corresponding to each of the question and answer samples.

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

[0060] In step S103, the target question is encoded based on the target question and answer model to obtain a second hidden state sequence corresponding to the target question.

[0061] In the implementation process of this step, the target encoder in the target question and answer model can be used to encode the target question to obtain the second hidden state sequence corresponding to the target question.

[0062] In step S104, each of the answer segments is predicted based on the second hidden state sequence, each of the first hidden state sequences, an initial sentence sequence corresponding to the target question, and the target question and answer model.

[0063] In the 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 and answer model to predict an answer segment. The answer segment is spliced with the initial sentence to update the initial sentence sequence, so that the next answer segment is predicted. In this step, the answer segment can be a segment or a word.

[0064] In step S105, a target answer corresponding to the target question is generated based on each of the answer segments and output.

[0065] In this step, after obtaining each of the answer segments, each of the answer segments can be combined to obtain the target answer, and the target answer is output in a predetermined output manner.

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

[0067] Based on the above-mentioned embodiments, another embodiment of the present application provides a question and answer processing method, specifically comprising the following steps:

[0068] In step S201, a target question and a plurality of question and answer samples are obtained.

[0069] In step S202, a sample sentence sequence corresponding to each question and answer sample is generated based on each question and answer sample.

[0070] In the specific implementation process, each question and answer sample (x i ,y i ) can be put into a predetermined template to obtain a sentence sequence z i . The predetermined template is a question and answer template, that is, the question and answer template includes a question field and an answer field. Thus, 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 the sentence sequence.

[0071] In step S203, each sample sentence sequence is encoded based on a target encoder in the target question and answer model to obtain a first hidden state sequence corresponding to each sample sentence sequence.

[0072] In the specific implementation process, after obtaining the sample sentence sequence z i , the sample sentence sequence z i can be input into the encoder of T5 to obtain a first hidden state sequence h i , h i represents the first hidden state sequence output by the i-th question and answer sample in the encoder.

[0073] In step S204, an initial sentence sequence corresponding to the target question is generated based on the target question.

[0074] In the specific implementation process, the target question x test can be put into a predetermined template to obtain an initial sentence sequence z test .

[0075] In step S205, the initial sentence sequence is encoded based on a target encoder in the target question and answer model to obtain a second hidden state sequence.

[0076] In the implementation process, the initial sentence sequence z test The initial sentence sequence z test is input into the encoder of T5 to obtain a corresponding second hidden state sequence h test .

[0077] In step S206, the first hidden state sequence and the second hidden state sequence are spliced to obtain a spliced target hidden state sequence.

[0078] In the implementation process, the first hidden state sequence obtained in step S203 and the second hidden state sequence h test obtained in step S205 are spliced to obtain a target hidden state sequence h

[0079] In step S207, the target decoder in the target question answering model is used to perform answer prediction processing on the spliced target hidden state sequence and the initial sentence sequence corresponding to the target question to obtain a first answer segment.

[0080] In this step, the target question answering model can be a large language model (LLM) based on an encoder-decoder structure. By using the question answering model in the present application, bidirectional learning of in-context learning (ICL) reasoning can be achieved. In the question answering model, the encoder-decoder structure is used to input samples / instances into the encoder, and then the predicted answer to the target question is obtained in the decoder stage.

[0081] In the 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 a calculation result, and then based on the calculation result and the initial sentence sequence, the answer segment prediction is performed. Specifically, the answer segment prediction process is as follows:

[0082] In step S2071, the encoding-decoding attention module in the target decoder is used to perform 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 input into the encoding-decoding attention module in the decoder as a key-value pair for attention calculation, and the calculation formula is as follows:

[0084]

[0085] where K, V, and Q are matrices calculated from the target hidden state sequence.

[0086] ​Step S2072, based on the target calculation result and the initial sentence sequence, a first answer segment is predicted by using a prediction module in the target encoder, and the first answer segment is obtained;

[0087] In this step, when the target answer is predicted by using the decoder , that is, in the decoding stage, the initial sentence sequence z test may be input into the decoder, and then the decoder can predict the first segment of the answer / answer to obtain the first answer segment.

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

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

[0090] Step S2081, the first answer segment is taken as a current answer segment;

[0091] Step S2082, the current answer segment is compared with a 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 then 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 then step S2083 is executed. In this step, the predetermined end identifier can be <eos>.

[0093] Step S2083, the predicted obtained answer segment is spliced with the initial sentence sequence z test to update the initial sentence sequence and obtain the current sentence sequence z t ' est .

[0094] In the implementation process, 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, the current sentence sequence z t ' est is re-input into the target decoder to predict the nth answer segment

[0096] Step S2085, the nth answer segment is taken as the current answer segment, and the step S2082 is returned.

[0097] In this step, when the decoder output is used to predict the answer , that is, in the decoding stage, at the beginning, z test is input into the decoder, and then the decoder starts to predict the first segment of the answer ; subsequently, the predicted is spliced with z test to obtain the current sentence sequence z t ' est , and the prediction of the second segment is performed, and it is determined whether the predetermined prediction end condition is met, and when the end condition is not met, the is spliced with the current sentence sequence z t ' est to obtain a new z t ' est ; each subsequent step is automatically performed according to the above operation until the output segment ends the prediction to obtain each answer segment.

[0098] Step S209, the target answer corresponding to the target question is generated based on each answer segment and output.

[0099] In this step, after obtaining each answer segment, the answer segments 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. The target output mode can be a voice broadcast mode, a text display mode, etc.

[0100] The question and answer processing method in this embodiment can obtain a hidden state sequence by encoding the question and answer samples and the target question. Subsequently, the answer segments 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 the answer segments are more accurate and reasonable. Then, the target answer can be accurately generated based on the answer segments, and the accuracy of answer prediction is improved.

[0101] The method in this application uses LLMs based on an encoder-decoder structure, which can more fully utilize examples / question and answer samples, not only enriching the application field of LLMs, but also improving the performance and user experience of intelligent customer service systems. This not only enhances the targeted service of intelligent customer service, but also improves user experience, thereby increasing user stickiness.

[0102] The method in this application uses a strategy of bidirectional learning examples in the encoder, which not only ensures that the model can deeply understand the overall context when learning examples, but also captures rich bidirectional information in examples, so that the model can more comprehensively understand the context of each aspect. Through such a learning method, the model can better grasp the associated information in the examples and improve its global understanding ability of the input sequence, thereby more effectively dealing with complex tasks and reasoning requirements.

[0103] The method of learning each example separately not only ensures that the learning between examples is not disturbed, but also because the examples / question and answer samples and the query test / target question are independent, which enables the question and answer model to prepare in advance when performing multiple downstream reasoning tasks, thereby accelerating the efficiency of actual deployment. This independent learning strategy enables the model to more flexibly adapt to various input situations, improves the generality of the system, and makes it more easily adapt to the needs of different fields and application scenarios.

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

[0105] Another embodiment of the application provides a question and answer processing device, which comprises a processor and a memory, and the memory stores a question and answer processing program. Figure 2 As shown, comprising:

[0106] The acquisition module 11 is configured to acquire a target question and a plurality of question and answer samples;

[0107] The first processing module 12 is configured to encode each of the question and answer samples based on a target question and answer model obtained through pre-training, to obtain a first hidden state sequence corresponding to each of the question and answer samples;

[0108] The second processing module 13 is configured to encode the target question based on the target question and answer model, to obtain a second hidden state sequence corresponding to the target question;

[0109] The prediction module 14 is configured to predict each answer fragment based on the second hidden state sequence, each of the first hidden state sequences, and an initial sentence sequence corresponding to the target question, by using the target question and answer model;

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

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

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

[0113] encode each of the sample sentence sequences based on a target encoder in the target question and answer model, to obtain a first hidden state sequence corresponding to each of the sample sentence sequences.

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

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

[0116] encode the initial sentence sequence based on a target encoder in the target question and answer model, to obtain the second hidden state sequence.

[0117] In the implementation process of the embodiment, the prediction module specifically comprises:

[0118] The splicing unit is configured to splice each of the first hidden state sequences and the second hidden state sequence, to obtain a spliced target hidden state sequence;

[0119] The prediction unit is configured to use a target decoder in the target question and answer model to perform answer prediction processing on the spliced target hidden state sequence and the initial sentence sequence corresponding to the target question, to obtain a first answer fragment.

[0120] an updating unit configured to, when it is determined that the predetermined prediction end condition is not met based on the first answer segment, perform updating processing on the initial sentence sequence based on the first answer segment, to obtain a current sentence sequence for predicting a next answer segment, until it is determined that the predetermined prediction end condition is met based on an nth answer segment obtained by prediction, and the answer segment prediction is stopped, to obtain each answer segment, wherein n is a positive integer.

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

[0122] perform attention calculation on the target hidden state sequence based on an encoding-decoding attention module in the target decoder, to obtain a target calculation result; and perform first answer segment prediction processing on the initial sentence sequence based on the target calculation result and by using a prediction module in the target encoder, to obtain the first answer segment.

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

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

[0125] The prediction module further includes a determination unit configured to: compare 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, determine that the predetermined prediction end condition is met; and when it is determined that the nth answer segment is not consistent with the predetermined end identifier, determine that the predetermined prediction end condition is not met.

[0126] The question and answer processing apparatus in the embodiment can obtain a hidden state sequence by performing encoding processing on a question and answer sample and a target question, and can subsequently predict each answer segment based on the hidden state sequence and an initial sentence sequence corresponding to the target question, so that the prediction results of each answer segment are more accurate and reasonable, and the target answer can be accurately generated based on each answer segment, thereby improving the accuracy of answer prediction.

[0127] Another embodiment of the present application provides a storage medium storing a computer program, which, when executed by a processor, implements the following method steps:

[0128] Step one, obtaining a target question and a plurality of question and answer samples;

[0129] Step two, based on the target question and answer model obtained by pre-training, each of the question and answer samples is coded to obtain the first hidden state sequence corresponding to each of the question and answer samples;

[0130] Step three, based on the target question and answer model, the target question is coded to obtain the second hidden state sequence corresponding to the target question;

[0131] Step four, based on the second hidden state sequence, each of the first hidden state sequence, the initial sentence sequence corresponding to the target question, and the target question and answer model, each answer fragment is predicted and obtained;

[0132] Step five, based on each of the answer fragments, the target answer corresponding to the target question is generated and output.

[0133] The specific implementation process of the above method steps can be referred to the embodiments of any of the above question and answer processing methods, which will not be repeated here.

[0134] The storage medium in the present application obtains the hidden state sequence by coding 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 result of each answer fragment is more accurate and reasonable. Furthermore, the target answer can be accurately generated based on each answer fragment, and the accuracy of answer prediction is improved.

[0135] Another embodiment of the present application provides a computer device, which can be a server, and its internal structure diagram can be as shown in Figure 3 The computer device includes a processor, a memory, a network interface and a database connected by 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, 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 the external client through the network connection. The computer program is executed by the processor to realize the functions or steps of the product marketing strategy determination method server side.

[0136] In one embodiment, a computer device is provided, which can be a client, and its internal structure diagram can be as shown in 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, 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 the external server through the network connection. The computer program is executed by the processor to realize the functions or steps of the client side of the product marketing strategy determination method.

[0137] In one embodiment, a computer device is provided, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the computer program to implement the following steps:

[0138] Step one, obtaining a target question and a plurality of question and answer samples;

[0139] Step two, based on the target question and answer model obtained by pre-training, encoding processing is performed on each of the question and answer samples to obtain a first hidden state sequence corresponding to each of the question and answer samples;

[0140] Step three, based on the target question and answer model, encoding processing is performed on the target question to obtain a second hidden state sequence corresponding to the target question;

[0141] Step four, based on the second hidden state sequence, each of the first hidden state sequence, and the initial sentence sequence corresponding to the target question, using the target question and answer model, each answer fragment is predicted and obtained;

[0142] Step five, based on each of the answer fragments, a target answer corresponding to the target question is generated and output.

[0143] The specific implementation process of the above method steps can be referred to the embodiments of any of the above question and answer processing methods, which will not be repeated here.

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

[0145] The above examples are only exemplary embodiments of the present application, and are not intended to limit the present application. The scope of protection of the present application is defined by the claims. Those skilled in the art can make various modifications or equivalent replacements to the present application within the spirit and protection scope of the present application, and such modifications or equivalent replacements shall also be considered to fall within the protection scope of the present application. The non-company software tools or components appearing in the embodiments of the present application are only illustrative, and do not represent actual use.< / eos> ​

Claims

1. A question-answering processing method, characterized in that: include: Obtain target questions 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; Generate and output a target answer corresponding to the target question based on each of the answer fragments; 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: splicing the first hidden state sequences and the second hidden state sequences 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 the 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.

2. The method according to claim 1, wherein The target question-answering model obtained by pre-training is used to encode each question-answering sample to obtain a first hidden state sequence corresponding to each question-answering sample, specifically including: Generate a sample sentence sequence corresponding to each question and answer sample based on each question and answer sample; 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, wherein 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: generating 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 3, wherein 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: Performing attention calculation on the target hidden state sequence based on the encoding-decoding attention module in the target decoder 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 segment prediction process to obtain the first answer segment.

5. The method according to claim 3, wherein 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 segment to obtain a state vector corresponding to the first answer segment; Based on the state vector and the initial sentence sequence, a splicing process is performed to obtain the current sentence sequence.

6. The method according to any one of claims 1 to 5, wherein: 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.

7. A question-answering 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 configured to encode each question and answer sample based on a pre-trained target question and answer model to obtain a first hidden state sequence corresponding to each question and answer sample; A second processing module is configured 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 is configured 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; specifically comprising: performing splicing based on each of the first hidden state sequences and the second hidden state sequence to obtain a spliced ​​target hidden state sequence; performing answer prediction processing on the spliced ​​target hidden state sequence and the initial sentence sequence corresponding to the target question using the target decoder in the target question-answering model to obtain a first answer fragment; when it is determined based on the first answer fragment that a predetermined prediction end condition is not met, updating the initial sentence sequence 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, stopping answer fragment prediction, and obtaining each of the answer fragments, wherein n is a positive integer; A generation module is used to generate and output a target answer corresponding to the target question based on each of the answer fragments.

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

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

Citation Information

Patent Citations

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

    CN114328883A

  • Translation method, translation model generation method and related equipment

    CN117010416A