Text generation method and device, equipment, storage medium and program product
By introducing a correction mechanism to the candidate text and rewriting the task prompts during the text generation process, the accuracy of the generated text and its consistency with the character's style are ensured. This solves the problems of low accuracy and scene mismatch in text generation technology, realizes a text generation method, and improves the accuracy of the generated text and its consistency with the character's style.
Patent Information
- Application Number
- CN202410524997.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-26
- Publication Date
- 2025-10-31
AI Technical Summary
Existing text generation technologies produce text with low accuracy and content that does not match the scene when performing role-playing tasks, thus failing to effectively meet the task requirements.
After generating candidate text based on the first task prompt and role information, a correction mechanism is introduced to correct it, and the task prompt is rewritten based on the corrected text and the task prompt to ensure that the generated text matches the task information.
It improves the accuracy of generated text and its consistency with the character's style, ensuring that the text does not exceed the character's capabilities and solving the problems of inaccurate text and inconsistent content.
Smart Images

Figure CN120873156A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a text generation method, apparatus, device, storage medium, and program product. Background Technology
[0002] Text generation technology can not only be used to interact with users in a natural way (mainly through language and images), but it also has versatility across a wide range of scenarios. However, for specific text tasks such as role-playing, for example, simulating an administrative staff member and answering professional questions about various internal rules and regulations, the generated text suffers from low accuracy and inconsistencies between the generated text and the scenario. For instance, the generated text may not match the style of the role being played, or it may exceed the role's capabilities.
[0003] Therefore, there is an urgent need for a text generation solution that can solve problems such as inaccurate text and text content that does not match the context when performing text tasks. Summary of the Invention
[0004] The purpose of this application is to provide a text generation method, apparatus, device, storage medium, and program product to solve problems such as inaccurate text generated when performing text tasks and text content not matching the scene, thereby improving the quality of generated text and better meeting the requirements of text tasks.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, embodiments of this application provide a text generation method, comprising: obtaining a first candidate text based on a first task prompt word and first role information; correcting the first candidate text based on the first task information to obtain a first corrected text; determining a second task prompt word based on the first corrected text and the first task prompt word; and obtaining a first text based on the second task prompt word and the first role information.
[0007] Secondly, embodiments of this application provide a text generation apparatus, comprising: a first generation unit, configured to obtain a first candidate text based on a first task prompt word and first role information; a correction unit, configured to correct the first candidate text based on the first task information to obtain a first corrected text; a determination unit, configured to determine a second task prompt word based on the first corrected text and the first task prompt word; and a second generation unit, configured to obtain a first text based on the second task prompt word and the first role information.
[0008] Thirdly, embodiments of this application provide an electronic device, including: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the text generation method as described in the first aspect.
[0009] Fourthly, embodiments of this application provide a computer-readable storage medium that, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the text generation method as described in the first aspect.
[0010] Fifthly, embodiments of this application provide a computer program product, the computer program product including a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps in the text generation method as described in the first aspect.
[0011] The above-mentioned at least one technical solution adopted in the embodiments of this application can achieve the following beneficial effects: After generating the first candidate text based on the first task prompt and the first role information, the first candidate text is not directly output. Instead, a correction mechanism is used to specifically correct whether the first candidate text matches the first preset task information, and the first corrected text is output. Furthermore, based on the first corrected text and the first task prompt, the task prompt is rewritten in a targeted manner. The resulting second task prompt can better guide the execution of the text generation task, ensuring that the first text that matches the first task information is generated. This makes the first text accurate, consistent with the style of the first role information, and does not exceed the role's ability range, thus solving problems such as inaccurate text generated by executing text tasks and text content that does not match the scene. Attached Figure Description
[0012] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0013] Figure 1 A flowchart illustrating a text generation method provided in one embodiment of this application;
[0014] Figure 2 A flowchart illustrating a text generation method provided for another embodiment of this application;
[0015] Figure 3 A flowchart illustrating a text generation method provided for another embodiment of this application;
[0016] Figure 4 A flowchart illustrating a text generation method provided for another embodiment of this application;
[0017] Figure 5 A schematic diagram of the structure of a text generation device provided in one embodiment of this application;
[0018] Figure 6 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and are not used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following related objects are in an "or" relationship.
[0021] Explanation of some concepts:
[0022] Role-playing: In a textual context, a large model, such as a Large Language Model (LLM), is used to simulate the style of a specific character performing a designated textual task. This could involve simulating an administrator answering professional questions about company rules and regulations, or simulating multiple characters completing script design tasks. The large language model should possess background knowledge and personality traits as similar as possible to the real person (or fictional character) corresponding to that specific role, enabling it to think, speak, and act in that character's style.
[0023] Prompts are the text used by humans to communicate with the large model, guiding it to generate text according to the user's needs. Prompts can be a simple instruction or a long text containing complex content, such as background information on the text task, several task examples, or an introduction to the role being played. Generally, more detailed prompts allow the large model to more accurately understand and execute the text task, generating text that meets the task requirements.
[0024] Instructions: These are explicit commands and instructions, primarily focusing on describing the task, i.e., what the large model is expected to do. The relationship between instructions and cue words is that instructions can be part of cue words, but cue words do not necessarily include instructions. Relatively speaking, instructions are written more directly, while cue words are written more flexibly and can contain more content to stimulate the capabilities of the large model.
[0025] Instruction Tuning: Since large models are not specifically trained on instructions relevant to the current text task during training, their understanding of some instructions may be inadequate, leading to the generation of unexpected text. To enable large models to adapt to instructions in the current text task, instruction tuning techniques have been developed. Instruction tuning is a supervised training technique for large models. By collecting an instruction dataset ({<instruction, output>}), fine-tuning and updating some parameters of the large model can improve its capabilities and controllability. In this way, when performing the current text task, the large model can better understand instructions and generate text that better meets the task requirements.
[0026] Chain of Thoughts is a technique used to improve the reasoning capabilities of large models. It guides the model to generate a series of reasoning steps to solve problems. A chain of thoughts can be understood as a high-level cue word. It includes not only the input question and output conclusion, but also the intermediate reasoning process leading to the output. Furthermore, the chain of thoughts guides the model to include its own reasoning process as part of the output. This effectively improves the accuracy of large model outputs.
[0027] Hallucinations are mainly divided into two categories: factual hallucinations and faithfulness hallucinations. Factual hallucinations primarily include the following two situations: (1) Factual inconsistency: The output of the large model contradicts actual information in the real world; (2) Fact fabrication: The output of the large model includes things that do not exist and cannot be verified. Faithful hallucinations primarily include the following three situations: (1) Instruction inconsistency: The output of the large model is not the task the instructions command; (2) Contextual inconsistency: The output of the large model does not match the contextual information; (3) Logical inconsistency: The reasoning steps of the large model are inconsistent with the final output.
[0028] The aforementioned illusion can be simply understood as the output of the large model making people feel like they are talking nonsense.
[0029] As mentioned earlier, for specific text tasks such as role-playing, there are not only problems with low accuracy, but also problems with the text content not matching the scene. For example, the text content may not match the style of the character being played, or it may be beyond the character's ability range.
[0030] For example, if the prompt is "You are Sun Wukong. Suppose you are leaving for a while, what would you tell Zhu Bajie?", the generated text would be "Hello, please take good care of Tang Sanzang." In this scenario, Sun Wukong wouldn't be so polite to Bajie and should address Tang Sanzang as "Master." This is an example of text content that doesn't match the character's style. Another example is "Sun Wukong, what's your favorite movie?", which generates text as "My favorite movie is 'A Chinese Odyssey.'" In this scenario, the concept of movies didn't exist in the era depicted in Journey to the West, so more fitting text would be Sun Wukong's lack of understanding of movies and his expression of confusion. This is another example of text content exceeding the character's capabilities.
[0031] As can be seen, the problem of the generated text content not matching the scene is neither a factual error nor a problem of ununderstood prompts, and therefore cannot be addressed by current text generation technologies. To solve the problems of inaccurate text generated during text tasks and text content not matching the scene, this application proposes a text generation method. This method is mainly based on the following two considerations:
[0032] Firstly, in human life, targeted feedback can help correct errors. Based on this, this feedback mechanism can be introduced into the process of performing text tasks to correct the generated text, overcoming inaccuracies and discrepancies between text content and context, thus enabling the generated text to better meet the task requirements.
[0033] Secondly, guided by prompts consisting of specific instructions and thought processes, tasks can be completed effectively and reasons provided. Based on this, judging whether the generated text meets the task requirements can also be constructed as a text generation task. Compared to human feedback, using text generation tasks for feedback not only provides reasons but also has the advantages of high efficiency and comprehensive feedback.
[0034] Based on the above two considerations, the text generation method proposed in this application introduces a correction mechanism. After generating the first candidate text based on the first task prompt and the first role information, the first candidate text is not directly output. Instead, the correction mechanism is used to specifically correct whether the first candidate text matches the first preset task information, and the first corrected text is output. Furthermore, based on the first corrected text and the first task prompt, the task prompt is rewritten in a targeted manner. The resulting second task prompt can better guide the execution of the text generation task, ensuring that the first text that matches the first task information is generated. This makes the first text accurate, consistent with the style of the first role information, and within the scope of the role's capabilities, thus solving problems such as inaccurate text generated during the execution of text tasks and text content that does not match the scene.
[0035] It should be understood that the text generation method provided in this application embodiment can be executed by an electronic device, specifically by the processor of the electronic device. The electronic device referred to herein may include terminal devices, such as, but not limited to, smartphones, tablets, laptops, desktop computers, smart voice interaction devices, smart home appliances, smartwatches, vehicle terminals, and aircraft; or, the electronic device may also include a server, such as a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0036] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0037] Please see Figure 1 The following is a flowchart illustrating a text generation method according to an embodiment of this application. The method includes the following steps:
[0038] S102, based on the first task prompt and the first role information, obtain the first candidate text.
[0039] The first task prompt is used to instruct the execution of the target text task, such as generating text that matches the first role information. The first task information describes the requirements of the target text task. The first role information describes the first role to be played.
[0040] The requirements for role-playing tasks can be set according to actual needs, including but not limited to the generated text conforming to the style of the first character, the generated text not exceeding the first character's ability range, and the generated text containing specified content. For example, if the target text task 1 is: to imitate Fibonacci and explain the meaning and characteristics of the Fibonacci sequence, then the task requirements could include: the generated introductory text conforming to Fibonacci's style and not exceeding Fibonacci's ability range at the time, and the generated introductory text containing the meaning and characteristics of the Fibonacci sequence but not containing formulas. As another example, if the target text task 1 is: to imitate a film or television screenwriter and design a script for a specified story scene, then the task requirements could include: the dialogue in the script conforming to the characteristics of the characters in the specified story scene, the script unfolding in the form of dialogue, and the script's content matching the plot and character relationships in the specified story scene.
[0041] The first task prompt can take various appropriate forms, such as instructions, long blocks of text containing preset task requirements, or thought chains, etc., and this application embodiment does not limit this. In one embodiment, in order to better understand the first role information and generate text that meets the task requirements during the execution of the text task, the first task prompt can be generated based on the first role information and the first task information. Specifically, the first role information and the first task information can be filled into the task prompt template to obtain the first task prompt.
[0042] For example, Table 1 below shows a task prompt template for performing text tasks using a large model with generative language techniques.
[0043] Table 1
[0044]
[0045] Assuming the first character is Fibonacci, and the target text task is: to imitate Fibonacci and explain the meaning and characteristics of the Fibonacci sequence, the first task information includes: the generated introductory text conforms to Fibonacci's style and does not exceed Fibonacci's capabilities at the time; the generated introductory text includes the meaning and characteristics of the Fibonacci sequence but does not contain formulas. Filling the first character information and the first task information into the task prompt template shown in Table 1 above, we obtain the first task prompt words shown in Table 2 below:
[0046] Table 2
[0047]
[0048]
[0049] Assuming the first role is a screenwriter, and the target text task is to design a script for a specified story scene, mimicking the screenwriter's style, then the first task information can include: the dialogue in the script matches the characteristics of the characters in the specified story scene; the script unfolds in dialogue form; and the script's content matches the plot and character relationships in the specified story scene. Filling the first role information and the first task information into the task prompt template shown in Table 1 above yields the first task prompt words shown in Table 3 below:
[0050] Table 3
[0051]
[0052] This application embodiment illustrates one method for generating the first task prompt. Of course, it should be understood that the first task prompt can also be generated in other ways, and this application embodiment does not limit this method.
[0053] In step S102 above, the first candidate text can be generated using a first language model, a first task prompt, and first role information. Specifically, after generating the first task prompt, the first task prompt and the first role information are input into the first language model, causing the first language model to execute the text task according to the guidance of the first task prompt and generate the first candidate text.
[0054] For example, inputting the first task prompt words and first role information shown in Table 2 above into the first language model yields the first candidate text shown in Table 4 below.
[0055] Table 4
[0056]
[0057]
[0058] For example, inputting the first task prompt words shown in Table 3 above into the first language model yields the first candidate text shown in Table 5 below.
[0059] Table 5
[0060]
[0061] In this embodiment, the first language model can be any large model capable of generating text using generative language techniques, such as a generative language model, and this embodiment does not limit its use. The first language model can be obtained through various appropriate means, and this embodiment does not limit its use either. As an example, the first language model can be an existing large model without any training.
[0062] As another example, to enable a first language model to better understand task prompts and thus better perform the target text task, the first language model can be trained using sample task prompts and sample text. For instance, the sample task prompts guide the first language model to perform a sample text task, where the task type is the same as the target text task.
[0063] In practical applications, the training of the first language model can be achieved using various fine-tuning techniques commonly used in the field, and this application embodiment does not limit this. As an example, sample task prompts are used as training samples, and sample texts are used as the corresponding labels for the training samples. The first language model is trained based on the training samples and their labels. More specifically, sample task prompts are input into the first language model to obtain predicted text, and the generation loss of the first language model is calculated based on the difference between the predicted text and the sample text. The parameters of the first language model are then adjusted based on the generation loss.
[0064] For example, if the target text task is a knowledge-response type, such as the text task mentioned above, "Imitating Fibonacci, explain the meaning and characteristics of the Fibonacci sequence," then the sample text task is also a knowledge-response type text task, such as imitating a corporate administrator interpreting internal company rules and regulations. Similarly, if the target text task is a creative type, such as the text task mentioned above, "Imitating a film or television screenwriter, design a script for a specified story scene," then the sample text task is also a creative type text task, such as writing an article containing a specified central idea.
[0065] By training the first language model with sample task prompts and sample texts related to the same type of sample text task as the target text task, the effect of fine-tuning the first language model can be achieved. This allows the fine-tuned first language model to have learned the prompts related to the same type of task before performing the target text task, thereby improving the ability and controllability of the first language model. As a result, during the target text task, it can better understand the first task prompts and generate first candidate texts that match the first task information as closely as possible, thus reducing the workload of subsequent correction of the first candidate texts.
[0066] S104, Based on the first task information, the first candidate text is corrected to obtain the first corrected text.
[0067] The correction of the first candidate text is also achieved using generative language techniques. For example, the first candidate text is corrected using a second language model, which is a large model that generates text using generative language techniques. The second language model can be any large model with language capabilities commonly used in this field. It can correct the input text by referring to the first task information, determine whether the text matches the first task information and output reasons, and, if the text does not match the first task information, output corrected text describing directions for improvement.
[0068] In one embodiment, the first task information and the first candidate text can be concatenated and then input into a second language model for correction to obtain the first corrected text.
[0069] In another embodiment, to fully utilize the comprehensive and efficient language capabilities of generative language technology, prompt words can be used to guide the second language model in correcting the first candidate text. Specifically, S104 includes the following steps: S141, generating a first correction prompt word based on the first task information and the first candidate text; S142, correcting the first candidate text based on the first correction prompt word to obtain the first corrected text. For example, the first correction prompt word can be input into the second language model for correction to obtain the first corrected text. The first correction prompt word is used to indicate the correction of the first candidate text.
[0070] In step S141 above, as an example, the first task information and the first candidate text are concatenated to obtain the first correction prompt word. Generating the first correction prompt word in this way is simple and efficient.
[0071] As another example, to more accurately correct whether the first candidate text matches the first task information, the first correction prompt can be obtained as follows: Based on the first task information and the first candidate text, correction task information is generated; the correction task information and second role information are filled into the correction prompt template to obtain the first correction prompt. The second role information describes the attributes of the second role, such as the name and characteristics of the second role. The second role can be a role that guides the first role in performing the target text task; that is, the second role is similar to the first role's mentor. The second role can be set according to actual needs. For example, if the first role is a screenwriter, the second role is a screenwriting tutor; if the first role is Fibonacci, the second role is a historian of mathematics, etc. This application embodiment does not limit this. In the above example, the correction prompt template can be set according to actual needs, specifically including, but not limited to, fixed text, fields for filling the second role information, and fields for filling the correction task information, etc. This application embodiment does not limit this.
[0072] In this embodiment, the correction task information can be obtained through various appropriate methods. In one embodiment, in order to better guide the output of more targeted correction text by the generated first correction prompt word, and to ensure that the subsequent first text matching the first task information is obtained, the correction task information can be generated as follows: Step A1, the first task information and the first candidate text are fused to obtain fused text; Step A2, based on the first task type, candidate correction task information of the first candidate text is determined; Step A3, correction task information is generated based on the fused text and the candidate correction task information. Here, the first task type refers to the task type of the target text task.
[0073] In step A1 above, the first task information and the first candidate text can be concatenated to obtain the fused text.
[0074] In step A2 above, as an example, if the first task type is a knowledge response type, the determined candidate correction task information includes: correcting the first candidate text and outputting corrected text containing the reasons for the correction. Here, a knowledge response type text task refers to a task that answers a question through knowledge retrieval, such as the target text task 1 shown above. For example, for the aforementioned target text task 1, the determined candidate correction task information includes: judging whether the first candidate text is accurate, giving a conclusion on whether it is accurate, and listing up to three reasons, with the most important reason listed first.
[0075] Understandably, since knowledge-response text tasks have high accuracy requirements, by identifying candidate correction task information as text correction and outputting the reasons for correction, the first correction prompt words generated can better guide the correction process of the first candidate text, thereby better assisting in generating a first text with high accuracy and matching the first task information, effectively overcoming the illusion problem that exists in the process of performing text tasks using generative language technology.
[0076] If the first task type is a creative task, then the candidate correction task information includes: improving the first candidate text and outputting corrected text containing reasons for improvement. Here, a creative text task refers to a task of creating text according to given requirements, such as writing an article or the target text task 2 mentioned above. For example, for the aforementioned target text task 2, the determined candidate correction task information includes: based on a full understanding of the storyline and character relationships in the scene, determining whether each character's statements reflect their personality traits and whether they are acceptable; if not, listing reasons for improvement.
[0077] Understandably, since creative text tasks are highly subjective, offer a lot of room for creativity, and have high requirements for language expression, by identifying candidate correction task information as text improvement and outputting the reasons for improvement, the resulting first correction prompt words can better guide the improvement process of the first candidate text. This, in turn, better assists in generating a first text whose language expression conforms to the style of the first character and matches the first task information, effectively overcoming the problem of text generated using generative language technology not matching the scene.
[0078] In step A3 above, the fused text and candidate correction task information are concatenated to obtain the correction task information. For example, Table 6 below shows a correction prompt template, which is used to correct the input text using a large model with generative language capabilities.
[0079] Table 6
[0080]
[0081] Taking the first task information of the target text task 1 shown above and the first candidate text shown in Table 4 as an example, the first correction prompt words shown in Table 7 below can be obtained through the above steps A1 to A3 and S142.
[0082] Table 7
[0083]
[0084]
[0085] Taking the first task information of the target text task 2 shown above and the first candidate text shown in Table 5 as an example, the first correction prompt words shown in Table 8 below can be obtained through the above steps A1 to A3 and S142.
[0086] Table 8
[0087]
[0088] In another embodiment, to ensure that the generated first correction prompt word can better guide the correction model to output more targeted correction text, thereby ensuring that the target text that meets the preset task requirements is subsequently obtained, the preset task requirements can be broken down into n task sub-information, where n is an integer greater than 1. Then, for each task sub-information, a second language model is used to correct the first candidate text according to that task sub-information. The n second language models correct the first candidate text from different perspectives. That is, the preset task information includes n sub-task information, and the number of second language models is n, with each second language model corresponding to one task sub-information. Accordingly, the correction task information can be generated as follows: based on the task sub-information corresponding to the second language model and the first candidate text, the correction task information corresponding to the second language model is generated. Correspondingly, the above-mentioned filling the correction task information and second role information into the correction prompt template to obtain the first correction prompt word includes: filling the correction task information and second role information corresponding to the second language model into the correction prompt template to obtain the first correction prompt word corresponding to the second language model.
[0089] For example, the first task information includes the following three task sub-information:
[0090] Task Sub-Information 1: Targeted correction of whether the text generated by the character model conforms to the style of the first character. The implicit requirement here is that the correction model has a very thorough understanding of the first character. For example, in the target text task 2 above, the correction model is required to have a very good understanding of Sun Wukong and the entire Journey to the West story background.
[0091] Task Sub-Information 2: Determine whether the text generated by the role model conforms to the general characteristics of the group to which the first role belongs, and whether it conforms to the regional style of the region where the first role is located. For example, if the first role is a 21st-century New York high school student, then Task Sub-Information 2 includes determining whether the text generated by the role model conforms to the general characteristics of New York high school students and whether it conforms to the regional style of New York State. This ensures that the first role should not significantly exceed the group to which it belongs or deviate from its life context.
[0092] Task Sub-Information 3: From the perspective of professional mentors in writing, drama, performance, etiquette, etc., assess whether there are any flaws in the role-playing ability of the role model. For example, in official settings, does the text generated by the role model contain colloquial language? Or, in home settings, does the text generated by the role model contain formal language?
[0093] For the three task sub-information items mentioned above, second language models 1 through 3 can be used. For task sub-information 1, based on task sub-information 1 and the first candidate text, correction task information corresponding to second language model 1 is generated. This correction task information 1 and the second role information are then filled into the correction prompt word template to obtain the first correction prompt word corresponding to second language model 1. Thus, by inputting this first correction prompt word into second language model 1, it guides second language model 1 to correct whether the first candidate text matches task sub-information 1, and outputs the first corrected text 1. Similarly, the first correction prompt words corresponding to second language model 2 and second language model 3 are obtained. The first correction prompt word corresponding to second language model 2 is input into second language model 2 to guide second language model 2 to correct whether the first candidate text matches task sub-information 2, and the first correction prompt word corresponding to second language model 3 is input into second language model 3 to guide second language model 3 to correct whether the first candidate text matches task sub-information 3.
[0094] In practical applications, the specific implementation method for generating the correction task information corresponding to the second language model based on the task sub-information and the first candidate text is similar to the specific implementation method shown in steps A1 to A3 above, and will not be repeated here.
[0095] In this embodiment, the second language model can be any large model with text generation capabilities, such as a generative language model, and this embodiment does not limit its use. The second language model can be obtained through various appropriate methods, and this embodiment does not limit its use either. As an example, the second language model can be an existing large model without any training.
[0096] As another example, to enable a second language model to better understand correction prompts and thus better correct the input text, the second language model can be trained using sample correction prompts and sample correction text. The sample correction prompts are used to prompt the second language model to correct the sample text based on the task requirements. In practical applications, various fine-tuning techniques commonly used in the field can be employed to train the second language model, and this embodiment does not limit this approach. As an example, sample correction prompts are used as training samples, and sample correction text is used as the corresponding labels for the training samples. The second language model is trained based on the training samples and their labels. More specifically, the sample correction prompts are input into the second language model to obtain predicted correction text. Based on the difference between the predicted correction text and the sample correction text, the generation loss of the second language model is calculated, and the parameters of the second language model are adjusted based on the generation loss.
[0097] Training a second language model using sample correction prompts and sample correction texts can fine-tune the model, allowing it to learn relevant correction prompts before correcting the input text. This improves the model's capabilities and controllability, enabling it to better understand the first correction prompts and generate targeted and accurate first correction text during the text correction process. This, in turn, better assists in generating first text that matches the first task information.
[0098] In this embodiment, the second language model can be a large model independent of the first language model. In this case, the second language model acts as a tutor, assisting the first language model by collaborating with it to enable the first language model to better perform the target text task and generate first text that matches the first task information.
[0099] Of course, the first language model itself can also serve as a second language model for correction. In this case, the first language model can self-correct through "introspection," similar to a human writing a draft and then reading it again to consider and revise many issues. Because the first language model understands the first language very well and has strong reasoning capabilities, correcting the text it generates through "introspection" can stimulate its self-reflection ability and achieve text correction functionality.
[0100] S106, Based on the first correction text and the first task prompt word, determine the second task prompt word.
[0101] S108, based on the second task prompt and the first role information, obtain the first text.
[0102] The second task prompt is better able to guide the generation of text that matches the information in the first task compared to the first task prompt.
[0103] In one implementation, such as Figure 2 As shown, S106 above includes the following steps: if the first correction text indicates that the first candidate text matches the first task information, then the first task prompt word is used as the second task prompt word.
[0104] In another embodiment, such as Figure 3As shown, S106 above includes the following steps: Step B1, generating a first candidate task prompt based on the first corrected text, the first task prompt word, and the first prompt template, wherein the first candidate task prompt word is used to indicate the correction of the first candidate text based on the first corrected text; Step B2, obtaining a second candidate text based on the first candidate task and the first role information; Step B3, correcting the second candidate text based on the first task information to obtain a second corrected text; Step B4, if the second corrected text indicates that the second candidate text matches the first task information, then the first candidate task prompt word is used as the second task prompt word. Correspondingly, in step S108 above, the second candidate text is used as the first text.
[0105] Of course, if the second correction text indicates that the second candidate text does not match the first task information, then step B5 is executed to correct the first candidate task prompt based on the second correction text. The specific implementation of step B5 is similar to the method of correcting the first task prompt based on the first correction text, and will not be described again.
[0106] Furthermore, the specific implementation of step B3 above is similar to the specific implementation of S104 above, and will not be repeated here.
[0107] For example, taking the target text task 1 mentioned above as an example, the first task prompt words are shown in Table 2, the first candidate text is shown in Table 4, and the first correction prompt words are shown in Table 7. Inputting the first correction prompt words into the second language model yields the first corrected text shown in Table 9 below.
[0108] Table 9
[0109]
[0110] Furthermore, based on the first corrected text, the first task prompt word, and the first prompt template shown in Table 10, the first candidate task prompt words shown in Table 11 are generated.
[0111] Table 10
[0112]
[0113] Table 11
[0114]
[0115]
[0116] Inputting the first candidate task prompts shown in Table 11 above into the first language model yields the second candidate text shown in Table 12 below.
[0117] Table 12
[0118]
[0119] Furthermore, based on the second candidate text and the first task information, a second correction prompt word is generated as shown in Table 13 below; the second correction prompt word is input into the second language model to obtain the second correction text as shown in Table 14 below.
[0120] Table 13
[0121]
[0122]
[0123] Table 14
[0124]
[0125] Since the second correction text indicates that the second candidate text meets the preset task requirements, the second task prompt word shown in Table 11 above is used as the target task prompt word, and the second candidate text shown in Table 12 above is used as the target text that meets the preset task requirements.
[0126] For example, taking the target text task 2 mentioned above as an example, the first task prompt words are shown in Table 3, the first candidate text is shown in Table 5, and the first correction prompt words are shown in Table 8. Inputting the first correction prompt words into the correction model yields the first corrected text shown in Table 15 below.
[0127] Table 15
[0128]
[0129]
[0130] Furthermore, based on the first corrected text, the first task prompt word, and the first prompt template shown in Table 10, the first candidate task prompt words shown in Table 16 are generated.
[0131] Table 16
[0132]
[0133] Inputting the first candidate task prompts shown in Table 16 above into the first language model yields the second candidate text shown in Table 17 below.
[0134] Table 17
[0135]
[0136]
[0137] Furthermore, based on the second candidate text and the first task information, a second correction prompt word is generated as shown in Table 18 below; the second correction prompt word is input into the second language model to obtain the second correction text as shown in Table 19 below.
[0138] Table 18
[0139]
[0140]
[0141] Table 19
[0142]
[0143] Since the second correction text indicates that the second candidate text matches the first task information, the first candidate task prompt word shown in Table 16 above is used as the second task prompt word, and the second candidate text shown in Table 17 above is used as the first text.
[0144] In this embodiment, when the first candidate text does not match the first task information, the first candidate task prompt is generated by combining the first corrected text, the first task prompt word, and the first prompt template. This helps to remind the first language model to avoid making similar mistakes when generating new text, thereby making targeted corrections to the generated text, eliminating the illusion problem and the problem that the generated text content does not match the scene, and achieving a better role-playing effect.
[0145] In yet another implementation, such as Figure 4 As shown, the above S106 may include the following steps: Step C1, generating a second candidate task prompt based on the first correction text, the first task prompt word, and the second prompt template, the second candidate task prompt word being used to indicate that the first correction text is being verified; Step C2, obtaining the verification text of the first correction text based on the second candidate task prompt word and the first role information; Step C3, correcting the first candidate text based on the verification text to obtain a third correction text; Step C4, if the third correction text indicates that the first candidate text matches the first task information, then using the first task prompt word as the second task prompt word.
[0146] For example, taking the target text task 1 mentioned above as an example, the first candidate text is shown in Table 4, and the first corrected text shown in Table 9 indicates that the first candidate text does not match the first task information. In this case, based on the first corrected text, the first task prompt words, and the second prompt template shown in Table 20, the second candidate task prompt words shown in Table 21 are generated.
[0147] Table 20
[0148]
[0149]
[0150] Table 21
[0151]
[0152] The specific process of the above-mentioned text verification execution steps C3 to C4 will not be repeated here.
[0153] Furthermore, such as Figure 4 As shown, the above S106 may further include the following steps: Step C5, if the third correction text indicates that the first candidate text does not match the first task information, then based on the third correction text, the first task prompt word, and the first prompt template, a third candidate task prompt word is generated, which is used to indicate the correction of the first candidate text based on the third correction text; Step C6, based on the third candidate task prompt word and the first role information, a third candidate text is obtained; Step C7, based on the first task information, the third candidate text is corrected to obtain a fourth correction text; Step C8, if the fourth correction text indicates that the third candidate text matches the first task information, then the third candidate task prompt word is determined as the second task prompt word. It is worth noting that the specific implementation process of the above steps C5 to C8 is similar to that described above. Figure 3 The specific implementation process of steps B1 to B4 in the illustrated embodiment is similar and will not be repeated here.
[0154] In this embodiment, if the first candidate text does not match the first task information, a second candidate task prompt is generated by combining the first correction text, the first task prompt word, and the second prompt template. This prompt word is used to indicate that the first correction text should be verified. Then, the first candidate text is corrected again by combining the verification text. This allows the first language model and the second language model to provide feedback and promote each other. Through continuous correction of the text generated by the first language model, it can be ensured that the first text generated by the first language model is more in line with the character's personalized style and the needs of the current scene. The illusion problem and the problem of the generated text not matching the scene are effectively overcome, thereby improving the execution effect of the target text task.
[0155] The text generation method provided in this application embodiment can be applied to real-time dialogue scenarios with business parties. The business party here can be a user or a related business system; this application embodiment does not limit this. In this dialogue scenario, before S102, the text generation method further includes: using the real-time input task prompt as the first task prompt. This allows for full utilization of contextual information and more targeted correction of the generated text to obtain a first text that matches the first task information. Correspondingly, after S108, the text generation method may further include: in response to a dialogue end command, clearing all dialogue data generated during the dialogue process, including the task prompt, the first candidate text, the first corrected text, the second task prompt, and the first text. This ensures the independence between two dialogues, preventing different dialogues from influencing each other and thus affecting the execution effect of the target text task.
[0156] One or more embodiments of this application provide a text generation method that introduces a correction mechanism. After generating a first candidate text based on a first task prompt and first role information, the first candidate text is not directly output. Instead, the correction mechanism is used to specifically correct whether the first candidate text matches the first preset task information, and then the first corrected text is output. Furthermore, based on the first corrected text and the first task prompt, the task prompt is rewritten in a targeted manner. The resulting second task prompt can better guide the execution of the text generation task, ensuring that the first text that matches the first task information is generated. This makes the first text accurate, consistent with the style of the first role information, and does not exceed the role's ability range, thus solving problems such as inaccurate text generated when performing text tasks and text content that does not match the scene.
[0157] Furthermore, in the process of generating candidate text using a first language model, the first language model, as a large model, also suffers from problems such as inaccurate generated text and text content that does not match the scene. Inaccuracy often manifests as illusion problems, such as factual illusions and fidelity illusions. Therefore, the text generation method of this application does not directly output the first candidate text generated by the first language model. Instead, it utilizes the comprehensive and efficient reasoning capabilities of a second language model to specifically correct the first candidate text based on the first task information, outputting a first corrected text. Further, based on the first corrected text and the first task prompts, the task prompts are rewritten in a targeted manner. The resulting second task prompts can better guide the first language model to output text that matches the first task information, ensuring that the generated text is not only accurate but also consistent with the style of the first character information and does not exceed the character's capabilities. This solves the problems of illusion problems and inconsistencies between the generated text content and the scene that occur when the first language model performs text tasks.
[0158] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0159] Based on the same inventive concept, this application also provides a text generation device. Figure 5 This is a schematic diagram of a text generation apparatus provided in one embodiment of this application. Please refer to... Figure 5 In one software implementation, the text generation device 400 may include: a first generation unit 510, a correction unit 520, a determination unit 530, and a second generation unit 540.
[0160] The first generation unit 510 is used to obtain the first candidate text based on the first task prompt word and the first role information.
[0161] The correction unit 520 is used to correct the first candidate text based on the first task information to obtain the first corrected text.
[0162] The determining unit 530 is used to determine the second task prompt word based on the first corrected text and the first task prompt word.
[0163] The second generation unit 540 is used to obtain the first text based on the second task prompt word and the first role idea.
[0164] In another embodiment, the correction unit is configured to: generate a first correction prompt word based on the first task information and the first candidate text; and correct the first candidate text based on the first correction prompt word to obtain a first corrected text.
[0165] In another embodiment, when the correction unit generates a first correction prompt word based on the first task information and the first candidate text, it performs the following steps: generating correction task information based on the first task information and the first candidate text; filling the correction task information and the second role information into the correction prompt template to obtain the first correction prompt word.
[0166] In another embodiment, when the correction unit generates correction task information based on the first task information and the first candidate text, it performs the following steps: performing fusion processing on the first task information and the first candidate text to obtain fused text; determining candidate correction task information for the first candidate text based on the first task type; and generating the correction task information based on the fused text and the candidate correction task information.
[0167] In another embodiment, the determining unit is configured to: generate a first candidate task prompt based on the first corrected text, the first task prompt word, and the first prompt template, wherein the first candidate task prompt word is used to indicate that the first candidate text should be corrected based on the first corrected text; obtain a second candidate text based on the first candidate task prompt word and the first role information; correct the second candidate text based on the first task information to obtain a second corrected text; and if the second corrected text indicates that the second candidate text matches the first task information, then use the first candidate task prompt word as the second task prompt word.
[0168] In another embodiment, the determining unit is configured to: generate a second candidate task prompt based on the first corrected text, the first task prompt word, and the second prompt template, wherein the second candidate task prompt word is used to indicate that the first corrected text is validated; obtain a validated text of the first corrected text based on the second candidate task prompt word and the first role information; correct the first candidate text based on the validated text to obtain a third corrected text; and if the third corrected text indicates that the first candidate text matches the first task information, then use the first task prompt word as the second task prompt word.
[0169] In another embodiment, the determining unit is further configured to: if the third corrected text indicates that the first candidate text does not match the first task information, generate a third candidate task prompt based on the third corrected text, the first task prompt word, and the first prompt template, wherein the third candidate task prompt word is used to indicate that the first candidate text should be corrected based on the third corrected text; obtain a third candidate text based on the third candidate task prompt word and the first role information; correct the third candidate text based on the first task information to obtain a fourth corrected text; if the fourth corrected text indicates that the third candidate text matches the first task information, determine the third candidate task prompt word as the second task prompt word.
[0170] In another embodiment, the text generation device further includes: a receiving unit, configured to use a real-time input task prompt word as the first task prompt word; and a clearing unit, configured to, in response to a dialogue end command, clear the task prompt word, the first candidate text, the first corrected text, the second task prompt word, and the first text after the second generation unit obtains a first text matching the first task information based on the second task prompt word and the first role information.
[0171] In another embodiment, the first candidate text is generated using a first language model, the first task prompt word, and the first role information, wherein the first language model is trained based on sample task prompt words, sample role information, and sample text; and / or, the first corrected text is obtained by correcting the first candidate text using a second language model and the first preset task information, wherein the second language model is trained based on sample corrected prompt words and sample corrected text.
[0172] Obviously, the text generation apparatus provided in this application embodiment can serve as... Figure 1 The execution body of the text generation method shown, for example Figure 1 In the text generation method shown, step S102 can be performed by... Figure 5 The first generation unit 510 in the text generation device shown executes step S104, which can be performed by... Figure 5 The correction unit 520 in the text generation device shown executes step S106, which can be performed by... Figure 5 The determination unit 530 in the text generation device shown is executed, and step S108 can be performed by... Figure 5 The second generation unit 540 in the text generation device shown is executed.
[0173] According to another embodiment of this application, Figure 5 The various modules in the text generation device shown can be individually or entirely merged into one or more other modules, or some of the modules can be further divided into multiple functionally smaller modules. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above modules are based on logical function division. In practical applications, the function of one module can be implemented by multiple modules, or the function of multiple modules can be implemented by one module. In the embodiments of this application, the text generation device may also include other modules. In practical applications, these functions can also be implemented with the assistance of other modules, and can be implemented collaboratively by multiple modules.
[0174] According to another embodiment of this application, a general-purpose computing device, such as a computer, including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can run an application capable of performing tasks such as... Figure 1 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 5 The text generation apparatus shown herein, and the text generation method for implementing the embodiments of this application, are described. The computer program may be recorded on, for example, a computer-readable storage medium, and may be transferred to and run in an electronic device via such a medium.
[0175] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Please refer to it. Figure 6 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and memory. The memory may include main memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for other business operations.
[0176] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0177] Memory is used to store programs. Specifically, programs may include program code, which includes computer operation instructions. Memory may include main memory and non-volatile memory, and provides instructions and data to the processor.
[0178] The processor reads the corresponding computer program from non-volatile memory into memory and then runs it, forming a text generation device at the logical level. The processor executes the program stored in memory and specifically performs the following operations: obtaining a first candidate text based on a first task prompt word and first role information; correcting the first candidate text based on the first task information to obtain a first corrected text; determining a second task prompt word based on the first corrected text and the first task prompt word; and obtaining the first text based on the second task prompt word and the first role information.
[0179] The above is as stated in this application. Figure 1 The text generation device disclosed in the illustrated embodiments can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0180] The electronic device can also perform Figure 1 The method, and implement the text device in Figures 1 to 4 The functions of the embodiments shown are not described in detail here.
[0181] Of course, in addition to software implementation, the electronic device of this application does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0182] This application also proposes a computer-readable storage medium that stores one or more programs, the programs including instructions that, when executed by a portable electronic device including multiple applications, enable the portable electronic device to perform... Figure 1 The method of the illustrated embodiment is specifically used to perform the following operations: obtaining a first candidate text based on a first task prompt word and first role information; correcting the first candidate text based on the first task information to obtain a first corrected text; determining a second task prompt word based on the first corrected text and the first task prompt word; and obtaining the first text based on the second task prompt word and the first role information.
[0183] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps in the text generation method provided in this application.
[0184] In summary, the above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
[0185] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0186] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0187] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. The various embodiments in this specification are described in a progressive manner, and similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the description of the method embodiments.
Claims
1. A text generation method, characterized in that, include: The first candidate text is obtained based on the first task prompt and the first role information; Based on the first task information, the first candidate text is corrected to obtain the first corrected text; Based on the first corrected text and the first task prompt word, determine the second task prompt word; Based on the second task prompt and the first role information, the first text is obtained.
2. The method according to claim 1, characterized in that, The step of correcting the first candidate text based on the first task information to obtain the first corrected text includes: Based on the first task information and the first candidate text, a first correction prompt word is generated; The first candidate text is corrected based on the first correction prompt word to obtain the first corrected text.
3. The method according to claim 2, characterized in that, The step of generating a first correction prompt word based on the first task information and the first candidate text includes: Based on the first task information and the first candidate text, generate correction task information; The correction task information and the second role information are filled into the correction prompt template to obtain the first correction prompt word.
4. The method according to claim 3, characterized in that, The step of generating correction task information based on the first task information and the first candidate text includes: The first task information and the first candidate text are fused together to obtain the fused text. Based on the first task type, determine the candidate correction task information for the first candidate text; The correction task information is generated based on the fused text and the candidate correction task information.
5. The method according to claim 1, characterized in that, The step of determining the second task prompt word based on the first corrected text and the first task prompt word includes: Based on the first corrected text, the first task prompt word, and the first prompt template, a first candidate task prompt word is generated. The first candidate task prompt word is used to indicate the correction of the first candidate text based on the first corrected text. Based on the first candidate task prompt and the first role information, the second candidate text is obtained; Based on the first task information, the second candidate text is corrected to obtain the second corrected text; If the second correction text indicates that the second candidate text matches the first task information, then the first candidate task prompt word is used as the second task prompt word.
6. The method according to claim 1, characterized in that, The step of determining the second task prompt word based on the first corrected text and the first task prompt word includes: Based on the first correction text, the first task prompt word, and the second prompt template, a second candidate task prompt word is generated. The second candidate task prompt word is used to indicate that the first correction text is to be verified. Based on the second candidate task prompt and the first role information, the verification text of the first correction text is obtained; Based on the verification text, the first candidate text is corrected to obtain the third corrected text; If the third correction text indicates that the first candidate text matches the first task information, then the first task prompt word is used as the second task prompt word.
7. The method according to claim 6, characterized in that, The step of determining the second task prompt word based on the first corrected text and the first task prompt word further includes: If the third correction text indicates that the first candidate text does not match the first task information, then a third candidate task prompt is generated based on the third correction text, the first task prompt word, and the first prompt template. The third candidate task prompt word is used to indicate that the first candidate text should be corrected based on the third correction text. Based on the third candidate task prompt and the first role information, the third candidate text is obtained; Based on the first task information, the third candidate text is corrected to obtain the fourth corrected text; If the fourth correction text indicates that the third candidate text matches the first task information, then the third candidate task prompt word is determined as the second task prompt word.
8. The method according to claim 1, characterized in that, Before obtaining the first candidate text based on the first task prompt word and the first role information, the method further includes: Use the real-time input task prompt as the first task prompt; After obtaining the first text matching the first task information based on the second task prompt word and the first role information, the method further includes: In response to the dialogue end command, the task prompt word, the first candidate text, the first correction text, the second task prompt word, and the first text are cleared.
9. The method according to any one of claims 1 to 8, characterized in that, The first candidate text is generated using a first language model, the first task prompt word, and the first role information. The first language model is trained based on sample task prompt words, sample role information, and sample text. And / or, The first corrected text is obtained by correcting the first candidate text using a second language model and the first preset task information. The second language model is trained based on sample correction prompts and sample corrected text.
10. A text generation device, characterized in that, include: The first generation unit is used to obtain the first candidate text based on the first task prompt word and the first role information; A correction unit is configured to correct the first candidate text based on the first task information to obtain a first corrected text; The determining unit is configured to determine a second task prompt word based on the first corrected text and the first task prompt word; The second generation unit is used to obtain the first text based on the second task prompt word and the first role idea.
11. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the text generation method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the text generation method as described in any one of claims 1 to 9.
13. A computer program product, characterized in that, The computer program product includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps in the text generation method as claimed in any one of claims 1 to 9.