A method, apparatus, device, storage medium, and product for adjusting prompt text.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2026-08-14
AI Technical Summary
[0059]本申请实施例中,获取待调整的提示文本和M个样本文本集合对应的提示文本类别,基于待调整的提示文本和M个样本文本集合对应的提示文本类别,确定待调整的提示文本对应的目标调整规则,目标调整规则是基于目标样本文本集合生成的,待调整的提示文本所属的类别包含于目标样本文本集合对应的提示文本类别中,按照目标调整规则对待调整的提示文本进行调整,得到待调整的提示文本的调整结果。可见,通过不同调整规则对不同类别的提示文本进行针对性调整,可以使得提示文本的调整过程更加灵活和具有针对性,从而提高调整结果的质量。
Smart Images

Figure CN122572437A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a method for adjusting prompt text, a device for adjusting prompt text, a computer device, a computer-readable storage medium, and a product for adjusting prompt text. Background Technology
[0002] With advancements in scientific research, generative modeling technology has developed rapidly. Generative models, trained on large-scale text data, can understand and generate natural language, performing various language tasks such as text generation, translation, question answering, and dialogue. By inputting prompt text into a large language model, multimodal content including text, images, audio, and video can be generated. Research has found that the input prompt text has a significant impact on the quality of the generative model's output; therefore, improving the quality of the prompt text (to make the generative model output more consistent with expectations) has become a hot research topic. Summary of the Invention
[0003] This application provides a method, apparatus, device, computer-readable storage medium, and product for adjusting prompt text, which can make targeted adjustments to the prompt text to be adjusted, thereby improving the quality of the adjustment results.
[0004] On the one hand, embodiments of this application provide a method for adjusting prompt text, including:
[0005] Get the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, where M is an integer greater than 1;
[0006] Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, the target adjustment rule corresponding to the prompt text to be adjusted is determined. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text category corresponding to the target sample text set.
[0007] The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted. The adjustment result is used to guide the generation model to generate the expected content of the prompt text to be adjusted.
[0008] On one hand, embodiments of this application provide a prompt text adjustment device, which includes:
[0009] The acquisition unit is used to acquire the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, where M is an integer greater than 1;
[0010] The processing unit is used to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text categories corresponding to the target sample text set.
[0011] And to adjust the prompt text to be adjusted according to the target adjustment rules, to obtain the adjustment result of the prompt text to be adjusted, and the adjustment result is used to guide the generation model to generate the expected content of the prompt text to be adjusted.
[0012] In one implementation, the processing unit is configured to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, specifically configured to:
[0013] The prompt text to be adjusted is categorized to determine its category.
[0014] Based on the inclusion relationship between the category of the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, the target sample text set corresponding to the prompt text to be adjusted is determined;
[0015] Obtain the target sample text set;
[0016] Extract text features from the target sample text set and generate target adjustment rules based on the text features.
[0017] In one implementation, the processing unit is configured to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and a set of M sample texts, specifically configured to:
[0018] Obtain a set of M sample texts;
[0019] Extract the text features of each sample text set, and generate M adjustment rules based on the text features of the M sample text sets;
[0020] The matching degree between the prompt text to be adjusted and M adjustment rules is predicted by the rule prediction model to obtain the target adjustment rule corresponding to the prompt text to be adjusted.
[0021] In one implementation, each sample text set is associated with at least one reference text, and the reference text associated with any sample text set corresponds one-to-one with the prompt text category corresponding to that sample text set; the processing unit is used to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and M sample text sets, specifically for:
[0022] Calculate the similarity between the prompt text to be adjusted and the reference text associated with each sample text set;
[0023] If the similarity between the prompt text to be adjusted and any reference text associated with the i-th sample text set is greater than the first similarity threshold, then the i-th sample text set is determined as the target sample text set corresponding to the prompt text to be adjusted, where i is a positive integer less than or equal to M.
[0024] Obtain the target sample text set;
[0025] Extract text features from the target sample text set and generate target adjustment rules based on the text features.
[0026] In one implementation, the processing unit is configured to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0027] The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain the adjusted prompt text;
[0028] Analyze the semantic similarity between the prompt text to be adjusted and the adjusted prompt text;
[0029] If the semantic similarity between the prompt text to be adjusted and the adjusted prompt text is greater than the second similarity threshold, then the adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted.
[0030] In one implementation, the processing unit is configured to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0031] Adjust the prompt text to be adjusted according to the target adjustment rules to obtain at least two adjusted prompt texts;
[0032] Analyze the semantic similarity between the prompt text to be adjusted and each adjusted prompt text;
[0033] The j-th adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted. The semantic similarity between the j-th adjusted prompt text and the prompt text to be adjusted is greater than the semantic similarity between other adjusted prompt texts and the prompt text to be adjusted. j is a positive integer less than or equal to M.
[0034] In one implementation, the processing unit is configured to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0035] Adjust the prompt text to be adjusted according to the adjustment dimensions indicated by the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted;
[0036] The adjustment dimensions include the dimensions of accuracy of expression, logical coherence, conciseness, and format standardization.
[0037] In one implementation, each adjustment rule is associated with a different rewriting template and a customization strategy; the processing unit is used to adjust the prompt text to be adjusted according to the target adjustment rule to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0038] The prompt text to be adjusted is rewritten according to the rewriting template associated with the target adjustment rules, resulting in the rewritten prompt text;
[0039] By using a customized strategy associated with the target adjustment rules, the rewritten prompt text is partially adjusted to obtain the adjusted prompt text.
[0040] In one implementation, the number of target adjustment rules is N, where N is an integer greater than 1; the processing unit is used to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0041] Based on the matching degree between each target adjustment rule and the prompt text to be adjusted, the N target adjustment rules are weighted and fused to obtain a fused rule. The prompt text to be adjusted is then adjusted based on this fused rule to obtain the adjusted prompt text; or,
[0042] The adjustment results of the prompt text to be adjusted are obtained by iteratively adjusting the prompt text using N target adjustment rules.
[0043] In one embodiment, the processing unit is further configured to:
[0044] The generative model is invoked based on the adjustment results to obtain the first generated result;
[0045] The quality of the first generated result is evaluated to obtain the quality evaluation result of the first generated result.
[0046] In one embodiment, the processing unit is configured to perform a quality assessment on the first generated result to obtain a quality assessment result of the first generated result, specifically configured to:
[0047] The generation model is invoked to obtain a second generated result based on the prompt text to be adjusted; the quality of the first and second generated results is compared to obtain a quality evaluation result for the first generated result; or,
[0048] The quality of the first generated result is evaluated from at least one evaluation dimension to obtain the quality evaluation result of the first generated result; wherein, the evaluation dimensions include the coherence dimension, the accuracy dimension, and the innovation dimension.
[0049] In one embodiment, the processing unit is further configured to:
[0050] If the quality assessment results indicate that the first generated result meets the quality requirements, the adjustment result will be marked as sample prompt text;
[0051] If the quality assessment results indicate that the first generated result does not meet the quality requirements, the target adjustment rules will be updated.
[0052] In one embodiment, the processing unit is further configured to:
[0053] In response to the annotation operation of the adjustment results, the adjustment results are added to the target sample text set.
[0054] Accordingly, this application provides a computer device comprising:
[0055] Memory, which stores computer programs;
[0056] The processor is used to load computer programs to implement the above-mentioned method for adjusting the prompt text.
[0057] Accordingly, this application provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by the above-described prompt text adjustment method.
[0058] Accordingly, this application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned prompt text adjustment method.
[0059] In this embodiment, the prompt text to be adjusted and the prompt text categories corresponding to M sample text sets are obtained. Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, a target adjustment rule corresponding to the prompt text to be adjusted is determined. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text categories corresponding to the target sample text set. The prompt text to be adjusted is adjusted according to the target adjustment rule to obtain the adjustment result of the prompt text to be adjusted. It can be seen that by using different adjustment rules to make targeted adjustments to prompt text of different categories, the prompt text adjustment process can be made more flexible and targeted, thereby improving the quality of the adjustment result. Attached Figure Description
[0060] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0061] Figure 1 A scenario diagram illustrating the adjustment of prompt text provided in this application embodiment;
[0062] Figure 2 A flowchart illustrating a method for adjusting prompt text provided in an embodiment of this application;
[0063] Figure 3a A schematic diagram illustrating the correspondence between a sample text set and text categories provided in an embodiment of this application;
[0064] Figure 3b A flowchart for determining adjustment rules is provided in an embodiment of this application;
[0065] Figure 3c A correspondence diagram between a set of reference texts and a set of sample texts provided for embodiments of this application;
[0066] Figure 3d A schematic diagram of an adjustment process provided in an embodiment of this application;
[0067] Figure 3e This is a schematic diagram illustrating another adjustment process provided in an embodiment of this application;
[0068] Figure 4 A flowchart illustrating another method for adjusting prompt text provided in this application embodiment;
[0069] Figure 5a This application provides a schematic diagram of the module relationships of a prompt text adjustment system.
[0070] Figure 5b An example diagram illustrating the adjustment of prompt text provided in this application embodiment;
[0071] Figure 6 This is a schematic diagram of the structure of a prompt text adjustment device provided in an embodiment of this application;
[0072] Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0073] 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, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0074] In generative artificial intelligence, prompt text is the input content that guides the output of a generative model. It is usually a description or instruction. The quality of the prompt text directly affects the quality of the generated result. For example, if the prompt text is unclear, it may cause the generative model to misinterpret the key points of the prompt text and generate information that does not meet expectations (such as irrelevant answers or missing key content).
[0075] This application provides a suggestion text adjustment scheme, which can make targeted adjustments to the suggestion text to be adjusted, thereby improving the quality of the adjusted suggestion text. Figure 1 A scenario diagram for adjusting prompt text provided in an embodiment of this application, such as... Figure 1As shown, the prompt text adjustment scenario provided in this application includes a terminal device 101 and a server 102. The prompt text adjustment scheme provided in this application can be executed by either the terminal device 101 or the server 102. It is understood that when the prompt text adjustment scheme provided in this application is executed by the terminal device 101, the prompt text adjustment scenario may not include the server 102. The terminal device may include, but is not limited to: smartphones (such as Android phones, iOS phones, etc.), tablet computers, portable personal computers, mobile internet devices (MIDs), smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, wearable devices, etc., and this application embodiment does not limit this; the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, and this application embodiment does not limit this.
[0076] It should be noted that, Figure 1 The number of terminal devices and servers is for illustrative purposes only and does not constitute an actual limitation of this application. Terminal device 101 and server 102 can be connected via wired or wireless means, and this application does not impose any restrictions on this.
[0077] The general process of the prompt text adjustment scheme provided in this application is as follows:
[0078] (1) Server 102 obtains the prompt text to be adjusted and the prompt text categories corresponding to M sample text sets; wherein, each sample text set can correspond to one or more prompt text categories, different sample text sets are used to generate different adjustment rules, and each adjustment rule is used to adjust the prompt text of the corresponding category. Since different adjustment rules are based on different sample text sets, there are differences between the adjustment rules (such as different adjustment focuses, different dimensions, different templates used, etc.), and M is an integer greater than 1.
[0079] (2) Server 102 determines the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets; wherein, the target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text category corresponding to the target sample text set. The category division criteria can be dynamically adjusted according to needs, and this application does not limit this; for example, according to the scenario, it can be divided into text generation category, code generation category, image generation category, etc.; according to the ability, it can be divided into logical reasoning category, creative category, philosophical category, etc.
[0080] It is understandable that when a sample text set corresponds to multiple prompt text categories, it means that the adjustment rules generated based on the sample text set can be used to adjust the prompt texts of multiple categories. For example, if sample text set A corresponds to the first prompt text category and the second prompt text category, then adjustment rule 1 generated based on sample text set A can be used to adjust the prompt texts of the first category, and it can also be used to adjust the prompt texts of the second category.
[0081] (3) Server 102 adjusts the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted; wherein, the adjustment result is used to guide the generation model to generate the expected content of the prompt text to be adjusted. After obtaining the adjustment result, server 102 can directly return the adjustment result to terminal device 101, or it can use the adjustment result as input to the generation model and return the corresponding generation result to terminal device 101.
[0082] In this embodiment, the prompt text to be adjusted and the prompt text categories corresponding to M sample text sets are obtained. Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, a target adjustment rule corresponding to the prompt text to be adjusted is determined. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text categories corresponding to the target sample text set. The prompt text to be adjusted is adjusted according to the target adjustment rule to obtain the adjustment result of the prompt text to be adjusted. It can be seen that by using different adjustment rules to make targeted adjustments to prompt text of different categories, the prompt text adjustment process can be made more flexible and targeted, thereby improving the quality of the adjustment result.
[0083] Based on the above-mentioned prompt text adjustment scheme, this application proposes a more detailed prompt text adjustment method. The prompt text adjustment method proposed in this application will be described in detail below with reference to the accompanying drawings.
[0084] Please see Figure 2 , Figure 2A flowchart illustrating a method for adjusting prompt text provided in this application embodiment, wherein the method can be executed by a computer device; for example, by... Figure 1 The terminal device 101 or server 102 shown executes this. For example... Figure 2 As shown, the method for adjusting the prompt text may include the following steps S201-S203:
[0085] S201. Obtain the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets.
[0086] The prompt text serves as input data for the generative model, guiding it to output the generated result. Specifically, the prompt text can be words, sentences, paragraphs, instructions, etc. Besides being directly input, the prompt text can also be extracted from multimodal data such as audio, video, and images; this application does not impose any restrictions on this. In other words, the prompt text adjustment method provided in this application is equally applicable to processing multimodal data.
[0087] Each sample text set includes at least one sample cue text. Each sample text set corresponds to at least one cue text category. Different sample text sets are used to generate different adjustment rules, and each adjustment rule is used to adjust the cue text of the corresponding category. M is an integer greater than 1.
[0088] Figure 3a This diagram illustrates the correspondence between a sample text set and text categories, as provided in an embodiment of this application. Figure 3a As shown, sample text set A corresponds to prompt text categories 1, 7, and 9. This means that adjustment rule A generated based on sample text set A can be used to adjust prompt text belonging to prompt text category 1, prompt text belonging to prompt text category 7, and prompt text belonging to prompt text category 9. Sample text set B corresponds to prompt text category 3. This means that adjustment rule B generated based on sample text set B only applies to prompt text belonging to prompt text category 3. Sample text set C corresponds to prompt text categories 8, 9, and n (where n is an integer greater than 9). Both sample text sets A and C correspond to prompt text category 9, indicating that prompt text belonging to prompt text category 7 can be adjusted using adjustment rule A generated based on sample text set A, adjustment rule C generated based on sample text set C, or a combination of adjustment rules A and C.
[0089] In one embodiment, the M sample text sets can be updated in real time, and the sample text sets can also be associated with customized rules (such as expert-defined rules). That is, in addition to updating the sample prompt texts contained in the sample text sets, the customized rules associated with the sample text sets can also be updated. In one implementation, a computer device extracts text features from the sample text sets, generates adjustment rules based on the text features, and then combines the customized rules associated with the sample text sets with the adjustment rules to obtain complete adjustment rules.
[0090] It is evident that by updating the sample text set, we can ensure that the adjustment rules generated based on the sample text set can adapt to changes in the application environment and requirements, and can be extended (such as by associating with customized rules), thereby providing a guarantee for the adjustment process of subsequent prompt texts to be adjusted.
[0091] S202. Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, determine the target adjustment rule corresponding to the prompt text to be adjusted.
[0092] The target adjustment rules are generated based on the target sample text set. The category to which the prompt text to be adjusted belongs is included in the prompt text category corresponding to the target sample text set. In one implementation, each sample text set corresponds to a prompt text category, and (in the case of category matching) a unique sample text set can be determined by the category to which the prompt text to be adjusted belongs.
[0093] In one implementation, the computer device can first identify the category to which the prompt text to be adjusted belongs, then determine the corresponding target sample text set based on the category to which the prompt text to be adjusted belongs, and generate the target adjustment rule corresponding to the prompt text to be adjusted based on the target sample text set.
[0094] Figure 3b This is a flowchart illustrating an adjustment rule determination method provided in an embodiment of this application. Figure 3bAs shown, the computer device calls a large language model (or classifier, etc.) to identify the category of the prompt text to be adjusted, thus obtaining the category to which the prompt text belongs. Then, based on the inclusion relationship between the category to which the prompt text belongs and the prompt text categories corresponding to M sample text sets, the target sample text set corresponding to the prompt text to be adjusted is determined. Specifically, if the category to which the prompt text belongs is included in the prompt text category corresponding to the sample text set, the computer device determines that sample text set as the target sample text set. After determining the target sample text set corresponding to the prompt text to be adjusted, the computer device acquires the target sample text set, extracts the text features of the target sample text set, and generates target adjustment rules based on these text features. For example, assuming that the text features of sample text set 1 indicate that the sample prompt texts in sample text set 1 each individually indicate the subject, object, and relation, the adjustment rules generated by the computer device based on these text features may include: extracting the subject, object, and relation of the prompt text and indicating them individually. Accordingly, if the category to which the prompt text to be adjusted belongs is not included in the prompt text category corresponding to any sample text set, the computer device can determine the preset adjustment rule as the target adjustment rule corresponding to the prompt text to be adjusted.
[0095] It is evident that by first determining the category to which the prompt text to be adjusted belongs, and then generating the target adjustment rule, the efficiency of obtaining the adjustment rule can be improved (there is no need to obtain all sample sets and generate adjustment rules corresponding to all sample sets), and the timeliness of the adjustment rule can be ensured (if the adjustment rule is generated first and then the adjustment rule is matched by category, the sample text set corresponding to the adjustment rule may be updated during the matching process).
[0096] In another implementation, the computer device can generate M adjustment rules corresponding to M sample text sets, and directly predict the target adjustment rule among the M adjustment rules that corresponds to the prompt text to be adjusted. In one embodiment, the computer device acquires M sample text sets, extracts text features from each sample text set, and generates M adjustment rules based on the text features of the M sample text sets. Then, the computer device uses a rule prediction model to predict the matching degree between the prompt text to be adjusted and the M adjustment rules to obtain the target adjustment rule corresponding to the prompt text to be adjusted. In one embodiment, if the matching degree between any adjustment rule and the prompt text to be adjusted is greater than a matching degree threshold, the computer device determines that adjustment rule as the target adjustment rule corresponding to the prompt text to be adjusted. Correspondingly, if the matching degree between each adjustment rule and the prompt text to be adjusted is less than or equal to the matching degree threshold, the computer device determines a preset adjustment rule as the target adjustment rule corresponding to the prompt text to be adjusted.
[0097] Similar to the above method, the computer device can also calculate the matching degree between the prompt text to be adjusted and the set of M sample texts, and then determine the target sample text set corresponding to the prompt text to be adjusted based on the matching degree, thereby obtaining the target adjustment rule corresponding to the prompt text to be adjusted.
[0098] Compared to directly determining the target adjustment rules by category, the matching degree prediction method can more fully explore the hidden relationships between the prompt text to be adjusted and various adjustment rules, and considers more comprehensive factors.
[0099] In another embodiment, each sample text set is associated with at least one reference text, and the reference text associated with any sample text set corresponds one-to-one with the prompt text category corresponding to that sample text set. Figure 3c This is a diagram illustrating the correspondence between a set of reference texts and a set of sample texts provided for embodiments of this application. For example... Figure 3b As shown, sample text set A corresponds to prompt text categories 1, 7, and 9. Prompt text category 1 corresponds to reference text 1, prompt text category 7 corresponds to reference text 7, and prompt text category 9 corresponds to reference text 9_1 (i.e., the reference texts associated with sample text set A are reference text 1, reference text 7, and reference text 9_1). Similarly, sample text set C corresponds to prompt text categories 8, 9-n (n is an integer greater than 9). Prompt text category 8 corresponds to reference text 8, prompt text category 9 corresponds to reference text 9_2, and so on, with prompt text category n corresponding to reference text n (i.e., the reference texts associated with sample text set C are reference text 8, reference text 9_2-n). It is evident that although both sample text sets A and C correspond to prompt text category 9, due to differences between them, they each correspond to different reference texts (i.e., reference text 9_1 and reference text 9_2).
[0100] In one embodiment, the computer device calculates the similarity between the prompt text to be adjusted and the reference text associated with each sample text set. If the similarity between the prompt text to be adjusted and any reference text associated with the i-th sample text set is greater than a first similarity threshold, the computer device determines the i-th sample text set as the target sample text set corresponding to the prompt text to be adjusted, where i is a positive integer less than or equal to M. The first similarity threshold can be a fixed value or a dynamic value, and this application does not impose any restrictions on it. Next, the computer device acquires the target sample text set, extracts the text features of the target sample text set, and generates target adjustment rules based on the text features.
[0101] As can be seen, when the category to which the prompt text to be adjusted belongs is included in multiple adjustment rules, the adjustment rules can be further filtered by the corresponding sample prompt text.
[0102] S203. Adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted.
[0103] The adjustment results are used to guide the generative model in generating the desired content and prompt text to be adjusted.
[0104] In one implementation, the target adjustment rule indicates at least one adjustment dimension (e.g., each adjustment dimension may be included in the adjustment rule as one or more adjustment rules). The adjustment dimension may specifically be a dimension of accuracy of expression, logical coherence, conciseness, or format standardization, etc. The computer device adjusts the prompt text to be adjusted according to (at least one) adjustment dimension indicated by the target adjustment rule, thereby obtaining the adjusted result of the prompt text. Figure 3d This is a schematic diagram illustrating an adjustment process provided in an embodiment of this application. Figure 3d As shown, adjustment rule 2 is the target adjustment rule corresponding to the prompt text to be adjusted. The computer device adjusts the prompt text to be adjusted based on the adjustment details in adjustment rule 2 to obtain the adjustment result. In one embodiment, the computer device predicts the score of the prompt text to be adjusted in each adjustment dimension. If the score of the prompt text to be adjusted meets the target adjustment dimension, no adjustment is made to the prompt text to be adjusted in the target dimension; correspondingly, if the score of the prompt text to be adjusted does not meet the target adjustment dimension, the prompt text to be adjusted is adjusted in the target dimension.
[0105] In another implementation, each adjustment rule is associated with a different rewriting template and a customization strategy. The computer device rewrites the prompt text to be adjusted according to the rewriting template associated with the target adjustment rule, obtaining the rewritten prompt text (which can be understood as performing a global adjustment); then, the customized strategy associated with the target adjustment rule is used to perform local adjustments on the rewritten prompt text, obtaining the adjusted result of the prompt text to be adjusted. Figure 3e This is a schematic diagram illustrating another adjustment process provided for an embodiment of this application. For example... Figure 3e As shown, adjustment rule 2 is the target adjustment rule corresponding to the prompt text to be adjusted. The computer device first rewrites the prompt text to be adjusted based on template 2 associated with adjustment rule 2 (global adjustment), and then performs local adjustments (fine-tuning) on the rewritten prompt text through the customization strategy associated with adjustment rule 2 to obtain the adjustment result of the prompt text to be adjusted.
[0106] In another embodiment, the number of target adjustment rules is N, where N is an integer greater than 1. The computer device performs a comprehensive adjustment on the prompt text to be adjusted based on the N target adjustment rules to obtain the adjusted result of the prompt text. In one embodiment, the computer device performs a weighted fusion of the N target adjustment rules based on the matching degree between each target adjustment rule and the prompt text to be adjusted to obtain a fusion rule, and adjusts the prompt text to be adjusted based on the fusion rule to obtain the adjusted result of the prompt text. In another embodiment, the computer device iteratively adjusts the prompt text to be adjusted using the N target adjustment rules (e.g., each target adjustment rule corresponds to one iterative adjustment) to obtain the adjusted result of the prompt text.
[0107] In this embodiment, the prompt text to be adjusted and the prompt text categories corresponding to M sample text sets are obtained. Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, a target adjustment rule corresponding to the prompt text to be adjusted is determined. The target adjustment rule is generated based on the target sample text set. The category to which the prompt text to be adjusted belongs is included in the prompt text categories corresponding to the target sample text set. The prompt text to be adjusted is adjusted according to the target adjustment rule to obtain the adjustment result of the prompt text to be adjusted. It can be seen that by using different adjustment rules to make targeted adjustments to different categories of prompt text, the adjustment process of prompt text can be made more flexible and targeted, thereby improving the quality of the adjustment result. In addition, by updating the sample text set, it can be ensured that the adjustment rules generated based on the sample text set can adapt to changes in the application environment and requirements, and can be extended (such as by associating customized rules), thereby providing a guarantee for the subsequent adjustment process of the prompt text to be adjusted. By determining the category first and then determining the adjustment rule, the efficiency of obtaining the adjustment rule can be further improved (without generating adjustment rules for all sample text sets) and the timeliness of the adjustment rule can be ensured.
[0108] Please see Figure 4 , Figure 4 A flowchart illustrating another method for adjusting prompt text provided in this application embodiment, wherein the method can be executed by a computer device; for example, by... Figure 1 The terminal device 101 or server 102 shown executes this. For example... Figure 4 As shown, the method for adjusting the prompt text may include the following steps S401-S406:
[0109] S401. Obtain the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets.
[0110] S402. Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, determine the target adjustment rule corresponding to the prompt text to be adjusted.
[0111] For detailed implementation methods of steps S401 and S402, please refer to Figure 2 The implementation methods in steps S201 and S202 will not be described in detail here.
[0112] S403. Adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjusted prompt text.
[0113] In one implementation, the computer device adjusts the prompt text to be adjusted according to the target adjustment rules to obtain at least one adjusted prompt text.
[0114] S404. Based on the adjusted prompt text, determine the adjustment result of the prompt text to be adjusted.
[0115] In one implementation, the computer device determines the adjustment result of the prompt text to be adjusted based on the semantic similarity between the prompt text to be adjusted and the adjusted prompt text, and a second similarity threshold. Specifically, if the semantic similarity between the prompt text to be adjusted and the adjusted prompt text is greater than the second similarity threshold, the computer device determines the adjusted prompt text as the adjustment result of the prompt text to be adjusted. Correspondingly, if the semantic similarity between the prompt text to be adjusted and the adjusted prompt text is less than or equal to the second similarity threshold, the computer device may regenerate the adjusted prompt text or keep the prompt text to be adjusted unchanged.
[0116] In another implementation, the number of adjusted prompt texts is greater than 1. The computer device selects the prompt text with the highest semantic similarity from the adjusted prompt texts as the adjustment result of the prompt text to be adjusted. Specifically, the computer device analyzes the semantic similarity between the prompt text to be adjusted and each adjusted prompt text, and determines the j-th adjusted prompt text as the adjustment result of the prompt text to be adjusted. The semantic similarity between the j-th adjusted prompt text and the prompt text to be adjusted is greater than the semantic similarity between the other adjusted prompt texts and the prompt text to be adjusted, where j is a positive integer less than or equal to M.
[0117] In another implementation, in response to a labeling operation on the adjustment result (such as marking the adjustment result as sample prompt text), the computer device adds the adjustment result to the target sample text set. This implementation enables result feedback, prompting the sample text set to be continuously updated, thereby obtaining more accurate adjustment rules.
[0118] S405. Based on the adjustment results, the first generated result is obtained.
[0119] In one implementation, the computer device inputs the adjustment result as input data into the generation model to obtain the first generation result output by the generation model.
[0120] S406. Perform a quality assessment on the first generated result to obtain the quality assessment result of the first generated result.
[0121] In one implementation, the computer device can use a second generated result as a reference to evaluate the quality of the first generated result; wherein the second generated result is obtained by inputting the prompt text to be adjusted into the generation model. In one embodiment, the computer device calls the generation model to obtain the second generated result based on the prompt text to be adjusted, and compares the quality of the first generated result and the second generated result (such as satisfaction, completeness, clarity, accuracy, etc.) to obtain a quality evaluation result of the first generated result.
[0122] In another implementation, the computer device evaluates the quality of the first generated result from at least one evaluation dimension to obtain a quality evaluation result of the first generated result; wherein the evaluation dimensions include coherence dimension, accuracy dimension, and innovativeness dimension.
[0123] Furthermore, after obtaining the quality evaluation results, if the quality evaluation results indicate that the first generated result meets the quality requirements, the computer device can label the adjustment result as sample prompt text (and add the adjustment result to the target sample text set); if the quality evaluation results indicate that the first generated result does not meet the quality requirements, the computer device can update the target adjustment rules (i.e., update the adjustment rules by using the quality of the generated result output by the generation model).
[0124] In another embodiment, after obtaining the adjustment result, in addition to evaluating the quality of the adjustment result based on the adjustment result, the computer device can also evaluate the quality of the adjustment result in combination with the first generated result (i.e., comprehensively consider the adjustment result from two dimensions).
[0125] The above-mentioned method for adjusting prompt text can also be implemented through a corresponding prompt text adjustment system, which may contain multiple modules. Figure 5a This is a schematic diagram illustrating the module relationship of a prompt text adjustment system provided in an embodiment of this application. For example... Figure 5aAs shown, the prompt text adjustment system includes a category recognition module, an adjustment rule generation module, a prompt text rewriting module, a semantic similarity verification module, and a quality evaluation module. After obtaining the prompt text to be adjusted, the category recognition module performs category recognition. If the category of the prompt text to be adjusted is successfully identified, and this category is included in the prompt text category corresponding to at least one sample text set, the adjustment rule generation module obtains the corresponding sample text set (i.e., the target sample text set) and generates adjustment rules based on this sample text set. Conversely, if the category of the prompt text to be adjusted is not successfully identified, or the identified category is not included in the prompt text category corresponding to any sample text set, the adjustment rule generation module obtains a preset sample text set and generates adjustment rules based on this sample text set; or, it directly obtains the preset adjustment rules as the adjustment rules corresponding to the prompt text to be adjusted. After determining the adjustment rules corresponding to the prompt text to be adjusted, the prompt text rewriting module is called to adjust (rewrite) the prompt text to be adjusted according to the adjustment rules corresponding to the prompt text to be adjusted, resulting in the adjusted prompt text. Furthermore, after obtaining the adjusted prompt text, the semantic similarity verification module performs semantic consistency verification on the prompt text to be adjusted and the adjusted prompt text. If the adjusted prompt text fails the semantic consistency verification, the adjustment rules can be adjusted, and the prompt text to be adjusted can be readjusted based on the adjusted adjustment rules until the adjusted prompt text passes the semantic consistency verification; if the adjusted prompt text passes the semantic consistency verification, the adjusted prompt text is input into the generation model to obtain the generation result. Then, the quality evaluation module performs a quality evaluation on the generation result to obtain the quality evaluation result of the generation result. Further, if the quality evaluation result indicates that the generation result meets the quality requirements, the adjusted prompt text can be labeled and added to the corresponding sample text set (as sample prompt text); if the quality evaluation result indicates that the generation result does not meet the quality requirements, the corresponding adjustment rules can be updated.
[0126] Figure 5b This is an example diagram illustrating the adjustment of prompt text provided in an embodiment of this application. For example... Figure 5bAs shown, assuming the prompt text to be adjusted is "Please write an article about the future of artificial intelligence", the computer device first performs category recognition on the prompt text, determining that the category of the prompt text is "text generation". Then, based on the recognized category, it determines the target adjustment rule corresponding to the prompt text to be adjusted. For example, it obtains the corresponding sample text set based on the recognized category, and then generates the target adjustment rule based on the sample text set. In this example, the target adjustment rule is: (1) Clarity and accuracy: Clearly define the topic and output goal, and avoid vague expressions. (2) Thought chain and logic: The prompt words should contain clear logical thinking to ensure that the generated content is coherent. (3) Formatting: There should be clear article structure guidance, such as introduction, body, and conclusion. Then, the prompt text to be adjusted is adjusted according to the target adjustment rule, and the adjusted prompt text is "Please write an article about the future development trend of artificial intelligence. The content should include an introduction, the current state of technology, future technological challenges and possible innovation directions, and finally give a conclusion". After obtaining the adjusted prompt text, the computer device can also perform semantic consistency verification and quality evaluation to ensure the quality of the adjusted prompt text.
[0127] In this embodiment, by automatically identifying the category of the prompt text to be adjusted, targeted adjustment rules are determined, and the prompt text is automatically adjusted according to these rules. This improves the optimization efficiency of the prompt text and makes the adjusted prompt text more accurate and consistent with the object's initial intent. By performing semantic consistency verification on the prompt text to be adjusted and the adjusted prompt text, it is ensured that the adjusted prompt text is semantically consistent with the prompt text to be adjusted, thereby avoiding the risk of generated content deviating from the object's intended meaning. By continuously updating and expanding the sample text set, the adjustment rules can be dynamically updated, ensuring that the adjustment rules can adapt to changes in object requirements and different scenarios.
[0128] The methods of the embodiments of this application have been described in detail above. In order to facilitate better implementation of the above solutions of the embodiments of this application, the apparatus of the embodiments of this application is provided below.
[0129] Please see Figure 6 , Figure 6 This is a schematic diagram of a prompt text adjustment device provided in an embodiment of this application. Figure 6 The indicated prompt text adjustment device can be mounted in a computer device, which may specifically be a terminal device or a server. Figure 6 The indicated prompt text adjustment device can be used to perform the above. Figure 2 and Figure 4 Some or all of the functionality described in the method embodiments. Please refer to [link / reference]. Figure 6 The prompt text adjustment device includes:
[0130] The acquisition unit 601 is used to acquire the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, where M is an integer greater than 1;
[0131] The processing unit 602 is used to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text categories corresponding to the target sample text set.
[0132] And to adjust the prompt text to be adjusted according to the target adjustment rules, to obtain the adjustment result of the prompt text to be adjusted, and the adjustment result is used to guide the generation model to generate the expected content of the prompt text to be adjusted.
[0133] In one implementation, the processing unit 602 is configured to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, specifically configured to:
[0134] The prompt text to be adjusted is categorized to determine its category.
[0135] Based on the inclusion relationship between the category of the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, the target sample text set corresponding to the prompt text to be adjusted is determined;
[0136] Obtain the target sample text set;
[0137] Extract text features from the target sample text set and generate target adjustment rules based on the text features.
[0138] In one implementation, the processing unit 602 is configured to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and a set of M sample texts, specifically configured to:
[0139] Obtain a set of M sample texts;
[0140] Extract the text features of each sample text set, and generate M adjustment rules based on the text features of the M sample text sets;
[0141] The matching degree between the prompt text to be adjusted and M adjustment rules is predicted by the rule prediction model to obtain the target adjustment rule corresponding to the prompt text to be adjusted.
[0142] In one implementation, each sample text set is associated with at least one reference text, and the reference text associated with any sample text set corresponds one-to-one with the prompt text category corresponding to that sample text set; the processing unit 602 is used to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and M sample text sets, specifically for:
[0143] Calculate the similarity between the prompt text to be adjusted and the reference text associated with each sample text set;
[0144] If the similarity between the prompt text to be adjusted and any reference text associated with the i-th sample text set is greater than the first similarity threshold, then the i-th sample text set is determined as the target sample text set corresponding to the prompt text to be adjusted, where i is a positive integer less than or equal to M.
[0145] Obtain the target sample text set;
[0146] Extract text features from the target sample text set and generate target adjustment rules based on the text features.
[0147] In one implementation, the processing unit 602 is configured to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0148] The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain the adjusted prompt text;
[0149] Analyze the semantic similarity between the prompt text to be adjusted and the adjusted prompt text;
[0150] If the semantic similarity between the prompt text to be adjusted and the adjusted prompt text is greater than the second similarity threshold, then the adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted.
[0151] In one implementation, the processing unit 602 is configured to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0152] Adjust the prompt text to be adjusted according to the target adjustment rules to obtain at least two adjusted prompt texts;
[0153] Analyze the semantic similarity between the prompt text to be adjusted and each adjusted prompt text;
[0154] The j-th adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted. The semantic similarity between the j-th adjusted prompt text and the prompt text to be adjusted is greater than the semantic similarity between other adjusted prompt texts and the prompt text to be adjusted. j is a positive integer less than or equal to M.
[0155] In one implementation, the processing unit 602 is configured to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0156] Adjust the prompt text to be adjusted according to the adjustment dimensions indicated by the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted;
[0157] The adjustment dimensions include the dimensions of accuracy of expression, logical coherence, conciseness, and format standardization.
[0158] In one implementation, each adjustment rule is associated with a different rewriting template and a customization strategy; the processing unit 602 is used to adjust the prompt text to be adjusted according to the target adjustment rule to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0159] The prompt text to be adjusted is rewritten according to the rewriting template associated with the target adjustment rules, resulting in the rewritten prompt text;
[0160] By using a customized strategy associated with the target adjustment rules, the rewritten prompt text is partially adjusted to obtain the adjusted prompt text.
[0161] In one implementation, the number of target adjustment rules is N, where N is an integer greater than 1; the processing unit 602 is used to adjust the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted, specifically for:
[0162] Based on the matching degree between each target adjustment rule and the prompt text to be adjusted, the N target adjustment rules are weighted and fused to obtain a fused rule. The prompt text to be adjusted is then adjusted based on this fused rule to obtain the adjusted prompt text; or,
[0163] The adjustment results of the prompt text to be adjusted are obtained by iteratively adjusting the prompt text using N target adjustment rules.
[0164] In one embodiment, the processing unit 602 is further configured to:
[0165] The generative model is invoked based on the adjustment results to obtain the first generated result;
[0166] The quality of the first generated result is evaluated to obtain the quality evaluation result of the first generated result.
[0167] In one embodiment, the processing unit 602 is configured to perform a quality assessment on the first generated result to obtain a quality assessment result of the first generated result, specifically configured to:
[0168] The generation model is invoked to obtain a second generated result based on the prompt text to be adjusted; the quality of the first and second generated results is compared to obtain a quality evaluation result for the first generated result; or,
[0169] The quality of the first generated result is evaluated from at least one evaluation dimension to obtain the quality evaluation result of the first generated result; wherein, the evaluation dimensions include the coherence dimension, the accuracy dimension, and the innovation dimension.
[0170] In one embodiment, the processing unit 602 is further configured to:
[0171] If the quality assessment results indicate that the first generated result meets the quality requirements, the adjustment result will be marked as sample prompt text;
[0172] If the quality assessment results indicate that the first generated result does not meet the quality requirements, the target adjustment rules will be updated.
[0173] In one embodiment, the processing unit 602 is further configured to:
[0174] In response to the annotation operation of the adjustment results, the adjustment results are added to the target sample text set.
[0175] According to one embodiment of this application, Figure 2 and Figure 4 The steps involved in the method for adjusting the prompt text shown can be derived from... Figure 6 The prompt text adjustment device is executed by adjusting each unit. For example, Figure 2 Step S201 shown can be performed by Figure 6 The acquisition unit 601 shown is executed, and steps S202 and S203 can be performed by... Figure 6 The processing unit 602 shown executes the operation; Figure 4 Step S401 shown can be performed by Figure 6 The acquisition unit 601 shown is executed, and steps S402-S406 can be performed by... Figure 6 The processing unit 602 shown executes. Figure 6The various units in the illustrated prompt text adjustment device can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the prompt text adjustment device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0176] According to another embodiment of this application, a general-purpose computing device, such as a computer device including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can perform operations such as... Figure 2 and Figure 4 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 6 The accompanying diagram illustrates a prompt text adjustment device and a prompt text adjustment method for implementing embodiments of this application. A computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned computing device via the same medium, and executed therein.
[0177] Based on the same inventive concept, the principle and beneficial effects of the prompt text adjustment device provided in the embodiments of this application are similar to the principle and beneficial effects of the prompt text adjustment method in the embodiments of this application. For details, please refer to the principle and beneficial effects of the method implementation. For the sake of brevity, these will not be repeated here.
[0178] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device may be a terminal device or a server. Figure 7As shown, the computer device includes at least a processor 701, a communication interface 702, and a memory 703. The processor 701, communication interface 702, and memory 703 can be connected via a bus or other means. The processor 701 (or Central Processing Unit, CPU) is the computing and control core of the computer device. It can parse various instructions within the computer device and process various data. For example, the CPU can parse power-on / off commands issued by objects to the computer device and control the computer device to perform power-on / off operations; it can also transmit various interactive data between internal structures of the computer device, and so on. The communication interface 702 may optionally include standard wired interfaces or wireless interfaces (such as Wi-Fi, mobile communication interfaces, etc.), and can be used to send and receive data under the control of the processor 701; the communication interface 702 can also be used for data transmission and interaction within the computer device. The memory 703 is the storage device in the computer device, used to store programs and data. It can be understood that the memory 703 here can include the computer device's built-in memory, or it can include extended memory supported by the computer device. The memory 703 provides storage space for storing the operating system of the computer device, which may include, but is not limited to, Android, iOS, Windows Phone, etc. This application does not limit this.
[0179] This application embodiment also provides a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the processing system of the computer device. Furthermore, the storage space also stores computer programs suitable for loading and execution by the processor 701. It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer-readable storage medium located remotely from the aforementioned processor.
[0180] In one embodiment, processor 701 performs the following operations by running a computer program stored in memory 703:
[0181] Get the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, where M is an integer greater than 1;
[0182] Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, the target adjustment rule corresponding to the prompt text to be adjusted is determined. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text category corresponding to the target sample text set.
[0183] The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted. The adjustment result is used to guide the generation model to generate the expected content of the prompt text to be adjusted.
[0184] As an optional embodiment, the processor 701 determines the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets. A specific embodiment of this is as follows:
[0185] The prompt text to be adjusted is categorized to determine its category.
[0186] Based on the inclusion relationship between the category of the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, the target sample text set corresponding to the prompt text to be adjusted is determined;
[0187] Obtain the target sample text set;
[0188] Extract text features from the target sample text set and generate target adjustment rules based on the text features.
[0189] As an optional embodiment, the processor 701 determines the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and a set of M sample texts. A specific embodiment of this is as follows:
[0190] Obtain a set of M sample texts;
[0191] Extract the text features of each sample text set, and generate M adjustment rules based on the text features of the M sample text sets;
[0192] The matching degree between the prompt text to be adjusted and M adjustment rules is predicted by the rule prediction model to obtain the target adjustment rule corresponding to the prompt text to be adjusted.
[0193] As an optional embodiment, each sample text set is associated with at least one reference text, and the reference text associated with any sample text set corresponds one-to-one with the prompt text category corresponding to that sample text set; the processor 701 determines the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the M sample text sets. A specific embodiment of this is as follows:
[0194] Calculate the similarity between the prompt text to be adjusted and the reference text associated with each sample text set;
[0195] If the similarity between the prompt text to be adjusted and any reference text associated with the i-th sample text set is greater than the first similarity threshold, then the i-th sample text set is determined as the target sample text set corresponding to the prompt text to be adjusted, where i is a positive integer less than or equal to M.
[0196] Obtain the target sample text set;
[0197] Extract text features from the target sample text set and generate target adjustment rules based on the text features.
[0198] As an optional embodiment, the processor 701 adjusts the prompt text to be adjusted according to the target adjustment rules, and the specific embodiment for obtaining the adjusted prompt text is as follows:
[0199] The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain the adjusted prompt text;
[0200] Analyze the semantic similarity between the prompt text to be adjusted and the adjusted prompt text;
[0201] If the semantic similarity between the prompt text to be adjusted and the adjusted prompt text is greater than the second similarity threshold, then the adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted.
[0202] As an optional embodiment, the processor 701 adjusts the prompt text to be adjusted according to the target adjustment rules, and the specific embodiment for obtaining the adjusted prompt text is as follows:
[0203] Adjust the prompt text to be adjusted according to the target adjustment rules to obtain at least two adjusted prompt texts;
[0204] Analyze the semantic similarity between the prompt text to be adjusted and each adjusted prompt text;
[0205] The j-th adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted. The semantic similarity between the j-th adjusted prompt text and the prompt text to be adjusted is greater than the semantic similarity between other adjusted prompt texts and the prompt text to be adjusted. j is a positive integer less than or equal to M.
[0206] As an optional embodiment, the processor 701 adjusts the prompt text to be adjusted according to the target adjustment rules, and the specific embodiment for obtaining the adjusted prompt text is as follows:
[0207] Adjust the prompt text to be adjusted according to the adjustment dimensions indicated by the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted;
[0208] The adjustment dimensions include the dimensions of accuracy of expression, logical coherence, conciseness, and format standardization.
[0209] As an optional embodiment, each adjustment rule is associated with a different rewriting template and customization strategy; the processor 701 adjusts the prompt text to be adjusted according to the target adjustment rule, and the specific embodiment for obtaining the adjusted prompt text is as follows:
[0210] The prompt text to be adjusted is rewritten according to the rewriting template associated with the target adjustment rules, resulting in the rewritten prompt text;
[0211] By using a customized strategy associated with the target adjustment rules, the rewritten prompt text is partially adjusted to obtain the adjusted prompt text.
[0212] As an optional embodiment, the number of target adjustment rules is N, where N is an integer greater than 1; the processor 701 adjusts the prompt text to be adjusted according to the target adjustment rules, and the specific embodiment for obtaining the adjustment result of the prompt text to be adjusted is as follows:
[0213] Based on the matching degree between each target adjustment rule and the prompt text to be adjusted, the N target adjustment rules are weighted and fused to obtain a fused rule. The prompt text to be adjusted is then adjusted based on this fused rule to obtain the adjusted prompt text; or,
[0214] The adjustment results of the prompt text to be adjusted are obtained by iteratively adjusting the prompt text using N target adjustment rules.
[0215] As an optional embodiment, the processor 701, by running a computer program in the memory 703, also performs the following operations:
[0216] The generative model is invoked based on the adjustment results to obtain the first generated result;
[0217] The quality of the first generated result is evaluated to obtain the quality evaluation result of the first generated result.
[0218] As an optional embodiment, the processor 701 performs a quality evaluation on the first generated result, and the specific embodiment for obtaining the quality evaluation result of the first generated result is as follows:
[0219] The generation model is invoked to obtain a second generated result based on the prompt text to be adjusted; the quality of the first and second generated results is compared to obtain a quality evaluation result for the first generated result; or,
[0220] The quality of the first generated result is evaluated from at least one evaluation dimension to obtain the quality evaluation result of the first generated result; wherein, the evaluation dimensions include the coherence dimension, the accuracy dimension, and the innovation dimension.
[0221] As an optional embodiment, the processor 701, by running a computer program in the memory 703, also performs the following operations:
[0222] If the quality assessment results indicate that the first generated result meets the quality requirements, the adjustment result will be marked as sample prompt text;
[0223] If the quality assessment results indicate that the first generated result does not meet the quality requirements, the target adjustment rules will be updated.
[0224] As an optional embodiment, the processor 701, by running a computer program in the memory 703, also performs the following operations:
[0225] In response to the annotation operation of the adjustment results, the adjustment results are added to the target sample text set.
[0226] Based on the same inventive concept, the principle and beneficial effects of the computer device provided in the embodiments of this application in solving the problem are similar to the principle and beneficial effects of the prompt text adjustment method in the embodiments of this application in solving the problem. Please refer to the principle and beneficial effects of the implementation of the method. For the sake of brevity, they will not be repeated here.
[0227] This application also provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and to execute the prompt text adjustment method of the above method embodiments.
[0228] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned prompt text adjustment method.
[0229] The steps in the method of this application embodiment can be adjusted, combined, or deleted according to actual needs.
[0230] The modules in the device of this application embodiment can be merged, divided, and deleted according to actual needs.
[0231] In the embodiments of this application, the term "module" or "unit" refers to a computer program or part of a computer program with a predetermined function, which works together with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0232] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.
[0233] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Those skilled in the art will understand that all or part of the processes for implementing the above embodiments and equivalent variations made in accordance with the claims of this application are still within the scope of this application.
Claims
1. A method for adjusting prompt text, characterized in that, The method includes: Get the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, where M is an integer greater than 1; Based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, a target adjustment rule corresponding to the prompt text to be adjusted is determined. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text categories corresponding to the target sample text set. The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted. The adjustment result is used to guide the generation model to generate the expected content of the prompt text to be adjusted.
2. The method as described in claim 1, characterized in that, The step of determining the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets includes: The prompt text to be adjusted is classified to obtain the category to which the prompt text to be adjusted belongs; Based on the inclusion relationship between the category to which the prompt text to be adjusted belongs and the prompt text categories corresponding to the M sample text sets, the target sample text set corresponding to the prompt text to be adjusted is determined; Obtain the target sample text set; Extract text features from the target sample text set, and generate target adjustment rules based on the text features.
3. The method as described in claim 1, characterized in that, The step of determining the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the M sample text sets includes: Obtain a set of M sample texts; Extract the text features of each sample text set, and generate M adjustment rules based on the text features of the M sample text sets; The matching degree between the prompt text to be adjusted and the M adjustment rules is predicted by the rule prediction model to obtain the target adjustment rule corresponding to the prompt text to be adjusted.
4. The method as described in claim 1, characterized in that, Each sample text set is associated with at least one reference text, and the reference text associated with any sample text set corresponds one-to-one with the prompt text category corresponding to that sample text set; the step of determining the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the M sample text sets includes: Calculate the similarity between the prompt text to be adjusted and the reference text associated with each sample text set; If the similarity between the prompt text to be adjusted and any reference text associated with the i-th sample text set is greater than the first similarity threshold, then the i-th sample text set is determined as the target sample text set corresponding to the prompt text to be adjusted, where i is a positive integer less than or equal to M. Obtain the target sample text set; Extract text features from the target sample text set, and generate target adjustment rules based on the text features.
5. The method as described in claim 1, characterized in that, The step of adjusting the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted includes: The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain the adjusted prompt text; Analyze the semantic similarity between the prompt text to be adjusted and the adjusted prompt text; If the semantic similarity between the prompt text to be adjusted and the adjusted prompt text is greater than the second similarity threshold, then the adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted.
6. The method as described in claim 1, characterized in that, The step of adjusting the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted includes: The prompt text to be adjusted is adjusted according to the target adjustment rules to obtain at least two adjusted prompt texts; Analyze the semantic similarity between the prompt text to be adjusted and each adjusted prompt text; The j-th adjusted prompt text is determined as the adjustment result of the prompt text to be adjusted. The semantic similarity between the j-th adjusted prompt text and the prompt text to be adjusted is greater than the semantic similarity between other adjusted prompt texts and the prompt text to be adjusted. j is a positive integer less than or equal to M.
7. The method as described in claim 1, characterized in that, The step of adjusting the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted includes: The prompt text to be adjusted is adjusted according to the adjustment dimensions indicated by the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted; The adjustment dimensions include the dimensions of accuracy of expression, logical coherence, conciseness, and format standardization.
8. The method as described in claim 1, characterized in that, Each adjustment rule is associated with different rewriting templates and customization strategies; the adjustment of the prompt text to be adjusted according to the target adjustment rule to obtain the adjustment result of the prompt text to be adjusted includes: The prompt text to be adjusted is rewritten according to the rewriting template associated with the target adjustment rule to obtain the rewritten prompt text; The rewritten prompt text is partially adjusted using a customized strategy associated with the target adjustment rule to obtain the adjustment result of the prompt text to be adjusted.
9. The method as described in claim 1, characterized in that, The number of target adjustment rules is N, where N is an integer greater than 1; adjusting the prompt text to be adjusted according to the target adjustment rules to obtain the adjustment result of the prompt text to be adjusted includes: Based on the matching degree between each target adjustment rule and the prompt text to be adjusted, the N target adjustment rules are weighted and fused to obtain a fused rule. The prompt text to be adjusted is then adjusted based on the fused rule to obtain the adjusted result of the prompt text; or, The prompt text to be adjusted is iteratively adjusted using N target adjustment rules to obtain the adjustment result of the prompt text to be adjusted.
10. The method as described in claim 1, characterized in that, The method further includes: The generative model is invoked based on the adjustment results to obtain the first generated result; The quality of the first generated result is evaluated to obtain the quality evaluation result of the first generated result.
11. The method as described in claim 10, characterized in that, The quality evaluation of the first generated result, to obtain the quality evaluation result of the first generated result, includes: The generation model is invoked to obtain a second generation result based on the prompt text to be adjusted; the quality of the first generation result and the second generation result is compared to obtain a quality evaluation result of the first generation result; or, The quality of the first generated result is evaluated from at least one evaluation dimension to obtain the quality evaluation result of the first generated result; wherein, the evaluation dimension includes the coherence dimension, the accuracy dimension, and the innovation dimension.
12. The method as described in claim 10, characterized in that, The method further includes: If the quality assessment result indicates that the first generated result meets the quality requirements, then the adjustment result is marked as sample prompt text; If the quality assessment result indicates that the first generated result does not meet the quality requirements, then the target adjustment rule is updated.
13. The method as described in claim 1, characterized in that, The method further includes: In response to the annotation operation of the adjustment result, the adjustment result is added to the target sample text set.
14. A prompt text adjustment device, characterized in that, The prompt text adjustment device includes: The acquisition unit is used to acquire the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets, where M is an integer greater than 1; The processing unit is configured to determine the target adjustment rule corresponding to the prompt text to be adjusted based on the prompt text to be adjusted and the prompt text categories corresponding to the M sample text sets. The target adjustment rule is generated based on the target sample text set, and the category to which the prompt text to be adjusted belongs is included in the prompt text categories corresponding to the target sample text set. And to adjust the prompt text to be adjusted according to the target adjustment rule, so as to obtain the adjustment result of the prompt text to be adjusted, the adjustment result being used to guide the generation model to generate the expected content of the prompt text to be adjusted.
15. A computer device, characterized in that, include: A memory, wherein a computer program is stored; A processor for loading the computer program to implement the prompt text adjustment method as described in any one of claims 1-13.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed as described in any one of claims 1-13.
17. A computer program product, characterized in that, The computer program product includes a computer program adapted to be loaded by a processor and execute the prompt text adjustment method as described in any one of claims 1-13.