Prompt generation method and system, computer equipment and storage medium
The propt generation model built through the Transformer network architecture solves the problem of propt writing in AI painting, and achieves rapid and efficient generation of propt that conforms to the model capabilities, improving user experience and creative effects.
Patent Information
- Application Number
- CN202411194149.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-11-29
AI Technical Summary
In the existing AI painting technology, when users write propt, due to the differences in the understanding and processing capabilities of different models for propt, non-professional users find it difficult to generate propt that meets the model's capabilities, which limits the ability and effect of AI painting technology.
The Transformer network architecture is used to build a propt generative model, and the target propt generative text is collected and preprocessed, and the training generator and discriminator is used for adversarial training to generate a target propt that conforms to the understanding and processing capabilities of the target model.
It realizes the rapid, efficient and accurate generation of target propts that conform to the understanding and processing capabilities of the target model, simplifies the interaction between users and AI painting models, and improves the user's convenience and creative effect.
Smart Images

Figure CN119047431A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a prompt generation method, system, computer equipment and non-volatile computer-readable storage medium. Background Art
[0002] At present, with the rapid development of artificial intelligence (AI) technology, AI painting technology has gradually become an emerging technology focus in the fields of art, design, media and advertising. AI painting is a technology that automatically generates images through machine learning algorithms, especially neural network-based methods. The development of this technology provides artists, designers, media and advertisers with huge innovation space and creative possibilities. For example, artists can use AI painting to expand their creativity and ideas, designers can use AI painting to design buildings and products, and media and advertisers can use AI painting to create publicity and advertising materials.
[0003] Currently, in existing AI paintings, users guide the model to generate images of specific themes or styles by inputting instructions called prompts. As an important form of network input, prompt plays a vital role in the process of model generation of images. Therefore, in the process of using AI painting, users need to input clear and specific required content, required visual effects of artworks, and understand the limitations of different models in order to formulate prompts that meet the capabilities of the model. However, in the prior art, due to differences in the understanding and processing capabilities of different AI painting models for prompts, users face many challenges when writing prompts. For non-professional users, it is difficult to correctly write prompts that are consistent with the understanding and processing capabilities of AI painting models, which limits their ability and effectiveness in using AI painting technology.
[0004] In summary, how to provide a prompt generation method, system, computer device and non-volatile computer-readable storage medium that can quickly, efficiently and accurately generate a target prompt that meets the target model's understanding and processing capabilities is a problem that needs to be urgently solved by technical personnel in this field. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the object of the present invention is to provide a prompt generation method, system, computer device and non-volatile computer-readable storage medium that can be used in financial technology or other related fields, aiming to solve the problem of how to quickly, efficiently and accurately generate a target prompt that meets the understanding and processing capabilities of the target model.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions:
[0007] A prompt generation method, comprising:
[0008] Collecting a number of prompt texts, and preprocessing the prompt texts to obtain corresponding training samples;
[0009] Building an initial model based on the Transformer network architecture, and training the initial model using the training samples to obtain a corresponding prompt generation model;
[0010] Based on the prompt generation model, the original prompt input by the target user is transformed to generate a corresponding target prompt.
[0011] In a further technical solution, in the prompt generation method, in the step of collecting a plurality of prompt texts and preprocessing the plurality of prompt texts to obtain corresponding training samples,
[0012] The preprocessing includes: data cleaning, word segmentation, masking, and data enhancement.
[0013] In a further technical solution, the prompt generation method, wherein the initial model is constructed based on the Transformer network architecture, and the initial model is trained using the training sample to obtain a corresponding prompt generation model, comprises:
[0014] An initial model is constructed based on the Transformer network architecture; the initial model includes a generator, a discriminator, and an output layer;
[0015] The training samples are used to perform adversarial training on the generator and the discriminator. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
[0016] In a further technical solution, the prompt generation method, wherein the training sample is used to perform adversarial training on the generator and the discriminator, and when both the generator and the discriminator meet the preset requirements, a prompt generation model corresponding to the initial model is generated, comprising:
[0017] The generator and the discriminator are adversarially trained using the training samples, and random noise is introduced during the training process. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
[0018] In a further technical solution, the prompt generation method, wherein the original prompt input by the target user is converted based on the prompt generation model to generate a corresponding target prompt, includes:
[0019] Get the original prompt entered by the target user;
[0020] The original prompt is input into the prompt generation model for transformation to generate corresponding multiple target prompts.
[0021] In a further technical solution, the prompt generation method, wherein the original prompt is input into the prompt generation model for conversion to generate a corresponding plurality of target prompts, comprises:
[0022] In response to the target user's selection instruction for the multiple target prompts, a target prompt selected by the target user is input into the target model.
[0023] In a further technical solution, in the prompt generation method, the target model is an AI painting model.
[0024] A prompt generation system, comprising:
[0025] A collection module, used to collect a number of prompt texts, and obtain corresponding training samples after preprocessing the plurality of prompt texts;
[0026] A training module is used to build an initial model based on the Transformer network architecture, and to obtain a corresponding prompt generation model after training the initial model using the training samples;
[0027] The conversion module is used to convert the original prompt input by the target user based on the prompt generation model to generate a corresponding target prompt.
[0028] A computer device, wherein the computer device comprises at least one processor; and
[0029] a memory communicatively connected to the at least one processor; wherein,
[0030] The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, the prompt generation method as described in any one of the above items can be implemented.
[0031] A non-volatile computer-readable storage medium stores a computer program, wherein the computer program, when executed by at least one processor, can implement any of the prompt generation methods described above.
[0032] Compared with the prior art, the present invention provides a prompt generation method, system, computer device and non-volatile computer-readable storage medium, wherein the method includes: collecting a number of prompt texts, pre-processing the several prompt texts to obtain corresponding training samples; building an initial model based on the Transformer network architecture, training the initial model with the training samples to obtain a corresponding prompt generation model; based on the prompt generation model, transforming the original prompt input by the target user to generate a corresponding target prompt. In this way, the method of the present invention can achieve fast, efficient and accurate generation of a target prompt that meets the understanding and processing capabilities of the target model. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 A flowchart of a prompt generation method provided in an embodiment of the present invention.
[0035] Figure 2 A schematic diagram of functional modules of a prompt generation system provided in an embodiment of the present invention.
[0036] Figure 3 A schematic diagram of the hardware structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0038] In the description of the present invention, the terms "include", "including", "have", "contain", etc. are all open terms, which mean including but not limited to. The descriptions with reference to the terms "one embodiment", "a specific embodiment", "some embodiments", "for example", etc. mean that the specific features, structures or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. The order of steps involved in each embodiment is used to schematically illustrate the implementation of the present application, and the order of steps therein is not limited and can be appropriately adjusted as needed.
[0039] Various non-limiting embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.
[0040] At present, with the rapid development of artificial intelligence (AI) technology, AI painting technology has gradually become an emerging technology focus in the fields of art, design, media and advertising. AI painting is a technology that automatically generates images through machine learning algorithms, especially neural network-based methods. The development of this technology provides artists, designers, media and advertisers with huge innovation space and creative possibilities. For example, artists can use AI painting to expand their creativity and ideas, designers can use AI painting to design buildings and products, and media and advertisers can use AI painting to create publicity and advertising materials.
[0041] Currently, in existing AI paintings, users guide the model to generate images of specific themes or styles by inputting instructions called prompts. As an important form of network input, prompt plays a vital role in the process of model generation of images. Therefore, in the process of using AI painting, users need to input clear and specific required content, required visual effects of artworks, and understand the limitations of different models in order to formulate prompts that meet the capabilities of the model. However, in the prior art, due to differences in the understanding and processing capabilities of different AI painting models for prompts, users face many challenges when writing prompts. For non-professional users, it is difficult to correctly write prompts that are consistent with the understanding and processing capabilities of AI painting models, which limits their ability and effectiveness in using AI painting technology.
[0042] In summary, how to provide a prompt generation method, system, computer device and non-volatile computer-readable storage medium that can quickly, efficiently and accurately generate a target prompt that meets the target model's understanding and processing capabilities is a problem that needs to be urgently solved by technical personnel in this field.
[0043] To solve the above problems, see Figure 1 The embodiment of the present invention provides a prompt generation method, wherein the method comprises the steps of:
[0044] S100, collecting a number of prompt texts, and preprocessing the plurality of prompt texts to obtain corresponding training samples;
[0045] S200, constructing an initial model based on the Transformer network architecture, and training the initial model using the training sample to obtain a corresponding prompt generation model;
[0046] S300: Based on the prompt generation model, convert the original prompt input by the target user to generate a corresponding target prompt.
[0047] Furthermore, in the prompt generation method, in step S100, a plurality of prompt texts are collected, and the plurality of prompt texts are preprocessed to obtain corresponding training samples, wherein:
[0048] The preprocessing includes: data cleaning, word segmentation, masking, and data enhancement.
[0049] Furthermore, in the prompt generation method, the target model is an AI painting model.
[0050] In the specific implementation, in this embodiment, a number of prompt texts are collected, and the corresponding training samples are obtained after preprocessing the prompt texts, wherein the preprocessing includes: data cleaning, word segmentation, masking, and data enhancement;
[0051] The specific implementation process is as follows:
[0052] 1) Data Collection
[0053] First, it is necessary to collect several prompt texts from the user that have been input into the target model (in this embodiment, the AI painting model) in the history; this can be achieved through a user interface, where the user enters a description text (i.e., prompt text) of the task they want the target model to perform or the content they want to generate;
[0054] 2) Data cleaning
[0055] The collected raw text data may contain noise, such as extra spaces, special characters, or irrelevant information; in the data cleaning step, operations to remove these irrelevant characters will be performed, and the text may be standardized (for example, converting all text to lowercase to eliminate differences in upper and lower case);
[0056] 3) Participle
[0057] Tokenization is the process of breaking a text string into smaller units, such as words or characters. This helps the initial model better understand the structure of the text. For English, this may mean breaking up sentences by spaces and punctuation. For languages such as Chinese, a specific tokenization algorithm may be used to identify word boundaries.
[0058] 4) Mask operation
[0059] In some models, such as BERT or its variants, masking is a technique where certain input tokens are replaced with special tags (such as [MASK]), forcing the model to learn to infer the meaning of these tokens from the context; this can be used as part of a preprocessing step to prepare the data for initial model training;
[0060] 5) Data Augmentation
[0061] Data augmentation is a technique to improve the generalization ability of the model by applying a series of transformations to the original data to generate new training samples; for example, data diversity can be increased by synonym replacement, sentence reorganization, random insertion, deletion, or exchange of partial text fragments;
[0062] 6) Feature extraction
[0063] After preprocessing, it is usually necessary to extract features from the text. These features can be word embeddings, sentence embeddings, or any other form of numerical representation that can be used as input by the initial model.
[0064] 7) Construct training samples
[0065] Finally, the cleaned, segmented, masked, and enhanced text is converted into a format that the initial model can understand, such as feature vectors or tensors, which will be input into the initial model as training samples;
[0066] The above process constitutes the basic process of converting the prompt text input by the user into training samples, providing prepared data for subsequent initial model training and fine-tuning; in actual operation, the above process can also be adjusted according to the requirements and characteristics of a specific model;
[0067] The AI painting model of this embodiment is a model that uses artificial intelligence technology to generate visual art works. The following is a brief introduction to its workflow:
[0068] 1) Learning phase
[0069] The AI painting model first learns from a large amount of image data to identify different visual elements, styles, and compositions;
[0070] 2) User Input
[0071] The user provides a text prompt to describe the content or style of the image they want to generate, such as "tranquil landscape painting" or "cyberpunk-style city";
[0072] 3) Text processing
[0073] The AI painting model converts the text prompt into an understandable format, which may include word segmentation, keyword extraction, and conversion into feature vectors;
[0074] 4) Image Generation
[0075] Based on the processed text information, the AI painting model uses a generative algorithm (such as GANs, VAEs, or diffusion models) to create an image;
[0076] 5) Output and iteration
[0077] The AI painting model generates an initial image, which the user can evaluate and provide feedback on; in some cases, the AI painting model can iterate based on the feedback and optimize the generated image;
[0078] The AI painting model combines artistic creation with technological innovation, allowing users to explore visual art in new ways, while also bringing new possibilities to the fields of art and design.
[0079] Furthermore, the prompt generation method, wherein the step S200, constructing an initial model based on the Transformer network architecture, and training the initial model using the training sample to obtain a corresponding prompt generation model, comprises:
[0080] An initial model is constructed based on the Transformer network architecture; the initial model includes a generator, a discriminator, and an output layer;
[0081] The training samples are used to perform adversarial training on the generator and the discriminator. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
[0082] Furthermore, the prompt generation method, wherein the training sample is used to perform adversarial training on the generator and the discriminator, and when both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated, including:
[0083] The generator and the discriminator are adversarially trained using the training samples, and random noise is introduced during the training process. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
[0084] In the specific implementation, in this embodiment, an initial model is constructed based on the Transformer network architecture; the initial model includes a generator, a discriminator, and an output layer; the training samples are used to perform adversarial training on the generator and the discriminator, and random noise is introduced during the training process. When the generator and the discriminator both meet the preset requirements, a prompt generation model corresponding to the initial model is generated;
[0085] The specific implementation process is as follows:
[0086] 1) Build the initial model
[0087] An initial model is constructed based on the Transformer network architecture. Transformer is a network architecture based on the self-attention mechanism. It has the advantages of parallel computing and long sequence processing and has been widely used in the field of natural language processing.
[0088] The initial model includes a generator, a discriminator, and an output layer;
[0089] Generator: responsible for generating corresponding prompts based on the input text description;
[0090] Discriminator: responsible for evaluating the quality of the generated prompt and comparing it with the original prompt;
[0091] Output layer: output the generated prompt in text form;
[0092] 2) Prepare training samples
[0093] Based on the training samples collected and preprocessed above, these training samples will be used to train the generator to generate accurate prompts, and train the discriminator to correctly evaluate the generated prompts;
[0094] 3) Adversarial training and introduction of random noise
[0095] The generator and discriminator are trained adversarially using training samples. In each training iteration, the generator receives a random noise vector and a text description as input to generate a prompt. The discriminator evaluates the similarity between the generated prompt and the original prompt. In this process, the introduction of random noise increases the diversity of generated samples, prompting the generator to learn how to recover meaningful prompts from noise.
[0096] 4) Optimize model parameters
[0097] Through optimization techniques such as back-propagation and gradient descent, the parameters of the generator and discriminator are updated according to a loss function (such as contrastive loss or binary cross entropy loss); the loss function measures the difference between the generated prompt and the original prompt, and the goal is to minimize this difference, thereby improving the quality of the generated prompt;
[0098] 5) Evaluate and generate prompt generation model
[0099] When the prompt generated by the generator and the evaluation ability of the discriminator both meet the preset performance requirements, the adversarial training is stopped. At this point, the initial model is transformed into a prompt generation model that can stably generate high-quality prompts after training and optimization. Through the output layer, the prompt generation model can output the expected prompt according to the text description input by the user, so that the user can use it on the target model later.
[0100] Through the above process, a prompt generation model based on the Transformer network architecture can be trained. The prompt generation model can generate prompts that meet the requirements based on the user's text description, meeting the needs of non-professional users in AI painting or other text generation scenarios.
[0101] Furthermore, the prompt generation method, wherein the step S300, based on the prompt generation model, converts the original prompt input by the target user to generate a corresponding target prompt, includes:
[0102] Get the original prompt entered by the target user;
[0103] The original prompt is input into the prompt generation model for transformation to generate corresponding multiple target prompts.
[0104] Furthermore, the prompt generation method, wherein the original prompt is input into the prompt generation model for conversion to generate a corresponding plurality of target prompts, comprises:
[0105] In response to the target user's selection instruction for the multiple target prompts, a target prompt selected by the target user is input into the target model.
[0106] In specific implementation, in this embodiment, an original prompt input by a target user is obtained; the original prompt is input into the prompt generation model for conversion to generate a corresponding plurality of target prompts; in response to a selection instruction of the target user for the plurality of target prompts, a target prompt selected by the target user is input into the target model;
[0107] The specific implementation process is as follows:
[0108] 1) User input collection
[0109] First, obtain the original prompt that the target user is going to input into the target model (such as an AI painting model); this original prompt is the basic description or theme that the target user wants the target model to generate related images;
[0110] 2) Generate target prompt
[0111] The original prompt input by the target user is input into the trained prompt generation model for conversion; the prompt generation model uses its generator part and combines the random noise vector to generate multiple candidate target prompts related to the original prompt, and these candidate target prompts can all meet the understanding and processing capabilities of the target model;
[0112] This step can provide target users with a series of options to increase the diversity of choices;
[0113] 3) User selection
[0114] The generated multiple target prompts that meet the target model's understanding and processing capabilities are displayed to the target user, and the target user can select a target prompt that best meets his or her expectations from these candidate options according to his or her preferences or needs;
[0115] This step allows the target users to participate in the generation process, ensuring that the final generated text is closer to the actual needs of the target users;
[0116] 4) Respond to user selection
[0117] Once the target user selects a target prompt, the selected target prompt will be input into the target model; if the target model is an AI model for text generation, such as AI painting description generation or other types of text creation, this step will trigger the target model to generate the final text output (such as the AI painting model generating the image required by the target user);
[0118] 5) Output the final result
[0119] After receiving the selected target prompt, the target model uses its internal algorithm and learned knowledge to generate the final text or image description and presents it to the target user as output; for example, if this is an AI painting model, the final output may be a descriptive text or image for further use by artists or designers;
[0120] Through the above process, not only can a variety of text (target prompt) options be generated, but it can also ensure that the user's choice is incorporated into the final creation process, thereby improving user satisfaction and the relevance of the generated content.
[0121] It can be seen from the above method embodiments that the prompt generation method provided by the present invention at least includes: collecting a number of prompt texts, preprocessing the several prompt texts, and obtaining corresponding training samples; building an initial model based on the Transformer network architecture, and training the initial model with the training samples to obtain a corresponding prompt generation model; based on the prompt generation model, transforming the original prompt input by the target user to generate a corresponding target prompt; etc. In this way, the method of the present invention can achieve fast, efficient and accurate generation of a target prompt that meets the understanding and processing capabilities of the target model.
[0122] Specifically, the prompt generation method provided in the embodiment of the present invention, i.e., the method for generating an AI painting prompt based on a Transformer network architecture, can generate a corresponding AI painting prompt according to a prompt provided by a user, thereby simplifying the interaction and operation process between the user and the computer, and improving the convenience and comfort of the user;
[0123] At the same time, the embodiments of the present invention can generate a large number of diverse AI painting prompts, covering different themes, emotions and styles, providing rich resources for the stimulation of creativity and the creation of inspiration;
[0124] In addition, the embodiment of the present invention can generate an AI painting prompt that meets the user's personalized needs based on the input and needs provided by the user, thereby realizing customized creation;
[0125] Finally, the embodiment of the present invention utilizes the semantic understanding and logical reasoning capabilities of the network to generate more accurate and logical AI painting prompts, bringing more opportunities and possibilities for the creation and application of AI paintings.
[0126] It should be understood that, although the present application provides method operation steps as described in the embodiments or flowcharts, more or less operation steps may be included based on conventional or non-creative labor, and these operation steps are not necessarily performed in sequence according to the embodiment or flowchart. The order of steps listed in the embodiment or flowchart is only one way of executing the order of many steps, and does not represent the only execution order. It should be noted that there is not necessarily a certain order between the above steps. A person of ordinary skill in the art can understand from the description of the embodiment of the present invention that in different embodiments, the above steps may have different execution orders, that is, they may be executed in parallel, or they may be executed in exchange, etc. Moreover, at least a part of the steps in the embodiment or flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but may be executed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but may be executed in turn, alternately or synchronously with other steps or at least a part of the sub-steps or stages of other steps.
[0127] Based on the above method embodiment, please refer to Figure 2 Another embodiment of the present invention further provides a prompt generation system, wherein the system comprises:
[0128] A collection module 11 is used to collect a number of prompt texts and obtain corresponding training samples after preprocessing the plurality of prompt texts;
[0129] A training module 12 is used to build an initial model based on the Transformer network architecture, and to obtain a corresponding prompt generation model after training the initial model using the training sample;
[0130] The conversion module 13 is used to convert the original prompt input by the target user based on the prompt generation model to generate a corresponding target prompt.
[0131] Furthermore, in the prompt generation system, the plurality of prompt texts are collected, and the plurality of prompt texts are preprocessed to obtain corresponding training samples, wherein:
[0132] The preprocessing includes: data cleaning, word segmentation, masking, and data enhancement.
[0133] Furthermore, in the prompt generation system, the target model is an AI painting model.
[0134] In the specific implementation, in this embodiment, a number of prompt texts are collected, and the corresponding training samples are obtained after preprocessing the prompt texts, wherein the preprocessing includes: data cleaning, word segmentation, masking, and data enhancement;
[0135] The specific implementation process is as follows:
[0136] 1) Data Collection
[0137] First, it is necessary to collect several prompt texts from the user that have been input into the target model (in this embodiment, the AI painting model) in the history; this can be achieved through a user interface, where the user enters a description text (i.e., prompt text) of the task they want the target model to perform or the content they want to generate;
[0138] 2) Data cleaning
[0139] The collected raw text data may contain noise, such as extra spaces, special characters, or irrelevant information; in the data cleaning step, operations to remove these irrelevant characters will be performed, and the text may be standardized (for example, converting all text to lowercase to eliminate differences in upper and lower case);
[0140] 3) Participle
[0141] Tokenization is the process of breaking a text string into smaller units, such as words or characters. This helps the initial model better understand the structure of the text. For English, this may mean breaking up sentences by spaces and punctuation. For languages such as Chinese, a specific tokenization algorithm may be used to identify word boundaries.
[0142] 4) Mask operation
[0143] In some models, such as BERT or its variants, masking is a technique where certain input tokens are replaced with special tags (such as [MASK]), forcing the model to learn to infer the meaning of these tokens from the context; this can be used as part of a preprocessing step to prepare the data for initial model training;
[0144] 5) Data Augmentation
[0145] Data augmentation is a technique to improve the generalization ability of the model by applying a series of transformations to the original data to generate new training samples; for example, data diversity can be increased by synonym replacement, sentence reorganization, random insertion, deletion, or exchange of partial text fragments;
[0146] 6) Feature extraction
[0147] After preprocessing, it is usually necessary to extract features from the text. These features can be word embeddings, sentence embeddings, or any other form of numerical representation that can be used as input by the initial model.
[0148] 7) Construct training samples
[0149] Finally, the cleaned, segmented, masked, and enhanced text is converted into a format that the initial model can understand, such as feature vectors or tensors, which will be input into the initial model as training samples;
[0150] The above process constitutes the basic process of converting the prompt text input by the user into training samples, providing prepared data for subsequent initial model training and fine-tuning; in actual operation, the above process can also be adjusted according to the requirements and characteristics of a specific model;
[0151] The AI painting model of this embodiment is a model that uses artificial intelligence technology to generate visual art works. The following is a brief introduction to its workflow:
[0152] 1) Learning stage
[0153] The AI painting model first learns from a large amount of image data to identify different visual elements, styles, and compositions;
[0154] 2) User Input
[0155] The user provides a text prompt to describe the content or style of the image they want to generate, such as "tranquil landscape painting" or "cyberpunk-style city";
[0156] 3) Text processing
[0157] The AI painting model converts the text prompt into an understandable format, which may include word segmentation, keyword extraction, and conversion into feature vectors;
[0158] 4) Image Generation
[0159] Based on the processed text information, the AI painting model uses a generative algorithm (such as GANs, VAEs, or diffusion models) to create an image;
[0160] 5) Output and iteration
[0161] The AI painting model generates an initial image, which the user can evaluate and provide feedback on; in some cases, the AI painting model can iterate based on the feedback and optimize the generated image;
[0162] The AI painting model combines artistic creation with technological innovation, allowing users to explore visual art in new ways, while also bringing new possibilities to the fields of art and design.
[0163] Furthermore, the prompt generation system, wherein the initial model is constructed based on the Transformer network architecture, and the initial model is trained using the training sample to obtain a corresponding prompt generation model, includes:
[0164] An initial model is constructed based on the Transformer network architecture; the initial model includes a generator, a discriminator, and an output layer;
[0165] The training samples are used to perform adversarial training on the generator and the discriminator. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
[0166] Furthermore, the prompt generation system, wherein the training samples are used to perform adversarial training on the generator and the discriminator, and when both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated, including:
[0167] The generator and the discriminator are adversarially trained using the training samples, and random noise is introduced during the training process. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
[0168] In the specific implementation, in this embodiment, an initial model is constructed based on the Transformer network architecture; the initial model includes a generator, a discriminator, and an output layer; the training samples are used to perform adversarial training on the generator and the discriminator, and random noise is introduced during the training process. When the generator and the discriminator both meet the preset requirements, a prompt generation model corresponding to the initial model is generated;
[0169] The specific implementation process is as follows:
[0170] 1) Build the initial model
[0171] An initial model is constructed based on the Transformer network architecture. Transformer is a network architecture based on the self-attention mechanism. It has the advantages of parallel computing and long sequence processing and has been widely used in the field of natural language processing.
[0172] The initial model includes a generator, a discriminator, and an output layer;
[0173] Generator: responsible for generating corresponding prompts based on the input text description;
[0174] Discriminator: responsible for evaluating the quality of the generated prompt and comparing it with the original prompt;
[0175] Output layer: output the generated prompt in text form;
[0176] 2) Prepare training samples
[0177] Based on the training samples collected and preprocessed above, these training samples will be used to train the generator to generate accurate prompts, and train the discriminator to correctly evaluate the generated prompts;
[0178] 3) Adversarial training and introduction of random noise
[0179] The generator and discriminator are trained adversarially using training samples. In each training iteration, the generator receives a random noise vector and a text description as input to generate a prompt. The discriminator evaluates the similarity between the generated prompt and the original prompt. In this process, the introduction of random noise increases the diversity of generated samples, prompting the generator to learn how to recover meaningful prompts from noise.
[0180] 4) Optimize model parameters
[0181] Through optimization techniques such as back-propagation and gradient descent, the parameters of the generator and discriminator are updated according to a loss function (such as contrastive loss or binary cross entropy loss); the loss function measures the difference between the generated prompt and the original prompt, and the goal is to minimize this difference, thereby improving the quality of the generated prompt;
[0182] 5) Evaluate and generate prompt generation model
[0183] When the prompt generated by the generator and the evaluation ability of the discriminator both meet the preset performance requirements, the adversarial training is stopped. At this point, the initial model is transformed into a prompt generation model that can stably generate high-quality prompts after training and optimization. Through the output layer, the prompt generation model can output the expected prompt according to the text description input by the user, so that the user can use it on the target model later.
[0184] Through the above process, a prompt generation model based on the Transformer network architecture can be trained. The prompt generation model can generate prompts that meet the requirements based on the user's text description, meeting the needs of non-professional users in AI painting or other text generation scenarios.
[0185] Furthermore, the prompt generation system, wherein the step of converting the original prompt input by the target user based on the prompt generation model to generate the corresponding target prompt, includes:
[0186] Get the original prompt entered by the target user;
[0187] The original prompt is input into the prompt generation model for transformation to generate corresponding multiple target prompts.
[0188] Furthermore, the prompt generation system, wherein the inputting of the original prompt into the prompt generation model for conversion to generate a corresponding plurality of target prompts, comprises:
[0189] In response to the target user's selection instruction for the multiple target prompts, a target prompt selected by the target user is input into the target model.
[0190] In specific implementation, in this embodiment, an original prompt input by a target user is obtained; the original prompt is input into the prompt generation model for conversion to generate a corresponding plurality of target prompts; in response to a selection instruction of the target user for the plurality of target prompts, a target prompt selected by the target user is input into the target model;
[0191] The specific implementation process is as follows:
[0192] 1) User input collection
[0193] First, obtain the original prompt that the target user is going to input into the target model (such as an AI painting model); this original prompt is the basic description or theme that the target user wants the target model to generate related images;
[0194] 2) Generate target prompt
[0195] The original prompt input by the target user is input into the trained prompt generation model for conversion; the prompt generation model uses its generator part and combines the random noise vector to generate multiple candidate target prompts related to the original prompt, and these candidate target prompts can all meet the understanding and processing capabilities of the target model;
[0196] This step can provide target users with a series of options to increase the diversity of choices;
[0197] 3) User selection
[0198] The generated multiple target prompts that meet the target model's understanding and processing capabilities are displayed to the target user, and the target user can select a target prompt that best meets his or her expectations from these candidate options according to his or her preferences or needs;
[0199] This step allows the target users to participate in the generation process, ensuring that the final generated text is closer to the actual needs of the target users;
[0200] 4) Respond to user selection
[0201] Once the target user selects a target prompt, the selected target prompt will be input into the target model; if the target model is an AI model for text generation, such as AI painting description generation or other types of text creation, this step will trigger the target model to generate the final text output (such as the AI painting model generating the image required by the target user);
[0202] 5) Output the final result
[0203] After receiving the selected target prompt, the target model uses its internal algorithm and learned knowledge to generate the final text or image description and presents it to the target user as output; for example, if this is an AI painting model, the final output may be a descriptive text or image for further use by artists or designers;
[0204] Through the above process, not only can a variety of text (target prompt) options be generated, but it can also ensure that the user's choice is incorporated into the final creation process, thereby improving user satisfaction and the relevance of the generated content.
[0205] It can be seen from the above system embodiments that the prompt generation system provided by the present invention at least includes: a collection module, which is used to collect a number of prompt texts, and obtain corresponding training samples after preprocessing the several prompt texts; a training module, which is used to build an initial model based on the Transformer network architecture, and obtain a corresponding prompt generation model after training the initial model with the training samples; a conversion module, which is used to convert the original prompt input by the target user based on the prompt generation model to generate a corresponding target prompt; and so on. In this way, the system of the present invention can realize the rapid, efficient and accurate generation of the target prompt that meets the understanding and processing capabilities of the target model.
[0206] Specifically, the prompt generation system provided by the embodiment of the present invention, i.e., the system for generating AI painting prompt based on the Transformer network architecture, can generate a corresponding AI painting prompt according to the prompt provided by the user, thereby simplifying the interaction and operation process between the user and the computer, and improving the convenience and comfort of the user;
[0207] At the same time, the embodiments of the present invention can generate a large number of diverse AI painting prompts, covering different themes, emotions and styles, providing rich resources for the stimulation of creativity and the creation of inspiration;
[0208] In addition, the embodiment of the present invention can generate an AI painting prompt that meets the user's personalized needs based on the input and needs provided by the user, thereby realizing customized creation;
[0209] Finally, the embodiment of the present invention utilizes the semantic understanding and logical reasoning capabilities of the network to generate more accurate and logical AI painting prompts, bringing more opportunities and possibilities for the creation and application of AI paintings.
[0210] Based on the above method embodiment, please refer to Figure 3 Another embodiment of the present invention further provides a computer device, wherein the computer device 10 includes:
[0211] memory 120 and one or more processors 110, Figure 3 A processor 110 is used as an example for description. The processor 110 and the memory 120 may be connected via a communication bus or other means. Figure 3 The example of connection via a communication bus is taken as an example.
[0212] The processor 110 is used to complete various control logics of the computer device 10. It can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of these components. In addition, the processor 110 can also be any traditional processor, microprocessor or state machine. The processor 110 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP, or any other such configuration.
[0213] The memory 120 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as the computer program corresponding to the prompt generation method in the embodiment of the present invention. The processor 110 executes various functional applications and data processing of the computer device 10 by running the non-volatile software programs, instructions and units stored in the memory 120, that is, implements the prompt generation method in the above method embodiment.
[0214] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store an application required for operating the device or at least one function; the data storage area may store data created according to the use of the computer device 10, etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include a memory remotely arranged relative to the processor 110, and these remote memories may be connected to the computer device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0215] One or more units are stored in the memory 120, and when executed by one or more processors 110, the prompt generation method in any of the above method embodiments can be implemented, for example, the above described prompt generation method can be implemented. Figure 1 The method comprises steps S100 to S300.
[0216] Those skilled in the art will understand that Figure 3 The hardware structure diagram shown in the figure is only a schematic diagram of a partial structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0217] Based on the above method embodiments, another embodiment of the present invention further provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the prompt generation method in any of the above method embodiments can be implemented, for example, the above described prompt generation method can be implemented. Figure 1 The method comprises steps S100 to S300.
[0218] As an example, the non-volatile storage medium can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable ROM (EEPROM), or a flash memory. Volatile memory can include a random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synch link DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.
[0219] Based on the above method embodiments, another embodiment of the present invention further provides a computer program product, the computer program product includes a computer program stored on a non-volatile computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a processor, the prompt generation method in any of the above method embodiments can be implemented, for example, the above described prompt generation method can be implemented. Figure 1 The method comprises steps S100 to S300.
[0220] The embodiments described above are merely illustrative, in which the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0221] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can exist in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0222] Conditional language such as "can," "can," "might," or "may," unless specifically stated otherwise or otherwise understood within the context as used, is generally intended to convey, among other things, that a particular embodiment can include (while other embodiments do not) a particular feature, element, and / or operation. Thus, such conditional language is also generally intended to imply that a feature, element, and / or operation is required for one or more embodiments anyway or that one or more embodiments must include logic for determining, with or without input or prompting, whether such features, elements, and / or operations are included or will be performed in any particular embodiment.
[0223] What has been described herein, in this specification and in the accompanying drawings includes examples that can provide a prompt generation method, system, computer device, and non-volatile computer-readable storage medium. Of course, it is not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of the present disclosure, but it can be recognized that many other combinations and permutations of the disclosed features are possible. Therefore, it is obvious that various modifications can be made to the present disclosure without departing from the scope or spirit of the present disclosure, but all these various modifications should belong to the scope of protection of the claims attached to the present invention. In addition, or in an alternative, other embodiments of the present disclosure may be obvious from consideration of the present specification and the accompanying drawings and from the practice of the present disclosure as presented herein. It is intended that the examples proposed in the present specification and the accompanying drawings are considered to be illustrative and not restrictive in all respects. Although specific terms are used herein, they are used in a general and descriptive sense and are not used for limiting purposes.
Claims
1. A prompt generation method, characterized in that: include: Collecting a number of prompt texts, and preprocessing the prompt texts to obtain corresponding training samples; Building an initial model based on the Transformer network architecture, and training the initial model using the training samples to obtain a corresponding prompt generation model; Based on the prompt generation model, the original prompt input by the target user is transformed to generate a corresponding target prompt.
2. The prompt generation method according to claim 1, characterized in that: In the step of collecting a plurality of prompt texts and preprocessing the plurality of prompt texts to obtain corresponding training samples, The preprocessing includes: data cleaning, word segmentation, masking, and data enhancement.
3. The prompt generation method according to claim 1 or 2, characterized in that: The initial model is constructed based on the Transformer network architecture, and after the initial model is trained using the training sample, a corresponding prompt generation model is obtained, including: An initial model is constructed based on the Transformer network architecture; the initial model includes a generator, a discriminator, and an output layer; The training samples are used to perform adversarial training on the generator and the discriminator. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
4. The prompt generation method according to claim 3, characterized in that: The training sample is used to perform adversarial training on the generator and the discriminator. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated, including: The generator and the discriminator are adversarially trained using the training samples, and random noise is introduced during the training process. When both the generator and the discriminator meet preset requirements, a prompt generation model corresponding to the initial model is generated.
5. The prompt generation method according to claim 4, characterized in that: The method of converting the original prompt input by the target user based on the prompt generation model to generate a corresponding target prompt includes: Get the original prompt entered by the target user; The original prompt is input into the prompt generation model for transformation to generate corresponding multiple target prompts.
6. The prompt generation method according to claim 5, characterized in that: After the original prompt is input into the prompt generation model for conversion and a corresponding plurality of target prompts is generated, the method further comprises: In response to the target user's selection instruction for the multiple target prompts, a target prompt selected by the target user is input into the target model.
7. The prompt generation method according to claim 6, characterized in that: The target model is an AI painting model.
8. A prompt generation system, characterized in that: include: A collection module, used to collect a number of prompt texts, and obtain corresponding training samples after preprocessing the plurality of prompt texts; A training module is used to build an initial model based on the Transformer network architecture, and to obtain a corresponding prompt generation model after training the initial model using the training samples; The conversion module is used to convert the original prompt input by the target user based on the prompt generation model to generate a corresponding target prompt.
9. A computer device, characterized in that: The computer device comprises at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, the prompt generation method according to any one of claims 1 to 7 can be implemented.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the prompt generation method according to any one of claims 1 to 7 can be implemented.
