Model cue word optimization method and device
Through the intelligent model interacting with users, extracting and analyzing interactive data, and optimizing initial prompt words, the problem of high cost of optimizing prompt words in the existing technology is solved, and the intelligent level of interaction between the model and the user is improved.
Patent Information
- Application Number
- CN202411495866.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-28
AI Technical Summary
In the prior art, the cost of optimizing prompt words is high, and it is difficult to automatically optimize prompt words to improve the intelligent level of model interaction with users.
By obtaining the initial prompt words, using the intelligent model to interact with the user, extract the summary information of the interactive data and conduct fine-grained sentiment analysis, and optimize the prompt words based on the analysis results until the optimal optimization effect is achieved.
The cost of optimizing prompt words is reduced, the intelligent level of interaction between the model and the user is improved, and more efficient prompt words are optimized.
Smart Images

Figure CN119537580A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of machine learning, and in particular to a method and device for optimizing model prompt words. Background Art
[0002] The level of interaction between the intelligent model and the user depends largely on the quality of the prompt words. Designing effective prompt words requires deep professional knowledge and rich practical experience. How to automatically optimize the prompt words to drive the model to interact more intelligently with the user is currently a technical itch. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a model prompt word optimization method, device, electronic device and computer-readable storage medium to solve the problem of high cost of optimizing prompt words in the prior art.
[0004] According to a first aspect of an embodiment of the present application, a model prompt word optimization method is provided, including: obtaining an initial prompt word, using an intelligent model to interact with a user based on the initial prompt word, and obtaining first interaction data; extracting summary information in the first interaction data, performing fine-grained sentiment analysis on the interaction data, and obtaining analysis results of the first interaction data; optimizing the initial prompt word based on the summary information and analysis results of the first interaction data to obtain a target prompt word; using an intelligent model to interact with the user based on the target prompt word to obtain second interaction data; and determining whether to further optimize the target prompt word based on the second interaction data.
[0005] According to a second aspect of an embodiment of the present application, a model prompt word optimization device is provided, including: a first interaction module, configured to obtain an initial prompt word, and use an intelligent model to interact with a user based on the initial prompt word to obtain first interaction data; an extraction and analysis module, configured to extract summary information in the first interaction data, perform fine-grained sentiment analysis on the interaction data, and obtain analysis results of the first interaction data; an optimization module, configured to optimize the initial prompt word based on the summary information and analysis results of the first interaction data to obtain a target prompt word; a second interaction module, configured to use an intelligent model to interact with a user based on the target prompt word to obtain second interaction data; and a judgment module, configured to determine whether to further optimize the target prompt word based on the second interaction data.
[0006] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0007] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0008] Compared with the prior art, the embodiments of the present application have the following beneficial effects: obtaining the initial prompt word, using the intelligent model to interact with the user based on the initial prompt word, and obtaining the first interaction data; extracting the summary information in the first interaction data, performing fine-grained sentiment analysis on the interaction data, and obtaining the analysis results of the first interaction data; optimizing the initial prompt word based on the summary information and analysis results of the first interaction data, and obtaining the target prompt word; using the intelligent model to interact with the user based on the target prompt word, and obtaining the second interaction data; determining whether to further optimize the target prompt word based on the second interaction data. The above technical means can solve the problem of high cost of optimizing prompt words in the prior art, thereby reducing the cost of optimizing prompt words and improving the intelligence level of the interaction between the model and the user. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0010] Figure 1 It is a flow chart of a model prompt word optimization method provided in an embodiment of the present application;
[0011] Figure 2 It is a flowchart of another model prompt word optimization method provided in an embodiment of the present application;
[0012] Figure 3 It is a structural schematic diagram of a model prompt word optimization device provided in an embodiment of the present application;
[0013] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0014] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0015] A model prompt word optimization method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0016] Figure 1 It is a flow chart of a model prompt word optimization method provided in an embodiment of the present application. Figure 1 The model prompt word optimization method can be executed by a computer or a server, or software on a computer or a server. Figure 1 As shown, the model prompt word optimization method includes:
[0017] S101, obtaining an initial prompt word, and using an intelligent model to interact with a user based on the initial prompt word to obtain first interaction data;
[0018] S102, extracting summary information from the first interaction data, performing fine-grained sentiment analysis on the interaction data, and obtaining an analysis result of the first interaction data;
[0019] S103, optimizing the initial prompt word based on the summary information and analysis result of the first interaction data to obtain a target prompt word;
[0020] S104, using the intelligent model to interact with the user based on the target prompt word to obtain second interaction data;
[0021] S105: Determine whether to further optimize the target prompt word based on the second interaction data.
[0022] The intelligent model is a large language model (LLMs) used to interact with users. A separate large language model can be used to extract summary information from the first interaction data and perform fine-grained sentiment analysis on the interaction data. Natural language processing can also be used to extract summary information from the first interaction data and perform fine-grained sentiment analysis on the interaction data. A separate large language model can be used to extract the summary information based on the first interaction data and the analysis results to optimize the initial prompt words. The intelligent model is used to interact with the user based on the target prompt words, and it is determined whether to further optimize the target prompt words based on the second interaction data.
[0023] According to the technical solution provided by the embodiment of the present application, the initial prompt word is obtained, and the intelligent model is used to interact with the user based on the initial prompt word to obtain the first interaction data; the summary information in the first interaction data is extracted, and the interaction data is subjected to fine-grained sentiment analysis to obtain the analysis result of the first interaction data; the initial prompt word is optimized based on the summary information and analysis result of the first interaction data to obtain the target prompt word; the intelligent model is used to interact with the user based on the target prompt word to obtain the second interaction data; and it is determined whether to further optimize the target prompt word based on the second interaction data. The above technical means can solve the problem of high cost of optimizing prompt words in the prior art, thereby reducing the cost of optimizing prompt words and improving the intelligence level of the interaction between the model and the user.
[0024] Furthermore, based on the summary information and analysis results of the first interaction data, the initial prompt word is optimized to obtain a target prompt word, including: the first interaction data includes an initial prompt word and a user reply sentence, and the summary information of the first interaction data includes a first summary of the initial prompt word and a second summary of the user reply sentence; the first summary and the second summary are compared to obtain a first content that is missing and a second content that is redundant in the first summary compared to the second summary; the first content is added to the initial prompt word and the second content is deleted, and based on the analysis results of the first interaction data, the word order of the initial prompt word is adjusted and the expression of the initial prompt word is polished to obtain the target prompt word.
[0025] The interaction between the intelligent model and the user can be regarded as the intelligent model outputting the initial prompt word on the interactive interface, and the user inputting the user reply sentence. After multiple rounds of interaction between the intelligent model and the user, the first interaction data is obtained. The summary information of the first interaction data is extracted, which can be divided into the first summary of the initial prompt word and the second summary of the user reply sentence. By comparing the first summary and the second summary, the missing content (recorded as the first content) and the redundant content (recorded as the second content) of the first summary compared to the second summary are obtained. Because the intelligent model actually replies to the user based on the user's questions on the current interactive interface or the historical interaction data between the intelligent model and the user, in fact, the initial prompt word output by the intelligent model and the user's user reply sentence are often inconsistent. In the case where the initial prompt word and the user reply sentence do not correspond, it can be assumed that the first content is not mentioned by the user due to negligence and the second content is redundant, so the first content is added to the initial prompt word and the second content is deleted.
[0026] The analysis result of the first interaction data is the user's emotional tendency towards each word in the user's reply sentence, including satisfaction, neutrality, dissatisfaction, etc., or importance, neutrality, indifference, etc. The user's reply sentence corresponds to the initial prompt word after adding the first content and deleting the second content in terms of content, so based on the analysis result of the first interaction data, the word order of the initial prompt word and the expression of the initial prompt word are polished to highlight the words that the user is satisfied with or values (the more the user values the word, the higher it is in the initial prompt word, and the more the user values the word, the greater the degree of polishing in the initial prompt word). Polishing refers to adding or replacing modifiers, etc.
[0027] For example, a user opens the travel planning agent in the intelligent model. The initial prompt is: "Hello! I am your travel planning assistant. Please tell me your destination, travel date and preferences, and I will make a perfect travel plan for you." The user replies: "I plan to travel to Paris for a week on October 1st, with a budget of about $3,000, and hope to visit more cultural attractions." In the historical interaction data between the intelligent model and the user, users often ask for detailed information about accommodation, but this is not mentioned in the initial prompt. The target prompt is: "Hello! I am your travel planning assistant. You plan to travel to Paris for a week on October 1st, with a budget of $3,000. In order to meet your preference for visiting cultural attractions, I will recommend some hotel options for you. Do you have any special requirements for accommodation?"
[0028] Furthermore, determining whether to further optimize the target prompt word based on the second interaction data includes: extracting summary information in the second interaction data, performing fine-grained sentiment analysis on the interaction data, and obtaining analysis results of the second interaction data; and determining whether to further optimize the target prompt word based on the summary information and analysis results of the second interaction data.
[0029] Furthermore, based on the summary information and analysis results of the second interaction data, determining whether to further optimize the target prompt word includes: the second interaction data includes the target prompt word and the user reply sentence, and the summary information of the second interaction data includes a first summary of the target prompt word and a second summary of the user reply sentence; comparing the first summary with the second summary, and judging whether there is missing content and redundant content in the first summary compared with the second summary; when there is no missing content and redundant content in the first summary compared with the second summary, and there is no content that the user is not satisfied with in the analysis results of the second interaction data, taking the target prompt word as the prompt word finally optimized; otherwise, further optimizing the target prompt word based on the summary information and analysis results of the second interaction data.
[0030] Furthermore, the target prompt words are further optimized based on the summary information and analysis results of the second interaction data, including: adding the missing content of the first summary compared to the second summary to the target prompt words, and filtering out the redundant content of the first summary compared to the second summary; adjusting the word order of the target prompt words and polishing the expression of the target prompt words based on the analysis results of the second interaction data.
[0031] Further optimizing the target prompt words based on the summary information and analysis results of the second interaction data is similar to optimizing the initial prompt words based on the summary information and analysis results of the first interaction data, and will not be described in detail here.
[0032] Furthermore, after using the intelligent model to interact with the user based on the target prompt word to obtain the second interaction data, the method also includes: executing the following loop: determining whether the target prompt word needs to be further optimized based on the second interaction data; when the target prompt word does not need to be further optimized, exiting the loop; when the target prompt word needs to be further optimized, optimizing the target prompt word based on the second interaction data; using the intelligent model to interact with the user based on the optimized target prompt word to obtain updated second interaction data.
[0033] When there is no need to further optimize the target prompt word, the loop is exited and the target prompt word is used as the final optimized prompt word. Optimizing the target prompt word based on the second interaction data is to further optimize the target prompt word based on the summary information and analysis results of the second interaction data. The intelligent model outputs the optimized target prompt word on the interactive interface, and the user inputs the user reply sentence. After multiple rounds of interaction between the intelligent model and the user, the updated second interaction data is obtained.
[0034] Figure 2 is a flow chart of another model prompt word optimization method provided in an embodiment of the present application, such as Figure 2 As shown:
[0035] Execute the following loop:
[0036] S201, calculating the loss between the user reply sentence and the expected reply sentence in the first interaction data;
[0037] S202, calculating the gradient of the mask mark in the initial prompt word based on the loss;
[0038] S203, optimizing the initial prompt word using a gradient descent algorithm according to the gradient of the mask mark;
[0039] S204, using the intelligent model to interact with the user based on the optimized initial prompt word, obtaining updated first interaction data, and performing the next round of optimization until the initial prompt word converges to a minimum loss, and then exiting the loop.
[0040] The mask mark is [MASK]. Some positions in the initial prompt word are mask marks. These mask marks are adjustable words in the initial prompt word. According to the gradient of the mask mark, the gradient descent algorithm is used to optimize the words on the mask mark in the initial prompt word (equivalent to using the mask mark in the initial prompt word as an adjustable parameter).
[0041] The above loop can be regarded as multiple rounds of optimization of the initial prompt word: calculate the loss between the user's reply sentence and the expected reply sentence in the current round; calculate the gradient of the mask mark in the initial prompt word based on the loss in the current round; use the gradient descent algorithm to optimize the initial prompt word according to the gradient of the mask mark in the current round; proceed to the next round until the loss no longer decreases after a certain round, exit the loop, and use the optimized initial prompt word in that round as the final prompt word.
[0042] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0043] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0044] Figure 3 Schematic diagram of a model prompt word optimization device provided in an embodiment of the present application. Figure 3 As shown, the model prompt word optimization device includes:
[0045] The first interaction module 301 is configured to obtain an initial prompt word, and use an intelligent model to interact with the user based on the initial prompt word to obtain first interaction data;
[0046] The extraction and analysis module 302 is configured to extract summary information from the first interaction data, perform fine-grained sentiment analysis on the interaction data, and obtain analysis results of the first interaction data;
[0047] An optimization module 303 is configured to optimize the initial prompt word based on the summary information and analysis result of the first interaction data to obtain a target prompt word;
[0048] The second interaction module 304 is configured to use the intelligent model to interact with the user based on the target prompt word to obtain second interaction data;
[0049] The judgment module 305 is configured to determine whether to further optimize the target prompt word based on the second interaction data.
[0050] The intelligent model is a large language model (LLMs) used to interact with users. A separate large language model can be used to extract summary information from the first interaction data and perform fine-grained sentiment analysis on the interaction data. Natural language processing can also be used to extract summary information from the first interaction data and perform fine-grained sentiment analysis on the interaction data. A separate large language model can be used to extract the summary information based on the first interaction data and the analysis results to optimize the initial prompt words. The intelligent model is used to interact with the user based on the target prompt words, and it is determined whether to further optimize the target prompt words based on the second interaction data.
[0051] According to the technical solution provided by the embodiment of the present application, the initial prompt word is obtained, and the intelligent model is used to interact with the user based on the initial prompt word to obtain the first interaction data; the summary information in the first interaction data is extracted, and the interaction data is subjected to fine-grained sentiment analysis to obtain the analysis result of the first interaction data; the initial prompt word is optimized based on the summary information and analysis result of the first interaction data to obtain the target prompt word; the intelligent model is used to interact with the user based on the target prompt word to obtain the second interaction data; and it is determined whether to further optimize the target prompt word based on the second interaction data. The above technical means can solve the problem of high cost of optimizing prompt words in the prior art, thereby reducing the cost of optimizing prompt words and improving the intelligence level of the interaction between the model and the user.
[0052] In some embodiments, the optimization module 303 is also configured that the first interaction data includes an initial prompt word and a user reply sentence, and the summary information of the first interaction data includes a first summary of the initial prompt word and a second summary of the user reply sentence; the first summary and the second summary are compared to obtain the first content missing from the first summary and the second content redundant in comparison with the second summary; the first content is added to the initial prompt word and the second content is deleted, and based on the analysis results of the first interaction data, the word order of the initial prompt word is adjusted and the expression of the initial prompt word is polished to obtain the target prompt word.
[0053] The interaction between the intelligent model and the user can be regarded as the intelligent model outputting the initial prompt word on the interactive interface, and the user inputting the user reply sentence. After multiple rounds of interaction between the intelligent model and the user, the first interaction data is obtained. The summary information of the first interaction data is extracted, which can be divided into the first summary of the initial prompt word and the second summary of the user reply sentence. By comparing the first summary and the second summary, the missing content (recorded as the first content) and the redundant content (recorded as the second content) of the first summary compared to the second summary are obtained. Because the intelligent model actually replies to the user based on the user's questions on the current interactive interface or the historical interaction data between the intelligent model and the user, in fact, the initial prompt word output by the intelligent model and the user's user reply sentence are often inconsistent. In the case where the initial prompt word and the user reply sentence do not correspond, it can be assumed that the first content is not mentioned by the user due to negligence and the second content is redundant, so the first content is added to the initial prompt word and the second content is deleted.
[0054] The analysis result of the first interaction data is the user's emotional tendency towards each word in the user's reply sentence, including satisfaction, neutrality, dissatisfaction, etc., or importance, neutrality, indifference, etc. The user's reply sentence corresponds to the initial prompt word after adding the first content and deleting the second content in terms of content, so based on the analysis result of the first interaction data, the word order of the initial prompt word and the expression of the initial prompt word are polished to highlight the words that the user is satisfied with or values (the more the user values the word, the higher it is in the initial prompt word, and the more the user values the word, the greater the degree of polishing in the initial prompt word). Polishing refers to adding or replacing modifiers, etc.
[0055] For example, a user opens the travel planning agent in the intelligent model. The initial prompt is: "Hello! I am your travel planning assistant. Please tell me your destination, travel date and preferences, and I will make a perfect travel plan for you." The user replies: "I plan to travel to Paris for a week on October 1st, with a budget of about $3,000, and hope to visit more cultural attractions." In the historical interaction data between the intelligent model and the user, users often ask for detailed information about accommodation, but this is not mentioned in the initial prompt. The target prompt is: "Hello! I am your travel planning assistant. You plan to travel to Paris for a week on October 1st, with a budget of $3,000. In order to meet your preference for visiting cultural attractions, I will recommend some hotel options for you. Do you have any special requirements for accommodation?"
[0056] In some embodiments, the optimization module 303 is further configured to extract summary information from the second interaction data, perform fine-grained sentiment analysis on the interaction data, and obtain analysis results of the second interaction data; and determine whether to further optimize the target prompt word based on the summary information and analysis results of the second interaction data.
[0057] In some embodiments, the optimization module 303 is also configured such that the second interaction data includes a target prompt word and a user reply sentence, and the summary information of the second interaction data includes a first summary of the target prompt word and a second summary of the user reply sentence; the first summary and the second summary are compared to determine whether there is missing content and redundant content in the first summary compared to the second summary; when there is no missing content and redundant content in the first summary compared to the second summary, and there is no content that the user is not satisfied with in the analysis results of the second interaction data, the target prompt word is used as the prompt word obtained by the final optimization; otherwise, the target prompt word is further optimized based on the summary information and analysis results of the second interaction data.
[0058] In some embodiments, the optimization module 303 is further configured to add the missing content of the first summary compared to the second summary to the target prompt word, and filter out the redundant content of the first summary compared to the second summary; adjust the word order of the target prompt word and polish the expression of the target prompt word based on the analysis results of the second interaction data.
[0059] Further optimizing the target prompt words based on the summary information and analysis results of the second interaction data is similar to optimizing the initial prompt words based on the summary information and analysis results of the first interaction data, and will not be described in detail here.
[0060] In some embodiments, the optimization module 303 is also configured to execute the following loop: determine whether the target prompt word needs to be further optimized based on the second interaction data; when the target prompt word does not need to be further optimized, exit the loop; when the target prompt word needs to be further optimized, optimize the target prompt word based on the second interaction data; use the intelligent model to interact with the user based on the optimized target prompt word to obtain updated second interaction data.
[0061] When there is no need to further optimize the target prompt word, the loop is exited and the target prompt word is used as the final optimized prompt word. Optimizing the target prompt word based on the second interaction data is to further optimize the target prompt word based on the summary information and analysis results of the second interaction data. The intelligent model outputs the optimized target prompt word on the interactive interface, and the user inputs the user reply sentence. After multiple rounds of interaction between the intelligent model and the user, the updated second interaction data is obtained.
[0062] In some embodiments, the optimization module 303 is also configured to execute the following loop: calculate the loss between the user reply statement and the expected reply statement in the first interaction data; calculate the gradient of the mask mark in the initial prompt word based on the loss; optimize the initial prompt word using a gradient descent algorithm according to the gradient of the mask mark; until the initial prompt word converges to the minimum loss, exit the loop.
[0063] The mask mark is [MASK]. Some positions in the initial prompt word are mask marks. These mask marks are adjustable words in the initial prompt word. According to the gradient of the mask mark, the gradient descent algorithm is used to optimize the words on the mask mark in the initial prompt word (equivalent to using the mask mark in the initial prompt word as an adjustable parameter).
[0064] The above loop can be regarded as multiple rounds of optimization of the initial prompt word: calculate the loss between the user's reply sentence and the expected reply sentence in the current round; calculate the gradient of the mask mark in the initial prompt word based on the loss in the current round; use the gradient descent algorithm to optimize the initial prompt word according to the gradient of the mask mark in the current round; proceed to the next round until the loss no longer decreases after a certain round, exit the loop, and use the optimized initial prompt word in that round as the final prompt word.
[0065] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0066] Figure 4 Schematic diagram of an electronic device 4 provided in an embodiment of the present application. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0067] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 The electronic device 4 is merely an example and does not limit the electronic device 4 , and may include more or less components than those shown in the figure, or different components.
[0068] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0069] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.
[0070] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0071] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0072] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A model prompt word optimization method, characterized in that: include: Acquire an initial prompt word, and use an intelligent model to interact with a user based on the initial prompt word to obtain first interaction data; Extracting summary information from the first interaction data, performing fine-grained sentiment analysis on the interaction data, and obtaining analysis results of the first interaction data; Optimizing the initial prompt word based on the summary information and analysis results of the first interaction data to obtain a target prompt word; Using the intelligent model to interact with the user based on the target prompt word to obtain second interaction data; Determine whether to further optimize the target prompt word based on the second interaction data.
2. The method according to claim 1, characterized in that Optimizing the initial prompt word based on the summary information and analysis results of the first interaction data to obtain a target prompt word includes: The first interaction data includes the initial prompt word and the user reply sentence, and the summary information of the first interaction data includes a first summary of the initial prompt word and a second summary of the user reply sentence; Comparing the first summary with the second summary, obtaining first content missing from the first summary and second content redundant from the second summary; The first content is added to the initial prompt word and the second content is deleted. Based on the analysis result of the first interaction data, the word order of the initial prompt word is adjusted and the expression of the initial prompt word is polished to obtain the target prompt word.
3. The method according to claim 1, characterized in that Determining whether to further optimize the target prompt word based on the second interaction data includes: Extracting summary information from the second interaction data, performing fine-grained sentiment analysis on the interaction data, and obtaining analysis results of the second interaction data; Determine whether to further optimize the target prompt word based on the summary information and analysis result of the second interaction data.
4. The method according to claim 3, characterized in that Determining whether to further optimize the target prompt word based on the summary information and analysis result of the second interaction data includes: The second interaction data includes the target prompt word and the user reply sentence, and the summary information of the second interaction data includes a first summary of the target prompt word and a second summary of the user reply sentence; Comparing the first summary with the second summary, determining whether the first summary contains any missing content or any redundant content compared to the second summary; When the first summary does not contain any missing or redundant content compared to the second summary, and the analysis result of the second interaction data does not contain any content that the user is dissatisfied with, the target prompt word is used as the prompt word finally optimized; Otherwise, the target prompt word is further optimized based on the summary information and analysis result of the second interaction data.
5. The method according to claim 4, characterized in that Further optimizing the target prompt word based on the summary information and analysis results of the second interaction data includes: Adding the missing content of the first summary compared with the second summary to the target prompt word, and filtering out the redundant content of the first summary compared with the second summary; The word order of the target prompt word is adjusted and the expression of the target prompt word is polished based on the analysis result of the second interaction data.
6. The method according to claim 1, characterized in that After the intelligent model is used to interact with the user based on the target prompt word to obtain second interaction data, the method further includes: Execute the following loop: Determining whether the target prompt word needs to be further optimized based on the second interaction data; When there is no need to further optimize the target prompt word, exit the loop; When the target prompt word needs to be further optimized, optimizing the target prompt word based on the second interaction data; The intelligent model is used to interact with the user based on the optimized target prompt word to obtain updated second interaction data.
7. The method according to claim 1, characterized in that After the intelligent model is used to interact with the user based on the initial prompt word to obtain the first interaction data, the method further includes: Execute the following loop: Calculating the loss between the user reply sentence and the expected reply sentence in the first interaction data; Calculating the gradient of the mask mark in the initial prompt word based on the loss; According to the gradient of the mask mark, optimizing the initial prompt word using a gradient descent algorithm; The intelligent model is used to interact with the user based on the optimized initial prompt word to obtain updated first interaction data, and the next round of optimization is performed until the initial prompt word converges to the minimum loss, and then the loop is exited.
8. A model prompt word optimization device, characterized in that: include: A first interaction module is configured to obtain an initial prompt word, and use an intelligent model to interact with the user based on the initial prompt word to obtain first interaction data; an extraction and analysis module, configured to extract summary information from the first interaction data, perform fine-grained sentiment analysis on the interaction data, and obtain analysis results of the first interaction data; an optimization module, configured to optimize the initial prompt word based on the summary information and analysis result of the first interaction data to obtain a target prompt word; A second interaction module is configured to utilize the intelligent model to interact with the user based on the target prompt word to obtain second interaction data; A judgment module is configured to determine whether to further optimize the target prompt word based on the second interaction data.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.