Prompt-based model tuning method and device, electronic equipment and readable medium

By acquiring a test dataset, calling pre-trained prompt optimization and parameter optimization models, optimizing the target model's prompt and adjusting model parameters, and generating tuning strategies, the problem of tedious manual tuning during large language model switching is solved, achieving automated and standardized tuning for model switching.

CN120930735APending Publication Date: 2025-11-11BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510973830.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-15
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

When switching between large language models, users need to manually adjust the prompt and model parameters, making the tuning process tedious and complex, and making it difficult to quickly find the best tuning strategy.

Method used

By acquiring a test dataset, calling pre-trained prompt optimization and parameter optimization models, optimizing the target model's prompt and adjusting model parameters, and generating tuning strategies, including prompt optimization strategies and parameter adjustment strategies.

Benefits of technology

It achieves automated and standardized tuning during model switching, reduces the complexity of model switching, quickly finds the best tuning strategy, and reduces the workload of manual tuning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120930735A_ABST
    Figure CN120930735A_ABST
Patent Text Reader

Abstract

The invention relates to a model tuning method and device based on prompt, electronic equipment and a readable medium, and the method comprises the steps: obtaining a test data set; calling a prompt optimization model obtained through training in advance, and optimizing the first prompt of the target model by using the test data set and the prompt optimization model to obtain a second prompt; calling a parameter optimization model obtained through training in advance, and adjusting model parameters of the target model by using the test data set, the second prompt and the parameter optimization model to obtain an adjusted target model; the adjusting and optimizing effect of the adjusted target model is detected, when the adjusting and optimizing effect reaches the expected effect, an adjusting and optimizing strategy of the target model is generated, and the adjusting and optimizing strategy comprises a prompt optimizing strategy obtained through the prompt optimizing model and a parameter adjusting strategy obtained through the parameter optimizing model. The problem that the optimal tuning strategy is difficult to find quickly by manually tuning the model during model switching is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of large language model technology, and in particular to a prompt-based model tuning method, apparatus, electronic device, and readable medium. Background Technology

[0002] Currently, large language models, with their powerful language understanding and generation capabilities, have been widely used in many fields such as natural language processing, computer vision, and speech recognition. However, in practical applications, users may need to temporarily switch models due to various factors, such as interface instability or service interruptions. However, different large language models have significant differences in their architectural design and behavioral performance. When switching from one model to another alternative model, users cannot directly use the original settings; they need to readjust the prompt and model parameters for the new model.

[0003] Because different models understand and respond to prompts differently, and different models have different sensitivities and ranges of parameters, manually tuning these parameters is an extremely tedious and complex process. Furthermore, due to the complex interactions and influences between parameters, it is difficult to quickly find the best tuning strategy by manually tuning the model when switching models.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This application provides a prompt-based model tuning method, apparatus, electronic device, and readable medium to solve the aforementioned technical problem that "it is difficult to quickly find the best tuning strategy by manually tuning the model during model switching".

[0006] According to one aspect of the embodiments of this application, this application provides a prompt-based model tuning method, comprising: acquiring a test data set, wherein the test data set includes multiple sets of corresponding preset questions and preset answers; calling a pre-trained prompt optimization model, and using the test data set and the prompt optimization model to optimize a first prompt of the target model to obtain a second prompt; calling a pre-trained parameter optimization model, and using the test data set, the second prompt, and the parameter optimization model to adjust the model parameters of the target model to obtain an adjusted target model; detecting the tuning effect of the adjusted target model, and when the tuning effect reaches the expected effect, generating a tuning strategy for the target model, wherein the tuning strategy includes a prompt optimization strategy obtained by the prompt optimization model and a parameter adjustment strategy obtained by the parameter optimization model.

[0007] Optionally, the first prompt of the target model is optimized using a test dataset and a prompt optimization model to obtain a second prompt, including: processing the preset questions in the test dataset through the first prompt to obtain first input data; inputting the first input data into the target model to obtain the first output result of the target model; comparing and analyzing the first output result and the preset answer using the prompt optimization model to obtain a first analysis result, wherein the first analysis result includes the prompt optimization strategy, the first question type, and the first matching degree between the first output result and the preset answer; and optimizing the first prompt using the prompt optimization strategy to obtain the second prompt.

[0008] Optionally, the model parameters of the target model are adjusted using a test dataset, a second prompt, and a parameter optimization model to obtain an adjusted target model. This includes: processing the preset questions in the test dataset through the second prompt to obtain second input data; inputting the second input data into the target model to obtain a second output result of the target model; comparing and analyzing the second output result and the preset answer using the parameter optimization model to obtain a second analysis result, wherein the second analysis result includes a parameter adjustment strategy, a second question type, and a second matching degree between the second output result and the preset answer; and adjusting the model parameters of the target model using the parameter adjustment strategy to obtain the adjusted target model.

[0009] Optionally, detecting the tuning effect of the adjusted target model includes: processing the preset problem in the test dataset through the second prompt to obtain the second input data; inputting the second input data into the adjusted target model to obtain the third output result of the adjusted target model; comparing and analyzing the third output result using the parameter optimization model and the prompt optimization model respectively to obtain the third analysis result; and determining the tuning effect of the adjusted target model based on the third analysis result.

[0010] Optionally, the tuning effect of the adjusted target model is determined based on the third analysis results, including: if the third analysis results indicate that the parameter optimization model does not output a parameter adjustment strategy and the prompt optimization model does not output a prompt optimization strategy, then the tuning effect is determined to have achieved the desired effect; or if the third analysis results indicate that the third matching degree output by the parameter optimization model reaches the first threshold and the fourth matching degree output by the prompt optimization model reaches the second threshold, then the tuning effect is determined to have achieved the desired effect.

[0011] Optionally, after detecting the optimization effect of the adjusted target model, the method further includes: when the optimization effect does not reach the expected effect, iteratively optimizing the adjusted target model; when the optimization effect is detected to reach the expected effect, stopping the optimization and saving the latest obtained optimization strategy to a preset database.

[0012] Optionally, after generating the tuning strategy for the target model, the method further includes: saving the tuning strategy for the target model to a preset database; in the event that the original model needs to be switched to the target model, calling the tuning strategy from the preset database; and tuning the target model according to the tuning strategy.

[0013] According to another aspect of the embodiments of this application, this application provides a prompt-based model tuning device, comprising: an acquisition module for acquiring a test data set, wherein the test data set includes multiple sets of corresponding preset questions and preset answers; an optimization module for calling a pre-trained prompt optimization model and optimizing a first prompt of a target model using the test data set and the prompt optimization model to obtain a second prompt; an adjustment module for calling a pre-trained parameter optimization model and adjusting the model parameters of the target model using the test data set, the second prompt, and the parameter optimization model to obtain an adjusted target model; and a detection module for detecting the tuning effect of the adjusted target model and generating a tuning strategy for the target model when the tuning effect reaches the expected effect, wherein the tuning strategy includes a prompt optimization strategy obtained from the prompt optimization model and a parameter adjustment strategy obtained from the parameter optimization model.

[0014] According to another aspect of the embodiments of this application, this application provides an electronic device, including a memory, a processor, a communication interface and a communication bus. The memory stores a computer program that can run on the processor. The memory and the processor communicate with each other through the communication bus and the communication interface. When the processor executes the computer program, it implements the steps of the above method.

[0015] According to another aspect of the embodiments of this application, this application also provides a computer-readable medium having processor-executable non-volatile program code that causes the processor to perform the above-described method.

[0016] Compared with related technologies, the technical solutions provided in this application have the following advantages:

[0017] This application provides a prompt-based model tuning method, comprising: acquiring a test dataset, wherein the test dataset includes multiple sets of corresponding preset questions and preset answers; calling a pre-trained prompt optimization model, and using the test dataset and the prompt optimization model to optimize the first prompt of the target model to obtain a second prompt; calling a pre-trained parameter optimization model, and using the test dataset, the second prompt, and the parameter optimization model to adjust the model parameters of the target model to obtain an adjusted target model; detecting the tuning effect of the adjusted target model, and generating a tuning strategy for the target model when the tuning effect reaches the expected effect, wherein the tuning strategy includes a prompt optimization strategy obtained by the prompt optimization model and a parameter adjustment strategy obtained by the parameter optimization model. Users only need to input test data; the prompt optimization model optimizes the target model's prompt based on the test data, and then the parameter optimization model adjusts the target model's parameters based on the test data. When the model tuning effect meets the target, a tuning strategy is generated, solving the problem that it is difficult to quickly find the optimal tuning strategy when manually tuning the model during model switching. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0020] Figure 1 This is a schematic diagram of the hardware environment for an optional prompt-based model tuning method provided according to an embodiment of this application.

[0021] Figure 2 A flowchart illustrating an optional prompt-based model tuning method provided according to an embodiment of this application;

[0022] Figure 3 This is a block diagram of an optional prompt-based model tuning device provided according to an embodiment of this application;

[0023] Figure 4 This is a schematic diagram of an optional electronic device structure provided in an embodiment of this application. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0025] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustration and has no specific meaning in itself. Therefore, "module" and "part" may be used interchangeably.

[0026] Currently, large language models, with their powerful language understanding and generation capabilities, have been widely used in many fields such as natural language processing, computer vision, and speech recognition. However, in practical applications, users may need to temporarily switch models due to various factors, such as interface instability or service interruptions. However, different large language models have significant differences in their architectural design and behavioral performance. When switching from one model to another alternative model, users cannot directly use the original settings; they need to readjust the prompt and model parameters for the new model.

[0027] Because different models understand and respond to prompts differently, and different models have different sensitivities and ranges of parameters, manually tuning these parameters is an extremely tedious and complex process. Furthermore, due to the complex interactions and influences between parameters, it is difficult to quickly find the best tuning strategy by manually tuning the model when switching models.

[0028] To address the problems mentioned in the background art, according to one aspect of the embodiments of this application, an embodiment of a prompt-based model tuning method is provided.

[0029] Optionally, in the embodiments of this application, the above-described prompt-based model tuning method can be applied to, for example... Figure 1 The hardware environment shown consists of terminal 101 and server 103. Figure 1 As shown, server 103 is connected to terminal 101 via a network and can be used to provide services to the terminal or clients installed on the terminal. Database 105 can be set up on the server or independently of the server to provide data storage services for server 103. The network mentioned above includes, but is not limited to, wide area network, metropolitan area network or local area network. Terminal 101 includes, but is not limited to, PC, mobile phone, tablet computer, etc.

[0030] The prompt-based model tuning method in this application embodiment can be executed by server 103, or it can be jointly executed by server 103 and terminal 101, such as... Figure 2 As shown, it includes:

[0031] Step 201: Obtain the test data set, which includes multiple sets of pre-set questions and pre-set answers that have a corresponding relationship;

[0032] Step 202: Call the pre-trained prompt optimization model, and use the test dataset and the prompt optimization model to optimize the first prompt of the target model to obtain the second prompt;

[0033] Step 203: Call the pre-trained parameter optimization model, and use the test dataset, the second prompt, and the parameter optimization model to adjust the model parameters of the target model to obtain the adjusted target model;

[0034] Step 204: Detect the tuning effect of the adjusted target model, and when the tuning effect reaches the expected effect, generate the tuning strategy of the target model. The tuning strategy includes the prompt optimization strategy obtained from the prompt optimization model and the parameter adjustment strategy obtained from the parameter optimization model.

[0035] This application is applied to model switching scenarios. Users only need to input test data. The prompt optimization model optimizes the prompt of the target model based on the test data. Then, the parameter optimization model adjusts the parameters of the target model based on the test data. When the model tuning effect meets the target, a tuning strategy is generated.

[0036] The test dataset consists of multiple sets of pre-defined questions and answers, with a one-to-one correspondence between them. The test dataset can be generated by filtering historical data or through manual configuration, producing multiple high-quality input-output question-answer pairs. The test dataset is used to evaluate the accuracy and consistency of the model's output, providing a reference for subsequent optimization steps.

[0037] In large language model applications, prompt is the core bridge connecting user intent and model capabilities, used to clearly inform the model of the operations that need to be performed.

[0038] The prompt optimization model and parameter optimization model involved in this application are both pre-trained and generated. The prompt optimization model is used to identify the key differences between the output result and the expected preset answer, and provides prompt improvement suggestions based on the differences. The parameter optimization model is used to compare the differences between the model output and the expected preset answer under different parameter configurations, and provides parameter optimization suggestions based on the differences.

[0039] There are already relatively mature model training processes in the existing technology, so this application will not elaborate on the training steps of prompt optimization model and parameter optimization model.

[0040] It should be noted that in the embodiments provided in this application, each complete optimization process first optimizes the prompt and then adjusts the model parameters. However, in actual applications, the model parameters can be adjusted first and then the prompt optimized, and the optimization effect will not be affected.

[0041] As an optional embodiment, the first prompt of the target model is optimized using a test dataset and a prompt optimization model to obtain a second prompt, including: processing a preset question in the test dataset through the first prompt to obtain first input data; inputting the first input data into the target model to obtain a first output result of the target model; comparing and analyzing the first output result and the preset answer using the prompt optimization model to obtain a first analysis result, wherein the first analysis result includes a prompt optimization strategy, a first question type, and a first matching degree between the first output result and the preset answer; and optimizing the first prompt using the prompt optimization strategy to obtain the second prompt.

[0042] The first prompt is the initial prompt corresponding to the target model. The preset question can be templated and constructed using the first prompt, making it the first input data that can be recognized by the model.

[0043] The target model identifies the first input data and outputs the first output result. The prompt optimization model compares and analyzes the first output result with the preset answer to obtain the first analysis result. The first analysis result includes the first matching degree between the first output result and the preset answer. If the first question type appears in the first analysis result, the corresponding prompt optimization strategy will be output.

[0044] This application does not restrict the first question type, including but not limited to tone deviation, length exceeding limit, and omission of key information. If the first question type is tone deviation, the corresponding prompt optimization strategy is: add tone constraints (e.g., use a humorous style). If the first question type is length exceeding limit, the corresponding prompt optimization strategy is: insert a length limit instruction (e.g., answer not exceeding 50 words). If the first question type is omission of key information, the corresponding prompt optimization strategy is: add explicit requirements (e.g., must include certain data).

[0045] For example, if the user scenario is a cheerful one, but the target model outputs a more serious result, which is different from the atmosphere of the preset answer, the prompt optimization model detects the problem and gives a suggestion, such as adding "Please answer the question in a humorous tone" to the prompt.

[0046] For example, the current user is having a short conversation, but the target model outputs a long answer that does not match the expected preset answer. In this case, the prompt optimization model detects the problem and provides suggestions, such as adding "Please answer the question briefly" to the prompt.

[0047] The first matching degree can be the text similarity between the first output result and the preset answer.

[0048] As an optional embodiment, the model parameters of the target model are adjusted using a test dataset, a second prompt, and a parameter optimization model to obtain an adjusted target model. This includes: processing a preset question from the test dataset using the second prompt to obtain second input data; inputting the second input data into the target model to obtain a second output result; comparing and analyzing the second output result and a preset answer using the parameter optimization model to obtain a second analysis result, wherein the second analysis result includes a parameter adjustment strategy, a second question type, and a second matching degree between the second output result and the preset answer; and adjusting the model parameters of the target model using the parameter adjustment strategy to obtain the adjusted target model.

[0049] Since the second prompt is already optimized, the second input data at this time is equivalent to having been optimized once. It is input into the target model to obtain the second output result of the target model, and the adjustment strategy of the model parameters is obtained based on the second output result.

[0050] The second matching degree can be the text similarity between the second output result and the preset answer.

[0051] This application does not restrict the type of the second problem, including but not limited to low diversity and high repetition rate.

[0052] The large model has many parameters, including temperature, top_p, top_k, and presence_penalty. Optimizing the model through parameters can provide optimization suggestions for each parameter.

[0053] For example, if the target model outputs exactly the same results for the same preset question, it means that the target model lacks diversity and does not meet the expected effect. In this case, the parameter optimization model will give a parameter adjustment strategy: "increase the temperature parameter value", because the higher the temperature, the more diverse the generated text.

[0054] For example, if the target model produces a lot of repetitive content, which does not meet the expected results, the parameter optimization model will provide a parameter adjustment strategy: "increase the frequency_penalty parameter value", because increasing this value can reduce the possibility of the model producing repetitive content.

[0055] This application describes an embodiment based on inputting a single preset question. In practical applications, multiple sets of preset questions and preset answers can be used to obtain multiple output contents. By comparing and analyzing each output content with the corresponding preset answer, more comprehensive optimization suggestions can be obtained.

[0056] As an optional embodiment, detecting the tuning effect of the adjusted target model includes: processing the preset problem in the test dataset through the second prompt to obtain the second input data; inputting the second input data into the adjusted target model to obtain the third output result of the adjusted target model; comparing and analyzing the third output result using the parameter optimization model and the prompt optimization model respectively to obtain the third analysis result; and determining the tuning effect of the adjusted target model based on the third analysis result.

[0057] When testing the optimization effect of the adjusted target model, after obtaining the third output result of the adjusted target model, the third output result is compared and analyzed using the parameter optimization model and the prompt optimization model respectively, and the third analysis result is obtained.

[0058] The third analysis results include the analysis results obtained by the parameter optimization model after comparing the third output result with the preset answer, and the analysis results obtained by the prompt optimization model after comparing the third output result with the preset answer.

[0059] As an optional embodiment, determining the tuning effect of the adjusted target model based on the third analysis result includes: if the third analysis result indicates that the parameter optimization model does not output a parameter adjustment strategy and the prompt optimization model does not output a prompt optimization strategy, then it is determined that the tuning effect has reached the expected effect; or if the third analysis result indicates that the third matching degree output by the parameter optimization model reaches the first threshold and the fourth matching degree output by the prompt optimization model reaches the second threshold, then it is determined that the tuning effect has reached the expected effect.

[0060] If the parameter optimization model does not output a parameter adjustment strategy, it means that the model parameters of the current target model have been adjusted to the optimal level. If the prompt optimization model does not output a prompt optimization strategy, it means that the prompt used to process the input data of the target model has been adjusted to the optimal level.

[0061] Additionally, a first threshold and a second threshold can be preset. If the third analysis result indicates that the third matching degree of the parameter optimization model output reaches the first threshold, or the fourth matching degree of the prompt optimization model output reaches the second threshold, it means that the current output content can well express the intent of the preset answer.

[0062] The first and second thresholds can be adaptively adjusted according to the actual situation.

[0063] For example, the first threshold θ for semantic matching is dynamically adjusted according to the difficulty of the task. If it is a simple task, then θ = 0.9 (strict matching) and if it is a complex task, then θ = 0.7 (allowing some expression differences). The second threshold is similar.

[0064] As an optional embodiment, after detecting the optimization effect of the adjusted target model, the method further includes: when the optimization effect does not reach the expected effect, iteratively optimizing the adjusted target model; when the optimization effect is detected to have reached the expected effect, stopping the optimization and saving the latest obtained optimization strategy to a preset database.

[0065] The optimization process may involve more than one round. If the optimization effect of the adjusted target model does not meet the expected effect, optimization will continue through iteration. The specific iteration steps are the same as the optimization steps described above, and will not be repeated here.

[0066] You can set a maximum number of iterations. If the number of iterations reaches the maximum number of iterations, the prompt optimization strategy and parameter adjustment strategy corresponding to the highest matching degree obtained so far will be directly selected. The matching degree here can be the matching degree output by the prompt optimization model, the matching degree output by the parameter optimization model, or the average of the two matching degrees.

[0067] This application can reduce the complexity of adjustment work when switching models and enable rapid model switching.

[0068] As an optional embodiment, after generating the tuning strategy for the target model, the method further includes: saving the tuning strategy for the target model to a preset database; in the event that the original model needs to be switched to the target model, calling the tuning strategy from the preset database; and tuning the target model according to the tuning strategy.

[0069] After generating the tuning strategy for the target model, the tuning strategy is saved to the preset database. At the same time, relevant information about the original model and the target model (such as model name, model number, etc.) is also saved. In other words, the original model, the new model, and the tuning strategy are associated and saved as a complete data entry.

[0070] For example, if model A needs to be switched to the target model, then the optimization strategy corresponding to switching model A to the target model is searched from the preset database, and then the strategy is directly called to adjust the prompt and model parameters of the target model.

[0071] By pre-setting a database to store and call tuning strategies, the model tuning is standardized, automated, and traceable. The tuning strategies in this application can be reused multiple times, avoiding repeated experiments.

[0072] This application provides a prompt-based model tuning method, comprising: acquiring a test dataset, wherein the test dataset includes multiple sets of corresponding preset questions and preset answers; calling a pre-trained prompt optimization model, and using the test dataset and the prompt optimization model to optimize the first prompt of the target model to obtain a second prompt; calling a pre-trained parameter optimization model, and using the test dataset, the second prompt, and the parameter optimization model to adjust the model parameters of the target model to obtain an adjusted target model; detecting the tuning effect of the adjusted target model, and generating a tuning strategy for the target model when the tuning effect reaches the expected effect, wherein the tuning strategy includes a prompt optimization strategy obtained by the prompt optimization model and a parameter adjustment strategy obtained by the parameter optimization model. Users only need to input test data; the prompt optimization model optimizes the target model's prompt based on the test data, and then the parameter optimization model adjusts the target model's parameters based on the test data. When the model tuning effect meets the target, a tuning strategy is generated, solving the problem that it is difficult to quickly find the optimal tuning strategy when manually tuning the model during model switching.

[0073] According to another aspect of the embodiments of this application, this application provides a prompt-based model tuning device, such as... Figure 3 As shown, it includes:

[0074] The acquisition module 301 is used to acquire a test data set, wherein the test data set includes multiple sets of preset questions and preset answers that have a corresponding relationship;

[0075] The optimization module 302 is used to call the pre-trained prompt optimization model and optimize the first prompt of the target model using the test dataset and the prompt optimization model to obtain the second prompt.

[0076] The adjustment module 303 is used to call the parameter optimization model obtained through pre-training, and use the test dataset, the second prompt, and the parameter optimization model to adjust the model parameters of the target model to obtain the adjusted target model.

[0077] The detection module 304 is used to detect the tuning effect of the adjusted target model, and when the tuning effect reaches the expected effect, it generates the tuning strategy of the target model. The tuning strategy includes the prompt optimization strategy obtained by the prompt optimization model and the parameter adjustment strategy obtained by the parameter optimization model.

[0078] It should be noted that the acquisition module 301 in this embodiment can be used to execute step 201 in this application embodiment, the optimization module 302 in this embodiment can be used to execute step 202 in this application embodiment, the adjustment module 303 in this embodiment can be used to execute step 203 in this application embodiment, and the detection module 304 in this embodiment can be used to execute step 204 in this application embodiment.

[0079] Optionally, the optimization module 302 is specifically used to process the preset questions in the test dataset through the first prompt to obtain the first input data; input the first input data into the target model to obtain the first output result of the target model; use the prompt optimization model to compare and analyze the first output result and the preset answer to obtain the first analysis result, wherein the first analysis result includes the prompt optimization strategy, the first question type, and the first matching degree between the first output result and the preset answer; and use the prompt optimization strategy to optimize the first prompt to obtain the second prompt.

[0080] Optionally, the adjustment module 303 is specifically used to process the preset questions in the test dataset through the second prompt to obtain the second input data; input the second input data into the target model to obtain the second output result of the target model; use the parameter optimization model to compare and analyze the second output result and the preset answer to obtain the second analysis result, wherein the second analysis result includes the parameter adjustment strategy, the second question type, and the second matching degree between the second output result and the preset answer; and use the parameter adjustment strategy to adjust the model parameters of the target model to obtain the adjusted target model.

[0081] Optionally, the detection module 304 includes:

[0082] The first processing submodule is used to process the preset questions in the test dataset through the second prompt to obtain the second input data;

[0083] The second processing submodule is used to input the second input data into the adjusted target model to obtain the third output result of the adjusted target model;

[0084] The analysis submodule is used to compare and analyze the third output results using the parameter optimization model and the prompt optimization model respectively, and obtain the third analysis result;

[0085] The determination submodule is used to determine the optimization effect of the adjusted target model based on the results of the third analysis.

[0086] Optionally, the determination submodule is specifically used to determine that the tuning effect has reached the expected effect if the third analysis result indicates that the parameter optimization model has not output a parameter adjustment strategy and the prompt optimization model has not output a prompt optimization strategy; or if the third analysis result indicates that the third matching degree output by the parameter optimization model has reached the first threshold and the fourth matching degree output by the prompt optimization model has reached the second threshold.

[0087] Optionally, the device further includes an iterative optimization module, which is used to iteratively optimize the adjusted target model after detecting the optimization effect of the adjusted target model, if the optimization effect does not reach the expected effect; and to stop the optimization when the optimization effect reaches the expected effect, and save the latest obtained optimization strategy to a preset database.

[0088] Optionally, the device further includes a processing module, which is used to save the optimization strategy of the target model to a preset database after generating the optimization strategy of the target model; to call the optimization strategy from the preset database when it is necessary to switch the original model to the target model; and to optimize the target model according to the optimization strategy.

[0089] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should also be noted that the above modules, as part of a device, can operate in environments such as... Figure 1 The hardware environment shown.

[0090] According to another aspect of the embodiments of this application, this application provides an electronic device, such as... Figure 4 As shown, the system includes a memory 401, a processor 403, a communication interface 405, and a communication bus 407. The memory 401 stores a computer program that can run on the processor 403. The memory 401 and the processor 403 communicate through the communication interface 405 and the communication bus 407. When the processor 403 executes the computer program, it implements the steps of the above method.

[0091] The memory and processor in the aforementioned electronic devices communicate with each other via a communication bus and a communication interface. The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc.

[0092] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0093] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0094] According to another aspect of the embodiments of this application, a computer-readable medium having processor-executable non-volatile program code is also provided.

[0095] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.

[0096] In specific implementation, the embodiments of this application can be referred to the above embodiments and have corresponding technical effects.

[0097] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.

[0098] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0099] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0100] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0101] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0102] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0103] In addition, the functional units in the various embodiments of this application 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.

[0104] If the aforementioned function is implemented as 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 technical solution of the embodiments of this application, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks. It should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. In the absence of further restrictions, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0105] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A prompt-based model tuning method, characterized in that, include: Obtain a test data set, wherein the test data set includes multiple sets of preset questions and preset answers that have a corresponding relationship; The pre-trained prompt optimization model is invoked, and the first prompt of the target model is optimized using the test dataset and the prompt optimization model to obtain the second prompt; The pre-trained parameter optimization model is invoked, and the model parameters of the target model are adjusted using the test dataset, the second prompt, and the parameter optimization model to obtain the adjusted target model. The tuning effect of the adjusted target model is detected, and when the tuning effect reaches the expected effect, a tuning strategy for the target model is generated. The tuning strategy includes a prompt optimization strategy obtained from the prompt optimization model and a parameter adjustment strategy obtained from the parameter optimization model.

2. The method according to claim 1, characterized in that, The step of optimizing the first prompt of the target model using the test dataset and the prompt optimization model to obtain the second prompt includes: The preset question in the test dataset is processed by the first prompt to obtain the first input data; The first input data is input into the target model to obtain the first output result of the target model; The first output result and the preset answer are compared and analyzed using the prompt optimization model to obtain a first analysis result, wherein the first analysis result includes the prompt optimization strategy, the first question type, and the first matching degree between the first output result and the preset answer; The first prompt is optimized using the aforementioned prompt optimization strategy to obtain the second prompt.

3. The method according to claim 1, characterized in that, The step of adjusting the model parameters of the target model using the test dataset, the second prompt, and the parameter optimization model to obtain the adjusted target model includes: The preset question in the test dataset is processed by the second prompt to obtain the second input data; The second input data is input into the target model to obtain the second output result of the target model; The second output result and the preset answer are compared and analyzed using the parameter optimization model to obtain a second analysis result, wherein the second analysis result includes the parameter adjustment strategy, the second question type, and the second matching degree between the second output result and the preset answer; The parameter adjustment strategy is used to adjust the model parameters of the target model to obtain the adjusted target model.

4. The method according to claim 1, characterized in that, The detection of the optimization effect of the adjusted target model includes: The preset question in the test dataset is processed by the second prompt to obtain the second input data; The second input data is input into the adjusted target model to obtain the third output result of the adjusted target model; The third output result is compared and analyzed using the parameter optimization model and the prompt optimization model respectively, to obtain the third analysis result; The optimization effect of the adjusted target model is determined based on the third analysis results.

5. The method according to claim 4, characterized in that, Determining the optimization effect of the adjusted target model based on the third analysis result includes: If the third analysis result indicates that the parameter optimization model did not output the parameter adjustment strategy, and the prompt optimization model did not output the prompt optimization strategy, then it is determined that the tuning effect has achieved the expected effect; or If the third analysis result indicates that the third matching degree output by the parameter optimization model reaches the first threshold, and the fourth matching degree output by the prompt optimization model reaches the second threshold, then it is determined that the optimization effect has achieved the desired effect.

6. The method according to claim 1, characterized in that, After detecting the tuning effect of the adjusted target model, the method further includes: If the optimization effect does not achieve the desired effect, the adjusted target model is iteratively optimized. Once the optimization effect is detected to have achieved the desired effect, optimization is stopped, and the latest optimization strategy is saved to the preset database.

7. The method according to claim 1, characterized in that, After generating the tuning strategy for the target model, the method further includes: Save the optimization strategy of the target model to a preset database; In cases where it is necessary to switch the original model to the target model, the optimization strategy is invoked from the preset database; The target model is tuned according to the tuning strategy described above.

8. A prompt-based model tuning device, characterized in that, include: The acquisition module is used to acquire a test data set, wherein the test data set includes multiple sets of preset questions and preset answers that have a corresponding relationship; The optimization module is used to call the pre-trained prompt optimization model and optimize the first prompt of the target model using the test dataset and the prompt optimization model to obtain the second prompt. The adjustment module is used to call the parameter optimization model obtained through pre-training, and use the test dataset, the second prompt, and the parameter optimization model to adjust the model parameters of the target model to obtain the adjusted target model; The detection module is used to detect the optimization effect of the adjusted target model, and when the optimization effect reaches the expected effect, generate the optimization strategy of the target model, wherein the optimization strategy includes the prompt optimization strategy obtained by the prompt optimization model and the parameter adjustment strategy obtained by the parameter optimization model.

9. An electronic device comprising a memory, a processor, a communication interface, and a communication bus, wherein the memory stores a computer program executable on the processor, and the memory and the processor communicate via the communication bus and the communication interface, characterized in that... When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable medium having processor-executable non-volatile program code, characterized in that, The program code causes the processor to execute the method of any one of claims 1 to 7.