Prompt word generation method and device based on large model
By generating a Q&A pair in the chat page and integrating prompt words, combined with fine-tuning of the large language model, the problems of high labor costs and data processing complexity in the existing technology are solved, and efficient and accurate prompt word generation and large language model are achieved. Improve the ability to answer questions and answer in specific areas.
Patent Information
- Application Number
- CN202411253022.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-27
AI Technical Summary
When facing specific scenarios, the existing technology requires professionals to collect Q&A data and produce prompt words, resulting in high labor and time costs. In addition, large language models require a large number of sample Q&A pairs during training, resulting in data processing complexity and efficiency. Low.
A method of prompt word generation based on big model is proposed. By generating a question-and-answer pair in the chat page and matching it with the preset prompt word template, combined with the pre-trained prompt word generation model, the final prompt word is integrated and generated. The large language model is fine-tuned using sample Q&A pairs and its parameters are adjusted to generate a prompt word generation model.
Automatically collecting Q&A data and generating prompt words is realized, reducing labor and time costs, improving the efficiency and accuracy of data processing, and fine-tuning of large language models makes its Q&A capabilities in specific fields more matched.
Smart Images

Figure CN119202168A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, specifically the field of deep learning, natural language processing and large language model technology, and can be used in application scenarios such as generative search, intelligent document editing, intelligent assistants, virtual assistants, and intelligent e-commerce. Background Art
[0002] A large language model is a deep learning model trained with a large amount of text data that can generate natural language text or understand the meaning of language text. Large language models can handle a variety of natural language tasks, such as text classification, question answering, and dialogue, and are an important path to artificial intelligence.
[0003] Currently, when faced with specific spy scenarios, professionals are needed to collect question and answer data and create prompt words, and then use these prompt words to train a large language model. Summary of the invention
[0004] The disclosed embodiments provide a method, apparatus, device, storage medium, and program product for generating prompt words based on a large model.
[0005] In a first aspect, an embodiment of the present disclosure proposes a prompt word generation method based on a large model, including: generating a question-answer pair based on question-answer data in a chat page; matching the question-answer pair with a prompt word template corresponding to the question in the question-answer pair to generate a first prompt word; inputting the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word, wherein the prompt word generation model is obtained by training a large language model using sample question-answer pairs as input and sample prompt words as output; integrating the first prompt word and the second prompt word to generate a prompt word.
[0006] In the second aspect, the embodiments of the present disclosure propose a method for training a prompt word generation model, including: inputting a sample question and answer pair into a large language model to obtain a predicted prompt word; calculating the loss based on the predicted prompt word and the sample prompt word corresponding to the sample question and answer pair; based on the loss, adjusting the parameters of the large language model to obtain a prompt word generation model.
[0007] On the third aspect, the embodiment of the present disclosure proposes a prompt word generation device based on a large model, including: a first generation module, configured to generate a question and answer pair based on the question and answer data in the chat page; a second generation module, configured to match the question and answer pair with the prompt word template corresponding to the question in the question and answer pair to generate a first prompt word; a third generation module, configured to input the question and answer pair into a pre-trained prompt word generation model to obtain a second prompt word, wherein the prompt word generation model is obtained by training a large language model with sample question and answer pairs as input and sample prompt words as output; a fourth generation module, configured to integrate the first prompt word and the second prompt word to generate a prompt word.
[0008] In a fourth aspect, an embodiment of the present disclosure proposes a prompt word generation model training device, comprising: an input module, configured to input a sample question and answer pair into a large language model to obtain a predicted prompt word; a calculation module, configured to calculate a loss based on the predicted prompt word and the sample prompt word corresponding to the sample question and answer pair; an adjustment module, configured to adjust the parameters of the large language model based on the loss to obtain a prompt word generation model.
[0009] In the fifth aspect, an embodiment of the present disclosure proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable 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 described in the first aspect or the second aspect.
[0010] In a sixth aspect, an embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to cause a computer to execute the method described in the first aspect or the second aspect.
[0011] In a seventh aspect, an embodiment of the present disclosure proposes a computer program product, including a computer program, which implements the method described in the first aspect or the second aspect when executed by a processor.
[0012] The key or important features of the embodiments of the present disclosure are not 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
[0013] Other features, purposes and advantages of the present disclosure will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings. The drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. Among them:
[0014] Figure 1 is a flow chart of an embodiment of a prompt word generation model training method according to the present disclosure;
[0015] Figure 2 is a flow chart of an embodiment of a method for generating prompt words based on a large model according to the present disclosure;
[0016] Figure 3 is a flow chart of another embodiment of a method for generating prompt words based on a large model according to the present disclosure;
[0017] Figure 4 It is a structural diagram of the dialogue system for generating prompt words;
[0018] Figure 5is a structural schematic diagram of an embodiment of a prompt word generation model training device according to the present disclosure;
[0019] Figure 6 is a structural schematic diagram of an embodiment of a prompt word generating device based on a large model according to the present disclosure;
[0020] Figure 7 It is a block diagram of an electronic device used to implement the method for generating prompt words based on a large model according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] 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, the description of well-known functions and structures is omitted in the following description.
[0022] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0023] Figure 1 A process 100 of an embodiment of a prompt word generation model training method according to the present disclosure is shown. The prompt word generation model training method comprises the following steps:
[0024] Step 101: Input the sample question-answer pair into the large language model to obtain the predicted prompt word.
[0025] In this embodiment, the execution subject of the prompt word generation model training method can obtain training samples, input sample question-answer pairs in the training samples into the large language model, and obtain predicted prompt words.
[0026] The execution subject of the prompt word generation model training method is usually a server. The server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0027] The training samples may include sample question-answer pairs and sample prompt words. In order to ensure the accuracy of the sample prompt words, the sample prompt words may be generated by professionals who collect question-answer data. Since the manpower and time costs of manually generating sample prompt words are high, the number of training samples is relatively small. The large language model can be pre-trained on a large amount of text data and can perform a wide range of tasks, including but not limited to question-answering, text summarization, translation, sentiment analysis, etc. Here, based on the large language model, a small amount of training samples are used to fine-tune it to obtain a prompt word generation model.
[0028] Step 102, calculating the loss based on the predicted prompt word and the sample prompt word corresponding to the sample question and answer pair.
[0029] In this embodiment, the execution entity may calculate the loss based on the predicted prompt word and the sample prompt word corresponding to the sample question and answer pair.
[0030] Here, a suitable loss function can be selected. The prediction prompt word and the sample prompt word are input into the loss function to calculate the loss. The loss can be used to characterize the difference between the prediction prompt word and the sample prompt word. The smaller the difference, the better the effect of the large language model; the larger the difference, the worse the effect of the large language model.
[0031] Step 103: Based on the loss, adjust the parameters of the large language model to obtain a prompt word generation model.
[0032] In this embodiment, the execution entity may adjust the parameters of the large language model based on the loss to obtain a prompt word generation model.
[0033] The parameters of the large language model can be continuously updated iteratively during the training process until the loss is small enough and the model converges, and then the prompt word generation model can be obtained. Usually, BP (Back Propagation) can be used for training, and the GD (Gradient Descent) algorithm can be used to update the parameters of the large language model.
[0034] The disclosed embodiment provides a prompt word generation model training method, which uses sample question-answer pairs and sample prompt words to fine-tune a pre-trained large language model, and can generate a prompt word generation model with a prompt word generation function.
[0035] Continue to refer Figure 2 , which shows a process 200 of an embodiment of a method for generating prompt words based on a large model according to the present disclosure. The method for generating prompt words based on a large model comprises the following steps:
[0036] Step 201, generating a question-answer pair based on the question-answer data in the chat page.
[0037] In this embodiment, the execution body of the prompt word generation method based on the large model can generate question and answer pairs based on the question and answer data in the chat page.
[0038] The execution subject of the prompt word generation method based on the large model is usually a server. The server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0039] An online chat room is usually called a chat room. It is a kind of online forum where users can chat online. Users in the same chat room can chat in real time by broadcasting messages. Chat rooms can be built on the basis of instant messaging software, and the means of conversation can include but are not limited to: text, voice, video, etc. Usually, chat rooms are based on rooms or channels, and users in the same room or channel can broadcast and read public messages in real time.
[0040] The chat room can obtain multiple preset questions, such as what is the weather like today, how do you express your anger, etc. In order to reduce the complexity of question and answer data processing, the number of users participating in the chat (such as 5 people) and the chat duration (such as 30 minutes) can be limited. After the user registers a username and password on the web page, he can log in to the chat room. The chat room can support 3v3 or 5v5 chat. After entering the chat room, the chat room can ask multiple questions and display them on the chat page. For each question, the user can choose to answer once, and the answer will be displayed on the chat page. In addition, users in the chat room can also ask and answer freely, and the question and answer data will be displayed on the chat page. For example, M questions are displayed on the chat page, and each question is answered by N users. The question and answer data obtained from the chat page may include M questions and the answers of N users corresponding to each question.
[0041] In some embodiments, the prompt word knowledge base can be used to store preset questions and corresponding prompt word templates. The chat room can obtain questions from the prompt word knowledge base and display them in the chat page. Users can answer questions based on the questions displayed in the chat page and display the answers in the chat page. Among them, the questions and answers displayed in the chat page are question and answer data.
[0042] In some embodiments, the questions in the M questions are paired with the corresponding answers of the N users one by one, and M×N first question-answer pairs can be generated. Among them, a first question-answer pair can include a question and an answer. By pairing questions and answers one by one, more question-answer pairs can be generated.
[0043] In some embodiments, the questions in the M questions are combined with the corresponding answers of the N users to generate M second question-answer pairs. Among them, a second question-answer pair may include a question and N answers. By integrating different answers to the same question, it is convenient to analyze the logic of different answers.
[0044] The first question-answer pair and the second question-answer pair can be used directly as question-answer pairs to perform subsequent steps, or they can be filtered to generate question-answer pairs. For example, the first question-answer pair is matched with the preset sensitive words in the preset sensitive word library, and the first question-answer pair that matches the preset sensitive words is filtered out, so that the remaining first question-answer pairs are more standardized. At the same time, logical judgment is performed on the different answers in the second question-answer pair, and the answers with logical contradictions in the second question-answer pair are filtered out, so that the remaining second question-answer pairs are more logically accurate. Subsequently, the intersection of the first question-answer pair and the second question-answer pair is taken to obtain a question-answer pair, thereby ensuring the standardization and logical accuracy of the question-answer pair.
[0045] Step 202: Match the question-answer pair with the prompt word template corresponding to the question in the question-answer pair to generate a first prompt word.
[0046] In this embodiment, the execution entity may match the question-answer pair with a prompt word template corresponding to the question in the question-answer pair to generate a first prompt word.
[0047] In some embodiments, the prompt word knowledge base can be used to store preset questions and corresponding prompt word templates. For example, the question is "Q: What is the temperature in XX city today?", and the corresponding prompt word template is "Please answer the question based on the following background information, especially the numbers in it, that is, the bold part. The following is the weather conditions on XX month XX day of XX year, with an average temperature of XX degrees". The chat room can obtain questions from the prompt word knowledge base and display them on the chat page. Users can answer questions based on the questions displayed on the chat page and display the answers on the chat page. Based on the questions and answers displayed on the chat page, question-answer pairs can be generated. The prompt word template corresponding to the question is obtained from the prompt word knowledge base, and the question-answer pair is matched with the prompt word template to generate a first prompt word.
[0048] In some embodiments, based on the field of the question, a prompt word template can be selected. The question-answer pair is matched with the prompt word template to generate a first prompt word. Wherein, the field may include but is not limited to: weather, emotions, finance, medical care, etc. The prompt word template may be designed and collected by personnel from different business teams. After the prompt word template is determined, it will not change for a long time. A field may correspond to one or more prompt word templates. Different fields may correspond to different prompt word templates. Therefore, after determining the field of the problem, a prompt word template can be selected from the prompt word template corresponding to the field of the problem. In the case where a field corresponds to a prompt word template, the prompt word template corresponding to the field of the problem can be directly selected. In the case where a field corresponds to multiple prompt word templates, the prompt word template can be selected from the multiple prompt word templates corresponding to the field of the problem according to a certain strategy. For example, the keyword set of the problem is matched with the multiple prompt word templates corresponding to the field of the problem, and the prompt word template matching the keyword set is selected. For another example, the question-answer pair and multiple prompt word templates corresponding to the field of the question are respectively input into the encoder to obtain the question-answer pair word vector and multiple prompt word template word vectors; the distance between the question-answer pair word vector and the multiple prompt word template word vectors is calculated, and the prompt word template with the closest distance is selected.
[0049] In some embodiments, the question-answer pair is matched with the prompt word template, and the value of the variable in the prompt word template can be determined from the question-answer pair; the variable in the prompt word template is replaced by the value of the variable to generate a prompt word. Taking the weather field as an example, the generated question-answer pair is "Q: What is the temperature in a certain city today? A: The temperature in a certain city today is 37 degrees." The main framework of the selected prompt word template is "Please answer the question based on the following background information, especially the numbers in it, that is, the bold part. The following is the weather conditions on xx / xx / xx, with an average temperature of xx degrees." After that, other information will be accessed according to the specific temperature conditions. Because the temperature is higher than 30 degrees, the following information is "In hot weather, you should pay attention to sun protection and heatstroke prevention, and avoid prolonged exposure to the sun." Finally, the generated prompt words are (taking today's date, September 4, 2024, as an example): "Please answer the questions based on the following background information, paying special attention to the numbers in bold. The following is the weather conditions on September 4, 2024. The average temperature is 37 degrees. It is hot weather, so you should pay attention to sun protection and heatstroke prevention, and avoid prolonged exposure to the sun."
[0050] Step 203: input the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word.
[0051] In this embodiment, the execution subject may input the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word. The prompt word generation model may be obtained by training a large language model using sample question-answer pairs as input and sample prompt words as output. The training process can be referred to Figure 1 The embodiments shown will not be described in detail here.
[0052] Step 204: Integrate the first prompt word and the second prompt word to generate a prompt word.
[0053] In this embodiment, the execution entity may integrate the first prompt word and the second prompt word to generate a prompt word.
[0054] The prompt word can be generated based on the first prompt word and the second prompt word. For example, the first prompt word and the second prompt word are directly used as prompt words. For another example, the first prompt word and the second prompt word are scored respectively based on a preset evaluation strategy, and the one with a higher score is used as the prompt word. For another example, the same parts of the first prompt word and the second prompt word are retained, and the different parts are combined to generate a prompt word.
[0055] The disclosed embodiment provides a method for generating prompt words based on a large model, which automatically collects question and answer data and generates prompt words, thereby reducing labor costs and time costs.
[0056] Further references Figure 3 , which shows a process 300 of another embodiment of a method for generating prompt words based on a large model according to the present disclosure. The method for generating prompt words based on a large model comprises the following steps:
[0057] Step 301, generating a question-answer pair based on the question-answer data in the chat page.
[0058] In this embodiment, the execution body of the prompt word generation method based on the large model can generate question and answer pairs based on the question and answer data in the chat page.
[0059] The execution subject of the prompt word generation method based on the large model is usually a server. The server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0060] An online chat room is usually called a chat room. It is a kind of online forum where users can chat online. Users in the same chat room can chat in real time by broadcasting messages. Chat rooms can be built on the basis of instant messaging software, and the means of conversation can include but are not limited to: text, voice, video, etc. Usually, chat rooms are based on rooms or channels, and users in the same room or channel can broadcast and read public messages in real time.
[0061] The chat room can obtain multiple preset questions, such as what is the weather like today, how do you express your anger, etc. In order to reduce the complexity of question and answer data processing, the number of users participating in the chat (such as 5 people) and the chat duration (such as 30 minutes) can be limited. After the user registers a username and password on the web page, he can log in to the chat room. The chat room can support 3v3 or 5v5 chat. After entering the chat room, the chat room can ask multiple questions and display them on the chat page. For each question, the user can choose to answer once, and the answer will be displayed on the chat page. In addition, users in the chat room can also ask and answer freely, and the question and answer data will be displayed on the chat page. For example, M questions are displayed on the chat page, and each question is answered by N users. The question and answer data obtained from the chat page may include M questions and the answers of N users corresponding to each question.
[0062] In some embodiments, the prompt word knowledge base can be used to store preset questions and corresponding prompt word templates. The chat room can obtain questions from the prompt word knowledge base and display them in the chat page. Users can answer questions based on the questions displayed in the chat page and display the answers in the chat page. Among them, the questions and answers displayed in the chat page are question and answer data.
[0063] In some embodiments, the questions in the M questions are paired with the corresponding answers of the N users one by one, and M×N first question-answer pairs can be generated. Among them, a first question-answer pair can include a question and an answer. By pairing questions and answers one by one, more question-answer pairs can be generated.
[0064] In some embodiments, the questions in the M questions are combined with the corresponding answers of the N users to generate M second question-answer pairs. Among them, a second question-answer pair may include a question and N answers. By integrating different answers to the same question, it is convenient to analyze the logic of different answers.
[0065] The first question-answer pair and the second question-answer pair can be used directly as question-answer pairs to perform subsequent steps, or they can be filtered to generate question-answer pairs. For example, the first question-answer pair is matched with the preset sensitive words in the preset sensitive word library, and the first question-answer pair that matches the preset sensitive words is filtered out, so that the remaining first question-answer pairs are more standardized. At the same time, logical judgment is performed on the different answers in the second question-answer pair, and the answers with logical contradictions in the second question-answer pair are filtered out, so that the remaining second question-answer pairs are more logically accurate. Subsequently, the intersection of the first question-answer pair and the second question-answer pair is taken to obtain a question-answer pair, thereby ensuring the standardization and logical accuracy of the question-answer pair.
[0066] Step 302: Match the question-answer pair with the prompt word template corresponding to the question in the question-answer pair to generate a first prompt word.
[0067] In this embodiment, the execution entity may match the question-answer pair with a prompt word template corresponding to the question in the question-answer pair to generate a first prompt word.
[0068] In some embodiments, the prompt word knowledge base can be used to store preset questions and corresponding prompt word templates. For example, the question is "Q: What is the temperature in XX city today?", and the corresponding prompt word template is "Please answer the question based on the following background information, especially the numbers in it, that is, the bold part. The following is the weather conditions on XX month XX day of XX year, with an average temperature of XX degrees". The chat room can obtain questions from the prompt word knowledge base and display them on the chat page. Users can answer questions based on the questions displayed on the chat page and display the answers on the chat page. Based on the questions and answers displayed on the chat page, question-answer pairs can be generated. The prompt word template corresponding to the question is obtained from the prompt word knowledge base, and the question-answer pair is matched with the prompt word template to generate a first prompt word.
[0069] In some embodiments, based on the field of the question, a prompt word template can be selected. The question-answer pair is matched with the prompt word template to generate a first prompt word. Wherein, the field may include but is not limited to: weather, emotions, finance, medical care, etc. The prompt word template may be designed and collected by personnel from different business teams. After the prompt word template is determined, it will not change for a long time. A field may correspond to one or more prompt word templates. Different fields may correspond to different prompt word templates. Therefore, after determining the field of the problem, a prompt word template can be selected from the prompt word template corresponding to the field of the problem. In the case where a field corresponds to a prompt word template, the prompt word template corresponding to the field of the problem can be directly selected. In the case where a field corresponds to multiple prompt word templates, the prompt word template can be selected from the multiple prompt word templates corresponding to the field of the problem according to a certain strategy. For example, the keyword set of the problem is matched with the multiple prompt word templates corresponding to the field of the problem, and the prompt word template matching the keyword set is selected. For another example, the question-answer pair and multiple prompt word templates corresponding to the field of the question are respectively input into the encoder to obtain the question-answer pair word vector and multiple prompt word template word vectors; the distance between the question-answer pair word vector and the multiple prompt word template word vectors is calculated, and the prompt word template with the closest distance is selected.
[0070] In some embodiments, the question-answer pair is matched with the prompt word template, and the value of the variable in the prompt word template can be determined from the question-answer pair; the variable in the prompt word template is replaced by the value of the variable to generate a prompt word. Taking the weather field as an example, the generated question-answer pair is "Q: What is the temperature in a certain city today? A: The temperature in a certain city today is 37 degrees." The main framework of the selected prompt word template is "Please answer the question based on the following background information, especially the numbers in it, that is, the bold part. The following is the weather conditions on xx / xx / xx, with an average temperature of xx degrees." After that, other information will be accessed according to the specific temperature conditions. Because the temperature is higher than 30 degrees, the following information is "In hot weather, you should pay attention to sun protection and heatstroke prevention, and avoid prolonged exposure to the sun." Finally, the generated prompt words are (taking today's date, September 4, 2024, as an example): "Please answer the questions based on the following background information, paying special attention to the numbers in bold. The following is the weather conditions on September 4, 2024. The average temperature is 37 degrees. It is hot weather, so you should pay attention to sun protection and heatstroke prevention, and avoid prolonged exposure to the sun."
[0071] Step 303: input the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word.
[0072] In this embodiment, the execution subject may input the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word. The prompt word generation model may be obtained by training a large language model using sample question-answer pairs as input and sample prompt words as output. The training process can be referred to Figure 1 The embodiments shown will not be described in detail here.
[0073] Step 304: Integrate the first prompt word and the second prompt word to generate a prompt word.
[0074] In this embodiment, the execution entity may integrate the first prompt word and the second prompt word to generate a prompt word.
[0075] The prompt word can be generated based on the first prompt word and the second prompt word. For example, the first prompt word and the second prompt word are directly used as prompt words. For another example, the first prompt word and the second prompt word are scored respectively based on a preset evaluation strategy, and the one with a higher score is used as the prompt word. For another example, the same parts of the first prompt word and the second prompt word are retained, and the different parts are combined to generate a prompt word.
[0076] Step 305 , taking the question in the question-answer pair corresponding to the prompt word belonging to the target domain as input, taking the prompt word as the expected output, and training to obtain a question-answer model corresponding to the target domain.
[0077] In this embodiment, the execution subject can use the question in the question-answer pair corresponding to the prompt word belonging to the target domain as input, and the prompt word as the expected output, and fine-tune the pre-trained large language model to obtain the question-answer model corresponding to the target domain. Among them, the large language model can be pre-trained on a large amount of text data, and can perform a wide range of tasks, including but not limited to question-answering, text summarization, translation, sentiment analysis, etc. Here, the large language model is fine-tuned using the prompt words belonging to the target domain to obtain the question-answer model corresponding to the target domain, so that the answer output by the question-answer model is more matched with the corresponding domain.
[0078] The disclosed embodiment provides a method for generating prompt words based on a large model, which automatically collects question and answer data and generates prompt words, reducing labor costs and time costs. In addition, the large language model is fine-tuned using prompt words belonging to the target field to obtain a question and answer model corresponding to the target field, so that the answer output by the question and answer model is more matched with the corresponding field.
[0079] Further references Figure 4, which shows a structural diagram of a dialogue system 400 for generating prompt words. The dialogue system 400 may include a dialogue system page 401, a dialogue system background 402, a prompt word knowledge base 403, a prompt word generation model 404 and a database 405. Among them, the dialogue system page 401 is mainly used for dialogue display with the user. When the user clicks on the dialogue system page 401 to dialogue with the dialogue system 400, the dialogue system background 402 can obtain the questions preset in the prompt word knowledge base 403 and return them to the user. After the user answers, the corresponding prompt words can be generated based on the questions and answers. There are mainly two ways to generate prompt words. First, the prompt word knowledge base 403 stores preset questions and corresponding prompt word templates. Match the question-answer pair with the prompt word template corresponding to its question, and replace the variables in the prompt word template with the values of the variables in the answer in the question-answer pair to generate prompt words. Second, input the question-answer pair into the prompt word generation model 404, and output the prompt words. Finally, the prompt words generated by the two methods are integrated, stored in the database 405, and returned to the user.
[0080] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a prompt word generation model training device, and the device embodiment is Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0081] like Figure 5 As shown, the prompt word generation model training device 500 of this embodiment may include: an input module 501, a calculation module 502 and an adjustment module 503. Among them, the input module 501 is configured to input the sample question-answer pair into the large language model to obtain the predicted prompt word; the calculation module 502 is configured to calculate the loss based on the predicted prompt word and the sample prompt word corresponding to the sample question-answer pair; the adjustment module 503 is configured to adjust the parameters of the large language model based on the loss to obtain the prompt word generation model.
[0082] In this embodiment, in the prompt word generation model training device 500, the specific processing of the input module 501, the calculation module 502 and the adjustment module 503 and the technical effects thereof can be referred to respectively. Figure 1 The relevant descriptions of steps 101 - 103 in the corresponding embodiment are not repeated here.
[0083] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a prompt word generation device based on a large model. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0084] like Figure 6 As shown, the prompt word generation device 600 based on the large model of this embodiment may include: a first generation module 601, a second generation module 602, a third generation module 603 and a fourth generation module 604. The first generation module 601 is configured to generate a question-answer pair based on the question-answer data in the chat page; the second generation module 602 is configured to match the question-answer pair with the prompt word template corresponding to the question in the question-answer pair to generate a first prompt word; the third generation module 603 is configured to input the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word, wherein the prompt word generation model is obtained by training the large language model using the sample question-answer pair as input and the sample prompt word as output; the fourth generation module 604 is configured to integrate the first prompt word and the second prompt word to generate a prompt word.
[0085] In this embodiment, in the large model-based prompt word generation device 600, the specific processing of the first generation module 601, the second generation module 602, the third generation module 603 and the fourth generation module 604 and the technical effects thereof can be referred to in Figure 2 The relevant descriptions of steps 201 - 204 in the corresponding embodiment are not repeated here.
[0086] In some optional implementations of this embodiment, the question and answer data includes M questions and answers from N users corresponding to each question; and the first generation module 601 includes: a first generation submodule, configured to pair the questions in the M questions with the corresponding answers from the N users one by one, to generate M×N first question and answer pairs.
[0087] In some optional implementations of this embodiment, the first generation module 601 also includes: a first filtering submodule, configured to match the first question and answer pair with preset sensitive words in a preset sensitive word library, and filter out the first question and answer pair that matches the preset sensitive words.
[0088] In some optional implementations of this embodiment, the question and answer data includes M questions and answers from N users corresponding to each question; and the first generation module 601 includes: a second generation submodule, configured to combine the questions in the M questions with the corresponding answers from the N users to generate M second question and answer pairs.
[0089] In some optional implementations of this embodiment, the first generation module 601 also includes: a second filtering submodule, which is configured to perform logical judgment on different answers in the second question and answer pair, and filter out answers with logical contradictions in the second question and answer pair.
[0090] In some optional implementations of this embodiment, the first generation module 601 also includes: an intersection submodule, configured to take the intersection of the first question-answer pair and the second question-answer pair to obtain a question-answer pair.
[0091] In some optional implementations of this embodiment, the large model-based prompt word generation device 600 also includes: a first acquisition module, configured to obtain questions from a prompt word knowledge base and display them in a chat page, wherein the prompt word knowledge base is used to store preset questions and corresponding prompt word templates; a second acquisition module, configured to obtain the user's answers to the questions displayed in the chat page; a fifth generation module, configured to generate question and answer data based on the questions and answers; and the second generation module 602 is further configured to: obtain the prompt word template corresponding to the question from the prompt word knowledge base; match the question and answer pair with the prompt word template to generate a first prompt word.
[0092] In some optional implementations of this embodiment, the second generation module 602 is further configured to: match the question-answer pair with the prompt word template, determine the value of the variable in the prompt word template from the question-answer pair; replace the variable in the prompt word template with the value of the variable to generate a first prompt word.
[0093] In some optional implementations of this embodiment, the large model-based prompt word generation device 600 also includes: a training module, which is configured to take the question in the question-answer pair corresponding to the prompt word belonging to the target field as input, and the prompt word as the expected output, to train and obtain a question-answer model corresponding to the target field.
[0094] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0095] 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.
[0096] Figure 7 A schematic block diagram of an example electronic device 700 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.
[0097] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0098] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0099] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as the prompt word generation method based on the large model. For example, in some embodiments, the prompt word generation method based on the large model may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the prompt word generation method based on the large model described above may be executed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the large model-based prompt word generation method in any other appropriate manner (for example, by means of firmware).
[0100] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can 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.
[0101] 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.
[0102] 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 equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0103] 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).
[0104] The systems and techniques described herein may be implemented in a computing system that includes back-end 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 front-end 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 back-end components, middleware components, or front-end 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: a local area network (LAN), a wide area network (WAN), and the Internet.
[0105] A computer system may include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises through computer programs running on respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server combined with a blockchain.
[0106] 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 provided by this disclosure can be achieved, and this document does not limit this.
[0107] 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 prompt words based on a large model, comprising: Generate question-answer pairs based on the question-answer data in the chat page; Matching the question-answer pair with a prompt word template corresponding to the question in the question-answer pair to generate a first prompt word; Inputting the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word, wherein the prompt word generation model is obtained by training a large language model using sample question-answer pairs as input and sample prompt words as output; The first prompt word and the second prompt word are integrated to generate a prompt word.
2. The method according to claim 1, wherein: The question-and-answer data includes M questions and N users' answers corresponding to each question; as well as The step of generating a question-answer pair based on the question-answer data in the chat page includes: The M questions are paired with the corresponding answers of the N users one by one to generate M×N first question-answer pairs.
3. The method according to claim 2, wherein: The generating of question-answer pairs based on the question-answer data in the chat page further includes: The first question-answer pair is matched with a preset sensitive word in a preset sensitive word library, and the first question-answer pair matching the preset sensitive word is filtered out.
4. The method according to claim 3, wherein: The question-and-answer data includes M questions and N users' answers corresponding to each question; as well as The step of generating a question-answer pair based on the question-answer data in the chat page includes: The questions in the M questions are combined with the corresponding answers of the N users to generate M second question-answer pairs.
5. The method according to claim 4, wherein: The generating of question-answer pairs based on the question-answer data in the chat page further includes: Perform logical judgment on different answers in the second question-answer pair, and filter out answers in the second question-answer pair that have logical contradictions.
6. The method according to claim 5, wherein: The generating of question-answer pairs based on the question-answer data in the chat page further includes: An intersection is taken for the first question-answer pair and the second question-answer pair to obtain the question-answer pair.
7. The method according to claim 1, wherein: The method further comprises: Obtaining questions from a prompt word knowledge base and displaying them on the chat page, wherein the prompt word knowledge base is used to store preset questions and corresponding prompt word templates; Obtaining the user's answer based on the question displayed in the chat page; Based on the question and the answer, generate the question-answer data; and The step of matching the question-answer pair with a prompt word template corresponding to the question in the question-answer pair to generate a first prompt word includes: Acquire a prompt word template corresponding to the question from the prompt word knowledge base; The question-answer pair is matched with the prompt word template to generate the first prompt word.
8. The method according to any one of claims 1 to 7, wherein: The step of matching the question-answer pair with a prompt word template corresponding to the question in the question-answer pair to generate a first prompt word includes: Matching the question-answer pair with the prompt word template, and determining the value of the variable in the prompt word template from the question-answer pair; The variable in the prompt word template is replaced by the value of the variable to generate the first prompt word.
9. The method according to any one of claims 1 to 7, wherein: The method further comprises: The question in the question-answer pair corresponding to the prompt word belonging to the target domain is taken as input, and the prompt word is taken as the expected output, and a question-answer model corresponding to the target domain is obtained through training.
10. A method for training a prompt word generation model, comprising: Input the sample question-answer pair into the large language model to obtain the predicted prompt word; Calculating a loss based on the predicted prompt word and the sample prompt word corresponding to the sample question-answer pair; Based on the loss, the parameters of the large language model are adjusted to obtain a prompt word generation model.
11. A prompt word generation device based on a large model, comprising: A first generating module is configured to generate a question-answer pair based on the question-answer data in the chat page; A second generating module is configured to match the question-answer pair with a prompt word template corresponding to the question in the question-answer pair to generate a first prompt word; a third generation module, configured to input the question-answer pair into a pre-trained prompt word generation model to obtain a second prompt word, wherein the prompt word generation model is obtained by training a large language model using a sample question-answer pair as input and a sample prompt word as output; The fourth generating module is configured to integrate the first prompt word and the second prompt word to generate a prompt word.
12. The device according to claim 11, wherein The question-and-answer data includes M questions and N users' answers corresponding to each question; as well as The first generation module comprises: The first generation submodule is configured to pair the questions in the M questions with the corresponding answers of the N users one by one to generate M×N first question-answer pairs.
13. The device according to claim 12, wherein: The first generation module also includes: The first filtering submodule is configured to match the first question-answer pair with a preset sensitive word in a preset sensitive word library, and filter out the first question-answer pair that matches the preset sensitive word.
14. The device according to claim 13, wherein: The question-and-answer data includes M questions and N users' answers corresponding to each question; as well as The first generation module comprises: The second generation submodule is configured to combine the questions in the M questions with the corresponding answers of the N users to generate M second question-answer pairs.
15. The device according to claim 14, wherein: The first generation module also includes: The second filtering submodule is configured to perform logical judgment on different answers in the second question-answer pair, and filter out answers in the second question-answer pair that have logical contradictions.
16. The device according to claim 15, wherein: The first generation module also includes: The intersection submodule is configured to take the intersection of the first question-answer pair and the second question-answer pair to obtain the question-answer pair.
17. The device according to claim 11, wherein: The device also includes: A first acquisition module is configured to acquire questions from a prompt word knowledge base and display the questions on the chat page, wherein the prompt word knowledge base is used to store preset questions and corresponding prompt word templates; A second acquisition module is configured to acquire the user's answer based on the question displayed in the chat page; a fifth generating module configured to generate the question-answer data based on the question and the answer; and The second generation module is further configured to: Acquire a prompt word template corresponding to the question from the prompt word knowledge base; The question-answer pair is matched with the prompt word template to generate the first prompt word.
18. The device according to any one of claims 11 to 17, wherein: The second generation module is further configured to: Matching the question-answer pair with the prompt word template, and determining the value of the variable in the prompt word template from the question-answer pair; The variable in the prompt word template is replaced by the value of the variable to generate the first prompt word.
19. The device according to any one of claims 11 to 17, wherein: The device also includes: The training module is configured to take the question in the question-answer pair corresponding to the prompt word belonging to the target domain as input, take the prompt word as the expected output, and train to obtain the question-answer model corresponding to the target domain.
20. A prompt word generation model training device, comprising: An input module, configured to input the sample question-answer pair into the large language model to obtain a predicted prompt word; A calculation module, configured to calculate a loss based on the predicted prompt word and the sample prompt word corresponding to the sample question-answer pair; The adjustment module is configured to adjust the parameters of the large language model based on the loss to obtain a prompt word generation model.
21. 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 perform the method according to any one of claims 1 to 10.
22. A non-transitory computer-readable storage medium storing computer instructions, the computer instructions being used to cause the computer to execute the method of any one of claims 1-10.
23. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Model pre-training method and device, equipment, storage medium and program product
CN113962315A
Question and answer pair generation method and device, computer equipment and storage medium
CN115481223A
Generation method and device of cue word information of large language model, equipment and medium
CN117539975A
Prompt word determination method and device, electronic equipment and readable storage medium
CN117875303A
Method and device for processing cue word
CN117973374A
Cited By
Intelligent question answering method and device based on emotional tendency and storage medium
CN120030134A
Intelligent cue word generation evaluation method and system based on multi-component collaboration
CN121092653A
