Text training sample generation method and device based on large model and electronic equipment
By clustering query problems and generating text training samples with high differences, the problem of insufficient generalization of large models is solved, and the generalization and expression capabilities of the model are significantly improved.
Patent Information
- Application Number
- CN202411280715.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-17
AI Technical Summary
Existing large models have low generalization in multiple tasks, mainly due to the poor diversity of text training samples, which leads to insufficient generalization ability of the model after fine-tuning.
By clustering query problems, a diverse text training sample is generated, and the clustered query problem cluster generates a high-differentiated second query problem for the big model, and fine-tune it as a text training sample to improve the model generalization.
By generating diverse text training samples, the generalization ability of the large model on multiple tasks is significantly improved, and the expression ability and prediction performance of the model are enhanced.
Smart Images

Figure CN119151012A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to technical fields such as large models, model fine-tuning, deep learning, and natural language processing, and can be applied to interactive scenarios based on artificial intelligence, such as generative search, intelligent assistants, and intelligent customer service, and in particular to methods, devices, and electronic devices for generating text training samples based on large models. Background Art
[0002] The big model can handle a variety of tasks, such as knowledge question answering, NL2SQL (Natural Language to Structured Query Language, natural language conversion to SQL query), information extraction, meetings, leave, etc. Taking knowledge question answering as an example, users can ask questions as interactive context, and then the big model can give appropriate responses. In order to make the performance of the big model on a variety of tasks meet expectations, a large number of text training samples are usually required for model tuning. If the diversity of the text training samples is poor, the generalization of the big model fine-tuned based on such text training samples will be low. Therefore, generating diverse text training samples is very important for improving the generalization of the big model. Summary of the invention
[0003] The present disclosure provides a method, device and electronic device for generating text training samples based on a large model.
[0004] According to a first aspect of the present disclosure, a method for generating text training samples based on a large model is provided, comprising: clustering at least two query questions to obtain at least two query question clusters; obtaining a first query question from each of the query question clusters; taking the first query question as an example, generating at least two second query questions under a set topic through a first large model; and generating a first text training sample for fine-tuning a second large model based on the second query question.
[0005] According to a second aspect of the present disclosure, a method for fine-tuning a large model is provided, comprising: obtaining a first text training sample, wherein the first text training sample is generated based on the method for generating text training samples based on a large model described in the first aspect; and fine-tuning the large model based on the first text training sample.
[0006] According to a third aspect of the present disclosure, a question-answering method based on a big model is provided, comprising: obtaining a target query question; generating a prompt word corresponding to the target query question, wherein the prompt word is used to indicate a rule based on which a reply corresponding to the target query question is generated; inputting the prompt word into a big model to obtain a reply corresponding to the prompt word output by the big model, wherein the big model is a big model fine-tuned using a first text training sample, and the first text training sample is generated based on the method for generating text training samples based on a big model described in the first aspect.
[0007] According to a fourth aspect of the present disclosure, a device for generating text training samples based on a large model is provided, comprising: a clustering module, used to cluster at least two query questions to obtain at least two query question clusters; a first acquisition module, used to obtain a first query question from each of the query question clusters; a first generation module, used to take the first query question as an example, and generate at least two second query questions under a set topic through a first large model; and a second generation module, used to generate a first text training sample for fine-tuning a second large model based on the second query question.
[0008] According to a fifth aspect of the present disclosure, a device for fine-tuning a large model is provided, comprising: a fourth acquisition module, used to acquire a first text training sample, wherein the first text training sample is generated based on the method for generating text training samples based on a large model described in the first aspect; and a fine-tuning module, used to fine-tune the large model based on the first text training sample.
[0009] According to a sixth aspect of the present disclosure, a question-answering device based on a large model is provided, comprising:
[0010] The fifth acquisition module is used to obtain the target query question;
[0011] A fourth generating module, configured to generate a prompt word corresponding to the target query question, wherein the prompt word is used to indicate a rule based on which a reply corresponding to the target query question is generated;
[0012] A processing module is used to input the prompt word into a large model to obtain a response corresponding to the prompt word output by the large model, wherein the large model is a large model fine-tuned using a first text training sample, and the first text training sample is generated based on the method for generating text training samples based on a large model described in the first aspect.
[0013] According to a seventh aspect of the present disclosure, there is provided an electronic device, including:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for generating text training samples based on the large model as described in the first aspect, or execute the method for fine-tuning the large model as described in the second aspect, or execute the question-answering method based on the large model as described in the third aspect.
[0017] According to an eighth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method for generating text training samples based on a large model as described in the first aspect, or to execute the method for fine-tuning the large model as described in the second aspect, or to implement the question-answering method based on the large model as described in the third aspect.
[0018] According to the ninth aspect of the present disclosure, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the method for generating text training samples based on a large model as described in the first aspect, or implement the method for fine-tuning the large model as described in the second aspect, or implement the question-answering method based on the large model as described in the third aspect.
[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0021] Figure 1 It is a flowchart of a method for generating text training samples based on a large model provided according to an embodiment of the present disclosure;
[0022] Figure 2 is a flowchart of a method for generating text training samples based on a large model provided in accordance with another embodiment of the present disclosure;
[0023] Figure 3 is a flowchart of a method for generating text training samples based on a large model provided in accordance with another embodiment of the present disclosure;
[0024] Figure 4 is a flowchart of a method for generating text training samples based on a large model provided in accordance with another embodiment of the present disclosure;
[0025] Figure 5is a flow chart of a fine-tuning method for a large model provided according to an embodiment of the present disclosure;
[0026] Figure 6 It is a flowchart of a question-answering method based on a large model provided according to an embodiment of the present disclosure;
[0027] Figure 7 It is a structural schematic diagram of a device for generating text training samples based on a large model according to an embodiment of the present disclosure;
[0028] Figure 8 is a structural schematic diagram of a fine-tuning device for a large model provided according to an embodiment of the present disclosure;
[0029] Fig. 9 is a structural diagram of a question-answering device based on a large model provided according to an embodiment of the present disclosure;
[0030] Fig.10 It is a block diagram of an electronic device used to implement the method for generating text training samples based on a large model, the method for fine-tuning a large model, or the question-answering method based on a large model according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0032] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are all carried out with the user's consent, comply with the relevant laws and regulations, and do not violate public order and good morals.
[0033] In order to make the performance of a large model meet expectations on multiple tasks, it is usually necessary to use a large number of text training samples to fine-tune the model. Among them, a text training sample can include a prompt and a response combination, that is,<Prompt,Response> Among them, the prompt word means encapsulating the user's input, namely the query, into an instruction to interact with the big model. After requesting the big model with the prompt word, a response can be obtained. The response is the output of the big model. After further processing by the system, it can be presented to the user as the final result.
[0034] The related technology can manually write a query question, and then input the query question as a prompt word into any online large model to obtain the corresponding reply output by the large model, and then combine each prompt word with the corresponding reply to obtain at least two text training samples.
[0035] In this way, since the query questions initially input into the big model are manually written, and human vision and ability are limited, the diversity of text training samples generated based on the responses output by the big model is poor, resulting in low generalization of the big model fine-tuned based on such text training samples.
[0036] In order to generate diversified text training samples and improve the generalization of a large model fine-tuned based on the text training samples, the embodiments of the present disclosure provide a method, device and electronic device for generating text training samples based on a large model.
[0037] The following describes a method, device, and electronic device for generating text training samples based on a large model according to an embodiment of the present disclosure with reference to the accompanying drawings.
[0038] It should be noted that the execution subject of the method for generating text training samples based on a large model in this embodiment is a device for generating text training samples based on a large model. In the following embodiments, the device for generating text training samples based on a large model is referred to as a generating device. The generating device can be implemented by software and / or hardware, and can be configured in an electronic device, which can include but is not limited to a terminal, a server, etc.
[0039] Figure 1 It is a flowchart of a method for generating text training samples based on a large model provided according to an embodiment of the present disclosure.
[0040] like Figure 1 As shown, the method for generating text training samples based on the large model includes:
[0041] Step 101: cluster at least two query questions to obtain at least two query question clusters.
[0042] Among them, at least two query questions can be obtained by the generating device through various public, legal and compliant methods, for example, they can be obtained from a public data set, or obtained from the user after the user's authorization.
[0043] Among them, at least two query questions may have differences in any one or at least two of the following aspects: character length, core words, subject matter, field, intention, sentence structure, grammatical features, etc., so that they can be divided into different query question clusters.
[0044] For example, at least two query questions in the fields of science and technology, education, entertainment, and health can be obtained. Taking the field of health as an example, query questions related to topics such as making a fitness plan, improving sleep quality, and making a diet plan can be obtained, where the sentence structure and / or grammatical features of query questions under the same topic or different topics can be the same or different, such as "How to make a scientific and reasonable fitness plan to stay healthy?", "How much impact does sleep have on health?", "Help me make a healthy recipe", etc.
[0045] The method of clustering at least two query questions may be any one of the related technologies, such as K-means clustering, K-Medoids clustering, agglomerative hierarchical clustering, density-based clustering, etc. Taking K-means clustering as an example, a value of K may be pre-specified, where K is an integer greater than or equal to 2, and then the K-means clustering method is used to cluster at least two query questions to obtain K query question clusters.
[0046] Among them, by clustering at least two query questions, in at least two query question clusters obtained, the query questions in the same query question cluster have high similarity, and the query questions in different query question clusters have great differences. This difference can be reflected in any one or at least two of the following aspects: character length, core words, subject matter, field, intention, sentence structure, grammatical features, etc.
[0047] Step 102: Obtain a first query question from each query question cluster.
[0048] Among them, the number of first query questions obtained from each query question cluster can be set as needed, such as one or at least two, and the number of first query questions obtained from different query question clusters can be the same or different, and the present disclosure does not impose any restrictions on this.
[0049] Step 103: Taking the first query question as an example, at least two second query questions under the set topic are generated by using the first large model.
[0050] In a possible implementation form, the first query questions obtained from at least two query question clusters may be used as examples to generate at least two second query questions under a set topic through the first large model.
[0051] Among them, the first large model can be any large model. Among them, the large model is a large neural network model trained using a deep learning algorithm, which is designed to understand and generate natural language text. The large model is trained with a large amount of text data, and can capture the complexity and nuances of the language, so as to perform various natural language processing tasks, such as text generation, question-answering systems, semantic understanding and reasoning. This model is designed to improve the expressiveness and predictive performance of the model, and can handle more complex tasks and data, showing human-like intelligence. Among them, large models may include GPT3 (Generative Pre-trained Transformer, Generative Pre-trained Transformer 3), GPT4, T5 (Text-to-Text Transfer Transformer, Text to Text Transformer), LLaMA (Large Language Model Meta AI, lightweight large model), etc.
[0052] The theme can be set as needed and can include one or at least two set themes.
[0053] Among them, the number of second query questions generated by the first large model can be set in advance.
[0054] For example, assuming that the set topic includes the topic of improving sleep health, it is pre-set that 30 second query questions are generated through the first large model. assuming that 50 query questions are clustered to obtain 3 query question clusters, and query question A is obtained from query question cluster 1, query question B is obtained from query question cluster 2, and query question C is obtained from query question cluster 3. Then, the first large model can be requested to use query question A, query question B, and query question C as examples to generate 30 second query questions under the topic of improving sleep health.
[0055] Among them, when the first large model generates 30 second query questions under the topic, the first query questions used as examples are obtained from three query question clusters respectively, and there are differences between the first query questions obtained from different query question clusters. Therefore, the 30 second query questions generated by the first large model are also different, that is, diversified.
[0056] In one possible implementation, steps 102-103 may be performed at least twice, i.e., obtaining the first query question from each query question cluster at least twice, and then using the first query question obtained from at least two query question clusters each time as an example, generating at least two second query questions under the set topic through the first large model, thereby obtaining more second query questions with differences.
[0057] Step 104: Based on the second query question, generate a first text training sample for fine-tuning the second large model.
[0058] In a possible implementation form, a first text training sample may be generated based on at least two second query questions under a set topic generated by the first large model.
[0059] The second largest model can be any large model. The second largest model and the first largest model can be the same or different large models.
[0060] In one possible implementation form, for each second query question, the second query question can be used as a prompt word and input into any online large model. The response corresponding to the prompt word is obtained through the large model, and the prompt word is combined with the corresponding response to obtain a first text training sample.
[0061] The method for generating text training samples based on a large model provided by the embodiment of the present disclosure is to obtain at least two query question clusters by clustering at least two query question clusters; obtain a first query question from each query question cluster; use the first query question as an example to generate at least two second query questions under a set topic through the first large model; and generate a first text training sample for fine-tuning the second large model based on the second query question. Since the first large model uses the first query question obtained from each query question cluster as an example when generating at least two second query questions under a set topic, and the first query questions obtained from different query question clusters are different, the at least two second query questions under the set topic generated by the first large model are also different, that is, the generated at least two second query questions are diversified, and then the first text training sample is generated based on the diversified second query questions, thereby improving the diversity of the generated first text training sample, and the second large model is fine-tuned based on the generated first text training sample, thereby improving the generalization of the fine-tuned second large model.
[0062] In order to clearly illustrate the process of generating at least two second query questions under a set topic through the first large model, and the process of generating a first text training sample for fine-tuning the second large model based on the second query questions, the embodiment of the present disclosure also provides a method for generating text training samples based on a large model.
[0063] Figure 2 It is a flowchart of a method for generating text training samples based on a large model provided according to another embodiment of the present disclosure.
[0064] like Figure 2 As shown, the method for generating text training samples based on the large model includes:
[0065] Step 201: Obtain at least two query questions.
[0066] In a possible implementation form, at least two query questions may be obtained by using at least one of the following methods:
[0067] When the second largest model is online, historical query questions input into the second largest model are collected to obtain at least two query questions;
[0068] Obtain a network document, and divide the network document into at least two segments, and obtain at least two query questions based on the at least two segments; wherein one segment can be used as a query question;
[0069] Get at least two query questions input by humans.
[0070] Among them, network documents are documents that are publicly available on the Internet.
[0071] Among them, the second largest model is the large model to be fine-tuned.
[0072] In one possible implementation form, when the second largest model to be fine-tuned is already online, historical query questions input into the second largest model can be collected to obtain at least two query questions; when the second largest model is not online and is in a cold start stage, at least two query questions manually input can be obtained, and / or, a web document can be obtained and divided into at least two segments, and at least two query questions can be obtained based on the at least two segments.
[0073] Thus, it is possible to flexibly select an appropriate method to obtain at least two query questions according to needs, so that the at least two query questions obtained have differences in one or at least two aspects. In addition, by collecting historical query questions input into the second largest model that has been launched, at least two query questions are obtained, and then based on the at least two query questions, a first text training sample for fine-tuning the second largest model is generated, which can automatically fine-tune the second largest model according to the user input data of the second largest model that has been launched, thereby continuously iterating and optimizing the second largest model based on the user input data of the second largest model, so that the generalization of the second largest model is continuously improved.
[0074] Step 202: cluster at least two query questions to obtain at least two query question clusters.
[0075] Step 203: Obtain the first query question from each query question cluster.
[0076] Step 204: Generate a first prompt word based on the first query question and relevant content of the set topic, wherein the first prompt word is used to indicate the example referenced by the query question to be generated and the topic to which it belongs.
[0077] Among them, the relevant content of the set theme may include the theme name, introduction, etc. of the set theme.
[0078] In a possible implementation form, the first prompt word may be generated based on a first query question obtained from at least two query question clusters and relevant content of a set topic.
[0079] In a possible implementation form, step 204 may be implemented in the following manner:
[0080] Acquire a prompt word template, wherein the prompt word template includes: a first text to be replaced corresponding to an example referenced by the query question to be generated, and a second text to be replaced corresponding to a topic to which the query question to be generated belongs;
[0081] The first text to be replaced is replaced based on the first query question, and the second text to be replaced is replaced based on relevant content of the set topic to obtain a first prompt word.
[0082] The first text to be replaced may be replaced based on at least two first query questions.
[0083] Among them, the prompt word template is a template for generating the first prompt word, and the content thereof can be preset as needed. For example, it can be set to include the text to be replaced, such as the first text to be replaced corresponding to the example referenced by the query question to be generated, and the second text to be replaced corresponding to the subject to which the query question to be generated belongs. In addition, it can also include indication information for indicating the requirements met by the query question to be generated, such as the number of query questions to be generated, the format in which they are output, and which characters cannot be included.
[0084] For example, the prompt word template may include the following four paragraphs:
[0085] You are a query generator that can follow the example below and generate 30 diverse query questions on the topic at one time based on the relevant content of the topic, and return the generated data in a list format that can be processed by Python:
[0086] Relevant content of the topic: the topic name is "name", the introduction includes "Introduction";
[0087] Example: ["query"]
[0088] Please follow the example and generate 30 diverse query questions under the topic at one time based on the relevant content of the topic. At least 20 of the query questions cannot contain the topic name and must be in the inverted sentence format. Return the generated data in a list format.
[0089] Assuming that the relevant content of the set topic includes the topic name and introduction of the set topic, after obtaining the prompt word template, it can be determined that the first text to be replaced corresponding to the example referenced by the query question to be generated in the prompt word template is: query, and the second text to be replaced corresponding to the topic to which the query question to be generated belongs is: name, Introduction. Then, the first text to be replaced query can be replaced with at least two first query questions, the name in the second text to be replaced can be replaced with the topic name of the set topic, and the Introduction in the second text to be replaced can be replaced with the introduction of the set topic, thereby obtaining the first prompt word.
[0090] Thus, it is possible to quickly generate the first prompt word for indicating the example referenced by the query question to be generated and the subject to which it belongs based on the preset prompt word template.
[0091] It should be noted that, in order to facilitate distinction from other prompt word templates, the prompt word template used to generate the first prompt word can be called the first prompt word template.
[0092] Step 205: input the first prompt word into the first large model to obtain at least two second query questions under the set topic.
[0093] It can be understood that when the first prompt word is input into the first large model, the first large model can generate at least two second query questions under the set topic based on the first prompt word and the first query question in the first prompt word as an example through its own ability. Among them, since when the first large model generates at least two second query questions under the set topic, the first query question used as an example is obtained from at least two query question clusters, and the first query questions obtained from different query question clusters are different, then the at least two second query questions under the set topic generated by the first large model are also different, that is, the generated at least two second query questions are diversified.
[0094] Therefore, by generating a first prompt word based on the first query question and the relevant content of the set topic, the first prompt word is used to indicate the example referenced by the query question to be generated and the topic to which it belongs, and the first prompt word is input into the first large model to obtain at least two second query questions under the set topic. The first prompt word can be used to guide the first large model to more accurately understand the task requirements, thereby accurately generating at least two second query questions under the expected set topic based on the first query question and the relevant content of the set topic.
[0095] Step 206: Generate a second prompt word corresponding to the second query question, wherein the second prompt word is used to indicate a rule based on which a reply to the corresponding second query question is generated.
[0096] In a possible implementation form, for each second query question, a second prompt word corresponding to the second query question may be generated.
[0097] In a possible implementation form, the second prompt word corresponding to each second query question may be generated in the following manner:
[0098] Acquire a second prompt word template, wherein the second prompt word template includes a rule based on which a response to a specified query question is generated, and a third to-be-replaced text corresponding to the specified query question;
[0099] The third text to be replaced is replaced based on the second query question to obtain a second prompt word.
[0100] Among them, the second prompt word template is a template for generating the second prompt word, and the content thereof can be preset as needed. For example, it can be set to include text to be replaced, such as the third text to be replaced corresponding to the specified query question. In addition, it can also include rules based on which the reply to the specified query question is generated, such as which reference articles are used to generate the reply, which constraints the reply satisfies, the number of characters included in the reply, the format of the reply, etc.
[0101] For example, taking the knowledge question answering task as an example, the second prompt word template may include the following 10 paragraphs:
[0102] You are a content summarization assistant. Given a user query and a list of reference articles, you need to answer the user query with reference documents.
[0103] Answer constraints:
[0104] 1. Ignore articles that are not related to the query in the reference article list and only refer to articles that can answer the query; if there is no article in the reference article list that can answer the user's query, then reply "Sorry, I did not retrieve relevant information."
[0105] 2. The output needs to be divided into 3 parts. The answer output is in code format and wrapped in ``````:
[0106] The first part is a brief summary. You can just summarize it directly without the need to output a title such as "Brief Summary";
[0107] The second part should have at least two subheadings (for example: ###2023 financial industry keywords) and a summary. The summary should be 4-5 sentences and can be directly output without the need to output a title such as "Part 2"; (Try to include more points, 5-6 is best, but do not repeat information)
[0108] The third part gives the reference links used in the summary of the second part to answer the user's questions. It starts with "###Related Resources" and the title in the reference link is the title field in the reference article information.
[0109] The following is the input, and the answer is output directly. Note that the length of the answer does not exceed 2000 characters, and no analysis process is given:
[0110] User Query: {Query}
[0111] Reference article list: {Docs}
[0112] After obtaining the second prompt word template, it can be determined that the third text to be replaced corresponding to the specified query question in the second prompt word template is: {Query}, and the third text to be replaced {Query} can be replaced with the second query question to obtain the second prompt word.
[0113] Thus, it is possible to quickly generate the second prompt word for indicating the rule according to which the answer to the corresponding second query question is generated based on the preset second prompt word template.
[0114] Step 207: Generate a response corresponding to the second prompt word through the third model.
[0115] In a possible implementation form, a response corresponding to each second prompt word can be generated through a third model.
[0116] The third largest model can be any large model. The third largest model and the second largest model are different large models, and the third largest model and the first largest model can be the same or different large models.
[0117] In one possible implementation, for each second query question, the second prompt word corresponding to the second query question is input into the third largest model, and the third largest model can output a response corresponding to the second query question based on the rule indicated by the second prompt word, that is, a response corresponding to the second prompt word.
[0118] In a possible implementation form, for each second prompt word, at least two corresponding responses can also be generated through the third model.
[0119] As an example, for each second prompt word, at least two replies corresponding to the second prompt word may be generated in the following manner:
[0120] The second prompt word is input into at least two different third largest models to obtain responses respectively output by at least two different third largest models.
[0121] Among them, in order to improve the accuracy of the generated responses, at least two different third large models can adopt stronger large models, such as GPT4, Gemini (a high-performance multimodal artificial intelligence model), etc.
[0122] In this way, at least two responses corresponding to the same second prompt word can be quickly generated directly through at least two different third models.
[0123] As an example, for each second prompt word, at least two replies corresponding to the second prompt word may be generated in the following manner:
[0124] The third model generates responses corresponding to the second prompt word multiple times, and each generated response is different.
[0125] Among them, the reply generated for the Nth time is the output obtained by inputting the update prompt word into the third largest model, and the update prompt word is obtained by concatenating the second prompt word with the reply generated for the N-1th time, and N is an integer greater than or equal to 2.
[0126] For each second prompt word, responses corresponding to the second prompt word may be generated multiple times through one or at least two third largest models, wherein for the same third largest model, the responses generated each time are different.
[0127] For example, at least two responses corresponding to the second prompt word a can be generated through the third largest model 1 and the third largest model 2.
[0128] Among them, the second prompt word a can be input into the third largest model 1 to obtain a reply generated for the first time by the third largest model 1; the second prompt word a and the reply generated for the first time by the third largest model 1 are spliced to obtain the updated prompt word b, and the updated prompt word b is input into the third largest model 1 to obtain a reply generated for the second time by the third largest model 1, and the reply generated for the second time is different from the reply generated for the first time. Therefore, a total of two replies corresponding to the second prompt word a can be generated twice through the third largest model 1.
[0129] In addition, the second prompt word a can be input into the third largest model 2 to obtain a reply generated for the first time by the third largest model 2; the second prompt word a and the reply generated for the first time by the third largest model 2 can be concatenated to obtain an updated prompt word c, and the updated prompt word c can be input into the third largest model 2 to obtain a reply generated for the second time by the third largest model 2, and the reply generated for the second time is different from the reply generated for the first time. Thus, a total of two replies corresponding to the second prompt word a can be generated twice through the third largest model 2.
[0130] As an example, assuming that the second prompt word is: XXXXXX, and the last generated reply is YYYYYY, the second prompt word is concatenated with the last generated reply to obtain an updated prompt word, for example, it can be:
[0131] XXXXXX, your last reply was YYYYYY, so please reply to this question again and give a better answer?
[0132] In this way, at least two replies corresponding to the same second prompt word can be generated through at least one third largest model, thereby reducing the number of third largest models used in generating replies corresponding to the second prompt word and reducing the sample generation cost.
[0133] Step 208: Generate a first text training sample for fine-tuning the second large model based on the second prompt word and the reply.
[0134] In a possible implementation form, the combination of any second prompt word and any corresponding reply can be used as a candidate sample, so that the same second prompt word can obtain at least one candidate sample, and then for any candidate sample, based on the correlation between the second prompt word and the corresponding reply in the candidate sample and / or the quality of the reply itself, the quality of the candidate sample is evaluated to obtain the quality of the candidate sample, wherein the quality can be represented by a quality score. In the case where the same second prompt word corresponds to one candidate sample, if the quality score corresponding to the candidate sample is higher than a preset threshold, the candidate sample can be used as a first text training sample, and if the quality score of the candidate sample is not higher than the preset threshold, the candidate sample can be discarded. In the case where the same second prompt word corresponds to at least two candidate samples, the candidate sample with the highest quality score can be used as a first text training sample, and the other candidate samples corresponding to the second prompt word can be discarded. In this way, a first text training sample for fine-tuning the second large model can be generated.
[0135] Among them, the specific implementation forms of steps 201-208 and similar steps in other embodiments can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0136] In the disclosed embodiment, at least two query questions are clustered to obtain at least two query question clusters, a first query question is obtained from each query question cluster, a first prompt word is generated based on the first query question and relevant content of a set topic, wherein the first prompt word is used to indicate an example referenced by the query question to be generated and a topic to which it belongs, the first prompt word is input into a first large model to obtain a second query question, a second prompt word corresponding to the second query question is generated, wherein the second prompt word is used to indicate a rule based on which a reply to the corresponding second query question is generated, and a reply corresponding to the second prompt word is generated through a third large model, so that the third large model can be guided by the second prompt word to more accurately understand the task requirements, thereby accurately generating at least one expected reply to the second prompt word based on the generation rule of the reply to the second query question, and then generating a first text training sample for fine-tuning the second large model based on the second prompt word and the corresponding reply. In addition, since the first large model uses the first query questions obtained from each query question cluster as an example when generating at least two second query questions under the set topic, and the first query questions obtained from different query question clusters are different, the at least two second query questions under the set topic generated by the first large model are also different, that is, the generated at least two second query questions are diversified, and then the first text training samples are generated based on the diversified second query questions, thereby improving the diversity of the generated first text training samples, and fine-tuning the second large model based on the generated first text training samples, thereby improving the generalization of the fine-tuned second large model.
[0137] From the above analysis, it can be seen that the embodiment of the present disclosure can generate a first text training sample based on the second prompt word and the corresponding reply. In order to improve the quality of the generated first text training sample, the embodiment of the present disclosure also provides a method for generating text training samples based on a large model.
[0138] Figure 3 It is a flowchart of a method for generating text training samples based on a large model provided according to another embodiment of the present disclosure.
[0139] like Figure 3 As shown, the method for generating text training samples based on the large model includes:
[0140] Step 301: cluster at least two query questions to obtain at least two query question clusters.
[0141] Step 302: Obtain a first query question from each query question cluster.
[0142] Step 303: Taking the first query question as an example, at least two second query questions under the set topic are generated through the first large model.
[0143] Step 304: Generate a second prompt word corresponding to the second query question, wherein the second prompt word is used to indicate a rule based on which a reply to the corresponding second query question is generated.
[0144] Step 305: Generate a response corresponding to the second prompt word through the third model.
[0145] In a possible implementation form, for each second query question, a second prompt word corresponding to the second query question may be generated, and a response corresponding to the second prompt word may be generated through the third large model.
[0146] Step 306: Use the second prompt word and the corresponding reply as candidate samples.
[0147] In one possible implementation form, for each second prompt word, the combination of the second prompt word and a corresponding reply can be used as a candidate sample, so that when the second prompt word corresponds to one reply, a candidate sample corresponding to the second prompt word can be obtained, and when the second prompt word corresponds to at least two replies, at least two candidate samples corresponding to the second prompt word can be obtained.
[0148] Step 307, obtaining the quality of the candidate sample and the corresponding sample optimization information, wherein the quality is determined based on at least one of the relevance between the second prompt word and the corresponding reply and the quality of the reply itself.
[0149] The quality of any candidate sample is determined based on at least one of the relevance between the second prompt word in the candidate sample and the corresponding reply and the quality of the reply itself.
[0150] Among them, the correlation between the second prompt word and the corresponding reply indicates the correlation between the second prompt word and the corresponding reply. Among them, when the reply is closely related to the second prompt word, can accurately answer the query question corresponding to the second prompt word, or continue the topic of the conversation, the correlation between the second prompt word and the corresponding reply is high. For example, assuming that the second prompt word indicates the rule based on which the reply to the corresponding query question "How is the weather today?" is generated, if the reply corresponding to the second prompt word is "Today is Monday", since the theme of the second prompt word is weather and the theme of the reply is date, the two themes are different, then the correlation between the second prompt word and the corresponding reply is low; if the reply corresponding to the second prompt word is "Today is sunny", since the theme of the reply is weather, which is the same as the theme of the second prompt word, then the correlation between the second prompt word and the corresponding reply is high.
[0151] The quality of the reply itself can be determined by one or at least two of the following factors: clarity, naturalness, innovation, and richness. Clarity refers to whether the reply is clear and easy to understand, and whether the logic is coherent. Naturalness refers to whether the reply is natural and fluent, and whether it conforms to daily communication habits. Innovation refers to whether the reply contains novel ideas or expressions. Richness refers to whether the content of the reply is rich, such as whether the reply is provided from at least two aspects, and whether it includes at least two forms of expression such as text and tables.
[0152] The sample optimization information, i.e., the information used to optimize the candidate samples, may include, for example, defects of the candidate samples, optimization methods, etc.
[0153] In a possible implementation form, for any candidate sample, the quality of the candidate sample and the corresponding sample optimization information can be obtained in the following manner:
[0154] Based on the candidate sample, generate a corresponding third prompt word, wherein the third prompt word is used to indicate the quality of generating the candidate sample and the rule based on which the corresponding sample optimization information is based;
[0155] The third prompt word is input into the target evaluation model to obtain the quality of the candidate samples output by the target evaluation model and the corresponding sample optimization information.
[0156] The target evaluation model can be a large model in the related technology, or a model obtained by training the initial evaluation model. In order to improve the accuracy of the evaluation results, the large model in the related technology can adopt a stronger large model, such as GPT3. In order to improve training efficiency and reduce training costs, the initial evaluation model can adopt a large model with fewer parameters, such as the LLaMa model.
[0157] The quality of the candidate samples can be represented by a quality score.
[0158] In a possible implementation form, a third prompt word template may be obtained, which includes a rule based on which the quality of the specified sample and the corresponding sample optimization information are generated, and a fourth to-be-replaced text corresponding to the specified sample. The rule based on which the quality of the specified sample is generated and the rule based on which the corresponding sample optimization information is generated may be the same or different.
[0159] For example, the third prompt word template may include the following four sections:
[0160] Specify the sample as:<prompt,response>
[0161] The quality assessment rules are: evaluate from the following dimensions: the relevance of the prompt and the response, and the clarity, naturalness, and innovation of the response itself.
[0162] The generation rule of sample optimization information is as follows: sample optimization information of a specified sample is given from the dimensions of the relevance between prompt and response, and the clarity, naturalness, and innovation of the response itself.
[0163] What do you think of the quality score of this sample? What is the sample optimization information?
[0164] Among them, prompt and response in the third prompt word template are the fourth text to be replaced corresponding to the specified sample, the content of the second paragraph is the rule based on which the quality of the specified sample is generated, and the content of the third paragraph is the rule based on which the corresponding sample optimization information is generated.
[0165] After obtaining the third prompt word template, the prompt in the fourth text to be replaced can be replaced with the second prompt word in the candidate sample, and the response in the fourth text to be replaced can be replaced with the reply in the candidate sample, thereby obtaining the third prompt word, which is used to indicate the quality of the candidate sample and the rule based on which the corresponding sample optimization information is generated. The third prompt word is input into the target evaluation model to obtain the quality of the candidate sample output by the target evaluation model and the corresponding sample optimization information.
[0166] Therefore, by generating a corresponding third prompt word based on the candidate sample, wherein the third prompt word is used to indicate the quality of generating the candidate sample and the rules based on which the corresponding sample optimization information is generated, and inputting the third prompt word into the target evaluation model to obtain the quality of the candidate sample and the corresponding sample optimization information output by the target evaluation model, it is possible to guide the target evaluation model to more accurately understand the task requirements through the third prompt word, thereby accurately generating the expected quality of the candidate sample and the corresponding sample optimization information based on the rules based on which the quality of the candidate sample and the corresponding sample optimization information are generated.
[0167] In a possible implementation form, when the target evaluation model is a model obtained by training the initial evaluation model, the initial evaluation model may be trained to obtain the target evaluation model in the following manner:
[0168] Obtain a fourth prompt word corresponding to the target sample; wherein the target sample includes a sample prompt word corresponding to the sample query question and a corresponding sample reply, the sample prompt word is used to indicate a rule based on which a sample reply to the corresponding sample query question is generated, and the fourth prompt word is used to indicate a rule based on which the quality of the target sample and the corresponding sample optimization information are generated;
[0169] Inputting the fourth prompt word into the fourth model, obtaining the quality of the target sample output by the fourth model and corresponding sample optimization information;
[0170] The quality of the target sample and the corresponding sample optimization information are corrected, and the corrected quality of the target sample and the corresponding sample optimization information are used as the fourth prompt word annotated as the second text training sample to train the initial evaluation model to obtain the target evaluation model.
[0171] The fourth largest model can be any large model. The fourth largest model can be the same or different from the first large model, the second large model or the third large model. In order to improve the accuracy of the generated results, the fourth largest model can adopt a stronger large model.
[0172] The number of target samples may be at least two, and one target sample is obtained by combining a sample prompt word and a corresponding sample reply. The method for obtaining the sample query question, the corresponding sample prompt word, and the corresponding sample reply may correspond to the method for obtaining the second query question, the corresponding second prompt word, and the corresponding reply, and will not be repeated here.
[0173] The method for obtaining the fourth prompt word corresponding to the target sample may be the same as the method for obtaining the third prompt word corresponding to the candidate sample, which will not be described in detail here.
[0174] In the example embodiment, by inputting the fourth prompt word into the fourth largest model, the quality of the target sample output by the fourth largest model and the corresponding sample optimization information can be obtained, and the quality of the target sample and the corresponding sample optimization information can be corrected, such as by manual correction, and the corrected quality of the target sample and the corresponding sample optimization information are used as the annotation of the corresponding fourth prompt word, and the annotated fourth prompt word is used as the second text training sample to train the initial evaluation model to obtain the target evaluation model.
[0175] Therefore, by obtaining the fourth prompt word corresponding to the target sample, inputting the fourth prompt word into the fourth largest model, obtaining the quality of the target sample and the corresponding sample optimization information output by the fourth largest model, correcting the quality of the target sample and the corresponding sample optimization information, and using the fourth prompt word with the corrected target sample quality and the corresponding sample optimization information as the second text training sample to train the initial evaluation model, it is possible to train a target evaluation model that can accurately predict the quality of candidate samples and the corresponding sample optimization information.
[0176] Step 308, when the quality of the candidate sample does not meet the preset conditions, based on the corresponding sample optimization information, the third largest model of the response is generated to optimize the response and obtain the optimized candidate sample.
[0177] The quality of the candidate sample may be represented by a quality score. Accordingly, the quality of the candidate sample not meeting a preset condition may include: the quality score of the candidate sample is not higher than a preset threshold.
[0178] In one possible implementation form, when the quality of a candidate sample does not meet preset conditions, the response can be optimized by generating a third largest model of the response in the candidate sample based on the corresponding sample optimization information to obtain an optimized candidate sample.
[0179] In a possible implementation form, for candidate samples whose quality does not meet the preset conditions, the responses therein can be optimized in the following manner to obtain optimized candidate samples:
[0180] The second prompt word is concatenated with the sample optimization information to obtain an optimization prompt word; wherein the second prompt word refers to the second prompt word in the candidate sample whose quality does not meet the preset condition, and the sample optimization information refers to the sample optimization information corresponding to the candidate sample;
[0181] Input the optimization prompt words into the third model for generating responses, and obtain optimized responses; wherein the responses refer to responses in the candidate samples whose quality does not meet the preset conditions;
[0182] Based on the second prompt word and the optimized response, an optimized candidate sample is generated.
[0183] Among them, assuming that the second prompt word is: XXXXXX, and the sample optimization information is ******, then the optimization prompt word can be, for example: Please give a reply of XXXXXX based on the sample optimization information of ******?
[0184] In an example embodiment, for any candidate sample, if it is determined that the quality of the candidate sample does not meet the preset conditions based on at least one of the correlation between the second prompt word and the corresponding reply and the quality of the reply itself, the second prompt word in the candidate sample can be spliced with the corresponding sample optimization information to obtain the optimized prompt word, and then the optimized prompt word is input into the third largest model that originally generated the reply in the candidate sample, wherein the sample optimization information may include defects existing in the candidate sample, optimization methods, etc., so that the third largest model can consider the defects existing in the candidate sample, optimization methods, etc., and optimize the originally generated reply to obtain the optimized reply, and the second prompt word and the optimized reply can constitute the optimized candidate sample. In this way, it is possible to optimize the candidate sample based on the sample optimization information of the candidate sample through the third largest model, so that the correlation between the second prompt word in the candidate sample and the corresponding reply is higher or the quality of the reply itself is higher, thereby improving the quality of the candidate sample.
[0185] Step 309: Generate a first text training sample for fine-tuning the second largest model based on the optimized candidate sample.
[0186] It should be noted that, for any candidate sample, after obtaining the optimized candidate sample, you can continue to obtain the quality of the optimized candidate sample and the corresponding optimization information, and judge again whether the quality of the optimized candidate sample meets the preset conditions. If not, you can continue to optimize in the above manner until the quality of the further optimized candidate sample meets the preset conditions, or the number of optimizations reaches the preset number.
[0187] In a possible implementation, for any second prompt word, when the second prompt word corresponds to a candidate sample, if the quality of the candidate sample does not meet the preset conditions, the candidate sample can be optimized based on the sample optimization information, and after obtaining the optimized candidate sample, the quality of the optimized candidate sample and the corresponding optimization information are continued to be obtained, and it is judged again whether the quality of the optimized candidate sample meets the preset conditions. If not, the optimization can be continued in the above manner until the quality of the further optimized candidate sample meets the preset conditions, or the number of optimizations reaches the preset number, and the last optimized candidate sample is used as a first text training sample. If the quality of the candidate sample still does not meet the preset conditions after at least two optimizations, the candidate sample can be discarded.
[0188] In one possible implementation form, for any second prompt word, when the second prompt word corresponds to at least two candidate samples, for the candidate samples whose quality does not meet the preset conditions, optimization can be performed based on the corresponding sample optimization information, and after obtaining the optimized candidate samples, the quality of the optimized candidate samples and the corresponding optimization information are continued to be obtained, and it is judged again whether the quality of the optimized candidate samples meets the preset conditions. If not, the optimization can be continued in the above manner until the quality of the further optimized candidate samples meets the preset conditions, or the number of optimizations reaches the preset number, and the candidate sample with the highest quality is selected from the candidate samples optimized for the last time and the candidate samples whose initial quality meets the preset conditions as a first text training sample.
[0189] In the example embodiment, after generating enough first text training samples, the second largest model can be incrementally fine-tuned, and the performance of the fine-tuned second largest model can be evaluated. If it does not meet expectations, more first text training samples can be generated according to the method of the above embodiment, and the model can be fine-tuned again. After at least two rounds of training, the model capability is continuously improved. After the fine-tuned second largest model is launched, historical query questions input into the second largest model can be automatically mined from user logs, and then the first text training samples can be generated according to the above method, and the second largest model can be continuously updated to optimize the user experience.
[0190] In a possible implementation form, the third prompt word template may further include a rule for generating a difficulty value of a specified sample, so that after replacing the response in the fourth to-be-replaced text with the reply in the candidate sample, the third prompt word obtained is also used to indicate the rule for generating a difficulty value of the candidate sample. The difficulty value indicates the difficulty of generating a reply.
[0191] The rules for generating the difficulty value of the specified sample may include, for example, determining the difficulty value from the following aspects: the number of fields or topics included in the specified sample, whether at least two rounds of interaction are required to give a response, and the quality score of the specified sample. In the case where the number of fields or topics included in the specified sample is large, the difficulty value of the specified sample can be considered to be high. In the case where at least two rounds of interaction are required to give a response, the difficulty value of the specified sample can be considered to be high. The lower the quality score of the specified sample, the higher the difficulty value of the specified sample can be considered to be.
[0192] The third prompt word is input into the target evaluation model, and the difficulty value of the candidate sample output by the target evaluation model can also be obtained. After the first text training sample is generated according to the candidate sample, the first text training sample corresponding to the candidate sample can also be divided into the target training stage in at least two training stages of the second largest model according to the difficulty value, wherein the difficulty values corresponding to the first text training samples used in different training stages are different.
[0193] For example, the stage of fine-tuning the second largest model can be divided into three training stages, wherein the first training stage can use the first text training sample with a low difficulty value, the second training stage can use the first text training sample with a medium difficulty value, and the third training stage can use the first text training sample with a high difficulty value. By dividing the first text training samples corresponding to the candidate samples into target training stages in at least two training stages of the second largest model based on the difficulty value, and fine-tuning the second largest model in the order of the first training stage, the second training stage, and the third training stage, the second largest model can gradually establish a basic understanding and cognitive framework of the task, accelerate the fine-tuning process, and improve the model effect.
[0194] The specific implementation forms of steps 301-309 can refer to the detailed description in other embodiments of the present disclosure, and will not be described in detail here.
[0195] The method for generating text training samples based on a large model provided by the embodiment of the present disclosure takes the second prompt word and the corresponding reply as candidate samples, obtains the quality of the candidate samples and the corresponding sample optimization information, wherein the quality is determined based on at least one of the correlation between the second prompt word and the corresponding reply and the quality of the reply itself. When the quality of the candidate sample does not meet the preset conditions, based on the corresponding sample optimization information, the reply is optimized by generating a third large model of the reply to obtain the optimized candidate sample. Based on the optimized candidate sample, the first text training sample for fine-tuning the second large model is generated, which can improve the quality of the candidate samples, so that a large number of candidate samples will not be filtered out because their quality does not meet the preset conditions, improve the sample pass rate, and reduce the sample generation cost, thereby making the final second large model fine-tuned based on the first text training sample better.
[0196] Combine the following Figure 4 , the process of the method for generating text training samples based on a large model provided in an embodiment of the present disclosure is exemplarily described.
[0197] refer to Figure 4 ,The method for generating text training samples based on large models can include two stages: the ,candidate sample generation stage and the candidate sample optimization stage.
[0198] Among them, in the candidate sample generation stage, at least two query questions can be obtained first (corresponding to module 401), and then the at least two query questions are clustered to obtain at least two query question clusters, and the first query question is obtained from each query question cluster. The first query question is used as an example, and at least two second query questions under the set topic are generated through the first large model, thereby generating at least two second query questions (corresponding to module 402). Further, for each second query question, a second prompt word corresponding to the second query question can be generated, wherein the second prompt word is used to indicate the rule based on which the reply to the corresponding second query question is generated, and the reply corresponding to the second query question is generated through the third large model (corresponding to module 403). Further, for each second prompt word, the second prompt word and a corresponding reply can be used as a candidate sample, thereby obtaining at least one candidate sample corresponding to the second prompt word (corresponding to module 404).
[0199] In the candidate sample optimization stage, the target evaluation model can be obtained first (corresponding to module 405), and then for any candidate sample, based on the target evaluation model, the quality of the candidate sample and the corresponding sample optimization information (corresponding to module 406) are obtained, and when the quality of the candidate sample does not meet the preset conditions, the third largest model of the reply in the candidate sample is generated, and the reply is optimized based on the corresponding sample optimization information to obtain the optimized candidate sample, and then the quality of the optimized candidate sample and the corresponding sample optimization information are continuously obtained through the target evaluation model until the quality of the further optimized candidate sample meets the preset conditions or the number of optimizations reaches the preset number. Further, for any second prompt word, the candidate sample with the highest quality can be selected from the candidate sample optimized for the last time and the candidate sample whose initial quality meets the preset conditions as a first text training sample (corresponding to module 407). Thus, the first text training sample for fine-tuning the second largest model can be obtained (corresponding to module 408). The second largest model can be fine-tuned through the first text training sample to obtain the fine-tuned second largest model (corresponding to module 409), and the performance of the fine-tuned second largest model can be evaluated. If the performance does not meet expectations, more first text training samples can be generated according to the above method, and the model can be fine-tuned again. After at least two rounds of training, the model capability can be continuously improved.
[0200] After the fine-tuned second largest model is launched, historical query questions input into the second largest model can be automatically mined from user logs, and then the first text training samples can be generated according to the above method, and the second largest model can be continuously updated to optimize the user experience. The fine-tuned second largest model can be used in module 403 to continue to generate replies corresponding to the second prompt word, so as to further generate first text training samples and continue to fine-tune the model.
[0201] Therefore, when the first large model generates at least two second query questions under the set topic, the first query questions obtained from each query question cluster are used as examples, and the first query questions obtained from different query question clusters are different, so the at least two second query questions under the set topic generated by the first large model are also different, that is, the generated at least two second query questions are diversified, and then the first text training samples are generated based on the diversified second query questions, which improves the diversity of the generated first text training samples, and the second large model is fine-tuned based on the generated first text training samples, which improves the generalization of the fine-tuned second large model. When the quality of the candidate sample does not meet the preset conditions, by generating the third large model of the reply in the candidate sample, based on the corresponding sample optimization information, the reply is optimized to obtain the optimized candidate sample, and based on the optimized candidate sample, the first text training sample for fine-tuning the second large model is generated, which can improve the quality of the candidate sample, so that a large number of candidate samples will not be filtered out because the quality does not meet the preset conditions, improve the sample pass rate, reduce the sample generation cost, and thus make the second large model fine-tuned based on the first text training sample The effect is better. By automatically mining historical query questions input into the second largest model from user logs after the fine-tuned second largest model is launched, and then generating the first text training samples according to the above method, and continuously updating the second largest model, it is possible to automatically and efficiently generate the first text training samples based on the user input data of the second largest model that has been launched without human intervention, and automatically fine-tune the second largest model, thereby continuously iterating and optimizing the second largest model based on the user input data of the second largest model, so that the generalization of the second largest model is continuously improved.
[0202] Based on the first text training sample generated in the above embodiment, the present disclosure also provides a method for fine-tuning a large model.
[0203] It should be noted that the executor of the large model fine-tuning method of this embodiment is the large model fine-tuning device. The large model fine-tuning device can be implemented by software and / or hardware and can be configured in an electronic device. The electronic device may include but is not limited to a terminal, a server, etc.
[0204] Figure 5 It is a flowchart of a method for fine-tuning a large model provided according to an embodiment of the present disclosure.
[0205] like Figure 5 As shown, the fine-tuning method of the large model includes:
[0206] Step 501: Obtain a first text training sample.
[0207] The first text training sample is generated based on the method for generating text training samples based on a large model in the above embodiment.
[0208] Step 502: fine-tune the large model based on the first text training sample.
[0209] Among them, the large model can be the second largest model in the above embodiment.
[0210] Among them, the method of fine-tuning the large model can be set as needed.
[0211] In one possible implementation form, the large model can be incrementally fine-tuned based on the acquired first text training sample, and the performance of the fine-tuned large model can be evaluated. If it does not meet expectations, more first text training samples can be generated according to the method for generating text training samples based on the large model in the above embodiment, and then the model can be fine-tuned based on the generated first text training samples. After at least two rounds of training, the ability of the large model is continuously improved. After the fine-tuned large model is launched, historical query questions input into the large model can be automatically mined from user logs, and then the first text training samples can be generated according to the method for generating text training samples based on the large model in the above embodiment, and the large model can be continuously updated to optimize the user experience.
[0212] The method for fine-tuning a large model provided in an embodiment of the present disclosure obtains a first text training sample, wherein the first text training sample is generated based on the method for generating text training samples based on a large model in the above-mentioned embodiment, and then fine-tunes the large model based on the first text training sample. Since the first text training sample is diverse, the large model is fine-tuned based on the first text training sample, thereby improving the generalization of the large model after fine-tuning.
[0213] Based on the above embodiments, the present disclosure also provides a question-answering method based on a large model.
[0214] It should be noted that the executor of the big model-based question-answering method of this embodiment is a big model-based question-answering device. The big model-based question-answering device can be implemented by software and / or hardware and can be configured in an electronic device. The electronic device may include but is not limited to a terminal, a server, etc.
[0215] Figure 6 It is a flowchart of a question-answering method based on a large model provided according to an embodiment of the present disclosure.
[0216] like Figure 6 As shown, the large model-based question answering method includes:
[0217] Step 601, obtaining a target query question.
[0218] Among them, the target query question can be any query question raised by the user, such as "I want to go on a business trip", "How much impact does sleep have on health?", etc.
[0219] Step 602: Generate prompt words corresponding to the target query question, wherein the prompt words are used to indicate the rules based on which the responses corresponding to the target query question are generated.
[0220] In a possible implementation form, the prompt words corresponding to the target query question may be generated in the following manner:
[0221] Acquire a fourth prompt word template, wherein the fourth prompt word template includes a rule based on which a response to a specified query question is generated, and a fifth to-be-replaced text corresponding to the specified query question;
[0222] The fifth text to be replaced is replaced based on the target query question to obtain a prompt word corresponding to the target query question.
[0223] Among them, the fourth prompt word template is a template for generating prompt words corresponding to the target query question, and the content thereof can be pre-set as needed. For example, it can be set to include text to be replaced, such as the fifth text to be replaced corresponding to the specified query question. In addition, it can also include rules based on which the reply to the specified query question is generated, such as which reference articles are used to generate the reply, which constraints the reply satisfies, the number of characters included in the reply, the format of the reply, etc.
[0224] For example, taking the knowledge question answering task as an example, the fourth prompt word template may include the following 10 paragraphs:
[0225] You are a content summarization assistant. Given a user query and a list of reference articles, you need to answer the user query with reference documents.
[0226] Answer constraints:
[0227] 1. Ignore articles that are not related to the query in the reference article list and only refer to articles that can answer the query; if there is no article in the reference article list that can answer the user's query, then reply "Sorry, I did not retrieve relevant information."
[0228] 2. The output needs to be divided into 3 parts. The answer output is in code format and wrapped in ``````:
[0229] The first part is a brief summary. You can just summarize it directly without the need to output a title such as "Brief Summary";
[0230] The second part should have at least two subheadings (for example: ###2023 financial industry keywords) and a summary. The summary should be 4-5 sentences and can be directly output without the need to output a title such as "Part 2"; (Try to include more points, 5-6 is best, but do not repeat information)
[0231] The third part gives the reference links used in the summary of the second part to answer the user's questions. It starts with "###Related Resources" and the title in the reference link is the title field in the reference article information.
[0232] The following is the input, and the answer is output directly. Note that the length of the answer does not exceed 2000 characters, and no analysis process is given:
[0233] User Query: {Query}
[0234] Reference article list: {Docs}
[0235] After obtaining the fourth prompt word template, it can be determined that the fifth text to be replaced corresponding to the specified query question in the fourth prompt word template is: {Query}, and the fifth text to be replaced {Query} can be replaced with the target query question to obtain the prompt word corresponding to the target query question.
[0236] Taking the functional component recall task as an example, the fourth prompt word template may include the following 8 paragraphs:
[0237] You need to arrange the intent of the query entered by the user and output the intention arrangement results in a list, ensuring that the order of the intents in the list is logical (if the intent is not in the following list, an empty list is output).
[0238] List of intents:
[0239] [Travel Application Plugin]: Filter the to-do list based on time, priority, completion status and other information.
[0240] [Meal Card Recharge]: Returns the meal card recharge link for the current user.
[0241] [Leave Application]: Initiate an annual leave application for the current user, including the start and end time of the leave.
[0242] The output format is as follows:
[0243] ["meaning Figure 1 ","meaning Figure 2 ”]
[0244] User Query: {Query}
[0245] After obtaining the fourth prompt word template, it can be determined that the fifth text to be replaced corresponding to the specified query question in the fourth prompt word template is: {Query}, and the fifth text to be replaced {Query} can be replaced with the target query question to obtain the prompt word corresponding to the target query question.
[0246] Thus, based on the preset fourth prompt word template, prompt words for indicating the rule according to which the answer to the corresponding target query question is generated can be quickly generated.
[0247] Step 603: input the prompt word into the large model to obtain a reply corresponding to the prompt word output by the large model.
[0248] The large model is a large model that is fine-tuned using the first text training sample, and the first text training sample is generated based on the method for generating text training samples based on the large model in the above embodiment.
[0249] Continuing with the above example, assuming that the prompt word is generated based on the fourth prompt word template corresponding to the above knowledge question and answer task, the prompt word is input into the big model. The big model can summarize the reference article list based on the prompt word, thereby generating a response corresponding to the prompt word, which can answer the target query question.
[0250] Assuming that the prompt word is generated based on the fourth prompt word template corresponding to the above-mentioned functional component recall task, the prompt word is input into the big model, and the big model can perform intent arrangement for the target query question based on the prompt word, and output the intent arrangement result in a list. The intent arrangement result can be used to recall the corresponding functional component from the existing functional components.
[0251] The question-answering method based on a big model provided in the embodiment of the present disclosure obtains a target query question, generates a prompt word corresponding to the target query question, wherein the prompt word is used to indicate the rule based on which the reply corresponding to the target query question is generated, inputs the prompt word into the big model, and obtains the reply corresponding to the prompt word output by the big model, wherein the big model is a big model fine-tuned using a first text training sample, and the first text training sample is generated based on the method for generating a text training sample based on a big model in the above embodiment. Since the first text training sample is diverse, the generalization of the big model fine-tuned based on the first text training sample is improved, and then the target query question is answered based on the fine-tuned big model, which can improve the accuracy of the answer to the target query question.
[0252] In order to implement the above embodiments, the present disclosure also provides a device for generating text training samples based on a large model.
[0253] Figure 7It is a structural diagram of a device for generating text training samples based on a large model provided according to an embodiment of the present disclosure.
[0254] like Figure 7 As shown, the large model-based text training sample generation device 700 includes:
[0255] A clustering module 701 is used to cluster at least two query questions to obtain at least two query question clusters;
[0256] A first acquisition module 702, configured to acquire a first query question from each query question cluster;
[0257] A first generating module 703 is used to use the first query question as an example and generate at least two second query questions under a set topic through a first large model;
[0258] The second generating module 704 is used to generate a first text training sample for fine-tuning the second large model based on the second query question.
[0259] As a possible implementation of the embodiment of the present disclosure, the first generating module 703 includes:
[0260] A first generation submodule is used to generate a first prompt word based on the first query question and the relevant content of the set topic, wherein the first prompt word is used to indicate the example referenced by the query question to be generated and the topic to which it belongs;
[0261] The processing submodule is used to input the first prompt word into the first large model to obtain a second query question.
[0262] As a possible implementation of the embodiment of the present disclosure, the first generating submodule includes:
[0263] A first acquisition unit is used to acquire a prompt word template, wherein the prompt word template includes: a first text to be replaced corresponding to an example referenced by the query question to be generated, and a second text to be replaced corresponding to a topic to which the query question to be generated belongs;
[0264] The replacement unit is used to replace the first text to be replaced based on the first query question, and replace the second text to be replaced based on the relevant content of the set topic to obtain the first prompt word.
[0265] As a possible implementation of the embodiment of the present disclosure, the second generating module 704 includes:
[0266] A second generation submodule, used to generate a second prompt word corresponding to a second query question, wherein the second prompt word is used to indicate a rule based on which a reply to the corresponding second query question is generated;
[0267] A third generation submodule is used to generate a response corresponding to the second prompt word through a third model;
[0268] The fourth generation submodule is used to generate a first text training sample based on the second prompt word and the reply.
[0269] As a possible implementation of the embodiment of the present disclosure, each second prompt word corresponds to at least two replies; the third generation submodule includes:
[0270] The first generating unit is used to input the second prompt word into at least two different third largest models to obtain responses respectively output by at least two different third largest models.
[0271] As a possible implementation of the embodiment of the present disclosure, each second prompt word corresponds to at least two replies; the third generation submodule includes:
[0272] A second generation unit is used to generate responses corresponding to the second prompt word multiple times through the third model, and the responses generated each time are different;
[0273] Among them, the reply generated for the Nth time is the output obtained by inputting the update prompt word into the third largest model, and the update prompt word is obtained by concatenating the second prompt word with the reply generated for the N-1th time, and N is an integer greater than or equal to 2.
[0274] As a possible implementation of the embodiment of the present disclosure, the fourth generation submodule includes:
[0275] A determination unit, used for taking the second prompt word and the corresponding response as candidate samples;
[0276] A second acquisition unit is used to acquire the quality of the candidate sample and the corresponding sample optimization information, wherein the quality is determined based on at least one of the relevance between the second prompt word and the corresponding reply and the quality of the reply itself;
[0277] An optimization unit, used for optimizing the responses by generating a third model of responses based on corresponding sample optimization information when the quality of the candidate samples does not meet the preset conditions, thereby obtaining optimized candidate samples;
[0278] The third generating unit is used to generate a first text training sample based on the optimized candidate sample.
[0279] As a possible implementation of the embodiment of the present disclosure, the second acquisition unit includes:
[0280] A first generating subunit is used to generate a corresponding third prompt word based on the candidate sample, wherein the third prompt word is used to indicate the quality of generating the candidate sample and the rule based on which the corresponding sample optimization information is generated;
[0281] The second generating subunit is used to input the third prompt word into the target evaluation model to obtain the quality of the candidate samples output by the target evaluation model and the corresponding sample optimization information.
[0282] As a possible implementation of the embodiment of the present disclosure, the apparatus 700 for generating text training samples based on a large model further includes:
[0283] A second acquisition module is used to acquire a fourth prompt word corresponding to a target sample; wherein the target sample includes a sample prompt word corresponding to a sample query question and a corresponding sample reply, the sample prompt word is used to indicate a rule based on which a sample reply to the corresponding sample query question is generated, and the fourth prompt word is used to indicate a rule based on which a quality of the target sample and corresponding sample optimization information are generated;
[0284] A third generation module is used to input the fourth prompt word into the fourth model to obtain the quality of the target sample output by the fourth model and the corresponding sample optimization information;
[0285] A correction module, used to correct the quality of the target sample and the corresponding sample optimization information;
[0286] The training module is used to train the initial evaluation model by taking the fourth prompt word annotated with the quality of the corrected target sample and the corresponding sample optimization information as the second text training sample to obtain the target evaluation model.
[0287] As a possible implementation of the embodiment of the present disclosure, the optimization unit includes:
[0288] A concatenation subunit, used for concatenating the second prompt word with the sample optimization information to obtain an optimized prompt word;
[0289] The third generation subunit is used to input the optimization prompt word into the third model for generating a reply, so as to obtain an optimized reply;
[0290] The fourth generating subunit is used to generate an optimized candidate sample based on the second prompt word and the optimized reply.
[0291] As a possible implementation of the embodiment of the present disclosure, the apparatus 700 for generating text training samples based on a large model further includes:
[0292] The third acquisition module is used to acquire at least two query questions by using at least one of the following methods:
[0293] When the second largest model is online, historical query questions input into the second largest model are collected to obtain at least two query questions;
[0294] Obtain a network document, and divide the network document into at least two segments, and obtain at least two query questions based on the at least two segments;
[0295] Get at least two query questions input by humans.
[0296] It should be noted that the aforementioned explanation of the method for generating text training samples based on a large model is also applicable to the device for generating text training samples based on a large model in this embodiment, and will not be repeated here.
[0297] In order to implement the above embodiments, the present disclosure also provides a fine-tuning device for a large model.
[0298] Figure 8 It is a schematic diagram of the structure of a fine-tuning device for a large model provided according to an embodiment of the present disclosure.
[0299] like Figure 8 As shown, the fine-tuning device 800 of the large model includes:
[0300] A fourth acquisition module 801 is used to acquire a first text training sample, wherein the first text training sample is generated based on the method for generating a text training sample based on a large model in the above embodiment;
[0301] The fine-tuning module 802 is used to fine-tune the large model based on the first text training sample.
[0302] It should be noted that the aforementioned explanation of the fine-tuning method of the large model is also applicable to the fine-tuning device of the large model of this embodiment, and will not be repeated here.
[0303] In order to implement the above embodiments, the present disclosure also provides a question-answering device based on a large model.
[0304] Fig. 9 It is a structural diagram of a question-answering device based on a large model provided according to an embodiment of the present disclosure.
[0305] like Fig. 9 As shown, the large model-based question-answering device 900 includes:
[0306] A fifth acquisition module 901 is used to acquire a target query question;
[0307] The fourth generating module 902 is used to generate a prompt word corresponding to the target query question, wherein the prompt word is used to indicate a rule based on which a reply corresponding to the target query question is generated;
[0308] Processing module 903 is used to input the prompt word into the big model to obtain a reply corresponding to the prompt word output by the big model, wherein the big model is a big model fine-tuned using the first text training sample, and the first text training sample is generated based on the method for generating text training samples based on the big model in the above embodiment.
[0309] It should be noted that the aforementioned explanation of the large model-based question-answering method is also applicable to the large model-based question-answering device of this embodiment, and will not be repeated here.
[0310] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0311] Fig.10 A schematic block diagram of an example electronic device 1000 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0312] like Fig.10 As shown, the device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 1002 or a computer program loaded from a storage unit 1005 to a RAM (Random Access Memory) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An I / O (Input / Output) interface 1005 is also connected to the bus 1004.
[0313] A number of components in the device 1000 are connected to the I / O interface 1005, including: an input unit 1006, such as a keyboard, a mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1005, such as a disk, an optical disk, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the device 1000 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0314] The computing unit 1001 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Units), various dedicated AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, etc. The computing unit 1001 performs the various methods and processes described above, such as a method for generating a text training sample based on a large model or a fine-tuning method for a large model or a question-answering method based on a large model. For example, in some embodiments, a method for generating a text training sample based on a large model or a fine-tuning method for a large model or a question-answering method based on a large model may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 1005. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded into RAM 1003 and executed by the computing unit 1001, one or more steps of the method for generating text training samples based on a large model, the method for fine-tuning a large model, or the question-answering method based on a large model described above may be executed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute the method for generating text training samples based on a large model, the method for fine-tuning a large model, or the question-answering method based on a large model in any other appropriate manner (e.g., by means of firmware).
[0315] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application Specific Standard Products), SOCs (System On Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor that may be a dedicated or general-purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0316] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0317] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0318] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0319] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.
[0320] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0321] It should be noted that artificial intelligence is a discipline that studies how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.), and includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0322] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0323] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for generating text training samples based on a large model, comprising: Clustering at least two query questions to obtain at least two query question clusters; Obtaining a first query question from each of the query question clusters; Taking the first query question as an example, generating at least two second query questions under the set topic through the first large model; Based on the second query question, a first text training sample is generated for fine-tuning the second large model.
2. The method according to claim 1, wherein: The first query question is taken as an example, and at least two second query questions under the set topic are generated by the first large model, including: Based on the first query question and the relevant content of the set topic, a first prompt word is generated, wherein the first prompt word is used to indicate the example referenced by the query question to be generated and the topic to which it belongs; The first prompt word is input into the first large model to obtain the second query question.
3. The method according to claim 2, wherein: The generating of a first prompt word based on the first query question and the related content of the set topic includes: Acquire a prompt word template, wherein the prompt word template includes: a first text to be replaced corresponding to an example referenced by the query question to be generated, and a second text to be replaced corresponding to a topic to which the query question to be generated belongs; The first text to be replaced is replaced based on the first query question, and the second text to be replaced is replaced based on relevant content of the set theme to obtain the first prompt word.
4. The method according to claim 1, wherein: The step of generating a first text training sample for fine-tuning the second large model based on the second query question includes: Generating a second prompt word corresponding to the second query question, wherein the second prompt word is used to indicate a rule based on which a reply to the corresponding second query question is generated; Generate a response corresponding to the second prompt word through the third model; The first text training sample is generated based on the second prompt word and the reply.
5. The method according to claim 4, wherein: Each of the second prompt words corresponds to at least two of the responses; The generating a response corresponding to the second prompt word by the third model includes: The second prompt word is input into at least two different third largest models to obtain the responses respectively outputted by at least two different third largest models.
6. The method according to claim 4, wherein: Each of the second prompt words corresponds to at least two of the responses; The generating a response corresponding to the second prompt word by the third model includes: Generate responses corresponding to the second prompt word multiple times through the third model, and generate different responses each time; Among them, the reply generated for the Nth time is the output obtained by inputting the update prompt word into the third largest model, and the update prompt word is obtained by concatenating the second prompt word with the reply generated for the N-1th time, and N is an integer greater than or equal to 2.
7. The method according to claim 4, wherein: The step of generating the first text training sample based on the second prompt word and the reply includes: The second prompt word and the corresponding response are used as candidate samples; Acquire the quality of the candidate sample and the corresponding sample optimization information, wherein the quality is determined based on at least one of the relevance between the second prompt word and the corresponding reply and the quality of the reply itself; When the quality of the candidate sample does not meet the preset conditions, based on the corresponding sample optimization information, the response is optimized by generating the third largest model of the response to obtain the optimized candidate sample; Based on the optimized candidate samples, the first text training samples are generated.
8. The method according to claim 7, wherein: The obtaining the quality of the candidate samples and the corresponding sample optimization information includes: Based on the candidate sample, generate a corresponding third prompt word, wherein the third prompt word is used to indicate the quality of generating the candidate sample and the rule based on which the corresponding sample optimization information is generated; The third prompt word is input into the target evaluation model to obtain the quality of the candidate sample output by the target evaluation model and the corresponding sample optimization information.
9. The method according to claim 8, wherein: The method further comprises: Obtain a fourth prompt word corresponding to the target sample; wherein the target sample includes a sample prompt word corresponding to the sample query question and a corresponding sample reply, the sample prompt word is used to indicate a rule based on which a sample reply to the corresponding sample query question is generated, and the fourth prompt word is used to indicate a rule based on which the quality of the target sample and the corresponding sample optimization information are generated; Inputting the fourth prompt word into the fourth model to obtain the quality of the target sample output by the fourth model and corresponding sample optimization information; The quality of the target sample and the corresponding sample optimization information are corrected, and the fourth prompt word annotated with the corrected quality of the target sample and the corresponding sample optimization information is used as the second text training sample to train the initial evaluation model to obtain the target evaluation model.
10. The method according to claim 7, wherein: The step of optimizing the response based on the corresponding sample optimization information by generating the third largest model of the response to obtain the optimized candidate sample includes: splicing the second prompt word with the sample optimization information to obtain an optimized prompt word; Inputting the optimization prompt words into the third model for generating the response to obtain an optimized response; Based on the second prompt word and the optimized reply, the optimized candidate sample is generated.
11. The method according to any one of claims 1 to 10, wherein: The method further comprises: The at least two query questions are obtained by using at least one of the following methods: When the second largest model is online, historical query questions input into the second largest model are collected to obtain the at least two query questions; Acquire a network document, and divide the network document into at least two segments, and obtain the at least two query questions based on the at least two segments; The at least two query questions manually input are obtained.
12. A method for fine-tuning a large model, comprising: Acquire a first text training sample, wherein the first text training sample is generated based on the method of any one of claims 1-11; Based on the first text training sample, the large model is fine-tuned.
13. A question answering method based on a large model, comprising: Get the target query question; Generate a prompt word corresponding to the target query question, wherein the prompt word is used to indicate a rule based on which a reply corresponding to the target query question is generated; The prompt word is input into the big model to obtain a response corresponding to the prompt word output by the big model; wherein the big model is a big model fine-tuned using a first text training sample, and the first text training sample is generated based on the method described in any one of claims 1-11.
14. A device for generating text training samples based on a large model, comprising: A clustering module, used for clustering at least two query questions to obtain at least two query question clusters; A first acquisition module, configured to acquire a first query question from each query question cluster; A first generating module, configured to use the first query question as an example and generate at least two second query questions under a set topic through a first large model; The second generating module is used to generate a first text training sample for fine-tuning the second large model based on the second query question.
15. The device according to claim 14, wherein: The first generating module comprises: A first generating submodule, configured to generate a first prompt word based on the first query question and the related content of the set topic, wherein the first prompt word is used to indicate the example referenced by the query question to be generated and the topic to which it belongs; The processing submodule is used to input the first prompt word into the first large model to obtain the second query question.
16. The device according to claim 15, wherein: The first generation submodule includes: A first acquisition unit is used to acquire a prompt word template, wherein the prompt word template includes: a first text to be replaced corresponding to an example referenced by the query question to be generated, and a second text to be replaced corresponding to a topic to which the query question to be generated belongs; A replacement unit is used to replace the first text to be replaced based on the first query question, and replace the second text to be replaced based on the relevant content of the set theme to obtain the first prompt word.
17. The device according to claim 14, wherein: The second generating module comprises: A second generation submodule, configured to generate a second prompt word corresponding to the second query question, wherein the second prompt word is used to indicate a rule based on which a reply to the corresponding second query question is generated; A third generation submodule, used for generating a response corresponding to the second prompt word through a third model; The fourth generating submodule is used to generate the first text training sample based on the second prompt word and the reply.
18. The device according to claim 17, wherein: Each of the second prompt words corresponds to at least two of the responses; The third generation submodule comprises: The first generating unit is used to input the second prompt word into at least two different third models to obtain the responses respectively output by at least two different third models.
19. The device according to claim 17, wherein: Each of the second prompt words corresponds to at least two of the responses; The third generation submodule comprises: A second generating unit is used to generate responses corresponding to the second prompt word multiple times by using the third large model, wherein the responses generated each time are different; Among them, the reply generated for the Nth time is the output obtained by inputting the update prompt word into the third largest model, and the update prompt word is obtained by concatenating the second prompt word with the reply generated for the N-1th time, and N is an integer greater than or equal to 2.
20. The device according to claim 17, wherein: The fourth generation submodule comprises: a determination unit, configured to use the second prompt word and the corresponding reply as candidate samples; A second acquisition unit, configured to acquire the quality of the candidate sample and the corresponding sample optimization information, wherein the quality is determined based on at least one of a relevance between the second prompt word and the corresponding reply and a quality of the reply itself; An optimization unit, configured to optimize the response by generating the third largest model of the response based on the corresponding sample optimization information to obtain the optimized candidate sample when the quality of the candidate sample does not meet the preset condition; The third generating unit is used to generate the first text training sample based on the optimized candidate sample.
21. The device according to claim 20, wherein: The second acquisition unit includes: A first generating subunit is configured to generate a corresponding third prompt word based on the candidate sample, wherein the third prompt word is used to indicate the quality of generating the candidate sample and the rule based on which the corresponding sample optimization information is generated; The second generating subunit is used to input the third prompt word into the target evaluation model to obtain the quality of the candidate sample output by the target evaluation model and the corresponding sample optimization information.
22. The device according to claim 21, wherein The device also includes: A second acquisition module is used to acquire a fourth prompt word corresponding to a target sample; wherein the target sample includes a sample prompt word corresponding to a sample query question and a corresponding sample reply, the sample prompt word is used to indicate a rule based on which a sample reply to the corresponding sample query question is generated, and the fourth prompt word is used to indicate a rule based on which a quality of the target sample and corresponding sample optimization information are generated; A third generation module, used for inputting the fourth prompt word into a fourth large model to obtain the quality of the target sample output by the fourth large model and corresponding sample optimization information; A correction module, used to correct the quality of the target sample and the corresponding sample optimization information; The training module is used to train the initial evaluation model by using the fourth prompt word annotated with the corrected quality of the target sample and the corresponding sample optimization information as the second text training sample to obtain the target evaluation model.
23. The device according to claim 20, wherein: The optimization unit comprises: A concatenation subunit, configured to concatenate the second prompt word with the sample optimization information to obtain an optimized prompt word; A third generating subunit is used to input the optimization prompt word into the third large model for generating the reply, so as to obtain an optimized reply; The fourth generating subunit is used to generate the optimized candidate sample based on the second prompt word and the optimized reply.
24. The device according to any one of claims 14 to 23, wherein: The device also includes: The third acquisition module is configured to acquire the at least two query questions by adopting at least one of the following methods: When the second largest model is online, historical query questions input into the second largest model are collected to obtain the at least two query questions; Acquire a network document, and divide the network document into at least two segments, and obtain the at least two query questions based on the at least two segments; The at least two query questions manually input are obtained.
25. A fine-tuning device for a large model, comprising: A fourth acquisition module, configured to acquire a first text training sample, wherein the first text training sample is generated based on the method according to any one of claims 1 to 11; A fine-tuning module is used to fine-tune the large model based on the first text training sample.
26. A question-answering device based on a large model, comprising: The fifth acquisition module is used to obtain the target query question; A fourth generating module, configured to generate a prompt word corresponding to the target query question, wherein the prompt word is used to indicate a rule based on which a reply corresponding to the target query question is generated; A processing module is used to input the prompt word into a large model to obtain a response corresponding to the prompt word output by the large model, wherein the large model is a large model fine-tuned using a first text training sample, and the first text training sample is generated based on the method described in any one of claims 1-11.
27. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1-11, or execute the method of claim 12, or execute the method of claim 13.
28. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method of any one of claims 1 to 11, or the method of claim 12, or the method of claim 13.
29. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 11, or implements the method according to claim 12, or implements the method according to claim 13.
Citation Information
Patent Citations
Prompt word full life cycle management method and system, electronic equipment and storage medium
CN117494814A
Generation method and device of cue word information of large language model, equipment and medium
CN117539975A
Document question and answer training sample construction method and device based on large model
CN117709429A
Data construction method and device for fine tuning training of large language model
CN118035751A
Cited By
Large model-based science and technology text related cue word generation method and system
CN119357375A
Training sample generation method and device, model training method and device, model extraction method and device, medium and product
CN120763619A
Statement recommendation method and device and electronic equipment
CN121144440A
