Text processing method, device, equipment and medium
Through multiple iterative processing and network parameter correction, the training data set was updated, which solved the problem of insufficient summary data of film and television scripts, improved the quality of summary generation, and improved the efficiency of review and understanding of film and television scripts.
Patent Information
- Application Number
- CN202410870612.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-01
AI Technical Summary
In the existing technology, due to the limited amount of film and television script summary data, the script summary generation model is prone to overfitting and low generalization problems, which reduces the quality of summary generation.
By obtaining the reference model and the model to be trained, the original text in the film and television script is processed for multiple iterations, and the network parameters are corrected using the reference predicted text, sample predicted text and annotation summary, and the corrected text is used as a new sample to update training data set to enrich the diversity of training data.
It improves the summary generation quality of the summary generation model, reduces the problems of overfitting and low generalization, and improves the efficiency of film and television script review and understanding.
Smart Images

Figure CN118410160B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text processing method, device, equipment and medium. Background Art
[0002] In the scenario of understanding long text content, since the long text content is too long, for example, when the long text is a film or television script, the film or television script may have at least a few thousand scenes or at most tens of thousands of scenes, and each scene may include dozens to thousands of words, it is difficult to read manually, which brings difficulties to the review and understanding of the film and television script.
[0003] At present, AI (Artificial Intelligence) can be used to automate script plot understanding. The conventional method can be to use a trained script summary extraction model to extract a summary of each scene in the film and television script and generate a summary of each scene, which helps film and television reviewers to quickly understand the plot and evaluate the value of the film and television script. Among them, the training of the above-mentioned script summary extraction model requires the collection of film and television drama summary data. Using these collected film and television drama summary data, the current open source language model is trained to generate script summaries, and finally a script summary generation model is obtained. However, due to the limited amount of collected film and television drama summary data (the annotation cost of high-quality summary data is too high, and a large amount of film and television drama summary data cannot be provided), the script summary generation model trained using this data is prone to overfitting, resulting in the problem of low generalization under changes in text language, which reduces the summary generation quality of the script summary generation model. Summary of the invention
[0004] The embodiments of the present application provide a text processing method, apparatus, device, and medium, which can enrich the diversity of training data and thereby improve the summary generation quality of a summary generation model.
[0005] An embodiment of the present application provides a text processing method, including:
[0006] Obtain the reference model and the model to be trained of the i-th iteration, and obtain the text training set of the i-th iteration; each training sample in the text training set of the i-th iteration includes the original text, the negative summary text and the positive summary text, and i is a positive integer;
[0007] By using the reference model of the i-th iteration, the original text contained in the training samples in the text training set of the i-th iteration is subjected to summary extraction processing to obtain a reference prediction text;
[0008] By using the to-be-trained model of the i-th iteration, the original text contained in the training sample in the text training set of the i-th iteration is subjected to summary extraction processing to obtain the sample prediction text;
[0009] According to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, the network parameters of the model to be trained of the i-th iteration are modified to obtain the summary generation model of the i-th iteration; the summary generation model of the i-th iteration is used as the reference model and the model to be trained of the i+1-th iteration;
[0010] The sample prediction text is corrected to obtain the sample corrected text, the original text, the sample prediction text and the sample corrected text are encapsulated as new samples, and the new samples are added to the text training set of the i+1th iteration; the text training set of the i+1th iteration is used to train the model to be trained of the i+1th iteration.
[0011] An embodiment of the present application provides a text processing method, including:
[0012] A model acquisition module is used to obtain a reference model and a model to be trained for the i-th iteration, and obtain a text training set for the i-th iteration; each training sample in the text training set for the i-th iteration includes an original text, a negative summary text, and a positive summary text, and i is a positive integer;
[0013] The first prediction module is used to perform summary extraction processing on the original text contained in the training samples in the text training set of the i-th iteration through the reference model of the i-th iteration to obtain a reference prediction text;
[0014] The second prediction module is used to extract the original text contained in the training sample in the text training set of the i-th iteration through the to-be-trained model of the i-th iteration to obtain the sample prediction text;
[0015] A parameter correction module is used to correct the network parameters of the model to be trained of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, so as to obtain the summary generation model of the i-th iteration; the summary generation model of the i-th iteration is used as the reference model and the model to be trained of the i+1-th iteration;
[0016] The training data updating module is used to correct the sample prediction text to obtain the sample correction text, encapsulate the original text, the sample prediction text and the sample correction text as new samples, and add the new samples to the text training set of the i+1th iteration; the text training set of the i+1th iteration is used to train the model to be trained of the i+1th iteration.
[0017] The model acquisition module acquires the reference model and the model to be trained of the i-th iteration to perform the following steps:
[0018] Get the summary generation model of the i-1th iteration; when i is 1, the summary generation model of the i-1th iteration is the pre-trained language model;
[0019] The summary generation model of the i-1th iteration is determined as the reference model of the i-th iteration, and the summary generation model of the i-1th iteration is determined as the model to be trained of the i-th iteration.
[0020] The second prediction module uses the training model of the i-th iteration to extract the original text contained in the training sample in the text training set of the i-th iteration to obtain the sample prediction text, which is used to perform the following steps:
[0021] Convert the original text contained in the training samples in the text training set of the i-th iteration into sample embedding representation;
[0022] Through the feature extraction component in the model to be trained in the i-th iteration, feature extraction is performed on the sample embedding representation to obtain the sample attention feature;
[0023] Through the fully connected layer in the model to be trained in the i-th iteration, the sample attention features are transformed to obtain the sample prediction text.
[0024] The feature extraction component in the model to be trained in the i-th iteration includes N attention subcomponents, where N is a positive integer;
[0025] The second prediction module performs feature extraction processing on the sample embedding representation through the feature extraction component in the training model of the i-th iteration to obtain the sample attention feature, which is used to perform the following steps:
[0026] Get the input features of the t-th attention subcomponent among N attention subcomponents; when t is 1, the input features of the t-th attention subcomponent include the sample embedding representation; when t is not 1, the input features of the t-th attention subcomponent include the output features of the t-1-th attention subcomponent; t is a positive integer less than or equal to N;
[0027] According to the self-attention mask layer in the t-th attention sub-component, the input features of the t-th attention sub-component are subjected to attention mask processing to obtain the attention mask features;
[0028] The attention mask feature and the input feature of the t-th attention subcomponent are combined into the first residual feature, and the first residual feature is normalized to obtain the sample normalized feature;
[0029] According to the feedforward network layer in the t-th attention subcomponent, the sample normalized features are subjected to feature transformation processing to obtain sample transformation features;
[0030] The sample transformation feature and the sample normalization feature are combined into a second residual feature, the second residual feature is normalized to obtain the output feature of the tth attention component, and the output feature of the Nth attention component is determined as the sample attention feature.
[0031] Among them, the second prediction module performs attention masking on the input features of the t-th attention subcomponent according to the self-attention mask layer in the t-th attention subcomponent to obtain the attention mask feature, which is used to perform the following steps:
[0032] According to the transformation weight matrix corresponding to the self-attention mask layer in the t-th attention subcomponent, the input features of the t-th attention subcomponent are transformed into a query matrix, a key matrix, and a value matrix;
[0033] Perform a dot multiplication operation on the transposed matrices of the query matrix and the key matrix to obtain the candidate weight matrix and obtain the number of columns corresponding to the query matrix;
[0034] The ratio between the candidate weight matrix and the square root of the number of columns is normalized to obtain the attention weight matrix, and the attention mask feature is determined according to the dot product between the attention weight matrix and the value matrix.
[0035] The parameter correction module corrects the network parameters of the training model of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text to obtain the summary generation model of the i-th iteration, which is used to perform the following steps:
[0036] Obtain a first prediction probability that the reference prediction text is a positive summary text, and obtain a second prediction probability that the reference prediction text is a negative summary text;
[0037] Obtaining a third prediction probability that the sample prediction text is a positive summary text, and obtaining a fourth prediction probability that the sample prediction text is a negative summary text;
[0038] Determine the training loss corresponding to the model to be trained for the i-th iteration according to a first logarithmic probability between the first prediction probability and the third prediction probability, and a second logarithmic probability between the second prediction probability and the fourth prediction probability;
[0039] According to the training loss corresponding to the model to be trained in the i-th iteration, the network parameters of the model to be trained in the i-th iteration are modified to obtain the pre-trained model of the i-th iteration;
[0040] The network parameters of the pre-trained model of the i-th iteration are fine-tuned to obtain the summary generation model of the i-th iteration.
[0041] The parameter correction module determines the training loss corresponding to the model to be trained for the i-th iteration according to the first logarithmic probability between the first prediction probability and the third prediction probability, and the second logarithmic probability between the second prediction probability and the fourth prediction probability, and is used to perform the following steps:
[0042] Obtaining a first logarithmic probability between the first predicted probability and the third predicted probability, and obtaining a second logarithmic probability between the second predicted probability and the fourth predicted probability;
[0043] The difference between the first logarithmic probability and the second logarithmic probability is activated to obtain a probability activation value, and the probability activation value is logarithmically operated to obtain the training loss corresponding to the model to be trained for the i-th iteration.
[0044] The parameter correction module fine-tunes the network parameters of the pre-trained model of the i-th iteration to obtain the summary generation model of the i-th iteration, which is used to perform the following steps:
[0045] Obtain a text test set; each test sample in the text test set includes a test text and an annotation summary;
[0046] Through the pre-trained model of the i-th iteration, the test text contained in the test sample in the text test set is abstracted and processed to obtain the test prediction text;
[0047] Determine the test loss corresponding to the pre-trained model of the i-th iteration based on the test prediction text and the annotation summary;
[0048] According to the test loss corresponding to the pre-trained model of the i-th iteration, the network parameters of the pre-trained model of the i-th iteration are fine-tuned to obtain the summary generation model of the i-th iteration.
[0049] The training data updating module corrects the sample prediction text to obtain the sample correction text, which is used to perform the following steps:
[0050] The correctness of the sample prediction text is evaluated through the standard language model to obtain the evaluation result and evaluation reason corresponding to the sample prediction text;
[0051] If the evaluation result indicates that the sample prediction text is an erroneous summary, the sample prediction text is corrected according to the evaluation reason to obtain a sample corrected text.
[0052] Wherein, the text processing device also includes:
[0053] The sample maintenance module is used to suspend the correction of the sample prediction text if the evaluation result indicates that the sample prediction text is a correct summary, and add the training sample corresponding to the sample prediction text in the text training set of the i-th iteration to the text training set of the i+1-th iteration.
[0054] Wherein, the text processing device also includes:
[0055] A training end module, used for training the to-be-trained model of the i+1th iteration according to the text training set of the i+1th iteration, to obtain a summary generation model of the i+1th iteration;
[0056] The training end module is further used to determine the summary generation model of the i+1th iteration as the target generation model if the training loss corresponding to the to-be-trained model of the i+1th iteration is the same as the training loss corresponding to the to-be-trained model of the i-th iteration.
[0057] Wherein, the text processing device also includes:
[0058] The script splitting module is used to obtain the episode plot set corresponding to the film and television script, split each episode plot in the episode plot set into scenes, and obtain the scene plot corresponding to each episode plot;
[0059] The plot summary extraction module is used to input the scenes corresponding to each episode into the target generation model in sequence according to their positions in the film and television script, and obtain the plot summary corresponding to each episode; the plot summary is used to assist the creative object in the subsequent creation of the film and television script.
[0060] On one hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory is connected to the processor, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method provided in the above aspect of the embodiment of the present application.
[0061] On one hand, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for being loaded and executed by a processor, so that a computer device with a processor executes the method provided in the above aspect of the embodiment of the present application.
[0062] According to one aspect of the present application, a computer program product is provided, which may include a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method provided in the above aspect.
[0063] In the embodiment of the present application, when the i-th iteration is executed in the model training stage, the text training set of the i-th iteration is obtained, and each training sample in the text training set includes the original text, the negative summary text and the positive summary text; the original text contained in the training sample in the text training set of the i-th iteration is extracted by the reference model of the i-th iteration to obtain the reference prediction text; the original text is extracted by the model to be trained of the i-th iteration to obtain the sample prediction text. The network parameters of the model to be trained of the i-th iteration are corrected by the reference prediction text output by the reference model, the sample prediction text, the positive summary text and the negative summary text output by the model to be trained to obtain the summary generation model trained for the i-th iteration. At this time, the summary generation model of the i-th iteration can be backed up as the reference model of the i+1th iteration, and the summary generation model of the i-th iteration can also be used as the model to be trained of the i+1th iteration. At the same time, the sample prediction text can be corrected to obtain a more correct summary text (sample correction text), and the original text, sample prediction text and sample correction text are encapsulated as a new sample, which can be used as a training sample for the model to be trained in the i+1th iteration. By obtaining more correct summary data in real time during the training phase and updating the text training set for each iteration, the diversity of training data can be enriched, thereby improving the summary generation quality of the summary generation model. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0065] Figure 1 It is a structural diagram of a network architecture provided by an embodiment of the present application;
[0066] Figure 2 This is a schematic diagram of a scenario for generating a text summary provided by an embodiment of the present application;
[0067] Figure 3 This is a flowchart of a text processing method provided in an embodiment of the present application. Figure 1 ;
[0068] Figure 4 It is a flowchart of a model training process provided by an embodiment of the present application;
[0069] Figure 5 This is a flowchart of a text processing method provided in an embodiment of the present application. Figure 2 ;
[0070] Figure 6 is a schematic diagram of correction of a sample prediction text provided in an embodiment of the present application;
[0071] Figure 7 This is a schematic diagram of a scene in which a target generation model provided in an embodiment of the present application is used in understanding the plot of a film or television script;
[0072] Figure 8 This is a structural diagram of a text processing device provided in an embodiment of the present application. Figure 1 ;
[0073] Fig. 9 This is a structural diagram of a text processing device provided in an embodiment of the present application. Figure 2 ;
[0074] Fig.10 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0075] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0076] For ease of understanding, the basic technical concepts involved in the embodiments of the present application are described below:
[0077] Natural language processing (NLP) technology: Natural language processing is an important direction in the fields of computer science and artificial intelligence; it can be used to study various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Natural language processing technology generally includes text processing, semantic understanding, machine translation, robot question answering, knowledge graphs and other technologies. In the embodiment of the present application, the input text can be semantically understood by the trained summary generation model to generate summary data for the input text; since the number of words in the summary data is much less than the number of words in the input text, it is beneficial for users to quickly understand the text content.
[0078] Film and TV Script: A document compiled by screenwriters for easy interpretation. Film and TV scripts are usually composed of time, place, characters, and dialogues between characters, and are used to guide the subsequent filming of the film and TV series.
[0079] Plot summary: Plot summary refers to the text information extracted from a text from the perspective of event description that can summarize the text, which can usually include time, place, characters, causes, process, results, etc. Plot summary can have different hierarchical dimensions. In other words, plot summary can contain multiple event classifications; for example, different plot types, different era backgrounds (different era backgrounds have different language styles, such as the Tang Dynasty and the Qing Dynasty have different language styles), different character relationships can drive different vocabulary ranges, etc.
[0080] DPO (Direct Preference Optimization) learning: DPO learning is a reinforcement learning method that is stable, high-performance, and computationally lightweight. It does not require fitting a reward model, sampling from a language model (LM) during fine-tuning, or a large amount of hyperparameter adjustment. Fine-tuning a pretrained language model using DPO can improve the quality of summary generation. A pretrained language model is a language model trained on large-scale text data that can learn rich language knowledge and grammatical rules; pretrained language models can be applied to various natural language processing tasks (for example, text summary prediction tasks).
[0081] Chain of thought (CoT): CoT allows network models (e.g., pre-trained language models) to decompose multi-step complex tasks into multiple intermediate steps, which helps to reduce the processing time of complex tasks.
[0082] Supervised Fine-Tuning (SFT): Supervised fine-tuning can utilize the parameters and structure of a pre-trained model (for example, a pre-trained language model) to avoid training the model from scratch, thereby accelerating the model training process and improving the model's performance on the target task.
[0083] See also Figure 1 , Figure 1 1 is a schematic diagram of a network architecture provided by an embodiment of the present application. The network architecture may include a server 10d and a terminal cluster. The terminal cluster may include one or more terminal devices. The number of terminal devices included in the terminal cluster is not limited. Figure 1As shown, the terminal cluster may specifically include terminal device 10a, terminal device 10b, and terminal device 10c, etc.; all terminal devices in the terminal cluster (for example, terminal device 10a, terminal device 10b, and terminal device 10c, etc.) may be connected to the server 10d through a network connection, so that each terminal device may exchange data with the server 10d through the network connection.
[0084] The terminal devices of the terminal cluster may include smart phones, tablet computers, laptops, PDAs, desktop computers, wearable devices (such as smart watches, smart bracelets, etc.), smart voice interaction devices, smart home appliances (such as smart TVs, etc.), vehicle-mounted devices, aircraft and other electronic devices. This application does not limit the type of terminal devices.
[0085] Among them, server 10d can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides 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 delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms. This application does not limit the type of server.
[0086] Understandably, Figure 1 Each terminal device shown can run a target generation model, and a text to be processed can be input into the target generation model. The target generation model can be used to perform summary extraction processing on the text to be processed to obtain a summary text corresponding to the text to be processed. The text to be processed may refer to the text content that needs to be understood. The summary text refers to the key content generated by the automatic text content understanding of the text to be processed using the target generation model; that is, the summary text refers to the text information that is simplified and has the same semantics as the text to be processed. The target generation model is a summary generation model obtained by learning DPO (direct preference optimization algorithm) using text summary data; the text summary data here may include an original text and two summary texts (a better summary text and a worse summary text). The target generation model can be used to generate a summary text corresponding to the text to be processed, which helps to quickly understand the content of the text to be processed.
[0087] See also Figure 2 , Figure 2 Schematic diagram of a scenario for generating a text summary provided by an embodiment of the present application. Figure 2 As shown in Figure 2, the above target generation model can be applied in the text summary generation scenario. Figure 2The terminal device 20a shown can be an electronic device running the above-mentioned target generation model; the current display interface in the terminal device 20a can be a summary generation page 20b, through which the target generation model can be called, and the target generation model can be used to generate a summary text corresponding to any input text.
[0088] Among them, the summary generation page 20b may include a first area 20c and a second area 20d. The first area 20c can be used to input text to be processed that requires text content understanding. When text is input in the first area 20c and the input operation is completed, the calling operation of the target generation model 20e can be triggered; the second area 20d can be used to display the summary text output by the target generation model 20e.
[0089] like Figure 2 As shown, when the user enters the text to be processed in the first area 20c of the summary generation page 20b: "Yesterday, the report about 'genetically modified mosquitoes to be released in City A' was wrong. Experts said that the mosquitoes to be released in City A are 'beneficial' mosquitoes carrying natural symbiotic bacteria, not genetically modified mosquitoes. The symbiotic bacteria can reduce the ability of mosquito vectors to spread dengue fever and reduce the number of mosquitoes. This is to correct.", the terminal device 20a can call the target generation model 20e, input the text to be processed in the first area 20c into the target generation model 20e, and perform summary extraction processing on the text to be processed in the first area 20c through the target generation model 20e to obtain the summary text corresponding to the text to be processed: "The mosquitoes released in City A carry natural symbiotic bacteria, which can reduce the ability of mosquito vectors to spread dengue fever and reduce the number of mosquitoes", and display the summary text in the second area 20d.
[0090] Understandably, Figure 2 The summary generation page shown is only an example of a specific application scenario of the target generation model. The application scenario of the target generation model can also be presented in other ways, such as in the form of "question-answer", etc. This application does not limit this.
[0091] The training process of the target generation model can be found in Figures 3 to 7 The training process of the target generation model may include multiple iterations, and one epoch iteration refers to completing one full data training; for example, when the training data set used to train the target generation model is recorded as a text data set Then the text training set is completed After a complete training of all training samples in the training set, it can be called an iteration (or a round of iteration). In the embodiment of the present application, the text data set used in each full data training may be the same or different, and the summary generation model trained in the previous iteration can be used as the initial model for the next iteration training. For ease of understanding, in the training process of the target generation model, the initial model of each iteration can be called the model to be trained, and the current model to be trained after each iteration is completed can be called the summary generation model. For example, the summary generation model of the previous iteration can be used as the model to be trained in the next iteration, and the summary generation model finally obtained after multiple iterations can be called the target generation model.
[0092] See also Figure 3 , Figure 3 This is a flowchart of a text processing method provided in an embodiment of the present application. Figure 1 It can be understood that the text processing method can be executed by a computer device, which can be a server (such as Figure 1 The server 10d shown in FIG. 10A ) may also be a terminal device (such as Figure 1 Any terminal device in the terminal cluster shown in the figure), this application does not limit this. Figure 3 As shown, the text processing method may include the following steps S101 to S105:
[0093] Step S101, obtaining a reference model and a model to be trained for the i-th iteration, and obtaining a text training set for the i-th iteration.
[0094] In the embodiments of the present application, each iteration in the model training process involves a reference model and a model to be trained. The reference model may be a currently open source language model, or may be an SFT fine-tuning model generated by fine-tuning the currently open source language model using the collected text summary data, or a pre-trained language model trained using the collected text summary data, etc. The present application does not limit the method for obtaining the reference model. The model to be trained may refer to a model generated after updating parameters using a reinforcement learning method based on the reference model.
[0095] Among them, the reference model and the model to be trained involved in the embodiment of the present application may have the same network structure, but the training method and network parameters used by the reference model and the model to be trained are different; wherein, the model to be trained will update the network parameters at each iteration, and back up the network parameters of the model to be trained at the end of each iteration. At this time, the backed-up model to be trained can be called a summary generation model. The reference model does not need to participate in the update of network parameters in the iteration of the training process, but only uses the summary generation model backed up in the previous iteration as the reference model for the next iteration. Among them, the network structure of the reference model and the model to be trained can be any one of the network structures of Variational Auto-Encoders (VAE), Recurrent Neural Network (RNN), Transformer model architecture (a deep learning model using an attention mechanism), Tencent Hunyuan large model, Baichuan large model, llama2 (an open source language large model), or it can be a combination of at least two of the above network structures, or it can be a deformation of any of the above network structures. This application does not limit the network structure of the reference model and the model to be trained.
[0096] It is understandable that before model training, text summary data can be collected offline and used as training samples in the initialization text training set. The initialization text training set can be used as the text training set for the first iteration in the model training process, that is, the initialization text training set can be used for the first training reinforcement learning task; for ease of understanding, the text training set for the first iteration can be recorded as .
[0097] Among them, the training sample (text summary data) may include an original text and two summary texts. The two summary texts in the training sample may record which summary text is better. The better summary may be called a positive summary text (recorded as chosen), and the worse summary may be called a negative summary text (recorded as rejected). The two summary texts may be called summary comparison data and may be used for reinforcement learning. All training samples involved in the embodiments of the present application may be recorded as , where text represents the original text in the training sample, represents the negative summary text in the training sample, Represents the positive summary text in the training sample.
[0098] In one or more embodiments, the text dataset The method for obtaining the training samples in may include: obtaining the original text to be trained, and using the currently disclosed large language model to obtain the summary text corresponding to the original text. Among them, the large language model may include but is not limited to any of the language models such as GPT4 (Generative Pre-trained Transformer 4, the 4th generation generative pre-trained language model based on the Transformer structure), Qwen1.5-32B-Chat (an open source large language model), llama3-70B (a general language model), Skywork-13B (an open source large language model), Tencent Hunyuan large model, Baichuan large model, etc. For example, the summary text corresponding to the original text can be obtained by asking questions to the large language model. The question sentence can be "The following is a paragraph of original text. Please extract the content summary of the paragraph of original text. It is required to describe the specific things that happened in the original text. Do not guess or make abstract descriptions. The original text is xxx". The xxx in the question sentence can be the content of the original text. It should be understood that the above question sentence is only an example in the embodiment of the present application. The question sentence can be set according to the specific application scenario, or can be adjusted in real time according to the specific content of the original text. The present application does not limit the form of the question sentence.
[0099] The large language model can be used to output the answer to the question. If the answer obtained by the large language model may have problems such as incorrect details or misplaced characters, the answer can be used as the negative summary text corresponding to the original text (denoted as ). By manually correcting the answer obtained by the large language model, a corrected text can be obtained, and the corrected text can be used as the positive summary text corresponding to the original text (denoted as ). Optionally, if the answer obtained by the large language model does not have problems such as detail errors or character misplacement, the answer can still be used as the negative summary text corresponding to the original text (denoted as ), and improve the answer, and the positive summary text corresponding to the original text of the improved answer (recorded as ). For all the collected original texts to be trained, the above method can be used to obtain the text dataset of the first iteration. The training samples in .
[0100] It is understandable that the text training set of the second iteration can be recorded as , the text training set of the third iteration can be recorded as , the text training set of the i-th iteration can be recorded as , all training samples in the text training set of each iteration can be recorded as , i is a positive integer, such as i can be 1, 2, .... Among them, except for the text training set of the first iteration The process of obtaining text training sets other than will be described in detail in the subsequent content.
[0101] Among them, for all training samples in the text training set of each iteration , can be encapsulated as DPO training data. The format of each DPO training data can be expressed as follows:
[0102] {
[0103] "prompt": "The following is a piece of original text. Please extract the content summary of this original text. Please describe the specific things that happened in the original text. Do not make guesses or abstract descriptions. The original text is xxx", "prompt_id": "0001",
[0104] "chosen": [{"content": "The following is a piece of original text. Please extract the content summary of this original text. Please describe the specific events that happened in the original text. Do not make guesses or abstract descriptions. The original text is xxx", "role": "user"}, {"content": A, "role": "assistant"}],
[0105] "rejected": [{"content": "The following is a piece of original text. Please extract the content summary of this original text. Please describe the specific events that happened in the original text. Do not make guesses or abstract descriptions. The original text is xxx ", "role": "user"}, {"content":"B", "role": "assistant"}]
[0106] }
[0107] Among them, "prompt" represents the prompt input into the reference model and the model to be trained, which can be the content of the original text, and "prompt_id" represents the serial number of the current DPO training data. "chosen" represents the better answer to the given prompt, such as the positive summary text. ; "role": "user" means inputting the original text into the input of the reference model or the model to be trained; "content": A means acceptable positive summary text , "role": "assistant" indicates the reference model or model to be trained for summarizing the original text. "content": "B" indicates the negative summary text that is not accepted .
[0108] In an embodiment of the present application, for any iteration in the model training process (for example, the i-th iteration), the reference model and the model to be trained of the i-th iteration can be obtained; wherein, the reference model of the i-th iteration can be the summary generation model of the i-1-th iteration (i.e., the model to be trained at the end of the i-1-th iteration), and the model to be trained of the i-th iteration can also be the summary generation model of the i-1-th iteration. When i is 1, the summary generation model of the i-1-th iteration (summary generation model i-1) can be a pre-trained language model, such as the pre-trained language model can be used as the reference model of the first iteration, and the network parameters of the reference model of the first iteration are used to initialize the model to be trained of the first iteration. When i is not 1, the summary generation model of the i-1-th iteration can refer to the summary generation model obtained at the end of the i-1-th iteration, or can be understood as the summary generation model obtained after the i-1 iteration. Among them, the optimization process of each iteration in the model training process can be considered to be similar. The following will take the i-th iteration as an example to describe the optimization process of one iteration in the model training process.
[0109] For ease of understanding, the summary generation model of the i-1th iteration can be recorded as summary generation model i-1, the model to be trained of the i-1th iteration can be recorded as model to be trained i-1, the model to be trained of the i-th iteration can be recorded as model to be trained i, and so on.
[0110] Optionally, the reference model of the first iteration (which may be denoted as reference model 1) may refer to the SFT fine-tuning model obtained by fine-tuning the public language model using data in the form of "text-summary". The data in the form of "text-summary" may be obtained from a text dataset. The training samples included Obtained from data, or Data; conventional training methods such as batch gradient descent can be used to adjust the network parameters of the disclosed language model to obtain reference model 1. This application does not limit the training method of reference model 1; the reference model of each iteration is used to generate reference prediction information (used to calculate the training loss of the model to be trained) and does not participate in the update of network parameters. After obtaining reference model 1, the network parameters of reference model 1 can be used to initialize the model to be trained to obtain the first iteration of the model to be trained (recorded as model to be trained 1), that is, the reference model 1 is used to initialize the parameters of the model to be trained.
[0111] During the model training process, when i=1, the text dataset of the i-th iteration is the text dataset , the text dataset The number of training samples contained in is ( can be an integer greater than 1). The format of each training sample is as shown in the format of the DPO training data above. Randomly select ( Can be less than or equal to A positive integer) training samples form a batch of data, and the text dataset In The training samples are divided into batches are input into reference model 1 and model 1 to be trained for forward calculation. Batch training means completing one iteration until the training loss of a certain iteration no longer decreases.
[0112] When i is greater than 1, the text dataset of the i-th iteration is the text dataset , the text dataset Can contain two parts: and ;in Represents a text dataset The training samples that have not been updated in The training samples in are text datasets The training samples in Represents a text dataset The training samples updated according to the model i to be trained; The number of training samples and The ratio between the number of training samples in can be expressed as p1:p2. Using the text dataset When training the model i to be trained, The methods for obtaining training samples may include but are not limited to: and The training samples are randomly selected according to a certain sample extraction ratio. training samples, of which and The sample extraction ratio in can be p1:p2; that is, each batch can be extracted according to the ratio of p1:p2 The training samples and The training samples in constitute batch data.
[0113] Optionally, a gradually decreasing Training samples, and gradually increasing The training samples form batches of data. For example, in the first batch, The training samples can all come from In the second batch, The training samples can come from The remaining training samples in k are from The training samples in k are less than is a positive integer, k can be 1, 2, ...; in the third batch, The training samples can come from The remaining training samples in , 2k training samples come from The remaining training samples in ; and so on, we get batches, of which Represents a text dataset The number of batches in Represents a text dataset The number of training samples in the batch data acquisition method described above allows the model to be trained to gradually adapt to the learning under the updated training sample distribution, avoiding a strong change in the loss of the model to be trained when switching text data sets, which is conducive to smooth iteration. This application does not limit the method for obtaining batch data.
[0114] Step S102 , using the reference model of the i-th iteration, performing summary extraction processing on the original text contained in the training samples in the text training set of the i-th iteration to obtain a reference predicted text.
[0115] In the embodiment of the present application, for ease of understanding, the forward calculation process of the reference model and the model to be trained is described by taking the network structure of the reference model and the model to be trained as a multi-layer transformer stacked structure as an example. Among them, the network structure of the reference model can be shown in the following Table 1:
[0116] Table 1
[0117]
[0118] The network structure of the reference model may include an embedding layer, N (N is a positive integer, such as 32, or other values) decoder layers, and a fully connected layer. The embedding layer can convert the input text into an embedded representation; the model network layer may include N decoder layers, where the model network layer may also be referred to as a feature extraction component, and the decoder layer may be a decoder structure in a transformer structure, or an attention subcomponent; the model output layer may specifically be a fully connected layer, which may convert the hidden state features (e.g., reference attention features, or sample attention features) output by the decoder layer into prediction results of Embedding_tokens ids (embedding identification number); for example, if the dictionary includes 64,000 unit characters (single characters or words), then the length of the embedding identification number is 64,000, and the prediction result output by the fully connected layer may be a vector with a dimension of 1×64,000.
[0119] Among them, the network structure of a decoder layer can be shown in the following Table 2:
[0120] Table 2
[0121]
[0122] Among them, a decoder layer may include a self-attention structure (specifically, a self-attention mask layer), an attention normalization layer (specifically, a root mean square normalization layer), a multi-layer perceptron, and an output normalization layer (specifically, a root mean square normalization layer).
[0123] In the i-th iteration, during the learning process of each batch of data, the original text in each training sample (which can be considered as the prompt in the DPO training data) can be input into the reference model of the i-th iteration (which can be referred to as reference model i) for forward calculation to obtain the reference predicted text. Among them, the text training set of the i-th iteration (which can be referred to as text training set) can be embedded in the reference model i through the embedding layer. ) is converted into a reference embedding representation. The embedding layer in the reference model i may refer to a network layer that converts the original text into a low-dimensional vector representation. The embedding layer may be word2vec (a word vector model), or may be a fully connected layer, or may be other structures. The present application does not limit the specific structure of the embedding layer; the reference embedding representation may be a low-dimensional vector representation corresponding to the original text in the training sample.
[0124] Specifically, the original text in the training sample can be segmented to obtain multiple unit characters (the unit character here can be a single word or a single word in the original text); each unit character is converted into a vector to obtain the word vector representation corresponding to each unit character. For example, one-hot (unique hot code) can be used to represent each unit character as a word vector. At this time, the word vector representation is a vector containing only one 1 and the rest are 0. Among them, the dictionary (also known as a character bag) can include a series of common unit characters. According to the position of each common unit character in the dictionary, the one-hot code corresponding to each common unit character can be obtained. The word vector representations (such as one-hot codes) corresponding to each unit character in the original text are concatenated to obtain the text vector representation corresponding to the original text; the text vector representation corresponding to the original text is converted through the embedding layer in the reference model i to obtain the reference embedding representation corresponding to the original text.
[0125] The reference embedding representation is subjected to feature extraction processing by the feature extraction component in the reference model i to obtain the reference attention feature. For example, the feature extraction component may be the model network layer (Model layers) in Table 1 above, and the reference attention feature may be the hidden state feature output by the model network layer. The reference attention feature is subjected to feature transformation processing by the fully connected layer in the reference model i to obtain the reference predicted text corresponding to the original text. For example, the reference attention feature may be converted into the final prediction result by the fully connected layer in the reference model i, and the prediction result here may include the prediction probability of classifying each unit character in the original text as a character in the dictionary; the character corresponding to the maximum prediction probability may be used as the reference predicted text.
[0126] Among them, the feature extraction component in the reference model i may include N attention subcomponents (for example, N decoder layers), N may be a positive integer, and N may take the value of 1, 2, ...; for example, N may take the value of 32, which means that the reference model i contains 32 attention subcomponents. The N attention subcomponents in the reference model i may be chain-connected, such as the output feature of the first attention subcomponent may be used as the input feature of the second attention subcomponent, and the output feature of the second attention subcomponent may be used as the input feature of the third attention subcomponent; in short, the output feature of the previous attention subcomponent may be used as the input feature of the next attention subcomponent. Optionally, the N attention subcomponents in the reference model i may be residually connected, such as the input feature of the next attention subcomponent may include the input feature of the previous attention subcomponent and the output feature of the previous attention subcomponent. The present application does not limit the connection method between the N attention subcomponents in the reference model i.
[0127] The following describes the calculation process of the N attention subcomponents in the reference model i by taking the chain connection as an example. For any attention component among the N attention subcomponents contained in the reference model i (for example, the t-th attention subcomponent, t can be a positive integer less than or equal to N), the input features of the t-th attention subcomponent among the N attention subcomponents in the reference model i can be obtained; when t is 1, the input features of the t-th attention subcomponent in the reference model i can include the above-mentioned reference embedding representation; when t is not 1, the input features of the t-th attention subcomponent in the reference model i can include the output features of the t-1-th attention subcomponent.
[0128] According to the self-attention mask layer in the t-th attention subcomponent in the reference model i (for example, the self-attention structure in Table 2), the input features of the t-th attention subcomponent in the reference model i are subjected to attention mask processing to obtain reference mask features. The reference mask features and the input features of the t-th attention subcomponent are combined into a third residual feature, and the third residual feature is normalized according to the attention normalization layer in the t-th attention subcomponent in the reference model i to obtain reference normalized features. According to the feedforward network layer (also referred to as a multilayer perceptron) in the t-th attention subcomponent in the reference model i, the reference normalized feature is subjected to feature transformation processing to obtain reference transformed features; the reference transformed features and the reference normalized features are combined into a fourth residual feature, and the fourth residual feature is normalized according to the output normalization layer in the t-th attention subcomponent in the reference model i to obtain output features of the t-th attention subcomponent in the reference model i. And so on, until the output feature of the Nth attention subcomponent in the reference model i is obtained, and the output feature of the Nth attention subcomponent in the reference model i is determined as the reference attention feature.
[0129] Among them, the self-attention mask layer can introduce a mask code (mask), which can cover up certain values so that they have no effect when the parameters are updated. In the embodiment of the present application, the self-attention mask layer can involve a sequence mask (sequence mask); the sequence mask is to prevent the attention subcomponent from seeing future information; for example, for a reference embedding representation, in the text summary prediction task at time a (a is a positive integer), the output features of the attention subcomponent can only depend on the output features before time a, but not on the output features after time a, so a sequence mask can be used to hide the information after time a.
[0130] The attention normalization layer and output normalization layer in each attention subcomponent can be a root mean square normalization layer (RMSNorm). Taking the third residual feature as an example, the root mean square normalization process is described. The root mean square value corresponding to the third residual feature can be obtained. The root mean square value can refer to the square root of each element in the third residual feature, and the square of each element is accumulated and averaged. For example, the elements in the third residual feature include , then the RMS value can be expressed as The third residual feature is normalized using the RMS value to obtain a reference normalized feature.
[0131] Optionally, the self-attention mask layer in the attention subcomponent performs attention masking on the input features of the t-th attention subcomponent in the reference model i, and the step of obtaining the reference mask features may include: transforming the input features of the t-th attention subcomponent in the reference model i into a query matrix according to the transformation weight matrix corresponding to the self-attention mask layer in the t-th attention subcomponent contained in the reference model i , key matrix and the value matrix ; Among them, the transformation weight matrix corresponding to the self-attention mask layer in the parameter model i may include three transformation matrices (also referred to as three parameter matrices), such as the first transformation matrix , the second transformation matrix And the third transformation matrix , the transformation weight matrix is the parameter learned during the training process of the model to be trained. When the input feature of the t-th attention subcomponent in the reference model i is recorded as When , the input feature and the first transformation matrix Performing a dot multiplication operation, we can get the query matrix ,like ; Input features and the second transformation matrix Performing a dot multiplication operation, we can get the key matrix ,like ; Input features and the third transformation matrix By performing a dot multiplication operation, we can get the value matrix ,like . Among them, the query matrix Each query vector in can be used to encode the similarity relationship between each feature and other features, and the similarity relationship can determine the dependency information between the current feature and the previous feature.
[0132] The query matrix and key matrix The transposed matrix is multiplied by point operation to obtain the reference weight matrix (which can be recorded as ,in Represents the key matrix The reference weight matrix can be considered as the query matrix and key matrix The inner product (also called dot product) of each row vector in ; To prevent the inner product from being too large, you can get the query matrix The corresponding number of columns (query matrix and key matrix have the same number of columns). For the reference weight matrix The square root of the number of columns (which can be written as ) is normalized to obtain the reference attention weight matrix. The dot product between them determines the reference mask feature.
[0133] Among them, the reference attention weight matrix can be expressed as softmax( ); the reference attention weight matrix can be considered as a "dynamic weight" to characterize the information transfer between the global information of the original text; the softmax function is a function used for normalization processing. The softmax function can be used to calculate the self-attention coefficient of a single feature for other features. Each row in is softmaxed. The reference attention weight matrix is combined with the value matrix The dot product between is determined as the reference mask feature. The reference mask feature at this time can be expressed as .
[0134] Step S103 , using the to-be-trained model of the ith iteration, performs summary extraction processing on the original text contained in the training samples in the text training set of the ith iteration to obtain sample predicted text.
[0135] Among them, the model to be trained of the i-th iteration (which may be referred to as the model to be trained i) and the reference model i may have the same network structure. Specifically, the original text contained in the training samples in the text training set of the i-th iteration may be converted into a sample embedding representation through the embedding layer in the model to be trained i; the sample embedding representation may be subjected to feature extraction processing through the feature extraction component in the model to be trained of the i-th iteration to obtain the sample attention feature; the sample attention feature may be subjected to feature transformation processing through the fully connected layer in the model to be trained of the i-th iteration to obtain the sample predicted text.
[0136] Among them, the feature extraction component in the model to be trained i (such as the model network layer in Table 1) may include N attention sub-components, where N is a positive integer; the above-mentioned step of performing feature extraction processing on the sample embedding representation through the feature extraction component in the model to be trained for the i-th iteration to obtain the sample attention feature may include: obtaining the input feature of the t-th attention sub-component among the N attention sub-components contained in the model to be trained i; when t is 1, the input feature of the t-th attention sub-component in the model to be trained i includes the sample embedding representation; when t is not 1, the input feature of the t-th attention sub-component in the model to be trained i includes the output feature of the t-1-th attention sub-component; t is a positive integer less than or equal to N. Then, according to the self-attention mask layer in the tth attention subcomponent contained in the model i to be trained, the input features of the tth attention subcomponent in the model i to be trained can be subjected to attention mask processing to obtain the attention mask feature; the attention mask feature and the input feature of the tth attention subcomponent in the model i to be trained are combined into a first residual feature, the first residual feature is normalized to obtain a sample normalized feature; according to the feedforward network layer in the tth attention subcomponent, the sample normalized feature is subjected to feature transformation processing to obtain a sample transformation feature; the sample transformation feature and the sample normalization feature are combined into a second residual feature, the second residual feature is normalized to obtain the output feature of the tth attention component in the model i to be trained, and the output feature of the Nth attention component in the model i to be trained is determined as the sample attention feature.
[0137] The acquisition process of the attention mask feature may include: transforming the input feature of the t-th attention subcomponent in the training model i into the query matrix according to the transformation weight matrix corresponding to the self-attention mask layer in the t-th attention subcomponent contained in the training model i , key matrix and the value matrix ; For the query matrix and key matrix The transposed matrix is multiplied by point operation to obtain the candidate weight matrix (which can be recorded as ,in Represents the key matrix ), get the query matrix The corresponding number of columns; for the candidate weight matrix The square root of the number of columns (which can be written as ) is normalized to obtain the attention weight matrix, and the attention mask feature is determined according to the dot product between the attention weight matrix and the value matrix. Among them, the attention weight matrix can be expressed as softmax( ), the attention mask feature can be expressed as .
[0138] Among them, the process of obtaining the sample predicted text in step S103 can refer to the relevant description of the process of obtaining the reference predicted text in step S102. For example, the process of calculating the sample attention feature can refer to the process of calculating the reference attention feature in step S102, and the process of calculating the attention mask feature can refer to the process of calculating the reference mask feature in step S102, etc., which will not be repeated here.
[0139] Step S104, modifying the network parameters of the model to be trained of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, to obtain the summary generation model of the i-th iteration.
[0140] Specifically, we can use the text training set The relationship between the reference prediction text of each training sample in and the positive summary text, negative summary text, and the text training set The relationship between the sample prediction text of each training sample in and the positive summary text and the negative summary text is used to calculate the training loss corresponding to the model to be trained i. The training loss at this time may be a DPO loss. The training loss corresponding to the model to be trained i may be transmitted back to the model to be trained i, and the gradients of the network parameters of the model to be trained i are calculated. According to the gradients of the network parameters of the model to be trained i, the network parameters of the model to be trained i are updated.
[0141] Among them, the reinforcement learning process of the model to be trained in the i-th iteration may include Batch learning. When learning a batch, the reference prediction text and sample prediction text corresponding to each training sample in a batch can be calculated; according to the reference prediction text and sample prediction text of each training sample in a batch, as well as the positive summary text and negative summary text of the corresponding training sample, the training loss of a batch is calculated, and the training loss of a batch is fed back to the model to be trained i to update the network parameters. After completing the current batch learning, you can continue to learn the next batch until the batch learning is completed in sequence. Batch learning, that is, complete the text training set All training samples in .
[0142] Among them, when the text training set is completed All training samples in , that is, when the i-th iteration (1 epoch) is completed, the text training set can be obtained The training loss for each batch in the text training set In The average training loss of batches can be obtained by calculating the training loss of the model i in the text training set. The training loss in (such as Loss_train_i). The specific calculation process of the training loss corresponding to the training model i will be described in detail in the subsequent content.
[0143] Optionally, use a text training set For all training samples in , the model obtained after completing one iteration of training model i can be called the pre-training model of the i-th iteration. Then, we can obtain the text test set (which can be recorded as ), each test sample in the text test set may include a test text and a labeled summary corresponding to the test text. The test samples in the text test set are subjected to summary extraction processing by the pre-trained model of the i-th iteration to obtain a test prediction text. The text test set of each iteration may use the same test data, that is, the same text test set may be used; the acquisition process of the test prediction text may refer to the relevant description of the acquisition process of the reference prediction text in step S102, which will not be repeated here. The test loss corresponding to the pre-trained model of the i-th iteration (which may be recorded as Loss_test_i) may be calculated according to the labeled summary of the test prediction text and the test sample; the network parameters of the pre-trained model of the i-th iteration are fine-tuned by the test loss corresponding to the pre-trained model of the i-th iteration to obtain the summary generation model of the i-th iteration (summary generation model i). The summary generation model i and its corresponding training loss Loss_train_i and test loss Loss_test_i may be saved. The summary generation model i may be used as a reference model for the i+1-th iteration and a model to be trained for the i+1-th iteration.
[0144] Step S105, correcting the sample prediction text to obtain the sample correction text, encapsulating the original text, the sample prediction text and the sample correction text into a newly added sample, and adding the newly added sample to the text training set of the i+1th iteration.
[0145] Specifically, the sample prediction text can be considered as the summary text predicted by the original text input by the training model i. At this time, the sample prediction text may have problems such as information dislocation and character relationship dislocation. Therefore, the sample prediction text output by the training model i can be corrected by asking questions to the standard language model (CoT method can be used) to obtain the sample correction text. At this time, the text training set The original text, sample prediction text, and sample correction text in the training samples are encapsulated as new samples (new training samples), which can be added to the text training set of the i+1th iteration (which can be recorded as ). Among them, the sample prediction text can be used as the negative summary text in the newly added sample, and the sample correction text can be used as the positive summary text in the newly added sample; the format of the newly added sample can be shown in the format of the DPO training data, and the newly added sample can be specifically added to the text training set In .
[0146] Among them, the standard language model can be any large language model currently open source, or a language model developed independently; for example, the standard language model can be any one of the models such as GPT4, Qwen1.5-32B-Chat, llama3-70B, Skywork-13B, etc. This application does not limit the type of the standard language model.
[0147] Optionally, the sample prediction text output by the training model i may not have problems such as information dislocation and character relationship dislocation, so there is no need to correct the sample prediction text. In other words, the text training set The current training sample in (the training sample corresponding to the sample prediction text) does not need to be updated, and the training sample is added to the text training set In Among them, the and Can form a text training set , The number of training samples and The ratio between the number of training samples in is p1:p2.
[0148] It should be noted that the above step S104 and step S105 can be calculated in parallel during the model training process, which can improve the training speed of the model to be trained.
[0149] In the embodiment of the present application, the iteration number i is incremented by 1 each time, and the aforementioned steps S101 to S105 are continuously looped until the training loss of the previous iteration is less than or equal to the training loss of the next iteration, and the model training process is terminated. Finally, among all the saved summary generation models, the summary generation model with the smallest test loss or training loss can be selected as the target generation model. For example, the text training set of the i+1th iteration (text training set ), train the model to be trained of the i+1th iteration to obtain the summary generation model of the i+1th iteration (which can be recorded as summary generation model i+1); if the training loss corresponding to the model to be trained of the i+1th iteration is the same as the training loss corresponding to the model to be trained of the i-th iteration, the summary generation model of the i+1th iteration can be determined as the target generation model. The training process of the summary generation model i+1 can refer to the above steps S101 to S105, which will not be repeated here.
[0150] Since the upper limit of the model to be trained is determined by the text training set, each time the model to be trained is updated during the model training process, the text training set can be optimized once to improve the quality of the training data and thus increase the upper limit of the training data. This allows the model to be trained to achieve better summary generation effects by learning from better training data.
[0151] It is understandable that the embodiments of the present application can optimize the text training set once in each iteration, or can optimize the text training set once after several iterations, and the present application does not limit this. For example, the optimization frequency of the text training set can be preset, and the optimization frequency can be any value set according to the specific task, and the present application does not limit this; when the optimization frequency is set to 2, it means that the text training set is optimized once every 2 iterations, such as using the text data set Train the models to be trained in the first and second iterations, and obtain the first optimized text dataset by correcting the sample prediction text of the second iteration. ; Then we can use the text dataset Train the models to be trained in the third and fourth iterations, and obtain the second optimized text dataset by correcting the sample prediction text of the fourth iteration. , and so on, until the target generation model is obtained at the end of training.
[0152] See also Figure 4 , Figure 4 It is a flowchart of a model training process provided in an embodiment of the present application. Figure 4 The corresponding embodiment describes the closed-loop self-iterative training process of model reinforcement learning and automatic updating of reinforcement learning data. Among them, model reinforcement learning can refer to reinforcement learning of the training model based on reference learning; automatic updating of reinforcement learning data can refer to the text training set automatically updated every time during the model training process.
[0153] You can collect an initial text dataset (i.e. the text training set mentioned above) ), in the first iteration, the reference model 1 can be used to initialize the network parameters of the model to be trained 1, and then the reference model 1 and the model to be trained 1 are used to perform DPO training in the initial text data set, and the network parameters of the model to be trained 1 are updated to obtain the summary generation model 1. Similarly, in the i-th iteration, the reference model i and the model to be trained i can be used to perform DPO training in the text training set of the i-th iteration, and the network parameters of the model to be trained i are updated to obtain the summary generation model i. Among them, the reference model 1 and the model to be trained 1 represent the reference model and the model to be trained when the model to be trained learns to the first iteration respectively; the reference model i and the model to be trained i represent the reference model and the model to be trained when the model to be trained learns to the i-th iteration respectively.
[0154] For example, the training loss of the model i to be trained (for example, the DPO loss) can be calculated based on the prediction results (reference predicted text) generated by the reference model i for the original text in the current text training set and the prediction results (sample predicted text) generated by the model i to be trained for the original text, and the network parameters of the model i to be trained can be updated based on the training loss of the model i to be trained to obtain the summary generation model i.
[0155] While the model is being trained, the model to be trained can be backed up to obtain a backup model. Since the backup operation of the model to be trained lags behind the training operation, the current model to be trained learns to the i-th iteration (such as Figure 4 When the model to be trained i) is stored, the backup model is the summary generation model i-1; the summary generation model i-1 can be the model to be trained after i-1 iterations of learning, or it can be the model to be trained at the end of the i-1th iteration of learning. The backup model can be used to perform summary extraction processing on the original text in the training samples contained in the text training set to generate a first summary text (which can be considered a poor summary); by updating the CoT data, the first summary text is corrected based on the standard language model to obtain a second summary text; compared with the first summary text, the second summary text can be considered to be a better summary text. The original text, the first summary text, and the second summary text are used as new samples to implement the optimization process of the text training set.
[0156] It should be noted that the positive summary text (better summary text) in the newly added sample can be obtained by correcting the first summary text generated by the backup model based on the standard language model using the CoT method; or, the positive summary text (better summary text) in the newly added sample can be obtained by correcting the sample prediction text generated by the training model i based on the standard language model using the CoT method; or, the positive summary text (better summary text) in the newly added sample can be obtained by correcting the reference prediction text generated by the reference model i based on the standard language model using the CoT method, and this application does not limit this. It should be understood that since the reference model does not participate in the update of network parameters in iterative learning, the reference prediction text generated by the reference model i and the first summary text generated by the backup model are the same in principle.
[0157] In an embodiment of the present application, in each iterative learning of model training, a reference model and a model to be trained are used to perform DPO training in a text training set, and the network parameters of the model to be trained are corrected to obtain a summary generation model learned in each iteration. While the model is being trained, the sample prediction text generated by the model to be trained can be corrected to obtain a more correct summary text (sample correction text), and the original text, sample prediction text, and sample correction text are encapsulated as a newly added sample, which can be used as a training sample for the model to be trained in the i+1th iteration. By obtaining more correct summary data in real time during the training phase and updating the text training set for each iteration, the diversity of the training data can be enriched, thereby improving the summary generation quality of the summary generation model.
[0158] See also Figure 5 , Figure 5 This is a flowchart of a text processing method provided in an embodiment of the present application. Figure 2 It can be understood that this can be executed by a computer device, which can be a server or a terminal device, and this application does not limit this. Figure 5 As shown, the method may include the following steps S201 to S212:
[0159] Step S201, obtaining a reference model and a model to be trained for the i-th iteration, and obtaining a text training set for the i-th iteration.
[0160] Step S202 , using the reference model of the i-th iteration, perform summary extraction processing on the original text contained in the training samples in the text training set of the i-th iteration to obtain a reference predicted text.
[0161] Step S203 , using the to-be-trained model of the ith iteration, performs summary extraction processing on the original text contained in the training samples in the text training set of the ith iteration to obtain sample predicted text.
[0162] The specific implementation process of step S201 to step S203 can be found in Figure 3 The description of step S101 to step S103 in the corresponding embodiment will not be repeated here.
[0163] Step S204: obtaining a first prediction probability that the reference prediction text is a positive summary text, and obtaining a second prediction probability that the reference prediction text is a negative summary text.
[0164] Step S205 , obtaining a third prediction probability that the sample prediction text is a positive summary text, and obtaining a third prediction probability that the sample prediction text is a negative summary text.
[0165] Step S206, determining the training loss corresponding to the model to be trained for the i-th iteration according to the first logarithmic probability between the first prediction probability and the third prediction probability, and the second logarithmic probability between the second prediction probability and the fourth prediction probability.
[0166] In the embodiment of the present application, the training loss corresponding to the model to be trained in each iteration can be a DPO loss. For example, the training loss corresponding to the model to be trained in the i-th iteration can be as shown in the following formula (1):
[0167] (1)
[0168] in, Represents the input to the reference model i (denoted as ) and the model to be trained i (denoted as ) in the training samples All belong to the text training set . Indicates that the reference model i (denoted as ) and the model to be trained i (denoted as ) in the text training set The training loss in is the training loss corresponding to the model to be trained in the i-th iteration. Indicates that when the original text x is input, a better summary text appears in the sample prediction text generated by the training model i The probability of (positive summary text), that is, the third predicted probability mentioned above; Indicates that when the original text x is input, the sample prediction text generated by the training model i contains a summary text that is not good enough (negative summary text), which is the fourth predicted probability mentioned above. Indicates that when the original text x is input, a better summary text appears in the reference prediction text generated by the reference model i The probability of (positive summary text), that is, the first predicted probability mentioned above; Indicates that when the original text x is input, the reference prediction text generated by the reference model i contains a summary text that is not good enough (negative summary text), which is the second predicted probability mentioned above. Represents a logarithmic function whose base is a natural constant; is a hyperparameter that can be set according to actual applications, such as The value may be 0.1, or 0.2, or 1, etc., which is not limited in this application; represents the activation function; represents the maximum likelihood objective.
[0169] in, represents the first logarithmic probability between the first predicted probability and the third predicted probability, represents the second logarithmic probability between the second predicted probability and the fourth predicted probability. The model i to be trained is a model that has been learned through multiple iterations. The reference model i generates preference data (positive summary text) when the original text is fixed. ) and non-preferred data (negative summary text ) Fixed probability prediction , , through the training loss shown in formula (1), the preference data (positive summary text) can be increased ) and reduces the likelihood of non-preferred data (negative summary text ) possibility; therefore, the loss optimization shown in formula (1) can be used to make the model to be trained move towards "having a greater probability than the reference model to appear positive summary text" Direction learning.
[0170] It should be understood that the training loss corresponding to the model to be trained in each iteration can be referred to in the above formula (1), which will not be repeated here. It should be noted that the text training set in the above formula (1) may change during different iterative learning, such as the first prediction probability, the second prediction probability, the third prediction probability and the fourth prediction probability in each iteration.
[0171] Step S207, according to the training loss corresponding to the model to be trained in the i-th iteration, the network parameters of the model to be trained in the i-th iteration are corrected to obtain the pre-trained model of the i-th iteration.
[0172] Specifically, the network parameters of the model to be trained at the i-th iteration can be updated by minimizing the training loss corresponding to the model to be trained at the i-th iteration. For example, the above formula (1) can be used to calculate the parameters The gradient of (network parameters of the model to be trained) is the gradient of the training loss corresponding to the model to be trained i. By using the gradient of the training loss corresponding to the model to be trained i, the network parameters of the model to be trained i are updated to obtain the pre-trained model of the i-th iteration, which can increase the generation of better summary text. (positive summary text), reducing the probability of generating poor summary text The probability of (negative summary text).
[0173] Step S208, fine-tuning the network parameters of the pre-trained model of the i-th iteration to obtain the summary generation model of the i-th iteration.
[0174] In the embodiment of the present application, the text training set When all training samples in are trained, the pre-trained model of the i-th iteration can be obtained. Then, the network model of the pre-trained model of each iteration can be fine-tuned using the text test set to obtain the summary generation model i. Specifically, the text test set (which can be recorded as ); Each test sample in the text test set may include a test text and an annotated summary; through the pre-trained model of the i-th iteration, the test text contained in the test sample in the text test set is subjected to summary extraction processing to obtain a test prediction text; wherein, the process of obtaining the test prediction text can be referred to Figure 3 The relevant description of the reference prediction text acquisition process in the corresponding embodiment is not repeated here. Then, the test loss corresponding to the pre-trained model of the i-th iteration can be determined according to the test prediction text and the annotated summary; according to the test loss corresponding to the pre-trained model of the i-th iteration, the network parameters of the pre-trained model of the i-th iteration are fine-tuned to obtain the summary generation model of the i-th iteration.
[0175] When the text test set is used to fine-tune the pre-trained model of the i-th iteration, the training method used is non-reinforcement learning training, and the cross entropy loss between the test prediction text and the annotation summary of the pre-trained model of the i-th iteration is calculated. The cross entropy loss can be used as the test loss of the pre-trained model of the i-th iteration. The test loss corresponding to the pre-trained model of the i-th iteration can be shown as the following formula (2):
[0176] (2)
[0177] in, Represents the test loss corresponding to the pre-trained model of one iteration; It can represent the one-hot label of the jth word (unit character) in the annotation summary, where j is a positive integer less than or equal to H, and H represents the number of words (unit characters) in the annotation summary; the dimension of the one-hot label can be the number of words in the dictionary (such as the length of the embedding identifier number mentioned above), The label is 1 if it is a word in the dictionary, otherwise it is 0. It can represent the predicted probability of the jth word in the annotation summary. The dimension of is the same as the dimension of the one-hot label. Fine-tuning the pre-trained model of the i-th iteration by the test loss shown in the above formula (2) can improve the prediction probability that the model-predicted word is the target word; where the model-predicted word is the word in the above test prediction text, and the target word is the word in the annotation summary.
[0178] It can be understood that the pre-trained model of the i-th iteration can output the prediction probability of all words in the dictionary at the word position in the annotated summary, and the word corresponding to the maximum prediction probability can be determined as the predicted word output by the pre-trained model of the i-th iteration to obtain the above-mentioned test prediction text; and the target word at the corresponding position on the annotated summary can be converted into a one-hot dictionary vector representation (one-hot label), and then the cross entropy loss of each word in the annotated summary is calculated to measure the test loss of the pre-trained model of the i-th iteration.
[0179] Step S209, evaluating the correctness of the sample prediction text through a standard language model to obtain an evaluation result and evaluation reason corresponding to the sample prediction text.
[0180] Step S210: If the evaluation result indicates that the sample prediction text is an erroneous summary, the sample prediction text is corrected according to the evaluation reason to obtain a sample corrected text.
[0181] Step S211: encapsulate the original text, the sample predicted text and the sample corrected text into a newly added sample, and add the newly added sample to the text training set of the i+1th iteration.
[0182] In the embodiment of the present application, the sample prediction text generated by the model to be trained in the i-th iteration may have problems such as information description errors. The sample prediction text can be corrected based on the standard language model to obtain the sample correction text, and then the original text, the sample prediction text and the sample correction text can be used as new samples. The negative summary text in the new sample is the sample prediction text, and the positive summary text is the sample correction text. The new sample can be used as a training sample for training the model to be trained i+1. It can be understood that the sample prediction text can be considered as the summary text predicted by the model to be trained i as the input original text, that is, the sample prediction text is a piece of text data; the CoT method can be used to split the sample prediction text into multiple sentences, and the standard language model can be used to gradually optimize the multiple sentences obtained by splitting, which can improve the correction efficiency of the sample prediction text.
[0183] See also Figure 6 , Figure 6 is a schematic diagram of a correction of a sample prediction text provided in an embodiment of the present application. Figure 6 As shown in , the original text in the training sample is input into the training model i (the training model learned to the i-th iteration), and the sample prediction text can be obtained by forward calculation of the original text through the training model i. , then we can predict the text based on the period Segmentation is performed to obtain R sentences, where R is used to represent the sample prediction text The number of sentences in R can be a positive integer. You can initialize the update sentence count=0 and predict the text from the sample Start traversing all statements from the first statement in the R statements. For any statement s among the R statements (s can be a positive integer less than or equal to R, such as s = 1, 2, ..., R):
[0184] ① Standard language models (e.g., GPT4) can be used to evaluate sample prediction text The correctness of sentence s in the sentence, that is, to judge whether sentence s is correct, the question statement can be as follows: "The following is a piece of original text and a corresponding content summary description. Please judge whether the content summary description is correct and give the reason. The return is in json (JavaScript ObjectNotation) format, such as {'Is it correct': 'No', 'Score': 60, 'Reason': 'The characters are wrong. It was Zhang San and Li Si chatting, and Wang Wu walked in, instead of Zhang San and Wang Wu chatting'}. Original text: b1, content summary description: b2". Among them, json format is a lightweight data exchange format based on the object representation of JavaScript (a high-level programming language for web page development). It is easy to read and write, and also easy for machines to parse and generate; data in json format can be represented in the form of key-value pairs.
[0185] ② After obtaining the standard language model's answers to the above text b1 and content summary description b2, it can be processed according to the "Is it correct?" result (i.e., the evaluation result). If the "Is it correct?" result is "yes," that is, the "Is it correct?" result points to the correct summary, then the next sentence (s+1) is judged. If the "Is it correct?" result is "no," then the next correction operation is performed.
[0186] ③If the result of "Is it correct?" indicates an incorrect summary, continue to use the standard language model for correction. The question format for correction can be as follows: "The following is a paragraph of original text and a corresponding sentence of content summary description. Please combine the original text and the xxx question in it to give a revised summary description that is consistent with the content of the original text. Then give the similarity score between the revised summary description and the original text, and return it in JSON format, such as {'corrected summary': b3, 'score': 85}. Original text: b1, content summary description: b2". Among them, xxx is the reason part of the previous answer (i.e., the evaluation reason).
[0187] ④Perform step ③ twice, combined with the original step ①, to obtain three summaries (one original summary, i.e., sample prediction text , two new summaries, i.e. the summaries obtained by performing step ③ twice) and three scores, and the one with the highest score is obtained to replace the original sentence s. When the replacement statement is the original sentence s, it can be considered that there is no update, and the number of updated statements count at this time remains 0; when the replacement statement is not the original sentence s, the number of updated statements count is increased by 1, i.e. count+=1.
[0188] ⑤ Continue to judge the next sentence (s+1), and repeat the above steps ① to ④ until the sample prediction text is All statements in the are completed.
[0189] The above steps ① to ⑤ can be called the CoT step-by-step optimization process. After all the sentences in the sample are judged, the sample correction text can be obtained. When count>0, it means the sample prediction text The sample correction text and sample prediction text are updated. Different, indicating that a better summary text is generated. At this time, the original text and the sample prediction text (as the negative summary text) can be )、Sample revised text (as the main summary text ) as a valid new sample.
[0190] For the original content of all training samples in the text training set, all valid new samples are obtained. For invalid sample correction text (no updated sample prediction text, that is, count=0), the text dataset of the previous stage can be used (for example, the model to be trained in the first iteration uses the text dataset ) as the training samples in the new text training set (i.e., the historical training samples are used). For example, if the evaluation result indicates that the sample prediction text is a correct summary, the correction of the sample prediction text is suspended, and the training samples corresponding to the sample prediction text in the text training set of the i-th iteration are added to the text training set of the i+1-th iteration. Based on the above valid new samples and the historical training samples that have not been updated, the text training set of the i+1-th iteration can be obtained. It is understandable that the question format described in the above steps ① to ⑤ is only an example of the gradual optimization process of CoT. In practical applications, the question format can be adjusted in real time according to the actual situation. This application does not limit the question format.
[0191] Step S212: If the training loss corresponding to the model to be trained in the (i+1)th iteration is the same as the training loss corresponding to the model to be trained in the (i)th iteration, the summary generation model in the (i+1)th iteration is determined as the target generation model.
[0192] Specifically, after obtaining the text training set of the i+1th iteration Afterwards, the model to be trained i+1 and the reference model i+1 can be used in the text training set DPO learning is performed in , and when the training loss corresponding to the model to be trained at the i+1th iteration is the same as the training loss corresponding to the model to be trained at the i-th iteration, the summary generation model at the i+1th iteration is determined as the target generation model. Optionally, when the training loss corresponding to the model to be trained no longer decreases, the summary generation model with the smallest training loss or test loss can be used as the target generation model obtained by the final training.
[0193] It should be understood that the embodiment of the present application relates to a reinforcement learning method for a summary generation model based on a semi-real-time updated preference comparison text. In the training stage of the summary generation model, the effect of the training data (or training samples) in the current model to be trained is synchronously evaluated, and new training data (which can be called newly added samples) is generated with the help of CoT, which can enrich the diversity of the training data; the current model to be trained is dynamically updated with the new training data, thereby improving the summary generation effect of the summary generation model. Since the newly added samples are generated by reasoning while training the current model to be trained, the generation of the newly added samples usually lags behind the learning steps of the current model to be trained, so it is called reinforcement learning with semi-real-time update of training data. The embodiment of the present application uses CoT to evaluate and correct the summary text generated by the current model to be trained, and generates training data that is more meaningful for the current model to be trained, which can effectively improve the optimization learning of the model to be trained, thereby improving the summary generation quality of the target generation model obtained by the final training.
[0194] It should be noted that the target generation model obtained through the above training can be applied to text content understanding scenarios such as plot understanding scenarios of film and television scripts, book plot understanding scenarios, and article content understanding scenarios. For example, the target generation model can generate a concise plot summary for the text content of each scene of the film and television script, which is helpful for helping users to quickly understand the main content of the film and television script. For the input film and television script, the film and television script can be divided into multiple scene texts, and then the target generation model is used to generate a plot summary text for each scene text, and the plot summary text of each scene text is returned, which can assist the review of relevant personnel.
[0195] In one or more embodiments, when the target generation scenario is applied to the above-mentioned text content understanding scenario, the predicted text output by the target generation model can be directly used as the summary text of the original input text; or, the predicted text output by the target generation model can be gradually optimized by CoT to obtain a corrected predicted text, and then the corrected predicted text can be used as the summary text of the original input text, which can improve the description accuracy of the summary text. This application does not limit this.
[0196] Optionally, the target generation model can be used to help film and television researchers, script critics, script reviewers and other personnel quickly understand and analyze the plot structure of film and television dramas (movies, TV series, etc.) so as to conduct in-depth research and comments on the plot of film and television scripts. Optionally, the target generation model can be used to help writers or screenwriters and other creative personnel quickly sort out and plan story lines during the creative process to improve the efficiency of work creation. Optionally, in the planning stage of film and television dramas, the target generation model can be used to help planners quickly understand the main content of a large number of film and television scripts, so as to conduct effective plot screening and decision-making, that is, to improve the efficiency of plot screening and the success rate of decision-making.
[0197] In a feasible implementation manner, the target generation model obtained by the above training can be applied to the plot understanding scenario of a film and television script. The episode plot set corresponding to the film and television script can be obtained, and each episode plot in the episode plot set can be split into scenes to obtain the scene plots corresponding to each episode plot; according to the position of the scene plots corresponding to each episode plot in the film and television script, the scene plots corresponding to each episode plot are input into the target generation model in sequence to obtain the plot summary corresponding to each episode plot; the plot summary is used to assist the creative object in the subsequent creation of the film and television script.
[0198] See also Figure 7 , Figure 7 This is a schematic diagram of a scenario in which a target generation model provided in an embodiment of the present application is used in understanding the plot of a film or TV script. Figure 7 As shown, the target generation model can be used to understand the episode plots of the film and television script to assist the creator in story creation. When r (r is a positive integer) episodes of the film and television script have been obtained, it means that the user has completed the creation of the r episode script of the film and television script. For the script of the input episode plot r (i.e., the rth episode script), the rth episode script can be split into scenes through the background service to obtain multiple scene texts (scene plots); then the target generation model can be called to generate a scene summary for each scene text, and the scene summaries corresponding to the multiple scene texts of the rth episode script are spliced to obtain the plot summary of the rth episode script (this episode summary). The plot summary of the rth episode script can be transmitted to the front end for display, such as the plot of the first episode, the plot of the second episode, ..., the plot of the rth episode can be displayed on the front end.
[0199] By reading the plots of the first r episodes displayed on the front end, the creator can quickly sort out and plan the story line, continue to create the script for the r+1 episode, and continue to input the script of the r+1 episode plot that has been created or obtained. The r+1 episode script can be split into scenes through the backend service, and multiple scene texts (scene plots) can also be obtained; then the target generation model can be called to generate a scene summary for each scene text in the r+1 episode script, and the scene summaries corresponding to the multiple scene texts in the r+1 episode script can be spliced to obtain the plot summary of the r+1 episode script (this episode summary). The plot summary of the r+1 episode script can be transmitted to the front end for display, such as the plot of the first episode, the plot of the second episode, ..., the plot of the r+1 episode can be displayed on the front end. Calling the target generation model can help creators quickly sort out and plan the story line during the creation process and improve creation efficiency.
[0200] In the embodiments of the present application, training samples related to the text summary prediction task are used for model training. By matching the text summary prediction task with the training samples, the summary generation effect of the target generation model can be improved. By automatically optimizing the text data set and using the optimized text data set to perform reinforcement learning on the model to be trained, the upper limit of model learning can be improved. By optimizing the text training set in iterative training and continuing to train the model with the optimized text data set, a closed loop of model data learning, training data updating and model self-evolution is formed, thereby improving the efficiency of the self-evolution of the summary generation model. The training data used in the model training process are all fully automatically annotated data, without the need for manual intervention, which can improve the efficiency of collecting training data and the training efficiency of the summary generation model.
[0201] It is understandable that in the specific implementation of the present application, the training samples in the text training set may involve personal information such as character information introduction. When the above embodiments of the present application are applied to specific products or technologies, it is necessary to obtain the permission or consent of the relevant institutions or departments, or the users themselves, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant regions.
[0202] See also Figure 8 , Figure 8 This is a schematic diagram of the structure of a text processing device provided in an embodiment of the present application. Figure 1 .like Figure 8 As shown, the text processing device 1 includes: a model acquisition module 101, a first prediction module 102, a second prediction module 103, a parameter correction module 104, and a training data update module 105;
[0203] The model acquisition module 101 is used to acquire the reference model and the model to be trained of the i-th iteration, and acquire the text training set of the i-th iteration; each training sample in the text training set of the i-th iteration includes the original text, the negative summary text and the positive summary text, and i is a positive integer;
[0204] The first prediction module 102 is used to perform summary extraction processing on the original text contained in the training samples in the text training set of the i-th iteration through the reference model of the i-th iteration to obtain a reference prediction text;
[0205] The second prediction module 103 is used to perform summary extraction processing on the original text contained in the training sample in the text training set of the i-th iteration through the to-be-trained model of the i-th iteration to obtain the sample prediction text;
[0206] The parameter correction module 104 is used to correct the network parameters of the model to be trained of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, so as to obtain the summary generation model of the i-th iteration; the summary generation model of the i-th iteration is used as the reference model and the model to be trained of the i+1-th iteration;
[0207] The training data updating module 105 is used to correct the sample prediction text to obtain the sample correction text, encapsulate the original text, the sample prediction text and the sample correction text into new samples, and add the new samples to the text training set of the i+1th iteration; the text training set of the i+1th iteration is used to train the model to be trained of the i+1th iteration.
[0208] According to an embodiment of the present application, the above Figure 3 The steps involved in the text processing method shown can be represented by Figure 8 The text processing device 1 shown in the figure is executed by each module. For example, Figure 3 Step S101 shown can be performed by Figure 8 The model acquisition module 101 shown is used to execute, Figure 3 Step S102 shown can be performed by Figure 8 The first prediction module 102 shown is used to execute, Figure 3 Step S103 shown can be performed by Figure 8 The second prediction module 103 shown is used to execute, Figure 3 Step S104 shown can be performed by Figure 8 The parameter correction module 104 shown is used to perform, Figure 3 Step S105 shown can be performed by Figure 8 The training data update module 105 shown is used to perform the following steps.
[0209] According to one embodiment of the present application, Figure 8 The various modules in the text processing device 1 shown can be individually or all combined into one or several modules, or one (some) of the modules can be further divided into at least two functionally smaller units to achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In actual applications, the function of one module can also be implemented by at least two units, or the functions of at least two modules can be implemented by one module. In other embodiments of the present application, the text processing device 1 may also include other modules or units. In actual applications, these functions can also be implemented with the assistance of other modules, and can be implemented by the collaboration of at least two modules.
[0210] In an embodiment of the present application, in each iterative learning of model training, a reference model and a model to be trained are used to perform DPO training in a text training set, and the network parameters of the model to be trained are corrected to obtain a summary generation model learned in each iteration. While the model is being trained, the sample prediction text generated by the model to be trained can be corrected to obtain a more correct summary text (sample correction text), and the original text, sample prediction text, and sample correction text are encapsulated as a newly added sample, which can be used as a training sample for the model to be trained in the i+1th iteration. By obtaining more correct summary data in real time during the training phase and updating the text training set for each iteration, the diversity of the training data can be enriched, thereby improving the summary generation quality of the summary generation model.
[0211] See also Fig. 9 , Fig. 9 This is a structural diagram of a text processing device provided in an embodiment of the present application. Figure 2 .like Fig. 9 As shown, the text processing device 2 includes: a model acquisition module 201, a first prediction module 202, a second prediction module 203, a parameter correction module 204, and a training data update module 205;
[0212] The model acquisition module 201 is used to acquire the reference model and the model to be trained of the i-th iteration, and acquire the text training set of the i-th iteration; each training sample in the text training set of the i-th iteration includes the original text, the negative summary text and the positive summary text, and i is a positive integer;
[0213] The first prediction module 202 is used to perform summary extraction processing on the original text contained in the training samples in the text training set of the i-th iteration through the reference model of the i-th iteration to obtain a reference prediction text;
[0214] The second prediction module 203 is used to extract the original text contained in the training sample in the text training set of the i-th iteration by using the training model of the i-th iteration to obtain the sample prediction text;
[0215] The parameter correction module 204 is used to correct the network parameters of the model to be trained of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, so as to obtain the summary generation model of the i-th iteration; the summary generation model of the i-th iteration is used as the reference model and the model to be trained of the i+1-th iteration;
[0216] The training data updating module 205 is used to correct the sample prediction text to obtain the sample correction text, encapsulate the original text, the sample prediction text and the sample correction text as new samples, and add the new samples to the text training set of the i+1th iteration; the text training set of the i+1th iteration is used to train the model to be trained of the i+1th iteration.
[0217] In one or more embodiments, the model acquisition module 201 acquires the reference model and the model to be trained of the i-th iteration to perform the following steps:
[0218] Get the summary generation model of the i-1th iteration; when i is 1, the summary generation model of the i-1th iteration is the pre-trained language model;
[0219] The summary generation model of the i-1th iteration is determined as the reference model of the i-th iteration, and the summary generation model of the i-1th iteration is determined as the model to be trained of the i-th iteration.
[0220] In one or more embodiments, the second prediction module 203 performs summary extraction processing on the original text contained in the training sample in the text training set of the i-th iteration through the training model to be trained of the i-th iteration to obtain the sample prediction text for performing the following steps:
[0221] Convert the original text contained in the training samples in the text training set of the i-th iteration into sample embedding representation;
[0222] Through the feature extraction component in the model to be trained in the i-th iteration, feature extraction is performed on the sample embedding representation to obtain the sample attention feature;
[0223] Through the fully connected layer in the model to be trained in the i-th iteration, the sample attention features are transformed to obtain the sample prediction text.
[0224] In one or more embodiments, the feature extraction component in the model to be trained in the i-th iteration includes N attention subcomponents, where N is a positive integer;
[0225] The second prediction module 203 performs feature extraction processing on the sample embedding representation through the feature extraction component in the training model of the i-th iteration to obtain the sample attention feature for executing the following steps:
[0226] Get the input features of the t-th attention subcomponent among N attention subcomponents; when t is 1, the input features of the t-th attention subcomponent include the sample embedding representation; when t is not 1, the input features of the t-th attention subcomponent include the output features of the t-1-th attention subcomponent; t is a positive integer less than or equal to N;
[0227] According to the self-attention mask layer in the t-th attention sub-component, the input features of the t-th attention sub-component are subjected to attention mask processing to obtain the attention mask features;
[0228] The attention mask feature and the input feature of the t-th attention subcomponent are combined into the first residual feature, and the first residual feature is normalized to obtain the sample normalized feature;
[0229] According to the feedforward network layer in the t-th attention subcomponent, the sample normalized features are subjected to feature transformation processing to obtain sample transformation features;
[0230] The sample transformation feature and the sample normalization feature are combined into a second residual feature, the second residual feature is normalized to obtain the output feature of the tth attention component, and the output feature of the Nth attention component is determined as the sample attention feature.
[0231] In one or more embodiments, the second prediction module 203 performs attention masking on the input features of the t-th attention subcomponent according to the self-attention mask layer in the t-th attention subcomponent to obtain an attention mask feature for performing the following steps:
[0232] According to the transformation weight matrix corresponding to the self-attention mask layer in the t-th attention subcomponent, the input features of the t-th attention subcomponent are transformed into a query matrix, a key matrix, and a value matrix;
[0233] Perform a dot multiplication operation on the transposed matrices of the query matrix and the key matrix to obtain the candidate weight matrix and obtain the number of columns corresponding to the query matrix;
[0234] The ratio between the candidate weight matrix and the square root of the number of columns is normalized to obtain the attention weight matrix, and the attention mask feature is determined according to the dot product between the attention weight matrix and the value matrix.
[0235] In one or more embodiments, the parameter correction module 204 corrects the network parameters of the training model of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text, and the negative summary text to obtain the summary generation model of the i-th iteration, which is used to perform the following steps:
[0236] Obtain a first prediction probability that the reference prediction text is a positive summary text, and obtain a second prediction probability that the reference prediction text is a negative summary text;
[0237] Obtaining a third prediction probability that the sample prediction text is a positive summary text, and obtaining a fourth prediction probability that the sample prediction text is a negative summary text;
[0238] Determine the training loss corresponding to the model to be trained for the i-th iteration according to a first logarithmic probability between the first prediction probability and the third prediction probability, and a second logarithmic probability between the second prediction probability and the fourth prediction probability;
[0239] According to the training loss corresponding to the model to be trained in the i-th iteration, the network parameters of the model to be trained in the i-th iteration are modified to obtain the pre-trained model of the i-th iteration;
[0240] The network parameters of the pre-trained model of the i-th iteration are fine-tuned to obtain the summary generation model of the i-th iteration.
[0241] In one or more embodiments, the parameter correction module 204 determines the training loss corresponding to the to-be-trained model of the i-th iteration according to the first logarithmic probability between the first prediction probability and the third prediction probability, and the second logarithmic probability between the second prediction probability and the fourth prediction probability, and is used to perform the following steps:
[0242] Obtaining a first logarithmic probability between the first predicted probability and the third predicted probability, and obtaining a second logarithmic probability between the second predicted probability and the fourth predicted probability;
[0243] The difference between the first logarithmic probability and the second logarithmic probability is activated to obtain a probability activation value, and the probability activation value is logarithmically operated to obtain the training loss corresponding to the model to be trained for the i-th iteration.
[0244] In one or more embodiments, the parameter modification module 204 fine-tunes the network parameters of the pre-trained model of the i-th iteration to obtain the summary generation model of the i-th iteration, which is used to perform the following steps:
[0245] Obtain a text test set; each test sample in the text test set includes a test text and an annotation summary;
[0246] Through the pre-trained model of the i-th iteration, the test text contained in the test sample in the text test set is abstracted and processed to obtain the test prediction text;
[0247] Determine the test loss corresponding to the pre-trained model of the i-th iteration based on the test prediction text and the annotation summary;
[0248] According to the test loss corresponding to the pre-trained model of the i-th iteration, the network parameters of the pre-trained model of the i-th iteration are fine-tuned to obtain the summary generation model of the i-th iteration.
[0249] In one or more embodiments, the training data updating module 205 corrects the sample prediction text to obtain the sample corrected text for performing the following steps:
[0250] The correctness of the sample prediction text is evaluated through the standard language model to obtain the evaluation result and evaluation reason corresponding to the sample prediction text;
[0251] If the evaluation result indicates that the sample prediction text is an erroneous summary, the sample prediction text is corrected according to the evaluation reason to obtain a sample corrected text.
[0252] In one or more embodiments, the text processing device 2 further includes: a sample maintaining module 206;
[0253] The sample maintaining module 206 is used to suspend the correction of the sample prediction text if the evaluation result indicates that the sample prediction text is a correct summary, and add the training sample corresponding to the sample prediction text in the text training set of the i-th iteration to the text training set of the i+1-th iteration.
[0254] In one or more embodiments, the text processing device 2 further includes: a training end module 207;
[0255] A training end module 207 is used to train the to-be-trained model of the i+1th iteration according to the text training set of the i+1th iteration to obtain a summary generation model of the i+1th iteration;
[0256] The training end module 207 is further configured to determine the summary generation model of the (i+1)th iteration as the target generation model if the training loss corresponding to the to-be-trained model of the (i+1)th iteration is the same as the training loss corresponding to the to-be-trained model of the (i)th iteration.
[0257] In one or more embodiments, the text processing device 2 further includes: a script splitting module 208, a plot summary extraction module 209;
[0258] The script splitting module 208 is used to obtain the episode plot set corresponding to the film and television script, split each episode plot in the episode plot set into scenes, and obtain the scene plot corresponding to each episode plot;
[0259] The plot summary extraction module 209 is used to input the scenes corresponding to each episode into the target generation model in sequence according to their positions in the film and television script, and obtain the plot summary corresponding to each episode; the plot summary is used to assist the creative object in the subsequent creation of the film and television script.
[0260] According to an embodiment of the present application, the above Figure 3 and Figure 5 The steps involved in the text processing method shown can be represented by Fig. 9 The text processing device 2 shown in the figure is executed by each module. For example, Figure 3 Steps S101 to S105 shown in FIG. 1 can be sequentially performed by Fig. 9 The model acquisition module 201, the first prediction module 202, the second prediction module 203, the parameter correction module 204, the training data update module 205 are executed, etc.
[0261] According to one embodiment of the present application, Fig. 9 The various modules in the text processing device 2 shown can be individually or all combined into one or several modules, or one (some) of the modules can be further divided into at least two functionally smaller units, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In actual applications, the functions of one module can also be implemented by at least two units, or the functions of at least two modules can be implemented by one module. In other embodiments of the present application, the text processing device 2 may also include other modules or units. In actual applications, these functions can also be implemented with the assistance of other modules, and can be implemented by the collaboration of at least two modules.
[0262] In the embodiments of the present application, training samples related to the text summary prediction task are used for model training. By matching the text summary prediction task with the training samples, the summary generation effect of the target generation model can be improved. By automatically optimizing the text data set and using the optimized text data set to perform reinforcement learning on the model to be trained, the upper limit of model learning can be improved. By optimizing the text training set in iterative training and continuing to train the model with the optimized text data set, a closed loop of model data learning, training data updating and model self-evolution is formed, thereby improving the efficiency of the self-evolution of the summary generation model. The training data used in the model training process are all fully automatically annotated data, without the need for manual intervention, which can improve the efficiency of collecting training data and the training efficiency of the summary generation model.
[0263] See also Fig.10 , Fig.10 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Fig.10 As shown, the computer device 1000 may be a terminal device, for example, Figure 1 The terminal device 10a in the corresponding embodiment may also be a server, for example, Figure 1The server 10d in the corresponding embodiment will not be limited here. For ease of understanding, this application takes a computer device as an example of a terminal device. The computer device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Fig.10 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
[0264] The network interface 1004 in the computer device 1000 can also provide a network communication function, and the optional user interface 1003 can also include a display screen (Display) and a keyboard (Keyboard). Fig.10 In the computer device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0265] Obtain the reference model and the model to be trained of the i-th iteration, and obtain the text training set of the i-th iteration; each training sample in the text training set of the i-th iteration includes the original text, the negative summary text and the positive summary text, and i is a positive integer;
[0266] By using the reference model of the i-th iteration, the original text contained in the training samples in the text training set of the i-th iteration is subjected to summary extraction processing to obtain a reference prediction text;
[0267] By using the to-be-trained model of the i-th iteration, the original text contained in the training sample in the text training set of the i-th iteration is subjected to summary extraction processing to obtain the sample prediction text;
[0268] According to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, the network parameters of the model to be trained of the i-th iteration are modified to obtain the summary generation model of the i-th iteration; the summary generation model of the i-th iteration is used as the reference model and the model to be trained of the i+1-th iteration;
[0269] The sample prediction text is corrected to obtain the sample corrected text, the original text, the sample prediction text and the sample corrected text are encapsulated as new samples, and the new samples are added to the text training set of the i+1th iteration; the text training set of the i+1th iteration is used to train the model to be trained of the i+1th iteration.
[0270] It should be understood that the computer device 1000 described in the embodiment of the present application can execute the above Figure 3 , Figure 5 The description of the text processing method in any of the embodiments may also be performed as described above. Figure 8 The description of the text processing device 1 in the corresponding embodiment, or Fig. 9 The description of the text processing device 2 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated here either.
[0271] In addition, it should be pointed out that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the text processing device 1 or the text processing device 2 mentioned above, and the computer program includes computer instructions. When the processor executes the computer instructions, it can execute the above-mentioned Figure 3 , Figure 5 The description of the text processing method in any of the embodiments will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, program instructions can be deployed on a computer device for execution, or on multiple computer devices located at one location, or on multiple computer devices distributed at multiple locations and interconnected by a communication network. Multiple computer devices distributed at multiple locations and interconnected by a communication network can constitute a blockchain system.
[0272] In addition, it should be noted that: the embodiment of the present application also provides a computer program product, which may include a computer program, and the computer program may be stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor may execute the computer program, so that the computer device performs the above Figure 3 , Figure 5 The description of the text processing method in any of the embodiments will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer program product or computer program embodiment involved in the present application, please refer to the description of the method embodiment of the present application.
[0273] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different media contents, rather than to describe a specific order. In addition, the term "comprising" and any variation thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment comprising a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other step units inherent to these processes, methods, devices, products, or equipment.
[0274] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0275] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0276] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0277] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A text processing method, It is characterized in that include: Obtain the reference model and the model to be trained of the i-th iteration, and obtain the text training set of the i-th iteration; Each training sample in the text training set of the i-th iteration contains the original text, the negative summary text and the positive summary text, where i is a positive integer; the reference model of the i-th iteration has the same network structure as the model to be trained of the i-th iteration, and the reference model of the i-th iteration is the model to be trained at the end of the i-1-th iteration; By using the reference model of the i-th iteration, the original text contained in the training samples in the text training set of the i-th iteration is subjected to summary extraction processing to obtain a reference prediction text; The reference prediction text is obtained by forward calculation of an embedding layer, N attention subcomponents, and a fully connected layer in a reference model of the i-th iteration; an attention subcomponent in the reference model of the i-th iteration includes a self-attention mask layer, an attention normalization layer, a feedforward network layer, and an output normalization layer; N is a positive integer; By using the to-be-trained model of the i-th iteration, the original text contained in the training sample in the text training set of the i-th iteration is subjected to summary extraction processing to obtain the sample prediction text; According to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, the network parameters of the model to be trained of the i-th iteration are modified to obtain the summary generation model of the i-th iteration; the summary generation model of the i-th iteration is used as the reference model and the model to be trained of the i+1-th iteration; The sample prediction text is corrected to obtain a sample corrected text, the original text, the sample prediction text and the sample corrected text are encapsulated as a newly added sample, and the newly added sample is added to the text training set of the i+1th iteration; the text training set of the i+1th iteration is used to train the model to be trained of the i+1th iteration.
2. The method according to claim 1, It is characterized in that The obtaining of the reference model and the model to be trained of the i-th iteration includes: Get the summary generation model of the i-1th iteration; when i is 1, the summary generation model of the i-1th iteration is the pre-trained language model; The summary generation model of the i-1th iteration is determined as the reference model of the i-th iteration, and the summary generation model of the i-1th iteration is determined as the model to be trained of the i-th iteration.
3. The method according to claim 1, It is characterized in that The method of extracting the original text contained in the training sample in the text training set of the i-th iteration by the training model of the i-th iteration to obtain the sample prediction text includes: Convert the original text contained in the training samples in the text training set of the i-th iteration into sample embedding representation; Performing feature extraction processing on the sample embedding representation through the feature extraction component in the model to be trained of the i-th iteration to obtain the sample attention feature; The sample attention features are subjected to feature transformation processing through the fully connected layer in the model to be trained of the i-th iteration to obtain the sample prediction text.
4. The method according to claim 3, It is characterized in that The feature extraction component in the model to be trained in the i-th iteration includes N attention subcomponents, where N is a positive integer; The feature extraction component in the model to be trained of the i-th iteration performs feature extraction processing on the sample embedding representation to obtain the sample attention feature, including: Obtaining the input features of the t-th attention subcomponent among the N attention subcomponents; when t is 1, the input features of the t-th attention subcomponent include the sample embedding representation; when t is not 1, the input features of the t-th attention subcomponent include the output features of the t-1-th attention subcomponent; t is a positive integer less than or equal to N; According to the self-attention mask layer in the t-th attention sub-component, the input features of the t-th attention sub-component are subjected to attention mask processing to obtain the attention mask features; Combining the attention mask feature and the input feature of the t-th attention subcomponent into a first residual feature, and normalizing the first residual feature to obtain a sample normalized feature; According to the feedforward network layer in the t-th attention subcomponent, performing feature transformation processing on the sample normalized features to obtain sample transformation features; The sample transformation feature and the sample normalization feature are combined into a second residual feature, the second residual feature is normalized to obtain the output feature of the tth attention component, and the output feature of the Nth attention component is determined as the sample attention feature.
5. The method according to claim 4, It is characterized in that The method performs attention mask processing on the input features of the t-th attention subcomponent according to the self-attention mask layer in the t-th attention subcomponent to obtain the attention mask features, including: According to the transformation weight matrix corresponding to the self-attention mask layer in the t-th attention subcomponent, the input features of the t-th attention subcomponent are transformed into a query matrix, a key matrix, and a value matrix; Performing a dot multiplication operation on the query matrix and the transposed matrix of the key matrix to obtain a candidate weight matrix, and obtaining the number of columns corresponding to the query matrix; The ratio between the candidate weight matrix and the square root of the number of columns is normalized to obtain an attention weight matrix, and the attention mask feature is determined according to the dot product between the attention weight matrix and the value matrix.
6. The method according to claim 1, It is characterized in that The method of modifying the network parameters of the model to be trained of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text to obtain the summary generation model of the i-th iteration includes: Obtaining a first prediction probability that the reference prediction text is the positive summary text, and obtaining a second prediction probability that the reference prediction text is the negative summary text; Obtaining a third prediction probability that the sample prediction text is the positive summary text, and obtaining a fourth prediction probability that the sample prediction text is the negative summary text; Determine a training loss corresponding to the model to be trained for the i-th iteration according to a first logarithmic probability between the first predicted probability and the third predicted probability, and a second logarithmic probability between the second predicted probability and the fourth predicted probability; According to the training loss corresponding to the model to be trained in the i-th iteration, the network parameters of the model to be trained in the i-th iteration are modified to obtain the pre-trained model of the i-th iteration; The network parameters of the pre-trained model of the i-th iteration are fine-tuned to obtain the summary generation model of the i-th iteration.
7. The method according to claim 6, It is characterized in that The determining, according to a first logarithmic probability between the first predicted probability and the third predicted probability, and a second logarithmic probability between the second predicted probability and the fourth predicted probability, a training loss corresponding to the model to be trained for the i-th iteration includes: Obtaining a first logarithmic probability between the first predicted probability and the third predicted probability, and obtaining a second logarithmic probability between the second predicted probability and the fourth predicted probability; An activation process is performed on the difference between the first logarithmic probability and the second logarithmic probability to obtain a probability activation value, and a logarithmic operation is performed on the probability activation value to obtain a training loss corresponding to the model to be trained for the i-th iteration.
8. The method according to claim 6, It is characterized in that The fine-tuning of the network parameters of the pre-trained model of the i-th iteration to obtain the summary generation model of the i-th iteration includes: Obtain a text test set; each test sample in the text test set includes a test text and an annotation summary; Through the pre-trained model of the i-th iteration, the test text contained in the test sample in the text test set is abstracted and processed to obtain the test prediction text; Determining a test loss corresponding to the pre-trained model of the i-th iteration according to the test prediction text and the annotation summary; According to the test loss corresponding to the pre-trained model of the i-th iteration, the network parameters of the pre-trained model of the i-th iteration are fine-tuned to obtain the summary generation model of the i-th iteration.
9. The method according to claim 1, It is characterized in that The step of correcting the sample predicted text to obtain the sample corrected text includes: Performing a correctness evaluation on the sample prediction text using a standard language model to obtain an evaluation result and evaluation reason corresponding to the sample prediction text; If the evaluation result indicates that the sample prediction text is an erroneous summary, the sample prediction text is corrected according to the evaluation reason to obtain a sample corrected text.
10. The method according to claim 9, It is characterized in that The method further comprises: If the evaluation result indicates that the sample predicted text is a correct summary, the correction of the sample predicted text is suspended, and the training sample corresponding to the sample predicted text in the text training set of the i-th iteration is added to the text training set of the i+1-th iteration.
11. The method according to any one of claims 6 to 10, It is characterized in that The method further comprises: According to the text training set of the i+1th iteration, the model to be trained of the i+1th iteration is trained to obtain the summary generation model of the i+1th iteration; If the training loss corresponding to the model to be trained in the (i+1)th iteration is the same as the training loss corresponding to the model to be trained in the (i)th iteration, the summary generation model in the (i+1)th iteration is determined as the target generation model.
12. The method according to claim 11, It is characterized in that The method further comprises: Obtaining a set of episode plots corresponding to a film or TV script, splitting each episode plot in the set of episode plots into scenes, and obtaining the scene plots corresponding to each episode plot; According to the positions of the scenes corresponding to the various episodes in the film and television script, the scenes corresponding to the various episodes are input into the target generation model in sequence to obtain the plot summaries corresponding to the various episodes; the plot summaries are used to assist the creative object in the subsequent creation of the film and television script.
13. A text processing device, It is characterized in that include: A model acquisition module is used to obtain a reference model and a model to be trained for the i-th iteration, and to obtain a text training set for the i-th iteration; Each training sample in the text training set of the i-th iteration contains the original text, the negative summary text and the positive summary text, where i is a positive integer; the reference model of the i-th iteration has the same network structure as the model to be trained of the i-th iteration, and the reference model of the i-th iteration is the model to be trained at the end of the i-1-th iteration; The first prediction module is used to perform summary extraction processing on the original text contained in the training samples in the text training set of the i-th iteration through the reference model of the i-th iteration to obtain a reference prediction text; The reference prediction text is obtained by forward calculation of an embedding layer, N attention subcomponents, and a fully connected layer in a reference model of the i-th iteration; an attention subcomponent in the reference model of the i-th iteration includes a self-attention mask layer, an attention normalization layer, a feedforward network layer, and an output normalization layer; N is a positive integer; The second prediction module is used to extract the original text contained in the training sample in the text training set of the i-th iteration through the to-be-trained model of the i-th iteration to obtain the sample prediction text; A parameter correction module, used for correcting the network parameters of the model to be trained of the i-th iteration according to the reference prediction text, the sample prediction text, the positive summary text and the negative summary text, so as to obtain the summary generation model of the i-th iteration; the summary generation model of the i-th iteration is used as the reference model and the model to be trained of the i+1-th iteration; A training data updating module is used to correct the sample prediction text to obtain a sample corrected text, encapsulate the original text, the sample prediction text and the sample corrected text as a newly added sample, and add the newly added sample to the text training set of the i+1th iteration; the text training set of the i+1th iteration is used to train the model to be trained of the i+1th iteration.
14. A computer device, It is characterized in that including memory and processor; The memory is connected to the processor, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 12.
16. A computer program product, It is characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 12 when being executed by a processor.
