Question and answer processing method, device, electronic device and storage medium

The target length information of the Token sequence in question and answer processing is determined through the Token length prediction model, which solves the problems of high memory bandwidth and low efficiency caused by kv_cache in the existing technology, and achieves more efficient question and answer processing.

CN117668198BActive Publication Date: 2024-09-06DARK MATTER ARTIFICIAL INTELLIGENT (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311733085.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-15
Publication Date
2024-09-06
Estimated Expiration
2043-12-15

AI Technical Summary

Technical Problem

Existing text generative models use kv_cache technology in question and answer processing, which results in high memory bandwidth usage, reduced reasoning efficiency, and may cause answer generation failure in multiple concurrency situations.

Method used

The Token length prediction model is used to quickly and accurately determine the target length information of the Token sequence. The target response text is generated through the encoder network, cognitive model and pre-trained Token length prediction model, reducing memory bandwidth requirements and improving efficiency.

Benefits of technology

It improves the accuracy and efficiency of question and answer processing, avoids reasoning failures caused by memory competition, and reduces memory bandwidth requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117668198B
    Figure CN117668198B
Patent Text Reader

Abstract

The present application provides a question-answering processing method, device, electronic device and storage medium, including: outputting a Token sequence corresponding to each question text; inputting the Token sequence corresponding to the question text into a cognitive model, and outputting feature information of each Token sequence; inputting the feature information into a Token length prediction model, performing length prediction, and outputting the length information of each Token sequence; inputting the length information of each Token sequence into a cognitive interaction network, and outputting target length information of each Token sequence; inputting the target length information of each Token sequence and each Token sequence into a cognitive model, performing answer prediction, and outputting a response Token for each question text; inputting the response Token of each question text into an encoder network, and outputting a target response text for each question text, thereby improving the efficiency of response text generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering processing method, device, electronic device, and storage medium. Background Art

[0002] The current text generation model mainly consists of three architectures: Encoder-Decoder architecture, Causal Decoder architecture, and Prefix Decoder architecture. However, no matter which architecture is used, unidirectional attention is used to generate tokens one by one when generating output tokens, and finally convert them into corresponding text. For the above process of generating new tokens, kv_cache technology is usually used to store the KV matrix corresponding to historical tokens to reduce the amount of calculation and speed up the reasoning process. However, the use of kv_cache technology introduces a problem: the KV matrix generated by the current token needs to be spliced ​​with the KV matrix of the historical token, which will take up a lot of memory bandwidth, reduce the reasoning efficiency, and when multiple questions and answers are generated at the same time, it will cause multiple reply answers to fail to generate. Therefore, how to improve the accuracy and efficiency of question and answer processing has become a technical issue that cannot be underestimated. Summary of the invention

[0003] In view of this, the purpose of the present application is to provide a question and answer processing method, device, electronic device and storage medium, which utilizes the Token length prediction model to quickly and accurately determine the target length information of the Token sequence, thereby generating a target answer text based on the target length information of the Token sequence and the Token sequence of each question text, thereby improving the accuracy and efficiency of answer text generation.

[0004] The present application embodiment provides a question-answering processing method, the question-answering processing method comprising:

[0005] Input multiple question texts into the encoder network, encode each question text, and output the Token sequence corresponding to each question text;

[0006] Input the Token sequence corresponding to each of the question texts into the cognitive model, perform feature extraction on the Token sequence of each of the question texts, and output feature information of each of the Token sequence;

[0007] Input the feature information of each Token sequence into a pre-trained Token length prediction model, perform length prediction on the feature information of each Token sequence, and output the length information of each Token sequence;

[0008] Inputting the length information of each of the Token sequences into the cognitive interaction network, and outputting the target length information of each of the Token sequences based on the reference Token length information and the length information of each of the Token sequences;

[0009] Input the target length information of each Token sequence and each Token sequence into the cognitive model, perform answer prediction, and output the answer Token of each question text;

[0010] The answer Token of each question text is input into the encoder network, and the target answer text of each question text is output.

[0011] In a possible implementation, the inputting of multiple question texts into the encoder network, encoding each of the question texts, and outputting a Token sequence corresponding to each of the question texts include:

[0012] Inputting a plurality of the question texts into the encoder network, processing each of the question texts based on a byte pair encoding algorithm, and determining a vocabulary for each of the question texts;

[0013] The vocabulary of each question text is converted to determine the Token sequence corresponding to each question text.

[0014] In a possible implementation manner, inputting the length information of each Token sequence into the cognitive interaction network, and outputting the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, includes:

[0015] Inputting the length information of each of the Token sequences into the cognitive interaction network to determine the reference Token length information corresponding to each of the question texts;

[0016] For any of the question texts, detecting whether the reference Token length information of the question text is greater than the length information of the Token sequence of the question text;

[0017] If yes, the reference Token length information is used as the target length information of the Token sequence;

[0018] If not, the length information of the Token sequence is used as the target length information of the Token sequence.

[0019] In a possible implementation manner, inputting the length information of each Token sequence into the cognitive interaction network, and outputting the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, further includes:

[0020] For any of the question texts, if there is no reference Token length information for the question text, the length information of the Token sequence is determined as the target length information of the Token sequence of the question text.

[0021] In a possible implementation manner, inputting the answer Token of each question text into the encoder network and outputting the target answer text of each question text includes:

[0022] The response Token of each question text is encoded based on a byte pair encoding algorithm to generate a target response text for each question text.

[0023] In a possible implementation manner, the Token length prediction model is determined by the following steps:

[0024] Obtain sample feature information of multiple sample Token sequences and label information of each of the sample Token sequences;

[0025] Inputting the sample feature information of each of the sample Token sequences into the delayed neural model, predicting the length of the sample feature information of the sample Token sequence, and determining the predicted length of the sample Token sequence;

[0026] Determine a loss value based on each of the predicted lengths and the label information of each of the sample Token sequences;

[0027] The delay neural model is iteratively trained based on the loss value until the iterative training is completed to determine the Token length prediction model.

[0028] In a possible implementation manner, the iterative training of the delay neural model based on the loss value until the iterative training is completed to determine the Token length prediction model includes:

[0029] If the loss value is less than a preset loss threshold, the iterative training of the delay neural model is stopped, and the delay neural model is used to determine the Token length prediction model;

[0030] If the loss value is greater than a preset loss threshold, the network parameters of the delay neural model are changed and the delay neural model is iteratively trained until the loss value is less than the preset loss threshold, and the training is stopped to determine the Token length prediction model using the delay neural model.

[0031] The present application also provides a question-answer processing device, the question-answer processing device comprising:

[0032] The encoding module is used to input multiple question texts into the encoder network, encode each question text, and output a Token sequence corresponding to each question text;

[0033] A feature extraction module is used to input the Token sequence corresponding to each of the question texts into the cognitive model, perform feature extraction on the Token sequence of each of the question texts, and output feature information of each of the Token sequence;

[0034] The first prediction module is used to input the feature information of each Token sequence into a pre-trained Token length prediction model, perform length prediction on the feature information of each Token sequence, and output the length information of each Token sequence;

[0035] A length determination module, used to input the length information of each Token sequence into the cognitive interaction network, and output the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence;

[0036] A second prediction module is used to input the target length information of each Token sequence and each Token sequence into the cognitive model, perform answer prediction, and output a response Token for each question text;

[0037] The answer generation module is used to input the answer Token of each question text into the encoder network and output the target answer text of each question text.

[0038] An embodiment of the present application also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of the question and answer processing method as described above are performed.

[0039] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the question-and-answer processing method as described above are executed.

[0040] The embodiments of the present application provide a question-answering processing method, device, electronic device and storage medium, and the question-answering processing method includes: inputting a plurality of question texts into an encoder network, encoding each of the question texts, and outputting a Token sequence corresponding to each of the question texts; inputting the Token sequence corresponding to each of the question texts into a cognitive model, extracting features from the Token sequence of each of the question texts, and outputting feature information of each of the Token sequence; inputting the feature information of each of the Token sequence into a pre-trained Token length prediction model, predicting the length of the feature information of each of the Token sequence, and outputting the length information of each of the Token sequence; inputting the length information of each of the Token sequence into a cognitive interaction network, and outputting target length information of each of the Token sequence based on reference Token length information and the length information of each of the Token sequence; inputting the target length information of each of the Token sequence and each of the Token sequence into the cognitive model, predicting the answer, and outputting a response Token for each of the question texts; inputting the response Token of each of the question texts into the encoder network, and outputting a target response text for each of the question texts. The Token length prediction model is used to quickly and accurately determine the target length information of the Token sequence, thereby generating the target answer text based on the target length information of the Token sequence and the Token sequence of each question text, thereby improving the accuracy and efficiency of answer text generation.

[0041] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

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

[0044] Figure 2One of the structural schematic diagrams of a question-answer processing device provided in an embodiment of the present application;

[0045] Figure 3 A second structural diagram of a question-and-answer processing device provided in an embodiment of the present application;

[0046] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work belongs to the scope of protection of the present application.

[0048] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0049] In order to enable those skilled in the art to use the contents of this application, the following implementation method is given in combination with the specific application scenario of "processing questions and answers". For those skilled in the art, the general principles defined here can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application.

[0050] The following methods, devices, electronic devices or computer-readable storage media of the embodiments of the present application can be applied to any scenario where questions and answers need to be processed. The embodiments of the present application are not limited to specific application scenarios. Any scheme using a question and answer processing method, device, electronic device and storage medium provided by the embodiments of the present application is within the scope of protection of this application.

[0051] First, the application scenarios to which this application is applicable are introduced. This application can be applied in the field of artificial intelligence technology.

[0052] After research, it was found that the current text generation model mainly consists of three architectures: Encoder-Decoder architecture, CausalDecoder architecture, and Prefix Decoder architecture. However, no matter which architecture is used, unidirectional attention is used to generate tokens one by one when generating output tokens, and finally convert them into corresponding text. For the above process of generating new tokens, kv_cache technology is usually used to store the KV matrix corresponding to historical tokens to reduce the amount of calculation and accelerate the reasoning process. However, the use of kv_cache technology introduces a problem: the KV matrix generated by the current token needs to be spliced ​​with the KV matrix of the historical token, which will take up a lot of memory bandwidth, reduce the reasoning efficiency, and when multiple questions and answers are generated at the same time, it will cause multiple reply answers to fail to generate. Therefore, how to improve the accuracy and efficiency of question and answer processing has become a technical issue that cannot be underestimated.

[0053] Based on this, an embodiment of the present application provides a question and answer processing method, which utilizes a Token length prediction model to quickly and accurately determine the target length information of a Token sequence, thereby generating a target answer text based on the target length information of the Token sequence and the Token sequence of each question text, thereby improving the accuracy and efficiency of answer text generation.

[0054] See also Figure 1 , Figure 1 This is a flow chart of a question-answering processing method provided in an embodiment of the present application. Figure 1 As shown in , the question-answering processing method provided in the embodiment of the present application includes:

[0055] S101: Input multiple question texts into the encoder network, encode each question text, and output a Token sequence corresponding to each question text.

[0056] In this step, multiple question texts are input into the encoder network, each question text is encoded, and a Token sequence corresponding to each question text is output.

[0057] Here, the type of question text may be common sense type questions or other types of questions, and this section does not limit the question type.

[0058] In a possible implementation, the inputting of multiple question texts into the encoder network, encoding each of the question texts, and outputting a Token sequence corresponding to each of the question texts include:

[0059] A: Input a plurality of the question texts into the encoder network, process each of the question texts based on a byte pair encoding algorithm, and determine a vocabulary for each of the question texts.

[0060] Here, multiple question texts are input into the encoder network, each question text is processed according to the byte pair encoding algorithm, and the vocabulary of each question text is determined.

[0061] B: Convert the vocabulary of each question text to determine the Token sequence corresponding to each question text.

[0062] Here, the vocabulary of each question text is converted to determine the Token sequence corresponding to each question text.

[0063] Among them, the role of the encoder network is to convert the user's question text into a corresponding Token sequence (called Token in the model) using a vocabulary.

[0064] Here, the byte pair encoding algorithm is to split the word into character granularity, uniformly calculate the frequency of each adjacent byte pair, merge the adjacent byte pairs with the highest frequency into new subwords, and repeat the merging until the set word list size is reached. In this solution, in addition to using the byte pair encoding algorithm to encode the question text, the WordPiece method or the Sentence Piece method can also be used for processing, which is not limited in this part.

[0065] S102: Input the Token sequence corresponding to each of the question texts into the cognitive model, perform feature extraction on the Token sequence of each of the question texts, and output feature information of each of the Token sequence.

[0066] In this step, the Token sequence corresponding to each question text is input into the cognitive model, the features of the Token sequence of each question text are extracted, and the feature information of each Token sequence is output.

[0067] S103: Input the feature information of each Token sequence into a pre-trained Token length prediction model, perform length prediction on the feature information of each Token sequence, and output the length information of each Token sequence.

[0068] In this step, the feature information of each Token sequence is input into the pre-trained Token length prediction model, the length of the feature information of each Token sequence is predicted, and the length information of each Token sequence is output.

[0069] Among them, length prediction is to determine the length corresponding to the Token sequence. The determined length information can avoid the situation where multiple questions and answers may show insufficient storage in the process of generating reply text due to uncertainty about the length of the answer generated for each question when generating multiple questions and answers at the same time.

[0070] In a possible implementation manner, the Token length prediction model is determined by the following steps:

[0071] I: Obtain sample feature information of multiple sample Token sequences and label information of each of the sample Token sequences.

[0072] Here, sample feature information of multiple sample Token sequences and label information of each sample Token sequence are obtained.

[0073] Among them, sample question texts from different evaluation sets of the current cognitive model are collected, and the corresponding feature-label pairs are generated through the cognitive model, and the generated data are divided into training set, validation set and test set in the ratio of 8:1:1.

[0074] II: Input the sample feature information of each sample Token sequence into the delayed neural model, perform length prediction on the sample feature information of the sample Token sequence, and determine the predicted length of the sample Token sequence.

[0075] Here, the sample feature information of each sample Token sequence is input into the delayed neural model, the length of the sample feature information of the sample Token sequence is predicted, and the predicted length of the sample Token sequence is determined.

[0076] III: Based on each of the predicted lengths and the label information of each of the sample Token sequences, a loss value is determined; based on the loss value, the delay neural model is iteratively trained until the iterative training is completed to determine the Token length prediction model.

[0077] Here, the loss value is determined according to each predicted length and the label information of each sample Token sequence, and the delay neural model is iteratively trained according to the loss value until the iterative training is completed to determine the Token length prediction model.

[0078] In a possible implementation manner, the iterative training of the delay neural model based on the loss value until the iterative training is completed to determine the Token length prediction model includes:

[0079] (1): If the loss value is less than a preset loss threshold, the iterative training of the delay neural model is stopped, and the delay neural model is used to determine the token length prediction model;

[0080] (2): If the loss value is greater than the preset loss threshold, the network parameters of the delay neural model are changed and the delay neural model is iteratively trained until the loss value is less than the preset loss threshold. The training is stopped and the delay neural model is used to determine the Token length prediction model.

[0081] Here, we build a TDNN network, use the prepared training data, use Adam / Adamw as the optimizer, and use cross entropy as the loss function for training, and save the optimal model for inference.

[0082] In this solution, the length of the Token sequence corresponding to the question text is predicted, which can effectively reduce the memory bandwidth requirements during the cognitive model reasoning process and will not cause reasoning failures due to memory competition under multiple concurrency. In addition, a user setting interface is provided to adjust the Token length generated by the model.

[0083] Among them, TDNN (Time Delay Neural Network) is a time delay neural network used to process time series data. It can capture time-related information in sequence data and can learn and predict future data. The TDNN network is mainly composed of an input layer, a hidden layer, and an output layer. The input layer receives time series data, and the neurons in the hidden layer have different time delay windows and process data at different time steps. Each neuron receives input from the previous layer and performs convolution operations using a weight matrix of a fixed window, and then processes it through a nonlinear activation function. Depending on the task, the output layer can be a regression problem or a classification problem. The TDNN network has a wide range of applications in speech recognition, natural language processing, and other fields. It can process input sequences of different lengths and has the characteristics of time invariance and position invariance. In addition, the TDNN network can also extract more advanced features by adding convolutional layers and pooling layers to further improve the performance of the model. Since the TDNN network has a simple structure, can effectively process contextual information, has high parallelism and fast speed, and will not affect the performance of the entire reasoning process, the TDNN network structure is preferred. Others such as RNN structure networks and Transformer structure networks are also suitable for predicting the output Token length.

[0084] S104: Input the length information of each of the Token sequences into the cognitive interaction network, and output the target length information of each of the Token sequences based on the reference Token length information and the length information of each of the Token sequences.

[0085] In this step, the length information of each Token sequence is input into the cognitive interaction network, and the target length information of each Token sequence is output based on the reference Token length information and the length information of each Token sequence.

[0086] In a possible implementation manner, inputting the length information of each Token sequence into a cognitive interaction network of a question prediction system, and outputting target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, includes:

[0087] a: Input the length information of each of the Token sequences into the cognitive interaction network to determine the reference Token length information corresponding to each of the question texts.

[0088] Here, the length information of each Token sequence is input into the cognitive interaction network to determine the reference Token length information corresponding to each question text.

[0089] Here, the reference Token length information corresponding to the question text is preset.

[0090] b: For any of the question texts, detect whether the reference Token length information of the question text is greater than the length information of the Token sequence of the question text.

[0091] Here, for any question text, it is detected whether the reference Token length information of the question text is greater than the length information of the Token sequence of the question text.

[0092] c: If yes, the reference Token length information is used as the target length information of the Token sequence; if no, the length information of the Token sequence is used as the target length information of the Token sequence.

[0093] Here, if yes, the reference Token length information is used as the target length information of the Token sequence; if no, the length information of the Token sequence is used as the target length information of the Token sequence.

[0094] Among them, TDNN and other neural network-based models are used to predict the output Token length. In order to prevent the probability of the prediction result deviating from the actual Token length, a cognitive interaction network is designed so that the user can modify the output Token length.

[0095] In a possible implementation manner, inputting the length information of each Token sequence into the cognitive interaction network, and outputting the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, further includes:

[0096] For any of the question texts, if there is no reference Token length information for the question text, the length information of the Token sequence is determined as the target length information of the Token sequence of the question text.

[0097] Here, for any question text, if there is no reference Token length information for the question text, the length information of the Token sequence is determined as the target length information of the Token sequence of the question text.

[0098] Among them, in the cognitive interaction network, if the user does not set the output Token length, the length predicted by the model is used; if the user sets the output Token length, then if the set Token length is less than the length predicted by the model, the length predicted by the model is used; if it is greater than the length predicted by the model, the length set by the user is used.

[0099] S105: Input the target length information of each Token sequence and each Token sequence into the cognitive model, perform answer prediction, and output the response Token of each question text.

[0100] In this step, the target length information of each Token sequence and each Token sequence are input into the cognitive model, the answer is predicted, and the response Token of each question text is output.

[0101] Among them, the cognitive model continuously iterates and generates the output answer Token according to the Token sequence (Token sequence) of the input question text until the end Token is encountered or the preset Token length is reached and the iterative generation stops.

[0102] In this solution, sufficient kv_cache cache is applied in advance to avoid the problem of excessive memory bandwidth caused by frequent kv_cache splicing.

[0103] S106: Input the answer Token of each question text into the encoder network, and output the target answer text of each question text.

[0104] In this step, the answer Token of each question text is input into the encoder network, and the target answer text of each question text is output.

[0105] The step of inputting the answer Token of each question text into the encoder network and outputting the target answer text of each question text comprises:

[0106] The response Token of each question text is encoded based on a byte pair encoding algorithm to generate a target response text for each question text.

[0107] Here, each response token is encoded according to a byte pair encoding algorithm to generate a target response text for each question text.

[0108] An embodiment of the present application provides a question-answering processing method, which includes: inputting multiple question texts into an encoder network, encoding each of the question texts, and outputting a Token sequence corresponding to each of the question texts; inputting the Token sequence corresponding to each of the question texts into a cognitive model, extracting features from the Token sequence of each of the question texts, and outputting feature information of each of the Token sequences; inputting the feature information of each of the Token sequences into a pre-trained Token length prediction model, predicting the length of the feature information of each of the Token sequences, and outputting the length information of each of the Token sequences; inputting the length information of each of the Token sequences into a cognitive interaction network, and outputting target length information of each of the Token sequences based on reference Token length information and the length information of each of the Token sequences; inputting the target length information of each of the Token sequences and each of the Token sequences into the cognitive model, predicting the answer, and outputting a response Token for each of the question texts; inputting the response Token of each of the question texts into the encoder network, and outputting a target response text for each of the question texts. The Token length prediction model is used to quickly and accurately determine the target length information of the Token sequence, thereby generating the target answer text based on the target length information of the Token sequence and the Token sequence of each question text, thereby improving the accuracy and efficiency of answer text generation.

[0109] See also Figure 2 , Figure 3 , Figure 2 One of the structural schematic diagrams of a question-answer processing device provided in an embodiment of the present application; Figure 3 This is a second structural diagram of a question-answering processing device provided in an embodiment of the present application. Figure 2 As shown in , the question-answer processing device 200 includes:

[0110] The encoding module 210 is used to input multiple question texts into the encoder network, encode each question text, and output a token sequence corresponding to each question text;

[0111] The feature extraction module 220 is used to input the Token sequence corresponding to each question text into the cognitive model, perform feature extraction on the Token sequence of each question text, and output feature information of each Token sequence;

[0112] The first prediction module 230 is used to input the feature information of each Token sequence into a pre-trained Token length prediction model, perform length prediction on the feature information of each Token sequence, and output the length information of each Token sequence;

[0113] A length determination module 240, configured to input the length information of each of the Token sequences into the cognitive interaction network, and output the target length information of each of the Token sequences based on the reference Token length information and the length information of each of the Token sequences;

[0114] The second prediction module 250 is used to input the target length information of each Token sequence and each Token sequence into the cognitive model, perform answer prediction, and output the answer Token of each question text;

[0115] The answer generation module 260 is used to input the answer Token of each question text into the encoder network and output the target answer text of each question text.

[0116] Furthermore, when the encoding module 210 is used to input a plurality of question texts into the encoder network, encode each of the question texts, and output a Token sequence corresponding to each of the question texts, the encoding module 210 is specifically used to:

[0117] Inputting a plurality of the question texts into the encoder network, processing each of the question texts based on a byte pair encoding algorithm, and determining a vocabulary for each of the question texts;

[0118] The vocabulary of each question text is converted to determine the Token sequence corresponding to each question text.

[0119] Further, when the length determination module 240 is used to input the length information of each Token sequence into the cognitive interaction network and output the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, the length determination module 240 is specifically used to:

[0120] Inputting the length information of each of the Token sequences into the cognitive interaction network to determine the reference Token length information corresponding to each of the question texts;

[0121] For any of the question texts, detecting whether the reference Token length information of the question text is greater than the length information of the Token sequence of the question text;

[0122] If yes, the reference Token length information is used as the target length information of the Token sequence;

[0123] If not, the length information of the Token sequence is used as the target length information of the Token sequence.

[0124] Further, when the length determination module 240 is used to input the length information of each Token sequence into the cognitive interaction network and output the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, the length determination module 240 is specifically used to:

[0125] For any of the question texts, if there is no reference Token length information for the question text, the length information of the Token sequence is determined as the target length information of the Token sequence of the question text.

[0126] Furthermore, when the answer generation module 260 is used to input the answer Token of each question text into the encoder network and output the target answer text of each question text, the answer generation module 260 is specifically used to:

[0127] The response Token of each question text is encoded based on a byte pair encoding algorithm to generate a target response text for each question text.

[0128] Further, such as Figure 3 As shown, the question-answering processing device 200 further includes a model training module 270, which is used to determine the question prediction model through the following steps:

[0129] The Token length prediction model is determined by the following steps:

[0130] Obtain sample feature information of multiple sample Token sequences and label information of each of the sample Token sequences;

[0131] Inputting the sample feature information of each of the sample Token sequences into the delayed neural model, predicting the length of the sample feature information of the sample Token sequence, and determining the predicted length of the sample Token sequence;

[0132] Determine a loss value based on each of the predicted lengths and the label information of each of the sample Token sequences;

[0133] The delay neural model is iteratively trained based on the loss value until the iterative training is completed to determine the Token length prediction model.

[0134] Further, when the model training module 270 is used to iteratively train the delay neural model based on the loss value until the iterative training is completed to determine the Token length prediction model, the model training module 270 is specifically used to:

[0135] If the loss value is less than a preset loss threshold, the iterative training of the delay neural model is stopped, and the delay neural model is used to determine the Token length prediction model;

[0136] If the loss value is greater than a preset loss threshold, the network parameters of the delay neural model are changed and the delay neural model is iteratively trained until the loss value is less than the preset loss threshold, and the training is stopped to determine the Token length prediction model using the delay neural model.

[0137] An embodiment of the present application provides a question-answer processing device, which includes: an encoding module, which is used to input multiple question texts into an encoder network, encode each of the question texts, and output a Token sequence corresponding to each of the question texts; a feature extraction module, which is used to input the Token sequence corresponding to each of the question texts into a cognitive model, extract features from the Token sequence of each of the question texts, and output feature information of each of the Token sequences; a first prediction module, which is used to input the feature information of each of the Token sequences into a pre-trained Token length prediction model, predict the length of the feature information of each of the Token sequences, and output the length information of each of the Token sequences; a length determination module, which is used to input the length information of each of the Token sequences into a cognitive interaction network, and output the target length information of each of the Token sequences based on the reference Token length information and the length information of each of the Token sequences; a second prediction module, which is used to input the target length information of each of the Token sequences and each of the Token sequences into the cognitive model, predict the answer, and output the answer Token of each of the question texts; and an answer generation module, which is used to input the answer Token of each of the question texts into the encoder network, and output the target answer text of each of the question texts. The Token length prediction model is used to quickly and accurately determine the target length information of the Token sequence, thereby generating the target answer text based on the target length information of the Token sequence and the Token sequence of each question text, thereby improving the accuracy and efficiency of answer text generation.

[0138] See also Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown in , the electronic device 400 includes a processor 410 , a memory 420 and a bus 430 .

[0139] The memory 420 stores machine-readable instructions executable by the processor 410. When the electronic device 400 is running, the processor 410 communicates with the memory 420 via the bus 430. When the machine-readable instructions are executed by the processor 410, the above-mentioned Figure 1 The specific implementation of the steps of the question and answer processing method in the method embodiment shown can be found in the method embodiment, and will not be repeated here.

[0140] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1The specific implementation of the steps of the question and answer processing method in the method embodiment shown can be found in the method embodiment, and will not be repeated here.

[0141] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0142] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0143] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0144] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0145] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0146] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A question-answering processing method, characterized in that: The question-answering processing method comprises: Input multiple question texts into the encoder network, encode each question text, and output the Token sequence corresponding to each question text; Input the Token sequence corresponding to each of the question texts into the cognitive model, perform feature extraction on the Token sequence of each of the question texts, and output feature information of each of the Token sequence; Input the feature information of each Token sequence into a pre-trained Token length prediction model, perform length prediction on the feature information of each Token sequence, and output the length information of each Token sequence; Inputting the length information of each of the Token sequences into the cognitive interaction network, and outputting the target length information of each of the Token sequences based on the reference Token length information and the length information of each of the Token sequences; Input the target length information of each Token sequence and each Token sequence into the cognitive model, perform answer prediction, and output the answer Token of each question text; Inputting the answer Token of each question text into the encoder network, and outputting the target answer text of each question text; The step of inputting the length information of each Token sequence into the cognitive interaction network and outputting the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence comprises: Inputting the length information of each of the Token sequences into the cognitive interaction network to determine the reference Token length information corresponding to each of the question texts; For any of the question texts, detecting whether the reference Token length information of the question text is greater than the length information of the Token sequence of the question text; If yes, the reference Token length information is used as the target length information of the Token sequence; If not, the length information of the Token sequence is used as the target length information of the Token sequence.

2. The question-answer processing method according to claim 1, characterized in that: The step of inputting multiple question texts into the encoder network, encoding each question text, and outputting a token sequence corresponding to each question text includes: Inputting a plurality of the question texts into the encoder network, processing each of the question texts based on a byte pair encoding algorithm, and determining a vocabulary for each of the question texts; The vocabulary of each question text is converted to determine the Token sequence corresponding to each question text.

3. The question-answer processing method according to claim 1, characterized in that: The step of inputting the length information of each Token sequence into the cognitive interaction network, and outputting the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, further comprises: For any of the question texts, if there is no reference Token length information for the question text, the length information of the Token sequence is determined as the target length information of the Token sequence of the question text.

4. The question-answer processing method according to claim 1, characterized in that: The step of inputting the answer Token of each question text into the encoder network and outputting the target answer text of each question text comprises: The response Token of each question text is encoded based on a byte pair encoding algorithm to generate a target response text for each question text.

5. The question-answer processing method according to claim 1, characterized in that: The Token length prediction model is determined by the following steps: Obtain sample feature information of multiple sample Token sequences and label information of each of the sample Token sequences; Inputting the sample feature information of each of the sample Token sequences into the delayed neural model, predicting the length of the sample feature information of the sample Token sequence, and determining the predicted length of the sample Token sequence; Determine a loss value based on each of the predicted lengths and the label information of each of the sample Token sequences; The delay neural model is iteratively trained based on the loss value until the iterative training is completed to determine the Token length prediction model.

6. The question-answer processing method according to claim 5, characterized in that: The iterative training of the delay neural model based on the loss value until the iterative training is completed to determine the Token length prediction model includes: If the loss value is less than a preset loss threshold, the iterative training of the delay neural model is stopped, and the delay neural model is used to determine the Token length prediction model; If the loss value is greater than a preset loss threshold, the network parameters of the delay neural model are changed and the delay neural model is iteratively trained until the loss value is less than the preset loss threshold, and the training is stopped to determine the Token length prediction model using the delay neural model.

7. A question-answer processing device, characterized in that: The question-answer processing device comprises: The encoding module is used to input multiple question texts into the encoder network, encode each question text, and output a Token sequence corresponding to each question text; A feature extraction module is used to input the Token sequence corresponding to each of the question texts into the cognitive model, perform feature extraction on the Token sequence of each of the question texts, and output feature information of each of the Token sequence; The first prediction module is used to input the feature information of each Token sequence into a pre-trained Token length prediction model, perform length prediction on the feature information of each Token sequence, and output the length information of each Token sequence; A length determination module, used to input the length information of each Token sequence into the cognitive interaction network, and output the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence; A second prediction module is used to input the target length information of each Token sequence and each Token sequence into the cognitive model, perform answer prediction, and output a response Token for each question text; An answer generation module, used for inputting the answer Token of each question text into the encoder network, and outputting the target answer text of each question text; When the length determination module is used to input the length information of each Token sequence into the cognitive interaction network and output the target length information of each Token sequence based on the reference Token length information and the length information of each Token sequence, the length determination module is specifically used to: Inputting the length information of each of the Token sequences into the cognitive interaction network to determine the reference Token length information corresponding to each of the question texts; For any of the question texts, detecting whether the reference Token length information of the question text is greater than the length information of the Token sequence of the question text; If yes, the reference Token length information is used as the target length information of the Token sequence; If not, the length information of the Token sequence is used as the target length information of the Token sequence.

8. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate via the bus, and the machine-readable instructions are executed by the processor to execute the steps of the question-and-answer processing method as described in any one of claims 1 to 6.

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