Text generation method, text model training method, electronic equipment, storage medium and program product
By introducing training samples and reply data samples with word count requirements in large language models, fine-tuning the model to generate text with a specific word count, solving the problem that existing LLM cannot accurately control the word count of text, and achieving the satisfaction of word count requirements.
Patent Information
- Application Number
- CN202410963778.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2024-12-06
AI Technical Summary
Existing large language models (LLMs) are difficult to accurately meet user's word count requirements when generating text, and cannot generate text that meets a specific word count range.
By obtaining user input data, generating text generation requests, carrying subject information and word count requirements, using a general generative basic model for training, fine-tuning the model to generate text that meets specific word count requirements.
It realizes the accurate generation of text that meets the predetermined word count requirements based on user needs, and meets the user's personalized needs for text generation.
Smart Images

Figure CN119090001A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a text generation method, a text generation model training method, an electronic device, a computer storage medium, and a computer program product. Background Art
[0002] At present, machine learning models, such as LLM (Large Language Model), are playing an increasingly important role in people's work and life.
[0003] LLM is a model trained based on massive text data that can not only generate natural language text, but also deeply understand the meaning of text and handle various natural language tasks, such as text summarization, question answering, translation, etc. Although LLM itself has strong processing capabilities, its capabilities are generalized and cannot meet the personalized needs of users in some cases. For example, in some scenarios, users have requirements on the number of words in the text generated by LLM, which cannot be too many or too few. The current LLM and models similar to LLM cannot meet this requirement.
[0004] Therefore, how to accurately generate text that meets the word count requirements is a technical problem that needs to be solved. Summary of the invention
[0005] In view of this, embodiments of the present application provide a text generation method, a text generation model training method, an electronic device, a computer storage medium, and a computer program product to at least partially solve the above-mentioned problems.
[0006] According to a first aspect of an embodiment of the present application, a text generation method is provided, comprising: using user input data to generate a text generation request, and sending it to a server, wherein the text generation request carries subject information of a text to be generated and word count requirement information of the text to be generated; receiving text generated by a text generation model of the server in response to the text generation request, wherein the text is a text generated by the text generation model with the subject information in the input data as the subject and the number of words satisfying the number of words indicated by the word count requirement information, and the text generation model is obtained by training based on a general generative basic model.
[0007] According to a second aspect of an embodiment of the present application, a text generation method is provided, comprising: obtaining subject information of a text to be generated and word count requirement information of the text to be generated from a text generation request sent by a user device, and generating prompt information; inputting the prompt information into a text generation model, so as to generate a text with the subject information as the subject and the word count satisfying the word count indicated by the word count requirement information through the text generation model; wherein the text generation model is obtained based on a general generative basic model.
[0008] According to a third aspect of an embodiment of the present application, a method for training a line of text generation model is provided, comprising: obtaining a training sample for model training, the training sample comprising a prompt information sample and a corresponding reply data sample, the prompt information sample containing word count requirement information for a text to be generated, the word count of the reply data sample matching the word count indicated by the word count requirement information; inputting the prompt information sample into a universal generative basic model so that the universal generative basic model generates text based on the prompt information sample to obtain a text generation data sample; and fine-tuning the universal generative basic model at least according to the difference between the word count of the text generation data sample and the word count of the reply data sample to obtain a text generation model capable of generating text of a corresponding number of words according to the word count requirement information.
[0009] According to a fourth aspect of an embodiment of the present application, there is provided an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; the memory is used to store a computer program; the processor is used to execute any one of the methods described in the first aspect, the second aspect and the third aspect by running the computer program stored in the memory.
[0010] According to a fifth aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in any one of the first aspect, the second aspect, and the third aspect is implemented.
[0011] According to a sixth aspect of an embodiment of the present application, a computer program product is provided, including a computer program, which, when executed by a processor, implements the method described in any one of the first aspect, the second aspect, and the third aspect.
[0012] According to the text generation scheme provided in the embodiment of the present application, a text generation request can be generated according to the user's input data and sent to the server. The text generation request carries the subject information of the text to be generated and the word count requirement information of the text to be generated. Then, the text generated by the text generation model obtained based on the general generative basic model on the server in response to the text generation request is received. The text is a text generated by the text generation model with the subject information in the input data as the subject and the number of words meeting the number of words indicated by the word count requirement information. Therefore, through this scheme, the text generation model can be used to more accurately generate text that meets the predetermined word count requirement, thereby better meeting the user's needs for text generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0014] Figure 1 A schematic diagram of an exemplary system applicable to the embodiment scheme of the present application.
[0015] Figure 2 The present invention is a flowchart of the steps of a text generation model training method according to an embodiment of the present application.
[0016] Figure 3 This is an optional flowchart of a method for obtaining training samples in step S202 of an embodiment of the present application.
[0017] Figure 4 This is an optional flowchart of step S204 of an embodiment of the present application.
[0018] Figure 5 This is a flowchart of the steps of a text generation method according to an embodiment of the present application.
[0019] Fig. 6A for Figure 5 A schematic diagram of a human-computer interaction interface on a user device side in the illustrated embodiment.
[0020] Figure 6B for Figure 5 A schematic diagram of another human-computer interaction interface on the user equipment side in the illustrated embodiment.
[0021] Figure 6C for Figure 5 A schematic diagram of a human-computer interaction interface on a user device side in another embodiment is shown.
[0022] Figure 7 This is a flowchart of the steps of another text generation method according to an embodiment of the present application.
[0023] Figure 8 for Figure 7 An optional flow chart of step S704 in the illustrated embodiment.
[0024] Fig. 9 This is a scene example diagram according to an embodiment of the present application.
[0025] Fig.10 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0027] Figure 1 An exemplary system applicable to the embodiment of the present application is shown. Figure 1 As shown, the system 100 may include a cloud service end 102, a communication network 104 and / or one or more user devices 106. Figure 1 The example in FIG. 1 is a plurality of user devices.
[0028] The cloud server 102 may be any suitable device for storing information, data, programs and / or any other suitable type of content, including but not limited to distributed storage system devices, server clusters, computing cloud server clusters, etc. In some embodiments, the cloud server 102 may perform any suitable function. For example, in some embodiments, the cloud server 102 may implement a text generation model training method to obtain a trained text generation model. As an optional example, in some embodiments, the cloud server 102 may first obtain a training sample for model training, the training sample including a prompt information sample and a corresponding reply data sample, the prompt information sample including the word count requirement information of the text to be generated, and the word count of the reply data sample matches the word count indicated by the word count requirement information; then, the prompt information sample is input into the general generative basic model so that the general generative basic model generates text based on the prompt information sample to obtain a text generation data sample; thereafter, at least according to the difference between the word count of the text generation data sample and the word count of the reply data sample, the general generative basic model is fine-tuned and trained to obtain a text generation model that can generate a text of the corresponding word count according to the word count requirement information. In some embodiments, after the cloud service end 102 completes the training of the text generation model, it can implement a text generation method to generate text that meets the needs. As an optional example, in some embodiments, the cloud service end 102 can first generate prompt information based on at least the subject information of the text to be generated and the word count requirement information of the text to be generated carried in the text generation request sent by the user device 106; then, the prompt information is input into the text generation model to generate a text with the subject information as the subject and the word count meeting the word count requirement information through the text generation model, wherein the text generation model is obtained based on the general generative basic model. Optionally, after generating the text, the cloud service end 102 can return the generated text to the user device 106.
[0029] In some embodiments, the communication network 104 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 104 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN) and / or any other suitable communication network. The user device 106 can be connected to the communication network 104 via one or more communication links (e.g., communication link 112), and the communication network 104 can be linked to the cloud service end 102 via one or more communication links (e.g., communication link 114). The communication link can be any communication link suitable for transmitting data between the user device 106 and the cloud service end 102, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link, or any suitable combination of such links.
[0030] The user device 106 may include any one or more user devices suitable for presenting text, interacting with a user, etc. When the scheme of the embodiment of the present application is completed by the user device 106, the user device 106 may implement a text generation method to generate text that meets the needs. As an optional example, in some embodiments, the user device 106 may first generate a text generation request based on the user's input data, and send it to a server such as a cloud server 102, wherein the text generation request carries the subject information of the text to be generated and the word count requirement information of the text to be generated; the text generated by the text generation model of the receiving server such as the cloud server 102 in response to the text generation request, the text is a text generated by the text generation model with the subject information in the input data as the subject, and the number of words generated meets the number of words indicated by the word count requirement information, and the text generation model is obtained based on a general generative basic model. In some embodiments, the user device 106 may include any suitable type of device. For example, in some embodiments, the user device 106 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of user device. Optionally, a predetermined client program (such as a browser, etc.) can be installed on the user device 106, which can receive user input data through its human-computer interaction interface, so as to generate a text generation request based on the user input data and send it to a server such as the cloud server 102 through the client program.
[0031] Based on the above system, the embodiments of the present application provide a text generation scheme and a text generation model training scheme, which are described below through multiple embodiments.
[0032] To facilitate the description of the embodiments of the present application, the training method of the text generation model is first described here. Figure 2 1 is a flowchart of the steps of a text generation model training method according to an embodiment of the present application. Figure 2 As shown, the text generation model training method includes steps S202, S204, S206 and S208, specifically:
[0033] S202: Obtain training samples for model training.
[0034] The training samples include prompt information samples and corresponding reply data samples, the prompt information samples contain word count requirement information of the text to be generated, and the word count of the reply data samples matches the word count indicated by the word count requirement information.
[0035] The training sample may come from a training sample set, and a training sample includes a pair of a prompt information sample and a response data sample.
[0036] In the embodiment of the present application, during the model training process, the prompt information sample in the training sample is also called a prompt sample, which can enable the model to be trained to generate text to generate a text with the number of words indicated by the word count requirement information contained in the prompt information sample. The prompt information sample can include historical prompt information, or a prompt information sample generated in a certain way.
[0037] Optionally, the word count requirement information in the prompt information sample may be embodied in any style, which may specify a certain word count range or a specific word count. For example, as an example for easy understanding, the word count requirement information may include "generate a text within the range of 900 to 1000 words", or "generate a text of approximately 1000 words", or "generate a text of 1000 words". For example, the form of "approximately 1000 words" may be 1000±a words, and a may be selected as needed, such as taking a as 50 as an example.
[0038] In an embodiment of the present application, during the model training process, the reply data sample in the training sample can be used as a supervised condition for supervised training, so as to calculate the loss with the text generation data sample generated by the model prediction, and then perform model training based on the calculation results, including but not limited to adjusting the model parameters, etc. The number of words in the reply data sample matches the number of words indicated by the word requirement information in the prompt information sample. For example, taking the word requirement information of the above prompt information sample as "generating a text within the range of 900 to 1000 words" as an example, the number of words in the corresponding reply data sample can be within 900 to 1000 words; taking the word requirement information of the above prompt information sample as "generating a text of about 1000 words" as an example, the number of words in the corresponding reply data sample can be within 950 to 1050 words (only as an example); taking the word requirement information of the above prompt information sample as "generating a text of 1000 words", the number of words in the corresponding reply data sample can be 1000 words. The text generation model to be trained generates text according to the prompt information sample in the training sample, and then calculates the loss value, i.e., the difference between the two, based on the number of words in the generated text (i.e., the text generation data sample) and the number of words in the reply data sample according to the preset loss function, and adjusts the model parameters according to the loss value. This process is iteratively executed until the training termination condition is met, such as reaching a preset number of training times, or the loss value reaches a preset threshold, etc. Among them, the loss function used in the embodiment of the present application can be set by those skilled in the art according to actual needs, including but not limited to the cross entropy loss function, etc. The embodiment of the present application does not limit the specific implementation of the loss function.
[0039] In some optional embodiments, a general generative basic model can be used as a basis to obtain the required text generation model by fine-tuning and training it. In some implementations, the general generative basic model can adopt a large language model (Large Language Model, LLM for short). The large language model LLM itself has powerful text understanding and generation capabilities, and after proper training, it can effectively meet the text generation requirements. In the embodiment of the present application, the general generative basic model is trained by inputting training samples, and after the training is completed, a text generation model that can generate text that meets the word count requirement is obtained.
[0040] Optionally, refer to Figure 3 As shown in the flowchart, the method of obtaining training samples in step S202 may include steps S2021 and S2022, specifically:
[0041] S2021: Obtain training sample groups from a training sample set used for model training, each training sample group includes multiple training samples, and the multiple training samples include multiple prompt information samples and multiple reply data samples corresponding to the multiple prompt information samples. Among the multiple prompt information samples in the same group, except for the word count requirement information, other information is the same.
[0042] The training sample set may include multiple training sample groups. Optionally, for any training sample group, each of the multiple training samples includes a prompt information sample and a reply data sample corresponding to the prompt information sample. In the training sample group, the multiple prompt information samples have the same information except for the word count requirement information. For example, the other information may include the subject information of the text to be generated or the content requirement information.
[0043] Optionally, multiple training sample groups can be obtained from the training sample set. For example, the multiple training sample groups are 2 groups, namely training sample groups A1 and A2. In the prompt sample information of each training sample in the training sample group A1 (for example, a total of n training samples), the word count requirement information is X1, ..., Xn, and the subject information can be B1. In the prompt sample information of each training sample in the training sample group A2 (for example, a total of m training samples), the word count requirement information is Y1, ..., Ym, and the subject information can be B2. In a specific example, it is assumed that a training sample group contains 3 training samples, and the subject information in the 3 training samples is the same, but the word count requirement information is different. For example, training sample 01 is "Please write a text related to XXX, with a word count of about 2000 words"; training sample 02 is "Please write a text related to XXX, with a word count of about 5000 words"; "Please write a text related to XXX, with a word count of about 7000 words". It can be seen that in this group of training samples, the word count requirement information is different, but other information is the same.
[0044] S2022: Taking the training sample group as a unit, sequentially obtain multiple training samples in the same training sample group for training the general generative basic model.
[0045] The obtained training sample group can be used for subsequent model training. An exemplary method can be referred to the relevant description in step S204 below, which will not be described in detail here.
[0046] It should be understood that based on the optional implementation methods of steps S2021 to S2022 above, in the present application, multiple training samples in the same training sample group can be obtained in sequence based on the training sample group, so as to facilitate subsequent model training. Among the multiple prompt information samples in the same group of training samples, except for the different word count requirement information, other information is the same. Therefore, in the subsequent model training process, multiple training samples in the same training sample group can be used in sequence, and the general generative basic model can be trained in a targeted manner with different word count requirement information by controlling variables, so that the model can be more sensitive to word count information, so that when using the trained text generation model to generate text, it can more accurately generate text that meets the predetermined word count requirement, thereby meeting the user's needs for text generation.
[0047] S204: Inputting the prompt information sample into the general generative basic model, so that the general generative basic model generates text based on the prompt information sample, and obtaining a text generation data sample.
[0048] Optionally, after obtaining a training sample for model training, the prompt information sample in the training sample can be input into the general generative basic model, so that the general generative basic model generates text based on the prompt information sample to obtain a text generation data sample.
[0049] Optionally, multiple training samples in the same training sample group can be obtained in sequence, with the training sample group as the unit. For each training sample in the multiple training samples, the prompt information sample in the training sample is input into the general generative basic model, so that the general generative basic model generates text based on the prompt information sample in the training sample to obtain the corresponding text generation data sample.
[0050] For example, taking the above-mentioned training sample groups A1 and A2 as examples, for the training sample group A1, multiple training samples in the training sample group A1 can be obtained in sequence, and the general generative basic model can be trained in sequence using multiple prompt sample information of the word count requirement information X1, ..., Xn and the response data samples C1, ..., Cn corresponding to the multiple prompt sample information respectively; and then for the training sample group A2, multiple training samples in the training sample group A2 can be obtained in sequence, and the general generative basic model can be trained in sequence using multiple prompt sample information of the word count requirement information Y1, ..., Ym and the response data samples D1, ..., Dm corresponding to the multiple prompt sample information respectively.
[0051] For example, taking the above-mentioned training sample groups A1 and A2 as examples, for the training sample group A1, the prompt sample information including the word count requirement information X1, ..., Xn can be obtained in sequence, and the information can be input into the general generative basic model in sequence. The general generative basic model generates text generation data samples P1, ..., Pn in sequence based on the prompt sample information including the word count requirement information X1, ..., Xn; for the training sample group A2, the prompt sample information including the word count requirement information Y1, ..., Yn can be obtained in sequence, and the information can be input into the general generative basic model in sequence. The general generative basic model generates text generation data samples Q1, ..., Qm in sequence based on the prompt sample information including the word count requirement information Y1, ..., Ym.
[0052] In some optional embodiments, referring to Figure 4 As shown in the flowchart, the above step S204 may include the following steps S2041 to S2042, specifically:
[0053] S2041: Inputting the prompt information sample into the general generative basic model, and extracting the word count requirement information and the semantic information of the prompt information sample in the prompt information sample through the general generative basic model.
[0054] The general generative basic model such as LLM itself has a strong text understanding ability and can extract semantic information from the text. For example, taking the above-mentioned prompt information sample containing the word count requirement information X1 as an example, the prompt sample information can be input into the general generative basic model (such as LLM), and the prompt sample information is analyzed by the general generative basic model to obtain the corresponding word count requirement information X1 and the semantic information of the prompt information sample. The same is true for other prompt sample information.
[0055] For example, if the input data is "Please write a text about XXX, with about 7,000 words", the generated prompt information also contains the above information. For the general generative basic model, after receiving the prompt information, on the one hand, it extracts the word requirement information "about 7,000 words" from it; on the other hand, it obtains the semantic information of "Please write a text about XXX", such as "Generate a text about XXX". Subsequently, the generation process will be performed based on these two parts of information.
[0056] S2042: Generate text based on semantic information using a general generative basic model and the number of words indicated by the word count requirement information to obtain a text generation data sample.
[0057] Still taking the above-mentioned prompt information sample containing the word count requirement information X1 as an example, during model training, the general generative basic model's text generation capability is used to generate text according to the word count requirement information X1 based on the semantic information of the prompt information sample, and obtain the text generation data sample P1. The other prompt sample information is similar, and the text generation data samples P2, ..., Pn, and the text generation data samples Q1, ..., Qm are obtained when needed.
[0058] Based on this, through the optional implementation methods of the above steps S2041 to S2042, it is possible to effectively generate text based on prompt information samples through a generative language model to obtain text generation data samples, so as to facilitate the subsequent further model training process, and obtain a text generation model that can generate text with a corresponding number of words according to the word count requirement information, so as to use the text generation model to more accurately generate text that meets the predetermined word count requirement, and better meet the user's needs for text generation.
[0059] S206: Fine-tune the general generative basic model at least according to the difference between the number of words in the text generation data sample and the number of words in the response data sample, to obtain a text generation model that can generate text of a corresponding number of words according to the word count requirement information.
[0060] After the general generative basic model generates a text generation data sample, it can be processed by word count, including but not limited to obtaining the word count of the text generation data sample by writing and running a program, calling an API interface for word count, etc. Then, based on the word count and the word count of the reply data sample, a loss value (i.e., the difference between the word count of the text generation data sample and the word count of the reply data sample) is calculated by a preset loss function such as a cross entropy loss function, and then the general generative basic model is fine-tuned based on the loss value.
[0061] According to the difference between the number of words in the text generation data sample and the number of words in the response data sample, the general generative base model is fine-tuned and trained to adjust the model parameters of the general generative base model. After the training end conditions are met, a text generation model is obtained that can generate text of the corresponding number of words according to the word count requirement information.
[0062] Optionally, the training end condition can be set as needed. For example, the training end condition can be that when a predetermined number of training times is reached, the training end condition can be considered to be reached, thereby terminating the model training process. Alternatively, the training end condition can also be that when the loss value calculated by a preset loss function is within a preset loss value range, the training end condition can be considered to be reached, thereby terminating the model training process.
[0063] Based on this, an optional implementation method of the above steps S202 to S206 in the embodiment of the present application is to obtain training samples for model training, the training samples include prompt information samples and corresponding reply data samples, the prompt information samples contain word count requirement information for the text to be generated, the number of words in the reply data sample matches the number of words indicated by the word count requirement information, and then the prompt information samples are input into the general generative basic model so that the general generative basic model generates text based on the prompt information samples to obtain text generation data samples, and then fine-tune the general generative basic model at least according to the difference between the number of words in the text generation data sample and the number of words in the reply data sample, so as to obtain a text generation model that can generate text of the corresponding number of words according to the word count requirement information. Using this text generation model, text that meets the predetermined word count requirement can be generated more accurately, thereby better meeting the user's needs for text generation.
[0064] In some optional embodiments, the method of fine-tuning the above step S206 may include: fine-tuning the general generative basic model according to the difference between the content of the text generation data sample and the content of the reply data sample, and the difference between the number of words in the text generation data sample and the number of words in the reply data sample.
[0065] Optionally, the difference between the content of the text generation data sample and the content of the reply data sample may be a difference in semantic information between the content of the text generation data sample and the content of the reply data sample.
[0066] For example, in the model training process, the fine-tuning training process of the above-mentioned text data sample P1 and the reply data sample C1 can be used for illustrative understanding. Then, the general generative basic model can be fine-tuned according to the difference between the content of the text generation data sample P1 and the content of the reply data sample C1, and the difference between the number of words of the text generation data sample P1 and the number of words of the reply data sample C1; with reference to the fine-tuning training process of P1 and C1, the text generation data samples and reply data samples generated by other training samples can be used, and after multiple fine-tuning trainings, the model training is completed to obtain a text generation model that can generate a text of the corresponding number of words according to the word count requirement information, and the text can meet the predetermined content requirements.
[0067] It should be understood that through the above-mentioned optional implementation manner, the general generative basic model is fine-tuned and trained according to the difference between the content of the text generation data sample and the content of the reply data sample, as well as the difference between the number of words in the text generation data sample and the number of words in the reply data sample, and a text generation model is obtained after the training is completed. The text generation model can be used to accurately generate text that meets the predetermined word count requirements and meets the predetermined content requirements, thereby better meeting the user's needs for text generation.
[0068] In some optional embodiments, the text generation model training method of the embodiments of the present application also includes: updating the word count requirement information in the prompt information sample according to the word count of the text generation data sample; generating a new training sample based on the prompt information sample and the text generation data sample after the word count requirement information is updated.
[0069] Optionally, the prompt information sample after the word count requirement information is updated can be determined as a new prompt information sample, and the text generation data sample can be determined as a new reply data sample. Then, the new prompt information sample and the new reply data sample can be determined as new training samples, and the model training can be continued through the new training samples. In this way, the effective expansion of the training samples is achieved, and the generated data of the model can be used. The word count requirement information of the generated training samples is relatively accurate, which greatly reduces the cost of obtaining the training samples.
[0070] Based on this, in the present application, the word count requirement information in the prompt information sample is updated according to the word count of the text generation data sample, and new training samples are generated based on the prompt information sample and the text generation data sample after the word count requirement information is updated. On the one hand, the training samples can be enriched and the effect of model training can be improved; on the other hand, the new training samples obtained can be used to realize adversarial training of the general generative basic model. The training process is conducive to gradually improving the accuracy of the general generative basic model in generating texts that meet the preset word count requirements, so that the text generation model obtained after the training is able to more accurately generate texts that meet the predetermined word count requirements and the predetermined content requirements in the inference stage, thereby better meeting the user's needs for text generation.
[0071] It is understandable that the above description of the text generation model training method is only an exemplary description of the present application and does not constitute any limitation to the present application.
[0072] The text generation method of the embodiment of the present application is described below. Figure 5 As shown in the flowchart, this embodiment describes the text generation method from the perspective of the user device. The text generation method of this embodiment includes the following steps S502 and S504, specifically:
[0073] S502: Generate a text generation request using the user's input data and send it to the server. The text generation request carries the subject information of the text to be generated and the word count requirement information of the text to be generated.
[0074] The text generation method of the embodiment of the present application can be used for user equipment 106. The above-mentioned input data may include relevant information such as the user's requirements for the subject and word count of the text to be generated. After receiving the user's input data, the user equipment 106 can analyze the user's input data and generate a corresponding text generation request based on the input data, so that the text generation request carries the subject information of the text to be generated and the word count requirement information of the text to be generated. After obtaining the text generation request, the text generation request can be sent to the server (which can be the cloud server 102), and the server generates the text in response to the text generation request.
[0075] The user may input the above input data in any manner. Optionally, a predetermined client program may be installed on the user device 106, and a human-computer interaction interface for inputting data may be provided in the client program, and the user may input the above input data in the human-computer interaction interface by means including but not limited to typing input, voice input, copy and paste input, material dragging, etc.
[0076] Optionally, the subject information of the text to be generated may indicate the subject of the text to be generated, which is the central idea of the text to be generated and can describe the main content of the text to be generated.
[0077] In some optional embodiments, the implementation method of generating a text request based on user input data in step S502 may include: receiving input data input by the user through a text input box in a human-computer interaction interface, which contains subject information and word count requirement information of the text to be generated, and generating a text generation request based on the input data.
[0078] For example, refer to Fig. 6A The human-computer interaction interface of the example can be understood as the human-computer interaction interface of the client program on the user device 106, which includes a text input box. The user can input input data including the subject information and word count requirement information of the text to be generated into the text input box by typing, voice input, copying and pasting, etc. After the input is completed, the user device 106 can obtain the input data and generate a corresponding text generation request based on the input data.
[0079] For example, in an easy-to-understand example, if a user wants to generate a 10,000-word text with the main content of "Application of artificial intelligence in new media creation", he can Fig. 6AThe text input box inputs something like: "Please generate an article with the theme of "Application of Artificial Intelligence in New Media Creation", and the required word count is 10,000 words", so as to complete the input of the input information. When the user clicks the "Generate Article Directly" button in the interface, the article, that is, a long text of 10,000 words, will be generated directly based on the above input data according to the requirement of 10,000 words. If the user clicks "Generate Reference Outline" in the interface, a text outline will be generated first, and after the user confirms, a long text of 10,000 words will be generated based on the text outline. Of course, this example does not serve as any limitation to the present application.
[0080] Based on this, through the above-mentioned optional method, it is convenient for users to input input data containing the subject information and word count requirement information of the text to be generated through the text input box, so that the text generation request generated according to the input data can effectively carry the subject information of the text to be generated and the word count requirement information of the text to be generated, so as to facilitate the subsequent generation of text that meets the predetermined word count requirement, thereby better meeting the user's needs for text generation.
[0081] In other optional embodiments, the implementation method of using the user's input data to generate a text request in step S502 may include: receiving input data input by the user through the text input box in the human-computer interaction interface, which contains subject information of the text to be generated, and receiving the user's selection operation for multiple word count options displayed in the human-computer interaction interface, and determining the word count requirement information of the text to be generated based on the selection operation; using the input data and the word count requirement information to generate a text generation request.
[0082] For example, refer to Figure 6B The human-computer interaction interface of the example in the figure can be a human-computer interaction interface of a client program on the user device 106, which includes a text input box and multiple word count options. The user can input the input data containing the subject information of the to-be-generated text into the text input box by typing, voice input, copying and pasting input, etc., and then select the number of words required for the to-be-generated text from multiple word count options. The user device 106 can determine the word count requirement information of the to-be-generated text according to the word count option selected by the user, and then the user device 106 can generate a text generation request according to the input data and the word count requirement information.
[0083] Optionally, the plurality of word count options may include a fixed word count option (eg Figure 6B , "500 words", "1000 words", etc.), and may also include word range options (e.g. Figure 6B The "2500 words or more" option shown above) may also include a word count input option (e.g. Figure 6BThe "input word count" option shown), the word count input option allows the user to freely input the word count based on the selected operation to further meet the user's text generation needs.
[0084] For example, in an easy-to-understand example, if a user wants to generate a 1,000-word text with the main content of "Application of artificial intelligence in new media creation", he can Figure 6B Enter the text input box of the subject information similar to: "Application of artificial intelligence in new media creation" and click Figure 6B The "1000 words" word count option is selected to complete the input of the input data and word count requirement information. Of course, this example is not intended to be any limitation to this application.
[0085] Based on this, through the above-mentioned optional method, it is convenient for users to input input data containing the subject information of the text to be generated through the text input box, and it is convenient for users to input the word count requirement information through the selection operation of the word count option, so that the text generation request generated according to the input data and the word count requirement information can effectively carry the subject information of the text to be generated and the word count requirement information of the text to be generated, so as to facilitate the subsequent generation of text that meets the predetermined word count requirement, thereby better meeting the user's needs for text generation.
[0086] S504: Receive text generated by the text generation model of the server in response to the text generation request, where the text is generated by the text generation model with the subject information in the input data as the subject and the number of words meeting the number of words indicated by the word requirement information.
[0087] Among them, as mentioned above, the text generation model is obtained by fine-tuning training based on the general generative basic model.
[0088] In the embodiment of the present application, the server (including but not limited to Figure 1 After receiving the text generation request sent by the user device, the cloud service end shown in the figure can generate the corresponding text in response to the text generation request through the text generation model. When generating text, the text generation model generates the content of the text based on the subject information carried in the text generation request, and generates text that meets the number of words indicated by the word requirement information based on the word requirement information carried in the text generation request, so as to accurately generate the text required by the user with the predetermined word requirement and subject requirement, and better meet the user's demand for text generation.
[0089] Optionally, the server may generate prompt information based on at least the subject information of the text to be generated and the word count requirement information of the text to be generated carried in the text generation request sent by the user device; and then input the prompt information into the text generation model to generate a text with the subject information as the subject and the word count meeting the word count requirement information through the text generation model. Afterwards, the server may send the generated text to the user device.
[0090] Based on this, through the text generation method of the above steps S502 to S504, a text generation request can be generated according to the user's input data and sent to the server. The text generation request carries the subject information of the text to be generated and the word count requirement information of the text to be generated. Then, the text generated by the text generation model of the server in response to the text generation request is received. The text is a text generated by the text generation model with the subject information in the input data as the subject and the number of words satisfying the number of words indicated by the word count requirement information. Therefore, through this solution, the text generation model can be used to more accurately generate text that meets the predetermined word count requirement, thereby better meeting the user's needs for text generation.
[0091] Optionally, the text generation method in the embodiment of the present application also includes: receiving text material associated with the subject information input by the user. Optionally, the text material can be of any type, and can adopt text materials of any type including but not limited to word, pdf, txt, ppt, excel, etc., and the text material can also adopt pictures including text in image content, etc. The text material records the text content related to the subject information, which can assist the text generation model in text generation. For example, the text generation model can generate text based on the text content in the text material. The text content in the text material can be passed to the text generation model by directly splicing with the input data, such as by carrying the prompt information. But not limited to this, other methods that can be passed to the text generation model are also applicable.
[0092] In some other optional embodiments, the implementation method of generating a text request according to the user's input data in step S502 may include: generating a text generation request according to the user's input data and the text material. On this basis, the text generated by the server may be a text generated by a text generation model based on the subject information in the input data and the text material, and the number of words meets the number of words indicated by the word requirement information.
[0093] Optionally, refer to Figure 6CThe human-computer interaction interface of the example can be understood as the human-computer interaction interface of the client program on the user device 106, which also includes a material input box. The user can add text materials through the material input box (the text materials can be added by dragging them in, or by clicking and selecting them), and can also input the above-mentioned input data in any optional way to generate a text generation request based on the user's input data and text materials.
[0094] Optionally, the server may generate prompt information based on at least the subject information, word count requirement information, and text material carried in the text generation request sent by the user device, and then input the prompt information into the text generation model to generate a text with the subject information as the subject, generated based on the text material, and the word count meeting the word count indicated by the word count requirement information through the text generation model. Afterwards, the server may send the generated text to the user device.
[0095] For example, an example application scenario of generating text through text materials may be that the user wishes to generate text containing the main internal part of a certain article or semantic information or key information, etc., then some reference example articles may be found and input as text materials associated with the subject information to generate a text generation request, so that the text generation model realizes text generation according to the subject information, text materials, and word count requirement information. It should be understood that this example application scenario does not serve as any limitation to the embodiments of the present application.
[0096] It should be understood that in the present application, the text material associated with the subject information input by the user can enable the text generation model to take the subject information in the input data as the subject, and refer to the content of the text material to generate a text with a word count that meets the word count requirement information. This allows the generated text to not only meet the predetermined word count requirement, but also be more consistent with the text material in terms of content, thereby better meeting the user's needs for text generation.
[0097] Optionally, the text generation method in the embodiment of the present application further includes: receiving writing requirement information input by the user. Optionally, the writing requirement information can indicate the writing requirements of the text to be generated, which is intended to indicate a series of regulations, guidelines or expected standards that need to be followed in the text to be generated, and can include other writing requirements besides the word count requirement, which can be used as limiting conditions for generating text. For example, the generated text is required to have clear logic, a certain timeliness of content, and the core ideas are supported by necessary data and factual evidence, etc. Figure 6C As shown in , the user can input the writing requirements through the writing requirements input box in the human-computer interaction interface of the client program on the user device 106 .
[0098] In some further optional embodiments, the implementation of generating a text request according to the user's input data in step S502 may include: generating a text generation request according to the user's input data and writing requirement information. On this basis, the text generated by the server may be a text generated by a text generation model with the subject information in the input data as the subject, and in accordance with the writing requirement information and the word count requirement information.
[0099] Optionally, the user can input writing requirement information through the text input box of the human-computer interaction interface. Figure 6C The human-computer interaction interface can be understood, and the input data and writing requirement information can be input into the text input box to generate a text generation request according to the user's input data and writing requirement information.
[0100] Optionally, the server may generate prompt information based on at least the subject information, word count information, and writing requirement information carried in the text generation request sent by the user device, and then input the prompt information into the text generation model to generate a text based on the subject information and the writing requirement information and word count information through the text generation model. Afterwards, the server may send the generated text to the user device.
[0101] For example, an example application scenario of generating text through writing requirement information may be that the user wishes to generate text with other requirements in addition to the number of words, such as requiring that the text "does not allow character names" or "must contain at least three famous quotes", etc., which can be input as writing requirement information as needed to generate a text generation request, so that the text generation model can realize text generation according to the topic information, writing requirement information, and word count requirement information. It should be understood that this example application scenario does not serve as any limitation to the embodiments of the present application.
[0102] It should be understood that in the present application, through the user inputting writing requirement information, the text generation model can take the subject information in the input data as the subject, and refer to the writing requirement information to generate a text with a word count that meets the word count indicated by the word count requirement information, so that the generated text can not only meet the predetermined word count requirement, but also be more consistent with other writing requirements indicated by the writing requirement information in terms of content, thereby better meeting the user's needs for text generation.
[0103] It can be understood that the above description of the text generation method of the first aspect is only intended as some exemplary descriptions of the present application and does not constitute any limitation to the present application.
[0104] Reference Figure 7As shown in the flowchart, the present application embodiment provides another text generation method, which focuses on explaining the reasoning application of the generated text generation model from the perspective of a server such as a cloud server. The text generation method includes the following steps S702 and S704, specifically:
[0105] S702: Obtaining subject information of the text to be generated and word count requirement information of the text to be generated from the text generation request sent by the user device, and generating prompt information.
[0106] Regarding the text generation request, please refer to the description of the relevant parts in the above embodiment, which will not be repeated here.
[0107] In step S702 of the embodiment of the present application, after the user device sends a text generation request to the server, the server can generate prompt information based on the subject information of the text to be generated and the word count requirement information of the text to be generated carried in the text generation request. The prompt information can be used for understanding by the text generation model for text generation.
[0108] S704: Input the prompt information into the text generation model, so as to generate a text with the topic information as the theme and the number of words satisfying the number of words indicated by the word number requirement information through the text generation model.
[0109] Among them, the text generation model is obtained based on the general generative basic model, and text generation can be effectively realized through the text generation model. It should be understood that the text generation model can be obtained by training the general generative basic model in any way. For example, the general generative basic model can be trained in the manner described in the above-mentioned text generation model training method embodiment. The details can be understood by referring to the above-mentioned embodiment, and will not be repeated here.
[0110] Based on this, in the embodiment of the present application, the text generation method through the above steps S702 to S704 can generate prompt information based on at least the subject information of the text to be generated and the word count requirement information of the text to be generated carried in the text generation request sent by the user device, and then input the prompt information into the text generation model to generate a text with the subject information as the subject and the word count meeting the word count indicated by the word count requirement information through the text generation model, so as to accurately generate the text with the predetermined word count requirement and subject requirement required by the user, thereby better meeting the user's needs for text generation.
[0111] Optionally, the text generation request also carries text material associated with the subject information. In some optional embodiments, the above step S702 may include: generating prompt information based on at least the subject information, word count requirement information and text material carried in the text generation request sent by the user device; the above step S704 may include: inputting the prompt information into the text generation model to generate a text with the subject information as the subject, generated based on the text material, and the word count meeting the word count indicated by the word count requirement information through the text generation model. The specific implementation thereof may refer to the relevant description in the above text generation method embodiment, which will not be repeated here.
[0112] It should be understood that in the embodiment of the present application, prompt information is generated based on the subject information, word count requirement information and text material carried in the text generation request sent by the user device, and a text generation model is input, so that the text generation model can take the subject information as the subject, and refer to the content of the text material to generate a text with a word count that meets the word count indicated by the word count requirement information, so that the generated text can not only meet the predetermined word count requirement, but also be more consistent with the text material in terms of content, thereby better meeting the user's needs for text generation.
[0113] Optionally, the text generation request also carries writing requirement information. In some optional embodiments, the above step S702 may include: generating prompt information according to at least the subject information, word count requirement information and writing requirement information carried in the text generation request sent by the user device; the above step S704 may include: inputting the prompt information into the text generation model to generate a text with the subject information as the subject and generated according to the writing requirement information and word count requirement information through the text generation model. The specific implementation thereof may refer to the relevant description in the above text generation method embodiment, which will not be repeated here.
[0114] It should be understood that in the embodiment of the present application, prompt information is generated based on the subject information, word count requirement information and writing requirement information carried in the text generation request sent by the user device, and the text generation model is input, so that the text generation model can take the subject information in the input data as the subject, and refer to the writing requirement information to generate a text with a word count that meets the word count indicated by the word count requirement information, so that the generated text can not only meet the predetermined word count requirement, but also be more consistent with other writing requirements indicated by the writing requirement information in terms of content, thereby better meeting the user's needs for text generation.
[0115] In some optional embodiments, referring to Figure 8 As shown in the flowchart, any implementation of the above step S704 may include the following steps S7041, S7042 and S7043, specifically:
[0116] S7041: Input the prompt information into the text generation model to generate text outline data matching the topic information through the text generation model.
[0117] Optionally, the text outline data may briefly describe the contents of each part of the text to be generated. Since the text generation model has a powerful text generation capability, it can randomly generate text outline data of various styles. Therefore, it is possible to select appropriate text outline data as needed to generate new prompt information to achieve text generation.
[0118] For ease of understanding, in some examples, the text outline data matching the topic information generated by the text generation model according to the prompt information may be:
[0119] “
[0120] 1. History of Computer Development
[0121] 1.1XXXXX
[0122] 1.2XXXXXX ......
[0124] 2. Components of a computer
[0125] 2.1XXXXX
[0126] 2.2XXXXXXX ......
[0128] ”
[0129] As can be seen from the above example, the text outline data is similar to a directory, which can briefly describe the contents of each part of the text to be generated. The text outline data facilitates the subsequent text generation.
[0130] S7042: Generate new prompt information based on text outline data, subject information and word count requirement information.
[0131] After obtaining the text outline data, new prompt information can be generated according to the text outline data, the subject information and the word count requirement information, so as to input the new prompt information into the text generation model for use in text generation.
[0132] In some optional embodiments, step S7042 may include: receiving text outline data modified by a user; and generating new prompt information according to the modified text outline data, subject information and word count requirement information.
[0133] It should be understood that in the above embodiment, the user is allowed to modify the text outline data generated in step S7041, and generate new prompt information based on the modified text outline data, subject information and word count requirement information, so that the generated text can meet the predetermined preset word count requirement and better meet the user's usage requirements for the generated text.
[0134] Optionally, after generating text outline data in step S7041, the server (cloud server 102) may send the text outline data to the user device 106 and display it through an interactive control such as an interactive text display control. The user of the user device 106 may modify the text outline data as needed. After the modification is completed, the user device 106 sends the modified text outline data to the server. The server receives the modified text outline data and can generate new prompt information based on the modified text outline data, subject information and word count requirement information for subsequent text generation.
[0135] Of course, in other optional embodiments, if the user is satisfied with the text outline data generated in step S7041, the text outline data may not be modified. The server may directly generate new prompt information based on the text outline data, subject information and word count requirement information generated in step S7041 for subsequent text generation.
[0136] S7043: Input the new prompt information into the text generation model, so that the text generation model generates a text with the subject information as the theme and the number of words satisfying the number of words indicated by the word requirement information according to the text outline data.
[0137] Based on this, in this application, through the optional implementation method of the above steps S7041 to S7043, by inputting prompt information into the text generation model, so as to generate text outline data matching the subject information through the text generation model, and then generating new prompt information based on the text outline data, the subject information and the word count requirement information, and then inputting the new prompt information into the text generation model, it is possible to conveniently and effectively generate a text with the subject information as the subject and the word count satisfying the word count requirement information through the text generation model according to the text outline data, thereby effectively ensuring the correspondence between the content of the generated text meeting the predetermined word count requirement and the subject, and better meeting the user's needs for the generated text.
[0138] Fig. 9 A schematic diagram of a scenario example of the text generation solution of the embodiment of the present application. Fig. 9 The text generation scheme in the embodiment of the present application is shown as a whole. It should be noted that it should be understood that Fig. 9The example scenarios shown are only used to facilitate understanding of the embodiments of the present application and are not intended to be any limitation to the present application.
[0139] like Fig. 9 As shown in , it is assumed that the user inputs "Please write a text related to XXXXX, with about 7000 words" (i.e., input data) through the human-computer interaction interface of the user device. The user device generates a corresponding text generation request based on the input data, and sends it to the cloud server. After receiving the text generation request, the cloud server parses the input data therein, and generates a corresponding prompt message prompt based on the input data, and the prompt message includes the information "Please write a text related to XXXXX, with about 7000 words". The prompt message prompt will be input into the text generation model of the cloud server, which is shown as the LLM after fine-tuning training in this example. After receiving the prompt message, the LLM prompts, generates text related to XXXXX according to the word count requirement information of "about 7000 words", and outputs a text of about 7000 words.
[0140] Furthermore, the cloud server may send the text of about 7,000 words to the user device so as to be displayed to the user on the user device.
[0141] It can be seen that the text generation model in this example can effectively generate text according to the number of words required by the user. It should be noted that in multiple embodiments of the present application, several thousand words are used as examples, but those skilled in the art should understand that in actual applications, LLM can generate long texts of tens of thousands of words or even hundreds of thousands of words or millions of words. The embodiments of the present application do not limit the specific number of words in the generated text, and all of them are applicable to the solutions of the embodiments of the present application, and are all within the scope of protection required by the present application.
[0142] An embodiment of the present application also provides an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store a computer program; and the processor is used to execute any method described in the aforementioned multiple method embodiments by running the computer program stored in the memory.
[0143] Fig.10 1000 is a block diagram of an optional electronic device in an embodiment of the present application. The present application embodiment does not limit the specific implementation of the electronic device 1000. Fig.10The electronic device 1000 provided in the embodiment of the present application includes: a processor 1002, a communication interface 1004, a memory 1006, and a communication bus 1008. Among them:
[0144] The processor 1002 , the communication interface 1004 , and the memory 1006 communicate with each other via a communication bus 1008 .
[0145] The communication interface 1004 is used to communicate with other electronic devices or servers.
[0146] The processor 1002 is used to execute the computer program 1010, and specifically can execute the relevant steps of any method embodiment in the aforementioned multiple method embodiments.
[0147] Specifically, the computer program 1010 may include program codes, which include computer operation instructions.
[0148] The processor 1002 may be a CPU, or a GPU (Graphic Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or may be processors of different types, such as one or more CPUs and one or more ASICs.
[0149] The memory 1006 is used to store the computer program 1010. The memory 1006 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0150] The computer program 1010 may be specifically configured to enable the processor 1002 to execute a method of any one of the foregoing method embodiments.
[0151] The specific implementation of each step in the computer program 1010 can refer to the corresponding description of the corresponding steps and units in any of the above-mentioned multiple method embodiments, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above-mentioned method embodiments, which will not be repeated here.
[0152] In addition, the embodiment of the present application further provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method of any of the aforementioned multiple method embodiments is implemented. The computer storage medium includes, but is not limited to: a compact disc read-only memory (CD-ROM), a random access memory (RAM), a floppy disk, a hard disk, or a magneto-optical disk, etc.
[0153] An embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements a method as in any one of the above-mentioned multiple method embodiments.
[0154] In addition, it should be noted that the user-related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to sample data used to train the model, data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0155] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0156] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor or programmable or dedicated hardware (such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA)). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., a random access memory (RAM), a read-only memory (ROM), a flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a dedicated computer for executing the method shown here.
[0157] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for specific applications, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0158] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". It should be noted that the concepts of "first", "second", etc. mentioned in the embodiments of the present application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units. It should be noted that the modifications of "one" and "multiple" mentioned in the embodiments of the present application are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0159] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.
Claims
1. A text generation method, comprising: Generate a text generation request using the user's input data and send it to the server, wherein the text generation request carries the subject information of the text to be generated and the word count requirement information of the text to be generated; Receive text generated by the text generation model of the server in response to the text generation request, wherein the text is a text generated by the text generation model with the subject information in the input data as the subject and the number of words satisfying the number of words indicated by the word requirement information, and the text generation model is obtained by training based on a general generative basic model.
2. The method according to claim 1, wherein: The step of using the user's input data to generate a text generation request includes: Receiving input data input by a user through a text input box in a human-computer interaction interface, which includes subject information and word count requirement information of a text to be generated, and using the input data to generate the text generation request; or, Receive input data including subject information of a text to be generated, which is input by a user through a text input box in a human-computer interaction interface, and receive a selection operation of a plurality of word count options displayed in the human-computer interaction interface by the user, and determine word count requirement information of the text to be generated according to the selection operation; and generate the text generation request using the input data and the word count requirement information.
3. The method according to claim 1 or 2, wherein: The method further comprises: receiving text material associated with the subject information input by the user; The step of using the user's input data to generate a text generation request includes: using the user's input data and the text material to generate a text generation request; The text is a text generated by the text generation model based on the text material with the subject information in the input data as the subject, and the number of words meets the number of words indicated by the word number requirement information.
4. The method according to claim 1 or 2, wherein: The method further comprises: receiving writing requirement information input by the user; The step of using the user's input data to generate a text generation request includes: using the user's input data and the writing requirement information to generate a text generation request; The text is a text generated by the text generation model with the subject information in the input data as the subject, in accordance with the writing requirement information and the word count requirement information.
5. A text generation method, comprising: Obtaining subject information of the text to be generated and word count requirement information of the text to be generated from the text generation request sent by the user device, and generating prompt information; Inputting the prompt information into a text generation model, so as to generate a text with the subject information as the theme and the number of words satisfying the number of words indicated by the word number requirement information through the text generation model; Wherein, the text generation model is obtained based on a general generative basic model.
6. The method according to claim 5, wherein: The text generation request also carries text material associated with the subject information; The step of obtaining the subject information of the text to be generated and the word count requirement information of the text to be generated from the text generation request sent by the user device, and generating the prompt information includes: obtaining the subject information, the word count requirement information and the text material from the text generation request sent by the user device, and generating the prompt information; The step of inputting the prompt information into a text generation model so as to generate, through the text generation model, a text with the subject information as the theme and the number of words satisfying the number of words indicated by the word count requirement information, includes: inputting the prompt information into a text generation model so as to generate, through the text generation model, a text with the subject information as the theme, generated based on the text material and the number of words satisfying the number of words indicated by the word count requirement information.
7. The method according to claim 5, wherein: The text generation request also carries writing requirement information; The step of obtaining the subject information of the text to be generated and the word count requirement information of the text to be generated from the text generation request sent by the user device and generating the prompt information includes: obtaining the subject information, the word count requirement information and the writing requirement information from the text generation request sent by the user device and generating the prompt information; The step of inputting the prompt information into a text generation model so as to generate, through the text generation model, a text with the subject information as the theme and the number of words satisfying the number of words indicated by the word requirement information, includes: inputting the prompt information into a text generation model so as to generate, through the text generation model, a text with the subject information as the theme and generated in accordance with the writing requirement information and the word requirement information.
8. The method according to any one of claims 5 to 7, wherein: The step of inputting the prompt information into a text generation model to generate a text with the subject information as the theme and the number of words satisfying the number of words indicated by the word number requirement information through the text generation model includes: Inputting the prompt information into a text generation model to generate text outline data matching the subject information through the text generation model; Generate new prompt information according to the text outline data, the subject information and the word count requirement information; The new prompt information is input into a text generation model, so that the text generation model generates a text with the subject information as the theme and the number of words satisfying the number of words indicated by the word requirement information according to the text outline data.
9. The method according to claim 8, wherein: The generating new prompt information according to the text outline data, the subject information and the word count requirement information includes: receiving text outline data modified by a user; New prompt information is generated according to the modified text outline data, the subject information and the word count requirement information.
10. A text generation model training method, comprising: Acquire a training sample for model training, the training sample comprising a prompt information sample and a corresponding reply data sample, the prompt information sample comprising word count requirement information of a text to be generated, and the word count of the reply data sample matches the word count indicated by the word count requirement information; Inputting the prompt information sample into a general generative basic model, so that the general generative basic model generates text based on the prompt information sample to obtain a text generation data sample; At least according to the difference between the number of words of the text generation data sample and the number of words of the reply data sample, the general generative basic model is fine-tuned and trained to obtain a text generation model that can generate a text of a corresponding number of words according to the word count requirement information.
11. The method according to claim 10, wherein: The obtaining of training samples for model training includes: Obtaining a training sample group from a training sample set for model training, each training sample group includes a plurality of training samples, the plurality of training samples include a plurality of prompt information samples and a plurality of reply data samples corresponding to the plurality of prompt information samples, and the plurality of prompt information samples in the same group have the same information except for the word count requirement information; Taking the training sample group as a unit, a plurality of training samples in the same training sample group are sequentially obtained for training the general generative basic model.
12. The method according to claim 10 or 11, wherein: The fine-tuning training of the general generative basic model at least according to the difference between the number of words in the text generation data sample and the number of words in the reply data sample comprises: The general generative basic model is fine-tuned and trained according to the difference between the content of the text generation data sample and the content of the reply data sample, and the difference between the number of words of the text generation data sample and the number of words of the reply data sample.
13. The method according to claim 12, wherein: The method further comprises: According to the word count of the text generated data sample, updating the word count requirement information in the prompt information sample; A new training sample is generated based on the prompt information sample after the word count requirement information is updated and the text generation data sample.
14. The method according to claim 10 or 11, wherein: The step of inputting the prompt information sample into a universal generative basic model so that the universal generative basic model generates text based on the prompt information sample to obtain a text generation data sample comprises: Inputting the prompt information sample into a general generative basic model, and extracting word count requirement information and semantic information of the prompt information sample in the prompt information sample through the general generative basic model; The general generative basic model is used to generate text based on the semantic information and the number of words indicated by the word count requirement information to obtain a text generation data sample.
15. An electronic device, comprising: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to execute the method according to any one of claims 1 to 14 by running the computer program stored in the memory.
16. A computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 14.
17. A computer program product, comprising a computer program, which implements the method according to any one of claims 1 to 14 when executed by a processor.
Citation Information
Cited By
Text generation method, text generation model training method, electronic device, storage medium, and program product
WO2026016898A1
