Model training method and device, text information generation method and device, equipment and medium
By constructing a target prompt output model, using the initial prompt message sample and target imitation text sample to optimize prompt text, the problem of prompting words is solved when the existing language processing model generates original text, and the higher quality original text is achieved generate.
Patent Information
- Application Number
- CN202310948733.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2025-02-14
AI Technical Summary
Existing language processing models are susceptible to the impact of prompt text when generating original text, resulting in poor use.
By obtaining the initial prompt information sample, an imitation text sample is generated, and a target imitation text sample that meets the preset semantic similarity requirements is determined. Based on these samples, the parameters of the language processing model are trained to build a target prompt output model to optimize the prompt text.
No matter what language style the user enters, the target message output model can generate optimized message, so that the language processing model can better generate original text information that meets user needs, and improve output quality and user satisfaction.
Smart Images

Figure CN119441854A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a model training method, a text information generation method, a device, a equipment and a medium. Background Art
[0002] Language processing models can learn the content of objects from training data through various machine learning methods and generate original text information.
[0003] The original text information generated by the existing language processing model based on the user input prompt will be as similar as possible to the training data. The quality of the generated original content is related to the prompt given by the user.
[0004] However, existing methods are easily affected by prompt text when using language processing models to generate original text, resulting in poor performance. Summary of the invention
[0005] The present application provides a model training method, a text information generation method, an apparatus, a device and a medium, which are used to solve the problem that the existing method is easily affected by the prompt text when using the language processing model to generate text, resulting in poor use effect.
[0006] In a first aspect, the present application provides a model training method, the method comprising:
[0007] Obtaining an initial prompt information sample, where the initial prompt information sample is an information sample that meets the output requirements of the prompt output model to be trained;
[0008] Based on the initial prompt information sample, an imitation text sample is obtained, and the imitation text sample includes at least two different text samples;
[0009] Determine a target imitation text sample from the imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample;
[0010] Based on the initial prompt information sample, training the pre-training layer parameters of the prompt output model to be trained to obtain the initial prompt output model;
[0011] Based on the initial prompt information samples and the target imitation text samples, the output layer parameters of the initial prompt output model are trained to obtain the target prompt output model.
[0012] In the embodiment of the present application, obtaining an initial prompt information sample includes:
[0013] Acquire model text information and prompt text corresponding to the model text information, wherein the model text information is text information generated by the language processing model based on the prompt text;
[0014] In response to a user's selection operation on the model text information, determining target model text information in the model text information that meets a correspondence requirement with the prompt text, and a target prompt text corresponding to the target model text information;
[0015] The target prompt text is determined as the initial prompt information sample.
[0016] In the embodiment of the present application, based on the initial prompt information sample, the imitation text sample is obtained, including:
[0017] Determining the sentence composition of the initial prompt information sample based on the sentence structure of the initial prompt information sample;
[0018] Based on the preset order adjustment rules, the sentence composition of the initial prompt information sample is permuted in order to obtain an imitation text sample.
[0019] In the embodiment of the present application, after determining the sentence composition of the initial prompt information sample based on the sentence structure of the initial prompt information sample, the method further includes:
[0020] Identify the target words in the sentence composition;
[0021] Based on a preset word library, the target word is replaced to obtain an imitation text sample. The preset word library is a preset database storing words of multiple categories, and the target word is a word corresponding to the word category stored in the preset word library.
[0022] In the embodiment of the present application, determining a target imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample from the imitation text sample includes:
[0023] Determine the word vector of the imitation text sample and the word vector of the initial prompt information sample;
[0024] Based on the word embedding, determine the semantic similarity between the imitation text sample and the initial prompt information sample;
[0025] If the similarity between the word vectors of the imitation text sample and the initial prompt information sample meets the preset similarity threshold requirement, the imitation text sample is determined to be the target imitation text sample.
[0026] In the embodiment of the present application, based on the initial prompt information sample, the pre-training layer parameters of the prompt output model to be trained are trained to obtain the initial prompt output model, including:
[0027] Determine the text structure and text features of the initial prompt information sample;
[0028] Based on the text structure and text features, train the pre-training layer model parameters.
[0029] In the embodiment of the present application, based on the initial prompt information sample and the target imitation text sample, the output layer parameters of the initial prompt output model are trained to obtain the target prompt output model, including:
[0030] Sending the target imitation text sample to the initial prompt output model to obtain the pre-trained prompt text fed back by the initial prompt output model;
[0031] Compare the pre-trained prompt text and the initial prompt information sample, and train the output layer parameters of the initial prompt output model according to the comparison result, so that the pre-trained prompt text is consistent with the initial prompt information sample;
[0032] Based on the initial prompt output model and the trained output layer parameters, a target prompt output model is obtained.
[0033] In a second aspect, the present application provides a method for generating text information, the method comprising:
[0034] Get the prompt text;
[0035] Based on the prompt text and the target prompt output model, an optimized prompt text is generated, and the target prompt output model is the target prompt output model mentioned above;
[0036] The optimized prompt text is sent to the language processing model so that the language processing model generates original text information that meets the text requirements based on the optimized prompt text.
[0037] In a third aspect, the present application provides a model training device, the device comprising:
[0038] A prompt sample acquisition module is used to acquire an initial prompt information sample, where the initial prompt information sample is an information sample that meets the output requirements of the prompt output model to be trained;
[0039] An imitation text determination module, used to obtain an imitation text sample based on the initial prompt information sample, wherein the imitation text sample includes at least two different texts;
[0040] A target text determination module is used to determine a target imitation text sample from the imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample;
[0041] A pre-training layer training module is used to train the pre-training layer parameters of the prompt output model to be trained based on the initial prompt information sample to obtain the initial prompt output model;
[0042] The output layer training module is used to train the output layer parameters of the initial prompt output model based on the initial prompt information sample and the target imitation text sample to obtain the target prompt output model.
[0043] In a fourth aspect, the present application provides a text information generating device, the device comprising:
[0044] A text acquisition module is used to acquire the prompt text;
[0045] A text generation module, used to generate an optimized prompt text based on the prompt text and the target prompt output model, wherein the target prompt output model is the target prompt output model mentioned above;
[0046] The text sending module is used to send the optimized prompt text to the language processing model, so that the language processing model generates original text information that meets the text requirements based on the optimized prompt text.
[0047] In a fifth aspect, the present application provides a device, comprising: a processor, and a memory communicatively connected to the processor;
[0048] Memory stores computer-executable instructions;
[0049] The processor executes the computer-executable instructions stored in the memory to implement the method of the present application.
[0050] In a sixth aspect, the present application provides a computer-readable storage medium, in which computer-readable storage medium is stored computer execution instructions, and the computer execution instructions are used to implement the method of the present application when executed by a processor.
[0051] The model training method, text information generation method, device, equipment and medium provided by the present application obtain an initial prompt information sample, which is an information sample that meets the output requirements of the prompt output model to be trained; based on the initial prompt information sample, an imitation text sample is obtained, and the imitation text sample includes at least two different text samples; a target imitation text sample that meets the preset semantic similarity requirements with the initial prompt information sample is determined from the imitation text sample; based on the initial prompt information sample, the pre-training layer parameters of the prompt output model to be trained are trained to obtain the initial prompt output model; based on the initial prompt information sample and the target imitation text sample, the output layer parameters of the initial prompt output model are trained to obtain the target prompt output model.
[0052] In this way, the target imitation text sample can be determined from the imitation text samples based on the preset semantic similarity requirements through the initial prompt information sample that meets the model output requirements, and the model parameters of the prompt output model to be trained to obtain the target prompt output model, thereby ensuring that no matter what language style of prompt the user inputs, the target prompt output model can output the optimized prompt, so that the optimized prompt meets the prompt style of the language processing model, and the language processing model generates original text information that meets user needs based on the optimized prompt. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0054] Figure 1 A flowchart of a model training method provided in an embodiment of the present application;
[0055] Figure 2 A flowchart of a text information generation method provided in an embodiment of the present application;
[0056] Figure 3 A flowchart of another model training method provided in an embodiment of the present application;
[0057] Figure 4 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;
[0058] Figure 5 A schematic diagram of the structure of a text information generating device provided in an embodiment of the present application;
[0059] Figure 6 This is a structural block diagram of a device for executing a model training method according to an embodiment of the present application.
[0060] The above-mentioned drawings have shown clear embodiments of the present application, which will be described in more detail below; these drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0061] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0062] In the prior art, a user inputs a prompt into a language processing model, and the language processing model can generate original text information that meets the requirements of the prompt. However, the output quality is very dependent on whether the given prompt is similar in style to the prompts in the original training data set. When the style of the prompts input by the user is significantly different from the style of the prompts in the original training data set, the original text information output by the language processing model will also deviate significantly from the requirements of the prompts.
[0063] In order to solve the above problems, an embodiment of the present application provides a model training method, which can train the pre-training layer parameters of the prompt output model to be trained through the initial prompt information samples that meet the model output requirements, and train the output layer parameters of the prompt output model to be trained through the target imitation text samples and the initial prompt information samples that meet the preset semantic similarity requirements with the initial prompt information samples, so that after the prompt output model to be trained is trained with the initial prompt information samples, it can generate the initial prompt information samples that meet the model output requirements based on the similar target imitation text samples, thereby completing the construction of the target prompt output model.
[0064] At the same time, a text information generation method is proposed. Based on the target prompt output model, the prompts in any language style input by the user are optimized, and the optimized prompts are sent to the language processing model, so that the language processing model generates original text information that meets the requirements of the prompts based on the optimized prompts, thereby meeting the needs of users and improving the output quality of the language processing model and user satisfaction.
[0065] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0066] This embodiment does not impose any special restrictions on the implementation method of the execution subject, as long as the execution subject can obtain an initial prompt information sample, which is an information sample that meets the output requirements of the prompt output model to be trained; based on the initial prompt information sample, an imitation text sample is obtained, and the imitation text sample includes at least two different text samples; a target imitation text sample that meets the preset semantic similarity requirements with the initial prompt information sample is determined from the imitation text sample; based on the initial prompt information sample, the pre-training layer parameters of the prompt output model to be trained are trained to obtain the initial prompt output model; based on the initial prompt information sample and the target imitation text sample, the output layer parameters of the initial prompt output model are trained to obtain the target prompt output model.
[0067] Among them, the prompt output model to be trained can be a prompt optimization model, specifically a deep neural network model, which can obtain the prompt text input by the user and output the optimized prompt text, so that the language processing model generates original text information that meets the prompt requirements based on the optimized prompt text; at the same time, the prompt output model to be trained can also be a model of other forms, as long as it is a model that can optimize the input prompt, and this embodiment does not limit this.
[0068] The prompt output model to be trained can be divided into a pre-training layer and an output layer. All parameters of the pre-training layer will be pre-trained with text that conforms to the style of the generative artificial intelligence model training text data. After all parameters are trained, the model construction process is completed and the target prompt output model is obtained.
[0069] The preset semantic similarity requirement is a pre-set requirement for determining the semantic similarity between different sentences. If the sentences meet the preset semantic similarity requirement, it indicates that the sentences have a high semantic similarity. The similarity of the sentences can be compared by automatic methods such as existing artificial intelligence model comparison and dictionary matching query comparison.
[0070] Figure 1 A flow chart of a model training method provided in an embodiment of the present application. Figure 1 As shown, the model training method may include the following steps:
[0071] S110, obtaining an initial prompt information sample, where the initial prompt information sample is an information sample that meets the output requirements of the prompt output model to be trained.
[0072] The prompt output model to be trained is a prompt output model whose model parameters need to be trained to complete the construction.
[0073] The output requirements are the text feature requirements of the prompt text generated by the prompt output model to be trained; the language processing model can generate original text information that meets the user requirements based on the prompt text that meets the output requirements, thereby improving the output quality and better enhancing the user experience.
[0074] In some implementations, obtaining an initial prompt information sample includes:
[0075] Acquire model text information and prompt text corresponding to the model text information, wherein the model text information is text information generated by the language processing model based on the prompt text;
[0076] In response to a user's selection operation on the model text information, determining target model text information in the model text information that meets a correspondence requirement with the prompt text, and a target prompt text corresponding to the target model text information;
[0077] The target prompt text is determined as the initial prompt information sample.
[0078] Among them, the target model text information is the model text information determined by the user from the model text information generated by the language processing model and the text content meets the requirements. It can be understood that since the target model text information meets the user requirements well, it means that the corresponding prompt text is a text that meets the language style of the language processing model and meets the output requirements of the prompt output model to be trained. Therefore, the target model text information can be used as an initial prompt information sample for training the prompt output model to be trained.
[0079] The selection operation represents the operation of the user determining the target original text information that meets the requirements from the original text information. The selection operation may be performed by the user through a mouse or a trigger, or in other forms, which is not limited in this embodiment.
[0080] Based on this, by obtaining the original text information generated by the language processing model based on the prompt text, and the corresponding prompt text, through the user's selection operation, the target original text information and the corresponding target prompt text are determined, and the target prompt text is determined as the initial prompt information sample.
[0081] S120: Obtain an imitation text sample based on the initial prompt information sample, where the imitation text sample includes at least two different text samples.
[0082] Among them, the imitation text sample is text information obtained by imitating the text features and text language of the initial prompt information sample, and the sentence meaning of the imitation text sample is the same as that of the initial prompt information sample; the imitation text sample can be obtained by methods such as manual writing, template matching generation, artificial intelligence model generation, etc., or in other forms, which is not limited in this embodiment.
[0083] In some implementations, obtaining the imitation text sample based on the initial prompt information sample includes:
[0084] Determining the sentence composition of the initial prompt information sample based on the sentence structure of the initial prompt information sample;
[0085] Based on the preset order adjustment rules, the sentence composition of the initial prompt information sample is permuted in order to obtain an imitation text sample.
[0086] The sentence structure is the composition structure of the sentence of the initial prompt information sample, such as the subject, predicate, object, attributive, adverbial, complement, predicative, appositive and other components that constitute the sentence.
[0087] The preset order adjustment rule is a pre-set rule for changing the order of sentence components to obtain an imitation sentence with smooth language logic.
[0088] Based on this, according to the preset order adjustment rules, the sentence composition of the initial prompt information sample is replaced in order, and the connecting words are added or deleted from the replaced text according to the preset language logic, so as to obtain an imitation text sample with smooth language logic.
[0089] In this implementation, after determining the sentence composition of the initial prompt information sample based on the sentence structure of the initial prompt information sample, the method further includes:
[0090] Identify the target words in the sentence composition;
[0091] Based on a preset word library, the target word is replaced to obtain an imitation text sample. The preset word library is a preset database storing words of multiple categories, and the target word is a word corresponding to the word category stored in the preset word library.
[0092] Among them, the target word can be understood as a word corresponding to a word category stored in the preset word library. For example, if the word "spicy food" is determined in the initial prompt information sample, other words indicating spicy food can be found in the category corresponding to the word "spicy food" in the preset word library for replacement, thereby obtaining an imitation text sample that has the same sentence meaning as the initial prompt information sample but a different specific text form.
[0093] The preset word library can be constructed or an existing word library can be directly used, as long as it is a database storing a large number of words of different categories. Users can also continuously store new words in the preset word library, thereby continuously improving the preset word library.
[0094] Based on this, by constructing a preset vocabulary library and determining the target words, the words in the initial prompt information sample can be replaced to obtain an imitation text sample.
[0095] S130: Determine, from the imitation text samples, a target imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample.
[0096] The preset semantic similarity requirement is a pre-set requirement for determining the semantic similarity between texts. If the texts meet the preset semantic similarity requirement, it is determined that the texts are similar.
[0097] In this implementation, determining a target imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample from the imitation text sample includes:
[0098] Determine the word vector of the imitation text sample and the word vector of the initial prompt information sample;
[0099] Based on the word embedding, determine the semantic similarity between the imitation text sample and the initial prompt information sample;
[0100] If the similarity between the word vectors of the imitation text sample and the initial prompt information sample meets the preset similarity threshold requirement, the imitation text sample is determined to be the target imitation text sample.
[0101] Among them, word vectors can map words into a numerical vector, and words with similar semantics have similar positions in the vector space, which can be used to determine the semantic similarity between texts.
[0102] Based on this, by determining the word vectors of the initial prompt information sample and the imitation text sample, and by comparing the word vectors, it is determined whether the texts meet the preset semantic similarity requirements, and the target imitation text sample that meets the preset semantic similarity requirements with the initial prompt information sample is determined.
[0103] S140: Based on the initial prompt information sample, train the pre-training layer parameters of the prompt output model to be trained to obtain the initial prompt output model.
[0104] Among them, the pre-training layer parameters are the model parameters of the pre-training layer of the prompt output model to be trained; the prompt output model to be trained is divided into a pre-training layer and an output layer. By training and adjusting the model parameters, the target prompt output model can be obtained.
[0105] In this implementation, based on the initial prompt information sample, the pre-training layer parameters of the prompt output model to be trained are trained to obtain the initial prompt output model, including:
[0106] Determine the text structure and text features of the initial prompt information sample;
[0107] Based on the text structure and text features, train the pre-training layer model parameters.
[0108] Among them, the text structure and text features characterize the text language style of the initial prompt information sample.
[0109] Based on this, based on the text structure and text features of the initial prompt information sample, the training of the pre-training layer model parameters of the prompt output model to be trained is completed, so that the prompt output model to be trained learns the language style of the initial prompt information sample, which is helpful for the subsequent generation of optimized prompt text.
[0110] S150: Based on the initial prompt information sample and the target imitation text sample, the output layer parameters of the initial prompt output model are trained to obtain the target prompt output model.
[0111] Among them, the target prompt output model is the prompt output model that has been trained and constructed. No matter what language style of the prompt text is input, the target prompt output model can generate an optimized prompt text that meets the language style of the language processing model, so that the language processing model can generate original text information that meets user requirements based on the optimized prompt text, thereby improving the output quality.
[0112] In some implementations, based on the initial prompt information sample and the target imitation text sample, the output layer parameters of the initial prompt output model are trained to obtain the target prompt output model, including:
[0113] Sending the target imitation text sample to the initial prompt output model to obtain the pre-trained prompt text fed back by the initial prompt output model;
[0114] Compare the pre-trained prompt text and the initial prompt information sample, and train the output layer parameters of the initial prompt output model according to the comparison result, so that the pre-trained prompt text is consistent with the initial prompt information sample;
[0115] Based on the initial prompt output model and the trained output layer parameters, a target prompt output model is obtained.
[0116] Among them, the pre-trained prompt text is the prompt text generated by the initial prompt output model according to the target imitation text sample.
[0117] The comparison representation determines whether the pre-trained prompt text is completely consistent with the initial prompt information sample.
[0118] Based on this, by determining whether the prompt text generated by the initial prompt output model according to the target imitation text sample is consistent with the initial prompt information sample, the output layer parameters of the initial prompt output model are trained and adjusted to obtain the target prompt output model, and to ensure that the target prompt output model can generate optimized prompt text that meets the language style of the language processing model based on prompt text of any language style.
[0119] In this embodiment, by determining whether the original text information generated by the language processing model according to the prompt text meets the requirements, the target prompt text corresponding to the target original text information is obtained, thereby determining the initial prompt information sample; by sequentially replacing the sentence composition of the initial prompt information sample, or by replacing the target words in the initial prompt information sample based on a preset word library, thereby obtaining an imitation text sample; and by using the word vectors of the initial prompt information sample and the imitation text sample, determining the target imitation text sample in the imitation text sample that meets the preset semantic similarity requirements, so that the model parameters of the prompt output model to be trained and adjusted by using the initial prompt information sample and the target imitation text sample, thereby obtaining the target prompt language output model.
[0120] That is to say, when the user needs the language processing model to generate a piece of original text information that meets the user's requirements, a piece of prompt text will be input into the language processing model, and this piece of prompt text includes the user's requirements. If the prompt text input into the language processing model by the user meets the language style of the language processing model itself, the original text information generated by the language processing model based on the prompt text will meet the user's requirements. By training the parameters of the prompt output model to be trained, the construction of the target prompt model is completed, so that the prompt texts of various language styles input by the user are optimized through the target prompt output model, so as to obtain the optimized prompt texts that meet the language style of the language processing model. In this way, based on the target prompt output model, the prompt text is optimized, so as to ensure that the optimized prompt text better meets the language style of the language processing model, and based on this, the content quality of the original text information generated by the language processing model is improved.
[0121] Figure 2 A flowchart of a text information generation method provided in an embodiment of the present application. Figure 2 As shown, the text information generating method may include the following steps:
[0122] S210: Obtain prompt text.
[0123] The prompt text is a prompt text containing user requirements, and is used to enable the language processing model to generate original text information that meets the user requirements based on the prompt text.
[0124] Based on this, the prompt text is obtained.
[0125] S220: Generate an optimized prompt text based on the prompt text and the target prompt output model, where the target prompt output model is the target prompt output model mentioned above.
[0126] Based on this, an optimized prompt text is generated based on the acquired prompt text through a target prompt output model, thereby optimizing prompt text of any language style into prompt text of a language style that satisfies the language processing model.
[0127] S230: Send the optimized prompt text to the language processing model, so that the language processing model generates original text information that meets the text requirements based on the optimized prompt text.
[0128] The text requirement is the user's requirement for the original text information generated by the language processing model, which is included in the prompt text.
[0129] Based on this, the language processing model generates original text information that meets the requirements according to the optimized prompt text generated by the target prompt output model.
[0130] In this embodiment, the prompt text is optimized through the target prompt output model to obtain the optimized prompt text, so that the prompt text of any language style can be optimized into the optimized prompt text of the language style that satisfies the language processing model, so that the language processing model can generate original text information that meets the user's requirements based on the optimized prompt text; in this way, the content quality of the original text information generated by the language processing model is improved, the actual needs of the user are met, and the use effect of the language processing model is effectively improved.
[0131] Figure 3 A flow chart of another model training method provided in an embodiment of the present application. Figure 3 As shown, the model training method may include the following steps:
[0132] S310. Input a large amount of test text into the generative artificial intelligence model to generate corresponding original content results.
[0133] The test text can be understood as a prompt text, which contains user requirements. The model can generate original content that meets the user requirements based on the test text.
[0134] A generative AI model is an AI that uses various machine learning methods to learn the content-text components of an object from training data, and then generates new, completely original content. Since the current principle of AI models to generate original content is to fit the original data set, the quality of their output is very dependent on whether the given prompts are close to the style of the text prompts in the original data set. When the style of the prompts input by the user is quite different, the original content given will also be quite deviant.
[0135] Based on this, a large amount of prompt text is input into the generative artificial intelligence model to obtain original content generated by the model that corresponds to the prompt text.
[0136] S320: Select the qualified part of the original content, and select the corresponding input text as the first prompt data set that conforms to the style of the model training text data.
[0137] Among them, the qualified part is the original content that meets the user's requirements, and the user can select from it.
[0138] The model training text data style can be understood as the common text style of the prompt text that enables the model to generate original content that meets the requirements.
[0139] S330 , generating a large number of corresponding texts in different styles for the first prompt word data set to form a second prompt word data set in other styles.
[0140] Among them, different styles can be understood as the second prompt data set and the first prompt data set have the same sentence meaning, but different specific language styles. For example, the first prompt data set includes a prompt text "Someone is eating spicy food in the restaurant", and the corresponding second prompt can be "Someone is eating spicy food in the restaurant", "Someone is eating spicy food in the restaurant", "Xiao Ming likes to eat Malatang in the restaurant", etc. The two are semantically the same, but the specific forms of the sentences are different.
[0141] Methods for producing a large number of corresponding texts of different styles include but are not limited to manual writing, template matching generation, artificial intelligence model generation, etc.; for one input, a large number of outputs can be given.
[0142] S340: Use the first prompt data set for pre-training to obtain pre-training layer parameters of the prompt optimization generation model.
[0143] The prompt optimization generation model is to input a text and output a text that conforms to the style of the first prompt dataset. The model framework of the pre-training layer in the model can be original or refer to an existing model, which is not limited in this embodiment.
[0144] S350, comparing the text similarity of the first prompt word data set and the second prompt word data set, selecting all qualified prompt words in the second prompt word data set as the third prompt word data set, and using the first prompt word data set and the third prompt word data set to train the output layer parameters of the prompt optimization generation model.
[0145] Among them, the specific method of comparing the text similarity between the first prompt data set and the second prompt data set includes but is not limited to using artificial intelligence model comparison, dictionary matching query comparison, etc. After obtaining the corresponding similarity, all texts with similarity exceeding the threshold are selected to form a third prompt data set.
[0146] Based on this, the third prompt dataset is used as input and the first prompt dataset is used as output to train the prompt optimization generation model.
[0147] S360, the user's original input enters the prompt optimization generation model, obtains the optimized prompt, and inputs it into the generative artificial intelligence model to obtain better original content results.
[0148] Based on this, after obtaining the prompt, the prompt optimization generation model begins to process and obtains the corresponding optimized prompt, which is then input into the generative artificial intelligence model to generate the final original content.
[0149] In this embodiment, a prompt optimization generation model is provided. No matter what style of prompt the user inputs, the optimized prompt can be obtained through this model. The prompt is in line with the prompt style of the generative artificial intelligence model to be input. After the user inputs the prompt, the prompt optimization generation model starts processing and obtains the corresponding optimized prompt, which is then input into the generative artificial intelligence model for processing to generate the final original content. In this way, no matter what style of prompt is input, the prompt optimization generation model can process the prompt according to the language style of the generative artificial intelligence model to obtain the optimized prompt.
[0150] Figure 4 A schematic diagram of the structure of a model training device 400 provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the model training device 400 includes: a prompt sample acquisition module 410, an imitation text determination module 420, a target text determination module 430, a pre-training layer training module 440 and an output layer training module 450.
[0151] The prompt sample acquisition module 410 is used to acquire an initial prompt information sample, where the initial prompt information sample is an information sample that meets the output requirements of the prompt output model to be trained;
[0152] The imitation text determination module 420 is used to obtain an imitation text sample based on the initial prompt information sample, wherein the imitation text sample includes at least two different texts;
[0153] A target text determination module 430 is used to determine a target imitation text sample from the imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample;
[0154] A pre-training layer training module 440 is used to train the pre-training layer parameters of the prompt output model to be trained based on the initial prompt information sample to obtain the initial prompt output model;
[0155] The output layer training module 450 is used to train the output layer parameters of the initial prompt output model based on the initial prompt information sample and the target imitation text sample to obtain the target prompt output model.
[0156] In the embodiment of the present application, the prompt sample acquisition module 410 may also be specifically used for:
[0157] Acquire model text information and prompt text corresponding to the model text information, wherein the model text information is text information generated by the language processing model based on the prompt text;
[0158] In response to a user's selection operation on the model text information, determining target model text information in the model text information that meets a correspondence requirement with the prompt text, and a target prompt text corresponding to the target model text information;
[0159] The target prompt text is determined as the initial prompt information sample.
[0160] In the embodiment of the present application, the imitation text determination module 420 may also be specifically used for:
[0161] Determining the sentence composition of the initial prompt information sample based on the sentence structure of the initial prompt information sample;
[0162] Based on the preset order adjustment rules, the sentence composition of the initial prompt information sample is permuted in order to obtain an imitation text sample.
[0163] In the embodiment of the present application, the imitation text determination module 420 may also be specifically used for:
[0164] Identify the target words in the sentence composition;
[0165] Based on a preset word library, the target word is replaced to obtain an imitation text sample. The preset word library is a preset database storing words of multiple categories, and the target word is a word corresponding to the word category stored in the preset word library.
[0166] In the embodiment of the present application, the target text determination module 430 may also be specifically used for:
[0167] Determine the word vector of the imitation text sample and the word vector of the initial prompt information sample;
[0168] Based on the word embedding, determine the semantic similarity between the imitation text sample and the initial prompt information sample;
[0169] If the similarity between the word vectors of the imitation text sample and the initial prompt information sample meets the preset similarity threshold requirement, the imitation text sample is determined to be the target imitation text sample.
[0170] In the embodiment of the present application, the pre-training layer training module 440 may also be specifically used for:
[0171] Determine the text structure and text features of the initial prompt information sample;
[0172] Based on the text structure and text features, train the pre-training layer model parameters.
[0173] In the embodiment of the present application, the output layer training module 450 may also be specifically used for:
[0174] Sending the target imitation text sample to the initial prompt output model to obtain the pre-trained prompt text fed back by the initial prompt output model;
[0175] Compare the pre-trained prompt text and the initial prompt information sample, and train the output layer parameters of the initial prompt output model according to the comparison result, so that the pre-trained prompt text is consistent with the initial prompt information sample;
[0176] Based on the initial prompt output model and the trained output layer parameters, a target prompt output model is obtained.
[0177] Figure 5 A structural diagram of a text information generating device 500 provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the text information generating device 500 includes: a text acquiring module 510 , a text generating module 520 and a text sending module 530 .
[0178] The text acquisition module 510 is used to acquire the prompt text;
[0179] A text acquisition module 520, for generating an optimized prompt text based on the prompt text and the target prompt output model, wherein the target prompt output model is the target prompt output model mentioned above;
[0180] The text sending module 530 is used to send the optimized prompt text to the language processing model, so that the language processing model generates original text information that meets the text requirements based on the optimized prompt text. Figure 6 This is a schematic diagram of the structure of the device provided in the embodiment of the present application. Figure 6 As shown, the device 600 includes:
[0181] The device 600 may include a processor 601 with one or more processing cores, a memory 602 with one or more computer-readable storage media, a communication component 603 and other components. The processor 601 , the memory 602 and the communication component 603 are connected via a bus 604 .
[0182] In a specific implementation process, at least one processor 601 executes the computer execution instructions stored in the memory 602, so that at least one processor 601 executes the above message processing method.
[0183] The specific implementation process of the processor 601 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0184] In the above Figure 6 In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the present application may be directly implemented as being executed by a hardware processor, or may be implemented as being executed by a combination of hardware and software modules in the processor.
[0185] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0186] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0187] In some embodiments, a computer program product is also proposed, including a computer program or instructions, which, when executed by a processor, implements the steps of any of the above-mentioned model training methods and text information generation methods.
[0188] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0189] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0190] To this end, an embodiment of the present application provides a computer-readable storage medium, which stores multiple computer execution instructions, and the computer execution instructions can be loaded by a processor to execute the steps of any model training method or text information generation method provided in the embodiment of the present application.
[0191] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0192] According to one aspect of the present application, a computer program product or a computer program is provided. The computer program product or the computer program comprises computer instructions stored in a computer-readable storage medium.
[0193] Since the instructions stored in the storage medium can execute the steps in any one of the model training methods and text information generation methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the model training methods and text information generation methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0194] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0195] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A model training method, characterized in that: The method comprises: Acquire an initial prompt information sample, where the initial prompt information sample is an information sample that meets the output requirements of the prompt output model to be trained; Based on the initial prompt information sample, obtaining an imitation text sample, wherein the imitation text sample includes at least two different text samples; Determine, from the imitation text samples, a target imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample; Based on the initial prompt information sample, training the pre-training layer parameters of the prompt output model to be trained to obtain an initial prompt output model; Based on the initial prompt information sample and the target imitation text sample, the output layer parameters of the initial prompt output model are trained to obtain a target prompt output model.
2. The method according to claim 1, characterized in that The obtaining of the initial prompt information sample comprises: Acquire model text information and prompt text corresponding to the model text information, wherein the model text information is text information generated by a language processing model based on the prompt text; In response to a user's selection operation on the model text information, determining target model text information in the model text information that meets a correspondence requirement with the prompt text, and a target prompt text corresponding to the target model text information; The target prompt text is determined to be the initial prompt information sample.
3. The method according to claim 1, characterized in that The step of obtaining the imitation text sample based on the initial prompt information sample includes: Determining the sentence composition of the initial prompt information sample based on the sentence structure of the initial prompt information sample; Based on a preset order adjustment rule, the sentence components of the initial prompt information sample are sequentially permuted to obtain the imitation text sample.
4. The method according to claim 3, characterized in that After determining the sentence composition of the initial prompt language information sample based on the sentence structure of the initial prompt language information sample, the method further includes: Determining a target word in the sentence composition; The target word is replaced based on a preset word library to obtain the imitation text sample. The preset word library is a preset database storing words of multiple categories, and the target word is a word corresponding to the word category stored in the preset word library.
5. The method according to claim 1, characterized in that The step of determining a target imitation text sample from the imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample comprises: Determining the word vector of the imitation text sample and the word vector of the initial prompt information sample; Based on the word vector, determining the semantic similarity between the imitation text sample and the initial prompt information sample; If the similarity between the word vectors of the imitation text sample and the initial prompt information sample meets the preset similarity threshold requirement, the imitation text sample is determined to be a target imitation text sample.
6. The method according to claim 1, characterized in that The step of training the pre-training layer parameters of the prompt output model to be trained based on the initial prompt information sample to obtain the initial prompt output model includes: Determining the text structure and text features of the initial prompt information sample; Based on the text structure and text features, the pre-training layer model parameters are trained.
7. The method according to claim 1, characterized in that The step of training the output layer parameters of the initial prompt output model based on the initial prompt information sample and the target imitation text sample to obtain the target prompt output model includes: Sending the target imitation text sample to the initial prompt output model to obtain the pre-trained prompt text fed back by the initial prompt output model; Comparing the pre-trained prompt text with the initial prompt information sample, and training the output layer parameters of the initial prompt output model according to the comparison result, so that the pre-trained prompt text is consistent with the initial prompt information sample; The target prompt output model is obtained based on the initial prompt output model and the trained output layer parameters.
8. A method for generating text information, characterized in that: The method comprises: Get the prompt text; Based on the prompt text and the target prompt output model, an optimized prompt text is generated, wherein the target prompt output model is the target prompt output model according to any one of claims 1 to 7; The optimized prompt text is sent to a language processing model, so that the language processing model generates original text information that meets text requirements based on the optimized prompt text.
9. A model training device, characterized in that: The device comprises: A prompt sample acquisition module, used to acquire an initial prompt information sample, wherein the initial prompt information sample is an information sample that meets the output requirements of the prompt output model to be trained; An imitation text determination module, used to obtain an imitation text sample based on the initial prompt information sample, wherein the imitation text sample includes at least two different texts; A target text determination module, used to determine a target imitation text sample from the imitation text sample that meets a preset semantic similarity requirement with the initial prompt information sample; A pre-training layer training module, used to train the pre-training layer parameters of the prompt output model to be trained based on the initial prompt information sample to obtain the initial prompt output model; The output layer training module is used to train the output layer parameters of the initial prompt output model based on the initial prompt information sample and the target imitation text sample to obtain the target prompt output model.
10. A text information generating device, characterized in that: The device comprises: A text acquisition module is used to acquire the prompt text; A text generation module, used to generate an optimized prompt text based on the prompt text and a target prompt output model, wherein the target prompt output model is the target prompt output model according to any one of claims 1 to 7; The text sending module is used to send the optimized prompt text to the language processing model, so that the language processing model generates original text information that meets the text requirements based on the optimized prompt text.
11. A device, characterized in that: include: one or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions can be called by a processor to execute the method according to any one of claims 1 to 8.