Text rewriting method and device, electronic equipment and storage medium

By building diverse data sets and training different models, rewriting the rewritten text multiple times, and fusing the results, the problem of insufficient generalization capabilities in the existing technology is solved, and more accurate and diversified Text rewriting effect.

CN119476218APending Publication Date: 2025-02-18BEIJING LONGZHI DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411570716.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the existing text rewriting technology, the model lacks generalization ability when facing different tasks, resulting in inaccurate rewriting results.

Method used

By building a diverse data set and training different models, the first rewrite model and the second rewrite model are used to rewrite the rewrite text separately, generate multiple rewrite results with different styles, and fuse these results. , to generate more accurate and diverse target rewrite results.

Benefits of technology

Improves the diversity and accuracy of text rewriting, enhances the generalization ability of the model, and enables it to adapt to more text rewriting scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119476218A_ABST
    Figure CN119476218A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of natural language processing, and provides a text rewriting method and device, electronic equipment and a storage medium. The method comprises the steps of obtaining a to-be-rewritten text; the to-be-rewritten text is input into a first rewriting model, a first rewriting result is obtained, and the first rewriting model is obtained through training according to the original data set; the to-be-rewritten text is input into a second rewriting model to obtain a second rewriting result, the second rewriting model is obtained through training according to a variant data set, and the variant data set is obtained by performing data expansion processing on the original data set; and performing text fusion on the first rewriting result and the second rewriting result to obtain a target rewriting result. The problem that a text rewriting result is inaccurate is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and in particular to a text rewriting method, device, electronic device and storage medium. Background Art

[0002] Text rewriting is a natural language processing task that can modify, adjust or regenerate the original text based on a given input text or prompt while keeping the core meaning of the original text unchanged. Text rewriting tasks can be applied to multiple fields, such as content creation, search engine optimization, and academic fields.

[0003] There are many ways to implement existing text rewriting technologies, such as rewriting input text according to predefined templates, or generating prompt words by training deep neural networks. However, these rewriting technologies cannot avoid the problem that the model's generalization ability is insufficient when facing different tasks, resulting in inaccurate rewriting results. Summary of the invention

[0004] In view of this, the present application provides a text rewriting method, device, electronic device and storage medium to solve the problem of inaccurate rewriting results in the prior art.

[0005] In a first aspect of the present application, a text rewriting method is provided, comprising: obtaining a text to be rewritten; inputting the text to be rewritten into a first rewriting model to obtain a first rewriting result, wherein the first rewriting model is trained based on an original data set; inputting the text to be rewritten into a second rewriting model to obtain a second rewriting result, wherein the second rewriting model is trained based on a variant data set, wherein the variant data set is obtained by performing data expansion processing on the original data set; and text fusion is performed on the first rewriting result and the second rewriting result to obtain a target rewriting result.

[0006] According to a second aspect of the present application, a text rewriting device is provided, including: an acquisition module, configured to acquire a text to be rewritten; a first rewriting module, configured to input the text to be rewritten into a first rewriting model to obtain a first rewriting result, wherein the first rewriting model is trained based on an original data set; a second rewriting module, configured to input the text to be rewritten into a second rewriting model to obtain a second rewriting result, wherein the second rewriting model is trained based on a variant data set, wherein the variant data set is obtained by performing data expansion processing on the original data set; and a fusion module, configured to perform text fusion on the first rewriting result and the second rewriting result to obtain a target rewriting result.

[0007] According to a third aspect of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0008] According to a fourth aspect of the present application, a storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0009] At least one of the above technical solutions adopted in this application can achieve the following beneficial effects:

[0010] By obtaining the text to be rewritten, the first rewriting result is obtained by rewriting the text to be rewritten using the first rewriting model, and the first rewriting model is a model trained on the original data set. At the same time, the second rewriting result is obtained by processing the text to be rewritten using the second rewriting model, and the second rewriting result is obtained by training the variant data set. In this way, the second rewriting result can have more different expressions and preserve the original meaning at the same time. In this way, by constructing different data sets and using different data sets to train the corresponding models, different models can generate rewriting results of different styles. Then, the first rewriting result is fused with the second rewriting result to obtain the target rewriting result. In this way, the text to be rewritten can be rewritten by multiple models to obtain multiple rewriting results, and the multiple rewriting results are fused to obtain a more accurate target rewriting result. This not only improves the diversity and accuracy of the target rewriting results, but also improves the generalization ability of the model, so that it can adapt to more text rewriting scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 any creative work.

[0012] Figure 1 It is a flowchart of a text rewriting method provided in an embodiment of the present application;

[0013] Figure 2 is a flowchart of another text rewriting method provided in an embodiment of the present application;

[0014] Figure 3 It is a flowchart of another text rewriting method provided in an embodiment of the present application;

[0015] Figure 4 It is a flowchart of another text rewriting method provided in an embodiment of the present application;

[0016] Figure 5 It is a flowchart of another text rewriting method provided in an embodiment of the present application;

[0017] Figure 6 It is a flowchart of an optional text rewriting method provided in an embodiment of the present application;

[0018] Figure 7 is a structural schematic diagram of a text rewriting device provided in an embodiment of the present application;

[0019] Figure 8 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0021] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0022] In addition, it should be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "includes..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0023] In text rewriting or text style adjustment tasks, traditional methods often rely on fixed prompt words and templates, which makes it difficult for models to effectively handle these tasks when faced with complex text. The limitation of fixed templates is that they can only cope with inputs of specific structures or formats, and usually perform poorly for complex and diverse text rewriting needs. At the same time, when training the model by expanding the training set, if the generated prompt word dataset lacks sufficient diversity, the generalization ability of the model will be limited. This will make it difficult for the model to generate high-quality output when faced with different tasks or text style changes.

[0024] To solve these problems, this solution proposes a strategy to construct a diversified cue word training set, and improve the expressiveness and generalization ability of text rewriting through multi-model training. Specifically, the original cue words are diversified through a variety of variant strategies to generate a richer set of cue words to expand the breadth and depth of the training data. Subsequently, multiple pre-trained models with different structures or styles (such as the Mistral model and the LLaMA model, the LLaMA model represents the LargeLanguage Model Meta AI, which means a large language model that can be used to perform text understanding and text generation tasks) are fine-tuned using these diversified cue word training sets, and rewriting reasoning is performed using multiple models and the rewriting results of multiple models are fused to obtain accurate rewriting results.

[0025] A text rewriting method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.

[0026] Figure 1 is a flowchart of a text rewriting method provided by an embodiment of the present application. Figure 1 As shown, the text rewriting method includes:

[0027] S101, obtaining the text to be rewritten.

[0028] Specifically, the acquired text to be rewritten may be original, unprocessed content, which may come from different application scenarios, such as articles, paragraphs, or sentences, and is data waiting to be rewritten or style adjusted by the model.

[0029] S102, inputting the text to be rewritten into a first rewriting model to obtain a first rewriting result, where the first rewriting model is trained based on the original data set.

[0030] Specifically, the original data set may be a data set including samples to be rewritten, prompt word samples, and rewritten samples obtained from a public database or other available data, and the original data set may represent a data set used for the variant data set to be expanded. The first rewriting model may be trained based on the original data set, so that the first rewriting model can be closer to the style and semantic expression of the original data when rewriting.

[0031] S103, inputting the text to be rewritten into a second rewriting model to obtain a second rewriting result, wherein the second rewriting model is trained based on a variant data set, and the variant data set is obtained by performing data expansion processing on the original data set.

[0032] Specifically, the variant dataset may include corresponding samples to be rewritten, variant prompt word samples, and variant rewriting samples, which may represent a dataset obtained by expanding (such as adding details, changing style, and adjusting structure) the original dataset. This can help the model learn more diversity and changes, and then use the second rewriting model to rewrite the text to be rewritten. The second rewriting result obtained is more flexible and diverse. Of course, the generated second rewriting result and the first rewriting result are rewritten based on the same text to be rewritten, but they are different in rewriting style or expression, and their core meaning remains the same.

[0033] S104, performing text fusion on the first rewriting result and the second rewriting result to obtain a target rewriting result.

[0034] Specifically, after the first rewriting result and the second rewriting result are generated, the two types of rewriting results are merged to obtain a more accurate and smoother target rewriting result.

[0035] Figure 2 This is a flowchart of another text rewriting method provided by an embodiment of the present application. Figure 2 The text rewriting and merging process of this embodiment is described.

[0036] First, you can load the inference configuration of each model (the first rewriting model and the second rewriting model), including the model name, adapter path, prompt template and parsing strategy. The prompt template can represent the system's data structure template for the input text, and the parsing strategy can represent the strategy for parsing the target rewriting result and feeding it back to the user. It will not be expanded here.

[0037] Furthermore, the configuration of each model is verified to ensure the validity of the model path and the configurator path, and the relevant parameters and parsing strategies used in the reasoning stage are prepared. The first rewriting model and the second rewriting model are used to perform rewriting reasoning to obtain the first rewriting result and the second rewriting result. The results are stored and fused to further determine whether the rewriting task is completed. If the generated target rewriting result is not complete, the reasoning is re-run to obtain the rewriting result again, and all the rewriting results are fused to obtain the final rewriting result. The final rewriting result is processed based on the parsing strategy to generate a result file, such as combing the text with messy structure, deleting the structure with structural words such as "user input" and "rewriting result", etc., which will not be expanded here.

[0038] According to the technical solution provided in the above embodiment, two different rewriting models are used, each of which obtains specific rewriting capabilities from different training data (original data set and variant data set), and generates two different rewriting results respectively. By fusing these two types of results, a better target rewriting result is generated. This method enhances the generalization ability of the model and improves the diversity and accuracy of text rewriting.

[0039] In some embodiments, the original data set includes corresponding samples to be rewritten, prompt word samples and rewritten samples, and the variant data set is obtained by performing data expansion processing on the original data set, including: obtaining prompt word samples and samples to be rewritten from the original data set; according to a predefined variant strategy, expanding the prompt word samples to obtain variant prompt word samples corresponding to the prompt word samples, and the variant strategy represents the strategy for expanding the prompt word samples; rewriting the samples to be rewritten according to the variant prompt word samples to obtain variant rewritten samples, and the variant data set includes corresponding samples to be rewritten, variant prompt word samples and variant rewritten samples.

[0040] Specifically, the original data set can be expanded based on a predefined variant strategy to obtain a variant data set. Specifically, the original data set can include three types of data, namely, mutually corresponding samples to be rewritten, prompt word samples, and rewritten samples, wherein the samples to be rewritten can represent the original text fragments or sentences that need to be rewritten in the sample data, the prompt word samples can represent the prompt words generated during the rewriting task of the samples to be rewritten to guide the model to rewrite, and the rewritten samples can be understood as the text corresponding to the text to be rewritten, that is, the result after the model rewrites according to the corresponding prompt word samples. The samples to be rewritten, the prompt word samples, and the rewritten samples can be stored in the form of data pairs, that is, multiple data pairs can be included in the original data set. The original data set can come from historical training data or a public database, which is not limited here.

[0041] Furthermore, the variant data set can be obtained by processing the original data set through a series of variant strategies.

[0042] Figure 3 This is a flowchart of another text rewriting method provided in an embodiment of the present application. Figure 3 The generation process of variant prompt word samples is explained.

[0043] First, the prompt word samples and the samples to be rewritten can be obtained from the original data set, that is, the original data is loaded, and then the data structure for storing variant prompts (such as a JSON file, which can represent a file that uses the JavaScript Object Notation format to store and transmit data) is checked or created to save the generated variant prompt word samples later. Further, the prompt word samples are mutated by a pre-defined variant strategy, the prompt word samples are traversed, and each prompt word sample is processed by applying each variant strategy to obtain a variant prompt word sample. The task of generating variant prompt word samples can be performed by a large language model. After obtaining the variant prompt word samples, they can be saved in a pre-created data structure, wherein the variant prompt word samples correspond to the prompt word samples, and the variant prompt word samples and the prompt word samples are characterized as prompt words with different styles or different detailed descriptions, but with the same core meaning.

[0044] Furthermore, after obtaining the variant prompt word samples, the prompt word samples are traversed again to check whether there are any unprocessed prompt word variants. If there are any unprocessed prompt word variants, the variant tasks are traversed again. If not, the final variant prompt word is generated.

[0045] Among them, the predetermined variant strategy can be a variety of variant strategies set manually in advance. When performing the training task, a variant style is formulated, and then the prompt word sample is rewritten according to the corresponding variant strategy. The variant strategy can be understood as a set of rules or methods for rewriting the prompt word sample, which aims to change the content, form or style of the prompt word, for example: adding details, that is, adding more instructions or requirements to the prompt word sample; changing the style, that is, changing the tone of the prompt word sample from formal to informal, or from technical to popular; simplifying the prompt word, that is, simplifying the description of the prompt word sample to obtain a concise and clear variant prompt word sample. When performing the task, there can be multiple variant strategies, which are not limited here. In order to ensure that each prompt word sample has multiple variants for subsequent training, each prompt word sample can be traversed one by one in the variant process, and each variant strategy can be applied in turn. For each strategy, the pre-trained model is called to generate a new variant prompt word sample. In this way, by generating multiple variant prompt word samples, the diversity of the variant data set can be expanded, and the performance of the model in different tasks can be improved.

[0046] Furthermore, the variant prompt word samples can be used to rewrite the samples to be rewritten to obtain variant rewritten samples, and the samples to be rewritten, the variant prompt word samples and the variant rewritten texts can be stored to obtain a variant dataset, providing rich training data for model learning.

[0047] It should be understood that in order to ensure that the core meanings of subsequent variant prompt word samples and prompt word samples are consistent, and to ensure that the training processes of the original data set and the variant data set for different rewriting models are consistent, the samples to be rewritten in the variant data set and the samples to be rewritten in the original data set can be the same data.

[0048] According to the technical solution provided in the above embodiment, the prompt word samples are rewritten using a variant strategy to generate variant prompt word samples, and variant rewritten texts are regenerated based on these variant prompt word samples. The final variant data provides more diverse and extensive training data, so that the model can better cope with different types of rewriting tasks, thereby improving the generalization ability and rewriting quality of the model.

[0049] In some embodiments, before rewriting the sample to be rewritten according to the variant prompt word sample to obtain the variant rewritten sample, it also includes: loading a variant rewriting model, the variant rewriting model is used to rewrite the sample to be rewritten according to the variant prompt word sample to obtain the variant rewritten sample; in response to manually determined rewriting requirements, configuring parameters of the variant rewriting model, the parameters including the text length limit of the variant rewriting model input and a quantization loading option.

[0050] Specifically, a variant rewriting model can be loaded, and the variant rewriting model is used to rewrite the sample to be rewritten according to the variant prompt word sample. The variant rewriting model can be a Gemma model, but there is no limitation here. Any large model that can be used to perform text generation tasks and meet the task requirements of this embodiment can be used.

[0051] When loading the variant rewriting model, the system can configure personalized parameters for the model operation according to the actual text rewriting requirements. The actual text rewriting requirements can be determined manually, and the specific rewriting requirements can also vary according to the specific task changes, such as: the text style that needs to be generated, the text length requirements, and the optimization of processing speed or resource consumption. In response to these requirements, some important model parameters can be set manually, including but not limited to: 1. Input text length limit, that is, in order to ensure that the generated rewritten text does not exceed the expected length, the input text length limit can be set for the model, which can determine the maximum number of characters or words that the model can accept when processing variant prompt word samples and samples to be rewritten. 2. Quantization loading options, quantization technology can be used to reduce the memory and computing resource consumption of the model. For example, 4-bit quantization can reduce the size of the model and make it run more efficiently, which can help the model achieve performance optimization so that the model can run in a low-resource environment.

[0052] According to the technical solution provided in the above embodiment, by loading a special variant rewriting model, and then configuring the parameters of the variant rewriting model according to the specific rewriting requirements, the performance and generation results of the model are optimized. This ensures that the rewriting results of the variant generation model can not only meet the expected text length or content requirements, but also run efficiently under resource-constrained conditions and generate diversified variant rewriting samples that meet the requirements.

[0053] In some embodiments, the sample to be rewritten is rewritten according to the variant prompt word sample to obtain the variant rewritten sample, including: comparing the variant prompt word sample with the rewritten sample to determine whether there is a variant prompt word sample corresponding to the rewritten sample; if there is a variant prompt word sample corresponding to the rewritten sample, filtering the variant prompt word samples with the corresponding rewritten samples and retaining the variant prompt word samples without the corresponding rewritten samples; processing the sample to be rewritten according to the variant prompt word sample without the corresponding rewritten sample to obtain the variant rewritten sample.

[0054] Specifically, in the process of generating variant rewriting samples, it is possible to first determine whether there is already a corresponding rewriting text in the original data set. If rewriting the sample to be rewritten by the variant prompt word sample will generate an existing rewriting text, then the variant prompt word sample can be proposed to avoid the process of repeatedly generating the same or similar rewriting text, so as to achieve efficient construction of the variant data set, that is, to determine whether a repeated rewriting sample will be generated by determining whether there is a "variant prompt word sample with a corresponding rewriting sample".

[0055] Each variant prompt word sample can be compared with the existing rewriting sample to check whether a model has already generated a corresponding rewriting result based on this variant prompt word sample. The comparison course can be compared through semantic understanding, which will not be expanded here.

[0056] If it is found that a variant prompt word sample already has a corresponding rewriting result, these variant prompt word samples will no longer be processed repeatedly. The variant prompt word samples with corresponding rewriting samples can be filtered out, and the "variant prompt word samples without corresponding rewriting samples" can be retained. In this way, repeated processing of the already generated text can be avoided, the waste of computing resources is reduced, and it is ensured that new variant prompt word samples can be used to generate new rewritten texts.

[0057] Figure 4 This is a flowchart of another text rewriting method provided in an embodiment of the present application. Figure 4 This embodiment is further described.

[0058] First, load the variant rewriting model, configure the corresponding parameters for it, and load the samples to be rewritten and the variant prompt word samples. Select the unprocessed variant prompt word samples (that is, the variant prompt word samples without corresponding rewriting samples) from the variant prompt word samples for rewriting to obtain the variant rewriting samples. Save the variant rewriting samples and construct a variant dataset together with the samples to be rewritten and the variant prompt word samples.

[0059] According to the technical solution provided by the above embodiment, repeated rewriting operations are avoided through comparison, and only variant prompt word samples that do not have corresponding rewriting samples are processed, which improves efficiency, ensures that the generated variant rewriting samples have sufficient diversity, and avoids wasting resources to repeatedly generate existing texts. This helps to ensure that the model can be trained more widely based on new prompt words, while reducing unnecessary repeated operations, optimizing the efficiency and quality of text generation, enriching the variant data set, and thus improving the accuracy of the model-generated rewriting text.

[0060] In some embodiments, text fusion is performed on the first rewriting result and the second rewriting result to obtain a target rewriting result, including: performing semantic analysis on the first rewriting result and the second rewriting result to obtain an analysis result; selecting a corresponding fusion method based on the analysis result, and fusing the first rewriting result and the second rewriting result based on the corresponding fusion method to obtain a target rewriting result, and the fusion methods include splicing methods and model integration methods.

[0061] Specifically, after the text to be rewritten is rewritten by using the first rewriting model and the second rewriting model to obtain the corresponding first rewriting result and second rewriting result, the two rewriting results can be fused to obtain the target rewriting result.

[0062] The fusion method can be splicing and model integration. The splicing method can be to splice and fuse texts with relatively independent text structures or texts with consistent content and similar styles. Model integration can be understood as using a large model to analyze and fuse two rewriting results, and regenerate a more coherent and consistent text based on the semantic information of the two rewriting results. Of course, there is no restriction here.

[0063] Before fusion, it is possible to determine which fusion method is applicable to the current rewriting task, that is, before fusion of the first rewriting result and the second rewriting result, semantic analysis can be performed on both to understand the meaning, content, style, structure and other characteristics of each text. Specifically, the analysis process can compare the consistency of the content, style differences, semantic similarity, etc. of each text, and select a suitable fusion method based on the analysis results. The specific selection of the analysis method is not limited here, and the task can be performed by the system.

[0064] As some examples, when the analysis shows that the contents of the first rewriting result and the second rewriting result complement each other to some extent, or they process different parts respectively and have similar content or style, the target rewriting result can be constructed by splicing. When there are large differences between the two rewriting results and simple splicing may lead to semantic incoherence or style conflicts, the model integration method can be applied to further perform deep learning processing on the two rewriting results to obtain a more natural and consistent text output.

[0065] According to the technical solution provided in the above embodiment, semantic analysis is used to understand the similarities or differences between two rewriting results, and then a suitable fusion method is selected. The rewriting results with similar content are simply spliced ​​together, and the rewriting results with large content differences are fused through model integration. This ensures the consistency, accuracy and diversity of the target rewriting results.

[0066] In some embodiments, before obtaining the text to be rewritten, it also includes: obtaining an original data set and a variant data set, the original data set includes an original training set and an original evaluation set, and the variant data set includes a variant training set and a variant evaluation set; training and evaluating the performance of a pre-trained first rewriting model according to the original training set and the original evaluation set to obtain a first rewriting model; training and evaluating the performance of a pre-trained second rewriting model according to the variant training set and the variant evaluation set to obtain a second rewriting model.

[0067] Figure 5 This is a flowchart of another text rewriting method provided in an embodiment of the present application. Figure 5 Explain the model training.

[0068] Specifically, before performing the text rewriting task, two different rewriting models can be constructed and evaluated through a series of steps, namely, a first rewriting model based on the original data set and a second rewriting model based on the variant data set, where the first rewriting model can be the Mistral model and the second model can be the LLaMA model, but this is not limited here.

[0069] First, load the model and word segmenter in the system, and configure model quantization and device mapping. After that, you can obtain the original data set and variant data set. The specific acquisition method will not be expanded here. After obtaining the original data set and variant data set, you can split the two data sets respectively, and filter out the overly long samples to obtain the original training set and original evaluation set corresponding to the original data set, as well as the variant training set and variant evaluation set corresponding to the variant data set. The original training set can be used to train the first rewriting model, and the original evaluation set is used regularly during the training process to evaluate the model performance and detect the generalization ability and accuracy of the first rewriting model. The variant training set can be used to train the second rewriting model, so that the rewriting task of the second rewriting model has more rewriting effects corresponding to the variant strategy, such as adding details, simplifying structure, etc. The variant evaluation set can be used to test and evaluate the performance of the second rewriting model. Similar to the original evaluation set, the variant evaluation set can ensure that the second rewriting model can handle diverse prompt words and generate reasonable rewritten texts.

[0070] During the training process, both the first rewriting model and the second rewriting model will learn how to generate the corresponding rewritten texts based on the corresponding training sets. Common evaluation indicators can be used to evaluate the models, such as the BLEU evaluation indicator, the ROUGE evaluation indicator, or based on manual review. The BLEU evaluation indicator represents Bilingual Evaluation Understudy, which can be used to evaluate the matching degree between the rewritten text and the training set, and the ROUGE evaluation indicator represents Recall-Oriented Understudy for Gisting Evaluation, which can be used to evaluate the semantic retention and information overlap between the rewritten text and the training set.

[0071] Furthermore, training the first rewriting model based on the original data set can enable the first rewriting model to learn the rewriting task execution method corresponding to the prompt word sample, while the second rewriting model can learn the prompt word styles of multiple variant prompt word samples, and then learn the corresponding rewriting task execution method. In this way, by using models trained with different data sets to jointly perform rewriting tasks, the diversity and robustness of the model system can be enhanced.

[0072] According to the technical solution provided in the above embodiment, the first rewriting model and the second rewriting model are trained respectively through the original data set and the variant data set, wherein the first rewriting model is good at processing the rewriting task of the original prompt word, and the second rewriting model is good at processing the rewriting task corresponding to the prompt word processed by the variant, thereby ensuring that they have high accuracy and generation ability in the rewriting tasks corresponding to different types of prompt words.

[0073] In some embodiments, after text fusion is performed on the first rewriting result and the second rewriting result to obtain the target rewriting result, the method further includes: obtaining prompt words, the prompt words including original prompt words and variant prompt words, the original prompt words are obtained by processing the text to be rewritten based on the first rewriting model, and the variant prompt words are obtained by processing the text to be rewritten based on the second rewriting model; if there are prompt words that do not correspond to the target rewriting result, the text to be rewritten is rewritten according to the prompt words that do not correspond to the target rewriting result to obtain a second rewriting result.

[0074] Specifically, after the first rewriting result and the second rewriting result are merged to obtain the target rewriting result, the completion degree of the rewriting task of the text to be rewritten can also be judged, that is, the prompt words in the current first rewriting model and the second rewriting model are obtained, and it is judged whether the target rewriting result contains the rewriting results corresponding to all the prompt words. If there are prompt words that are not included, the rewriting task is re-executed according to the prompt words to obtain the rewriting result again.

[0075] According to the technical solution provided by the above embodiment, the completion degree of the rewriting task of the text to be rewritten can be judged by judging whether there is a prompt word without a corresponding target rewriting result, thereby increasing the accuracy of the rewriting result.

[0076] Figure 6 This is a flowchart of an optional text rewriting method provided in an embodiment of the present application. Figure 6 The embodiments of the present application are further described.

[0077] First, the original dataset can be loaded, and variant prompt word samples can be generated based on the original dataset.

[0078] Further, variant rewriting samples are generated based on the variant prompt word samples, and a variant data set is generated based on the variant rewriting samples, the samples to be rewritten and the variant prompt word samples.

[0079] Based on the variant data set and the original data set, multi-model training can be performed to obtain the first rewriting model and the second rewriting model. After that, the trained first rewriting model and the second rewriting model can be used to perform model reasoning and fusion to output the final rewriting result.

[0080] In this way, the dataset can be expanded through multiple variants of the prompt word samples, and then variant rewriting samples can be generated based on these variant prompt word samples, and multiple models can be further fine-tuned. Finally, in the inference stage, high-quality final text output is generated through multi-model fusion, ensuring that the model can cope with different text generation tasks and improving the robustness of the model.

[0081] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.

[0082] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0083] Figure 7 Schematic diagram of the structure of a text rewriting device provided in an embodiment of the present application. Figure 7 As shown, the text rewriting device comprises:

[0084] An acquisition module 701 is configured to acquire the text to be rewritten;

[0085] A first rewriting module 702 is configured to input the to-be-rewritten text into a first rewriting model to obtain a first rewriting result, wherein the first rewriting model is obtained by training based on the original data set;

[0086] The second rewriting module 703 is configured to input the to-be-rewritten text into a second rewriting model to obtain a second rewriting result, wherein the second rewriting model is obtained by training the variant data set, and the variant data set is obtained by performing data expansion processing on the original data set;

[0087] The fusion module 704 is configured to perform text fusion on the first rewriting result and the second rewriting result to obtain a target rewriting result.

[0088] In some embodiments, the second rewriting module 703 is specifically used to obtain a prompt word sample and the sample to be rewritten from the original data set; according to a predefined variant strategy, the prompt word sample is expanded to obtain a variant prompt word sample corresponding to the prompt word sample, and the variant strategy represents a strategy for expanding the prompt word sample; according to the variant prompt word sample, the sample to be rewritten is rewritten to obtain a variant rewritten sample, and the variant data set includes the corresponding sample to be rewritten, the variant prompt word sample and the variant rewritten sample.

[0089] In some embodiments, the second rewriting module 703 is specifically used to load a variant rewriting model, which is used to rewrite the sample to be rewritten according to the variant prompt word sample to obtain the variant rewriting sample; in response to the manually determined rewriting requirements, the variant rewriting model is configured with parameters, and the parameters include the text length limit of the variant rewriting model input and the quantization loading option.

[0090] In some embodiments, the second rewriting module 703 is specifically used to compare the variant prompt word sample with the rewriting sample to determine whether there is a variant prompt word sample corresponding to the rewriting sample; if there is a variant prompt word sample corresponding to the rewriting sample, the variant prompt word samples with the corresponding rewriting samples are filtered and the variant prompt word samples without the corresponding rewriting samples are retained; the sample to be rewritten is processed according to the variant prompt word sample without the corresponding rewriting sample to obtain the variant rewriting sample.

[0091] In some embodiments, the fusion module 704 is specifically used to perform semantic analysis on the first rewriting result and the second rewriting result to obtain an analysis result; select a corresponding fusion method based on the analysis result, and fuse the first rewriting result and the second rewriting result based on the corresponding fusion method to obtain a target rewriting result. The fusion method includes a splicing method and a model integration method.

[0092] In some embodiments, the acquisition module 701 is specifically used to acquire an original data set and a variant data set, the original data set includes an original training set and an original evaluation set, and the variant data set includes a variant training set and a variant evaluation set; a first rewrite model before training is trained and performance evaluated according to the original training set and the original evaluation set to obtain a first rewrite model; a second rewrite model before training is trained and performance evaluated according to the variant training set and the variant evaluation set to obtain a second rewrite model.

[0093] In some embodiments, the fusion module 704 is specifically used to obtain prompt words, which include original prompt words and variant prompt words. The original prompt words are obtained by processing the text to be rewritten based on the first rewriting model, and the variant prompt words are obtained by processing the text to be rewritten based on the second rewriting model; if there are prompt words that do not correspond to the target rewriting results, the text to be rewritten is rewritten according to the prompt words that do not correspond to the target rewriting results to obtain a second rewriting result.

[0094] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0095] Figure 8 Schematic diagram of an electronic device 8 provided in an embodiment of the present application. Figure 8As shown, the electronic device 8 of this embodiment includes: a processor 801, a memory 802, and a computer program 803 stored in the memory 802 and executable on the processor 801. When the processor 801 executes the computer program 803, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 801 executes the computer program 803, the functions of the modules / units in the above-mentioned device embodiments are implemented.

[0096] The electronic device 8 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 8 may include, but is not limited to, a processor 801 and a memory 802. Those skilled in the art will appreciate that Figure 8 The electronic device 8 is merely an example and does not limit the electronic device 8 . The electronic device 8 may include more or fewer components than those shown in the figure, or different components.

[0097] The processor 801 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0098] The memory 802 may be an internal storage unit of the electronic device 8, for example, a hard disk or memory of the electronic device 8. The memory 802 may also be an external storage device of the electronic device 8, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 8. The memory 802 may also include both an internal storage unit of the electronic device 8 and an external storage device. The memory 802 is used to store computer programs and other programs and data required by the electronic device.

[0099] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0100] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0101] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A text rewriting method, characterized in that: include: Get the text to be rewritten; Inputting the to-be-rewritten text into a first rewriting model to obtain a first rewriting result, wherein the first rewriting model is trained based on an original data set; Inputting the to-be-rewritten text into a second rewriting model to obtain a second rewriting result, wherein the second rewriting model is obtained by training a variant data set, and the variant data set is obtained by performing data expansion processing on the original data set; Text fusion is performed on the first rewriting result and the second rewriting result to obtain a target rewriting result.

2. The method according to claim 1, characterized in that The original data set includes corresponding samples to be rewritten, prompt word samples and rewritten samples. The variant data set is obtained by performing data expansion processing on the original data set, including: Acquire the prompt word sample and the to-be-rewritten sample from the original data set; According to a predefined variant strategy, the prompt word sample is extended to obtain a variant prompt word sample corresponding to the prompt word sample, wherein the variant strategy represents a strategy for extending the prompt word sample; The sample to be rewritten is rewritten according to the variant prompt word sample to obtain a variant rewritten sample, and the variant data set includes the corresponding sample to be rewritten, the variant prompt word sample and the variant rewritten sample.

3. The method according to claim 2, characterized in that Before rewriting the sample to be rewritten according to the variant prompt word sample to obtain the variant rewritten sample, the method further includes: Loading a variant rewriting model, wherein the variant rewriting model is used to rewrite the sample to be rewritten according to the variant prompt word sample to obtain the variant rewriting sample; In response to the manually determined rewriting requirements, parameters are configured for the variant rewriting model, wherein the parameters include a text length limit of the variant rewriting model input and a quantization loading option.

4. The method according to claim 3, characterized in that The step of rewriting the sample to be rewritten according to the variant prompt word sample to obtain the variant rewritten sample includes: Comparing the variant prompt word sample with the rewritten sample to determine whether there is a variant prompt word sample corresponding to the rewritten sample; If there are variant prompt word samples with corresponding rewritten samples, filtering the variant prompt word samples with corresponding rewritten samples and retaining variant prompt word samples without corresponding rewritten samples; The sample to be rewritten is processed according to the variant prompt word sample without corresponding rewriting sample to obtain the variant rewriting sample.

5. The method according to claim 1, characterized in that The performing text fusion on the first rewriting result and the second rewriting result to obtain a target rewriting result includes: Performing semantic analysis on the first rewriting result and the second rewriting result to obtain an analysis result; A corresponding fusion method is selected based on the analysis result, and the first rewriting result and the second rewriting result are fused based on the corresponding fusion method to obtain the target rewriting result. The fusion method includes a splicing method and a model integration method.

6. The method according to claim 2, characterized in that Before obtaining the text to be rewritten, the method further includes: Acquire the original data set and the variant data set, wherein the original data set includes an original training set and an original evaluation set, and the variant data set includes a variant training set and a variant evaluation set; Training and performance evaluation of a pre-trained first rewriting model according to the original training set and the original evaluation set to obtain the first rewriting model; The second rewriting model before training is trained and performance evaluated according to the variant training set and the variant evaluation set to obtain the second rewriting model.

7. The method according to claim 6, characterized in that After performing text fusion on the first rewriting result and the second rewriting result to obtain a target rewriting result, the method further includes: Acquire prompt words, the prompt words including original prompt words and variant prompt words, the original prompt words are obtained by processing the to-be-rewritten text based on the first rewriting model, and the variant prompt words are obtained by processing the to-be-rewritten text based on the second rewriting model; If there is a prompt word that does not correspond to the target rewriting result, the text to be rewritten is rewritten according to the prompt word that does not correspond to the target rewriting result to obtain a second rewriting result.

8. A text rewriting device, characterized in that: include: An acquisition module, configured to acquire the text to be rewritten; A first rewriting module is configured to input the to-be-rewritten text into a first rewriting model to obtain a first rewriting result, wherein the first rewriting model is obtained by training based on an original data set; A second rewriting module is configured to input the to-be-rewritten text into a second rewriting model to obtain a second rewriting result, wherein the second rewriting model is obtained by training a variant data set, and the variant data set is obtained by performing data expansion processing on the original data set; The fusion module is configured to perform text fusion on the first rewriting result and the second rewriting result to obtain a target rewriting result.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.