Article generation method and device, electronic equipment and storage medium
By generating text in rounds and using preset large models, the problem that article generation in the prior art does not meet expectations is solved, and higher accuracy and format consistency are achieved.
Patent Information
- Application Number
- CN202311779463.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-21
- Publication Date
- 2025-06-24
AI Technical Summary
When generating articles, existing large models find it difficult to generate articles in the specified format and content, resulting in the generated articles being inconsistent with expectations and low accuracy.
Text generation is generated in rounds, and the input of each round includes the output of the previous round. The preset text generation model is used to generate and combine text content in sequence to ensure the accuracy of the target text content.
Improves the accuracy of article generation and ensures that the generated articles meet the specified format and content requirements.
Smart Images

Figure CN120196941A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text processing, and in particular, to an article generation method, device, electronic device, and storage medium. Background Art
[0002] Currently, large models are booming. Large models can understand text and perform corresponding reasoning in fields such as text generation, and have excellent general generation capabilities. People can use corresponding instructions to let large models generate different types of articles. However, it is difficult for large models to generate articles in a specified format and in combination with given content. The actually generated articles do not match the expectations, and the accuracy is relatively low. Therefore, how to provide an article generation method that can ensure a high accuracy when generating articles has become an urgent problem to be solved. Summary of the Invention
[0003] An embodiment of the present invention provides an article generation method, aiming to solve the problem that the actually generated articles in the existing article generation do not match the expectations and the accuracy is relatively low. By using the text information to be generated in the current round, the prompt text in the current round is determined, and the prompt text is input into a preset text generation large model for text generation processing. The text content is generated in sequence according to the rounds, and the text content generated in different rounds is combined in sequence according to the round order, so as to obtain the target text content. Since the text is generated in rounds, and the input of each round can include the output of the previous round, the accuracy of the target text content can be guaranteed.
[0004] In a first aspect, an embodiment of the present invention provides an article generation method, and the method includes the following steps:
[0005] Obtain the text information to be generated in the current round, where the text information to be generated in the current round includes the text content and the text structure in the current round;
[0006] Based on the text content and the text structure, determine the first prompt text in the current round;
[0007] Input the first prompt text in the current round into a preset text generation large model for text generation processing to obtain the text generation content in the current round, and the text generation content in the current round corresponds to the text structure in the current round;
[0008] When the text generation processing of all rounds is completed, obtain the target text content.
[0009] Optionally, the current round includes the first round and non-first rounds. The obtaining the text information to be generated in the current round, where the text information to be generated in the current round includes the text content and the text structure in the current round, includes:
[0010] When the current round is the first round, the text content of the current round includes the text input content input by the user;
[0011] When the current round is not the first round, the text content of the current round includes the text input content input by the user and the text generation content of the historical round.
[0012] Optionally, before obtaining the text information to be generated, the method further includes:
[0013] Obtain a preset large model and sample data, where the sample data includes text content of different types, and the text content of different types includes text content corresponding to different text structures;
[0014] Perform data preprocessing on the sample data to obtain a training data set;
[0015] Perform text generation training on the preset large model based on the training data set to obtain the preset text generation large model.
[0016] Optionally, the performing data preprocessing on the sample data to obtain a training data set includes:
[0017] Standardize the text content to obtain text content with a unified text structure;
[0018] Determine different types of generation tasks based on the text content with the unified text structure;
[0019] Determine the training data set based on the different types of generation tasks.
[0020] Optionally, the different types of text content include text expansion content, text generation content, and error correction text content. The determining different types of generation tasks based on the text content with the unified text structure includes:
[0021] Determine an article generation task based on the generated text content with a unified text structure;
[0022] Determine an expansion task based on the expanded text content with a unified text structure;
[0023] Determine an error correction task based on the error correction text content with a unified text structure;
[0024] Determine the different types of generation tasks based on the article generation task, the expansion task, and the error correction task.
[0025] Optionally, the determining the training data set based on the different types of generation tasks includes:
[0026] Construct different types of second prompt texts based on the different types of generation tasks;
[0027] Construct the training data set based on the different types of second prompt texts, where the second prompt text includes a prompt text and a label text corresponding to the prompt text.
[0028] Optionally, the training the preset large model for text generation based on the training data set to obtain the preset text generation large model includes:
[0029] Input the prompt text into the preset large model for text generation processing to obtain a text generation result;
[0030] Calculate a loss value between the label text and the text generation result through a preset loss function;
[0031] Taking minimizing the loss value as an optimization objective, adjust the parameters of the preset large model, iterate the parameter adjustment process until the loss value converges at the minimum, stop training, and obtain the preset text generation large model.
[0032] In a second aspect, an embodiment of the present invention further provides an article generation device, where the article generation device includes:
[0033] A first acquisition module, configured to acquire the text information to be generated in the current round, where the text information to be generated in the current round includes the text content in the current round and the text structure in the current round;
[0034] A first determination module, configured to determine the first prompt text in the current round based on the text content and the text structure;
[0035] A first generation module, configured to input the first prompt text in the current round into the preset text generation large model for text generation processing to obtain the text generation content in the current round, where the text generation content in the current round corresponds to the text structure in the current round;
[0036] A second generation module, configured to obtain the target text content when the text generation processing of all rounds is completed.
[0037] In a third aspect, an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the computer program, the steps in the article generation method provided by the embodiment of the present invention are implemented.
[0038] Fourthly, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the article generation method provided by the embodiment of the invention are implemented.
[0039] In the embodiment of the present invention, the text information to be generated in the current round is obtained. The text information to be generated includes the text content and the text structure in the current round. Based on the text content and the text structure, the first prompt text in the current round is determined. The first prompt text in the current round is input into a preset text generation large model for text generation processing to obtain the text generation content in the current round. The text generation content in the current round corresponds to the text structure in the current round. When the text generation processing for all rounds is completed, the target text content is obtained. By using the text information to be generated in the current round, the prompt text in the current round is determined, and the prompt text is input into a preset text generation large model for text generation processing. The text content is generated in sequence according to the rounds, and the text content generated in different rounds is combined in sequence according to the round order, so as to obtain the target text content. Since the text generation is carried out in rounds, and the input of each round can include the output of the previous round, the accuracy of the target text content can be guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0041] Figure 1 is a flowchart of an article generation method provided by an embodiment of the present invention;
[0042] Figure 2 is a flowchart of an article assisted writing provided by an embodiment of the present invention;
[0043] Figure 3 is a flowchart of a model training provided by an embodiment of the present invention;
[0044] Figure 4 is a schematic structural diagram of an article generation device provided by an embodiment of the present invention;
[0045] Figure 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0046] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without making creative efforts belong to the scope of protection of the present invention.
[0047] As Figure 1 shown, Figure 1 is a flowchart of a method for generating an article provided by an embodiment of the present invention, including:
[0048] 101. Obtain the text information to be generated in the current round.
[0049] In the embodiments of the present invention, the above text information to be generated includes the text content and text structure of the current round. The above text structure can be understood as the organization and layout of the article, that is, which parts the article consists of and the relationships between these parts. The above text content refers to the specific text content in the article, which can include the viewpoints, facts, data, examples, etc. expressed by the article author (i.e., a preset large text generation model). For example, the above text structure can include structures such as title, keywords, abstract, outline, and full text. The above text content can be the specific text content of the title, the specific text content of the keywords, the specific text content of the abstract, the specific text content of the outline, and the specific text content of the full text, etc.
[0050] For example, if the above text information to be generated is "Title: Large Model Landing Training.\nKeywords:", then the above text structure is "Title" and "Keywords", and the text content corresponding to the above "Title" is "Large Model Landing Training". If the above text information to be generated is "Title: Large Model Landing Training.\nKeywords: Large Model; Training; Assistant.\nAbstract:", then the above text structure is "Title", "Keywords", and "Abstract", and the text content is "Large Model Landing Training" corresponding to "Title" and "Large Model; Training; Assistant" corresponding to "Keywords". It can be seen that each text structure corresponds to a text content, and each text information to be generated includes at least one text structure corresponding to a text content and one text structure not corresponding to a text content.
[0051] It should be noted that the article generation method provided by the embodiments of the present invention performs text generation processing sequentially by rounds, and only the text content required for one text structure is generated in each round. For example, if the text structure in the current round is title, keywords, and abstract, and the text content in the current round is the specific text content of the title and the specific text content of the keywords, then the specific text content of the abstract needs to be generated in the current round based on the specific text content of the title and the specific text content of the keywords.
[0052] If the text structure of the current round is title, keywords, abstract, and outline, and the text content of the current round is the specific text content of the title, the specific text content of the keywords, and the specific text content of the abstract, then the specific text content of the outline needs to be generated according to the specific text content of the title, the specific text content of the keywords, and the specific text content of the abstract in the current round.
[0053] 102. Determine the first prompt text of the current round based on the text content and text structure.
[0054] In the embodiments of the present invention, different text structures correspond to different prompt instruction texts, and the above prompt instruction texts can be used to prompt the text generation large model to complete corresponding tasks according to the corresponding instructions.
[0055] For example, if the text structure of the current round is title, keywords, and abstract, and the text content of the current round is the specific text content of the title and the specific text content of the keywords, then the corresponding prompt instruction text "Please expand the abstract according to the title and keywords" can be set.
[0056] If the text structure of the current round is title, keywords, abstract, and outline, and the text content of the current round is the specific text content of the title, the specific text content of the keywords, and the specific text content of the abstract, then the corresponding prompt instruction text "Please expand the outline according to the title, keywords, and abstract" can be set.
[0057] After constructing the above corresponding prompt instruction text according to the above text structure and text content, the first prompt text can be constructed according to the above prompt instruction text, text structure, and text content.
[0058] For example, if the text structure of the current round is title, keywords, and abstract, the above text content is "Large model implementation training" corresponding to the title and "Large model; training; assistant" corresponding to the keywords, and the above prompt instruction text is "Please expand the abstract according to the title and keywords", then the above first prompt text can be {"instruction": "Please expand the abstract according to the title and keywords.", "input": "Title: Large model implementation training.\nKeywords: Large model; training; assistant."}.
[0059] If the text structure of the current round is title, keywords, abstract, and outline, and the above text content is the "Large Model Implementation Training" corresponding to the title, the "Large Model; Training; Assistant" corresponding to the keywords, and the "Large Model Implementation Training refers to providing specialized training for the deployment and implementation of large prediction models (usually models with higher complexity and more parameters). The purpose of this training is to help enterprises and institutions effectively use large models for data analysis and prediction, thereby achieving business optimization and improvement." corresponding to the abstract, then the above first prompt text can be {"Instruction": "Please expand the title, keywords, and abstract into an outline.", "Input": "Title: Large Model Implementation Training.\nKeywords: Large Model; Training; Assistant.\nAbstract: Large Model Implementation Training refers to providing specialized training for the deployment and implementation of large prediction models (usually models with higher complexity and more parameters). The purpose of this training is to help enterprises and institutions effectively use large models for data analysis and prediction, thereby achieving business optimization and improvement."}.
[0060] 103. Input the first prompt text of the current round into the preset text generation large model for text generation processing to obtain the text generation content of the current round.
[0061] In the embodiment of the present invention, the text generation content of the current round corresponds to the text structure of the current round. The current round includes at least one text structure corresponding to text content and one text structure not corresponding to text content. The above preset text generation large model can be understood as a large deep learning model for text tasks, usually having a large number of parameters and computational amounts, and can be used to process text data for text generation processing. The above preset text generation large model can be obtained by training any large model capable of completing text processing tasks in the vertical field (i.e., text generation ability). The above large model capable of completing text processing tasks can be ChatGPT large model, Wenxin Yiyan large model, Yunque large model, Baichuan large model, etc.
[0062] After inputting the first prompt text of the current round into the above preset text generation large model, the above text generation large model will, based on the above text structure and text content, perform corresponding text generation processing according to the prompt of the above prompt instruction text to obtain the text generation content of the current round.
[0063] 104. When the text generation processing of all rounds is completed, the target text content is obtained.
[0064] In the embodiment of the present invention, the first prompt texts of different rounds are different, and the prompt instruction texts corresponding to the first prompt texts of different rounds are also different.
[0065] It should be noted that, generally, the structure of a complete article may include a title, keywords, an abstract, an outline, and the full text. Different rounds can correspond to the above article structure. That is, in the first round, specific text content of keywords can be generated based on the specific text content of the title. In the second round, specific text content of the abstract can be generated based on the specific text content of the title and the specific text content of the keywords. In the third round, specific text content of the outline can be generated based on the specific text content of the title, the specific text content of the keywords, and the specific text content of the abstract. In the fourth round, specific text content of the full text can be generated based on the specific text content of the title, the specific text content of the keywords, the specific text content of the abstract, and the specific text content of the outline.
[0066] It can be seen that, except for the above first round, the input of each round includes the specific text content input in the first round and the specific text content output in the previous round. After completing the text generation processing of all rounds, according to the specific text content input and output in the last round, and in accordance with the text structure of the above specific text content, the above specific text content is combined to obtain the above target text content.
[0067] In the embodiment of the present invention, the text information to be generated in the current round is obtained. The text information to be generated includes the text content in the current round and the text structure in the current round. Based on the text content and the text structure, the first prompt text in the current round is determined. The first prompt text in the current round is input into the preset text generation large model for text generation processing to obtain the text generation content in the current round. The text generation content in the current round corresponds to the text structure in the current round. When the text generation processing of all rounds is completed, the target text content is obtained. By using the text information to be generated in the current round, the prompt text in the current round is determined, and the prompt text is input into the preset text generation large model for text generation processing. The text content is generated in sequence according to the rounds, and the text content generated in different rounds is combined in sequence according to the round order, so as to obtain the target text content. Since the text is generated in rounds and the input of each round can include the output of the previous round, the accuracy of the target text content can be guaranteed.
[0068] It can be understood that, in the specific implementation of the present application, relevant data such as the text information to be generated is involved. When the embodiments in the present application are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use, and processing of relevant data and the use of the large model need to comply with the relevant laws, regulations, and standards of relevant countries and regions.
[0069] It should be noted that the article generation method provided in the embodiment of the present invention can be applied to devices such as computers and servers that can perform article generation.
[0070] Optionally, in the current round including the first round and non-first rounds, in the step of obtaining the text information to be generated in the current round, where the text information to be generated includes the text content and the text structure of the current round, when the current round is the first round, the text content of the current round includes the text input content input by the user; when the current round is a non-first round, the text content of the current round includes the text input content input by the user and the text generation content of the historical rounds.
[0071] In the embodiments of the present invention, the above-mentioned text input content input by the user can be the basis for text generation processing. Based on the above-mentioned text input content, the preset text generation large model performs text generation processing in sequence according to the rounds to obtain the target text content. The above-mentioned text generation content of the historical rounds can be described according to the above-mentioned rounds. If the current round is the second round, the text content obtained in the first round is the text generation content of the historical rounds. If the current round is the third round, the text content obtained in the first round and the text content obtained in the second round are the text generation content of the historical rounds.
[0072] Specifically, the above-mentioned rounds can be illustrated by a flowchart for assisting in writing an article as Figure 2 shown. Figure 2 In the first round, the input text structure is the title and keywords, and the input text content is the specific text content of the title and the specific text content of the keywords, that is, the above-mentioned text input content is the specific text content of the title and the specific text content of the keywords. Specifically, it can be understood that the user inputs the above-mentioned text structure title and the corresponding specific text content of the title, the text structure "keywords" and the corresponding specific text content of the "keywords" into the large model (i.e., the above-mentioned preset text generation large model) for text generation processing to obtain the text structure "abstract" and the corresponding specific text content required for the article.
[0073] In the second round, the above-mentioned text structure "title" and the corresponding specific text content of the "title", the text structure "keywords" and the corresponding specific text content of the "keywords", and the text structure "abstract" and the corresponding specific text content generated in the first round are input into the large model (i.e., the above-mentioned preset text generation large model) for text generation processing to obtain the text structure "outline" and the corresponding specific text content required for the article. It can be seen that in the second round, the text structure "abstract" and the corresponding specific text content are the text generation content of the historical rounds.
[0074] The third round is to input the text structure "title" and the corresponding specific text content, the text structure "keywords" and the corresponding specific text content, the text structure "abstract" generated in the first round and the corresponding specific text content, and the text structure "outline" generated in the second round and the corresponding specific text content into the large model (i.e., the above-mentioned preset text generation large model) for text generation processing to obtain the text structure "full text" required for the article and the corresponding specific text content. It can be seen that in the third round, the text structure "abstract" and the corresponding specific text content, and the text structure "outline" and the corresponding specific text content are the text generation contents of the historical rounds.
[0075] The fourth round is to select text fragments from the specific text content corresponding to the "full text" generated in the third round for processing such as expansion, rewriting, polishing, and error correction.
[0076] It should be noted that if only based on the title, gradually generating the "full text" of the last round according to the rounds may deviate from the expected output. Therefore, the specific text content corresponding to the "full text" of the last round can be gradually generated according to the rounds based on the title and keywords. This can not only make the output article conform to the given title and keywords but also generate the full text according to the format of the outline, and finally obtain an article that meets the specified content, format, and has strong readability.
[0077] Optionally, before the step of obtaining the text information to be generated, a preset large model and sample data can also be obtained; data preprocessing is performed based on the sample data to obtain a training data set; the preset large model is trained for text generation based on the training data set to obtain the preset text generation large model.
[0078] In the embodiment of the present invention, the above-mentioned preset large model can be the large model capable of completing text processing tasks, that is, the above-mentioned ChatGPT large model, Wenxin Yiyan large model, Yunque large model, Baichuan large model, etc.
[0079] The above-mentioned sample data includes different types of text content, and the different types of text content include the text content corresponding to different text structures. The above-mentioned different types of text content can include articles with abstracts, keywords, and outlines. Generally, articles such as journals and papers are composed of a title, an abstract, keywords, and the main text. That is, it includes the text structure "title" and the corresponding specific text content, the text structure "abstract" and the corresponding specific text content, the text structure "keywords" and the corresponding specific text content, and the text structure "main text" and the corresponding specific text content.
[0080] The above-mentioned different types of text content may also include articles without abstracts, keywords, and outlines. For example, articles such as speeches and press releases do not have abstracts, keywords, and outlines. That is, they only include the text structures of "title" and the corresponding specific text content, the text structure of "body" and the corresponding specific text content.
[0081] The above-mentioned different types of text content may also include text content that needs to be expanded, rewritten, and polished. The above-mentioned text content that needs to be expanded, rewritten, and polished may be text with relatively brief content. For example, it may be news reports, announcements, statements, etc. These texts may only provide a brief overview of events or information and need to be further supplemented with details, background, and reasons to enable readers to understand the situation more comprehensively. Or it may also be contracts, legal documents, technical documents, etc. The language of these texts is often relatively professional and concise and needs to be appropriately expanded and polished to make it more understandable and easy to comprehend. Or it may also be advertising copy, brochures, product descriptions, etc. These texts need to highlight their key points or emphasize specific information to attract readers' attention and convey specific information.
[0082] The above-mentioned different types of text content may also include text content that needs to be corrected for text errors. For example, it may be text content with spelling mistakes, grammar mistakes, or semantic mistakes.
[0083] The above-mentioned different types of text content can obtain open-source data through the Internet or can also be generated by humans or the above-mentioned pre-set large model. The above-mentioned preprocessing may include standardization processing. The above-mentioned standardization processing may be to unify the text content with different text structures into text content with the same text structure.
[0084] After obtaining the above-mentioned different types of text content, the above-mentioned different types of text content can be subjected to standardization processing to obtain text content with a unified text structure. Based on the text content with the above-mentioned unified text structure, the above-mentioned training data set is constructed, and the above-mentioned pre-set large model is trained for text generation according to the above-mentioned training data set to obtain the above-mentioned pre-set text generation large model.
[0085] Optionally, in the step of performing data preprocessing on sample data to obtain a training data set, the text content can also be subjected to standardization processing to obtain text content with a unified text structure; based on the text content with the unified text structure, different types of generation tasks are determined; based on different types of generation tasks, a training data set is determined.
[0086] In an embodiment of the present invention, the above standardization process may be to standardize the text structure. Generally, the standardized text structure should be "title", "keywords", "abstract", "outline", and "full text". If the above text content is an article including a title, abstract, keywords, outline, and full text, it already has the above standardized text structure, namely "title", "keywords", "abstract", "outline", and "full text", and no standardization process is required. If the above text content does not include the text structure "outline" and the corresponding specific content, the outline can be formed by extracting the titles in the full text. If the above text content is an article including only a title and a full text, the abstract and keywords can be generated using the above preset large model, and the outline can be obtained by summarizing the article and can be modified manually.
[0087] After obtaining the text content with the above unified text structure, different types of generation tasks can be determined based on the text content with the above unified text structure. The above different types of generation tasks can be generation tasks, error correction tasks, and expansion tasks. According to different types of generation tasks, different types of second prompt texts are constructed, and based on different types of second prompt texts, the above training data set is constructed.
[0088] Optionally, in the step of determining different types of generation tasks based on the text content with the unified text structure, an article generation task can also be determined based on the generated text content with the unified text structure; an expansion task can be determined based on the expanded text content with the unified text structure; an error correction task can be determined based on the error correction text content with the unified text structure; and different types of generation tasks can be determined based on the article generation task, expansion task, and error correction task.
[0089] In an embodiment of the present invention, the above different types of text content include expanded text content, generated text content, and error correction text content. The above expanded text content may be the text content that needs to be expanded, rewritten, or polished. The above error correction text content may be the text content that needs to be corrected. The above generated text content may be the content that needs to be generated.
[0090] When the above text content is expanded text content, it means that expansion processing, rewriting processing, or polishing processing needs to be performed, and the corresponding task is an expansion task. When the text content is error correction text content, it means that error correction processing needs to be performed, and the corresponding task is an error correction task. When the text content is generated text content, it means that article generation needs to be performed, and the corresponding task is an article generation task. It can be understood that the above tasks are tasks for processing text. It can be understood that the above expansion task may include expansion processing, rewriting processing, and polishing processing.
[0091] Optionally, in the step of determining the training data set based on different types of generation tasks, different types of second prompt texts can also be constructed based on different types of generation tasks; and the training data set can be constructed based on different types of second prompt texts.
[0092] In an embodiment of the present invention, the above-mentioned second prompt text includes a prompt text and a label text corresponding to the prompt text. The above-mentioned prompt text may include a prompt instruction text, a text structure, and text content. Specifically, different types of prompt instruction texts can be constructed according to different types of generation tasks and text structures, and different types of the above-mentioned second prompt texts can be constructed according to the text structures, text contents corresponding to different types of generation tasks, and the above-mentioned prompt instruction texts. Classify and add different types of the above-mentioned second prompt texts to a preset empty set to obtain the above-mentioned training data set.
[0093] For example, if the above-mentioned generation task is an article generation task, and the above-mentioned article generation task is specifically that the model is required to generate an abstract based on a title and keywords, then the above-mentioned prompt instruction text is "Instruction": "Please expand the title and keywords into an abstract", the specific text content corresponding to the above-mentioned "title" is "Large Model Landing Training", and the specific text content corresponding to the above-mentioned "keywords" is "Large Model; Training; Assistant", then the above-mentioned second prompt text can be {"Instruction": "Please expand the title and keywords into an abstract.", "Input": "Title: Large Model Landing Training.\nKeywords: Large Model; Training; Assistant.", "Output": "Large model landing training refers to providing specialized training for the deployment and implementation of large prediction models (usually referring to models with higher complexity and more parameters). The purpose of this training is to help enterprises and institutions effectively use large models for data analysis and prediction, so as to achieve business optimization and improvement"}. Among them, the content corresponding to the above-mentioned "Output" is the label text corresponding to the above-mentioned prompt text, the content corresponding to the above-mentioned "Input" is the above-mentioned text content and text structure, and the content corresponding to the above-mentioned "Instruction" is the above-mentioned prompt instruction text. It should be noted that the above-mentioned "Output" can be the output obtained manually based on the above-mentioned "Input" according to the "Instruction", or can be understood as the expected output result, which is used for loss calculation when training the above-mentioned preset large model.
[0094] If the above generation task is an expansion task, the above instruction text can be "You are an expansion assistant. Expansion means enriching the content by adding detailed information, giving examples, providing more details, etc. without changing the original meaning of the text. The purpose of expansion is to make the article richer, more in-depth and broader, so as to better convey information or viewpoints. Please expand the following text and only output the expanded text, ensuring that you do not mention anything that may violate human values." If the text content corresponding to the above expansion task is "Always put people first and serve the people", then the above second prompt text can be {"instruction": "You are an expansion assistant. Expansion means enriching the content by adding detailed information, giving examples, providing more details, etc. without changing the original meaning of the text. The purpose of expansion is to make the article richer, more in-depth and broader, so as to better convey information or viewpoints. Please expand the following text and only output the expanded text, ensuring that you do not mention anything that may violate human values.\nText: {}\nExpanded result: ", "input": "Always put people first and serve the people.", "output": "Always uphold the people-centered and people-benefiting sentiment of caring about the masses. Think diligently about strategies for the people and earnestly implement measures that benefit the people. Make major decisions based on the will of the people and introduce work measures in response to the needs of the people."}
[0095] More specifically, if the above generation task is an expansion task and the text content corresponding to the above prompt text is "A certain company has launched a new product.", then the above labeled text can be "A certain company has launched a new product, which has multiple innovative functions and is designed to meet market demands." If the above generation task is a polishing task and the text content corresponding to the above prompt text is "Party A needs to pay Party B 100,000 yuan.", then the above labeled text can be "Party A needs to pay Party B 100,000 yuan, and this amount will be paid within 10 working days after the contract is signed." If the above generation task is a rewriting task and the text content corresponding to the above prompt text is "Our product is the best.", then the above labeled text can be "Our product is one of the best in the market. It has multiple advantages and features and can meet your needs."
[0096] Optionally, in the step of training a preset large model based on a training data set to obtain a preset text generation large model, the prompt text can also be input into the preset large model for text generation processing to obtain a text generation result; calculate the loss value between the labeled text and the text generation result through a preset loss function; take minimizing the loss value as the optimization goal, adjust the parameters of the preset large model, iterate the parameter adjustment process until the loss value converges at the minimum, and stop training to obtain the preset text generation large model.
[0097] In the embodiments of the present invention, the above text generation result is the output obtained by performing text generation processing on the above-mentioned pre-set large model when it is not trained yet (i.e., the above text generation result). The above-mentioned pre-set loss function can be a cross-entropy function. The above cross-entropy function is used to handle binary classification problems or multi-classification problems. When dealing with binary classification problems, the above cross-entropy function can be illustrated by the following binary cross-entropy formula:
[0098]
[0099] Among them, the above loss represents the loss value, the above y is the true label of each character in the above label text, taking values of 0 or 1, and the above represents the probability that each character in the text generation result output by the above-mentioned pre-set large model is a positive example, that is, the probability that y = 1. When y = 1, When y = 0,
[0100] When dealing with multi-classification problems, the above cross-entropy function can be illustrated by the following multi-classification cross-entropy formula:
[0101]
[0102] Among them, the above p(x) is the overall true distribution of the above label text, and the above q(x) is the overall distribution probability of the above text generation result. It can be understood that the above binary cross-entropy formula can be used to calculate the loss between each character in the above label text and each character in the above text generation result, and the above multi-classification cross-entropy formula is used to calculate the loss of the overall distribution probability between the above label text and the above text generation result.
[0103] Specifically, the training process of the above-mentioned pre-set text generation large model can be illustrated by a flowchart of a model training as shown in Figure 3 As shown in Figure 3 As shown, the data from different data sources such as data source 1, data source 2, data source n - 1, and data source n are collected and subjected to data preprocessing to obtain text content with a unified text structure. A part is randomly selected from the text content with a unified text structure to construct a training set, and the remaining part is constructed as a test set. The pre-set large model is trained according to the above training set to obtain a trained large model. The trained large model is deployed, and the trained large model is evaluated and tested through the test set. When the evaluation and test pass, the above-mentioned pre-set text generation large model can be obtained. If the evaluation and test do not pass, training can continue through the above test set until the evaluation and test of the trained large model pass, and the above-mentioned pre-set text generation large model is obtained.
[0104] More specifically, the above-mentioned model can be deployed in the form of text-generate-inference (TGI). The above-mentioned TGI is a framework specifically for deploying large models, which can facilitate people to deploy models, and finally returns an API (i.e., an interface). The above-mentioned test set is used to test the above-mentioned trained large model through the above-mentioned API, and the text generation result output by the above-mentioned trained model is compared with the label text in the above-mentioned test set. The accuracy rate of the above-mentioned text generation result that conforms to the above-mentioned label text is counted. Until the above-mentioned accuracy rate reaches the preset accuracy requirement, the above-mentioned preset text generation large model is obtained.
[0105] As Figure 4 shown, an embodiment of the present invention further provides an article generation device, including:
[0106] A first acquisition module 401, configured to acquire the text information to be generated in the current round, where the text information to be generated in the current round includes the text content and text structure of the current round;
[0107] A first determination module 402, configured to determine the first prompt text of the current round based on the text content and text structure;
[0108] A first generation module 403, configured to input the first prompt text of the current round into a preset text generation large model for text generation processing, and obtain the text generation content of the current round, where the text generation content of the current round corresponds to the text structure of the current round;
[0109] A second generation module 404, configured to obtain the target text content when the text generation processing of all rounds is completed.
[0110] Optionally, the first acquisition module 401 includes:
[0111] A first-round sub-module, configured to when the current round is the first round, the text content of the current round includes the text input content input by the user;
[0112] A non-first-round sub-module, configured to when the current round is a non-first round, the text content of the current round includes the text input content input by the user and the text generation content of the historical round.
[0113] Optionally, the article generation device further includes:
[0114] A second acquisition module, configured to acquire a preset large model and sample data, where the sample data includes text content of different types, and the text content of different types includes text content corresponding to different text structures;
[0115] A preprocessing module for preprocessing data based on the sample data to obtain a training data set;
[0116] A generation training module for performing text generation training on the preset large model based on the training data set to obtain the preset text generation large model.
[0117] Optionally, the preprocessing module includes:
[0118] A normalization sub-module for normalizing the text content to obtain text content with a unified text structure;
[0119] A first determination sub-module for determining different types of generation tasks based on the text content with the unified text structure;
[0120] A second determination sub-module for determining the training data set based on the different types of generation tasks.
[0121] Optionally, the first determination sub-module includes:
[0122] A first determination unit for determining an article generation task based on the generated text content with the unified text structure;
[0123] A second determination unit for determining an expansion task based on the expanded text content with the unified text structure;
[0124] A third determination unit for determining a correction task based on the corrected text content with the unified text structure;
[0125] A fourth determination unit for determining the different types of generation tasks based on the article generation task, the expansion task, and the correction task.
[0126] Optionally, the second determination sub-module includes:
[0127] A construction unit for constructing different types of second prompt texts based on the different types of generation tasks;
[0128] A building unit for building the training data set based on the different types of second prompt texts, where the second prompt text includes a prompt text and a label text corresponding to the prompt text.
[0129] Optionally, the generation training module includes:
[0130] A generation sub-module for inputting the prompt text into the preset large model for text generation processing to obtain a text generation result;
[0131] A calculation sub-module, configured to calculate a loss value between the label text and the text generation result through a preset loss function;
[0132] A training sub-module, configured to adjust the parameters of the preset large model with minimizing the loss value as an optimization goal, iterate the parameter adjustment process until the loss value converges at the minimum, stop training, and obtain the preset text generation large model.
[0133] As Figure 5 shown, an embodiment of the present invention further provides an electronic device, which includes a processor, and the above processor can execute any one of the above article generation methods.
[0134] Specifically, it includes a processor 501, a memory 502, and a computer program for executing the article generation method stored on the memory 502 and capable of running on the processor 501, where:
[0135] The processor 501 runs the calculator program of the article generation method stored in the memory 502 and executes the following steps:
[0136] Obtain the text information to be generated in the current round, where the text information to be generated in the current round includes the text content and the text structure in the current round;
[0137] Based on the text content and the text structure, determine the first prompt text in the current round;
[0138] Input the first prompt text in the current round into the preset text generation large model for text generation processing, and obtain the text generation content in the current round, where the text generation content in the current round corresponds to the text structure in the current round;
[0139] When the text generation processing of all rounds is completed, obtain the target text content.
[0140] Optionally, the current round executed by the processor 501 includes the first round and non-first rounds. The obtaining of the text information to be generated in the current round, where the text information to be generated in the current round includes the text content and the text structure in the current round, includes:
[0141] When the current round is the first round, the text content in the current round includes the text input content input by the user;
[0142] When the current round is a non-first round, the text content in the current round includes the text input content input by the user and the text generation content in the historical round.
[0143] Optionally, before the obtaining of the text information to be generated, the method executed by the processor 501 further includes:
[0144] Obtain a pre-set large model and sample data, where the sample data includes different types of text content, and the different types of text content include text content corresponding to different text structures;
[0145] Perform data preprocessing on the sample data to obtain a training data set;
[0146] Perform text generation training on the pre-set large model based on the training data set to obtain the pre-set text generation large model.
[0147] Optionally, the performing data preprocessing on the sample data to obtain a training data set executed by the processor 501 includes:
[0148] Perform standardization processing on the text content to obtain text content with a unified text structure;
[0149] Determine different types of generation tasks based on the text content with the unified text structure;
[0150] Determine the training data set based on the different types of generation tasks.
[0151] Optionally, the different types of text content executed by the processor 501 include text content for expansion, text content for generation, and text content for error correction. The determining different types of generation tasks based on the text content with the unified text structure includes:
[0152] Determine an article generation task based on the generated text content with a unified text structure;
[0153] Determine an expansion task based on the expanded text content with a unified text structure;
[0154] Determine an error correction task based on the error correction text content with a unified text structure;
[0155] Determine the different types of generation tasks based on the article generation task, expansion task, and error correction task.
[0156] Optionally, the determining the training data set based on the different types of generation tasks executed by the processor 501 includes:
[0157] Construct different types of second prompt texts based on the different types of generation tasks;
[0158] Construct the training data set based on the different types of second prompt texts, where the second prompt text includes a prompt text and a label text corresponding to the prompt text.
[0159] Optionally, the text generation training of the preset large model based on the training data set executed by the processor 501 to obtain the preset text generation large model includes:
[0160] Input the prompt text into the preset large model for text generation processing to obtain a text generation result;
[0161] Calculate the loss value between the label text and the text generation result through a preset loss function;
[0162] Taking minimizing the loss value as the optimization objective, adjust the parameters of the preset large model, iterate the parameter adjustment process until the loss value converges at the minimum, stop training, and obtain the preset text generation large model.
[0163] The embodiment of the present invention also provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, it realizes each process of the article generation method or the application-side article generation method provided by the embodiment of the present invention, and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0164] Those of ordinary skill in the art can understand that all or part of the processes of implementing the above method embodiments can be completed by instructing relevant hardware through a computer program. The above computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. Among them, the above computer-readable storage medium can be a magnetic disk, an optical disc, a read-only memory (ROM), or a random access memory (RAM), etc.
[0165] The above-disclosed are only the preferred embodiments of the present invention. Of course, the scope of the rights of the present invention cannot be limited by this. Therefore, equivalent changes made according to the claims of the present invention still fall within the scope covered by the present invention.
Claims
1. A method for generating an article, characterized in that, The method includes the following steps: Obtain the text information to be generated in the current round, where the text information to be generated includes the text content and text structure of the current round; Based on the text content and text structure, determine the first prompt text of the current round; Input the first prompt text of the current round into a preset large text generation model for text generation processing to obtain the text generation content of the current round, where the text generation content of the current round corresponds to the text structure of the current round; When the text generation processing for all rounds is completed, obtain the target text content.
2. The article generation method according to claim 1, characterized in that The current round includes the first round and non-first rounds. The obtaining of the text information to be generated in the current round, where the text information to be generated includes the text content and text structure of the current round, includes: When the current round is the first round, the text content of the current round includes the text input content input by the user; When the current round is a non-first round, the text content of the current round includes the text input content input by the user and the text generation content of the historical round.
3. The article generation method according to claim 1, characterized in that Before obtaining the text information to be generated, the method further includes: Obtain a preset large model and sample data, where the sample data includes different types of text content, and the different types of text content include text content corresponding to different text structures; Perform data preprocessing on the sample data to obtain a training data set; Perform text generation training on the preset large model based on the training data set to obtain the preset text generation large model.
4. The article generation method according to claim 3, wherein The performing data preprocessing on the sample data to obtain a training data set includes: Perform standardization processing on the text content to obtain text content with a unified text structure; Based on the text content with the unified text structure, determine different types of generation tasks; Based on the different types of generation tasks, determine the training data set.
5. The article generation method according to claim 4, characterized in that The different types of text content include text content for text expansion, text generation content, and text correction content. The determining different types of generation tasks based on the text content with the unified text structure includes: Based on the text generation content with the unified text structure, determine an article generation task; Based on the text expansion content with the unified text structure, determine an expansion task; Based on the text correction content with the unified text structure, determine a correction task; Based on the article generation task, expansion task, and correction task, determine the different types of generation tasks.
6. The article generation method according to claim 4, wherein The determining the training data set based on the different types of generation tasks includes: Construct different types of second prompt texts based on the different types of generation tasks; Based on the different types of second prompt texts, construct the training data set, where the second prompt text includes a prompt text and a label text corresponding to the prompt text.
7. The article generation method according to claim 6, wherein The performing text generation training on the preset large model based on the training data set to obtain the preset text generation large model includes: Input the prompt text into the preset large model for text generation processing to obtain a text generation result; Calculate the loss value between the labeled text and the text generation result through a preset loss function; Taking the minimization of the loss value as the optimization objective, adjust the parameters of the preset large model, iterate the parameter adjustment process until the loss value converges at the minimum, stop training, and obtain the preset text generation large model.
8. An article generation device, characterized in that, The article generation device includes: A first acquisition module, configured to acquire the text information to be generated in the current round, where the text information to be generated in the current round includes the text content and text structure in the current round; A first determination module, configured to determine the first prompt text in the current round based on the text content and text structure; A first generation module, configured to input the first prompt text in the current round into the preset text generation large model for text generation processing, and obtain the text generation content in the current round, where the text generation content in the current round corresponds to the text structure in the current round; A second generation module, configured to obtain the target text content after completing the text generation processing for all rounds.
9. An electronic device, characterized in that, Including: A memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the computer program, the steps in the article generation method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps in the article generation method according to any one of claims 1 to 7 are implemented.