A prompt word optimization method, system, electronic device and storage medium

Through the automated optimization process of the large language model, the problem of complex and inefficient manual adjustment of prompt words is solved, the efficiency and accuracy of prompt words are improved, the user experience is optimized, and automatic prompt word optimization without manual adjustment is realized.

CN118428492BActive Publication Date: 2024-09-27SHENZHEN TIANHAI CHENGUANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410895745.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-09-27
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

In the existing technology, the process of manually adjusting prompt words is complex and inefficient, and it is difficult to obtain appropriate prompt words, which affects the efficiency and accuracy of task completion of large-scale language models.

Method used

The basic prompt words and the original question set are obtained through the large language model, the answer set is calculated and scored, the optimized prompt words are generated, synonymous rewriting and loop optimization are performed until the loop end conditions are met, and the prompt words are automatically adjusted.

Benefits of technology

It improves the efficiency and accuracy of prompt word adjustment, optimizes the user experience, and realizes automatic prompt word optimization without manual adjustment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118428492B
    Figure CN118428492B
Patent Text Reader

Abstract

The present invention discloses a prompt word optimization method, system, electronic device and storage medium, and relates to the field of computer technology. The optimization method comprises the following steps: S10, obtaining basic prompt words and original question sets, and calculating the original answer set, and evaluating the original score set; S20, calculating the first answer set, and evaluating the first score set; S30, generating a prompt word optimization scheme, and obtaining the first optimized prompt word; S40 rewriting the first optimized prompt word synonymously to obtain several synonymous optimized prompt words; S50, calculating the optimized answer set, and evaluating the optimized score set; S60, calculating the average score of the first score set and the optimized score set, and outputting the optimized prompt word with the highest score; S70, using the optimized prompt word with the highest score as the next round of basic prompt words, and cyclically executing S10-S70 continuously, and judging whether the loop end condition is met, if met, the loop ends. The beneficial effects of the present invention are: the efficiency of adjusting prompt words is improved, and the user experience is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and more specifically, to a prompt word optimization method, system, electronic device and storage medium. Background Art

[0002] In natural language processing (NLP), prompts can be used to remind specific learning goals, so that pre-trained large language models (LLMs) can adapt to different task scenarios. Using prompts can use large language models (LLMs) to solve a large number of tasks. Appropriate prompts can better prompt LLMs and make the answers predicted by LLMs more accurate.

[0003] Under the existing technology, in the application of large models, it is necessary to manually design prompt words according to the needs to help the large model complete the task, and manually optimize the prompt words to improve the performance of the model. The process of manually adjusting the prompt words is relatively complicated, inefficient, and it is difficult to obtain suitable prompt words. Summary of the invention

[0004] In order to overcome the shortcomings of the prior art, the present invention provides a prompt word optimization method, system, electronic device and storage medium, which solves the problem that the current manual prompt word adjustment process is relatively complicated, inefficient, and difficult to obtain suitable prompt words, thereby improving the efficiency and accuracy of adjusting the prompt words and optimizing the user experience.

[0005] The technical solution adopted by the present invention to solve the technical problem is: a prompt word optimization method applied to a large language model, and the improvement thereof is that the prompt word optimization method comprises the following steps:

[0006] S10, the language model obtains the basic prompt words and the original question set, obtains the original answer set by calculating the original question set, and performs score evaluation on the original answer set to obtain the original score set;

[0007] S20, the language large model combines the basic prompt words to calculate the original question set to obtain a first answer set, and performs score evaluation on the first answer set to obtain a first score set;

[0008] S30, the language big model combines the original score set and the first score set to generate a prompt word optimization scheme, and optimizes the basic prompt word through the prompt word optimization scheme to obtain a first optimized prompt word;

[0009] S40, the language big model performs synonymous rewriting on the first optimization prompt word to obtain a plurality of synonymous optimization prompt words;

[0010] S50, the language big model combines the first optimization prompt word and several synonymous optimization prompt words to calculate several optimization answer sets for the original question set, and respectively performs score evaluation on the several optimization answer sets to obtain several optimization score sets;

[0011] S60, the language large model calculates the average scores of the first score set and several optimized score sets respectively, and outputs the optimized prompt word with the highest score;

[0012] S70, the language model uses the optimization prompt word with the highest score in S60 as the basic prompt word for the next round of optimization, and executes S10-S70 in a loop, and determines whether the current loop meets the loop end condition. If so, the loop ends, and if not, the loop continues.

[0013] Furthermore, the specific method for the language big model to obtain the basic prompt words and the original question set is: the user directly inputs the basic prompt words and the original question set into the language big model, and the language big model directly reads the text information corresponding to the basic prompt words and the original question set input by the user.

[0014] Furthermore, the language macromodel is provided with a target answer set corresponding to the original question set and a scoring mechanism based on the similarity of the target answer set.

[0015] Furthermore, the specific method in which the language macro model evaluates the scores of the first answer set and several optimized answer sets is: the language macro model compares the similarities between the first answer set and several optimized answer sets and the target answer set, and scores the compared similarities according to the scoring mechanism in the language macro model to obtain the first score set and several optimized score sets.

[0016] Furthermore, in the process of generating a prompt word optimization plan, the language large model needs to first determine whether the scores in the first score set are all higher than the scores in the original score set. If so, the language large model does not propose an optimization plan and directly outputs the basic prompt words; if not, the language large model needs to generate a prompt word optimization plan.

[0017] Furthermore, the number of synonymous rewritings performed by the language macro model on the first optimization prompt word is customized by the user.

[0018] Furthermore, the loop end condition specifically includes that the number of loops reaches a preset value and the scores in the first score set are higher than the scores in the original score set; wherein the preset value is set before executing the prompt word optimization method;

[0019] A prompt word optimization system is applied to the prompt word optimization method as described above, wherein the prompt word optimization system comprises:

[0020] A question-answer generation module, configured to calculate an original answer set by calculating an original question set, calculate a first answer set by combining the basic prompt words with the original question set, and calculate several optimized answer sets by combining the first optimized prompt words and several synonymous optimized prompt words with the original question set;

[0021] A synonym rewriting module is used to analyze and understand the first optimization prompt word, and generate a number of synonym optimization prompt words with different sentences but the same meaning;

[0022] An answer evaluation module is used to compare the similarity between the original answer set, the first answer set and several optimized answer sets and the target answer set, and to score them according to the scoring mechanism and the compared similarity to generate an original score set, a first score set and several optimized score sets;

[0023] A score screening module, used to calculate the average scores of the first score set and several optimized score sets respectively, and retain the optimized prompt words with the highest average scores;

[0024] An optimization scheme generating module, used for analyzing the original score set and the first score set to generate various basic optimization schemes for basic prompt words;

[0025] The optimization scheme summary module is used to summarize various basic optimization schemes and generate a comprehensive optimization scheme;

[0026] The optimization prompt word generation module is used to generate a first optimization prompt word by combining the comprehensive optimization scheme and the basic prompt word.

[0027] An electronic device, the improvement of which is that it comprises: at least one processor and at least one memory, wherein:

[0028] The memory has computer-readable instructions stored thereon;

[0029] The computer-readable instructions are executed by one or more of the processors, so that the electronic device implements the method for optimizing the prompt words as described above.

[0030] A storage medium stores computer-readable instructions, wherein the improvement lies in that the computer-readable instructions are executed by one or more processors to implement the above-mentioned prompt word optimization method.

[0031] The beneficial effects of the present invention are as follows: the scheme uses a large language model to directly calculate the original question set, calculate the original question in combination with the basic prompt words, and calculate the original question in combination with the first optimized prompt and the synonymous optimized prompt words to obtain an original answer set, a first answer set, and several optimized answer sets; the original answer set, the first answer set, and the optimized answer set are respectively evaluated and compared in score, and the optimized prompt words with the highest scores are retained and output; in this process, the large language model optimizes the basic prompt words by combining the original score set and the first score set to generate a prompt word optimization scheme to obtain the first optimized prompt words, and obtains several optimized prompt words by performing synonymous rewriting on the first optimized prompt words. The method comprises the following steps: performing synonymous optimization prompt words; calculating the average scores of the first score set and several optimization score sets respectively, outputting the optimization prompt word with the highest score, and taking the optimization prompt word with the highest score as the basic prompt word for the next round of optimization; looping and continuously executing the optimization process of the prompt words, and judging whether the current loop meets the loop end condition, if so, the loop ends, if not, the loop continues; the optimization method of the prompt words in this scheme is automatically implemented through the language big model, without manual adjustment, and can find the prompt word with the highest score by comparing the evaluation scores, and continuously iterate and change the prompt words, thereby improving the efficiency and accuracy of adjusting the prompt words and optimizing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 It is an overall flow chart of a prompt word optimization method of the present invention;

[0033] Figure 2 A block diagram of a prompt word optimization system of the present invention;

[0034] Figure 3 A hardware structure diagram of an electronic device is shown in an exemplary embodiment;

[0035] Figure 4 The present invention is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0036] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0037] The following will clearly and completely describe the concept, specific structure and technical effects of the present invention in combination with the embodiments and drawings, so as to fully understand the purpose, characteristics and effects of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, other embodiments obtained by technicians in this field without creative work are all within the scope of protection of the present invention. In addition, all the connection / connection relationships involved in the patent do not refer to the direct connection of components, but refer to the formation of a better connection structure by adding or reducing connection accessories according to the specific implementation situation. The various technical features in the invention can be combined interchangeably without conflicting with each other.

[0038] Reference Figure 1 As shown, the present invention discloses a prompt word optimization method, which is applied to a large language model, wherein the large language model is a sequence-to-sequence artificial intelligence model based on the Transformer architecture and trained with a large amount of text, question and answer, information and other corpus data; it supports Chinese and English question and answer, specifically, it can realize Chinese and English question and answer through training for Chinese and English corpus data, and has the ability to analyze, summarize, judge, score and the like according to logic; the prompt word optimization method comprises the following steps:

[0039] S10, the language big model obtains the basic prompt words and the original question set, and obtains the original answer set by calculating the original question set, and performs score evaluation on the original answer set to obtain the original score set; specifically, the specific way for the language big model to obtain the basic prompt words and the original question set is: the user directly inputs the basic prompt words and the original question set into the language big model, and the language big model directly reads the text information corresponding to the basic prompt words and the original question set input by the user; in this embodiment, the original question set includes a number of original questions, and the number of original questions in the original question set is customized by the user; the original question can be solving a math problem; summarizing an article; answering a question of the user, etc.; when the user inputs the original question set into the language big model, since the language big model is an artificial intelligence model trained with a large amount of text, question and answer, data and other corpora, the language big model will generate an original answer set according to the original question set input by the user, that is Answer each original question in the original question set to generate an original answer corresponding to each original question, and each original answer constitutes an original answer set; after the original answer set is generated, the language model will score each original answer in the original answer set, and the evaluation score of each original answer constitutes an original score set; specifically, the language model is provided with a target answer set corresponding to the original question set and a scoring mechanism based on the similarity of the target answer set; wherein the target answer set includes the target answer corresponding to each original question in the original question set; the scoring mechanism is to perform score evaluation by comparing the similarity between the language model's answer to the original question and the target answer, that is, comparing the similarity between the target answers corresponding to each original answer in the original answer set; in this embodiment, the score is set between 0 and 100, and the range is not fixed. The user can adjust the score setting range according to actual needs;

[0040] S20, the language big model calculates the first answer set for the original question set in combination with the basic prompt words, and performs score evaluation on the first answer set to obtain a first score set; in this embodiment, the basic prompt words and the original question are input into the language big model by the user, so as to allow the language big model to output the required results, wherein the language big model needs to cooperate with specific prompt words in the process of completing the task, and the basic prompt words refer to a group of words or phrases used to guide the language big model to generate relevant content, and in this solution, are used to guide the language big model to generate the first answer set. Similarly, when performing score evaluation on the first answer set, the language big model performs score evaluation by comparing the similarity between each answer in the first answer set and its corresponding target answer, so as to obtain the first score set;

[0041] S30, the language large model generates a prompt word optimization scheme in combination with the original score set and the first score set, and optimizes the basic prompt word through the prompt word optimization scheme to obtain the first optimized prompt word; wherein, in the process of generating the prompt word optimization scheme, the language large model needs to first determine whether the scores in the first score set are all higher than the scores in the original score set. If so, the language large model does not propose an optimization scheme and directly outputs the basic prompt word; if not, the language large model needs to generate a prompt word optimization scheme; in this embodiment, before performing step S30, it is also necessary to first determine whether the scores in the first score set are all higher than the corresponding scores in the original score set. If so, it means that the first answer in the first answer set is better and more accurate than the original answer in the original answer set, that is, the first answer set is good enough, and there is no need to optimize the basic prompt word, and the basic prompt word can be directly output; if not, it proves that the first answer set is good enough. If the first answer in the answer set is not good enough compared to the original answer in the original answer set, the basic prompt words need to be optimized; specifically, in the process of optimizing the basic prompt words, the original scores in the original score set need to be compared with the first scores corresponding to the first score set. If a certain original score is higher than the first score, the language model combines the original answer corresponding to the original score and the first answer corresponding to the first score to generate an optimization plan for the original question; if a certain original score is lower than the first score, no optimization plan is proposed; further, after comparing all the original scores in the original score set with the first scores corresponding to the first score set, the language model will summarize all the generated optimization plans to generate a comprehensive optimization plan, wherein, for multiple contradictory optimization plans, the one with a larger number or a more reasonable one is adopted, and the feasibility of the optimization plan is ensured;

[0042] S40, the language model performs synonymous rewriting on the first optimization prompt word to obtain a plurality of synonymous optimization prompt words; wherein the number of synonymous rewritings performed by the language model on the first optimization prompt word is set by the user; in this embodiment, the language model generates a plurality of optimization prompt words with different sentences but the same meaning by analyzing and understanding the first optimization prompt word;

[0043] S50, the language big model calculates the original question set in combination with the first optimization prompt word and several synonymous optimization prompt words to obtain several optimized answer sets, and performs score evaluation on the several optimized answer sets to obtain several optimized score sets; in this embodiment, after the language big model performs synonymous rewriting on the first optimization prompt word, it calculates the original question in combination with the first optimization prompt word and the synonymous optimization prompt word to obtain optimized answer sets, and performs score evaluation on the optimized answer sets to obtain several optimized score sets. Similarly, the specific manner in which the language big model performs score evaluation on the several optimized answer sets is: the language big model compares the similarity between the several optimized answer sets and the target answer set, and scores the compared similarities according to the scoring mechanism in the language big model to obtain several optimized score sets;

[0044] S60, the language big model calculates the average scores of the first score set and the several optimized score sets respectively, and outputs the optimized prompt word with the highest score; in this embodiment, the average score reflects the overall accuracy level of the answer set corresponding to the first score set and each optimized score set relative to the target answer set, and the higher the average score, the more similar the answer set corresponding to the score set is to the target answer set, that is, the answer is more accurate, and thus the optimized prompt word with the highest average score is output;

[0045] S70, the language model uses the optimization prompt word with the highest score in S60 as the basic prompt word for the next round of optimization, and executes S10-S70 in a loop, and determines whether the current loop meets the loop end condition. If so, the loop ends, and if not, the loop continues; wherein, the loop end condition specifically includes that the number of loops reaches a preset value and the scores in the first score set are higher than the scores in the original score set; wherein, the preset value is set before executing the prompt word optimization method; in this embodiment, after executing a round of prompt word optimization, the language model needs to automatically and continuously optimize the prompt word until the loop end condition is met. This process can gradually adjust and improve the prompt word to guide the language model to generate more accurate and reasonable answers; setting the loop end condition can avoid excessive iterations of the prompt word, prevent over-optimization or fall into an infinite loop, thereby enhancing the stability of the entire optimization process.

[0046] Reference Figure 2 As shown, a prompt word optimization system 600 is applied to the prompt word optimization method as described in the above embodiment. The prompt word optimization system 600 includes:

[0047] The question-answer generation module 601 is used to calculate an original answer set by calculating an original question set, calculate a first answer set by combining the basic prompt words with the original question set, and calculate several optimized answer sets by combining the first optimized prompt words and several synonymous optimized prompt words with the original question set respectively;

[0048] The synonym rewriting module 602 is used to analyze and understand the first optimization prompt word, and generate a plurality of synonymous optimization prompt words with different sentences but the same meaning;

[0049] The answer evaluation module 603 is used to compare the similarity between the original answer set, the first answer set and the plurality of optimized answer sets and the target answer set, and to score them according to the scoring mechanism and the compared similarity to generate the original score set, the first score set and the plurality of optimized score sets;

[0050] A score screening module 604 is used to calculate the average scores of the first score set and the plurality of optimized score sets, and retain the optimized prompt words with the highest average scores;

[0051] An optimization scheme generating module 605 is used to analyze the original score set and the first score set to generate various basic optimization schemes for basic prompt words;

[0052] The optimization scheme summary module 606 is used to summarize each basic optimization scheme and generate a comprehensive optimization scheme;

[0053] The optimization prompt word generation module 607 is used to generate a first optimization prompt word by combining the comprehensive optimization solution and the basic prompt word.

[0054] In this embodiment, when the language big model is executing the prompt word optimization method, the prompt word optimization system 600 calculates the original answer set for the original question set through the question and answer generation module 601, and calculates the first answer set for the original question set in combination with the basic prompt words, and calculates several optimized answer sets for the original question set in combination with the first optimized prompt words and several synonymous optimized prompt words; analyzes and understands the first optimized prompt words through the synonym rewriting module 602, and generates several synonymous optimized prompt words with different sentences but the same meaning; compares the similarity of the original answer set, the first answer set and several optimized answer sets with the target answer set through the answer evaluation module 603, and scores them according to the scoring mechanism and the compared similarity to generate the original score set, the first score set and several optimized score sets; through the score screening module 604, respectively calculating the average scores of the first score set and several optimized score sets, and retaining the optimized prompt words with the highest average scores; through the optimization scheme generation module 605, analyzing the original score set and the first score set to generate various basic optimization schemes for the basic prompt words; through the optimization scheme summary module 606, summarizing the various basic optimization schemes to generate a comprehensive optimization scheme; through the optimization prompt word generation module 607, combining the comprehensive optimization scheme and the basic prompt words, generating the first optimized prompt word; in this scheme, the language large model can realize automatic adjustment of the prompt words through various modules without manual adjustment, and can find the prompt word with the highest score by comparing the evaluation scores, thereby improving the efficiency of adjusting the prompt words and optimizing the user experience.

[0055] Figure 3 The present invention schematically illustrates the structure of an electronic device according to an exemplary embodiment.

[0056] It should be noted that the electronic device is only an example adapted to the present invention and cannot be considered to provide any limitation on the scope of use of the present invention. The electronic device cannot be interpreted as requiring dependence on or having Figure 3 One or more components of exemplary electronic device 2000 are shown.

[0057] The hardware structure of the electronic device 2000 may vary greatly due to differences in configuration or performance, such as Figure 3 As shown, the electronic device 2000 includes: a power supply 210 , an interface 230 , at least one memory 250 , and at least one central processing unit (CPU) 270 .

[0058] Specifically, the power supply 210 is used to provide operating voltage for each hardware device on the electronic device 2000 .

[0059] The interface 230 includes at least one wired or wireless network interface 231 for interacting with external devices. Of course, in other examples adapted by the present invention, the interface 230 may further include at least one serial-to-parallel conversion interface 233, at least one input-output interface 235, and at least one USB interface 237, etc. Figure 3 As shown, this is not intended to be a specific limitation.

[0060] The memory 250 is a carrier for storing resources, which may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 251, an application 253 and data 255, etc. The storage method may be temporary storage or permanent storage.

[0061] Among them, the operating system 251 is used to manage and control various hardware devices and application programs 253 on the electronic device 2000 to enable the central processor 270 to calculate and process the massive data 255 in the memory 250. It can be WindowsServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0062] The application program 253 is a computer-readable instruction that performs at least one specific task based on the operating system 251, and may include at least one module ( Figure 3 (not shown), each module may respectively include computer-readable instructions for the electronic device 2000. For example, the prompt word optimization system may be regarded as an application 253 deployed on the electronic device 2000.

[0063] The data 255 may be signal information, etc., stored in the memory 250 .

[0064] The central processor 270 may include one or more processors, and is configured to communicate with the memory 250 through at least one communication bus to read the computer-readable instructions stored in the memory 250, thereby realizing the operation and processing of the mass data 255 in the memory 250. For example, the optimization method of the prompt word is completed by the central processor 270 reading a series of computer-readable instructions stored in the memory 250.

[0065] In addition, the present invention can also be implemented by hardware circuits or hardware circuits combined with software. Therefore, the implementation of the present invention is not limited to any specific hardware circuits, software, or a combination of the two.

[0066] See also Figure 4 In an embodiment of the present invention, an electronic device 4000 is provided. The electronic device 4000 may include: a desktop computer, a laptop computer, a server, etc. with sensor recognition capability.

[0067] exist Figure 4 In the embodiment, the electronic device 4000 includes at least one processor 4001 and at least one memory 4003.

[0068] The data interaction between the processor 4001 and the memory 4003 can be realized through at least one communication bus 4002. The communication bus 4002 may include a path for transmitting data between the processor 4001 and the memory 4003. The communication bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0069] Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception, etc. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present invention.

[0070] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0071] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program instructions or codes in the form of instructions or data structures and can be accessed by the electronic device 4000, but is not limited to this.

[0072] The memory 4003 stores computer-readable instructions, and the processor 4001 can read the computer-readable instructions stored in the memory 4003 through the communication bus 4002 .

[0073] The computer-readable instructions are executed by one or more processors 4001 to implement the optimization method of the prompt words in the above-mentioned embodiments.

[0074] In addition, an embodiment of the present invention provides a storage medium on which computer-readable instructions are stored. The computer-readable instructions are executed by one or more processors to implement the above-mentioned method for optimizing prompt words.

[0075] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0076] Compared with the prior art, the present invention has the following beneficial effects:

[0077] 1. The embodiment of the present invention is automatically implemented through a large language model without manual adjustment, and can find the prompt word with the highest score by comparing the evaluation scores, and use the prompt word with the highest score as the basic prompt word for the next round of prompt word optimization, and continuously perform loop iterative optimization on the prompt word until the loop end condition is met, thereby improving the efficiency and accuracy of adjusting the prompt word and optimizing the user experience.

[0078] 2. The embodiment of the present invention can find the best prompt word by performing score evaluation and comparison on the original answer set, the first answer set and the optimized answer set, thereby improving the quality of the generated results.

[0079] 3. The embodiment of the present invention generates a plurality of synonymous optimization prompt words by performing synonymous rewriting on the first optimization prompt word, which can increase diversity and richness and further optimize the generation result of the model.

[0080] The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A method for optimizing prompt words, applied to a large language model, characterized in that: The optimization method of the prompt word comprises the following steps: S10, the language big model obtains the basic prompt words and the original question set, and obtains the original answer set by calculating the original question set, and performs score evaluation on the original answer set to obtain the original score set; wherein the specific manner in which the language big model obtains the basic prompt words and the original question set is: the user directly inputs the basic prompt words and the original question set into the language big model, and the language big model directly reads the text information corresponding to the basic prompt words and the original question set input by the user; S20, the language macro model calculates the first answer set for the original question set in combination with the basic prompt words, and performs score evaluation on the first answer set to obtain a first score set; wherein the language macro model is provided with a target answer set corresponding to the original question set and a scoring mechanism based on the similarity of the target answer set; the specific manner in which the language macro model performs score evaluation on the first answer set and several optimized answer sets is as follows: the language macro model compares the similarity of the first answer set and several optimized answer sets with the target answer set, and scores the similarity of the comparisons according to the scoring mechanism in the language macro model to obtain the first score set and several optimized score sets; S30, the language large model generates a prompt word optimization scheme by combining the original score set and the first score set, and optimizes the basic prompt word by the prompt word optimization scheme to obtain the first optimized prompt word; specifically, in the process of generating the prompt word optimization scheme, the language large model needs to first determine whether the scores in the first score set are all higher than the scores in the original score set. If so, the language large model does not propose an optimization scheme and directly outputs the basic prompt word; if not, the language large model needs to generate a prompt word optimization scheme; S40, the language model performs synonymous rewriting on the first optimization prompt word to obtain a plurality of synonymous optimization prompt words; wherein the number of synonymous rewritings performed on the first optimization prompt word by the language model is customized by the user; S50, the language big model combines the first optimization prompt word and several synonymous optimization prompt words to calculate several optimization answer sets for the original question set, and respectively performs score evaluation on the several optimization answer sets to obtain several optimization score sets; S60, the language large model calculates the average scores of the first score set and several optimized score sets respectively, and outputs the optimized prompt word with the highest score; S70, the language big model uses the optimization prompt word with the highest score in S60 as the basic prompt word for the next round of optimization, and executes S10-S70 in a loop, and determines whether the current loop meets the loop end condition. If so, the loop ends, and if not, the loop continues; wherein the loop end condition specifically includes that the number of loops reaches a preset value and the scores in the first score set are higher than the scores in the original score set; wherein the preset value is set before executing the prompt word optimization method.

2. A prompt word optimization system, applied to the prompt word optimization method according to claim 1, characterized in that: The optimization system of the prompt word includes: A question-answer generation module, configured to calculate an original answer set by calculating an original question set, calculate a first answer set by combining the basic prompt words with the original question set, and calculate several optimized answer sets by combining the first optimized prompt words and several synonymous optimized prompt words with the original question set; A synonym rewriting module is used to analyze and understand the first optimization prompt word, and generate a number of synonym optimization prompt words with different sentences but the same meaning; An answer evaluation module is used to compare the similarity between the original answer set, the first answer set and several optimized answer sets and the target answer set, and to score them according to the scoring mechanism and the compared similarity to generate an original score set, a first score set and several optimized score sets; A score screening module, used to calculate the average scores of the first score set and several optimized score sets respectively, and retain the optimized prompt words with the highest average scores; An optimization scheme generating module, used for analyzing the original score set and the first score set to generate various basic optimization schemes for basic prompt words; The optimization scheme summary module is used to summarize various basic optimization schemes and generate a comprehensive optimization scheme; The optimization prompt word generation module is used to generate a first optimization prompt word by combining the comprehensive optimization scheme and the basic prompt word.

3. An electronic device, characterized in that: include: at least one processor and at least one memory, wherein: The memory has computer-readable instructions stored thereon; The computer-readable instructions are executed by one or more of the processors to enable the electronic device to implement the method for optimizing prompt words as claimed in claim 1.

4. A storage medium having computer-readable instructions stored thereon, characterized in that: The computer-readable instructions are executed by one or more processors to implement the method for optimizing prompt words according to claim 1.