Content generation method, device, electronic device, storage medium and product
By performing dynamic risk detection and filtering in the multi-step reasoning process of large language models, the problem of random and high-risk content generated by the model is solved, and higher-quality and lower-risk content generation is achieved.
Patent Information
- Application Number
- CN202411038307.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-07-31
AI Technical Summary
When generating content, the output content may be relatively random, including sensitive or risky content, resulting in a degradation in the quality of generated content.
During the multi -step reasoning process of the model generating the target content, the first candidate results of each step reasonable test were performed, and the second candidate result of the second candidate that met the requirements of the target risk was determined according to the risk test results.
Through dynamic risk detection and filtering, control the risk of generating content, improve content quality, reduce computing power and time consumption, and ensure that the final generated content meets the target risk requirements.
Smart Images

Figure CN118569266B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a content generation method, device, electronic device, storage medium and product. Background Art
[0002] Natural Language Processing (NLP) is a field that studies and develops technologies that enable computers to understand, process, and generate natural language. Large language models can usually be applied to various NLP tasks. However, the content generated by the model is relatively random and may output some sensitive or risky content that does not meet the requirements, thus reducing the quality of the generated content. Summary of the invention
[0003] The present disclosure provides a content generation method, device, electronic device, storage medium and product.
[0004] In a first aspect, the present disclosure provides a content generation method, the content generation method comprising:
[0005] Obtaining a target prompt, wherein the target prompt at least includes task description information;
[0006] Based on the model, generating target content for the task description information according to the target prompt;
[0007] Among them, the model generates the target content through multi-step reasoning. In the multi-step reasoning process, risk detection is performed on the first candidate reasoning result of the target step reasoning to obtain the risk detection result, and based on the risk detection result, the second candidate reasoning result that meets the target risk requirements is determined, so that the second candidate reasoning result is used for the next step of reasoning.
[0008] In a second aspect, the present disclosure provides a content generation device, the content generation device comprising:
[0009] An acquisition module, used for acquiring a target prompt, wherein the target prompt at least includes task description information;
[0010] A generation module, configured to generate target content for the task description information based on the model and the target prompt, wherein the model generates the target content through multi-step reasoning;
[0011] The risk detection module is used to perform risk detection on the first candidate reasoning result of the target step reasoning in a multi-step reasoning process, obtain the risk detection result, and determine the second candidate reasoning result that meets the target risk requirement based on the risk detection result, so that the second candidate reasoning result can be used for the next step reasoning.
[0012] In a third aspect, the present disclosure provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can execute the above-mentioned content generation method.
[0013] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned content generation method when executed by a processor.
[0014] In a fifth aspect, the present disclosure provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned content generation method.
[0015] The content generation method provided by the embodiment of the present disclosure generates target content for task description information based on a model according to target prompts, and in the multi-step reasoning process of generating the target content, risk detection can be performed on the target reasoning to determine a second candidate reasoning result that meets the target risk requirements for the next reasoning step. In this way, by generating through a multi-step reasoning mechanism and dynamically performing risk detection directly in the reasoning process, risky content can be filtered out. This allows the risk of generated content to be controlled during the reasoning process, rather than performing risk detection and re-generation after all reasoning is completed, thereby reducing computing power and time consumption, improving efficiency, and allowing the target content finally generated to meet the target risk requirements, thereby improving content quality.
[0016] 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
[0017] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings. In the accompanying drawings:
[0018] Figure 1 An application scenario diagram of the content generation method and device provided in the embodiments of the present disclosure;
[0019] Figure 2A flowchart of a content generation method provided by an embodiment of the present disclosure;
[0020] Figure 3 This is an example diagram of risk word detection in an embodiment of the present disclosure;
[0021] Figure 4 is a principle block diagram of a content generation method in an embodiment of the present disclosure;
[0022] Figure 5 is a principle block diagram of task risk analysis in an embodiment of the present disclosure;
[0023] Figure 6 is a principle block diagram of risk word detection in an embodiment of the present disclosure;
[0024] Figure 7 It is a principle block diagram of the domain clause risk detection in the embodiment of the present disclosure;
[0025] Figure 8 A block diagram of a content generation device provided by an embodiment of the present disclosure;
[0026] Fig. 9 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below 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, those of ordinary skill in the art should recognize that various changes and modifications can 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, the description of well-known functions and structures is omitted in the following description.
[0028] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0029] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0030] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0031] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0032] In the technical solution disclosed in this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken for personal information access control; prescribed restrictions are imposed on the display of personal information; the purpose of using personal information does not exceed the scope of direct or reasonable association; when using personal information, clear identity orientation is eliminated to avoid precise positioning of specific individuals.
[0033] Large Language Model (LLM) is very important in the field of Natural Language Processing (NLP) and can usually be applied to various NLP tasks. However, the content generated by the model is relatively random and may output some sensitive or risky content that does not meet the requirements, thus reducing the quality of the generated content.
[0034] In the related art, after LLM outputs all the content, a risk assessment is usually performed on the output content. If the risk is high, the prompt of LLM is modified in a targeted manner, and then input into LLM for regeneration until the content output by LLM meets the risk requirements. However, this method requires repeating the entire reasoning process multiple times by re-modifying the prompt for regeneration, which is inefficient, time-consuming, and consumes more resources and computing power. In addition, the re-modified prompt cannot guarantee the low risk of the LLM output content, and may not be effective, resulting in the inability to obtain reliable and low-risk content. In addition, content with different semantics from the original output may be output, reducing the output quality.
[0035] A content generation method is provided in the disclosed embodiment. In the reasoning process of the model generating target content, risk detection is performed on the first candidate reasoning result of the target step reasoning to obtain the risk detection result, and based on the risk detection result, a second candidate reasoning result that meets the target risk requirement is determined, so that the second candidate reasoning result is used for the next step of reasoning. In this way, risk detection can be performed dynamically in the reasoning process, and risky content can be filtered out to determine content that meets the target risk requirement, so that the target content finally generated can also meet the target risk requirement, thereby improving efficiency, reducing resource computing power consumption, and also improving the quality of generated content.
[0036] Figure 1 The application scenario diagram of the content generation method and device provided by the embodiments of the present disclosure is schematically shown.
[0037] like Figure 1 As shown, the application scenario of the embodiment of the present disclosure may include a terminal device 101, a network 103 and a server 102. The network 103 is used to provide a medium for a communication link between the terminal device 101 and the server 102. The network 103 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0038] The user can use the terminal device 101 to interact with the server 102 through the network 103 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0039] The terminal device 101 may be any electronic device having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, and the like.
[0040] The server 102 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the terminal device 101. The background management server may analyze and process received data such as user requests, and feed back processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0041] It should be noted that the content generation method and apparatus provided in the embodiments of the present disclosure may be executed by the server 102. Accordingly, the content generation method and apparatus provided in the embodiments of the present disclosure may be arranged in the server 102. The content generation method and apparatus provided in the embodiments of the present disclosure may also be executed by a server or server cluster that is different from the server 102 and that can communicate with the terminal device 101 and / or the server 102. Accordingly, the content generation method and apparatus provided in the embodiments of the present disclosure may also be arranged in a server or server cluster that is different from the server 102 and that can communicate with the terminal device 101 and / or the server 102.
[0042] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0043] Figure 2 A flowchart of a content generation method provided by an embodiment of the present disclosure. Figure 2 , the method comprising:
[0044] S210: Obtain a target prompt, where the target prompt at least includes task description information.
[0045] In the embodiments of the present disclosure, there is no limitation on the application scenarios of the content generation method, for example, it can be applied to various NLP tasks such as machine translation, text summarization, question-answering system, dialogue generation, article or report generation, and can also be applied to other graphic tasks, etc. When the user uses the model to generate content, he can input the task description information through the application interface in the terminal in the form of text or voice, and then the model can generate target content that meets the target risk requirements based on the content generation method in the embodiments of the present disclosure.
[0046] Furthermore, in order to further improve the quality of generated content, the present disclosure also provides a possible implementation method, where the target prompt also includes risk constraint information, and the target prompt obtained in step S210 includes:
[0047] 1) Obtaining an initial prompt, wherein the initial prompt is used to indicate the task risk analysis requirements based on the task description information.
[0048] For example, the task description information is: "Please write a report analyzing the A-share market". The task description information and the set fixed task risk analysis instruction statement constitute the initial prompt. For example, the initial prompt is: "{Please write a report analyzing the A-share market}; the above is an instruction task. Please analyze what risks need to be paid attention to if a large language model is used to generate the task results?".
[0049] 2) Based on the initial prompt, perform a task risk analysis on the task description information to obtain risk constraint information when executing the task description information.
[0050] In some possible embodiments of the present disclosure, a task risk analysis model for task risk analysis can be obtained by fine-tuning the LLM model to improve the accuracy of risk analysis, and then the initial prompt is input into the task risk analysis model to perform task risk analysis on the task description information to obtain risk constraint information.
[0051] For example, the risk constraint information obtained is: 1. Avoid incorrect expressions and words; 2. Avoid sensitive content, etc.;…
[0052] 3) Obtaining a target prompt according to the task description information and the risk constraint information, wherein the target prompt is used to indicate that the task description information is to be executed under the condition of the risk constraint information.
[0053] In some possible embodiments, the task description information and the risk constraint information may be combined to obtain a target prompt, for example, the target prompt is: "Task: {Please write a report analyzing the A-share market}; Pay attention to risks: 1. Avoid incorrect expressions and words; 2. Avoid sensitive content, etc.; ...
[0054] In this way, in the embodiment of the present disclosure, based on the task description information, the risks that may be involved in the task are analyzed to obtain risk constraint information, and then based on the task description information and the risk constraint information, the target prompt is obtained and input into the model for content generation, which can reduce the risk of the model output content and improve the content quality.
[0055] S220: Based on the model, target content for the task description information is generated according to the target prompt; wherein the model generates the target content through multi-step reasoning, and in the multi-step reasoning process, risk detection is performed on the first candidate reasoning result of the target step reasoning to obtain the risk detection result, and based on the risk detection result, a second candidate reasoning result that meets the target risk requirement is determined, so that the second candidate reasoning result is used for the next step of reasoning.
[0056] Among them, in the embodiments of the present disclosure, the model can generate target content through multi-step reasoning. For example, for text content generation tasks, the LLM model can be used. The LLM model can generate one word at a time, and each step of reasoning generates one word. The generation of each word depends on the content that has been generated by the previous reasoning. During the reasoning process, risk detection is performed on the target step reasoning. There can be multiple target step reasonings, which can be set according to needs, so that risk detection can be performed on multiple target step reasonings.
[0057] In the disclosed embodiment, target content for task description information can be generated based on the model. The model generates the target content through a multi-step reasoning mechanism, which can improve the similarity between the generated content semantics and the original output semantics, reduce semantic deviation, and improve content quality. In the multi-step reasoning process, risk detection is dynamically performed to filter out content that does not meet the target risk requirements. Content risk can be controlled during the generation process, rather than performing risk detection and re-generation after all reasoning is completed, thereby reducing computing power and time consumption, improving efficiency, and making the final generated target content meet the target risk requirements, thereby improving content quality.
[0058] The following is an explanation of the risk detection in the reasoning process in the content generation method according to the embodiment of the present disclosure. In the embodiment of the present disclosure, the risk detection may include risk word detection and / or domain clause risk detection, specifically:
[0059] In a possible embodiment, risk detection includes risk word detection, and target risk requirements include risk word requirements.
[0060] As mentioned above, the target step reasoning in the above step S220 is each step reasoning in generating the target content, and a risk detection is performed on the first candidate reasoning result of the target step reasoning to obtain the risk detection result, including:
[0061] 1) For any target step reasoning in each step reasoning, a first candidate reasoning result of the target step reasoning is obtained, wherein the first candidate reasoning result includes a first candidate element and a first occurrence probability of the first candidate element.
[0062] For example, the first candidate element in the first candidate inference result of each step of inference may be a word, a phrase, a paragraph or a character, etc., without limitation.
[0063] 2) Determine the joint occurrence probability of the second combination content based on the first combination content of each step of reasoning before the target step of reasoning and the first candidate reasoning result, wherein the first combination content represents the candidate element combination of each step of reasoning before the target step of reasoning, and the second combination content represents the sequential combination of the first combination content and the first candidate element, and the joint occurrence probability is determined based on the first occurrence probability and the corresponding occurrence probability of the first combination content.
[0064] Among them, in the embodiment of the present disclosure, the first combination content of each step of reasoning before the target step of reasoning can be the first preset number of the ones that have passed the risk word detection, that is, no risk word is matched, and belong to the first preset number of the ones with the highest occurrence probability corresponding to each step of reasoning before the target step of reasoning. The occurrence probability corresponding to the first combination content is obtained by multiplying the occurrence probabilities corresponding to the candidate elements of each step of reasoning.
[0065] In the embodiment of the present disclosure, each step of reasoning needs to be based on the previous reasoning results, and multiple possible candidate elements may be output in each step of reasoning. For example, in the target step of reasoning, multiple first candidate elements can be output for the first combination content generated by the previous reasoning on which it depends. The occurrence probabilities corresponding to the first combination content of the previous steps of reasoning are multiplied by each first occurrence probability, and the joint occurrence probability of the second combination content can be obtained. Then, the top k second combination contents with the highest joint occurrence probability can be screened as the input for the next step of reasoning, and the reasoning can be continued. In the embodiment of the present disclosure, before being used as the input for the next step of reasoning, the top k screened second combination contents can also be subjected to risk word detection.
[0066] 3) According to the joint occurrence probability, a preset number of second combination contents with the highest joint occurrence probability are screened out.
[0067] Among them, the preset number can be set according to actual needs and experience, and is not limited in the embodiments of the present disclosure. For example, the use and accuracy of comprehensive resource computing power can be considered.
[0068] 4) The filtered second combination of content is matched in the preset risk word library to obtain the risk detection result.
[0069] Among them, the preset risk word library may include general risk words, domain risk words of the field to which the task description information belongs, etc.
[0070] In the embodiments of the present disclosure, when performing risk word matching, it is not only for the first candidate element inferred in the current target step, but also in combination with the first combined content inferred in each previous step. For example, the first step of inference outputs: word 1, the second step of inference outputs: word 2, and the third step of inference outputs: word 3. Perhaps word 1, word 2, and word 3 themselves do not belong to risk words, and "word 1 word 2" does not belong to risk words, but the three words connected together "word 1 word 2 word 3" may belong to risk words. Therefore, in the embodiments of the present disclosure, matching the second combined content of multiple steps of inference in the risk word library can improve the accuracy of risk word detection.
[0071] For the second candidate inference result that meets the target risk requirement determined according to the risk detection result in the above step S220, it includes:
[0072] 1) In the case where no risk word is matched in the risk detection result, the second combined content screened out is used as the second candidate inference result that meets the risk word requirement.
[0073] 2) In the case where a risk word is matched in the risk detection result, the second combined content where the risk word is matched is deleted, and the first preset number of second combined contents with the highest joint occurrence probability are screened out from the other second combined contents after deleting the second combined content where the risk word is matched. The screened second combined content is matched in the preset risk word library until no risk word is matched in the risk detection result. The second combined content where no risk word is matched is used as the second candidate inference result that meets the risk word requirement.
[0074] For example, referring to Figure 3 As shown, it is an example diagram of risk word detection in the embodiments of the present disclosure. Input 1: "The reason why the A-share market is immature is" is input into the model. In the first step of inference, based on this content, a set of different tokens and their corresponding occurrence probabilities is obtained, as Figure 3 shown. The next word predicted in the first step of inference and its occurrence probability are respectively: supervision (occurrence probability is 0.5), certificate (occurrence probability is 0.1), stock (occurrence probability is 0.3), capital (occurrence probability is 0.05), etc.; the first 2 with the highest occurrence probability, namely "supervision" and "stock", are selected for risk word matching. If no risk word is matched, they are used for the next step of inference.
[0075] In the second step of inference, the inputs are respectively input 2_1: "The reason why the A-share market is immature is supervision", input 2_2: "The reason why the A-share market is immature is stock". Based on each input, multiple next words can be predicted. For example, as Figure 3As shown in the figure, the corresponding inference predictions and their occurrence probabilities when input 2_1 are: management (occurrence probability is 0.6), investigation (occurrence probability is 0.2), prison (occurrence probability is 0.01), control (occurrence probability is 0.1), etc. The two outputs with the highest probability of occurrence (i.e., "management" and "investigation") are selected, and the joint occurrence probability with the output of the first step is calculated, such as the joint occurrence probability of "regulation" is: 0.5×0.6=0.3, and the joint occurrence probability of "supervision" is: 0.5×0.2=0.1; the corresponding inference predictions and their occurrence probabilities when input 2_2 are: people (occurrence probability is 0.5), tickets (occurrence probability is 0.3), cities (occurrence probability is 0.1), disasters (occurrence probability is 0.1), etc. The two outputs with the highest probability of occurrence (i.e., "people" and "tickets") are selected, and the joint occurrence probability with the output of the first step is calculated, such as the joint occurrence probability of "stockholders" is: 0.3×0.5=0.15, and the joint occurrence probability of "stocks" is: 0.3×0.3=0.09.
[0076] In this step, the top two combinations with the highest probability of joint occurrence are screened out, namely "regulation" and "stockholders"; the two screened combinations are matched in the preset risk vocabulary. Assuming that "regulation" is a risk word, the combination "regulation" is deleted. Since the preset number is 2 and only one is matched as a risk word, a combination with the highest probability of occurrence can be selected from other combinations, namely "supervision". If "supervision" is not a risk word, then "stockholders" and "supervision" can be used for the next reasoning step.
[0077] In the third step of reasoning, the inputs are input 3_1: "The reason why the A-share market is immature is stockholders" and input 3_2: "The reason why the A-share market is immature is supervision". Similarly, the prediction of the third step of reasoning and the joint occurrence probability of the first and second steps of reasoning are calculated, which are: the joint occurrence probability of "stockholders know" is: 0.3×0.5×0.5=0.075, the joint occurrence probability of "stockholders are sensitive" is: 0.3×0.5×0.4=0.06, the joint occurrence probability of "poor supervision" is 0.5×0.2×0.4=0.04, and the joint occurrence probability of "no supervision" is 0.5×0.2×0.3=0.03. Then, the top two combinations with the highest joint occurrence probability are screened out, and risk word detection is continued until the risk word detection of all steps of reasoning of the model is completed.
[0078] In the disclosed embodiments, during the reasoning process of the model generating the target content, dynamic risk word detection and control are performed to filter out risk words, so that the target content finally generated also meets the risk word requirements, rather than checking and regenerating after all the reasoning is completed. This improves efficiency, reduces computing power and time consumption, and each step of reasoning can control the generated content based on the probability of occurrence, thereby improving the quality and accuracy of content generation.
[0079] In a possible embodiment, when risk detection includes domain clause risk detection, target risk requirements include domain clause risk requirements.
[0080] Based on the above embodiment, the risk detection in the above step S220 includes domain clause risk detection, the target step reasoning is the xNth step reasoning in generating the target content, x and N are both positive integers, N represents a cycle, and x represents a multiple of the cycle. For the first candidate reasoning result of the target step reasoning, risk detection is performed to obtain the risk detection result, including:
[0081] 1) When reaching an xN-th reasoning step, obtaining the third combination content from the 0th reasoning step to the xN-th reasoning step, wherein the third combination content represents the candidate element combination in the first candidate reasoning result from the 0th reasoning step to the xN-th reasoning step.
[0082] Among them, in the disclosed embodiment, N is a configurable parameter, and x can be [1,2,3,…x]. For example, if N is 10, then the domain clause risk detection is performed every 10 steps of reasoning, that is, the domain clause risk detection is performed at the 10th step of reasoning, the 20th step of reasoning, etc. In the disclosed embodiment, since the domain clause risk detection usually needs to be judged by semantic analysis, it is necessary to target a piece of content. A shorter word or several words may be difficult to accurately express its semantics. In this way, the domain clause risk detection is performed after a certain number of steps of reasoning, which can not only more accurately determine whether there is a domain clause risk, but also improve efficiency and reduce computing power consumption.
[0083] Furthermore, the domain clause risk requirements may be pre-customized, and corresponding domain clause risk requirements may be configured for different domains, which is not limited in the embodiments of the present disclosure.
[0084] 2) According to the risk requirements of the domain terms, detect whether the third combination content meets the risk requirements of the domain terms and obtain the risk detection results.
[0085] In the disclosed embodiment, it can be implemented based on a risk analysis model for domain clause risk detection. According to the third combination content of step 0 to step xN, and the domain clause risk requirements, a risk detection prompt is obtained, and the risk detection prompt is input into the risk analysis model to determine whether the domain clause risk requirements are met. The risk analysis model can be a binary classification model that outputs yes or no, wherein a more accurate risk analysis model can be obtained by fine-tuning the instructions.
[0086] For example, the risk detection prompt is: "Text: {the third combination content of steps 0 to xN}; domain clause risk requirements: {configured domain clause risk requirements}; instruction: please determine whether the text content above meets all domain clause risk requirements. If so, output "yes", if not, output "no".
[0087] In the above step S220, according to the risk detection result, a second candidate reasoning result that meets the target risk requirement is determined, including:
[0088] 1) When the risk detection result meets the risk requirements of the domain clause, the third combination content is used as the second candidate reasoning result that meets the risk requirements of the domain clause.
[0089] 2) When the risk detection result is that the risk requirements of the domain clause are not met, the fourth combination of candidate elements in the first candidate reasoning result from the (x-1)Nth step to the xNth step is deleted, and reasoning is performed again from the (x-1)Nth step. When the xNth step is reached, the fifth combination of content from the 0th step to the xNth step is tested again to see whether it meets the risk requirements of the domain clause, until the risk detection result is that the risk requirements of the domain clause are met, and the fifth combination that meets the risk requirements of the domain clause is used as the second candidate reasoning result.
[0090] Furthermore, before re-inference from the (x-1)Nth step, the disclosed embodiment also provides a possible implementation method for adjusting the generation parameters of the model.
[0091] For example, adjust the generation parameter to temperature_xN = temperature_default + 0.1. Temperature is a generation parameter that can be used to control the creativity level of the model-generated content. By adjusting the temperature, the probability distribution of the model output content can be affected. For example, reducing the temperature can make the content more concentrated, and increasing the temperature can make the content more diversified. Furthermore, if the 0~xN step reasoning results meet the domain clause risk requirements, the temperature can be restored to the default value temperature_default to continue the next step of reasoning.
[0092] In this way, in the embodiment of the present disclosure, during the reasoning process of the model generating the target content, domain clause risk detection can also be performed, and risk assessment and compliance detection of domain clauses can be performed on the output content to reduce content risks and improve the quality and reliability of content generation. In addition, domain clause risk detection can also be performed during the reasoning process to improve efficiency.
[0093] It should be noted that in the embodiments of the present disclosure, during the reasoning process of the model generating the target content, only risk word detection or domain clause risk detection may be performed, or the two risk detections may be combined, so that risks can be controlled from multiple levels and the quality of content generation can be further improved. In the case of combining the two risk detections, there is no restriction on the execution order of risk word detection and domain clause risk detection. For example, risk word detection may be performed at each step of reasoning, and when reaching the xNth step of reasoning, risk word detection may be performed first, and after the risk word requirements are met, domain clause risk detection may be performed. After all requirements are met, the next step of reasoning may be continued. Of course, other risk detection methods may also be used in the embodiments of the present disclosure, and there is no restriction on this.
[0094] The content generation method in the embodiment of the present disclosure is described below using a specific application scenario, taking risk detection including risk word detection and domain clause detection as an example.
[0095] See also Figure 4 As shown, it is a principle block diagram of the content generation method in the embodiment of the present disclosure, such as Figure 4 As shown, the content generation method in the embodiment of the present disclosure may mainly include task risk analysis, model-based content generation, risk word detection and domain clause risk detection, specifically:
[0096] 1) Input the task description information into the task risk analysis module to obtain the risk constraint information when executing the task description information, and obtain the target prompt according to the task description information and the risk constraint information.
[0097] 2) Input the target prompt into the model used to generate task content.
[0098] 3) In the multi-step reasoning process of the model generating the target content, the first candidate reasoning result of the target step reasoning is input into the risk detection module, wherein the risk detection may include risk word detection and domain clause risk detection.
[0099] 4) Based on the risk detection module, risk detection is performed on the first candidate reasoning result of the target step reasoning to determine the second candidate reasoning result that meets the target risk requirements, and then the target content of the final output is obtained.
[0100] In one possible embodiment of the present disclosure, a possible embodiment is also provided for task risk analysis, see Figure 5 , which is a principle block diagram of task risk analysis in an embodiment of the present disclosure.
[0101] like Figure 5As shown, the initial prompt is input into the task risk analysis module, and the task risk analysis is performed on the task description information according to the initial prompt to obtain risk constraint information. It can be known which risks need to be paid attention to when executing the task description information, and then the risk constraint information and the task description information are merged to obtain the final target prompt.
[0102] In this way, in the embodiment of the present disclosure, the risks that may be involved in the task description information can be analyzed, and then the risk constraint information and the task description information can be merged and input into the model used to generate task content, thereby reducing the risk of the model output and improving the quality of the model output content.
[0103] In a possible embodiment of the present disclosure, a possible embodiment is also provided for risk word detection, see Figure 6 , which is a principle block diagram of risk word detection in an embodiment of the present disclosure.
[0104] In the disclosed embodiment, the model generates target content through multi-step reasoning. For example, a beam search mechanism may be used for reasoning to obtain better reasoning effect.
[0105] 1) In a multi-step reasoning process, in a possible embodiment of the present disclosure, risk word detection can be performed for each step of reasoning. Taking the nth step of reasoning as an example, Figure 6 As shown, the input _n of the nth step is input into the model to obtain multiple first candidate elements and the first occurrence probability of each first candidate element, and then determine the joint occurrence probability of the second combination content inferred from the first step to the nth step.
[0106] 2) Filter out the first preset number of second combination contents with the highest probability of joint occurrence, and match them in the preset risk word library.
[0107] 3) If no risk word is matched, the screened second combination content is used as the second candidate reasoning result that meets the risk word requirements, and is used as the input of the n+1th step to continue reasoning.
[0108] When a risk word is matched, the second combination content that matches the risk word is deleted, and the first preset number of second combination contents with the highest joint occurrence probability are screened out from other second combination contents, and risk word matching is performed until the risk detection result is that no risk word is matched.
[0109] Furthermore, based on the above embodiment, risk word detection is performed for each step of reasoning until all steps of reasoning are completed to obtain the target content.
[0110] In this way, in the embodiment of the present disclosure, the reasoning mechanism is adopted, and the risk word library is combined to perform dynamic detection and avoidance of risk words, so that the model can identify and filter out possible risks in real time when generating content, thereby improving the quality of generated content.
[0111] In a possible embodiment of the present disclosure, a possible embodiment is also provided for domain clause risk detection, see Figure 7 , which is a principle block diagram of domain clause risk detection in an embodiment of the present disclosure.
[0112] 1) In a multi-step reasoning process, in one possible implementation, domain clause risk detection can be performed for the xNth step reasoning. Taking the xNth step as an example, refer to Figure 7 As shown, the third combination content of the reasoning from step 0 to step xN and the risk requirements of the domain clauses are combined to obtain a risk detection prompt, and the risk detection prompt is input into the risk analysis model, wherein the risk detection prompt is used to indicate whether the third combination content meets the risk requirements of the domain clauses.
[0113] 2) Based on the risk analysis model and according to the risk detection prompt, it is determined whether the third combination content meets the risk requirements of the risk clause, and the risk analysis module can output a risk detection result of yes or no.
[0114] 3) If yes, that is, the domain clause risk requirement is met, then the next step of reasoning can be continued. When the (x+1)Nth step of reasoning is reached, the domain clause risk detection is performed again.
[0115] If the answer is no, that is, the risk requirements of the domain clause are not met, then the fourth combination of content from the (x-1)Nth step reasoning to the xNth step reasoning is deleted, and the generation parameters of the model can also be adjusted to increase the diversity of the model, and the reasoning is performed again from the (x-1)Nth step, and the cycle is repeated until the reasoning from step 0 to step xN meets the risk requirements of the domain clause.
[0116] In this way, in the embodiment of the present disclosure, during the reasoning process, it is possible to continuously detect whether the risk requirements of the domain clauses are met, and it is also possible to perform diversity adjustments, thereby improving efficiency and ensuring that the ultimately generated content can both meet the needs and reduce risks and improve content quality.
[0117] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0118] In addition, the present disclosure also provides a content generating device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any content generating method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to in the corresponding records of the method part and will not be repeated here.
[0119] Figure 8 A block diagram of a content generation device provided in an embodiment of the present disclosure.
[0120] Reference Figure 8 , an embodiment of the present disclosure provides a content generation device, the content generation device comprising:
[0121] An acquisition module 81 is used to obtain a target prompt, wherein the target prompt at least includes task description information;
[0122] A generating module 82, configured to generate target content for the task description information based on the model and the target prompt, wherein the model generates the target content through multi-step reasoning;
[0123] The risk detection module 83 is used to perform risk detection on the first candidate reasoning result of the target step reasoning in a multi-step reasoning process, obtain the risk detection result, and determine the second candidate reasoning result that meets the target risk requirement based on the risk detection result, so that the second candidate reasoning result can be used for the next step of reasoning.
[0124] In some possible embodiments, the target prompt also includes risk constraint information. When obtaining the target prompt, the obtaining module 81 is used to:
[0125] Acquire an initial prompt, wherein the initial prompt is used to indicate a task risk analysis requirement according to task description information;
[0126] According to the initial prompt, performing a task risk analysis on the task description information to obtain risk constraint information when executing the task description information;
[0127] A target prompt is obtained according to the task description information and the risk constraint information, wherein the target prompt is used to indicate that the task description information is executed under the condition of the risk constraint information.
[0128] In some possible embodiments, the risk detection includes risk word detection, the target step reasoning is each step of reasoning in generating the target content, and the first candidate reasoning result of the target step reasoning is subjected to risk detection. When the risk detection result is obtained, the risk detection module 83 is used to:
[0129] For any target step reasoning in each step reasoning, obtaining a first candidate reasoning result of the target step reasoning, wherein the first candidate reasoning result includes a first candidate element and a first occurrence probability of the first candidate element;
[0130] Determine the joint occurrence probability of the second combination content according to the first combination content of each step of reasoning before the target step of reasoning and the first candidate reasoning result, wherein the first combination content represents the candidate element combination of each step of reasoning before the target step of reasoning, the second combination content represents the sequential combination of the first combination content and the first candidate element, and the joint occurrence probability is determined according to the first occurrence probability and the corresponding occurrence probability of the first combination content;
[0131] According to the joint occurrence probability, a preset number of second combination contents having the highest joint occurrence probability are screened out;
[0132] The filtered second combination content is matched in a preset risk word library to obtain a risk detection result.
[0133] In some possible embodiments, the target risk requirement includes a risk word requirement. When determining the second candidate reasoning result that meets the target risk requirement based on the risk detection result, the risk detection module 83 is used to:
[0134] In the case that the risk detection result is that no risk word is matched, the screened second combination content is used as a second candidate reasoning result that meets the risk word requirement;
[0135] In the case where the risk detection result is a match with a risk word, the second combination content that matches the risk word is deleted, and the first preset number of second combination contents with the highest joint occurrence probability are screened out from the other second combination contents after the deletion of the second combination content that matches the risk word, and the screened out second combination contents are matched in a preset risk word library until the risk detection result is no match with the risk word, and the second combination content that does not match the risk word is used as the second candidate inference result that meets the risk word requirement.
[0136] In some possible embodiments, the risk detection includes domain clause risk detection, the target step reasoning is the xNth step reasoning in generating the target content, x and N are both positive integers, N represents a cycle, and x represents a multiple of the cycle, and the first candidate reasoning result of the target step reasoning is subjected to risk detection. When the risk detection result is obtained, the risk detection module 83 is used to:
[0137] When reaching an xN-th reasoning step, obtaining a third combination content from the 0th reasoning step to the xN-th reasoning step, wherein the third combination content represents a candidate element combination in the first candidate reasoning result from the 0th reasoning step to the xN-th reasoning step;
[0138] According to the risk requirements of the domain terms, detect whether the third combination content meets the risk requirements of the domain terms to obtain a risk detection result.
[0139] In some possible embodiments, the target risk requirement includes the field clause risk requirement. When determining the second candidate reasoning result that meets the target risk requirement based on the risk detection result, the risk detection module 83 is used to:
[0140] In the case where the risk detection result satisfies the risk requirement of the field clause, the third combination content is used as a second candidate reasoning result that meets the risk requirement of the field clause;
[0141] When the risk detection result is that the risk requirement of the domain clause is not met, the fourth combination content composed of the candidate elements in the first candidate reasoning result from the (x-1)Nth step reasoning to the xNth step reasoning is deleted, and the reasoning is performed again from the (x-1)Nth step, and when the xNth step reasoning is reached, the fifth combination content from the 0th step reasoning to the xNth step reasoning is checked again to see whether it meets the risk requirement of the domain clause, until the risk detection result is that it meets the risk requirement of the domain clause, and the fifth combination content that meets the risk requirement of the domain clause is used as the second candidate reasoning result.
[0142] In some possible embodiments, before re-inference from the (x-1)Nth step, the risk detection module 83 is further used to: adjust generation parameters of the model.
[0143] Each module in the above content generation device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0144] Fig. 9 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0145] Reference Fig. 9An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 901; at least one memory 902, and one or more I / O interfaces 903, connected between the processor 901 and the memory 902; wherein the memory 902 stores one or more computer programs that can be executed by the at least one processor 901, and the one or more computer programs are executed by the at least one processor 901 so that the at least one processor 901 can execute the above-mentioned content generation method.
[0146] Each module in the above electronic device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0147] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned content generation method when executed by a processor. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0148] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned content generation method.
[0149] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a transient medium).
[0150] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable program instructions, data structures, program modules or other data. Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is known to those of ordinary skill in the art, communication media typically contain computer readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0151] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0152] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet). In some embodiments, by using the state information of the computer-readable program instructions to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit may execute the computer-readable program instructions, thereby implementing various aspects of the present disclosure.
[0153] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0154] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0155] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0156] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0157] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0158] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A content generation method, characterized in that: include: Obtaining a target prompt, wherein the target prompt at least includes task description information; Based on the model, generating target content for the task description information according to the target prompt; The model generates the target content through multi-step reasoning. In the multi-step reasoning process, a risk detection is performed on the first candidate reasoning result of the target step reasoning to obtain a risk detection result, and a second candidate reasoning result that meets the target risk requirement is determined based on the risk detection result, so that the second candidate reasoning result is used for the next step reasoning; The risk detection includes risk word detection, the target step reasoning is each step of reasoning in generating the target content, and the risk detection is performed on the first candidate reasoning result of the target step reasoning to obtain the risk detection result, including: For any target step reasoning in each step reasoning, obtaining a first candidate reasoning result of the target step reasoning, wherein the first candidate reasoning result includes a first candidate element and a first occurrence probability of the first candidate element; Determine the joint occurrence probability of the second combination content according to the first combination content of each step of reasoning before the target step of reasoning and the first candidate reasoning result, wherein the first combination content represents the candidate element combination of each step of reasoning before the target step of reasoning, the second combination content represents the sequential combination of the first combination content and the first candidate element, and the joint occurrence probability is determined according to the first occurrence probability and the corresponding occurrence probability of the first combination content; According to the joint occurrence probability, a preset number of second combination contents with the highest joint occurrence probability are screened out; the screened out second combination contents are matched in a preset risk word library to obtain a risk detection result.
2. The method according to claim 1, characterized in that The target prompt also includes risk constraint information, and obtaining the target prompt includes: Acquire an initial prompt, wherein the initial prompt is used to indicate a task risk analysis requirement according to task description information; According to the initial prompt, performing a task risk analysis on the task description information to obtain risk constraint information when executing the task description information; A target prompt is obtained according to the task description information and the risk constraint information, wherein the target prompt is used to indicate that the task description information is executed under the condition of the risk constraint information.
3. The method according to claim 1, characterized in that The target risk requirement includes a risk word requirement, and determining a second candidate reasoning result that meets the target risk requirement according to the risk detection result includes: In the case that the risk detection result is that no risk word is matched, the screened second combination content is used as a second candidate reasoning result that meets the risk word requirement; In the case where the risk detection result is a match with a risk word, the second combination content that matches the risk word is deleted, and the first preset number of second combination contents with the highest joint occurrence probability are screened out from the other second combination contents after the deletion of the second combination content that matches the risk word, and the screened out second combination contents are matched in a preset risk word library until the risk detection result is no match with the risk word, and the second combination content that does not match the risk word is used as the second candidate inference result that meets the risk word requirement.
4. The method according to any one of claims 1 to 3, characterized in that: The risk detection includes domain clause risk detection, the target step reasoning is the xNth step reasoning in generating the target content, x and N are both positive integers, N represents a cycle, and x represents a multiple of the cycle, and the risk detection is performed on the first candidate reasoning result of the target step reasoning to obtain the risk detection result, including: When reaching an xN-th reasoning step, obtaining a third combination content from the 0th reasoning step to the xN-th reasoning step, wherein the third combination content represents a candidate element combination in the first candidate reasoning result from the 0th reasoning step to the xN-th reasoning step; According to the risk requirements of the domain terms, detect whether the third combination content meets the risk requirements of the domain terms to obtain a risk detection result.
5. The method according to claim 4, characterized in that The target risk requirement includes the field clause risk requirement, and the second candidate reasoning result that meets the target risk requirement is determined according to the risk detection result, including: In the case where the risk detection result satisfies the risk requirement of the field clause, the third combination content is used as a second candidate reasoning result that meets the risk requirement of the field clause; When the risk detection result is that the risk requirement of the domain clause is not met, the fourth combination content composed of the candidate elements in the first candidate reasoning result from the (x-1)Nth step reasoning to the xNth step reasoning is deleted, and the reasoning is performed again from the (x-1)Nth step, and when the xNth step reasoning is reached, the fifth combination content from the 0th step reasoning to the xNth step reasoning is checked again to see whether it meets the risk requirement of the domain clause, until the risk detection result is that it meets the risk requirement of the domain clause, and the fifth combination content that meets the risk requirement of the domain clause is used as the second candidate reasoning result.
6. The method according to claim 5, characterized in that Before re-reasoning from the (x-1)Nth step, the method further includes: Adjusting the generation parameters of the model.
7. A content generating device, characterized in that: include: An acquisition module, used for acquiring a target prompt, wherein the target prompt at least includes task description information; A generating module, configured to generate target content for the task description information based on the model and the target prompt, wherein the model generates the target content through multi-step reasoning; A risk detection module is used to perform risk detection on a first candidate reasoning result of a target step reasoning in a multi-step reasoning process, obtain a risk detection result, and determine a second candidate reasoning result that meets the target risk requirement based on the risk detection result, so that the second candidate reasoning result is used for the next step reasoning; Wherein, the risk detection includes risk word detection, the target step reasoning is each step reasoning in generating the target content, the first candidate reasoning result of the target step reasoning is subjected to risk detection, and when the risk detection result is obtained, the risk detection module is used to: For any target step reasoning in each step reasoning, obtaining a first candidate reasoning result of the target step reasoning, wherein the first candidate reasoning result includes a first candidate element and a first occurrence probability of the first candidate element; Determine the joint occurrence probability of the second combination content according to the first combination content of each step of reasoning before the target step of reasoning and the first candidate reasoning result, wherein the first combination content represents the candidate element combination of each step of reasoning before the target step of reasoning, the second combination content represents the sequential combination of the first combination content and the first candidate element, and the joint occurrence probability is determined according to the first occurrence probability and the corresponding occurrence probability of the first combination content; According to the joint occurrence probability, a preset number of second combination contents with the highest joint occurrence probability are screened out; the screened out second combination contents are matched in a preset risk word library to obtain a risk detection result.
8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the content generation method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the content generation method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The invention comprises a computer-readable code or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the content generation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Risk detection method, device and equipment for to-be-published text
CN112015869A
Method and device for generating word bank
CN113128209A