Text generation method, text generation model training method, electronic device, storage medium, and program product
By fine-tuning the training samples of a large language model, a text generation model that meets style requirements is generated, solving the problem that existing technologies cannot generate personalized style text and achieving style accuracy in text generation.
Patent Information
- Application Number
- PCT/CN2025/106638
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-07-17
- Filing Date
- 2025-07-02
- Publication Date
- 2026-01-22
AI Technical Summary
Existing Large Language Models (LLMs) cannot meet users' personalized style requirements when generating text, and cannot accurately generate text with a certain style.
By acquiring user input data to generate text generation requests, carrying topic information and style requirements, and using training samples to fine-tune the general generative base model, a text generation model that meets the style requirements is generated.
It enables the accurate generation of text that meets style requirements based on user needs, satisfying users' personalized needs for text generation.
Smart Images

Figure CN2025106638_22012026_PF_FP_ABST
Abstract
Description
Text generation and model training method thereof, electronic device, storage medium and program product
[0001] The present disclosure claims priority to Chinese Patent Application No. 202410963796.4, filed on July 17, 2024, with the Chinese Patent Office, entitled "Text generation and model training method thereof, electronic device, storage medium and program product", the entire contents of which are incorporated herein by reference. TECHNICAL FIELD
[0002] Embodiments of the present disclosure 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
[0003] Currently, machine learning models such as LLM (Large Language Model) are playing an increasingly important role in people's work and life.
[0004] LLM is a model trained based on massive text data, which can not only generate natural language text, but also deeply understand the meaning of the text and process various natural language tasks such as text summarization, question answering, translation, etc. Although LLM itself has strong processing capability, its capability is a kind of generalization capability, which cannot meet the personalized needs of users in some cases. For example, in some scenarios, users want to generate text with a certain style through LLM, or generate different styles of text that meet different needs, etc. However, the current LLM, as well as similar models to LLM, cannot meet this demand.
[0005] Therefore, how to accurately generate text that meets the style requirements has become a problem to be solved. SUMMARY
[0006] In view of this, embodiments of the present disclosure 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 problems.
[0007] According to a first aspect of the embodiments of the present disclosure, a text generation method is provided, including: using input data of a user, generating a text generation request and sending to a server, the text generation request carrying theme information of a text to be generated and style requirement information of the text to be generated; receiving a text generated by a text generation model of the server in response to the text generation request, the text being a text with a theme of the theme information in the input data and a text style satisfying a style indicated by the style requirement information, the text generation model being obtained based on training of a general generative base model.
[0008] According to a second aspect of the embodiments of the present disclosure, a text generation method is provided, including: obtaining theme information of a text to be generated and style requirement information of the text to be generated from a text generation request sent by a user device, generating prompt information; inputting the prompt information into a text generation model to generate a text with a theme of the theme information and a style satisfying a style indicated by the style requirement information through the text generation model; wherein the text generation model is obtained based on training of a general generative base model.
[0009] According to a third aspect of the embodiments of the present disclosure, a text generation model training method is provided, including: obtaining a training sample for model training, the training sample including prompt information samples and corresponding reply data samples, the prompt information samples containing style requirement information of a text to be generated, the text style of the reply data samples matching a style indicated by the style requirement information; inputting the prompt information samples into a general generative base model to make the general generative base model generate a text based on the prompt information samples, and obtain a text generation data sample; and performing fine-tuning training on the general generative base model according to a difference between a text style of the text generation data sample and a text style of the reply data sample, to obtain a text generation model capable of generating a text with a corresponding style according to the style requirement information.
[0010] According to a fourth aspect of the embodiments of the present disclosure, an electronic device is provided, including: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus; the memory is configured to store a computer program; and the processor is configured to execute the method of any one of the first aspect, the second aspect and the third aspect by running the computer program stored on the memory.
[0011] According to a fifth aspect of the embodiments of the present disclosure, a computer storage medium is provided, having a computer program stored thereon, the computer program being executed by a processor to implement the method of any one of the first aspect, the second aspect and the third aspect.
[0012] According to a sixth aspect of the embodiments of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method according to any one of the first aspect, the second aspect or the third aspect.
[0013] According to the text generation scheme provided by the embodiments of the present disclosure, since the text generation request can be generated according to the input data of the user and sent to the server, the text generation request carries the theme information of the text to be generated and the style requirement information of the text to be generated, and the text generated by the text generation model of the server in response to the text generation request is obtained based on the general generation model, and the text is a text whose theme is the theme information in the input data and whose text style meets the style indicated by the style requirement information. Therefore, by using the text generation model, the scheme of the embodiments of the present disclosure can generate a text that meets the predetermined style requirement more accurately, thereby better meeting the user's demand for text generation. BRIEF DESCRIPTION OF DRAWINGS
[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments described in the embodiments of the present disclosure, and other drawings can also be obtained by those skilled in the art based on these drawings.
[0015] FIG. 1 is a schematic diagram of an exemplary system suitable for the scheme of the embodiments of the present disclosure;
[0016] FIG. 2 is a step flowchart of a text generation model training method according to an embodiment of the present disclosure;
[0017] FIG. 3 is an optional flowchart of the way of obtaining training samples in step S202 of the embodiments of the present disclosure;
[0018] FIG. 4 is an optional flowchart of step S204 of the embodiments of the present disclosure;
[0019] FIG. 5 is a step flowchart of a text generation method according to an embodiment of the present disclosure;
[0020] FIG. 6A is a schematic diagram of a human-computer interaction interface on the user equipment side in the embodiment shown in FIG. 5;
[0021] FIG. 6B is a schematic diagram of another human-computer interaction interface on the user equipment side in the embodiment shown in FIG. 5;
[0022] FIG. 6C is a schematic diagram of still another human-computer interaction interface on the user equipment side in the embodiment shown in FIG. 5;
[0023] FIG. 7 is a flowchart of steps of another text generation method according to an embodiment of the present disclosure;
[0024] FIG. 8 is an optional flowchart of step S704 in the embodiment shown in FIG. 7;
[0025] FIG. 9 is a diagram of one scenario example according to an embodiment of the present disclosure;
[0026] FIG. 10 is a structural diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to make the personnel in the art better understand the technical solutions in the embodiments of the present disclosure, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art should belong to the scope of protection of the present disclosure.
[0028] FIG. 1 shows an exemplary system to which the embodiments of the present disclosure are applicable. As shown in FIG. 1, the system 100 can include a cloud server 102, a communication network 104, and / or one or more user devices 106, of which multiple user devices are shown in FIG. 1.
[0029] The cloud server 102 can be any appropriate device for storing information, data, programs, and / or any other suitable type of content, including but not limited to a distributed storage system device, a server cluster, a computing cloud server cluster, etc. In some embodiments, the cloud server 102 can perform any appropriate function. For example, in some embodiments, the cloud server 102 can generate text with a certain style. For example, the cloud server 102 can obtain theme information and style requirement information of the text to be generated from a received text generation request, and then generate prompt information based on the theme information and the style requirement information, so that the text generation model generates text meeting the style indicated by the style requirement information based on the prompt information. As an optional example, in some embodiments, the cloud server 102 is deployed with a text generation model obtained based on a general generative base model. In some embodiments, the cloud server 102 can also train the general generative base model to obtain a text generation model capable of generating text with a corresponding style according to style requirement information. As an optional example, in some embodiments, when training the model, the cloud server 102 can first obtain training samples for model training, the training samples including prompt information samples and corresponding reply data samples, the prompt information samples containing style requirement information of the text to be generated, and the text style of the reply data samples matching the style indicated by the style requirement information; then, the prompt information samples are input into the general generative base model to make the general generative base model generate text based on the prompt information samples and obtain text generation data samples; after that, the general generative base model is fine-tuned according to at least the difference between the text style of the text generation data samples and the text style of the reply data samples, to obtain a text generation model capable of generating text with a corresponding style according to style requirement information. Optionally, after generating the text, the cloud server 102 can return the generated text to the user device 106.
[0030] 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 connect to the communication network 104 through one or more communication links, e.g., communication link 112, which can link to the cloud server 102 via one or more communication links, e.g., communication link 114. The communication links can be any communication links suitable for communicating data among the user device 106 and the cloud server 102, such as network links, dial-up links, wireless links, hard-wired links, any other suitable communication links, or any suitable combination of such links.
[0031] The user device 106 can include any one or more user devices suitable for presenting text, interacting with a user, and / or the like. As an optional example, in some embodiments, the user device 106 can first generate a text generation request according to the input data of the user, and send the text generation request to the cloud server 102, the text generation request carrying theme information of the text to be generated and style requirement information of the text to be generated; receive the text generated by the text generation model of the cloud server 102 in response to the text generation request, the text being a text generated by the text generation model with the theme information in the input data as the theme, the text style of the generated text satisfying the style indicated by the style requirement information. In some embodiments, the user device 106 can include any suitable type of device. For example, in some embodiments, the user device 106 can 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 (e.g., a browser, etc.) can be installed on the user device 106, and the input data of the user can be received through the human-computer interaction interface of the client program, so as to generate a text generation request according to the input data of the user, and send the text generation request to the cloud server 102 through the client program.
[0032] Based on the above system, the embodiments of the present disclosure provide a text generation scheme and a text generation model training scheme, which are described below through multiple embodiments.
[0033] To facilitate the description of the embodiments of the present disclosure, the training method of the text generation model is first described herein. FIG. 2 is a step flowchart of a text generation model training method according to an embodiment of the present disclosure. Referring to FIG. 2, the text generation model training method includes steps S202, S204 and S206. Specifically:
[0034] S202: Obtain a training sample for model training.
[0035] The training sample includes a prompt information sample and a corresponding reply data sample. The prompt information sample contains style requirement information of the text to be generated. The text style of the reply data sample matches the style indicated by the style requirement information.
[0036] In the embodiments of the present disclosure, the style of the text means the writing style of the text, which is the collection of the writing characteristics of the writer, such as unique personality, language habits, expression methods and emotional colors, and can be embodied in multiple aspects such as language characteristics, narrative methods, emotional colors and cultural backgrounds. In the embodiments of the present disclosure, the prompt information sample contained in the training sample contains the style requirement information of the text to be generated, that is, the information of the writing style of the text that the user wants to generate. For example, the writing style is easy to understand, lively and interesting, professional and rigorous, etc. The embodiments of the present disclosure do not limit the specific style type.
[0037] The training sample can come from a training sample set. One training sample includes a pair of prompt information sample and reply data sample.
[0038] In the embodiments of the present disclosure, in the model training process, the prompt information sample in the training sample is also called a prompt sample, which can make the model to be trained generate text to generate the text of the style indicated by the style requirement information contained in the prompt information sample. The prompt information sample can include historical prompt information, or the prompt information sample can be generated in a certain way. Optionally, the style requirement information in the prompt information sample can be embodied in any style, which can specify a certain specific style, or can specify several styles. For example, as a convenient example, in addition to the aforementioned examples, the style requirement information can also be, for example, “business style” or “leisure style”.
[0039] In the model training process in the embodiments of the present disclosure, the reply data sample in the training sample can be used as a supervised condition for supervised training to perform loss calculation with the text generation data sample generated by the model prediction, and then the model is trained based on the calculation result, including but not limited to adjusting the model parameters. The text style of the reply data sample matches the style indicated by the style requirement information in the prompt information sample. For example, taking the style requirement information of the above prompt information sample as "business style" as an example, the text style of the corresponding reply data sample can be business style; and taking the style requirement information of the above prompt information sample as "vivid and interesting" as an example, the text style of the corresponding reply data sample can be vivid and interesting style. On this basis, the prompt information sample in the training sample can be input into the general generative base model for text generation, and then according to the preset loss function, the loss value (i.e. the difference between the two) is calculated based on the text style of the generated text (i.e. the text generation data sample) and the text style of the reply data sample, and the model parameters are adjusted according to the loss value. The process is iteratively executed until the training termination condition is met, such as reaching the preset training times, or the loss value reaches the preset threshold. The loss function used in the embodiments of the present disclosure can be set by those skilled in the art according to actual needs, including but not limited to cross-entropy loss function, etc., and the specific implementation of the loss function is not limited in the embodiments of the present disclosure.
[0040] In some optional embodiments, a general generative base model is used as a basis to obtain the required text generation model by fine-tuning training. In some embodiments, the general generative base model can use a large language model (LLM for short). The large language model LLM itself has strong text understanding and generation capability, and after appropriate training, it can effectively meet the text generation requirement. In the embodiments of the present disclosure, the general generative base model is trained by inputting the training sample, and after training, a text generation model capable of generating text meeting the style requirement is obtained.
[0041] For the training sample, although the model can use the method of training based on the pair of prompt information sample and corresponding reply data sample in one training sample. In order to make the model more sensitive to the style requirement information, in a feasible way, the model can also be trained in the form of training sample group.
[0042] Optionally, referring to the flowchart shown in FIG. 3, the way of obtaining the training sample in step S202 can include steps S2021 and S2022, specifically:
[0043] S2021: Obtain a training sample group from a training sample set used for model training, each training sample group including a plurality of training samples, the plurality of training samples including 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 being the same in information except for style requirement information.
[0044] The training sample set can include a plurality of training sample groups. Optionally, for any training sample group, each training sample included in the plurality of training samples includes a prompt information sample and a corresponding reply data sample corresponding to the prompt information sample. The plurality of prompt information samples in the training sample group are the same in information except for style requirement information. For example, the other information can include theme information or content requirement information of the text to be generated.
[0045] In one specific example, it is assumed that a training sample group includes 3 training samples, and the theme information of the 3 training samples is the same, but the style requirement information is different. For example, training sample 01 is "Please help me write an annual summary article, and the requirement is business style"; training sample 02 is "Please help me write an annual summary article, and the requirement is lively and interesting style"; and training sample 03 is "Please help me write an annual summary article, and the requirement is professional and rigorous style". As can be seen, the style requirement information in the training sample group is different, but the other information is the same.
[0046] Thus, the model can more effectively learn the style indicated by the style requirement information, and the cost and efficiency of obtaining the training sample are reduced.
[0047] S2022: Obtain the plurality of training samples in the same training sample group in sequence in units of training sample groups, for training the general generative base model.
[0048] The obtained training sample group can be used for subsequent model training. One exemplary manner can be described with reference to the related description in step S204 below, which will not be described here in detail.
[0049] It should be understood that based on the optional implementation of steps S2021-S2022 described above, the plurality of training samples in the same training sample group can be obtained in sequence in the disclosure, so as to facilitate subsequent model training. In addition to the style requirement information being different, the other information in the plurality of prompt information samples of the same group of training samples is the same. Therefore, in the subsequent model training process, the plurality of training samples in the same training sample group can be used in sequence, and the general generative base model is trained by different style requirement information in a controlled variable manner, so that when the text generation model is used for text generation, the text that meets the predetermined style requirement can be more accurately generated, thereby meeting the user's demand for text generation, and reducing the cost and efficiency of obtaining training samples.
[0050] S204: input the prompt information sample into the general generative base model, so that the general generative base model generates text based on the prompt information sample to generate a text generation data sample.
[0051] Optionally, after obtaining a certain training sample for model training, the prompt information sample in the training sample can be input into the general generative base model, so that the general generative base model generates text based on the prompt information sample to generate a text generation data sample.
[0052] Optionally, the plurality of training samples in the same training sample group can also be obtained in sequence in the unit of training sample group, and the prompt information sample in the training sample is input into the general generative base model in sequence, so that the general generative base model generates text based on the prompt information sample in the training sample to obtain the corresponding text generation data sample. As described previously, since the training is performed in the unit of training sample group, the model can more effectively learn the information related to the text style.
[0053] For example, taking training sample groups A1 and A2 as an example, for the training sample group A1, the n training samples in the training sample group A1 can be obtained in sequence, and the general generative base model is trained by using the plurality of prompt sample information of the style requirement information X1,..., Xn and the reply data sample C1,..., Cn corresponding to the plurality of prompt sample information in sequence; and for the training sample group A2, the m training samples in the training sample group A2 can be obtained in sequence, and the general generative base model is trained by using the plurality of prompt sample information of the style requirement information Y1,..., Ym and the reply data sample D1,..., Dm corresponding to the plurality of prompt sample information in sequence. Wherein, n and m are positive integers equal to or greater than 2.
[0054] For example, taking the above training sample groups A1 and A2 as an example, for the training sample group A1, prompt sample information containing style requirement information X1,..., Xn can be obtained in turn and input into the general generative base model, and the general generative base model generates text generation data samples P1,..., Pn in turn based on the prompt sample information containing style requirement information X1,..., Xn; for the training sample group A2, prompt sample information containing style requirement information Y1,..., Yn can be obtained in turn and input into the general generative base model, and the general generative base model generates text generation data samples Q1,..., Qm in turn based on the prompt sample information containing style requirement information Y1,..., Ym.
[0055] Although the above simple style type can be used to describe the style requirement information, in some scenarios, the user may not be able to accurately determine the text style they want, at which time the user may upload a style text example, such as an article or file that the user considers to meet the style requirements. Based on this, the training sample also fully considers this situation, and in a feasible manner, the prompt information sample contains a style text example.
[0056] In this case, in some optional embodiments, referring to the flowchart shown in FIG. 4, the above step S204 can include the following steps S2041-S2043, specifically:
[0057] S2041: Perform text style analysis on the style text example in the prompt information sample to obtain the text style corresponding to the style text example.
[0058] In a feasible manner, a machine learning model for text style analysis can be set in the cloud server, such as a convolutional neural network model, a recurrent neural network model, etc., and the specific implementation form of the model is not set by the embodiments of the present disclosure.
[0059] In another feasible manner, based on the powerful text understanding and analysis capability of the LLM, the text style analysis of the style text example can also be performed by the LLM. In this case, the cloud server can first extract the style text example from the prompt information sample to generate prompt information for indicating text style analysis.
[0060] For example, the original prompt information sample is "Please help me write an article describing daily life, using the same style as the following: 'XXXXXXXX', where 'XXXXXXXX' represents the text content of the style text sample. Based on this, the cloud server extracts the above data related to the style text sample from it and generates a prompt for indicating text style analysis of the style text sample, such as "Please perform writing style analysis on the following text content: 'XXXXXXXX'. The LLM performs text analysis based on the prompt information and obtains the corresponding analysis result, i.e., the text style corresponding to the style text sample, exemplarily, such as "humorous and witty". Further, the text style can be used as style requirement information, and the original information in the prompt information sample, except for the style text sample, is used to generate a new prompt information, such as "write an article describing daily life, using a humorous and witty style".
[0061] S2042: Obtain the text style as style requirement information, and the information in the prompt information sample except for the style text sample, to generate a new prompt information.
[0062] As described above, after obtaining the text style corresponding to the style text sample, the text style can be used as style requirement information to generate a new prompt information, such as "write an article describing daily life, using a humorous and witty style".
[0063] S2043: Input the new prompt information into the general generative base model, so that the general generative base model performs text generation based on the new prompt information to generate a text generation data sample.
[0064] As described above, the LLM has strong text understanding and analysis capabilities, and therefore, in this example, the same LLM can be used for text style analysis and text generation. In this way, there is no need to additionally deploy a model for text style analysis, saving the implementation cost of the scheme.
[0065] The LLM performs text generation based on the new prompt information, and generates text that meets the style requirement information indicated in the new prompt information. Still taking the above example, the LLM will generate an article describing daily life in a humorous and witty style.
[0066] S206: At least according to the difference between the text style of the text generation data sample and the text style of the reply data sample, fine-tune the general generative base model to obtain a text generation model capable of generating text in a corresponding style according to style requirement information.
[0067] After the general generative base model generates the text generation data sample, text style analysis can be performed on it. For example, the same or similar method as described above for text style analysis of the style text sample can be used. That is, the text generation data sample is subjected to text style analysis to obtain the corresponding text style; and the general generative base model is fine-tuned according to the difference between the text style of the text generation data sample and the text style of the reply data sample.
[0068] When fine-tuning the general generative base model according to the difference between the text style of the text generation data sample and the text style of the reply data sample, for example, the loss value (i.e., the difference between the text style of the text generation data sample and the text style of the reply data sample) can be calculated according to the text style of the text generation data sample and the text style of the reply data sample obtained by analysis through a preset loss function such as a cross-entropy loss function, and then the general generative base model is fine-tuned based on the loss value.
[0069] The general generative base model is fine-tuned according to the difference between the text style of the text generation data sample and the text style of the reply data sample to at least adjust the model parameters of the general generative base model. After reaching the training end condition, a text generation model capable of generating text of a corresponding style according to style requirement information is obtained.
[0070] Alternatively, the training end condition can be set as needed. For example, the training end condition can be that when the number of training reaches a predetermined number, it is considered that the training end condition is reached, thereby ending the model training process. Alternatively, the training end condition can also be that when the loss value calculated by the preset loss function is within a preset loss value range, it is considered that the training end condition is reached, thereby ending the model training process.
[0071] Based on this, the optional implementation of the above steps S202-S206 in the embodiments of the present disclosure is to obtain a training sample for model training, the training sample includes a prompt information sample and a corresponding reply data sample, the prompt information sample contains style requirement information of the text to be generated, and the text style of the reply data sample matches the style indicated by the style requirement information. Then the prompt information sample is input into the general generative base model to make the general generative base model generate text based on the prompt information sample to obtain a text generation data sample, and then the general generative base model is fine-tuned at least according to the difference between the text style of the text generation data sample and the text style of the reply data sample. Thus, a text generation model capable of generating text of a corresponding style according to style requirement information is obtained. Using this text generation model, text that meets the predetermined style requirements can be accurately generated, thereby better meeting the user's demand for text generation.
[0072] In some optional embodiments, the text generation model training method of the embodiments of the present disclosure further includes: updating the style requirement information in the prompt information sample according to the text style of the text generation data sample; and generating a new training sample based on the prompt information sample after the style requirement information is updated and the text generation data sample. In this way, the situation where the type of the text style is used as the style requirement information can be effectively adapted.
[0073] Optionally, the prompt information sample after the style 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 a new training sample, and the model training can be continued by using the new training sample. In this way, the effective expansion of the training sample is realized, the generation data of the model is utilized, the style requirement information of the generated training sample is relatively accurate, and the acquisition cost of the training sample is greatly reduced.
[0074] Based on this, in the present disclosure, the style requirement information in the prompt information sample is updated according to the style of the text generation data sample, and a new training sample is generated based on the prompt information sample after the style requirement information is updated and the text generation data sample. On the one hand, the training sample can be made more abundant, and the effect of model training can be improved. On the other hand, the new training sample obtained can be used to realize the adversarial training of the general generative basic model. During the training process, the accuracy of the general generative basic model for generating text meeting the preset style requirement can be gradually improved, so that the text generation model obtained after the training can more accurately generate text meeting the predetermined style requirement during the inference stage, thereby better meeting the user's demand for text generation.
[0075] It can be understood that the foregoing description of the text generation model training method is only as some exemplary description of the present disclosure, and does not limit the present disclosure in any way.
[0076] The text generation method of the embodiments of the present disclosure will be described below. Referring to the flowchart shown in FIG. 5, the text generation method of the present embodiment is described from the perspective of the user equipment. The text generation method of the present embodiment includes the following steps S502 and S504, specifically:
[0077] S502: using the input data of the user, generating a text generation request and sending it to the server, the text generation request carrying theme information of the text to be generated and style requirement information of the text to be generated.
[0078] The text generation method of the embodiments of the present disclosure can be used in a user device. The input data can include the theme requirement, style requirement and other related information of the text to be generated by the user. After receiving the input data of the user, the user device can generate a corresponding text generation request based on the input data, so that the text generation request carries the theme information of the text to be generated and the style requirement information of the text to be generated. After obtaining the text generation request, the text generation request can be sent to a server (which can be a cloud server), and the server responds to the text generation request to generate the text.
[0079] The user can input the input data in any way. Optionally, a predetermined client program can be installed on the user device, and a human-computer interaction interface for inputting data can be set in the client program. The user can input the input data in the human-computer interaction interface in a manner including but not limited to typing input, voice input, copy-paste input, and the like.
[0080] Optionally, the theme information of the text to be generated can indicate the theme 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.
[0081] In some optional embodiments, the implementation of generating the text request using the input data of the user in step S502 can include: receiving the input data containing the theme information and the style requirement information of the text to be generated input by the user through a text input box in the human-computer interaction interface, and generating the text generation request according to the input data.
[0082] For example, referring to the example of the human-computer interaction interface in FIG. 6A, the human-computer interaction interface can be a human-computer interaction interface of a client program on the user device, which includes a text input box. The user can input the input data containing the theme information and the style requirement information of the text to be generated into the text input box in a manner including but not limited to typing input, voice input, copy-paste input, and the like. After the input is completed, the user device can obtain the input data and generate a corresponding text generation request according to the input data.
[0083] For example, in a convenient understanding example, if a user wants to generate a text in a professional and rigorous style with the main content of "Application of Artificial Intelligence in New Media Creation", the user can input similar input data as "Please generate an article with the theme of "Application of Artificial Intelligence in New Media Creation" in a professional and rigorous style" in the text input box of FIG. 6A to complete the input of input information. When the user clicks the "directly generate article" button in the interface, the text will be generated based on the above input data according to the requirement of the professional and rigorous style, and if the user clicks the "generate reference outline" button in the interface, the text outline will be generated first, and then the long text in a professional and rigorous style will be generated based on the text outline after the user confirms. Of course, this example does not limit the present disclosure.
[0084] Based on this, through the above optional mode, the user can input the input data containing the theme information and style 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 theme information of the text to be generated and the style requirement information of the text to be generated, so as to facilitate subsequent generation of text meeting the predetermined style requirements, thereby better meeting the user's demand for text generation.
[0085] In some other optional embodiments, the implementation manner of generating a text request according to the input data of the user in step S502 can include: receiving the input data containing the theme information of the text to be generated input by the user through the text input box in the human-computer interaction interface, and receiving the style requirement information input by the user through the style interaction control displayed in the human-computer interaction interface; generating a text generation request according to the input data and the style requirement information.
[0086] The style interaction control can be implemented in any appropriate form that can be conveniently operated by the user. In a feasible manner, the style interaction control can be a style option, such as an interactive label or an interactive button for selecting a style, which displays information of a corresponding text style. This manner facilitates user operation and improves the efficiency of user's determination of text style. However, it is not limited thereto, and the interactive label or the interactive button can also be a label or a button for user to customize the text style, that is, when the user selects this kind of label or button, the user can manually input the required text style, thereby providing greater flexibility for the user to select the style.
[0087] In addition, as mentioned above, in some cases, the user may not be able to explicitly determine the text style he needs, and in another possible way, the style interaction control can be implemented in the form of a text input box or a file upload option. Thus, the user can input the text of the style text sample through the text input box to help the server determine the required text style; or the user can upload the corresponding style text sample file through the file upload option, so that the server analyzes the text content in the file to determine the text style required by the user. Thus, the way for the user to determine the text style is expanded, and the user experience is improved.
[0088] Based on this, in one possible way, input data containing theme information of the text to be generated input by the user through the text input box in the human-computer interaction interface is received, and style requirement information input by the user through the style interaction control in the human-computer interaction interface is received; and generating a text generation request according to the input data and the style requirement information can be implemented as:
[0089] Method one: receiving input data containing theme information of the text to be generated input by the user through the text input box in the human-computer interaction interface, and receiving selection operation of the user on the multiple style options displayed in the human-computer interaction interface, determining the style requirement information of the text to be generated according to the selection operation; and generating a text generation request according to the input data and the style requirement information.
[0090] As mentioned above, the style option can be implemented in the form of an interactive label or an interactive button, and the user can determine the required text style by selecting it, determine the corresponding style requirement information, and improve the efficiency of the user in determining the text style.
[0091] Method two: receiving input data containing theme information of the text to be generated input by the user through the text input box in the human-computer interaction interface, and receiving custom style requirement information input by the user through the style information input control in the human-computer interaction interface; and generating a text generation request according to the input data and the custom style requirement information.
[0092] As mentioned above, the interactive label or the interactive button can be implemented as a label or a button that allows the user to customize the text style, and when the user selects this kind of label or button, the user can manually input the required text style, thereby providing greater flexibility for the user to select the style.
[0093] Method three: receiving input data containing theme information of the text to be generated input by the user through the text input box in the human-computer interaction interface, and receiving style text sample input by the user through the style information input control in the human-computer interaction interface; and generating a text generation request according to the input data and the style text sample.
[0094] As described above, in this way, the style interaction control can be implemented in the form of a text input box or a file upload option. In this way, the user can input the text of the style text sample through the text input box or upload the file of the corresponding style text sample through the file upload option to determine the text style required by the user through the server. In this way, the way for the user to determine the text style is expanded, and the user experience is improved.
[0095] For example, with reference to the example of the human-computer interaction interface in FIG. 6B, the human-computer interaction interface can be the human-computer interaction interface of the client program on the user device 106, which includes an input text input box for the user to input data (such as the text input box under “Please enter” in FIG. 6B), multiple style options including a custom style (such as the multiple options under “Article style” in FIG. 6B), a text input box for inputting a style text sample (such as the text input box under “Style text sample” in FIG. 6B), and an upload option for uploading a style text sample file (such as the “Upload style text sample file” indicated by the “+” sign in FIG. 6B).
[0096] The user can input the input data containing the theme information of the text to be generated into the text input box through typing input, voice input, copy-paste input, etc., and then select the style required for the text to be generated from the multiple style options. The user device 106 can determine the style requirement information of the text to be generated according to the selected style option of the user, and then the user device 106 can generate a text generation request according to the input data and the style requirement information.
[0097] Optionally, the multiple style options can include fixed style options (such as “Professional and rigorous”, “Vivid and interesting”, “Simple and easy to understand”, “Emotional resonance”, etc. shown in FIG. 6B), can include options that can be intelligently matched by the LLM according to the theme information (such as the “Intelligent matching” option shown in FIG. 6B), and can include a custom style input option (such as the “Custom style” option shown in FIG. 6B).
[0098] For example, in a convenient-to-understand example, if the user wants to generate a text in a professional and rigorous style with the main content of “Application of artificial intelligence in new media creation”, the user can input input data similar to “Application of artificial intelligence in new media creation” into the text input box of the theme information in FIG. 6B, and then select the “Professional and rigorous” style option in FIG. 6B, thereby completing the input of the input data and the style requirement information. Of course, this example does not limit the present disclosure in any way.
[0099] For example, in a convenient understanding example, if a user wants to generate a text with the main content of "application of artificial intelligence in new media creation", but cannot determine the style of the text, the user can input the input data similar to "application of artificial intelligence in new media creation" in the text input box of the theme information of FIG. 6B, and input or paste the text content of the style text sample in the text input box of "example text" of FIG. 6B to determine the style requirement information through the server. Of course, this example does not limit the present disclosure.
[0100] Based on this, through the above optional mode, the user can input the input data containing the theme information of the text to be generated through the text input box, and the user can input the style requirement information through the operation of the style option, so that the text generation request generated according to the input data and the style requirement information can effectively carry the theme information of the text to be generated and the style requirement information of the text to be generated, so as to generate the text meeting the predetermined style requirement in the subsequent generation, thereby better meeting the user's demand for text generation.
[0101] S504: receiving the text generated by the text generation model of the server in response to the text generation request, the text being a text with the theme information in the input data as the theme, and the text style meeting the style indicated by the style requirement information.
[0102] The text generation model is obtained by fine-tuning training based on a general generative base model.
[0103] In the embodiment of the present disclosure, after receiving the text generation request sent by the user equipment, the server (including but not limited to the cloud server shown in FIG. 1) can generate the corresponding text in response to the text generation request through the text generation model. When generating the text, the text generation model generates the content of the text with the theme information carried in the text generation request as the theme, and generates the text meeting the style indicated by the style requirement information based on the style requirement information carried in the text generation request, so as to accurately generate the text with the predetermined style requirement and theme requirement required by the user, and better meet the user's demand for text generation.
[0104] Optionally, the server can generate prompt information according to at least the theme information of the text to be generated and the style requirement information of the text to be generated carried in the text generation request sent by the user equipment, and then input the prompt information into the text generation model to generate the text with the theme information as the theme and the style meeting the style indicated by the style requirement information through the text generation model. Then, the server can send the generated text to the user equipment.
[0105] Based on this, through the text generation method in steps S502-S504, the text generation request can be generated according to the input data of the user and sent to the server, the text generation request carries the theme information of the text to be generated and the style requirement information of the text to be generated, the text generated by the text generation model of the server in response to the text generation request is received, and the text is a text generated by the text generation model with the theme information in the input data as the theme, and the style of the generated text meets the style indicated by the style requirement information. Therefore, by using the text generation model, the text meeting the predetermined style requirement can be generated more accurately, thereby better meeting the user's demand for text generation.
[0106] Optionally, the text generation method in the embodiments of the present disclosure further includes receiving the text material associated with the theme information input by the user. Optionally, the text material can be of any type, and any type of text material can be used, including but not limited to word, pdf, txt, ppt, excel, etc. The text material can also be a picture including text and the like. The text material records text content related to the theme 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 delivered to the text generation model by being spliced with the input data directly, or by being carried by the prompt information. However, it is not limited thereto, and other delivery methods to the text generation model are also applicable.
[0107] In some optional embodiments, the implementation of step S502 of generating a text request using the input data of the user can include: generating a text generation request using the input data of the user and the text material. On this basis, the text generated by the server can be a text generated by the text generation model with the theme information in the input data as the theme, based on the text material, and the text style meets the style indicated by the style requirement information.
[0108] Optionally, referring to the example of the human-computer interaction interface in FIG. 6C, the human-computer interaction interface can be the human-computer interaction interface of the client program on the user device 106, which further includes a material input box. The user can add text material through the material input box (which can be added by dragging the text material or added by selecting the text material after clicking), and can input the input data described above through any optional method to generate a text generation request according to the input data of the user and the text material.
[0109] Optionally, the server can generate prompt information according to at least the theme information, the style requirement information and the text material carried in the text generation request sent by the user equipment, and input the prompt information into the text generation model to generate a text with the theme information as the theme, based on the text material, and with the text style meeting the style indicated by the style requirement information. Then, the server can send the generated text to the user equipment.
[0110] For example, an application scenario of one example of generating a text through a text material can be that the user wants to generate a text containing the main internal part or semantic information or key information of an article, and then some reference example articles can be found as text materials associated with the theme information for input to generate a text generation request, so that the text generation model can generate a text according to the theme information, the text material and the style requirement information. It should be understood that this application scenario example does not serve as any limitation on the embodiments of the present disclosure.
[0111] It should be understood that the text material associated with the theme information input by the user in the present disclosure can enable the text generation model to generate a text meeting the style indicated by the style requirement information with the theme information in the input data as the theme and by referring to the content of the text material, so that the generated text can correspond to the text material in content on the basis of meeting the predetermined style requirement, thereby better meeting the user's demand for text generation.
[0112] Optionally, the text generation method in the embodiments of the present disclosure further includes receiving writing requirement information input by the user. Optionally, the writing requirement information can indicate a writing requirement of the text to be generated, and is intended to indicate a series of regulations, guidelines or desired standards to be followed by the text to be generated, and can include other writing requirements in addition to the style requirement, which can be used as a limiting condition for generating the text. For example, the generated text is required to be logically clear, the content has a certain timeliness, the core viewpoint needs necessary data and factual arguments as support, and the like. As shown in FIG. 6C, the user can input the writing requirement through a writing requirement input box in the human-computer interaction interface of the client program on the user equipment 106.
[0113] In still some optional embodiments, the implementation manner of generating a text request using the input data of the user in step S502 can include generating a text generation request using the input data of the user and the writing requirement information. On this basis, the text generated by the server can be a text generated by the text generation model with the theme information in the input data as the theme, according to the writing requirement information and the style requirement information.
[0114] Optionally, the user can input the writing requirement information through the text input box of the human-computer interaction interface. For example, it can be understood with reference to the human-computer interaction interface of FIG. 6C, and the input data and the writing requirement information can be input into the text input box, so as to generate a text generation request according to the input data and the writing requirement information of the user.
[0115] Optionally, the server can generate prompt information according to at least the theme information, the style requirement information and the writing requirement information carried in the text generation request sent by the user equipment, and then input the prompt information into the text generation model to generate a text with the theme information as the theme and according to the writing requirement information and the style requirement information through the text generation model. Then, the server can send the generated text to the user equipment.
[0116] For example, an application scenario of one example of generating a text through the writing requirement information can be that the user expects the generated text to have other requirements in addition to the style, such as “not allowed to have a person's name”, “need to have at least 3 famous quotations” and the like, which can be input as the writing requirement information as needed to generate a text generation request, so that the text generation model generates a text according to the theme information, the writing requirement information and the style requirement information. It should be understood that this application scenario example does not serve as any limitation on the embodiments of the present disclosure.
[0117] It should be understood that, by inputting the writing requirement information by the user, the text generation model can generate a text with the theme information in the input data as the theme and according to the writing requirement information, so that the generated text can meet the predetermined style requirement and also meet other writing requirements indicated by the writing requirement information in the content, thereby better meeting the user's demand for text generation.
[0118] With reference to the flowchart shown in FIG. 7, the embodiments of the present disclosure provide another text generation method, which focuses on the inference application of the generated text generation model from the perspective of the server, such as a cloud server. The text generation method includes the following steps S702 and S704, specifically:
[0119] S702: obtaining theme information of a text to be generated and style requirement information of the text to be generated from a text generation request sent by a user equipment, and generating prompt information.
[0120] Regarding the text generation request, the description of the related part in the above embodiments can be referred to, which will not be repeated here.
[0121] In step S702 of the embodiment of the present disclosure, after the user equipment sends the text generation request to the server, the server can generate prompt information according to the theme information of the text to be generated and the style requirement information of the text to be generated carried in the text generation request. The prompt information can be used for the text generation model to understand, so as to be used for text generation.
[0122] S704: inputting the prompt information into the text generation model to generate the text with the theme information as the theme and the style satisfying the style indicated by the style requirement information through the text generation model.
[0123] The text generation model is obtained based on the general generative base 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 base model in any manner. For example, the general generative base model can be trained in the manner described in the foregoing embodiment of the text generation model training method. Details can be understood with reference to the foregoing embodiment, and will not be described herein again.
[0124] Based on this, in the embodiment of the present disclosure, the text generation method through steps S702-S704 described above can generate prompt information at least according to the theme information of the text to be generated and the style requirement information of the text to be generated carried in the text generation request sent by the user equipment, and then input the prompt information into the text generation model to generate the text with the theme information as the theme and the style satisfying the style indicated by the style requirement information through the text generation model. Therefore, the text with the predetermined style requirement and theme requirement required by the user can be accurately generated, and the demand of the user for text generation can be better met.
[0125] Optionally, the text generation request also carries text material associated with the theme information. In some optional embodiments, step S702 described above can include: obtaining the theme information, the style requirement information and the text material from the text generation request sent by the user equipment, and generating the prompt information; and step S704 described above can include: inputting the prompt information into the text generation model to generate the text with the theme information as the theme, based on the text material, and with the style satisfying the style indicated by the style requirement information through the text generation model. Details of the implementation can be referred to the related description in the foregoing embodiment of the text generation method, and will not be described herein again.
[0126] It should be understood that, in the embodiments of the present disclosure, the topic information, the style requirement information and the text material generation prompt information carried in the text generation request sent by the user equipment are generated according to the topic information, the style requirement information and the text material generation prompt information carried in the text generation request sent by the user equipment, and the text generation model is inputted, so that the text generation model can generate a text with a style meeting the style indicated by the style requirement information with the topic information as the topic and in reference to the content of the text material, so that the generated text can meet the predetermined style requirement and correspond to the text material in content, thereby better meeting the user's demand for text generation.
[0127] Optionally, the text generation request also carries writing requirement information, and in some optional embodiments, the step S702 can include obtaining the topic information, the style requirement information and the writing requirement information from the text generation request sent by the user equipment, and generating the prompt information, and the step S704 can include inputting the prompt information into the text generation model to generate a text with the topic information as the topic and in accordance with the writing requirement information and the style requirement information through the text generation model. The specific implementation can refer to the related description in the foregoing text generation method embodiments, and will not be described here.
[0128] Optionally, when the style requirement information carried in the text generation request is a style text example, in some optional embodiments, the step S702 can include performing text style analysis on the style text example carried in the text generation request sent by the user equipment to obtain corresponding text style information, and generating the prompt information according to the topic information and the text style information. The specific implementation can refer to the related description in the foregoing text generation method embodiments, and will not be described here.
[0129] It should be understood that, in the embodiments of the present disclosure, the prompt information is generated according to the topic information, the style requirement information and the writing requirement information carried in the text generation request sent by the user equipment, and the text generation model is inputted, so that the text generation model can generate a text with a style meeting the style indicated by the style requirement information with the topic information in the input data as the topic and in reference to the writing requirement information, so that the generated text can meet the predetermined style requirement and correspond to other writing requirements indicated by the writing requirement information in content, thereby better meeting the user's demand for text generation.
[0130] In some optional embodiments, with reference to the flow chart shown in FIG. 8, any implementation manner of the step S704 can include the following steps S7041, S7042 and S7043, specifically:
[0131] S7041: inputting the prompt information into the text generation model to generate text outline data matched with the topic information through the text generation model.
[0132] Optionally, the text outline data can briefly describe the content of each part of the text to be generated. Since the text generation model has strong text generation capability, it can randomly generate text outline data in various styles. Therefore, it can allow the selection of appropriate text outline data to generate new prompt information as needed to achieve text generation.
[0133] For ease of understanding, in some examples, it is assumed that the theme information is information indicating the generation of a computer theory text. Then, one of the text outline data generated by the text generation model according to the prompt information and matching the theme information can be:
[0134]
[0135] I. History of computer development
[0136] 1.1 XXXXX
[0137] 1.2 XXXXXXX
[0138] ...
[0139] II. Components of a computer
[0140] 2.1 XXXXX
[0141] 2.2 XXXXXXX
[0142] ...
[0143]
[0144] As can be seen from the above examples, the text outline data is similar to a directory and can briefly describe the content of each part of the text to be generated. Through the text outline data, it is convenient to continue text generation.
[0145] S7042: Generate new prompt information using the text outline data, the theme information, and the style requirement information.
[0146] After obtaining the text outline data, new prompt information can be generated according to the text outline data, the theme information, and the style requirement information, so as to input the new prompt information into the text generation model for text generation.
[0147] In some optional embodiments, step S7042 can include: receiving text outline data modified by a user on the text outline data; and generating new prompt information according to the modified text outline data, the theme information, and the style requirement information.
[0148] It should be understood that in the above embodiment, the user is allowed to modify the text outline data generated in step S7041, and new prompt information is generated according to the modified text outline data, the theme information and the style requirement information, so as to enable the generated text to meet the predetermined preset style requirements and better meet the user's use requirements for the generated text.
[0149] Optionally, after the text outline data is generated in step S7041, the server (cloud server 102) can send the text outline data to the user equipment 106 and display it through an interactive control such as an interactive text display control. The user using the user equipment 106 can modify the text outline data according to the requirements. After the modification is completed, the user equipment 106 sends the modified text outline data to the server, and the server receives the modified text outline data, so as to generate new prompt information according to the modified text outline data, the theme information and the style requirement information, for subsequent text generation.
[0150] Of course, in other optional embodiments, if the user is satisfied with the text outline data generated in step S7041, the user can not modify the text outline data, and the server can directly generate new prompt information according to the text outline data generated in step S7041, the theme information and the style requirement information, for subsequent text generation.
[0151] S7043: inputting the new prompt information into the text generation model to generate a text with the theme information as the theme and the style satisfying the style requirement information indicated by the style requirement information according to the text outline data through the text generation model.
[0152] Based on this, in the present disclosure, through the optional implementation of steps S7041-S7043, by inputting the prompt information into the text generation model, generating the text outline data matched with the theme information through the text generation model, and then generating the new prompt information according to the text outline data, the theme information and the style requirement information, and inputting the new prompt information into the text generation model, the text with the theme information as the theme and the style satisfying the style requirement information indicated by the style requirement information can be conveniently and effectively generated according to the text outline data through the text generation model, which can effectively ensure the correspondence between the content of the generated text meeting the predetermined style requirements and the theme, and better meet the user's use requirements for the generated text.
[0153] FIG. 9 is a schematic diagram of a scene example of a text generation scheme according to an embodiment of the present disclosure. The text generation scheme according to an embodiment of the present disclosure will be understood in whole in combination with FIG. 9. It should be understood that the scene example shown in FIG. 9 is only used to facilitate understanding of the embodiments of the present disclosure, and does not limit the present disclosure in any way.
[0154] As shown in FIG. 9, it is assumed that the user inputs "please help me write a paper on computer principles in a professional and rigorous style" (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 information prompt based on the input data, which includes the information "please help me write a paper on computer principles in a professional and rigorous style". The prompt information prompt is input into the text generation model of the cloud server, which in this example is an LLM that has been fine-tuned. After receiving the prompt information, the LLM generates a paper on computer principles in accordance with the style requirement information "professional and rigorous style" and outputs the paper.
[0155] Further, the cloud server can send the generated text to the user device for display to the user through the user device.
[0156] As can be seen, through the text generation model in this example, text can be effectively generated in accordance with the style required by the user.
[0157] The embodiments of the present disclosure also provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus; the memory is used to store a computer program; the processor is used to execute the method in any one of the preceding method embodiments by running the computer program stored on the memory.
[0158] FIG. 10 shows a structural block diagram of an optional electronic device in the embodiments of the present disclosure. The embodiments of the present disclosure do not limit the specific implementation of the electronic device 1000. As an exemplary, with reference to FIG. 10, the electronic device 1000 provided by the embodiments of the present disclosure includes a processor 1002, a communication interface 1004, a memory 1006, and a communication bus 1008. Among them:
[0159] The processor 1002, the communication interface 1004, and the memory 1006 complete mutual communication through the communication bus 1008.
[0160] The communication interface 1004 is used to communicate with other electronic devices or servers.
[0161] The processor 1002 is used to execute the computer program 1010, and specifically can execute the related steps in any one of the preceding method embodiments.
[0162] Specifically, the computer program 1010 can include program codes including computer operation instructions.
[0163] The processor 1002 can 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 disclosure. The one or more processors included in the smart device can be processors of the same type, such as one or more CPUs; or can be processors of different types, such as one or more CPUs and one or more ASICs.
[0164] The memory 1006 is configured to store the computer program 1010. The memory 1006 can include a high-speed RAM memory, and can also include a non-volatile memory, for example, at least one disk memory.
[0165] The computer program 1010 can be specifically configured to cause the processor 1002 to perform the method of any of the preceding method embodiments.
[0166] The specific implementation of each step in the computer program 1010 can refer to the corresponding description in the corresponding steps and units of any of the preceding method embodiments, and will not be described here. It can be clearly understood by those skilled in the art that, for the convenience and brevity of description, the specific working process of the device and the module described above can refer to the corresponding process description in the preceding method embodiments, and will not be described here.
[0167] In addition, the embodiments of the present disclosure further provide a computer storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the method of any of the preceding method embodiments. The computer storage medium includes but is not limited to: a CD-ROM (Compact Disc Read-Only Memory), a RAM (Random Access Memory), a floppy disk, a hard disk, or a magneto-optical disk, etc.
[0168] The embodiments of the present disclosure further provide a computer program product, including a computer program, which, when executed by a processor, implements the method of any of the preceding method embodiments.
[0169] In addition, it should be noted that the information related to the user (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to sample data for training the model, data for analysis, stored data, displayed data, etc.) involved in the embodiments of the present disclosure are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the country and region, and provide corresponding operation portal for the user to choose authorization or refusal.
[0170] It should be noted that, according to the needs of implementation, each component / step described in the embodiments of the present disclosure can be split into more components / steps, or two or more components / steps or part of the operation of the components / steps can be combined into a new component / step, to achieve the purpose of the embodiments of the present disclosure.
[0171] The above method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or 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 downloaded through a network and stored in a remote recording medium or non-transitory machine readable medium and then 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 computer, a special processor or programmable or special hardware such as an application specific integrated circuit (ASIC) or a field programmable gate array (FPGA). It can be understood that the computer, processor, microprocessor controller or programmable hardware includes a storage component (for example, random access memory (RAM), read-only memory (ROM), flash memory, etc.) that can store or receive software or computer code, when the software or computer code is accessed and executed by the computer, processor or hardware, the method described herein is implemented. In addition, when the general computer accesses the code for implementing the method shown herein, the execution of the code will convert the general computer into a special computer for executing the method shown herein.
[0172] Those skilled in the art can understand that the units and method steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to realize the described functions for specific applications, but such implementation should not be considered beyond the scope of the embodiments of the present disclosure.
[0173] The term "comprising" and its variants, as used herein, are inclusive or open-ended and do not exclude additional, unrecited elements or method steps. 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 additional embodiment"; the term "some embodiments" means "at least some embodiments". It is noted that the concepts of "first", "second", etc. mentioned in the embodiments of the present disclosure are only used to distinguish different devices, modules or units, and do not imply the order or mutual dependency of the functions performed by these devices, modules or units. It should be noted that the modification of "one", "multiple" mentioned in the embodiments of the present disclosure is illustrative and not restrictive, and those skilled in the art should understand that unless otherwise explicitly indicated in the context, it should be understood as "one or more".
[0174] The above embodiments are only used to illustrate but not limit the embodiments of the present disclosure. Those skilled in the art can make various changes and modifications to the embodiments of the present disclosure without departing from the spirit and scope of the embodiments of the present disclosure, and all equivalent technical solutions belong to the scope of the embodiments of the present disclosure. The patent protection scope of the embodiments of the present disclosure should be defined by the claims.
Claims
1. A method for generating text, comprising: generating a text generation request using input data of a user and sending the text generation request to a server, the text generation request carrying theme information of a text to be generated and style requirement information of the text to be generated; receiving a text generated by a text generation model of the server in response to the text generation request, the text being a text with a theme of the theme information in the input data and a style satisfying the style indicated by the style requirement information, the text generation model being obtained based on a general generative base model.
2. The method of claim 1, wherein, The generating a text generation request using input data of a user comprises: receiving input data of a user input through a text input box in a human-computer interaction interface, the input data containing theme information and style requirement information of a text to be generated, and generating the text generation request according to the input data; or, receiving input data of a user input through a text input box in a human-computer interaction interface, the input data containing theme information of a text to be generated, and receiving style requirement information input by a user through a style interaction control in the human-computer interaction interface; and generating the text generation request according to the input data and the style requirement information.
3. The method of claim 2, wherein, The receiving input data of a user input through a text input box in a human-computer interaction interface, the input data containing theme information of a text to be generated, and receiving style requirement information input by a user through a style interaction control in the human-computer interaction interface comprises: generating the text generation request according to the input data and the style requirement information, comprising: receiving input data of a user input through a text input box in a human-computer interaction interface, the input data containing theme information of a text to be generated, and receiving a selection operation of a user on a plurality of style options displayed in the human-computer interaction interface, and determining the style requirement information of the text to be generated according to the selection operation; and generating the text generation request according to the input data and the style requirement information; or, receiving input data of a user input through a text input box in a human-computer interaction interface, the input data containing theme information of a text to be generated, and receiving custom style requirement information input by a user through a style information input control in the human-computer interaction interface; and generating the text generation request according to the input data and the custom style requirement information; or, receiving input data of a user input through a text input box in a human-computer interaction interface, the input data containing theme information of a text to be generated, and receiving a style text sample input by a user through a style information input control in the human-computer interaction interface; and generating the text generation request according to the input data and the style text sample.
4. The method of any one of claims 1-3, wherein: the method further comprises receiving text material input by the user and associated with the theme information; the generating a text generation request using input data of a user comprises: generating a text generation request using input data of a user and the text material. The text is a text generated based on the text material by the text generation model with the theme information in the input data as the theme, and the text style meets the style indicated by the style requirement information.
5. The method of any one of claims 1-3, wherein, The method further comprises receiving the writing requirement information input by the user; The generating of the text generation request using the input data of the user comprises: generating the text generation request using the input data of the user and the writing requirement information; The text is a text generated according to the writing requirement information and the style requirement information by the text generation model with the theme information in the input data as the theme.
6. A text generation method, comprising: obtaining theme information of a text to be generated and style 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 to generate a text with the theme information as the theme and the style meeting the style indicated by the style requirement information by the text generation model; The text generation model is obtained based on a general generative base model.
7. The method of claim 6, wherein, The text generation request also carries text material associated with the theme information; The obtaining of the theme information of the text to be generated and the style requirement information of the text to be generated from the text generation request sent by the user device and the generation of the prompt information comprises: obtaining the theme information, the style requirement information and the text material from the text generation request sent by the user device, and generating the prompt information; The inputting of the prompt information into the text generation model to generate a text with the theme information as the theme and the style meeting the style indicated by the style requirement information by the text generation model comprises: inputting the prompt information into the text generation model to generate a text with the theme information as the theme and the style meeting the style indicated by the style requirement information based on the text material by the text generation model.
8. The method of claim 6, wherein, The text generation request also carries writing requirement information; The obtaining of the theme information of the text to be generated and the style requirement information of the text to be generated from the text generation request sent by the user device and the generation of the prompt information comprises: obtaining the theme information, the style requirement information and the writing requirement information from the text generation request sent by the user device, and generating the prompt information; The inputting of the prompt information into the text generation model to generate a text with the theme information as the theme and the style meeting the style indicated by the style requirement information by the text generation model comprises: inputting the prompt information into the text generation model to generate a text with the theme information as the theme and according to the writing requirement information and the style requirement information by the text generation model.
9. The method of claim 6, wherein, The style requirement information is a style text example; The subject information of the text to be generated and the style requirement information of the text to be generated are obtained from the text generation request sent by the user equipment, and prompt information is generated, including: performing text style analysis on the style text sample carried in the text generation request sent by the user equipment to obtain corresponding text style information; and generating prompt information according to the subject information and the text style information.
10. The method according to any one of claims 6-9, wherein, The prompt information is input into a text generation model to generate a text with the subject information as the subject and the style satisfying the style requirement information indicated by the style requirement information through the text generation model. The prompt information is input into a text generation model to generate a text with the subject information as the subject and the style satisfying the style requirement information indicated by the style requirement information through the text generation model. The prompt information is input into a text generation model to generate a text with the subject information as the subject and the style satisfying the style requirement information indicated by the style requirement information through the text generation model. The prompt information is input into a text generation model to generate a text with the subject information as the subject and the style satisfying the style requirement information indicated by the style requirement information through the text generation model.
11. The method of claim 10, wherein, The prompt information is input into a text generation model to generate a text with the subject information as the subject and the style satisfying the style requirement information indicated by the style requirement information through the text generation model. The prompt information is input into a text generation model to generate a text with the subject information as the subject and the style satisfying the style requirement information indicated by the style requirement information through the text generation model.
12. A text generation model training method, comprising: obtaining training samples for model training, the training samples comprising prompt information samples and corresponding reply data samples, the prompt information samples containing style requirement information of text to be generated, and the text style of the reply data samples matching the style indicated by the style requirement information; inputting the prompt information samples into a general generative base model to enable the general generative base model to generate text generation data samples based on the prompt information samples; performing fine-tuning training on the general generative base model according to the difference between the text style of the text generation data samples and the text style of the reply data samples to obtain a text generation model capable of generating text with a corresponding style according to the style requirement information. The obtaining of the training samples for model training comprises:
13. The method of claim 12, wherein, obtaining training sample groups from a training sample set for model training, each training sample group comprising a plurality of training samples, the plurality of training samples comprising 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 being identical in information except for the style requirement information; obtaining the plurality of training samples in the same training sample group in sequence as a unit to train the general generative base model. The fine-tuning training on the general generative base model according to the difference between the text style of the text generation data samples and the text style of the reply data samples comprises:
14. The method of claim 12 or 13, wherein, perform text style analysis on the text generation data sample to obtain a corresponding text style; perform fine-tuning training on the general generative base model according to a difference between the text style of the text generation data sample and the text style of the reply data sample.
15. The method according to any one of claims 12-14, wherein, If the prompt information sample contains a style text example, the inputting of the prompt information sample into the general generative base model comprises: performing text style analysis on the style text example to obtain a text style corresponding to the style text example; generating new prompt information by taking the obtained text style as style requirement information and information in the prompt information sample except the style text example; inputting the new prompt information into the general generative base model.
16. The method according to any one of claims 12-15, wherein, The method further comprises: updating style requirement information in the prompt information sample according to the text style of the text generation data sample; generating new training samples based on the prompt information sample after the updating of the style requirement information and the text generation data sample.
17. An electronic device comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus; the memory is configured to store a computer program; the processor is configured to execute the method in any one of claims 1-16 by running the computer program stored on the memory. 18.A computer storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method in any one of claims 1-16. 19.A computer program product comprising a computer program, the computer program being executed by a processor to implement the method in any one of claims 1-16.
Citation Information
Patent Citations
Text generation method and device, electronic equipment and storage medium
CN111221940A
Generation method and device of Chinese universal language, equipment and storage medium
CN116151194A
Article generation method and apparatus based on large language model, and electronic device
CN117709295A
Text generation method, text model training method, electronic equipment, storage medium and program product
CN119090002A
Automatic writing style detection and rewriting
US20240061999A1