Text generation method, and training method and device of generation model
Through adversarial training of generative models and quality assessment, the problem of unnatural AI-generated text is solved, and high-quality text that conforms to human writing style is generated.
Patent Information
- Application Number
- CN202510959193.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-10-17
AI Technical Summary
AI-generated text lacks the emotion, style, and personality of human writing, resulting in the generated text being unnatural and fluent, and difficult to meet user needs.
A generative model with adversarial training is used to adjust the parameters of the generative model through interaction with the discriminative model, so that it can generate text that conforms to human writing patterns. Combined with AI generation detection and quality assessment, the naturalness and fluency of the generated text are ensured.
The naturalness and fluency of generated text are improved, ensuring that the generated text conforms to human writing style and passes quality assessment, thereby enhancing user experience.
Smart Images

Figure CN120805865A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of artificial intelligence, in particular to the technical field of deep learning, natural language processing, and large model. More specifically, the present disclosure provides a text generation method, a training method of a generation model, an apparatus, an electronic device, a storage medium, and a computer program product. BACKGROUND
[0002] With the popularization of AI generation technology, the demand for AI generated content in various fields is increasing. However, there is a certain difference between AI generated content and human writing thinking, which leads to unnatural AI generated text and difficulty in meeting user requirements. SUMMARY
[0003] The present disclosure provides a text generation method, a training method of a generation model, an apparatus, an electronic device, a storage medium, and a computer program product.
[0004] According to a first aspect, a text generation method is provided, which includes: determining a topic and a field of a text to be generated according to input information; and in response to triggering of a first writing mode, generating target text conforming to the first writing mode using a generation model according to the topic and the field, wherein the generation model is obtained by adversarial training with a discrimination model, and the discrimination model is used to discriminate a writing mode of text generated by the generation model, and the writing mode is one of the first writing mode and a second writing mode.
[0005] According to a second aspect, a training method of a generation model is provided, which includes: obtaining historical revision data, wherein the historical revision data includes historical original text, review opinion text, and modification result text; rewriting the historical original text using the generation model to obtain rewritten text; performing writing mode detection on the rewritten text to obtain a writing mode detection result; determining a loss of the generation model according to the rewritten text, the review opinion text, the modification result text, and the writing mode detection result; and adjusting parameters of the generation model according to the loss.
[0006] According to a third aspect, a text generation apparatus is provided, which includes: a determination module configured to determine a topic and a field of a text to be generated according to input information; and a generation module configured to, in response to triggering of a first writing mode, generate target text conforming to the first writing mode using a generation model according to the topic and the field, wherein the generation model is obtained by adversarial training with a discrimination model, and the discrimination model is used to discriminate a writing mode of text generated by the generation model, and the writing mode is one of the first writing mode and a second writing mode.
[0007] According to a fourth aspect, a training device for a generative model is provided, which includes: an acquisition module for acquiring historical revision data, wherein the historical revision data includes historical original text, review opinion text, and modification result text; a rewriting module for rewriting the historical original text using the generative model to obtain a rewritten text; a detection module for performing writing mode detection on the rewritten text to obtain a writing mode detection result; a loss determination module for determining the loss of the generative model based on the rewritten text, review opinion text, modification result text, and writing mode detection result; and an adjustment module for adjusting the parameters of the generative model based on the loss.
[0008] According to a fifth aspect, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method provided according to the present disclosure.
[0009] According to a sixth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method provided according to the present disclosure.
[0010] According to a seventh aspect, a computer program product is provided, comprising a computer program stored on at least one of a readable storage medium and an electronic device, wherein the computer program implements the method provided according to the present disclosure when executed by a processor.
[0011] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0013] Figure 1 is a schematic diagram of an exemplary system architecture to which a text generation method and a training method for a generation model can be applied according to an embodiment of the present disclosure;
[0014] Figure 2 is a flowchart of a text generation method according to an embodiment of the present disclosure;
[0015] Figure 3 is a flowchart of a text generation method according to another embodiment of the present disclosure;
[0016] Figure 4 is a flowchart of a text generation method according to another embodiment of the present disclosure;
[0017] Figure 5 is a flowchart of a training method of a generation model according to one embodiment of the present disclosure;
[0018] Figure 6 is a schematic diagram of determining a loss of a generation model according to one embodiment of the present disclosure;
[0019] Figure 7 is a block diagram of a text generation apparatus according to one embodiment of the present disclosure;
[0020] Figure 8 is a block diagram of a training apparatus of a generation model according to one embodiment of the present disclosure; and
[0021] Figure 9 is a block diagram of an electronic device for at least one of a text generation method and a training method of a generation model according to one embodiment of the present disclosure. DETAILED DESCRIPTION
[0022] Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, which include various details of the embodiments of the present disclosure to help understanding, and should be considered as merely exemplary. Thus, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, for the sake of brevity and clarity, descriptions of well-known functions and constructions are omitted from the following description.
[0023] AI-generated text often lacks the emotion, style, and personality of human writing, and appears unnatural and unsmooth. In order to obtain writing content closer to the style of human writing, users will use some AI detection tools to detect AI-generated text to identify whether it is AI-generated. If the AI detection tool identifies that the text is AI-generated, the user needs to manually modify it to obtain natural and smooth text content.
[0024] Embodiments of the present disclosure provide a text generation method that directly generates target text conforming to the style of human writing using a generation model trained in an adversarial manner, which can improve the naturalness and fluency of text generation.
[0025] In the technical solutions of the present disclosure, the collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solutions comply with relevant laws and regulations and do not violate public order and good customs.
[0026] In the technical solutions of the present disclosure, the authorization or consent of the user is obtained before the user's personal information is acquired or collected.
[0027] Figure 1is an exemplary system architecture schematic diagram according to an embodiment of the present disclosure to which a text generation method and a training method of a generation model can be applied. It should be noted that Figure 1 The system architecture shown is only an example of a system architecture to which an embodiment of the present disclosure can be applied, to help those skilled in the art understand the technical content of the present disclosure, but does not mean that the embodiment of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0028] As Figure 1 shown, the system architecture 100 according to the embodiment can include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 can include various connection types, such as wired and / or wireless communication links, etc.
[0029] A user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. The terminal devices 101, 102, 103 can be various electronic devices, including but not limited to smartphones, tablets, laptop computers, etc.
[0030] The server 102 can be a server that provides various services, such as a background management server that provides support for a website browsed by a user using a terminal device 101 (only as an example). The background management server can analyze and process received user requests, etc., and feed back the processing results (such as text content generated according to the user's input information, etc.) to the terminal device. The server 102 can be deployed with a predetermined model that can be a large language model (LLM).
[0031] At least one of the text generation method and the training method of the generation model provided by the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, at least one of the text generation apparatus and the training apparatus of the generation model provided by the embodiment of the present disclosure can generally be provided in the server 105.
[0032] Figure 2 is a flowchart of a text generation method according to an embodiment of the present disclosure.
[0033] As Figure 2 shown, the text generation method 200 includes operation S210 to operation S220.
[0034] At operation S210, according to input information, the subject and the field of the text to be generated are determined.
[0035] The input information can be a title, a text segment, etc. input by a user. A large model (e.g., a large language model) can analyze the input information to determine a topic, a specialty, a field, and a field level, etc. of the content to be generated by the user. The content to be generated by the user can be an academic paper, an article, a novel, etc.
[0036] In operation S220, in response to triggering of the first writing mode, a target text conforming to the first writing mode is generated according to the topic and the field using a generation model.
[0037] For example, the first writing mode can be a human writing mode. Whether the first writing mode is triggered can be determined according to whether the user is a user of a specified category (e.g., a VIP). Or a control of the first writing mode is provided on a writing page, and in response to a selection operation of the control of the first writing mode by the user, the first writing mode can be triggered.
[0038] In the first writing mode, the generation model can generate a target text conforming to the first writing mode. The generation model can be obtained by adversarial training with a discriminator model. The generation model can be a generative large model based on a Transformer architecture, and the discriminator model can be a classification model.
[0039] For example, the generation model is used to generate a text conforming to the first writing mode based on user input information, and the discriminator model is used to determine a writing mode of the text generated by the generation model, the writing mode including the first writing mode and a second writing mode. The first writing mode is, for example, a human writing mode, and the second writing mode is, for example, an AI generation mode. The discriminator model is used to determine whether the text generated by the generation model is an AI generated text or a human written text.
[0040] In one example, the discriminator model can be obtained by integrating an AI detection tool. The AI detection tool is used to detect a text to identify whether the text is AI generated. If yes, it is determined that the detected text is an AI generated text, otherwise, it is determined that the detected text is a human written text.
[0041] In the adversarial training process, after the generation model generates a text, the discriminator model determines a writing mode of the text, for example, whether the text is an AI generated text or a human written text. According to the determination result, the generation model adjusts parameters to optimize the generation capability, so that the generated text conforms to the target writing mode (e.g., human writing mode). Through multiple adversarial training, the capability of the generation model gradually improves, and finally reaches a state that the discriminator model cannot distinguish the writing mode of the generated text, for example, the accuracy of the determination of the writing mode of the generated text by the discriminator model is close to the level of random guess (e.g., 50%).
[0042] The generated model trained through the above adversarial training can be directly used to generate target text conforming to the first writing mode. For example, an outline can be generated according to the theme and field of the content required by the user, and then a body, that is, the target text, can be generated based on the outline.
[0043] Embodiments of the present disclosure can improve the naturalness and fluency of the target text by using the adversarially trained generated model to generate the target text conforming to the human writing mode.
[0044] Figure 3 is a flowchart of a text generation method according to another embodiment of the present disclosure.
[0045] As shown in Figure 3 The present embodiment includes operations S310-S390.
[0046] In operation S310, the theme and field of the text to be generated are determined according to the input information.
[0047] For example, the input information can be a user input title or text segment. The large model can perform feature extraction and semantic analysis on the input information, determine the keywords of the content to be generated by the user, and determine the theme, field, specialty, and field level of the content to be generated according to the keywords.
[0048] In operation S320, the original text is generated according to the theme and field.
[0049] The original text can be a text conforming to a second generation mode, for example, an AI generation mode. For example, the large model can directly generate the original text according to the theme and field, and the original text has the mechanical rhythm characteristics of AI generated text and lacks the emotion, style, and personality of human writing.
[0050] In operation S330, the original text is revised using an adversarially trained generated model to obtain the target text.
[0051] The generated model can be a generative large model obtained through adversarial training with a discriminative model. The generated model can revise the original text by adding perturbations to the word vectors and feature weights of the original text to obtain the target text.
[0052] For example, adding perturbations to the word vectors or feature weights of the original text can change the sentence type, syntax, sentence length, sentence expression method (such as written expression, spoken expression, etc.), and word frequency of certain words. By changing the sentence type, syntax, sentence expression method, and word frequency, the original text can be revised into the target text.
[0053] In operation S340, the AI generation detection is performed on the target text.
[0054] In operation S350, it is determined whether the AI generation detection is passed. If yes, operation S360 is performed, otherwise operation S390 is performed.
[0055] After obtaining the target text, the AI detection tool can be further used to detect whether the target text is AI generated. If the AI generation detection is passed, the quality evaluation of the target text is continued, otherwise the original text can be output.
[0056] In operation S360, the quality of the target text is evaluated.
[0057] In the case of passing the AI generation detection, the quality of the target text is further evaluated to ensure that the target text can meet the quality requirements and avoid the situation of deviating from the theme, logical confusion, and violation of facts caused by excessive rewriting.
[0058] According to an embodiment of the present disclosure, the quality evaluation method can include evaluating the quality of the target text based on at least one of a coverage of the target text to a knowledge node in a preset knowledge graph, a semantic consistency between the target text and the original text, and a grammatical correctness of the target text.
[0059] The preset knowledge graph can be a knowledge graph corresponding to the field parsed from the input information, and the knowledge graph can include a plurality of knowledge nodes, each of which can include professional terms, principles, application descriptions, and other knowledge contents of a knowledge point. The coverage of the target text to the knowledge node in the preset knowledge graph can determine the degree of professional field knowledge contained in the target text, and the degree of containing professional field knowledge can represent the professionalism of the target text.
[0060] The semantic consistency between the target text and the original text can represent whether the target text deviates from the theme and semantics of the original text. The grammatical correctness of the target text can represent whether the target text has logical errors, etc.
[0061] At least one of the coverage of the knowledge node, the semantic consistency, and the grammatical accuracy can be used as a quality evaluation index of the target text to evaluate the quality of the target text.
[0062] In operation S370, it is determined whether the quality evaluation is passed. If yes, operation S380 is performed, otherwise operation S390 is performed.
[0063] In operation S380, the target text is output.
[0064] In operation S390, the original text is output.
[0065] For example, a standard for passing the quality assessment can be set, such as coverage greater than 70%, semantic consistency 90%, grammatical accuracy 99%, etc. If the target text meets the above standard, it passes the quality assessment.
[0066] In one example, after the target text passes the quality assessment, the target text can be output. In the case where the target text does not pass the quality assessment, such as at least one of the coverage of the knowledge node, the semantic consistency, and the grammatical accuracy does not meet the corresponding standard, the original text can be output.
[0067] In another example, in the case where it is judged in operation S370 that the target text does not pass the quality assessment, operation S330 can be returned to rewrite the original text using the generation model, and the AI generation detection and the quality assessment are performed again on the rewritten text until both the AI generation detection and the quality assessment pass, and the rewritten target text is output. Or, until a preset number of rewritings is reached, if the AI detection or the quality assessment still does not pass, the original text can be output.
[0068] In another example, in the case where it is judged in operation S350 that the target text does not pass the AI detection, operation S330 can be returned to rewrite the original text using the generation model, and the AI generation detection and the quality assessment are performed again on the rewritten text until both the AI generation detection and the quality assessment pass, and the rewritten target text is output. Or, until a preset number of rewritings is reached, if the AI detection or the quality assessment still does not pass, the original text can be output.
[0069] According to embodiments of the present disclosure, by performing the AI generation detection and the quality assessment on the target text obtained after rewriting, the target text can be output in a case where the target text meets the first writing mode and the quality requirement, so that the user obtains a high-quality target text.
[0070] Figure 4 is a flowchart of a text generation method according to another embodiment of the present disclosure.
[0071] As shown in Figure 4 , the present embodiment includes operations S410-S460.
[0072] In operation S410, an original text is generated according to user input information.
[0073] In operation S420, it is judged whether the first generation mode is triggered. If yes, operations S430-S450 are performed, otherwise operation S460 is performed.
[0074] In operation S430, a rewriting service is called to perform rewriting, AI generation detection, and quality assessment.
[0075] In operation S440, the state of "in generation" is maintained.
[0076] In operation S450, the rewritten text is output.
[0077] In operation S460, the original text is output.
[0078] The rewriting service described above can include a service of rewriting the original text, a service of AI generation detection on the rewritten text, and a service of quality evaluation on the rewritten text. In the process of calling the rewriting service for rewriting, AI generation detection, and quality evaluation, the front end can maintain the display state of "in generation", so that the user does not perceive the rewriting process of the original text and the AI generation detection and quality evaluation process of the rewritten text, seamlessly connects the generation and rewriting processes, and does not interrupt the user experience.
[0079] The present disclosure also provides a training method of a generation model.
[0080] Figure 5 is a flowchart of a training method of a generation model according to an embodiment of the present disclosure.
[0081] As shown in Figure 5 The training method 500 of the generation model includes operation S510 to operation S550.
[0082] In operation S510, historical revision data is obtained, and the historical revision data includes historical original text, review opinion text, and modification result text.
[0083] The historical original text in the historical modification data can be a text generated based on a large model, the review opinion text can be a text containing artificial review opinions, and the modification result text can be a text modified based on the review opinions.
[0084] For example, the historical original text generated by the large model can be a paper, an article, a novel, etc., the artificial review opinions can be opinions of artificial review on the writing style of the historical original text, and can include opinions of marked modification methods such as adjusting the order of words and adjusting the expression. The modification result text is a text obtained by adjusting the historical original text based on the artificial review opinions, and the writing style of which is more consistent with the human writing style.
[0085] In operation S520, the historical original text is rewritten using the generation model to obtain a rewritten text.
[0086] The generation model can be a generative large model based on a Transformer architecture. For example, the historical original text and the modified text can be input into the generation model, so that the generation model learns the features of the original text and the modified text, and generates the rewritten text by adding perturbations to the features or weights of the original text.
[0087] In operation S530, writing mode detection is performed on the rewritten text to obtain a writing mode detection result. The writing mode can include a human writing mode and an AI generation mode.
[0088] In operation S540, a loss of the generation model is determined according to the rewritten text, the review opinion text, the modification result text, and the writing mode detection result.
[0089] In operation S550, the parameters of the generation model are adjusted according to the loss.
[0090] After the generation model generates the rewritten text, the generation model can be subjected to adversarial training with a discriminator model. The discriminator model is used to determine whether the text generated by the generation model is an AI-generated text or a human-written text. In one example, the discriminator model can be integrated by an AI detection tool.
[0091] The discriminator model can be used to detect whether the rewritten text generated by the generation model is AI-generated. If so, it is determined that the writing mode of the rewritten text is AI-generated, otherwise it is determined that the writing mode of the rewritten text is human-written.
[0092] According to the discrimination result of the discriminator model, the loss of the generation model (which can be referred to as a discrimination loss) can be determined. For example, the rewritten text generated by the generation model is taken as a human writing mode as a target, and the discrimination loss is calculated according to the difference between the detection result (for example, the probability of the rewritten text being a human writing mode determined by the discriminator model) and the target (for example, 1). According to the discrimination loss, the parameters of the generation model are adjusted to improve the ability of the generation model to generate human writing mode text.
[0093] Through multiple adversarial training, the ability of the generation model gradually improves, and eventually reaches a state where the discriminator model cannot distinguish the writing mode of the generated text, for example, the accuracy of the discriminator model in discriminating the writing mode of the generated text is close to the level of random guessing (for example, 50%).
[0094] In addition to the discrimination loss used for adversarial training, a rewriting loss can also be determined according to the difference between the rewritten text and the modified text in the historical modification data. A quality loss can also be determined according to whether the rewritten text conflicts with the review opinion text, whether it is logically consistent, etc., to constrain the quality of the rewritten text.
[0095] According to the above-mentioned discrimination loss, rewriting loss, and quality loss, the overall loss of the generation model can be determined, and the parameters of the generation model can be adjusted according to the overall loss.
[0096] According to an embodiment of the present disclosure, the generation model obtained through multiple rounds of training has the ability to generate text conforming to the human writing mode, and using the trained generation model to generate text can improve the naturalness and fluency of the generated text.
[0097] Figure 6 FIG. 6 is a schematic diagram of determining the loss of a generation model according to an embodiment of the present disclosure.
[0098] As shown in FIG. 6, the overall loss 600 of the generation model includes a discrimination loss 610, a rewriting loss 620, and a quality loss 630. Figure 6 The discrimination loss 610 can be determined according to the writing mode 601 of the rewritten text generated by the generation model. For example, using an AI detection tool to detect whether the rewritten text is AI-generated, if yes, determining that the writing mode of the rewritten text is AI-generated mode, otherwise, human writing mode. The loss function of the discrimination loss can be designed to target generating text in human writing mode. According to the probability of the rewritten text being AI-generated mode detected by the AI detection tool, the discrimination loss can be determined.
[0099] The rewriting loss 620 can be determined according to the difference 602 between the rewritten text and the modified text. The modified text is the text modified according to the review comments in the historical revision data, and the review comments are the opinions of the human review on the writing mode of the historical original text. The modified text is more consistent with the human writing mode. Therefore, the rewriting loss function can be designed to target the consistency between the rewritten text and the modified text. According to the difference between the rewritten text and the modified text, the rewriting loss can be determined.
[0100] The quality loss 630 can be determined according to at least one of the coverage 603 of the rewritten text to the knowledge nodes in the preset knowledge graph, the semantic consistency 604 between the rewritten text and the modified text, the grammatical correctness 605 of the rewritten text, and the logical consistency 606 between the rewritten text and the review comment text.
[0101]
[0102] The preset knowledge graph can be a knowledge graph corresponding to the field of the historical original text. The coverage 603 of the knowledge nodes in the knowledge graph by the rewritten text can represent the professionalism of the rewritten text. The semantic consistency 604 between the rewritten text and the modified text can represent whether the rewritten text deviates from the topic of the historical original text. The grammatical correctness 605 of the rewritten text can represent whether the rewritten text has problems such as grammatical errors and logical confusion. The logical consistency 606 between the rewritten text and the review opinion text can represent whether the rewritten text conflicts with the review opinion in the review opinion text.
[0103] The quality loss 630 can be determined according to the coverage 603 of the knowledge nodes, the semantic consistency 604 between the rewritten text and the modified text, the grammatical correctness 605 of the rewritten text, and the logical consistency 606 between the rewritten text and the review opinion text.
[0104] According to an embodiment of the present disclosure, in the process of adversarial training of the generation model, in addition to the discrimination loss and the rewriting loss, a quality loss is introduced to constrain the quality of the rewritten text, which can avoid the problem of poor quality caused by excessive rewriting, so that the quality of the rewritten text can meet the user requirements and improve the user experience.
[0105] According to an embodiment of the present disclosure, the present disclosure also provides a text generation apparatus and a training apparatus of a generation model.
[0106] Figure 7 FIG. 7 is a block diagram of a text generation apparatus according to an embodiment of the present disclosure.
[0107] As shown in FIG. 7, the text generation apparatus 700 includes a determination module 710 and a generation module 720. Figure 7
[0108] The determination module 710 is configured to determine a topic and a field of a text to be generated according to input information.
[0109] The generation module 720 is configured to generate a target text in accordance with the first writing mode by using a generation model according to the topic and the field in response to triggering of the first writing mode, wherein the generation model is obtained by adversarial training with a discrimination model, and the discrimination model is configured to discriminate a writing mode of a text generated by the generation model, and the writing mode is one of the first writing mode and the second writing mode.
[0110] The generation module 720 includes an original text generation sub-module and a target text generation sub-module.
[0111] The original text generation sub-module is configured to generate an original text in accordance with the second writing mode according to the topic and the field.
[0112] The target text generation submodule is configured to rewrite the original text using the generation model to obtain the target text.
[0113] The target text generation submodule is configured to rewrite the original text using the generation model by adding perturbations to at least one of the text features and the feature weights of the original text to obtain the target text.
[0114] According to an embodiment of the present disclosure, the text generation apparatus 700 further includes a detection module, a quality evaluation module, and a first output module.
[0115] The detection module is configured to perform writing mode detection on the target text to obtain a writing mode detection result.
[0116] The quality evaluation module is configured to perform quality evaluation on the target text in response to the writing mode detection result being the first writing mode to obtain a quality evaluation result.
[0117] The first output module is configured to output the target text in response to the quality evaluation result meeting a preset condition.
[0118] The quality evaluation module is configured to perform quality evaluation on the target text based on at least one of coverage of knowledge nodes in a preset knowledge graph by the target text, semantic consistency between the target text and the original text, and grammatical correctness of the target text.
[0119] The text generation apparatus 700 further includes a second output module.
[0120] The second output module is configured to output the original text in response to the quality evaluation result not meeting the preset condition.
[0121] Figure 8 is a block diagram of a training apparatus of a generation model according to an embodiment of the present disclosure.
[0122] As shown in Figure 8 , the training apparatus 800 of the generation model includes an acquisition module 810, a rewriting module 820, a detection module 830, a loss determination module 840, and an adjustment module 850.
[0123] The acquisition module 810 is configured to acquire historical revision data, wherein the historical revision data includes historical original text, review opinion text, and modification result text.
[0124] The rewriting module 820 is configured to rewrite the historical original text using the generation model to obtain rewritten text.
[0125] The detection module 830 is configured to perform writing mode detection on the rewritten text to obtain a writing mode detection result.
[0126] The loss determination module 840 is configured to determine a loss of the generation model according to the rewritten text, the review text, the modified result text, and the writing mode detection result.
[0127] The adjustment module 850 is configured to adjust parameters of the generation model according to the loss.
[0128] The loss determination module 840 includes a quality loss determination sub-module, a discrimination loss determination sub-module, and a rewriting loss determination sub-module.
[0129] The quality loss determination sub-module is configured to determine a quality loss according to the rewritten text, the review text, and the modified result text.
[0130] The discrimination loss determination sub-module is configured to determine a discrimination loss according to the writing mode detection result.
[0131] The rewriting loss determination sub-module is configured to determine a rewriting loss according to a difference between the rewritten text and the modified result text.
[0132] The quality loss determination sub-module includes a quality evaluation unit and a quality loss determination unit.
[0133] The quality evaluation unit is configured to determine a quality evaluation result of the rewritten text according to at least one of coverage of the rewritten text for a knowledge node in a preset knowledge graph, semantic consistency between the rewritten text and the modified result text, grammatical correctness of the rewritten text, and logical consistency between the rewritten text and the review text.
[0134] The quality loss determination unit is configured to determine a quality loss according to the quality evaluation result.
[0135] The rewriting module 820 is configured to use the generation model to rewrite a historical original text by adding a disturbance to at least one of a text feature and a feature weight of the historical original text, to obtain the rewritten text.
[0136] According to embodiments of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium, and a computer program product.
[0137] Figure 9A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0138] like Figure 9 As shown, device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. RAM 903 may also store various programs and data required for the operation of device 900. Computing unit 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to bus 904.
[0139] Various components in the device 900 are connected to the I / O interface 905, including an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a magnetic disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0140] The computing unit 901 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 901 performs various methods and processes described above, such as at least one of the text generation method and the training method of the generation model. For example, in some embodiments, at least one of the text generation method and the training method of the generation model can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded onto the RAM 903 and executed by the computing unit 901, one or more steps of at least one of the text generation method and the training method of the generation model described above can be performed. Alternatively, in other embodiments, the computing unit 901 can be configured to perform at least one of the text generation method and the training method of the generation model by any other appropriate means, such as by means of firmware.
[0141] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0142] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package, or entirely on a remote machine or server.
[0143] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0144] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0145] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0146] The computer system can include clients and servers. This relationship can be
[0147] It should be understood that the procedures shown above can be re-ordered, added to, or removed from, while still being within the scope of the present disclosure. For example, the steps recited in the present disclosure can be performed in parallel, in series, or in a different order, as long as the desired results of the technology disclosed in the present disclosure are achieved, and are not limited herein.
[0148] The specific embodiments described above are not intended to be limiting, and persons skilled in the art will appreciate that various modifications, combinations, sub-combinations and alternatives can be made to the specific embodiments without departing from the spirit and principles of the disclosure. Accordingly, the disclosure is not limited to the specific embodiments described above.
Claims
1. A text generation method, comprising: Determine the subject and field of the text to be generated based on the input information; as well as In response to the triggering of the first writing mode, a generative model is used to generate a target text that conforms to the first writing mode according to the subject and field. The generative model is obtained by adversarial training with a discriminative model, and the discriminative model is used to discriminate the writing mode of the text generated by the generative model, where the writing mode is one of a first writing mode and a second writing mode.
2. The method according to claim 1, wherein In response to the triggering of the first writing mode, generating a target text conforming to the first writing mode according to the subject and domain using a generative model includes: generating an original text conforming to the second writing mode according to the subject and field; and The original text is rewritten using the generative model to obtain the target text.
3. The method according to claim 2, wherein: The using the generative model to rewrite the original text to obtain the target text includes: The target text is obtained by rewriting the original text by using the generative model and adding disturbance to at least one of the text features and feature weights of the original text.
4. The method according to claim 2, further comprising: Performing writing mode detection on the target text to obtain a writing mode detection result; In response to the writing mode detection result being the first writing mode, performing a quality assessment on the target text to obtain a quality assessment result; as well as In response to the quality assessment result meeting a preset condition, the target text is output.
5. The method according to claim 4, wherein The quality assessment of the target text includes: The target text is quality evaluated based on at least one of the coverage of the target text with respect to knowledge nodes in a preset knowledge graph, the semantic consistency between the target text and the original text, and the grammatical correctness of the target text.
6. The method according to claim 4, further comprising: In response to the quality assessment result not meeting the preset condition, outputting the original text.
7. A method for training a generative model, comprising: Obtaining historical revision data, wherein the historical revision data includes historical original text, reviewer comment text, and modified result text; Rewriting the historical original text using a generative model to obtain a rewritten text; Performing a writing mode detection on the rewritten text to obtain a writing mode detection result; Determining the loss of the generative model based on the rewritten text, the review text, the revised text, and the writing mode detection result; and Parameters of the generative model are adjusted based on the loss.
8. The method according to claim 7, wherein: Determining the loss of the generative model based on the rewritten text, the review opinion text, the revised text, and the writing mode detection result includes: Determine the quality loss based on the rewritten text, the reviewer's comments, and the revised text; determining a discrimination loss based on the writing pattern detection result; A rewriting loss is determined according to the difference between the rewritten text and the modified result text.
9. The method according to claim 8, wherein Determining the quality loss based on the rewritten text, the reviewer's opinion text, and the revised text includes: Determining a quality assessment result of the rewritten text based on at least one of coverage of the rewritten text for knowledge nodes in a preset knowledge graph, semantic consistency between the rewritten text and the modified result text, grammatical correctness of the rewritten text, and logical consistency between the rewritten text and the review opinion text; and The mass loss is determined according to the quality assessment result.
10. The method according to claim 7, wherein: The use of the generative model to rewrite the historical original text to obtain the rewritten text includes: The generative model is used to rewrite the historical original text by adding disturbance to at least one of the text features and feature weights of the historical original text to obtain the rewritten text.
11. A text generation device, comprising: A determination module, used to determine the subject and field of the text to be generated based on the input information; as well as A generation module is configured to generate a target text that conforms to the first writing mode based on the subject and domain using a generation model in response to a trigger of the first writing mode. The generative model is obtained by adversarial training with a discriminative model, and the discriminative model is used to discriminate the writing mode of the text generated by the generative model, where the writing mode is one of a first writing mode and a second writing mode.
12. A training device for generating a model, comprising: An acquisition module is used to acquire historical revision data, wherein the historical revision data includes historical original text, review opinion text and modification result text; A rewriting module, configured to rewrite the original historical text using a generative model to obtain a rewritten text; a detection module, configured to perform writing mode detection on the rewritten text to obtain a writing mode detection result; a loss determination module, configured to determine the loss of the generation model based on the rewritten text, the review text, the revision text, and the writing mode detection result; and An adjustment module is used to adjust the parameters of the generation model according to the loss.
13. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 10. 15 . A computer program product, comprising a computer program, wherein the computer program is stored on at least one of a readable storage medium and an electronic device, and when the computer program is executed by a processor, implements the method according to claim 1 .
Citation Information
Patent Citations
Method for constructing double-discriminator dialogue generation model based on generative adversarial network
CN111160512A
Model training and text generation method in specific field
CN117252161A
End-to-end unsupervised antagonistic text rewriting method and device
CN117933268A
Method of generating text, method of training model, electronic device, and medium
US20230084438A1