Text generation model training method, text generation method and answer generation method

By unifying the retrieval network layer and the generation network layer in the machine learning model and conducting joint training, the problem of insufficient efficiency and accuracy of the existing question and answer framework is solved, and efficient and accurate text generation is achieved.

CN118364060BActive Publication Date: 2024-09-13ALIBABA (CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410793696.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-13
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

The existing question and answer framework has low processing efficiency and poor processing accuracy, resulting in insufficient efficiency and accuracy of text generation tasks in human-computer interaction.

Method used

By unifying the model base of the retrieval network layer and the generation network layer in the machine learning model, using the first loss function and the second loss function for joint training, the model parameters are optimized to improve the processing performance and accuracy of the text generation model.

Benefits of technology

It reduces model calculation consumption and response delay time, improves the processing efficiency and accuracy of the text generation model, and ensures more efficient text generation performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118364060B
    Figure CN118364060B
Patent Text Reader

Abstract

The embodiments of this specification relate to the field of computer technology, and provide a text generation model training method, a text generation method, and an answer generation method, wherein the text generation model training method includes: determining a machine learning model to be trained, and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer; processing the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function; determining a target loss function according to the first loss function and the second loss function; adjusting the model parameters of the machine learning model according to the target loss function to obtain a trained text generation model, wherein the text generation model is used to perform the text generation task. Joint training of the retrieval network layer and the generation network layer is achieved to ensure the processing performance and processing accuracy of the text generation model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a text generation model training method, a text generation method, and an answer generation method. Background Art

[0002] Human-computer interaction refers to the process of information exchange between people and computers using a certain dialogue language and a certain interactive method. With the development of human-computer interaction technology, more and more intelligent products based on human-computer interaction have emerged. For example, users can use human-computer interaction technology to ask customized questions and answer questions raised by users. Usually, fast question-answering and search can be performed based on the framework of retrievers and generators. However, this framework has low processing efficiency and poor processing accuracy. Therefore, an effective technical solution is urgently needed to solve the above problems. Summary of the invention

[0003] In view of this, an embodiment of this specification provides a text generation model training method. One or more embodiments of this specification also involve a text generation model training device, a text generation method, a text generation device, an answer generation method, an answer generation device, a computing device, a computer-readable storage medium, and a computer program product to solve the technical defects of low processing efficiency and poor processing accuracy of the question-answering framework in the prior art.

[0004] According to a first aspect of an embodiment of this specification, a text generation model training method is provided, comprising:

[0005] Determining a machine learning model to be trained and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer;

[0006] Processing the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function;

[0007] Determine a target loss function according to the first loss function and the second loss function;

[0008] According to the target loss function, the model parameters of the machine learning model are adjusted to obtain a trained text generation model, wherein the text generation model is used to perform the text generation task.

[0009] According to a second aspect of an embodiment of this specification, a text generation model training device is provided, comprising:

[0010] A first determination module is configured to determine a machine learning model to be trained and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer;

[0011] A processing module, configured to process the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function;

[0012] A second determination module is configured to determine a target loss function according to the first loss function and the second loss function;

[0013] The adjustment module is configured to adjust the model parameters of the machine learning model according to the target loss function to obtain a trained text generation model, wherein the text generation model is used to perform the text generation task.

[0014] According to a third aspect of the embodiments of this specification, a text generation method is provided, including:

[0015] determining a reference text and determining target questions for the reference text;

[0016] Inputting the target question and the reference text into a text generation model to obtain a target text corresponding to the target question;

[0017] Among them, the text generation model includes a retrieval network layer and a generation network layer. The retrieval network layer is used to retrieve a reference text segment associated with the target question in the reference text, and the generation network layer is used to generate a target text corresponding to the target question based on the reference text segment. The text generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0018] According to a fourth aspect of the embodiments of this specification, there is provided a text generation device, including:

[0019] A determination module, configured to determine a reference text and determine a target question for the reference text;

[0020] An input module is configured to input the target question and the reference text into a text generation model to obtain a target text corresponding to the target question;

[0021] Among them, the text generation model includes a retrieval network layer and a generation network layer. The retrieval network layer is used to retrieve a reference text segment associated with the target question in the reference text, and the generation network layer is used to generate a target text corresponding to the target question based on the reference text segment. The text generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0022] According to a fifth aspect of the embodiments of this specification, a method for generating an answer is provided, including:

[0023] receiving a reference audio and a target question for the reference audio sent by a client;

[0024] Converting the reference audio to obtain a reference text corresponding to the reference audio;

[0025] Inputting the target question and the reference text into an answer generation model to obtain a target answer corresponding to the target question;

[0026] Sending the target answer to the client;

[0027] Among them, the answer generation model includes a retrieval network layer and a generation network layer, the retrieval network layer is used to retrieve the reference text segment associated with the target question in the reference text, and the generation network layer is used to generate the target answer corresponding to the target question based on the reference text segment. The answer generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0028] According to a sixth aspect of an embodiment of this specification, there is provided an answer generating device, including:

[0029] A receiving module, configured to receive a reference audio and a target question for the reference audio sent by a client;

[0030] A conversion module is configured to convert the reference audio to obtain a reference text corresponding to the reference audio;

[0031] An input module is configured to input the target question and the reference text into an answer generation model to obtain a target answer corresponding to the target question;

[0032] A sending module, configured to send the target answer to the client;

[0033] Among them, the answer generation model includes a retrieval network layer and a generation network layer, the retrieval network layer is used to retrieve the reference text segment associated with the target question in the reference text, and the generation network layer is used to generate the target answer corresponding to the target question based on the reference text segment. The answer generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0034] According to a seventh aspect of an embodiment of this specification, there is provided a computing device, including:

[0035] Memory and processor;

[0036] The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the above method are implemented.

[0037] According to an eighth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, and the steps of the above method are implemented when the computer program / instruction is executed by a processor.

[0038] According to a ninth aspect of the embodiments of this specification, there is provided a computer program product, comprising a computer program / instruction, which implements the steps of the above method when executed by a processor.

[0039] An embodiment of the present specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model computing consumption and reducing the response delay time, further improving the model processing efficiency. In addition, when training the machine learning model including the retrieval network layer and the generation network layer, the target loss function is determined by the first loss function and the second loss function, and the model parameters of the machine learning model are adjusted based on the target loss function, so as to realize the joint training of the retrieval network layer and the generation network layer, and further ensure the processing performance and processing accuracy of the text generation model. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a schematic diagram of an application scenario of a text generation model in a text generation model training method provided by an embodiment of this specification;

[0041] Figure 2 is a flowchart of a text generation model training method provided by an embodiment of this specification;

[0042] Figure 3 It is a structural diagram of a text generation model in a text generation model training method provided by an embodiment of this specification;

[0043] Figure 4 is a processing flow chart of a text generation model training method provided by an embodiment of this specification;

[0044] Figure 5 It is a structural schematic diagram of a text generation model training device provided by an embodiment of this specification;

[0045] Figure 6 is a flow chart of a text generation method provided by an embodiment of this specification;

[0046] Figure 7It is a structural schematic diagram of a text generation device provided by an embodiment of this specification;

[0047] Figure 8 is a flow chart of an answer generation method provided by one embodiment of this specification;

[0048] Fig. 9 is a schematic diagram of the structure of an answer generation device provided by an embodiment of this specification;

[0049] Fig.10 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0050] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0051] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0052] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0053] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0054] In one or more embodiments of this specification, a large model refers to a deep learning model with large-scale model parameters, which usually contains hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than 10 trillion model parameters. A large model can also be called a foundation model / foundation model. The large model is pre-trained with large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as a large-scale language model (LLM), a multi-modal pre-training model, etc.

[0055] When the big model is used in practice, only a small number of samples are needed to fine-tune the pre-trained model and it can be applied to different tasks. The big model can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image caption (IC), image generation, as well as natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. The main application scenarios of the big model include digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.

[0056] First, the terms involved in one or more embodiments of this specification are explained.

[0057] RAG: Retrieval-Augmented Generation, is a general framework that uses retrieval-augmented generation. That is, when answering questions or generating text, the large model will first retrieve relevant information from a large number of documents, and then answer or generate text based on the retrieved information, thereby improving the quality of the answer, rather than leaving it to the large model.

[0058] DPO: DirectPreferenceOptimization, direct preference optimization algorithm, this algorithm implicitly optimizes the same goal as RLHF (Reinforcement Learning from Human Feedback) (reward maximization with KL divergence constraint), but is simple to implement and easy to train, and does not require explicit reward modeling or reinforcement learning.

[0059] JointTraining: refers to training a model to complete multiple tasks at the same time, usually by sharing parameters or using a multi-task learning framework. Joint training can help the model transfer knowledge between different tasks and improve the performance of each task.

[0060] Contrasitive Learning: Contrasitive learning is a machine learning technique where the algorithm learns to distinguish between similar and dissimilar data points. The goal of contrastive learning is to learn a representation of the data that captures the underlying structure and relationships between different data points. In contrastive learning, the algorithm is trained to maximize the similarity between similar data points and minimize the similarity between dissimilar data points.

[0061] In practical applications, the RAG framework can usually be used to generate text for custom questions and answers based on independent retrieval and generation stages. However, splitting the retrieval task and the generation task into two independent tasks lacks the use and reflection of global knowledge, resulting in poor retrieval results. In addition, the independence of each other will also cause delays in the response of the large model, resulting in reduced efficiency and reduced retrieval accuracy. When the documents retrieved by the retriever are not relevant to the questions asked by the user, the large model will output incorrect answers, resulting in poor robustness of the model. In some cases, such as when the questions asked by the user are simple, the large model can answer directly, but because it is based on the RAG framework, the large model must generate answers based on the retrieved documents, which is easy to introduce noise. Or, for example, when the questions asked by the user need to be retrieved but the retrieval is inaccurate, it will also interfere with the generation of the answer. Therefore, an effective technical solution is urgently needed to solve the above problems.

[0062] In this specification, a text generation model training method is provided. This specification also involves a text generation model training device, a text generation method, a text generation device, an answer generation method, an answer generation device, a computing device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.

[0063] See also Figure 1 , Figure 1 A schematic diagram of an application scenario of a text generation model in a text generation model training method provided according to an embodiment of the present specification is shown. The specific steps of the text generation model training method are as follows.

[0064] Determining a machine learning model to be trained and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer;

[0065] Processing the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function;

[0066] Determine a target loss function according to the first loss function and the second loss function;

[0067] According to the target loss function, the model parameters of the machine learning model are adjusted to obtain a trained text generation model, wherein the text generation model is used to perform the text generation task.

[0068] An embodiment of the present specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model computing consumption and reducing the response delay time, further improving the model processing efficiency. In addition, when training the machine learning model including the retrieval network layer and the generation network layer, the target loss function is determined by the first loss function and the second loss function, and the model parameters of the machine learning model are adjusted based on the target loss function, so as to realize the joint training of the retrieval network layer and the generation network layer, and further ensure the processing performance and processing accuracy of the text generation model.

[0069] like Figure 1 As shown, Figure 1 It includes a terminal side device 102 and a cloud side device 104.

[0070] During specific implementation, when the text generation model performs a text generation task, the user can upload the meeting record audio and the question "What suggestions were put forward in the meeting" for the meeting record audio through the terminal device 102. The terminal device 102 can send the meeting record audio and the question raised by the user to the cloud device 104. The cloud device 104 can convert the meeting record audio into text, and input the question and text into the text generation model. According to the retrieval network layer of the text generation model, the text segment associated with the question is retrieved from the text, and according to the generation network layer of the text generation model, the answer corresponding to the question "The suggestions put forward in the meeting include the following: Suggestion 1... Suggestion 2..." is generated. The cloud device 104 can send the answer to the terminal device 102, and display it to the user through the display interface of the terminal device 102, thereby realizing customized Q&A.

[0071] The end-side device 102 may include a browser, an APP (Application), or a web application such as an H5 (Hyper Text Markup Language 5, version 5 of Hypertext Markup Language) application, or a light application (also known as a mini-program, a lightweight application) or a cloud application, etc. The end-side device may be based on a software development kit (SDK) of the corresponding service provided by the server, such as based on the real-time communication (RTC, Real Time Communication) SDK development and acquisition. The end-side device may be deployed in an electronic device and needs to rely on the device to run or some APPs in the device to run. The electronic device may have a display screen and support information browsing, such as a personal mobile terminal such as a mobile phone, a tablet computer, a personal computer, etc. Various other types of applications may also be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0072] The cloud-side device 104 can be understood as a server that provides various services, including physical servers and cloud servers, such as a server that provides communication services for multiple clients, a server for background training that supports the model used on the client, and a server that processes the data sent by the client. It should be noted that the cloud-side device 104 can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The cloud-side device 104 can also be a server for a distributed system, or a server combined with a blockchain. The cloud-side device 104 can also be a cloud server for basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDNs), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.

[0073] It is worth noting that the image processing method provided in the embodiments of this specification can be executed by the cloud-side device 104. In other embodiments of this specification, the image processing model can be deployed in the terminal-side device 102, so that the terminal-side device 102 can also have similar functions as the cloud-side device 104, thereby executing the image processing method provided in the embodiments of this specification; in other embodiments, the image processing method provided in the embodiments of this specification can also be executed jointly by the terminal-side device 102 and the cloud-side device 104.

[0074] See also Figure 2 , Figure 2A flowchart of a text generation model training method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0075] Step 202: Determine a machine learning model to be trained and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer.

[0076] Specifically, the text generation model training method provided in the embodiments of this specification can be applied to the field of human-computer interaction. In the field of human-computer interaction, the corresponding machine learning model can be trained according to the specific text generation task. The text generation task can be, for example, a task of generating text by asking questions about the input audio and video, or a task of generating text by asking questions about the input text, or a task of generating text by asking questions about the input picture, or a task of generating text by asking questions about the user. The embodiments of this specification do not limit the text generation tasks. In one embodiment of this specification, the text generation task can be an answer generation task, and accordingly, the text generation model can also be an answer generation model.

[0077] Among them, the retrieval network layer can be used for vector representation, and the generation network layer can be used to perform generation tasks.

[0078] Based on this, the machine learning model to be trained and the training data associated with the text generation task can be determined. The machine learning model to be trained includes a retrieval network layer and a generation network layer.

[0079] Furthermore, the machine learning model to be trained also includes a feature processing network layer, which performs feature processing on the training data to obtain a feature vector, and outputs the feature vector to the retrieval network layer and the generation network layer respectively, the retrieval network layer processes the training data according to the feature vector, and the generation network layer processes the training data according to the feature vector.

[0080] Specifically, the retrieval network layer and the generation network layer can share the feature processing network layer, so that the retrieval network layer and the generation network layer can be based on the same model base, thereby ensuring timely response when processing text generation tasks. The feature processing network layer can perform feature encoding processing on the input training data to obtain feature vectors, and output the feature vectors to the retrieval network layer and the generation network layer respectively, so as to facilitate the subsequent retrieval network layer and the generation network layer to perform text generation task processing. In specific implementation, the retrieval network layer can process the sample question according to the feature vector to obtain the predicted text corresponding to the sample question, and the generation network layer can process the sample question and the predicted text according to the feature vector to obtain the predicted answer corresponding to the sample question.

[0081] In addition, after obtaining the feature vector output by the feature processing network layer, the feature vector can also be cached so that the feature vector can be used for both the retrieval and generation stages at the same time.

[0082] In practical applications, see Figure 3 , Figure 3 FIG. 1 shows a schematic diagram of the structure of a text generation model in a text generation model training method provided according to an embodiment of the present specification. Figure 3 As shown, the text generation model includes a feature processing network layer 302, a retrieval network layer 304 and a generation network layer 306. The feature processing network layer 302 may include multiple network layers. The feature processing network layer 302 may encode the question and text input into the text generation model, obtain the feature vector obtained after encoding, and input the feature vector into the retrieval network layer 304 and the generation network layer 306 respectively. The retrieval network layer 304 may determine the text segment associated with the question from the text, and input the text segment into the generation network layer 306. The generation network layer 306 may generate an answer based on the feature vector and the text segment. In practical applications, the feature processing network layer may be a decoder-only architecture of a Transformer, which has powerful context modeling and generation capabilities.

[0083] In addition, during specific implementation, the text generation model also includes a sorting network layer and a judgment network layer. The retrieval network layer can retrieve multiple text segments associated with the question from the input text, and the judgment network layer can judge the degree of relevance between multiple text segments and the question. The sorting network layer can sort the multiple text segments according to the judgment result of the judgment network layer, so as to select a text segment with the highest degree of relevance to the question, and generate an answer corresponding to the question according to the text segment through the generation network layer.

[0084] In another embodiment of the present specification, the text generation model can also obtain multiple documents from the database, and retrieve documents associated with the question input by the user through the retrieval network layer.

[0085] In summary, by making the retrieval network layer and the generation network layer based on the same large model base, the computing consumption can be reduced while synergistically optimizing various capabilities. In addition, by caching the feature vector output by the feature processing network layer, the feature vector can be used for both the retrieval and generation stages without repeated calculations, thereby improving the reasoning speed, reducing computing and storage consumption, and ensuring the joint implementation of the retrieval stage and the generation stage.

[0086] Step 204: Process the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function.

[0087] Among them, the first loss function can be understood as the loss function for the retrieval network layer, and the second loss function can be understood as the loss function for the network generation layer.

[0088] In specific implementation, the process of training the machine learning model to be trained can simulate the human learning process. New knowledge can be learned in the learning stage. The training of the machine learning model is achieved through the process of joint training of the retrieval network layer and the generation network layer. The specific implementation method is as follows:

[0089] The training data includes sample questions and sample texts and sample answers associated with the sample questions;

[0090] Accordingly, the processing of the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function includes:

[0091] Processing the sample question according to the retrieval network layer to obtain a predicted text corresponding to the sample question;

[0092] Determining the first loss function for the retrieval network layer according to the predicted text and the sample text;

[0093] Processing the sample question and the predicted text according to the generation network layer to obtain a predicted answer corresponding to the sample question;

[0094] Determine the second loss function for the generative network layer according to the predicted answer and the sample answer.

[0095] Among them, the sample question can be understood as a question raised by the user. The sample text associated with the sample question can be understood as a sample text that has an association relationship with the sample question, such as a sample text whose similarity with the sample question reaches a preset similarity threshold. The sample answer can be understood as a sample answer associated with the sample question. It can be understood that the sample question and the sample text associated with the sample question and the sample answer can constitute a positive sample for model training. For example, the sample question can be "Have you eaten?", then the sample text associated with the sample question can be "What did you eat today", and the sample answer associated with the sample question can be "I ate rice today".

[0096] Based on this, sample questions and sample texts can be input into the machine learning model to be trained, and the sample questions and sample texts can be processed according to the retrieval network layer and the generation network layer to obtain the predicted text corresponding to the sample question output by the retrieval network layer and the predicted answer corresponding to the sample question output by the generation network layer. Based on the predicted text and the sample text, the first loss function for the retrieval network layer is calculated, and based on the predicted answer and the sample answer, the second loss function for the generation network layer is calculated.

[0097] In practical applications, the first loss function is shown in the following formula.

[0098]

[0099] in, is the model parameter of the text generation model, q is the sample question, d is the sample text, is the temperature hyperparameter, is the pooling result of the cosine similarity applied to each output, M is the total number of samples, i can be used to represent the i-th sample in the first training batch (i.e., a batch), and j can be used to represent the j-th sample in a training batch (i.e., a batch). Can be used to represent the i-th sample problem, Can be used to represent the i-th sample text, Can be used to represent the jth sample text, and It can be understood as a pair of matching samples, that is, positive samples. and It can be understood as a pair of mismatched samples, namely negative samples.

[0100] The second loss function is shown in the following formula.

[0101]

[0102] Where N is the total number of samples of the generated task (i.e. the total length of the answer to the generated task), X is the generated answer, i is the current generated token position (i.e. the label position), are model parameters, It can be understood as the answer corresponding to the i-th token position. It can be understood as the answer before the i-th token position. For example, if the answer X is "It rains today", the total length N is 4, and the corresponding answer token when i is 1 is "today", and the corresponding answer token when i is 2 is "day".

[0103] In summary, by calculating the first loss function for the retrieval network layer and the second loss function for the generation network layer respectively, it is convenient for the subsequent retrieval network layer to learn reasonable document representations, and the generation network layer to learn how to generate accurate answers, so as to realize the training of all parameters of the text generation model and train the ability to generate correct answers based on relevant documents.

[0104] Step 206: Determine a target loss function according to the first loss function and the second loss function.

[0105] Among them, the target loss function can be understood as a joint loss function used to jointly train the text generation model.

[0106] In a specific implementation, determining a target loss function according to the first loss function and the second loss function includes:

[0107] A weighted sum is performed on the first loss function and the second loss function to obtain the target loss function.

[0108] Specifically, in order to achieve joint training of the text generation model, the first loss function and the second loss function may be weightedly summed to obtain a target loss function.

[0109] In practical applications, the objective loss function is shown in the following formula.

[0110]

[0111] in, is the weight of the first loss function, is the weight of the second loss function, is the first loss function, is the second loss function.

[0112] In summary, by performing a weighted summation on the first loss function and the second loss function, it is convenient to subsequently jointly train the text generation model according to the obtained target loss function, and further ensure the joint training of the retrieval network layer and the generation network layer in the text generation model.

[0113] Step 208: According to the target loss function, adjust the model parameters of the machine learning model to obtain a trained text generation model, wherein the text generation model is used to perform the text generation task.

[0114] Specifically, the model parameters of the machine learning model can be adjusted according to the target loss function to obtain a trained text generation model.

[0115] In practical applications, the training of the retrieval network layer and the training of the generation network layer are achieved through single attention to ensure the model reasoning performance.

[0116] In one embodiment of the present specification, before adjusting the model parameters of the machine learning model according to the target loss function, the method further includes:

[0117] Processing the training data according to the retrieval network layer to obtain the first loss function;

[0118] The retrieval network layer is initialized and trained according to the first loss function.

[0119] Specifically, the training data can be processed according to the retrieval network layer to obtain a first loss function, and the retrieval network layer can be initialized and trained according to the first loss function.

[0120] In summary, by initializing and training the retrieval network layer, the retrieval network layer is started, which facilitates subsequent further training.

[0121] In specific implementation, the retrieval network layer can be initialized and trained by contrastive learning training. The specific implementation method is as follows:

[0122] The training data also includes a sample question, a first sample text associated with the sample question, and a second sample text not associated with the sample question;

[0123] Accordingly, the processing of the training data according to the retrieval network layer to obtain the first loss function includes:

[0124] Processing the sample question according to the retrieval network layer to obtain a predicted text corresponding to the sample question;

[0125] Calculating the first loss function according to the predicted text and the first sample text; or

[0126] Processing the sample question according to the retrieval network layer to obtain a predicted text corresponding to the sample question;

[0127] The first loss function is calculated according to the predicted text and the second sample text.

[0128] The first sample text associated with the sample question can be understood as a sample text that is associated with the sample question, and the second sample text that is not associated with the sample text can be understood as a sample text that is not associated with the sample text. It can be understood that the sample question and the first sample text constitute a positive sample, and the sample question and the second sample text constitute a negative sample. For example, if the sample question is "How is the weather today?", the first sample text can be "Is it raining today?", and the second sample text can be "I am very happy today."

[0129] Based on this, the sample question can be processed according to the retrieval network layer to obtain the predicted text corresponding to the sample question, and the first loss function can be calculated according to the predicted text and the first sample text; or, the sample question can be processed according to the retrieval network layer to obtain the predicted text corresponding to the sample text, and the first loss function can be calculated according to the predicted text and the second sample text. In practical applications, the first loss function can be the InfoNCE loss.

[0130] In addition, the text generation model may also be trained based on other supervised training methods or unsupervised training methods, which is not limited in the embodiments of this specification.

[0131] In summary, by using positive samples and negative samples and based on contrastive learning to initialize the retrieval network layer, the subsequent retrieval capability of the retrieval network layer is guaranteed.

[0132] In one embodiment of the present specification, after adjusting the model parameters of the machine learning model according to the target loss function to obtain a trained text generation model, the method further includes:

[0133] Determining a model optimization task for the text generation model, and determining optimization training data corresponding to the model optimization task;

[0134] The text generation model is optimized according to the optimized training data.

[0135] The model optimization task can be understood as a reflection task for the trained text generation model. During the reflection stage, the text generation model can reflect on its own errors and can usually be optimized through comparative learning. The optimized training data can include positive samples and negative samples.

[0136] Specifically, a model optimization task for a text generation model can be determined, and optimized training data corresponding to the model optimization task can be determined. The optimized training data can be input into the text generation model to obtain a prediction result of the text generation model. An optimized loss function can be determined based on the prediction result, and the text generation model can be optimized based on the optimized loss function.

[0137] In practical applications, the optimization loss function is shown in the following formula.

[0138]

[0139] Among them, the optimization loss function can be a DPO function, X is the input optimization training data, is a positive sample, is a negative sample, D is a data set containing optimized training data, positive samples and negative samples, is the machine learning model to be trained, For reference model.

[0140] In one embodiment of the present specification, a model optimization task may be a task of reflecting on whether a question needs to be retrieved. Then, the optimization training data corresponding to the model optimization task includes training samples (i.e., sample questions) and training labels (i.e., questions that need to be retrieved or questions that do not need to be retrieved). Then, the training samples and training labels may be input into a text generation model to obtain a prediction result output by the text generation model. Based on the training labels and the prediction results, the optimization loss function is calculated, and the text generation model is optimized based on the optimization loss function.

[0141] In another embodiment of the present specification, the model optimization task may be a task of reflecting on whether the question and the retrieved document are related. Then, the optimized training data corresponding to the model optimization task includes training samples (i.e., sample questions and sample texts) and training labels (i.e., the sample questions and sample texts are related or the sample questions and sample texts are unrelated). Then, the training samples and training labels may be input into the text generation model to obtain the prediction results output by the text generation model. Based on the training labels and the prediction results, the optimization loss function is calculated, and the text generation model is optimized based on the optimization loss function.

[0142] In another embodiment of the present specification, the model optimization task may be a task of reflecting on whether the generated answer is accurate. Then, the optimized training data corresponding to the model optimization task includes training samples (i.e., sample questions and sample answers) and training labels (i.e., the sample answers are correct or the sample answers are incorrect). Then, the training samples and training labels may be input into the text generation model to obtain the prediction results output by the text generation model. Based on the training labels and the prediction results, the optimization loss function is calculated, and the text generation model is optimized based on the optimization loss function.

[0143] In practical applications, when constructing optimized training data, natural language can be used to ensure the naturalness and accuracy of the optimized training data. Multiple model optimization tasks can be performed using the DPO algorithm.

[0144] In one embodiment of the present specification, the model optimization task may be a constructed dynamic reflection task, which may optimize the construction of the model task according to the inherent situation of the text generation model, thereby making the model optimization task more adaptable to the text generation model and realizing personalized optimization of the text generation model.

[0145] In summary, by performing reflective optimization on the text generation model, the processing performance of the text generation model can be further improved. In addition, by using global information such as retrieval documents and reflection results at the same time, the text generation model can be helped to generate more accurate answers. The training of the retrieval network layer will give the retrieval network layer a better representation and obtain a better semantic space distribution, which will help the subsequent text generation steps. In addition, the retrieval network layer after joint training has seen the document content and can learn the document content during the encoding process.

[0146] In summary, an embodiment of the present specification unifies the model bases of the retrieval network layer and the generation network layer by placing the retrieval network layer and the generation network layer in one machine learning model, thereby reducing model computing consumption and reducing response delay time, further improving model processing efficiency. In addition, when training a machine learning model including a retrieval network layer and a generation network layer, the target loss function is determined by the first loss function and the second loss function, and the model parameters of the machine learning model are adjusted based on the target loss function, thereby achieving joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and processing accuracy of the text generation model.

[0147] The following combination Figure 4 Taking the application of the text generation model training method provided in this specification in the text generation model training as an example, the text generation model training method is further described. Figure 4 A processing flow chart of a text generation model training method provided by an embodiment of the present specification is shown, which specifically includes the following steps.

[0148] Step 402: Determine a machine learning model to be trained and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer.

[0149] Step 404: Process the training data according to the retrieval network layer to obtain a first loss function.

[0150] The training data may include a sample question, a first sample text associated with the sample question, and a second sample text not associated with the sample question. The sample question and the first sample text constitute a positive sample, while the sample question and the second sample text constitute a negative sample. For example, if the sample question is "How is the weather today?", the first sample text may be "Did it rain today?", and the second sample text may be "I am very happy today."

[0151] Based on this, the sample question and the first sample text can be processed according to the retrieval network layer to obtain the predicted text corresponding to the sample question, and the first loss function can be calculated based on the predicted text and the first sample text; or, the sample question and the second sample text can be processed according to the retrieval network layer to obtain the predicted text corresponding to the sample text, and the first loss function can be calculated based on the predicted text and the second sample text.

[0152] Step 406: Initialize the retrieval network layer for training according to the first loss function.

[0153] Step 408: Process the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function.

[0154] The training data also includes sample questions, sample texts associated with the sample questions, and sample answers, which can constitute positive samples for model training. For example, the sample question can be "Have you eaten?", then the sample text associated with the sample question can be "What did you eat today?", and the sample answer associated with the sample question can be "I ate rice today."

[0155] Specifically, the sample questions and sample texts can be input into the machine learning model to be trained, and the sample questions and sample texts can be processed according to the retrieval network layer and the generation network layer to obtain the predicted text corresponding to the sample question output by the retrieval network layer and the predicted answer corresponding to the sample question output by the generation network layer. Based on the predicted text and the sample text, a first loss function for the retrieval network layer is calculated, and based on the predicted answer and the sample answer, a second loss function for the generation network layer is calculated.

[0156] Step 410: Determine a target loss function according to the first loss function and the second loss function.

[0157] Specifically, the first loss function and the second loss function may be weightedly summed to obtain a target loss function.

[0158] Step 412: According to the target loss function, adjust the model parameters of the machine learning model to obtain a trained text generation model.

[0159] Step 414: Determine a model optimization task for the text generation model, and determine the optimization training data corresponding to the model optimization task.

[0160] Specifically, the model optimization task may be a task of reflecting on whether a question needs to be retrieved. Then the optimization training data corresponding to the model optimization task includes training samples (i.e., sample questions) and training labels (i.e., questions need to be retrieved or questions do not need to be retrieved).

[0161] The model optimization task can also be a task of reflecting on whether the question and the retrieved document are related. In this case, the optimized training data corresponding to the model optimization task includes training samples (i.e., sample questions and sample texts) and training labels (i.e., the sample questions and sample texts are related or the sample questions and sample texts are not related).

[0162] The model optimization task can also be a task of reflecting on whether the generated answer is accurate. Then the optimization training data corresponding to the model optimization task includes training samples (i.e., sample questions and sample answers) and training labels (i.e., sample answers are correct or sample answers are incorrect).

[0163] Step 416: Optimize the text generation model based on the optimized training data.

[0164] Specifically, the training samples and training labels can be input into the text generation model to obtain the prediction results output by the text generation model, and the optimization loss function can be calculated based on the training labels and the prediction results, and the text generation model can be optimized based on the optimization loss function.

[0165] An embodiment of the present specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model computing consumption and reducing the response delay time, further improving the model processing efficiency. In addition, when training the machine learning model including the retrieval network layer and the generation network layer, the target loss function is determined by the first loss function and the second loss function, and the model parameters of the machine learning model are adjusted based on the target loss function, so as to realize the joint training of the retrieval network layer and the generation network layer, and further ensure the processing performance and processing accuracy of the text generation model.

[0166] Corresponding to the above method embodiment, this specification also provides a text generation model training device embodiment, Figure 5 FIG. 1 is a schematic diagram showing the structure of a text generation model training device provided by an embodiment of the present specification. Figure 5 As shown, the device comprises:

[0167] A first determination module 502 is configured to determine a machine learning model to be trained and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer;

[0168] A processing module 504 is configured to process the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function;

[0169] A second determination module 506 is configured to determine a target loss function according to the first loss function and the second loss function;

[0170] The adjustment module 508 is configured to adjust the model parameters of the machine learning model according to the target loss function to obtain a trained text generation model, wherein the text generation model is used to perform the text generation task.

[0171] In an optional embodiment, the training data includes sample questions and sample texts associated with the sample questions;

[0172] The processing module 504 is further configured to:

[0173] Processing the sample question according to the retrieval network layer to obtain a predicted text corresponding to the sample question;

[0174] Determining the first loss function for the retrieval network layer according to the predicted text and the sample text;

[0175] Processing the sample question and the predicted text according to the generation network layer to obtain a predicted answer corresponding to the sample question;

[0176] Determine the second loss function for the generative network layer according to the predicted answer and the sample answer.

[0177] In an optional embodiment, the second determining module 506 is further configured to:

[0178] A weighted sum is performed on the first loss function and the second loss function to obtain the target loss function.

[0179] In an optional embodiment, the adjustment module 508 is further configured to:

[0180] Processing the training data according to the retrieval network layer to obtain the first loss function;

[0181] The retrieval network layer is initialized and trained according to the first loss function.

[0182] In an optional embodiment, the training data further includes a sample question, a first sample text associated with the sample question, and a second sample text not associated with the sample question;

[0183] The adjustment module 508 is further configured to:

[0184] Processing the sample question according to the retrieval network layer to obtain a predicted text corresponding to the sample question;

[0185] Calculating the first loss function according to the predicted text and the first sample text; or

[0186] Processing the sample question according to the retrieval network layer to obtain a predicted text corresponding to the sample question;

[0187] The first loss function is calculated according to the predicted text and the second sample text.

[0188] In an optional embodiment, the adjustment module 508 is further configured to:

[0189] Determining a model optimization task for the text generation model, and determining optimization training data corresponding to the model optimization task;

[0190] The text generation model is optimized according to the optimized training data.

[0191] In an optional embodiment, the machine learning model to be trained also includes a feature processing network layer, which performs feature processing on the training data to obtain a feature vector, and outputs the feature vector to the retrieval network layer and the generation network layer, respectively, the retrieval network layer processes the training data according to the feature vector, and the generation network layer processes the training data according to the feature vector.

[0192] An embodiment of the present specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model computing consumption and reducing the response delay time, further improving the model processing efficiency. In addition, when training the machine learning model including the retrieval network layer and the generation network layer, the target loss function is determined by the first loss function and the second loss function, and the model parameters of the machine learning model are adjusted based on the target loss function, so as to realize the joint training of the retrieval network layer and the generation network layer, and further ensure the processing performance and processing accuracy of the text generation model.

[0193] The above is a schematic scheme of a text generation model training device of this embodiment. It should be noted that the technical scheme of the text generation model training device and the technical scheme of the above-mentioned text generation model training method belong to the same concept, and the details not described in detail in the technical scheme of the text generation model training device can be found in the description of the technical scheme of the above-mentioned text generation model training method.

[0194] See also Figure 6 , Figure 6 A flowchart of a text generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0195] Step 602: determining a reference text, and determining a target question for the reference text;

[0196] Step 604: inputting the target question and the reference text into a text generation model to obtain a target text corresponding to the target question;

[0197] Among them, the text generation model includes a retrieval network layer and a generation network layer. The retrieval network layer is used to retrieve a reference text segment associated with the target question in the reference text, and the generation network layer is used to generate a target text corresponding to the target question based on the reference text segment. The text generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0198] In an optional embodiment, the text generation model also includes a feature processing network layer, which performs feature processing on the target question and the reference text to obtain a feature vector, and outputs the feature vector to the retrieval network layer and the generation network layer, respectively. The retrieval network layer processes the reference text according to the feature vector, and the generation network layer processes the reference text segment according to the feature vector.

[0199] An embodiment of the present specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model computing consumption and reducing the response delay time, further improving the model processing efficiency. In addition, when training the machine learning model including the retrieval network layer and the generation network layer, the target loss function is determined by the first loss function and the second loss function, and the model parameters of the machine learning model are adjusted based on the target loss function, so as to realize the joint training of the retrieval network layer and the generation network layer, and further ensure the processing performance and processing accuracy of the text generation model.

[0200] Corresponding to the above method embodiment, this specification also provides a text generation device embodiment, Figure 7 FIG. 1 shows a schematic diagram of a text generation device provided by an embodiment of the present specification. Figure 7 As shown, the device comprises:

[0201] A determination module 702 is configured to determine a reference text and determine a target question for the reference text;

[0202] An input module 704 is configured to input the target question and the reference text into a text generation model to obtain a target answer corresponding to the target question;

[0203] Among them, the text generation model includes a retrieval network layer and a generation network layer. The retrieval network layer is used to retrieve a reference text segment associated with the target question in the reference text, and the generation network layer is used to generate a target text corresponding to the target question based on the reference text segment. The text generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0204] In an optional embodiment, the text generation model also includes a feature processing network layer, which performs feature processing on the target question and the reference text to obtain a feature vector, and outputs the feature vector to the retrieval network layer and the generation network layer, respectively. The retrieval network layer processes the reference text according to the feature vector, and the generation network layer processes the reference text segment according to the feature vector.

[0205] An embodiment of the present specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model computing consumption and reducing the response delay time, further improving the model processing efficiency. In addition, when training the machine learning model including the retrieval network layer and the generation network layer, the target loss function is determined by the first loss function and the second loss function, and the model parameters of the machine learning model are adjusted based on the target loss function, so as to realize the joint training of the retrieval network layer and the generation network layer, and further ensure the processing performance and processing accuracy of the text generation model.

[0206] The above is a schematic scheme of a text generation device of this embodiment. It should be noted that the technical scheme of the text generation device and the technical scheme of the above text generation method belong to the same concept, and the details not described in detail in the technical scheme of the text generation device can be referred to the description of the technical scheme of the above text generation method.

[0207] See also Figure 8 , Figure 8 A flowchart of an answer generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0208] Step 802: receiving a reference audio and a target question for the reference audio sent by a client;

[0209] Step 804: converting the reference audio to obtain a reference text corresponding to the reference audio;

[0210] Step 806: input the target question and the reference text into an answer generation model to obtain a target answer corresponding to the target question;

[0211] Step 808: Send the target answer to the client;

[0212] To achieve display through the display interface of the client;

[0213] Among them, the answer generation model includes a retrieval network layer and a generation network layer, the retrieval network layer is used to retrieve the reference text segment associated with the target question in the reference text, and the generation network layer is used to generate the target answer corresponding to the target question based on the reference text segment. The answer generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0214] Specifically, the answer generation method can be applied to the server, which can receive the reference audio sent by the user through the client, and the target question for the reference audio, convert the reference audio, obtain the reference text corresponding to the reference audio, and input the target question and the reference text into the answer generation model, thereby obtaining the target answer corresponding to the target question, and send the target answer to the client, and display it to the user through the client's display interface. Among them, the answer generation model can be understood as the aforementioned text generation model.

[0215] An embodiment of this specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model calculation consumption and reducing the response delay time, further improving the model processing efficiency. Through the data interaction between the client and the server and the call to the answer generation model, the answer generation for the target question raised by the user is realized, ensuring the user experience.

[0216] Corresponding to the above method embodiment, this specification also provides an answer generation device embodiment, Fig. 9 FIG. 2 shows a schematic diagram of the structure of another answer generation device provided by an embodiment of the present specification. Fig. 9 As shown, the device comprises:

[0217] The receiving module 902 is configured to receive a reference audio and a target question for the reference audio sent by a client;

[0218] The conversion module 904 is configured to convert the reference audio to obtain a reference text corresponding to the reference audio;

[0219] An input module 906 is configured to input the target question and the reference text into an answer generation model to obtain a target answer corresponding to the target question;

[0220] A sending module 908 is configured to send the target answer to the client and display it through a display interface of the client;

[0221] Among them, the answer generation model includes a retrieval network layer and a generation network layer, the retrieval network layer is used to retrieve the reference text segment associated with the target question in the reference text, and the generation network layer is used to generate the target answer corresponding to the target question based on the reference text segment. The answer generation model is trained according to the method provided in the first aspect of the embodiment of this specification.

[0222] An embodiment of this specification unifies the model bases of the retrieval network layer and the generation network layer by setting the retrieval network layer and the generation network layer in a machine learning model, thereby reducing the model calculation consumption and reducing the response delay time, further improving the model processing efficiency. Through the data interaction between the client and the server and the call to the answer generation model, the answer generation for the target question raised by the user is realized, ensuring the user experience.

[0223] The above is a schematic scheme of an answer generation device of this embodiment. It should be noted that the technical scheme of the answer generation device and the technical scheme of the answer generation method described above are of the same concept, and the details not described in detail in the technical scheme of the answer generation device can be found in the description of the technical scheme of the answer generation method described above.

[0224] Fig.10 The block diagram of a computing device 1000 according to an embodiment of the present specification is shown. The components of the computing device 1000 include but are not limited to a memory 1010 and a processor 1020. The processor 1020 is connected to the memory 1010 via a bus 1030, and the database 1050 is used to store data.

[0225] The computing device 1000 also includes an access device 1040 that enables the computing device 1000 to communicate via one or more networks 1060. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1040 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0226] In one embodiment of the present application, the above components of the computing device 1000 and Fig.10 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.10 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.

[0227] The computing device 1000 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 1000 may also be a mobile or stationary server.

[0228] The processor 1020 is used to execute the following computer program / instructions, which implement the steps of the above method when executed by the processor.

[0229] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computing device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0230] An embodiment of the present specification further provides a computer-readable storage medium storing a computer program / instruction, which implements the steps of the above method when executed by a processor.

[0231] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computer-readable storage medium embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0232] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which implements the steps of the above method when executed by a processor.

[0233] The above is a schematic solution of a computer program product of this embodiment. It should be noted that the technical solution of the computer program product and the technical solution of the above method belong to the same concept, and the details not described in detail in the technical solution of the computer program product can be referred to the description of the technical solution of the above method.

[0234] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0235] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0236] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0237] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0238] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A text generation model training method, comprising: Determine a machine learning model to be trained and training data associated with a text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer, and the machine learning model to be trained also includes a feature processing network layer, and the retrieval network layer and the generation network layer share the feature processing network layer; Processing the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function; Determine a target loss function according to the first loss function and the second loss function; According to the target loss function, the model parameters of the machine learning model are adjusted to obtain a trained text generation model, wherein the text generation model is used to perform the text generation task.

2. According to the text generation model training method of claim 1, the training data includes sample questions and sample texts and sample answers associated with the sample questions; The step of processing the training data according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function includes: Processing the sample question according to the retrieval network layer to obtain a predicted text corresponding to the sample question; Determining the first loss function for the retrieval network layer according to the predicted text and the sample text; Processing the sample question and the predicted text according to the generation network layer to obtain a predicted answer corresponding to the sample question; Determine the second loss function for the generative network layer according to the predicted answer and the sample answer.

3. The text generation model training method according to claim 1, wherein determining a target loss function according to the first loss function and the second loss function comprises: A weighted sum is performed on the first loss function and the second loss function to obtain the target loss function.

4. The text generation model training method according to claim 1, before adjusting the model parameters of the machine learning model according to the target loss function, further comprising: Processing the training data according to the retrieval network layer to obtain the first loss function; The retrieval network layer is initialized and trained according to the first loss function.

5. The text generation model training method according to claim 1, wherein after adjusting the model parameters of the machine learning model according to the target loss function to obtain the trained text generation model, the method further comprises: Determining a model optimization task for the text generation model, and determining optimization training data corresponding to the model optimization task; The text generation model is optimized according to the optimized training data.

6. According to the text generation model training method according to claim 1, the machine learning model to be trained also includes a feature processing network layer, the feature processing network layer performs feature processing on the training data to obtain a feature vector, and outputs the feature vector to the retrieval network layer and the generation network layer respectively, the retrieval network layer processes the training data according to the feature vector, and the generation network layer processes the training data according to the feature vector.

7. A text generation method, comprising: determining a reference text and determining target questions for the reference text; Inputting the target question and the reference text into a text generation model to obtain a target text corresponding to the target question; Among them, the text generation model includes a retrieval network layer and a generation network layer, the retrieval network layer is used to retrieve the reference text segment associated with the target question in the reference text, and the generation network layer is used to generate the target text corresponding to the target question based on the reference text segment. The text generation model is trained according to any one of the methods described in claims 1-6.

8. According to the text generation method according to claim 7, the text generation model also includes a feature processing network layer, which performs feature processing on the target question and the reference text to obtain a feature vector, and outputs the feature vector to the retrieval network layer and the generation network layer respectively, the retrieval network layer processes the reference text according to the feature vector, and the generation network layer processes the reference text segment according to the feature vector.

9. A method for generating an answer, comprising: receiving a reference audio and a target question for the reference audio sent by a client; Converting the reference audio to obtain a reference text corresponding to the reference audio; Inputting the target question and the reference text into an answer generation model to obtain a target answer corresponding to the target question; Sending the target answer to the client; Among them, the answer generation model includes a retrieval network layer and a generation network layer, the retrieval network layer is used to retrieve the reference text segment associated with the target question in the reference text, and the generation network layer is used to generate the target answer corresponding to the target question based on the reference text segment. The answer generation model is trained according to the method described in any one of claims 1-6.

10. A computing device comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the method described in any one of claims 1 to 9 are implemented.

11. A computer-readable storage medium storing a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.

12. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.