Method and device for optimizing large model generation content, electronic equipment and storage medium

By entering a preset target rule set in the large language model, the problem that the content generated by the large language model does not comply with specific rules is solved, and the accuracy and scope of application of the generated content is improved.

CN119106738APending Publication Date: 2024-12-10BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411311016.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

When generating content, large language models lack the ability to recognize the rules that need to be followed in a specific scenario, resulting in the generated content not meeting the actual needs of a specific scenario, limiting its in-field or product that requires strict compliance with standards or specifications. Application.

Method used

By obtaining user input questions and obtaining the target rule set corresponding to the target type from the preset multiple rule sets, inputting them into the large language model in the order of multiple target rules to ensure that the generated content follows specific rules.

Benefits of technology

It improves the accuracy of content generated by large language models, so that it can generate more compliant texts when it needs to comply with specific rules, and expands its application scope in the field of strict specifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106738A_ABST
    Figure CN119106738A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for optimizing large model generation content, electronic equipment and a storage medium, and relates to the technical field of artificial intelligence, in particular to the technical fields of text processing, large language models and the like. The method can be applied to official document processing, automatic contract generation, legal document writing, enterprise internal system management and the like. The specific implementation scheme is as follows: obtaining a question input by a user, wherein the question is used for indicating to generate a target type of text; then, a target rule set corresponding to the target type is obtained from a plurality of preset rule sets, the target rule set comprises a plurality of target rules, and the target rules are rules followed by the text of the target type; according to the sequence of the multiple target rules, the multiple target rules are sequentially input into the large language model, and a target text of the target type generated by the large language model is obtained. And the accuracy of generating the text following a certain rule by the large language model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to the field of text processing and large language model technology. Background Art

[0002] With the widespread application of artificial intelligence technology, large language models (LLMs) have shown great potential in content generation due to their powerful natural language understanding and generation capabilities. For example, large language models can currently be widely used in knowledge question answering, content creation, intelligent customer service, code development, and information extraction. Summary of the invention

[0003] The present disclosure provides a method, device, electronic device and storage medium for optimizing large model generated content.

[0004] A first aspect of an embodiment of the present disclosure provides a method for optimizing content generated by a large model, comprising:

[0005] Obtaining a question input by a user, wherein the question is used to indicate the generation of a text of a target type;

[0006] Acquire a target rule set corresponding to the target type from a plurality of preset rule sets, wherein the target rule set includes a plurality of target rules, and the target rules are rules followed by the text of the target type;

[0007] According to the order of the multiple target rules, the multiple target rules are sequentially input into the large language model to obtain the target text of the target type generated by the large language model.

[0008] A second aspect of the embodiments of the present disclosure provides a device for optimizing large model generated content, including:

[0009] An acquisition module, used for acquiring a question input by a user, wherein the question is used for indicating the generation of a text of a target type;

[0010] The acquisition module is further used to acquire a target rule set corresponding to the target type from a plurality of preset rule sets, wherein the target rule set includes a plurality of target rules, and the target rules are rules followed by the text of the target type;

[0011] A generating module is used to input the multiple target rules into the large language model in sequence according to the order of the multiple target rules acquired by the acquiring module, so as to obtain the target text of the target type generated by the large language model.

[0012] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any method according to the first aspect.

[0016] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute a method according to any one of the first aspects.

[0017] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method according to any one of the first aspects is implemented.

[0018] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0020] Figure 1 is a flow chart of a method for optimizing large model generation content provided by an embodiment of the present disclosure;

[0021] Figure 2 is a flow chart of a method for generating a target text provided by an embodiment of the present disclosure;

[0022] Figure 3 is a flowchart of a method for processing parallel nodes provided by an embodiment of the present disclosure;

[0023] Figure 4 is a flow chart of a method for processing a cyclic node provided by an embodiment of the present disclosure;

[0024] Figure 5 is a flowchart of a method for processing a judgment node provided by an embodiment of the present disclosure;

[0025] Figure 6 is a flow chart of a method for verifying a target text provided by an embodiment of the present disclosure;

[0026] Figure 7 is an exemplary schematic diagram of a target rule set provided by an embodiment of the present disclosure;

[0027] Figure 8 It is a structural schematic diagram of a device for optimizing large model generation content provided by an embodiment of the present disclosure;

[0028] Fig. 9 The present invention is a block diagram of an electronic device for implementing the method for optimizing large model generated content according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0029] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0030] Large language models are trained by deep learning models using massive amounts of data, and the accuracy of their output results mainly depends on the data used during training. However, when generating content, large language models often lack the ability to recognize the rules that need to be followed in specific scenarios, resulting in the generated content not meeting the actual needs of specific scenarios, which greatly limits the application of large language models in fields or products that need to strictly comply with specific standards or specifications.

[0031] To solve this problem, the present disclosure provides a method for optimizing large model generated content, which is applied to electronic devices, such as servers or desktop computers with data processing capabilities. Figure 1 As shown, the method comprises the following steps:

[0032] S101, obtaining a question input by a user.

[0033] In the disclosed embodiment, the terminal may display an input interface, and the user may input questions in the input interface by keyboard input or voice input, etc. Afterwards, when the terminal detects that the user triggers a submission instruction, the terminal sends the question input by the user to the electronic device.

[0034] Alternatively, the electronic device may display an input interface, and the user may input questions into the input interface by keyboard input or voice input.

[0035] The question is used to indicate the text of the target type to be generated. For example, the target type may be: corporate regulations, contracts, official documents, or patent documents.

[0036] For example, the question entered by the user is: Help me generate a labor contract between Company A and Employee B. In this case, the target type is Contract.

[0037] S102: Obtain a target rule set corresponding to the target type from multiple preset rule sets.

[0038] Each rule set includes a plurality of rules followed by a type of text, and correspondingly, the target rule set includes a plurality of target rules, where the target rules are rules followed by text of the target type.

[0039] For example, when the target type is a contract, the target rule set includes: having the signature or seal of Party A, having the signature or seal of Party B, and when the name of Party A or Party B contains English, the first letter of the English is capitalized, etc.

[0040] S103. Input the multiple target rules into the large language model in sequence according to the order of the multiple target rules to obtain a target text of the target type generated by the large language model.

[0041] pass Figure 1 According to the method shown, the disclosed embodiment can obtain a target rule set corresponding to the target type to which the text to be generated by the user belongs from a plurality of preset rule sets. Then, according to the order of the plurality of target rules included in the target rule set, the plurality of target rules are sequentially input into the large language model, thereby obtaining the target text of the target type generated by the large language model. Since the disclosed embodiment can sequentially input the rules that the text of the target type needs to follow into the large language model, the large language model can constrain its own generated content based on the target rules during the content generation process, thereby improving the accuracy of the target text generated by the large language model in following the target rules.

[0042] The following is a detailed description of the method for optimizing large model generation content provided by the embodiment of the present disclosure:

[0043] The above-mentioned S102 electronic device obtains the target rule set corresponding to the target type from the preset multiple rule sets in the following two ways:

[0044] Implementation method 1 of S102 is to use a rule set selected by a user from among multiple preset rule sets as a target rule set.

[0045] Among them, the input interface of the terminal can display multiple rule set controls and brief information, wherein the brief information is used to indicate the type corresponding to the rule set. Based on this, the terminal can receive the control selected by the user in the input interface, and send the (identifier, ID) of the rule set corresponding to the control to the electronic device, so that the electronic device determines the rule set selected by the user based on the received rule set ID, and uses the rule set as the target rule set.

[0046] Alternatively, the input interface of the electronic device may display controls and brief information of multiple rule sets. Based on this, the electronic device may receive a control selected by a user in the input interface, and use the rule set corresponding to the control selected by the user as the target rule set.

[0047] A second implementation method of S102 is to perform text classification on the question to obtain a target type to which the text generated by the question indication belongs, and based on the correspondence between multiple preset rule sets and preset types, obtain a target rule set corresponding to the target type.

[0048] The electronic device can input the question into the classifier, and the classifier can perform text classification on the question to obtain the target type output by the classifier. Then, based on the correspondence between the pre-stored multiple rule sets and the preset types, the target rule set corresponding to the target type is obtained.

[0049] For example, the classifier may be a long short-term memory network (LSTM), a naive Bayesian network, or a support vector machine (SVM).

[0050] For example, the correspondence between multiple rule sets and preset types is shown in Table 1:

[0051] Table 1

[0052] Rulesets type Rule Set 1 contract Rule Set 2 Corporate Regulations Rule Set 3 Patent Documents

[0053] Assuming the target type is contract, the target rule set is rule set 1.

[0054] Through the above method, the embodiment of the present disclosure supports the user to select a rule set, and also supports obtaining a target rule set corresponding to the target type by analyzing the target type to which the question input by the user belongs. That is, the embodiment of the present disclosure supports manual or automatic selection of a target rule set, which improves flexibility and makes the application scope of the embodiment of the present disclosure wider.

[0055] In some embodiments of the present disclosure, Figure 1 The target rule set in the embodiment includes a plurality of nodes connected in series, wherein the plurality of nodes includes a rule node representing a target rule.

[0056] Based on this, see Figure 2 The above S103 inputs the multiple rules into the large language model in sequence according to the order of the multiple rules to obtain the target text of the target type generated by the large language model, including the following steps:

[0057] S201. In the order of multiple nodes, if the node is a rule node, generate first prompt information based on the target rule represented by the node.

[0058] In one implementation, the electronic device may obtain a preset prompt word template, and then fill the target rule represented by the rule node into the prompt word template to obtain the first prompt information.

[0059] For example, the prompt word template is: "Rule: xxxxx; generate text that follows the above rules." Among them, xxxxx is a placeholder. Assuming that the target rule is "the company name is Party A, the person name is Party B", after filling the target rule into the prompt word template, the first prompt information obtained is "Rule: the company name is Party A, the person name is Party B; generate text that follows the above rules."

[0060] In another implementation, the electronic device may input the target rule represented by the rule node into a natural language processing (NLP) model to obtain the first prompt information output by the NLP model. For example, the NLP model may be a transformer, bidirectional encoder representations from transformers (BERT), or a large language model.

[0061] Alternatively, the electronic device may also generate the first prompt information based on the target rule in other ways, which is not specifically limited in the embodiments of the present disclosure.

[0062] S202, determine whether the node is the first node included in the target rule set; if so, execute S203; if not, execute S204.

[0063] S203: Input the first prompt information and the question into the large language model to obtain an output result of the large language model.

[0064] S204: Input the first prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model.

[0065] For example, assuming that the second node included in the target rule set is a rule node, the first prompt information generated based on the target rule represented by the second node and the output result of the large language model obtained based on the first node are input into the large language model to obtain the output result of the large language model.

[0066] S205, until the final output result is obtained as the target text, wherein the final output result is the output result obtained based on the last node included in the target rule set.

[0067] In the embodiment of the present disclosure, the target rule set includes multiple nodes, and the multiple nodes include a rule node representing a target rule. It can be seen that the embodiment of the present disclosure can split the rules that a type of text needs to follow into different rule nodes, thereby achieving decoupling of the rules. This allows the user to modify, delete or add each rule individually, and also adjust the order between the rules, thereby improving the flexibility of adjusting the rules that each type of text needs to follow.

[0068] Moreover, when a type of text needs to follow many rules, if prompt information is generated directly based on all the rules that the target type of text needs to follow, the generated prompt information may be too long, exceeding the length limit of the large language model for input content, resulting in the inability to input the large language model.

[0069] In the embodiment of the present disclosure, all the rules that a type of text needs to follow are split into different nodes, and prompt information can be generated based on part of the rules each time. This reduces the situation where the prompt information exceeds the length limit of the input content for the large language model and improves the stability of the text generation process.

[0070] In some embodiments of the present disclosure, the multiple nodes in the target rule set may further include parallel nodes, wherein the parallel nodes include multiple parallel rule sub-nodes, each of which represents a target rule.

[0071] For example, a parallel node includes: parallel rule subnode 1 and parallel rule subnode 2. Parallel rule subnode 1 is "the company name is Party A", and parallel rule subnode 2 is "the person name is Party B".

[0072] On this basis, see Figure 3 In the above S205 until the final output result is obtained as the target text, the electronic device may further perform the following steps:

[0073] S301: If the node is a parallel node, generate second prompt information based on target rules represented by multiple parallel rule sub-nodes included in the node.

[0074] The method of generating the second prompt information is the same as the method of generating the first prompt information. Please refer to the relevant description in S201 above, and will not be repeated here.

[0075] S302: Determine whether the node is the first node. If yes, execute S303; if no, execute S304.

[0076] S303: Input the second prompt information and the question into the large language model to obtain an output result of the large language model.

[0077] S304: Input the second prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model.

[0078] It can be seen that the disclosed embodiment supports setting parallel rules in parallel nodes, and can generate a prompt message based on multiple parallel rules included in the same parallel node. This reduces the number of times prompt messages are generated based on each rule and the number of times the large language model is called to obtain output results, thereby improving the efficiency of text generation.

[0079] In some embodiments of the present disclosure, the multiple nodes in the target rule set may further include a loop node, the loop node includes at least one loop rule sub-node, and each loop rule sub-node represents a target rule.

[0080] It is understandable that the accuracy of texts generated by a large language model that follow different rules is different. When the accuracy of texts generated by a large language model that follow a certain rule is low, the large language model can be recycled to generate texts that follow the rule to increase the possibility that the text output by the large language model follows the rule.

[0081] For example, assuming that the accuracy of the large language model in generating text that follows target rule 1 is low, the target rule set may include a loop node 1, loop node 1 includes a loop rule subnode 1, and the loop rule subnode represents target rule 1.

[0082] On this basis, see Figure 4 Before the final output result is obtained as the target text in the above S205, the electronic device may further perform the following steps:

[0083] S401: If the node is a loop node, generate third prompt information based on the target rule represented by the loop rule sub-node included in the node.

[0084] The method for generating the third prompt information is the same as the method for generating the first prompt information. Please refer to the relevant description in S201 above, which will not be repeated here.

[0085] S402: Determine whether the node is the first node. If yes, execute S403; if no, execute S404.

[0086] S403: Input the third prompt information and the question into the large language model to obtain an output result of the large language model. Then, execute S405.

[0087] S404: Input the third prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model. Then, execute S405.

[0088] It should be noted that, when the previous node is a loop node, the output result obtained based on the previous node is the output result of the large language model obtained based on the last round of loop of the previous node.

[0089] S405. Add one to the number of loops of the node. When the current number of loops does not reach the preset number, input the third prompt information and the output result obtained in the previous cycle into the large language model to obtain the output result of the large language model, and return to the step of adding one to the number of loops of the node until the current number of loops reaches the preset number.

[0090] In the disclosed embodiment, the initial value of the number of loops of the loop node is 0. Each time the electronic device executes S405 for a loop node, the number of loops of the loop node is increased by 1 until the number of loops of the loop node reaches a preset number, and the output result of the large language model obtained last time is used as the output result obtained based on the loop node. After that, the number of loops of the loop node is restored to 0.

[0091] Each loop node may include a specified number of loops or may not include a specified number of loops. When a loop node includes a specified number of loops, the preset number of loops is the specified number of loops. When a loop node does not include a specified number of loops, the preset number of loops is a default number of loops. For example, the default number of loops is 3.

[0092] Based on the loop node, the embodiment of the present disclosure can repeatedly call the large language model to generate text that follows the rules included in the loop node, thereby increasing the possibility that the text generated by the large language model follows the rules and improving the accuracy of the text generated by the large language model.

[0093] In some embodiments of the present disclosure, the multiple nodes in the target rule set may further include a judgment node, the judgment node includes a judgment condition and at least one judgment rule sub-node, and each judgment rule sub-node represents a target rule.

[0094] It is understandable that in actual application scenarios, for the same type of text, when the content contained in the text is different, the conditions that need to be followed may also be different.

[0095] For example, when the name of Party A in the contract is in English, the rule that the first letter of Party A's name is capitalized needs to be followed. When the name of Party A in the contract is in Chinese, the rule that the first letter of Party A's name is capitalized does not need to be followed. In this case, the target rule set can include a judgment node, and the judgment node includes a judgment condition of "whether Party A's name is all in English", and the judgment node includes a judgment rule subnode indicating the target rule of "the first letter of Party A's name is capitalized".

[0096] On this basis, see Figure 5In the above S205 until the final output result is obtained as the target text, the electronic device may further perform the following steps:

[0097] S501, if the node is a judgment node, determine whether the judgment condition included in the node is established. If yes, execute S502; if no, determine not to generate text based on the target rule represented by the judgment rule subnode included in the judgment node, that is, use the output result obtained based on the previous node of the judgment node as the output result obtained based on the judgment node, and jump to the next node.

[0098] The judgment conditions included in the judgment node may be set based on the actual application scenario.

[0099] S502: Generate fourth prompt information based on the target rule represented by the judgment rule sub-node included in the node.

[0100] The method for generating the fourth prompt information is the same as the method for generating the first prompt information. Please refer to the relevant description in S201 above, which will not be repeated here.

[0101] It should be noted that, when there is only one situation where the judgment condition is satisfied, the judgment node may include a judgment rule sub-node, and the electronic device may directly generate the fourth prompt information based on the target rule represented by the judgment rule sub-node.

[0102] Alternatively, when the judgment condition includes multiple situations in which a judgment is established, the judgment node may include multiple judgment rule sub-nodes, and each judgment rule sub-node corresponds to a situation in which a judgment is established. For example, the judgment condition is "Party A's name is Chinese or English", and there are two situations in which the judgment condition is established. The first situation in which a judgment is established is "Party A's name is Chinese", and the target rule represented by the judgment rule sub-node corresponding to this situation is "Party A's name has no spaces or punctuation marks"; the second situation in which a judgment is established is "Party A's name is English", and the target rule represented by the judgment rule sub-node corresponding to this situation is "The first letter of Party A's name is capitalized". In this case, the electronic device can generate a fourth prompt message based on the target rule represented by the judgment rule sub-node corresponding to the situation in which the judgment condition is established.

[0103] S503, determine whether the node is the first node; if so, execute S504; if not, execute S505.

[0104] S504: Input the fourth prompt information and the question into the large language model to obtain an output result of the large language model.

[0105] S505: Input the fourth prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model.

[0106] The disclosed embodiment can generate text based on the target rule represented by the judgment rule sub-node included in the judgment node when the judgment condition included in the judgment node is met; conversely, when the judgment condition included in the judgment node is not met, the text is not generated based on the target rule, and the text is continued to be generated by jumping to the next node, thereby improving the flexibility of the target rule on which the text generation process is based, and also improving the efficiency of generating text.

[0107] In the disclosed embodiment, if a type of text needs to follow a small number of rules, then strictly calling a large language model in sequence according to each rule to generate text may reduce the efficiency of text generation.

[0108] Therefore, before the above S103, the electronic device may further determine whether the number of target rules included in the target rule set is less than a preset number, for example, the preset number is 5.

[0109] If the number of rules is less than the preset number, the electronic device can generate a fifth prompt message based on multiple target rules, and then input the fifth prompt message and the question into the large language model to obtain a target text of the target type generated by the large language model.

[0110] It should be noted that the target rule set includes multiple target rules: target rules represented by rule nodes, target rules represented by parallel rule sub-nodes included in parallel nodes, target rules represented by loop rule sub-nodes included in loop nodes, and / or target rules represented by judgment rule sub-nodes included in judgment nodes.

[0111] The method for generating the fifth prompt information is the same as the method for generating the first prompt information. Please refer to the relevant description in S201 above, which will not be repeated here.

[0112] Since the target rule set includes a small number of target rules, the fifth prompt information generated based on each target rule included in the target rule set is generally not too long and will not exceed the input content length limit of the large language model. In this case, the embodiment of the present disclosure can directly input the fifth prompt information and the question into the large language model to obtain the target text, reducing the number of times the large language model is called, thereby improving the efficiency of generating the target text.

[0113] On the other hand, in the embodiment of the present disclosure, the above S103 can be implemented as follows: if the number of rules is greater than or equal to a preset number, multiple target rules are sequentially input into the large language model in the order of the multiple target rules to obtain a target text of the target type generated by the large language model.

[0114] In this case, the method of generating the target text can refer to the method of generating the target text in S103 above, which will not be described in detail here.

[0115] When the target rule set includes a large number of target rules, if prompt information is generated based on each target rule included in the target rule set, the generated prompt information may be too long, exceeding the limit of the input content length of the large language model. Therefore, in this case, the embodiment of the present disclosure can call the large model in sequence according to the order of each target rule to generate text, thereby improving the stability of the text generation process.

[0116] In some embodiments of the present disclosure, after the target text is generated in S103, in order to improve the accuracy of the text provided to the user, the electronic device may also verify whether the generated target text meets the target rules. The verification method includes the following steps:

[0117] Step 1: Verify whether the target text complies with the target rules in the order of multiple target rules.

[0118] The electronic device may verify whether the target text complies with the target rule according to the order of the nodes included in the target rule set and for the target rule represented by each node or the target rule represented by the subnodes included in each node.

[0119] Step 2: If the target text complies with multiple target rules, the target text is displayed to the user.

[0120] If the target text complies with each target rule included in the target rule set, it means that the target text complies with the rules that the preset type of text needs to comply with, and thus the target text can be displayed to the user.

[0121] The electronic device may send the target text to the terminal so that the terminal displays the target text to the user. Alternatively, the electronic device may directly display the target text to the user.

[0122] Through the above method, the embodiment of the present disclosure can verify whether the target text complies with each target rule, and display the target text to the user when the target text complies with each target rule, thereby improving the accuracy of the target text provided to the user and improving the user's usage experience.

[0123] In some embodiments of the present disclosure, see Figure 6 , the method of verifying whether the target text complies with the target rule in the above step 1 includes the following steps:

[0124] S601, input the first target rule and the target text included in the target rule set into the verification model, verify whether the target text complies with the first target rule through the verification model, and obtain the output result of the verification model, wherein the output result indicates the modified text obtained after the verification is passed or after the input target text is modified according to the input target rule.

[0125] The first target rule included in the target rule set is: the target rule represented by the first node included in the target rule set, or the target rule represented by a child node of the first node.

[0126] The verification model may be a large language model or other NLP models, etc., which is not specifically limited in the embodiments of the present disclosure.

[0127] S602: Determine whether the output result of the verification model indicates that the verification is passed. If yes, determine not to update the target text, that is, keep the current target text unchanged, and execute S604; if no, execute S603.

[0128] S603: Update the target text to the output result of the verification model, and then execute S604.

[0129] Since the output result of the verification model does not indicate that the verification is passed, it means that the target text does not follow the current verification target rules, and the verification model has corrected the target text and output the modified text obtained after modifying the target text according to the input target rules. Therefore, the electronic device can update the target text to the output result of the verification model, thereby improving the accuracy of the target text.

[0130] S604: Input the next target rule included in the target rule set and the current target text into the verification model, verify whether the input target text complies with the input target rule through the verification model, obtain the output result of the verification model, and return to S602.

[0131] The electronic device may determine the next node of the currently verified node, and use the target rule represented by the next node, or the target rule represented by a child node of the next node, as the next target rule.

[0132] It should be noted that when the node is a judgment node, when the judgment condition of the judgment node is not satisfied, the target rule included in the judgment node may not be verified. Alternatively, when the judgment condition of the judgment node is satisfied and the judgment node includes only one judgment rule subnode, the target rule represented by the judgment rule subnode may be obtained and verified. Alternatively, when the judgment condition of the judgment node is satisfied and the judgment node includes multiple judgment rule subnodes, the target rule represented by the judgment rule subnode corresponding to the situation where the judgment condition is satisfied may be obtained and verified.

[0133] In addition, when the node is a parallel node, the target rule represented by each parallel rule subnode included in the parallel node can be verified respectively, or the target rules represented by each parallel rule subnode included in the parallel node can be verified at the same time. For example, the target rules represented by each parallel rule subnode included in the parallel node are merged, and the merged rules are verified.

[0134] The electronic device executes S602 to S604 in a loop until an output result is obtained based on the last target rule included in the target rule set. When the output result indicates that the verification is passed, the target text is not updated and the loop ends; or when the output result does not indicate that the verification is passed, the target text is updated to the output result and the loop ends.

[0135] Through the above method, the embodiment of the present disclosure can verify whether the target text complies with each target rule in turn, and during the verification process, the target text is continuously updated, thereby improving the accuracy of the target text in complying with each target rule.

[0136] Since in the process of verifying whether the target rules satisfy each target rule, there may be cases where the verification fails, after verifying whether the target text complies with each target rule in the above step one, the electronic device can also execute: if any output result obtained based on multiple target rules does not indicate that the verification is passed, the most recently updated target text is displayed to the user.

[0137] If any of the output results obtained based on each target rule does not indicate that the verification is passed, it means that the initial target text cannot meet all the target rules, and the disclosed embodiment updates the target text during the verification process so that the updated target text meets each target rule. Therefore, the disclosed embodiment can show the user the target text after the most recent update in this case, thereby improving the accuracy of the target text provided to the user and improving the user experience.

[0138] It is understandable that the verification results of the verification model may have errors, and the greater the number of verifications, the smaller the possibility of errors in the verification results.

[0139] Therefore, in the embodiment of the present disclosure, the target rule has a rule level, and the rule level indicates the strictness of verifying the target rule. For example, the rule level includes: high, medium and low, wherein the high level indicates that it is necessary to verify very strictly whether the target text meets the target rule, the medium level indicates that it is necessary to verify strictly whether the target text meets the target rule, and the low level indicates that it is not necessary to verify strictly whether the target text meets the target rule.

[0140] On this basis, the method of the electronic device verifying whether the target text complies with the target rule in step 1 can be implemented as follows: obtaining the verification times corresponding to the rule level of the target rule, and then verifying whether the target text complies with the target rule for the verification times. Among them, the rule level is positively correlated with the verification times.

[0141] The electronic device may search for the number of verifications corresponding to the rule level of the target rule based on a pre-stored preset correspondence between each rule level and the number of verifications.

[0142] For example, the preset correspondence between each rule level and the number of verifications is shown in Table 2.

[0143] Table 2

[0144] Rule Level Verification times advanced 3 intermediate 2 Low Level 1

[0145] Assuming that the rule level of a target rule is high, the number of verifications is determined to be 3 times.

[0146] When a target rule is verified multiple times, each verification process may refer to the methods of S601 to S603, which will not be described in detail here.

[0147] In the disclosed embodiment, the higher the rule level of the target rule, the more times the target rule is verified, so that the target text is required to strictly comply with the rule and multiple verifications are performed, which increases the possibility that the target text meets the rule, that is, improves the accuracy and compliance of the target text. Conversely, the lower the rule level of the target rule, the fewer times the target rule is verified, which reduces the time spent on the verification process and improves the efficiency of displaying the target text to the user.

[0148] See also Figure 7 The following is an example to illustrate the overall process of the method for optimizing large model content generation provided by the embodiment of the present disclosure:

[0149] The electronic device receives the question input by the user from the terminal, and then performs text classification on the question to obtain the target type to which the text generated by the question instruction belongs. Then, the electronic device obtains the target rule set corresponding to the target type based on the correspondence between the preset multiple rule sets and the preset types.

[0150] like Figure 7 As shown, the target rule set includes: rule node 1, parallel node 2 and loop node 3. Wherein, parallel node 2 includes parallel rule sub-node 4 and parallel rule sub-node 5. Loop node 3 includes loop rule sub-node 6.

[0151] The electronic device generates first prompt information based on target rule 1 represented by rule node 1, and inputs the first prompt information and the question into the large language model to obtain an output result of the large language model.

[0152] Afterwards, the electronic device generates a second prompt message based on the target rule 2 represented by the parallel rule subnode 4 included in the parallel node 2 and the target rule 3 represented by the parallel rule subnode 5, and inputs the second prompt message and the output result obtained based on the rule node 1 into the large language model to obtain the output result of the large language model.

[0153] Then, the electronic device generates the third prompt information based on the target rule 4 represented by the loop rule subnode 6 included in the loop node 3, and inputs the third prompt information and the output result obtained based on the parallel node 2 into the large language model to obtain the output result of the large language model. The number of loops of the loop node 3 is increased by one. When the current number of loops does not reach the preset number, the third prompt information and the output result obtained in the previous cycle are input into the large language model to obtain the output result of the large language model, and the step of increasing the number of loops of the loop node 3 by one is returned until the current number of loops reaches the preset number. The electronic device uses the output result obtained based on the last cycle of the loop node 3 as the target text.

[0154] After obtaining the target text, the electronic device inputs target rule 1 and the target text into the verification model to obtain the output result of the verification model. If the output result does not indicate that the verification is passed, the target text is updated to the output result. Then, target rule 2, target rule 3 and the current target text are input into the verification model to obtain the output result of the verification model. If the output result does not indicate that the verification is passed, the target text is updated to the output result. Then, target rule 4 and the current target text are input into the verification model to obtain the output result of the verification model. If the output result does not indicate that the verification is passed, the target text is updated to the output result. Afterwards, the most recently updated target text is displayed to the user.

[0155] The disclosed embodiment can constrain the text output by the large language model through the target rules, thereby increasing the possibility that the target text generated based on the large language model complies with the target rule set. Moreover, after obtaining the target text, it is also possible to verify whether the target text meets each target rule, and continuously revise the target text, further ensuring the compliance and accuracy of the target text displayed to the user. It reduces the situation where the target text displayed to the user is non-compliant, resulting in the need for the user to make repeated modifications, that is, it reduces manual intervention and improves the generation efficiency of the target text. The disclosed embodiment can be applied to fields or products that need to comply with standards or regulations, such as official document processing, automatic contract generation, legal document writing, and internal enterprise system management.

[0156] The collection, storage, use, processing, transmission, provision and disclosure of the issues and rules involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0157] Based on the same inventive concept, corresponding to the above method embodiment, the embodiment of the present disclosure also provides a device for optimizing the content generated by the large model, such as Figure 8 As shown, the device includes: an acquisition module 801 and a generation module 802;

[0158] An acquisition module 801 is used to acquire a question input by a user, where the question is used to indicate the generation of a text of a target type;

[0159] The acquisition module 801 is further used to acquire a target rule set corresponding to the target type from a plurality of preset rule sets, where the target rule set includes a plurality of target rules, and the target rule is a rule followed by the text of the target type;

[0160] The generating module 802 is used to input the multiple target rules into the large language model in sequence according to the order of the multiple target rules obtained by the obtaining module 801, so as to obtain the target text of the target type generated by the large language model.

[0161] In some embodiments of the present disclosure, the target rule set includes a plurality of nodes connected in series, and the plurality of nodes includes a rule node representing a target rule; the generating module 802 is specifically configured to:

[0162] According to the order of the multiple nodes, if the node is a rule node, generating first prompt information based on the target rule represented by the node;

[0163] If the node is the first node included in the target rule set, the first prompt information and the question are input into the large language model to obtain an output result of the large language model;

[0164] If the node is not the first node, inputting the first prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model;

[0165] Until the final output result is obtained, it is used as the target text. The final output result is the output result obtained based on the last node included in the target rule set.

[0166] In some embodiments of the present disclosure, the plurality of nodes further include a parallel node, the parallel node includes a plurality of parallel rule sub-nodes, the parallel rule sub-node represents a target rule, and the generation module 802 is further used to:

[0167] Before the final output result is obtained as the target text, if the node is a parallel node, second prompt information is generated based on the target rules represented by the multiple parallel rule subnodes included in the node;

[0168] If the node is the first node, the second prompt information and the question are input into the large language model to obtain the output result of the large language model;

[0169] If the node is not the first node, the second prompt information and the output result obtained based on the previous node are input into the large language model to obtain the output result of the large language model.

[0170] In some embodiments of the present disclosure, the plurality of nodes further include a loop node, the loop node includes at least one loop rule sub-node, the loop rule sub-node represents a target rule, and the generation module 802 is further used to:

[0171] Before the final output result is obtained as the target text, if the node is a loop node, a third prompt information is generated based on the target rule represented by the loop rule subnode included in the node;

[0172] If the node is the first node, the third prompt information and the question are input into the large language model to obtain an output result of the large language model;

[0173] If the node is not the first node, inputting the third prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model;

[0174] The number of loops of the node is increased by one. When the current number of loops does not reach the preset number, the third prompt information and the output result obtained in the previous cycle are input into the large language model to obtain the output result of the large language model, and the step of increasing the number of loops of the node by one is returned until the current number of loops reaches the preset number.

[0175] In some embodiments of the present disclosure, the multiple nodes further include a judgment node, the judgment node includes a judgment condition and at least one judgment rule sub-node, the judgment rule sub-node represents a target rule, and the generation module 802 is further used to:

[0176] Before obtaining the final output result as the target text, if the node is a judgment node, determine whether the judgment condition included in the node is established;

[0177] If yes, generating fourth prompt information based on the target rule represented by the judgment rule subnode included in the node;

[0178] If the node is the first node, input the fourth prompt information and the question into the large language model to obtain an output result of the large language model;

[0179] If the node is not the first node, the fourth prompt information and the output result obtained based on the previous node are input into the large language model to obtain the output result of the large language model.

[0180] In some embodiments of the present disclosure, the generating module 802 is specifically configured to:

[0181] If the number of target rules included in the target rule set is greater than or equal to a preset number, the multiple target rules are sequentially input into the large language model in the order of the multiple target rules to obtain a target text of the target type generated by the large language model.

[0182] In some embodiments of the present disclosure, the generating module 802 is further configured to:

[0183] If the number of rules is less than the preset number, a fifth prompt message is generated based on the multiple target rules;

[0184] The fifth prompt information and the question are input into the large language model to obtain a target text of the target type generated by the large language model.

[0185] In some embodiments of the present disclosure, the device further comprises:

[0186] A verification module, for inputting the multiple target rules into the large language model in sequence according to the order of the multiple target rules, and after obtaining the target text of the target type generated by the large language model, verifying whether the target text complies with the target rules in the order of the multiple target rules;

[0187] The display module is used to display the target text to the user if the target text complies with multiple target rules.

[0188] In some embodiments of the present disclosure, the verification module is specifically used to:

[0189] Input the first target rule and the target text included in the target rule set into the verification model, verify whether the target text complies with the first target rule through the verification model, and obtain the output result of the verification model, where the output result indicates that the verification is passed or the modified text is obtained after the input target text is modified according to the input target rule;

[0190] Determine whether the output result of the verification model indicates that the verification is passed;

[0191] If not, update the target text to the output result of the verification model;

[0192] The next target rule and the current target text included in the target rule set are input into the verification model, and the verification model is used to verify whether the input target text complies with the input target rule, to obtain the output result of the verification model, and to return to the step of determining whether the output result of the verification model indicates that the verification is passed.

[0193] In some embodiments of the present disclosure, the display module is further used to:

[0194] After verifying whether the target text complies with the target rules in the order of multiple target rules, if any output result obtained based on the multiple target rules does not indicate that the verification is passed, the most recently updated target text is displayed to the user.

[0195] In some embodiments of the present disclosure, the target rule has a rule level, and the verification module is specifically used to:

[0196] Get the verification times corresponding to the rule level of the target rule, where the rule level is positively correlated with the verification times;

[0197] Verify the target text to see if it complies with the target rules.

[0198] In some embodiments of the present disclosure, the acquisition module 801 is specifically used to:

[0199] From among multiple preset rule sets, a rule set selected by the user is used as the target rule set; or,

[0200] Perform text classification on the question to obtain the target type to which the text generated by the question indicates;

[0201] Based on the correspondence between the preset multiple rule sets and the preset types, a target rule set corresponding to the target type is obtained.

[0202] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0203] Fig. 9 A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0204] like Fig. 9As shown, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0205] Multiple components in the electronic device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the electronic device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0206] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as a method for optimizing large model generation content. For example, in some embodiments, the method for optimizing large model generation content may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the method for optimizing large model generation content described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform a method for optimizing large model generation content in any other appropriate manner (e.g., by means of firmware).

[0207] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0208] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0209] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0210] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0211] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0212] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0213] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0214] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for optimizing content generated by a large model, comprising: Obtaining a question input by a user, wherein the question is used to indicate the generation of a text of a target type; Acquire a target rule set corresponding to the target type from a plurality of preset rule sets, wherein the target rule set includes a plurality of target rules, and the target rules are rules followed by the text of the target type; According to the order of the multiple target rules, the multiple target rules are sequentially input into the large language model to obtain the target text of the target type generated by the large language model.

2. The method according to claim 1, wherein: The target rule set includes a plurality of nodes connected in series, wherein the plurality of nodes include a rule node representing one of the target rules; and the plurality of target rules are sequentially input into a large language model in the order of the plurality of target rules to obtain a target text of the target type generated by the large language model, including: According to the order of the plurality of nodes, if the node is a rule node, generating first prompt information based on the target rule represented by the node; If the node is the first node included in the target rule set, inputting the first prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, inputting the first prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model; Until the final output result is obtained as the target text, the final output result is the output result obtained based on the last node included in the target rule set.

3. The method according to claim 2, wherein: The plurality of nodes also include parallel nodes, the parallel nodes include a plurality of parallel rule sub-nodes, the parallel rule sub-nodes represent one target rule, and before the final output result is obtained as the target text, the following further includes: If the node is a parallel node, generating second prompt information based on the target rules represented by the multiple parallel rule sub-nodes included in the node; If the node is the first node, inputting the second prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, the second prompt information and the output result obtained based on the previous node are input into the large language model to obtain the output result of the large language model.

4. The method according to claim 2 or 3, wherein: The plurality of nodes further include a loop node, the loop node includes at least one loop rule sub-node, the loop rule sub-node represents one of the target rules, and before the final output result is obtained as the target text, the following further includes: If the node is a loop node, generating third prompt information based on the target rule represented by the loop rule subnode included in the node; If the node is the first node, inputting the third prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, inputting the third prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model; The number of loops for the node is increased by one. When the current number of loops does not reach the preset number of times, the third prompt information and the output result obtained in the previous cycle are input into the large language model to obtain the output result of the large language model, and the step of increasing the number of loops for the node by one is returned until the current number of loops reaches the preset number of times.

5. The method according to any one of claims 2 to 4, wherein: The plurality of nodes further include a judgment node, the judgment node including a judgment condition and at least one judgment rule sub-node, the judgment rule sub-node representing one of the target rules, and before obtaining the final output result as the target text, further including: If the node is a judgment node, determine whether the judgment condition included in the node is established; If yes, generating fourth prompt information based on the target rule represented by the judgment rule subnode included in the node; If the node is the first node, inputting the fourth prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, the fourth prompt information and the output result obtained based on the previous node are input into the large language model to obtain the output result of the large language model.

6. The method according to any one of claims 1 to 5, wherein: The step of inputting the plurality of target rules into the large language model in sequence according to the order of the plurality of target rules to obtain the target text of the target type generated by the large language model comprises: If the number of target rules included in the target rule set is greater than or equal to a preset number, the multiple target rules are sequentially input into the large language model in the order of the multiple target rules to obtain the target text of the target type generated by the large language model.

7. The method according to claim 6, further comprising: If the number of rules is less than the preset number, generating fifth prompt information based on the multiple target rules; The fifth prompt information and the question are input into the large language model to obtain a target text of the target type generated by the large language model.

8. The method according to any one of claims 1 to 7, further comprising: after inputting the plurality of target rules into a large language model in sequence according to the order of the plurality of target rules to obtain a target text of the target type generated by the large language model: Verifying whether the target text complies with the target rules according to the order of the multiple target rules; If the target text complies with the multiple target rules, the target text is displayed to the user.

9. The method according to claim 8, wherein: Verifying whether the target text complies with the target rules in the order of the multiple target rules includes: Inputting the first target rule included in the target rule set and the target text into a verification model, verifying whether the target text complies with the first target rule through the verification model, and obtaining an output result of the verification model, wherein the output result indicates a modified text obtained after the verification is passed or after the input target text is modified according to the input target rule; Determining whether the output result of the verification model indicates that the verification is passed; If not, updating the target text to the output result of the verification model; The next target rule included in the target rule set and the current target text are input into the verification model, and the verification model is used to verify whether the input target text complies with the input target rule, to obtain the output result of the verification model, and return to the step of determining whether the output result of the verification model indicates that the verification is passed.

10. The method according to claim 9, after verifying whether the target text complies with the target rules in the order of the plurality of target rules, further comprises: If any of the output results obtained based on the multiple target rules does not indicate that the verification is passed, the most recently updated target text is displayed to the user.

11. The method according to any one of claims 8 to 10, wherein: The target rule has a rule level, and the verifying whether the target text complies with the target rule includes: Get the verification times corresponding to the rule level of the target rule, where the rule level is positively correlated with the verification times; Whether the target text complies with the target rule is verified the number of times.

12. The method according to any one of claims 1 to 11, wherein: The acquiring, from a plurality of preset rule sets, a target rule set corresponding to the target type comprises: From among the preset multiple rule sets, a rule set selected by the user is used as the target rule set; or, Performing text classification on the question to obtain a target type to which the text generated by the question indication belongs; Based on the correspondence between the preset multiple rule sets and the preset types, a target rule set corresponding to the target type is obtained.

13. A device for optimizing large model generated content, comprising: An acquisition module, used for acquiring a question input by a user, wherein the question is used for indicating the generation of a text of a target type; The acquisition module is further used to acquire a target rule set corresponding to the target type from a plurality of preset rule sets, wherein the target rule set includes a plurality of target rules, and the target rules are rules followed by the text of the target type; A generating module is used to input the multiple target rules into the large language model in sequence according to the order of the multiple target rules acquired by the acquiring module, so as to obtain the target text of the target type generated by the large language model.

14. The device according to claim 13, wherein: The target rule set includes a plurality of nodes connected in series, wherein the plurality of nodes includes a rule node representing one of the target rules; the generation module is specifically configured to: According to the order of the plurality of nodes, if the node is a rule node, generating first prompt information based on the target rule represented by the node; If the node is the first node included in the target rule set, inputting the first prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, inputting the first prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model; Until the final output result is obtained as the target text, the final output result is the output result obtained based on the last node included in the target rule set.

15. The device according to claim 14, wherein: The plurality of nodes further include a parallel node, the parallel node includes a plurality of parallel rule sub-nodes, the parallel rule sub-node represents one target rule, and the generating module is further used for: Before the final output result is obtained as the target text, if the node is a parallel node, second prompt information is generated based on the target rules represented by the multiple parallel rule subnodes included in the node; If the node is the first node, inputting the second prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, the second prompt information and the output result obtained based on the previous node are input into the large language model to obtain the output result of the large language model.

16. The device according to claim 14 or 15, wherein: The plurality of nodes further include a loop node, the loop node includes at least one loop rule sub-node, the loop rule sub-node represents one of the target rules, and the generation module is further used for: Before the final output result is obtained as the target text, if the node is a loop node, a third prompt information is generated based on the target rule represented by the loop rule subnode included in the node; If the node is the first node, inputting the third prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, inputting the third prompt information and the output result obtained based on the previous node into the large language model to obtain the output result of the large language model; The number of loops for the node is increased by one. When the current number of loops does not reach the preset number of times, the third prompt information and the output result obtained in the previous cycle are input into the large language model to obtain the output result of the large language model, and the step of increasing the number of loops for the node by one is returned until the current number of loops reaches the preset number of times.

17. The device according to any one of claims 14 to 16, wherein: The multiple nodes further include a judgment node, the judgment node includes a judgment condition and at least one judgment rule sub-node, the judgment rule sub-node represents one of the target rules, and the generation module is further used to: Before obtaining the final output result as the target text, if the node is a judgment node, determining whether the judgment condition included in the node is established; If yes, generating fourth prompt information based on the target rule represented by the judgment rule subnode included in the node; If the node is the first node, inputting the fourth prompt information and the question into the large language model to obtain an output result of the large language model; If the node is not the first node, the fourth prompt information and the output result obtained based on the previous node are input into the large language model to obtain the output result of the large language model.

18. The device according to any one of claims 14 to 17, wherein: The generation module is specifically used for: If the number of target rules included in the target rule set is greater than or equal to a preset number, the multiple target rules are sequentially input into the large language model in the order of the multiple target rules to obtain the target text of the target type generated by the large language model.

19. The device according to claim 18, wherein the generating module is further configured to: If the number of rules is less than the preset number, generating fifth prompt information based on the multiple target rules; The fifth prompt information and the question are input into the large language model to obtain a target text of the target type generated by the large language model.

20. The device according to any one of claims 13 to 19, further comprising: A verification module, configured to input the multiple target rules into the large language model in sequence according to the order of the multiple target rules to obtain a target text of the target type generated by the large language model, and then verify whether the target text complies with the target rules in the order of the multiple target rules; A display module is used to display the target text to the user if the target text complies with the multiple target rules.

21. The device according to claim 20, wherein: The verification module is specifically used for: Inputting the first target rule included in the target rule set and the target text into a verification model, verifying whether the target text complies with the first target rule through the verification model, and obtaining an output result of the verification model, wherein the output result indicates a modified text obtained after the verification is passed or after the input target text is modified according to the input target rule; Determining whether the output result of the verification model indicates that the verification is passed; If not, updating the target text to the output result of the verification model; The next target rule included in the target rule set and the current target text are input into the verification model, and the verification model is used to verify whether the input target text complies with the input target rule, to obtain the output result of the verification model, and return to the step of determining whether the output result of the verification model indicates that the verification is passed.

22. The device according to claim 21, wherein the display module is further used for: After verifying whether the target text complies with the target rules in the order of the multiple target rules, if any output result obtained based on the multiple target rules does not indicate that the verification is passed, the most recently updated target text is displayed to the user.

23. The device according to any one of claims 20 to 22, wherein: The target rule has a rule level, and the verification module is specifically used for: Get the verification times corresponding to the rule level of the target rule, where the rule level is positively correlated with the verification times; Whether the target text complies with the target rule is verified the number of times.

24. The device according to any one of claims 13 to 23, wherein: The acquisition module is specifically used for: From among the preset multiple rule sets, a rule set selected by the user is used as the target rule set; or, Performing text classification on the question to obtain a target type to which the text generated by the question indication belongs; Based on the correspondence between the preset multiple rule sets and the preset types, a target rule set corresponding to the target type is obtained.

25. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 12.

26. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-12.

27. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 12.

Citation Information

Cited By

  • Script generation and model training method and device, storage medium and program product

    CN119808728A