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 human-computer interaction question-answering framework and conducting joint training, the problems of insufficient efficiency and accuracy in the existing technology are solved, and more efficient and accurate text generation is achieved.
Patent Information
- Application Number
- PCT/CN2025/088634
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-19
- Filing Date
- 2025-04-11
- Publication Date
- 2025-12-26
AI Technical Summary
Existing human-computer interaction question-answering frameworks have low processing efficiency and poor accuracy, resulting in response delays and insufficient answer accuracy.
The retrieval network layer and the generation network layer are unified into a single machine learning model. The target loss function is determined by the first loss function and the second loss function. Joint training is performed to adjust the model parameters and achieve collaborative optimization of retrieval and generation.
This reduces model computational costs, lowers response latency, improves processing efficiency and accuracy, and ensures the processing performance and accuracy of the text generation model.
Smart Images

Figure CN2025088634_26122025_PF_FP_ABST
Abstract
Description
Text generation model training methods, text generation methods, and answer generation methods Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method for training a text generation model, a text generation method, and an answer generation method. Background Technology
[0002] Human-computer interaction (HCI) refers to the process of information exchange between humans and computers using a dialogue language and specific interactive methods. With the development of HCI technology, an increasing number of intelligent products based on HCI have emerged. For example, users can use HCI technology to ask custom questions and receive answers. Typically, quick question-and-answer and search can be performed based on a framework of retrieval and generator; however, this framework suffers from low processing efficiency and poor accuracy. Therefore, an effective technical solution is urgently needed to address these issues. Summary of the Invention
[0003] In view of this, embodiments of this disclosure provide a text generation model training method. One or more embodiments of this disclosure also relate to a text generation model training device, a text generation method, a text generation apparatus, an answer generation method, an answer generation apparatus, a computing device, a computer-readable storage medium, and a computer program product, to address the technical shortcomings of low processing efficiency and poor processing accuracy in existing question-answering frameworks.
[0004] According to a first aspect of the present disclosure, a text generation model training method is provided, comprising:
[0005] The machine learning model to be trained and the training data associated with the text generation task are determined, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer.
[0006] The training data is processed according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function;
[0007] Determine the target loss function based on the first loss function and the second loss function;
[0008] Based on 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 the present disclosure, a text generation model training apparatus is provided, comprising:
[0010] The first determining module is configured to determine the machine learning model to be trained and the training data associated with the text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer.
[0011] The processing module 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;
[0012] The second determining module is configured to determine a target loss function based on 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 present disclosure, a text generation method is provided, comprising:
[0015] Identify the reference text and determine the target problem for the reference text;
[0016] The target question and the reference text are input into a text generation model to obtain the target text corresponding to the target question;
[0017] 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 from the reference text. The generation network layer is used to generate 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 present disclosure.
[0018] According to a fourth aspect of the present disclosure, a text generation apparatus is provided, comprising:
[0019] The determination module is configured to determine reference text and identify a target problem for the reference text;
[0020] The input module is configured to input the target question and the reference text into a text generation model to obtain the target text corresponding to the target question.
[0021] 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 from the reference text. The generation network layer is used to generate 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 present disclosure.
[0022] According to a fifth aspect of the present disclosure, an answer generation method is provided, comprising:
[0023] Receive reference audio and a target question related to the reference audio sent by the client;
[0024] The reference audio is converted to obtain the reference text corresponding to the reference audio;
[0025] The target question and the reference text are input into the answer generation model to obtain the target answer corresponding to the target question;
[0026] Send the target answer to the client;
[0027] 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 from the reference text. 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 present disclosure.
[0028] According to a sixth aspect of the present disclosure, an answer generation apparatus is provided, comprising:
[0029] The receiving module is configured to receive reference audio and a target question for the reference audio sent by the client;
[0030] The conversion module is configured to perform conversion processing on the reference audio to obtain reference text corresponding to the reference audio.
[0031] The input module is configured to take the target question and the reference text as input to generate a model, and obtain the target answer corresponding to the target question.
[0032] The sending module is configured to send the target answer to the client;
[0033] 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 from the reference text. 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 present disclosure.
[0034] According to a seventh aspect of the present disclosure, a computing device is provided, comprising:
[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, which, when executed by the processor, implement the steps of the above method.
[0037] According to an eighth aspect of the present disclosure, a computer-readable storage medium is provided that stores a computer program / instructions that, when executed by a processor, implement the steps of the above-described method.
[0038] According to a ninth aspect of the present disclosure, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described method.
[0039] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model, thereby reducing model computational costs and response latency, and further improving model processing efficiency. Furthermore, when training the machine learning model containing the retrieval network layer and the generation network layer, a target loss function is determined using a first loss function and a second loss function. Based on the target loss function, the model parameters are adjusted to achieve joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and accuracy of the text generation model. Attached Figure Description
[0040] Figure 1 is a schematic diagram of the application scenario of a text generation model in a text generation model training method provided in an embodiment of this disclosure;
[0041] Figure 2 is a flowchart of a text generation model training method provided in an embodiment of this disclosure;
[0042] Figure 3 is a schematic diagram of the structure of a text generation model in a text generation model training method provided in an embodiment of this disclosure;
[0043] Figure 4 is a flowchart of the processing procedure of a text generation model training method provided in an embodiment of this disclosure;
[0044] Figure 5 is a schematic diagram of the structure of a text generation model training device provided in an embodiment of this disclosure;
[0045] Figure 6 is a flowchart of a text generation method provided in an embodiment of this disclosure;
[0046] Figure 7 is a schematic diagram of the structure of a text generation device provided in an embodiment of this disclosure;
[0047] Figure 8 is a flowchart of an answer generation method provided in an embodiment of this disclosure;
[0048] Figure 9 is a schematic diagram of the structure of an answer generation device provided in an embodiment of this disclosure;
[0049] Figure 10 is a structural block diagram of a computing device provided in an embodiment of this disclosure. Detailed Implementation
[0050] Numerous specific details are set forth in the following description to provide a full understanding of this disclosure. However, this disclosure can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this disclosure. Therefore, this disclosure is not limited to the specific implementations disclosed below.
[0051] The terminology used in one or more embodiments of this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this disclosure. The singular forms “a,” “the,” and “the” as used in one or more embodiments of this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this disclosure 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 disclosure, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this disclosure, and similarly, second may also be referred to as first. Depending on the context, the word “if” as used herein may be interpreted as “when”, “in response to a determination”, or “when…”.
[0053] Furthermore, 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 disclosure are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0054] In one or more embodiments of this disclosure, a large model refers to a deep learning model with a large number of model parameters, typically containing hundreds of millions, tens of billions, hundreds of billions, trillions, or even tens of trillions of model parameters. A large model can also be called a foundation model. It is pre-trained using large-scale unlabeled corpora to produce a pre-trained model with hundreds of millions of parameters. Such models can adapt to a wide range of downstream tasks and have good generalization ability. Examples include Large Language Models (LLMs) and multi-modal pre-training models.
[0055] In practical applications, large models only require a small number of samples to fine-tune the pre-trained model before they can be applied to different tasks. Large models can be widely used in fields such as Natural Language Processing (NLP) and Computer Vision. Specifically, they can be applied to computer vision tasks such as Visual Question Answering (VQA), Image Captioning (IC), and Image Generation, as well as NLP tasks such as text-based sentiment classification, text summarization, and machine translation. The main application scenarios for large models include digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design.
[0056] First, the terms and concepts involved in one or more embodiments of this disclosure will be explained.
[0057] RAG: Retrieval-Augmented Generation, is a general framework that uses retrieval to enhance generation. When a large model answers a question or generates text, it first retrieves relevant information from a large number of documents, and then uses this retrieved information to answer or generate text, thereby improving the quality of the answer, rather than letting the large model do its own thing.
[0058] DPO: Direct Preference Optimization. This algorithm implicitly optimizes the same objective as RLHF (Reinforcement Learning from Human Feedback) (maximizing reward with KL divergence constraints), but it is simple to implement and easy to train, without requiring explicit reward modeling or reinforcement learning.
[0059] Joint training refers to training a model simultaneously to complete multiple tasks, typically achieved by sharing parameters or using a multi-task learning framework. Joint training helps the model transfer knowledge between different tasks, improving the performance of each task.
[0060] Contrastive Learning is a machine learning technique where algorithms learn to distinguish between similar and dissimilar data points. The goal of contrastive learning is to learn representations of data to capture the fundamental 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, custom question-and-answer text generation can typically be performed using the RAG framework, with independent retrieval and generation phases. However, separating the retrieval and generation tasks into two independent tasks lacks utilization and reflection of global knowledge, leading to poor retrieval performance. Furthermore, this independence introduces latency into the large model's response, resulting in reduced efficiency and retrieval accuracy. When the documents retrieved by the retrieval machine are irrelevant to the user's question, the large model may output incorrect answers, resulting in poor model robustness. In some cases, such as when the user's question is simple, the large model can answer directly, but because it's based on the RAG framework, the large model must generate the answer from the retrieved documents, which can easily introduce noise. Alternatively, if the user's question requires retrieval but the retrieval is inaccurate, it can also interfere with answer generation. Therefore, an effective technical solution is urgently needed to address these issues.
[0062] This disclosure provides a text generation model training method, and also relates to a text generation model training device, a text generation method, a text generation apparatus, an answer generation method, an answer generation apparatus, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail in the following embodiments.
[0063] Referring to Figure 1, Figure 1 illustrates an application scenario of a text generation model in a text generation model training method according to an embodiment of this disclosure. The specific steps of the text generation model training method are as follows.
[0064] The machine learning model to be trained and the training data associated with the text generation task are determined, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer.
[0065] The training data is processed according to the retrieval network layer and the generation network layer to obtain a first loss function and a second loss function;
[0066] Determine the target loss function based on the first loss function and the second loss function;
[0067] Based on 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] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model, thereby reducing model computational costs and response latency, and further improving model processing efficiency. Furthermore, when training the machine learning model containing the retrieval network layer and the generation network layer, a target loss function is determined using a first loss function and a second loss function. Based on the target loss function, the model parameters are adjusted to achieve joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and accuracy of the text generation model.
[0069] As shown in Figure 1, Figure 1 includes end-side device 102 and cloud-side device 104.
[0070] In practice, during the text generation task performed by the text generation model, the user can upload meeting recording audio and a question related to the audio, "What suggestions were made in the meeting?", via the edge device 102. The edge device 102 can then send the meeting recording audio and the user's question to the cloud device 104. The cloud device 104 can convert the meeting recording audio into text and input the question and text into the text generation model. Based on the retrieval network layer of the text generation model, the model retrieves the text segment associated with the question from the text and generates the answer to the question, "The suggestions made in the meeting include the following: Suggestion 1... Suggestion 2...", based on the generation network layer of the text generation model. The cloud device 104 can then send the answer to the edge device 102, which displays it to the user through the display interface of the edge device 102, thereby realizing customized question and answer.
[0071] The edge device 102 may include a browser, an app (application), or a web application such as an H5 (Hypertext Markup Language 5) application, a lightweight application (also known as a mini-program), or a cloud application. The edge device can be developed based on a software development kit (SDK) provided by the server, such as a real-time communication (RTC) SDK. The edge device can be deployed in an electronic device and depends on the device's operation or certain apps within the device to run. The electronic device may have a display screen and support information browsing, such as a personal mobile terminal like a mobile phone, tablet, or personal computer. Various other types of applications can also be configured in the electronic device, such as human-computer interaction applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, and social media platform software.
[0072] Cloud-side device 104 can be understood as a server providing various services, including physical servers and cloud servers. Examples include servers providing communication services to multiple clients, servers supporting backend training of models used on clients, and servers processing data sent by clients. It should be noted that cloud-side device 104 can be implemented as a distributed server cluster composed of multiple servers, or as a single server. Cloud-side device 104 can also be a server for a distributed system, or a server integrated with blockchain. Cloud-side device 104 can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery 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 this embodiment can be executed by the cloud-side device 104. In other embodiments of this disclosure, the image processing model can be deployed in the edge device 102, so that the edge device 102 can also have similar functions to the cloud-side device 104, thereby executing the image processing method provided in this embodiment. In other embodiments, the image processing method provided in this embodiment can also be jointly executed by the edge device 102 and the cloud-side device 104.
[0074] Referring to Figure 2, Figure 2 shows a flowchart of a text generation model training method according to an embodiment of the present disclosure, which specifically includes the following steps.
[0075] Step 202: Determine the machine learning model to be trained and the training data associated with the 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 this disclosure can be applied to the field of human-computer interaction. In the field of human-computer interaction, a corresponding machine learning model can be trained according to a specific text generation task. The text generation task can be, for example, a task of generating text from input audio or video, a task of generating text from input text, a task of generating text from input images, or a task of generating text from user-generated questions. This disclosure does not limit the text generation task. In one embodiment of this disclosure, the text generation task can be an answer generation task; therefore, the corresponding text generation model can also be an answer generation model.
[0077] The retrieval network layer can be used for vector representation, while the generation network layer can be used to perform generation tasks.
[0078] Based on this, the machine learning model to be trained can be determined, and the training data associated with the text generation task can be identified. 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 feature vectors, and outputs the feature vectors to the retrieval network layer and the generation network layer respectively. The retrieval network layer processes the training data according to the feature vectors, and the generation network layer processes the training data according to the feature vectors.
[0080] Specifically, the retrieval network layer and the generation network layer can share a feature processing network layer, allowing them to operate on the same model foundation and ensuring timely response during text generation tasks. The feature processing network layer encodes the input training data to obtain feature vectors, which are then output to both the retrieval and generation networks. This facilitates subsequent text generation tasks in both layers. In practice, the retrieval network layer can use these feature vectors to process the sample question and obtain the predicted text, while the generation network layer can use these feature vectors to process both the sample question and the predicted text to obtain the predicted answer.
[0081] Furthermore, after obtaining the feature vector output by the feature processing network layer, the feature vector can be cached so that it can be used in both the retrieval and generation stages simultaneously.
[0082] In practical applications, refer to Figure 3, which illustrates the structural diagram of a text generation model in a text generation model training method according to an embodiment of this disclosure. As shown in Figure 3, 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 can encode the question and text input to the text generation model to obtain the encoded feature vector. The feature vector is then input into the retrieval network layer 304 and the generation network layer 306, respectively. The retrieval network layer 304 can 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 can generate the answer based on the feature vector and the text segment. In practical applications, the feature processing network layer can be a decoder-only architecture of Transformer, possessing powerful context modeling and generation capabilities.
[0083] In addition, in specific implementation, the text generation model also includes a ranking network layer and a judgment network layer. The retrieval network layer can retrieve multiple text segments related to the question from the input text. The judgment network layer can determine the degree of relevance between multiple text segments and the question. The ranking network layer can sort multiple text segments according to the judgment result of the judgment network layer, thereby selecting a text segment with a high degree of relevance to the question, and the generation network layer generates the answer to the question based on the text segment.
[0084] In another embodiment of this disclosure, the text generation model can also retrieve multiple documents from a database and retrieve documents associated with the user-input question through a retrieval network layer.
[0085] In summary, by basing the retrieval network layer and the generation network layer on the same large model foundation, we can reduce computational costs while synergistically optimizing various capabilities. Furthermore, by caching the feature vectors output by the feature processing network layer, these feature vectors can be used simultaneously in both the retrieval and generation stages without redundant computation, thereby improving inference speed, reducing computational and storage costs, and ensuring the joint operation of the retrieval and generation stages.
[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] 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 practice, the training process of the machine learning model can simulate the human learning process. During the learning phase, new knowledge can be learned. The machine learning model is trained through the joint training of the retrieval network layer and the generative network layer. The specific implementation method is as follows:
[0089] The training data includes sample questions, sample text associated with the sample questions, and sample answers;
[0090] Accordingly, 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:
[0091] Based on the retrieval network layer, the sample question is processed to obtain the predicted text corresponding to the sample question;
[0092] Based on the predicted text and the sample text, determine the first loss function for the retrieval network layer;
[0093] Based on the generative network layer, the sample question and the predicted text are processed to obtain the predicted answer corresponding to the sample question;
[0094] Based on the predicted answer and the sample answer, the second loss function for the generator network layer is determined.
[0095] Here, the sample question can be understood as the question posed by the user. The sample text associated with the sample question can be understood as sample text that is related to the sample question, such as sample text whose similarity to the sample question reaches a preset similarity threshold. The sample answer can be understood as the sample answer associated with the sample question. It is understandable that the sample question, the sample text associated with the sample question, and the sample answer can constitute positive samples for model training. For example, the sample question could be "Have you eaten?", then the sample text associated with the sample question could be "What did you eat today?", and the sample answer associated with the sample question could 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. The sample questions and sample texts are 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 sample texts, the first loss function for the retrieval network layer is calculated, and based on the predicted answer and 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] Among them, f θ Here are the model parameters for the text generation model: q represents the sample problem, d represents the sample text, τ represents the temperature hyperparameter, σ represents the pooling result applied to the cosine similarity of each output, M represents the total number of samples, and 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). (i) It can be used to represent the problem of the i-th sample, d (i) It can be used to represent the i-th sample text, d (j) It can be used to represent the j-th sample text, q (i) and d (i) This can be understood as a pair of matched samples, i.e., positive samples, q (i) and d (j) This can be understood as a pair of mismatched samples, i.e., negative samples.
[0099] The second loss function is shown in the following formula.
[0100] Where N is the total number of samples in the generated task (i.e., the total length of the answers to the generated task), X is the generated answer, i is the current generated token position (i.e., the tag position), η is the model parameters, and x (i) This can be understood as the answer corresponding to the i-th token position, x (<i) 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, the answer token corresponding to i is "today" when i is 1, and the answer token corresponding to i is "day" when i is 2.
[0101] In summary, by calculating the first loss function for the retrieval network layer and the second loss function for the generation network layer, it is easier for the retrieval network layer to learn reasonable document representations and for the generation network layer to learn how to generate accurate answers. This enables the training of all parameters of the text generation model and trains the ability to generate correct answers based on relevant documents.
[0102] Step 206: Determine the target loss function based on the first loss function and the second loss function.
[0103] The target loss function can be understood as the joint loss function used for joint training of the text generation model.
[0104] In specific implementation, determining the target loss function based on the first loss function and the second loss function includes:
[0105] The target loss function is obtained by weighted summation of the first loss function and the second loss function.
[0106] Specifically, in order to achieve joint training of the text generation model, the first loss function and the second loss function can be weighted and summed to obtain the target loss function.
[0107] In practical applications, the target loss function is shown in the following formula.
[0108] Where λRep is the weight of the first loss function, and λGen is the weight of the second loss function. For the first loss function, This is the second loss function.
[0109] In summary, by weighting and summing the first and second loss functions, it is easier to jointly train the text generation model based on the obtained target loss function, thereby further ensuring the joint training of the retrieval network layer and the generation network layer in the text generation model.
[0110] Step 208: 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.
[0111] 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.
[0112] In practical applications, training of the retrieval network layer and training of the generation network layer are achieved through single attention, ensuring the model's inference performance.
[0113] In one embodiment of this disclosure, before adjusting the model parameters of the machine learning model according to the target loss function, the method further includes:
[0114] The training data is processed according to the retrieval network layer to obtain the first loss function;
[0115] The retrieval network layer is initialized and trained according to the first loss function.
[0116] Specifically, the training data can be processed according to the retrieval network layer to obtain the first loss function, and the retrieval network layer can be initialized and trained according to the first loss function.
[0117] In summary, by initializing the training of the retrieval network layer, the retrieval network layer is started, which facilitates further training.
[0118] In practice, the retrieval network layer can be initialized and trained using a contrastive learning method, as follows:
[0119] The training data also includes sample questions, first sample text associated with the sample questions, and second sample text not associated with the sample questions.
[0120] Accordingly, the step of processing the training data according to the retrieval network layer to obtain the first loss function includes:
[0121] Based on the retrieval network layer, the sample question is processed to obtain the predicted text corresponding to the sample question;
[0122] Calculate the first loss function based on the predicted text and the first sample text; or,
[0123] Based on the retrieval network layer, the sample question is processed to obtain the predicted text corresponding to the sample question;
[0124] The first loss function is calculated based on the predicted text and the second sample text.
[0125] In this context, the first sample text, which is associated with the sample question, can be understood as sample text that is related to the sample question to a certain degree. The second sample text, which is not associated with the sample question, can be understood as sample text that is not related to the sample question to a certain degree. It can be understood that 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 could be "Did it rain today?", and the second sample text could be "I am very happy today".
[0126] Based on this, the sample question can be processed using the retrieval network layer to obtain the predicted text corresponding to the sample question, and a first loss function can be calculated based on the predicted text and the first sample text; alternatively, the sample question can be processed using the retrieval network layer to obtain the predicted text corresponding to the sample text, and a first loss function can be calculated based on the predicted text and the second sample text. In practical applications, the first loss function can be the InfoNCE loss.
[0127] In addition, the text generation model can be trained based on other supervised or unsupervised training methods, and this disclosure does not limit this method.
[0128] In summary, by using positive and negative samples and a contrastive learning approach to initialize and train the retrieval network layer, the subsequent retrieval capabilities of the retrieval network layer are guaranteed.
[0129] In one embodiment of this disclosure, 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 includes:
[0130] Determine the model optimization task for the text generation model, and determine the optimized training data corresponding to the model optimization task;
[0131] The text generation model is optimized based on the optimized training data.
[0132] The model optimization task can be understood as a reflection task on the trained text generation model. During the reflection phase, the text generation model can reflect on its own errors, which can usually be optimized through contrastive learning. The training data for optimization can include both positive and negative samples.
[0133] Specifically, the optimization task for the text generation model can be determined, and the corresponding optimization training data can be determined. The optimization training data is then input into the text generation model to obtain the prediction results of the text generation model. Based on the prediction results, the optimization loss function is determined, and the text generation model is optimized based on the optimization loss function.
[0134] In practical applications, the optimized loss function is shown in the following formula.
[0135] Wherein, the optimization loss function can be the DPO function, X is the input optimization training data, and y w For positive samples, y l Let D be the negative sample, and D be the dataset containing the optimized training data, positive samples, and negative samples. π θ For the machine learning model to be trained, π ref This is a reference model.
[0136] In one embodiment of this disclosure, the model optimization task can be a task of reflecting on whether a problem needs to be retrieved. The optimization training data corresponding to the model optimization task includes training samples (i.e., sample problems) and training labels (i.e., whether the problem needs to be retrieved or not). 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. Based on the training labels and prediction results, the optimization loss function is calculated, and the text generation model is optimized based on the optimization loss function.
[0137] In another embodiment of this disclosure, the model optimization task can be a task of reflecting on whether the question and the retrieved document are related. In this case, the optimization training data corresponding to the model optimization task includes training samples (i.e., sample questions and sample text) and training labels (i.e., sample questions and sample text are related or sample questions and sample text are unrelated). Then, 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. Based on the training labels and prediction results, the optimization loss function is calculated, and the text generation model is optimized based on the optimization loss function.
[0138] In another embodiment of this disclosure, the model optimization task can be a task of reflecting on whether the generated answer is accurate. 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., whether the sample answer is correct or incorrect). The training samples and training labels can be input into the text generation model to obtain the prediction result output by the text generation model. Based on the training labels and prediction results, the optimization loss function is calculated, and the text generation model is optimized based on the optimization loss function.
[0139] In practical applications, natural language can be used to construct optimized training data, ensuring its naturalness and accuracy. The DPO algorithm can be used for multiple model optimization tasks.
[0140] In one embodiment of this disclosure, the model optimization task can be a constructed dynamic reflection task. This dynamic reflection task can be constructed based on the characteristics of the text generation model, thereby enabling the model optimization task to better adapt to the text generation model and achieve personalized optimization of the text generation model.
[0141] In summary, by reflexively optimizing the text generation model, its processing performance can be further improved. Furthermore, by simultaneously utilizing global information such as the retrieved document and the reflexive results, the text generation model can generate more accurate answers. Training the retrieval network layer results in a better representation and a better semantic space distribution, which is beneficial for subsequent text generation steps. Moreover, the jointly trained retrieval network layer has already seen the document content and can learn from it during the encoding process.
[0142] In summary, one embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model, thereby reducing model computational costs and response latency, and further improving model processing efficiency. Furthermore, when training the machine learning model containing the retrieval network layer and the generation network layer, a target loss function is determined using a first loss function and a second loss function. Based on the target loss function, the model parameters are adjusted to achieve joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and accuracy of the text generation model.
[0143] The following description, in conjunction with Figure 4, uses the application of the text generation model training method provided in this disclosure in text generation model training as an example to further illustrate the text generation model training method. Figure 4 shows a flowchart of the processing procedure of a text generation model training method provided in an embodiment of this disclosure, specifically including the following steps.
[0144] Step 402: Determine the machine learning model to be trained and the training data associated with the text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer.
[0145] Step 404: Process the training data according to the retrieval network layer to obtain the first loss function.
[0146] The training data may include sample questions, first sample text associated with the sample questions, and second sample texts not associated with the sample questions. The sample questions and first sample texts constitute positive samples, while the sample questions and second sample texts constitute negative samples. For example, if the sample question is "How is the weather today?", the first sample text could be "Did it rain today?", and the second sample text could be "I am very happy today".
[0147] 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.
[0148] Step 406: Initialize and train the retrieval network layer according to the first loss function.
[0149] Step 408: Process the training data according to the retrieval network layer and the generation network layer to obtain the first loss function and the second loss function.
[0150] The training data also includes sample questions, their associated sample texts, and sample answers. These sample questions, their associated sample texts, and sample answers can constitute positive samples for model training. For example, a sample question could be "Have you eaten?", the associated sample text could be "What did you eat today?", and the associated sample answer could be "I ate rice today".
[0151] Specifically, sample questions and sample texts can be input into the machine learning model to be trained. The sample questions and sample texts are 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 sample texts, the first loss function for the retrieval network layer is calculated, and based on the predicted answer and sample answer, the second loss function for the generation network layer is calculated.
[0152] Step 410: Determine the target loss function based on the first loss function and the second loss function.
[0153] Specifically, the target loss function can be obtained by weighted summation of the first loss function and the second loss function.
[0154] Step 412: Adjust the model parameters of the machine learning model according to the target loss function to obtain the trained text generation model.
[0155] Step 414: Determine the model optimization task for the text generation model and determine the corresponding optimized training data for the model optimization task.
[0156] Specifically, the model optimization task can be a task of reflecting on whether a problem needs to be retrieved. In this case, the optimization training data corresponding to the model optimization task includes training samples (i.e., sample problems) and training labels (i.e., whether the problem needs to be retrieved or not).
[0157] Model optimization tasks can also be tasks that reflect on whether the problem and the retrieved document are related. In this case, the optimization training data for the model optimization task includes training samples (i.e., sample questions and sample texts) and training labels (i.e., sample questions and sample texts are related or sample questions and sample texts are not related).
[0158] Model optimization tasks can also be tasks that reflect on whether the generated answers are accurate. In this case, the optimization training data for the model optimization task includes training samples (i.e., sample questions and sample answers) and training labels (i.e., whether the sample answers are correct or incorrect).
[0159] Step 416: Optimize the text generation model based on the optimized training data.
[0160] 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. Based on the training labels and prediction results, the optimization loss function can be calculated, and the text generation model can be optimized based on the optimization loss function.
[0161] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model, thereby reducing model computational costs and response latency, and further improving model processing efficiency. Furthermore, when training the machine learning model containing the retrieval network layer and the generation network layer, a target loss function is determined using a first loss function and a second loss function. Based on the target loss function, the model parameters are adjusted to achieve joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and accuracy of the text generation model.
[0162] Corresponding to the above method embodiments, this disclosure also provides an embodiment of a text generation model training device. Figure 5 shows a schematic diagram of the structure of a text generation model training device provided in one embodiment of this disclosure. As shown in Figure 5, the device includes:
[0163] The first determining module 502 is configured to determine the machine learning model to be trained and the training data associated with the text generation task, wherein the machine learning model to be trained includes a retrieval network layer and a generation network layer.
[0164] 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;
[0165] The second determining module 506 is configured to determine a target loss function based on the first loss function and the second loss function;
[0166] 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.
[0167] In one optional embodiment, the training data includes sample questions and sample text associated with the sample questions;
[0168] The processing module 504 is further configured to:
[0169] Based on the retrieval network layer, the sample question is processed to obtain the predicted text corresponding to the sample question;
[0170] Based on the predicted text and the sample text, determine the first loss function for the retrieval network layer;
[0171] Based on the generative network layer, the sample question and the predicted text are processed to obtain the predicted answer corresponding to the sample question;
[0172] Based on the predicted answer and the sample answer, the second loss function for the generator network layer is determined.
[0173] In an optional embodiment, the second determining module 506 is further configured to:
[0174] The target loss function is obtained by weighted summation of the first loss function and the second loss function.
[0175] In an optional embodiment, the adjustment module 508 is further configured to:
[0176] The training data is processed according to the retrieval network layer to obtain the first loss function;
[0177] The retrieval network layer is initialized and trained according to the first loss function.
[0178] In an optional embodiment, the training data further includes sample questions, first sample text associated with the sample questions, and second sample text not associated with the sample questions;
[0179] The adjustment module 508 is further configured to:
[0180] Based on the retrieval network layer, the sample question is processed to obtain the predicted text corresponding to the sample question;
[0181] Calculate the first loss function based on the predicted text and the first sample text; or,
[0182] Based on the retrieval network layer, the sample question is processed to obtain the predicted text corresponding to the sample question;
[0183] The first loss function is calculated based on the predicted text and the second sample text.
[0184] In an optional embodiment, the adjustment module 508 is further configured to:
[0185] Determine the model optimization task for the text generation model, and determine the optimized training data corresponding to the model optimization task;
[0186] The text generation model is optimized based on the optimized training data.
[0187] In an optional embodiment, the machine learning model to be trained further includes a feature processing network layer, which performs feature processing on the training data to obtain feature vectors, and outputs the feature vectors to the retrieval network layer and the generation network layer respectively. The retrieval network layer processes the training data according to the feature vectors, and the generation network layer processes the training data according to the feature vectors.
[0188] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model, thereby reducing model computational costs and response latency, and further improving model processing efficiency. Furthermore, when training the machine learning model containing the retrieval network layer and the generation network layer, a target loss function is determined using a first loss function and a second loss function. Based on the target loss function, the model parameters are adjusted to achieve joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and accuracy of the text generation model.
[0189] The above is an illustrative scheme of a text generation model training device according to this embodiment. It should be noted that the technical solution of this text generation model training device and the technical solution of the text generation model training method described above belong to the same concept. For details not described in detail in the technical solution of the text generation model training device, please refer to the description of the technical solution of the text generation model training method described above.
[0190] Referring to Figure 6, Figure 6 shows a flowchart of a text generation method provided according to an embodiment of the present disclosure, which specifically includes the following steps.
[0191] Step 602: Identify the reference text and determine the target problem for the reference text;
[0192] Step 604: Input the target question and the reference text into the text generation model to obtain the target text corresponding to the target question;
[0193] 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 from the reference text. The generation network layer is used to generate 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 present disclosure.
[0194] In an optional embodiment, the text generation model further includes a feature processing network layer, which performs feature processing on the target question and the reference text to obtain feature vectors, and outputs the feature vectors to the retrieval network layer and the generation network layer respectively. The retrieval network layer processes the reference text according to the feature vectors, and the generation network layer processes the reference text segment according to the feature vectors.
[0195] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model, thereby reducing model computational costs and response latency, and further improving model processing efficiency. Furthermore, when training the machine learning model containing the retrieval network layer and the generation network layer, a target loss function is determined using a first loss function and a second loss function. Based on the target loss function, the model parameters are adjusted to achieve joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and accuracy of the text generation model.
[0196] Corresponding to the above method embodiments, this disclosure also provides a text generation apparatus embodiment. Figure 7 shows a schematic diagram of the structure of a text generation apparatus provided in one embodiment of this disclosure. As shown in Figure 7, the apparatus includes:
[0197] The determination module 702 is configured to determine a reference text and determine a target problem for the reference text;
[0198] Input module 704 is configured to input the target question and the reference text into a text generation model to obtain the target answer corresponding to the target question;
[0199] 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 from the reference text. The generation network layer is used to generate 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 present disclosure.
[0200] In an optional embodiment, the text generation model further includes a feature processing network layer, which performs feature processing on the target question and the reference text to obtain feature vectors, and outputs the feature vectors to the retrieval network layer and the generation network layer respectively. The retrieval network layer processes the reference text according to the feature vectors, and the generation network layer processes the reference text segment according to the feature vectors.
[0201] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model, thereby reducing model computational costs and response latency, and further improving model processing efficiency. Furthermore, when training the machine learning model containing the retrieval network layer and the generation network layer, a target loss function is determined using a first loss function and a second loss function. Based on the target loss function, the model parameters are adjusted to achieve joint training of the retrieval network layer and the generation network layer, further ensuring the processing performance and accuracy of the text generation model.
[0202] The above is an illustrative scheme of a text generation device according to this embodiment. It should be noted that the technical solution of this text generation device and the technical solution of the above-described text generation method belong to the same concept. For details not described in detail in the technical solution of the text generation device, please refer to the description of the technical solution of the above-described text generation method.
[0203] Referring to Figure 8, Figure 8 shows a flowchart of an answer generation method provided according to an embodiment of the present disclosure, which specifically includes the following steps.
[0204] Step 802: Receive reference audio and target question for the reference audio sent by the client;
[0205] Step 804: Perform conversion processing on the reference audio to obtain the reference text corresponding to the reference audio;
[0206] Step 806: Input the target question and the reference text into the answer generation model to obtain the target answer corresponding to the target question;
[0207] Step 808: Send the target answer to the client;
[0208] To achieve display through the client's display interface;
[0209] 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 from the reference text. 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 present disclosure.
[0210] Specifically, this answer generation method can be applied to the server side. The server can receive reference audio and a target question related to the reference audio sent by the user through the client. It then processes the reference audio to obtain the corresponding reference text. The target question and reference text are input into the answer generation model to obtain the target answer. The target answer is then sent to the client and displayed to the user through the client's interface. The answer generation model can be understood as the aforementioned text generation model.
[0211] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model. This reduces model computational overhead and response latency, further improving model processing efficiency. Through data interaction between the client and server and the invocation of the answer generation model, answers to user-submitted questions are generated, ensuring a positive user experience.
[0212] Corresponding to the above method embodiments, this disclosure also provides an answer generation device embodiment. Figure 9 shows a schematic diagram of another answer generation device provided in one embodiment of this disclosure. As shown in Figure 9, the device includes:
[0213] The receiving module 902 is configured to receive reference audio sent by the client and a target question for the reference audio;
[0214] The conversion module 904 is configured to perform conversion processing on the reference audio to obtain reference text corresponding to the reference audio.
[0215] Input module 906 is configured to take the target question and the reference text input answer generation model to obtain the target answer corresponding to the target question;
[0216] The sending module 908 is configured to send the target answer to the client and display it through the client's display interface;
[0217] 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 from the reference text. 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 present disclosure.
[0218] One embodiment of this disclosure unifies the model foundation of the retrieval network layer and the generation network layer by setting them in a single machine learning model. This reduces model computational overhead and response latency, further improving model processing efficiency. Through data interaction between the client and server and the invocation of the answer generation model, answers to user-submitted questions are generated, ensuring a positive user experience.
[0219] The above is a schematic scheme of an answer generation device according to this embodiment. It should be noted that the technical solution of this answer generation device and the technical solution of the answer generation method described above belong to the same concept. For details not described in detail in the technical solution of the answer generation device, please refer to the description of the technical solution of the answer generation method described above.
[0220] Figure 10 shows a structural block diagram of a computing device 1000 according to an embodiment of the present disclosure. 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 a database 1050 is used to store data.
[0221] The computing device 1000 also includes an access device 1040, which enables the computing device 1000 to communicate via one or more networks 1060. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 1040 may include one or more of any type of wired or wireless network interface (e.g., a network interface controller (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0222] In one embodiment of this disclosure, the aforementioned components of the computing device 1000, as well as other components not shown in FIG. 10, may be interconnected, for example, via a bus. It should be understood that the computing device block diagram shown in FIG. 10 is merely for illustrative purposes and is not intended to limit the scope of this disclosure. Those skilled in the art can add or replace other components as needed.
[0223] The computing device 1000 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 1000 can also be a mobile or stationary server.
[0224] The processor 1020 is used to execute the following computer program / instructions, which, when executed by the processor, implement the steps of the above method.
[0225] The various embodiments in this disclosure are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the computing device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0226] An embodiment of this disclosure also provides a computer-readable storage medium storing a computer program / instructions that, when executed by a processor, implement the steps of the above-described method.
[0227] The various embodiments in this disclosure are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the computer-readable storage medium embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the description of the method embodiments.
[0228] An embodiment of this disclosure also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described method.
[0229] The above is an illustrative scheme of a computer program product according to this embodiment. It should be noted that the technical solution of this computer program product and the technical solution of the above method belong to the same concept, and all 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.
[0230] The foregoing has described specific embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0231] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0232] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this disclosure are not limited to the described order of actions, because according to the embodiments of this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments of this disclosure.
[0233] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0234] The preferred embodiments disclosed above are merely illustrative of this disclosure. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments of this disclosure. These embodiments are selected and specifically described in this disclosure to better explain the principles and practical applications of the embodiments of this disclosure, thereby enabling those skilled in the art to better understand and utilize this disclosure. This disclosure is limited only by the claims and their full scope and equivalents.
Claims
1. A text generation model training method, comprising: 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 comprises 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 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.
2. The text generation model training method of claim 1, wherein the training data comprises a sample question and a sample text associated with the sample question; and the 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 comprises: 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; determining the second loss function for the generation network layer according to the predicted answer and the sample answer.
3. The text generation model training method of claim 1, wherein the determining a target loss function according to the first loss function and the second loss function comprises: performing weighted summation on the first loss function and the second loss function to obtain the target loss function.
4. The text generation model training method of claim 1, further comprising, before the adjusting model parameters of the machine learning model according to the target loss function: processing the training data according to the retrieval network layer to obtain the first loss function; initializing training the retrieval network layer according to the first loss function.
5. The text generation model training method of claim 4, wherein the training data further comprises a first sample text associated with the sample question and a second sample text not associated with the sample question, and the processing the training data to obtain the first loss function comprises: calculating the first loss function according to the predicted text and the first sample text; or processing the sample question to obtain a predicted text corresponding to the sample question, and calculating the first loss function according to the predicted text and the second sample text.
6. The text generation model training method of claim 1, further comprising, after the adjusting model parameters of the machine learning model according to the target loss function to obtain a trained text generation model: 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.
7. The text generation model training method of claim 1, wherein the machine learning model to be trained further comprises a feature processing network layer, the feature processing network layer is configured to perform feature processing on the training data to obtain a feature vector, and the feature vector is output to the retrieval network layer and the generation network layer respectively, the retrieval network layer is configured to process the training data according to the feature vector, and the generation network layer is configured to process the training data according to the feature vector.
8. The text generation model training method of claim 1, further comprising, after obtaining the feature vector output by the feature processing network layer: caching the feature vector, wherein the cached feature vector is used in the retrieval stage and the generation stage. 9.The text generation model training method of claim 1, further comprising: a sorting network layer and a judgment network layer, the judgment network layer is configured to judge the correlation degree between a plurality of text segments and the sample question, and the sorting network layer is configured to sort the plurality of text segments according to the judgment result of the judgment network layer, and determine the predicted text from the plurality of text segments based on the sorting result.
10. A text generation method, comprising: determining a reference text and determining a target question 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; wherein the text generation model comprises a retrieval network layer and a generation network layer, the retrieval network layer is configured to retrieve a reference text segment associated with the target question in the reference text, and the generation network layer is configured to generate a target text corresponding to the target question according to the reference text segment, and the text generation model is trained according to the method of any one of claims 1-9.
11. The text generation method of claim 10, wherein the text generation model further comprises a feature processing network layer, the feature processing network layer is configured to perform feature processing on the target question and the reference text to obtain a feature vector, and the feature vector is output to the retrieval network layer and the generation network layer respectively, the retrieval network layer is configured to process the reference text according to the feature vector, and the generation network layer is configured to process the reference text segment according to the feature vector.
12. An answer generation method, comprising: receiving a reference audio sent by a client and a target question for the reference audio; performing conversion processing on 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; wherein the answer generation model comprises a retrieval network layer and a generation network layer, the retrieval network layer is configured to retrieve a reference text segment associated with the target question in the reference text, and the generation network layer is configured to generate a target answer corresponding to the target question according to the reference text segment, and the answer generation model is trained according to the method of any one of claims 1-9.
13. A computing device comprising: a memory and a processor; said memory for storing computer programs / instructions, said processor for executing said computer programs / instructions, which, when executed by the processor, implement the steps of the method of any one of claims 1 to 12.
14. A computer readable storage medium storing computer programs / instructions, which, when executed by a processor, implement the steps of the method of any one of claims 1 to 12.
15. A computer program product comprising computer programs / instructions, which, when executed by a processor, implement the steps of the method of any one of claims 1 to 12.
Citation Information
Patent Citations
Question and answer model training method and device, question and answer processing method and device and storage medium
CN116257611A
Document detection model training method and device and electronic equipment
CN117333889A
Machine learning model training method, text-based image search method, automatic question and answer method, computing device, computer readable storage medium and computer program product
CN118132988A
Text generation model training method, text generation method and answer generation method
CN118364060A
Method and apparatus for multi-document question answering
US20210174161A1