Artificial intelligence content generation method, device, electronic device and storage medium
By introducing token authentication and intent recognition sensitive word extraction mechanisms in artificial intelligence content generation technology, the problem of lack of content verification in the existing technology is solved, and the security, legality and harmlessness of content generation are guaranteed.
Patent Information
- Application Number
- CN202411938540.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-01
AI Technical Summary
The existing artificial intelligence content generation technology lacks the verification and review of model input and output content, which makes it difficult to effectively prevent abnormal intentions and leakage of sensitive words in the content while ensuring the quality and security of content.
By obtaining the user's token and authenticating, if the token authentication is passed, the target language model is called based on the model call parameters to identify the intent of the input content, extracting the first sensitive word and generating the content in parallel. If the target termination condition is met, the relevant process will be terminated and prompt information will be output; if the termination condition is not met, the generated content will be output.
The security of content generation services is ensured through the token authentication mechanism, and the verification of the input and output content of the model is achieved through intention identification and sensitive word extraction, ensuring the efficiency, legality and harmlessness of the generated content.
Smart Images

Figure CN119740671A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an artificial intelligence content generation method, device, electronic device and storage medium. Background Art
[0002] With the continuous advancement of artificial intelligence and natural language processing technology, the number of parameters in large language models continues to increase, which will inevitably lead to a significant increase in the computing resources required for the deployment and operation of large language models. Considering the expensive cost of computing resources, in order to prevent the waste and leakage of computing resources, it is of great strategic significance to realize the authentication of calling large language models. In addition, with the continuous improvement of the functions of large language models, more caution is needed when applying large language models. The input and output of large language models must be effectively verified to ensure the legality and harmlessness of the model input and output content.
[0003] In recent years, research on AI content generation technology has made continuous progress, mainly focusing on the following two aspects:
[0004] (1) Improving the quality, specificity, and accuracy of model output content, mainly including the following implementation methods: improving the quality of model output content by analyzing the semantics of model input content; improving the quality of model output content by extracting the features of model input content and enriching the description of user input, or by generating content multiple times; effectively retrieving or supplementing model input content and adding personalized elements to improve the accuracy and specificity of model output content.
[0005] (2) Improving the security of model input and output content mainly includes the following implementation methods: preventing the leakage of user privacy information during the network transmission of model input content; using non-fungible token (NFT) technology to control the generation of model output content during the content generation process.
[0006] It can be seen that most of the existing AI content generation technologies focus on improving the quality of AI-generated content by adjusting model input content, adding relevant information, and generating content multiple times, and only improve the security of AI-generated content from the perspective of preventing user privacy leakage and controlling model output content generation. However, the existing AI content generation technologies lack implementation methods for verification and auditing of model input and output content. Summary of the invention
[0007] In view of this, an object of the present invention is to provide an artificial intelligence content generation method, device, electronic device and storage medium to alleviate the above-mentioned problems existing in the related art.
[0008] In a first aspect, an embodiment of the present invention provides an artificial intelligence content generation method, comprising: obtaining a token and input content corresponding to a user, and authenticating the token; wherein the token includes authentication information and load information, and the load information includes a model call parameter; if the token authentication is passed, calling a target language model based on the model call parameter to perform intent recognition, first sensitive word extraction and content generation of the input content in parallel; wherein the content generation includes: generating generated content corresponding to the input content, and performing second sensitive word extraction on the generated content; if a target termination condition is met, the intent recognition, the first sensitive word extraction and the content generation are terminated, and the target language model outputs prompt information corresponding to the target termination condition; wherein the target termination condition includes at least one of the following: the intent of the input content is identified as abnormal during the intent recognition process, sensitive words are extracted from the input content during the first sensitive word extraction process, and sensitive words are extracted from the generated content during the second sensitive word extraction process; if the target termination condition is not met, the target language model outputs the generated content after the intent recognition, the first sensitive word extraction and the content generation are completed.
[0009] In a second aspect, an embodiment of the present invention further provides an artificial intelligence content generation device, comprising: an authentication module, used to obtain a token and input content corresponding to a user, and authenticate the token; wherein the token includes authentication information and load information, and the load information includes a model call parameter; a parallel processing module, used to call a target language model based on the model call parameter to perform intent recognition, first sensitive word extraction and content generation of the input content in parallel if the token authentication is passed; wherein the content generation includes: generating generated content corresponding to the input content, and performing second sensitive word extraction on the generated content; a first output module, used to terminate the intent recognition, the first sensitive word extraction and the content generation if a target termination condition is met, and the target language model outputs prompt information corresponding to the target termination condition; wherein the target termination condition includes at least one of the following: the intent of the input content is identified as abnormal during the intent recognition process, sensitive words are extracted from the input content during the first sensitive word extraction process, and sensitive words are extracted from the generated content during the second sensitive word extraction process; a second output module, used to output the generated content after the intent recognition, the first sensitive word extraction and the content generation are completed if the target termination condition is not met.
[0010] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the artificial intelligence content generation method described in the first aspect above.
[0011] In a fourth aspect, an embodiment of the present invention further provides a storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the artificial intelligence content generation method described in the first aspect above.
[0012] An artificial intelligence content generation method, device, electronic device and storage medium provided by an embodiment of the present invention obtains a token (including authentication information and load information, the load information includes model call parameters) and input content corresponding to a user, and authenticates the token; if the token authentication is passed, the target language model is called based on the model call parameters to perform intent recognition, first sensitive word extraction and content generation of the input content in parallel; if the target termination condition is met, the intent recognition, first sensitive word extraction and content generation are terminated, and the target language model outputs prompt information corresponding to the target termination condition; if the target termination condition is not met, after the intent recognition, first sensitive word extraction and content generation are completed, the target language model outputs the generated content. By adopting the above technology, the security of the artificial intelligence content generation service can be guaranteed by token authentication, the verification of the model input and output content can be realized by intent recognition and sensitive word extraction, and efficient and risk-controlled artificial intelligence content generation can be realized by asynchronously executing intent recognition, first sensitive word extraction and content generation in parallel, thereby ensuring the efficiency, legality and harmlessness of artificial intelligence content generation.
[0013] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0014] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 A schematic diagram of a flow chart of an artificial intelligence content generation method in an embodiment of the present invention;
[0017] Figure 2 This is a flow chart of token generation in an embodiment of the present invention;
[0018] Figure 3 This is a token verification flow chart in an embodiment of the present invention;
[0019] Figure 4 A flowchart of artificial intelligence content generation in an embodiment of the present invention;
[0020] Figure 5 This is a schematic diagram of the structure of an artificial intelligence content generation device in an embodiment of the present invention;
[0021] Figure 6 The figure is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described in combination with the embodiments below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] Currently, most existing AI content generation technologies focus on improving the quality of AI-generated content by adjusting model input content, adding relevant information, and generating content multiple times. They also only improve the security of AI-generated content from the perspective of preventing user privacy leakage and controlling model output content generation. However, existing AI content generation technologies lack implementation methods for verification and auditing of model input and output content.
[0024] Based on this, the present invention provides an artificial intelligence content generation method, device, electronic device and storage medium, which can alleviate the above-mentioned problems existing in the related technology.
[0025] To facilitate understanding of this embodiment, firstly, an artificial intelligence content generation method, device, electronic device and storage medium disclosed in the embodiment of the present invention are described in detail, see Figure 1 As shown, the method may include the following steps:
[0026] Step S102, obtaining the token and input content corresponding to the user, and authenticating the token.
[0027] The token may include authentication information and load information, and the load information may include model calling parameters; the authentication information may be used for authentication of the token, and the model calling parameters may be used to call the corresponding language model.
[0028] Step S104, if the token authentication is passed, the target language model is called based on the model calling parameters to perform intent recognition of the input content, first sensitive word extraction and content generation in parallel.
[0029] The content generation may include: generating generated content corresponding to the input content, and extracting second sensitive words from the generated content.
[0030] Step S106: If the target termination condition is met, the intent recognition, the first sensitive word extraction and the content generation are terminated, and the target language model outputs prompt information corresponding to the target termination condition.
[0031] Among them, the target termination condition may include at least one of the following: identifying that the intention of the input content is abnormal during the intention recognition process, extracting sensitive words from the input content during the first sensitive word extraction process, and extracting sensitive words from the generated content during the second sensitive word extraction process.
[0032] Step S108, if the target termination condition is not met, after the intent recognition, the first sensitive word extraction and the content generation are completed, the target language model outputs the generated content.
[0033] An artificial intelligence content generation method provided by an embodiment of the present invention obtains a token (including authentication information and load information, the load information includes model call parameters) and input content corresponding to a user, and authenticates the token; if the token authentication is passed, the target language model is called based on the model call parameters to perform intent recognition, first sensitive word extraction and content generation of the input content in parallel; if the target termination condition is met, the intent recognition, first sensitive word extraction and content generation are terminated, and the target language model outputs prompt information corresponding to the target termination condition; if the target termination condition is not met, after the intent recognition, first sensitive word extraction and content generation are completed, the target language model outputs the generated content. By adopting the above technology, the security of the artificial intelligence content generation service can be guaranteed by token authentication, the verification of the model input and output content can be realized by intent recognition and sensitive word extraction, and efficient and risk-controlled artificial intelligence content generation can be realized by asynchronously executing intent recognition, first sensitive word extraction and content generation in parallel, thereby ensuring the efficiency, legality and harmlessness of artificial intelligence content generation.
[0034] As a possible implementation, the authentication information may include header information and signature information, and the payload information may also include an expiration time. Based on this, the authentication of the token in the above step S102 may include:
[0035] Step 1: Verify the header information and signature information.
[0036] The token can be generated using JSON Web Token (JWT) technology, see Figure 2 As shown, the generated token is a string, which consists of three parts: header information, payload information and signature information. The header information specifies the signature algorithm used to generate the signature information (such as HMAC-SHA256, etc.), and the payload information contains user usage information (such as expiration time, parameter information and calling frequency of the large language model to be called, etc.); the signature information is generated based on the product key, and the signature algorithm specified in the header information can be used to sign the header information, payload information and product key to obtain the signature information; when a user applies for a token, the client corresponding to the user will send a registration request to the corresponding server. After receiving the registration request, the server will use the system default information (that is, the default header information and signature information) combined with the user-defined information (that is, the user-specific payload information) to generate the corresponding token, and return the token to the client, and the client will store the token locally.
[0037] See also Figure 3 As shown, when the client communicates with the server, the client carries the locally stored token to be verified in the request (the token to be verified should be in the request header) and sends it to the server. After receiving the request carrying the token to be verified, the server will use the signature algorithm specified by the header information of the token to be verified to sign the header information, payload information and product key of the token to be verified to determine whether the obtained information to be verified is consistent with the signature information of the token to be verified, thereby verifying the header information and signature information.
[0038] Step 2: If the header information and signature information are verified, determine whether the token is expired based on the expiration time.
[0039] Continuing from the previous example, see Figure 3 As shown, during the process of verifying the header information and signature information of the token provided by the client, if the information to be verified is consistent with the corresponding signature information, the header information and signature information verification is passed, and the payload information of the token provided by the client can be further obtained, and the expiration time in the payload information is compared with the current time to determine whether the token is expired.
[0040] Step 3: If the token has not expired, the token authentication is successful.
[0041] Continuing from the previous example, see Figure 3 As shown, if the expiration time in the payload information of the token provided by the client is later than the current time of the server, the server determines that the token has not expired and the token authentication is successful.
[0042] Step 4: If the header information and signature information verification fails or the token has expired, the token authentication fails.
[0043] Continuing from the previous example, see Figure 3 As shown, if the information to be verified generated using the token provided by the client is inconsistent with the corresponding signature information, the header information and signature information verification fail, the token authentication fails, and the server returns a prompt message to the client indicating that the token is invalid; if the expiration time in the payload information of the token provided by the client is not later than the current time of the server, the server determines that the token has expired, the token authentication fails, and the server returns a prompt message to the client indicating that the token has expired.
[0044] As a possible implementation, the model calling parameters may include parameter information and calling frequency of the target language model. Based on this, in the above step S104, calling the target language model based on the model calling parameters and performing input content intent recognition, first sensitive word extraction and content generation in parallel may include:
[0045] Step A1: determining a target language model from a plurality of preset language models based on parameter information.
[0046] Among them, the parameter information can represent the interface parameters required for calling the corresponding language model, that is, the parameter information indicates which language model interface service is specifically called for content generation; the calling frequency indicates the frequency of using the language model interface service request when calling the language model interface service.
[0047] The above-mentioned multiple language models may include a small language model, a medium language model and a large language model; the number of parameters of the small language model is smaller than that of the medium language model, and the number of parameters of the medium language model is smaller than that of the large language model. For example, a language model with a parameter number of 7 billion or less can be defined as a small language model, a language model with a parameter number greater than 7 billion and less than 32 billion can be defined as a medium language model, and a language model with a parameter number of 32 billion or more can be defined as a large language model. Small language models have the advantages of fast running speed, low resource utilization and low training cost, but the quality of content generation is relatively low. In contrast, although large language models run slower, consume more resources and have higher training costs, they can provide better content generation effects. The performance and training cost of medium-sized language models are between small language models and large language models.
[0048] In addition, according to the different usage frequencies of language model interface service requests, service requests can be divided into three application scenarios: low-frequency use, medium-frequency use, and high-frequency use. For example, service request usage frequencies of 9Hz and below can be defined as low-frequency use, service request usage frequencies greater than 10Hz and less than 100Hz can be defined as medium-frequency use, and service request usage frequencies of 100Hz and above can be defined as high-frequency use. Low-frequency use is suitable for application scenarios of scattered service requests, high-frequency use is suitable for application scenarios of batch data processing, and the frequency of service requests using medium-frequency use is between low-frequency use and high-frequency use.
[0049] Continuing with the previous example, after the token provided by the client is authenticated, the server can obtain the payload information of the token. Since the payload information includes the parameter information and calling frequency of the target language model, the server can determine the target language model to be called based on the obtained parameter information model.
[0050] Step A2: Call the target language model according to the calling frequency to perform intent recognition, first sensitive word extraction and content generation in parallel.
[0051] Continuing with the previous example, after the server determines the target language model and obtains the calling frequency of the target language model, it can call the target language model according to the calling frequency and parallelly execute the intent recognition task, sensitive word extraction task and content generation task (including generating content corresponding to the input content and extracting sensitive words from the generated content) of the input content (the input content is placed in the request body of the service request).
[0052] As a possible implementation, the above-mentioned intention recognition step may include: generating a prompt corresponding to the input content based on a preset prompt template; the target language model generates an answer corresponding to the prompt, and identifies the intention of the input content based on the answer to determine whether the intention is normal. Based on this, the above-mentioned artificial intelligence content generation method may also include: if the intention of the input content is identified as abnormal during the intention recognition process, the target language model generates a first prompt information based on the abnormal intention obtained by the intention recognition.
[0053] For example, the input content can be assembled into corresponding prompts according to the prompt template, and then the prompts can be input into the language model, and the language model can be used to generate the corresponding answers to the prompts, so as to identify the intentions involved in the input content according to the answer results. The prompt template is as follows: "Single-choice question: \n```\n{input content}\n```\nThe above content involves ()\n\n\nA. Medical health\nB.XX\nC. Chat\nD. Violation of ethics\nE. Illegal\nF. Technology\nG. Discrimination and insult\nOnly output the answer options:".
[0054] If the language model service believes that the input content involves sensitive topics such as "XX", "violation of ethics and morality", "illegal and illegal", "discrimination and insult", etc., then it will be judged that the intention of the input is abnormal, and other parallel tasks will be terminated immediately, and a specific prompt message will be returned: "The request content involves {abnormal} intention, so it will not be answered."
[0055] Here is a concrete example of intent recognition:
[0056] Input content: "What impact does XX have on the development of YY?"
[0057] Prompt: "Single-choice question: \n```\n What impact does XX have on the development of YY? \n```\nThe above content involves ()\n\nA. Medical health\nB. XX\nC. Chatting\nD. Violation of ethics\nE. Illegal and irregular\nF. Technology\nG. Discrimination and insult\nOnly output the answer options:"
[0058] Language model return: "B"
[0059] The prompt message returned is: "The request content involves XX intention, so it will not be answered."
[0060] As a possible implementation, the first sensitive word extraction step may include: the target language model matches the input content with the sensitive words in the pre-built sensitive word library, and if the input content matches the corresponding sensitive words in the sensitive word library, the target language model extracts the sensitive words that match the input content. Based on this, the artificial intelligence content generation method may also include: if sensitive words are extracted from the input content during the first sensitive word extraction process, the target language model generates and outputs second prompt information based on the sensitive words extracted from the first sensitive word.
[0061] Accordingly, the step of extracting the second sensitive word may include: the target language model matches the generated content with the sensitive words in the sensitive word library, and if the generated content matches the corresponding sensitive words in the sensitive word library, the target language model extracts the sensitive words that match the generated content. Based on this, the artificial intelligence content generation method may also include: if sensitive words are extracted from the generated content during the second sensitive word extraction process, the target language model generates and outputs third prompt information based on the sensitive words extracted from the second sensitive word.
[0062] Exemplarily, a sensitive word library can be constructed in advance, and the construction process of the sensitive word library can include: first collecting sensitive words from public resources (such as banned words published by authoritative organizations, banned word lists of social media platforms, etc.), then reviewing the collected sensitive words, and finally forming a sensitive word library with the sensitive words retained after the review. After the sensitive word library is constructed, the sensitive word library can be used to perform regular matching on the input content and the generated content to identify the sensitive words contained in the input content and the generated content. If the match is successful, terminate other concurrent tasks in progress (such as the intent recognition task, the first sensitive word extraction task, and the content generation task that are being executed concurrently), and return a specific prompt message: "Because the content involves sensitive words {sensitive words}, no answer will be given."
[0063] For ease of understanding, the implementation of the above-mentioned artificial intelligence content generation method is exemplified by taking a specific application as an example as follows.
[0064] The main technical concept of the above-mentioned artificial intelligence content generation method is: first, when calling the service interface, a token authentication mechanism is used to ensure the security of the service interface to prevent unauthorized users from accessing and abusing the interface service; second, in the content generation process, the input content and generated content are verified through intent recognition and sensitive word extraction to ensure that the generated content is both safe and harmless.
[0065] In terms of the technical implementation of the above-mentioned artificial intelligence content generation method, two modules are mainly involved: the rights management module and the parallel content generation verification module. The rights management module is responsible for the generation and authentication of tokens. When generating a token, it is mainly necessary to set the load information, which includes the expiration time, parameter information (indicating the language model interface service to be called) and the calling frequency. During the token authentication process, the system will provide users with different levels of access rights (that is, whether the user calls a small language model, a medium language model or a large language model) based on the load information in the token. The parallel content generation verification module performs intent recognition, sensitive word extraction and content generation of the input content in parallel while processing the content generation request, and extracts sensitive words from the generated content during the content generation process to further ensure the security of the content.
[0066] See also Figure 4 As shown, the technical implementation of the above-mentioned artificial intelligence content generation method mainly includes the following two parts:
[0067] (I) Rights Management Module
[0068] This module covers token generation and authentication.
[0069] Token generation process: JSON Web Token (JWT) technology is used to generate a string as a token. The token consists of header information (which specifies the signature algorithm), payload information (which includes expiration time, parameter information, and call frequency), and signature information (generated based on the product key, header information, and payload information). Figure 2 As shown, when a user applies for a token, the system uses the default header information and signature information combined with the user-specific payload information to generate the corresponding token.
[0070] Token authentication process: After the system receives the content generation service request sent by the client corresponding to the user (there is a token in the request header and input content in the request body), it will verify the header information and signature information of the token in the request header to determine whether the token is valid; if the header information and signature information verification fail, the system determines that the token is invalid, the system will terminate the request input, and return a prompt message to the client "Please enter a valid token"; if the header information and signature information verification pass, the system determines that the token is valid, the system will extract the payload information in the token (including expiration time, parameter information and calling frequency); next, the system will check whether the token is expired based on the expiration time; if the token has expired, the system will terminate the request input and return a prompt message to the client "The token has expired, please apply for a new token"; if the token has not expired, the system will continue to call the language model interface service specified by the payload information according to the calling frequency specified by the payload information to regulate the content generation of the input content in the request body (that is, selecting different language models for the same input content will generate different generated content).
[0071] The language models available for selection in the language model interface service include small language models, medium language models, and large language models. The call frequencies in the load information are divided into low frequency, medium frequency, and high frequency. By analyzing the language models and call frequencies specified in the load information, you can select and allocate language models in a targeted manner and control the frequency of use of language models, thereby effectively managing the content generation services requested by the client and optimizing the resource utilization and performance of the content generation services.
[0072] (II) Parallel content generation and verification module
[0073] This module asynchronously and in parallel processes three tasks: intent recognition task (i.e., performing intent recognition on input content), sensitive word extraction task (i.e., performing sensitive word extraction on input content), and content generation task (i.e., generating generated content corresponding to the input content and performing sensitive word extraction on the generated content). The purpose of this module is to recognize the intent of the input content, detect and extract sensitive words from the input content, and simultaneously generate generated content corresponding to the input content and detect and extract sensitive words from the generated content. By processing these three tasks in parallel, the module is able to reject content generation involving input content with abnormal intent and / or containing sensitive words, and prevent the return of generated content containing sensitive words, while ensuring that content generation efficiency is not affected in the case of normal content generation.
[0074] For ease of description, sensitive word extraction, task intent recognition, and content generation tasks can be recorded as Task 1, Task 2, and Task 3, respectively. These three tasks are asynchronously parallelized through the following strategies:
[0075] 1) Three tasks start processing at the same time;
[0076] 2) If Task 1 extracts sensitive words (i.e., the input content contains sensitive words), other ongoing tasks should be terminated immediately, and specific prompt information should be returned to the client, and parallel processing ends;
[0077] 3) If Task 2 recognizes an abnormal intention, it should immediately terminate other ongoing tasks and return specific prompt information to the client, and the parallel processing ends;
[0078] 4) For Task 1 and Task 2, if no sensitive words or abnormal intentions are extracted during the execution process, the task should be considered to have ended normally;
[0079] 5) For Task 3, first perform content generation to obtain the generated content corresponding to the input content, and then extract sensitive words from the generated content. If Task 3 extracts sensitive words (that is, the generated content contains sensitive words), other ongoing tasks should be terminated immediately, and specific prompt information should be returned to the client, and parallel processing ends; if Task 3 does not extract sensitive words, it is necessary to wait for Task 1 and Task 2 to end normally, and then return the generated content to the client, and parallel processing ends.
[0080] In the above strategy, extraction lists for Task 1 and Task 3 can be established in advance, so that when Task 1 and Task 3 each extract sensitive words, the sensitive words extracted by Task 1 and Task 3 will be written into the corresponding extraction lists respectively. Whether Task 1 and Task 3 each extracts sensitive words can be determined by judging whether the corresponding extraction list is empty, that is: if the extraction list is empty, it means that the corresponding task has not extracted sensitive words, and if the extraction list is not empty, it means that the corresponding task has extracted sensitive words.
[0081] By adopting the above-mentioned artificial intelligence content generation method, through the control of the language model interface service call authority and the introduction of the verification mechanism of the input content and the generated content, the security and efficiency of the language model interface service call can be ensured, the social harm of the generated content is minimized, and the risk control of artificial intelligence content generation is effectively strengthened. In the specific implementation process, the selection of language models and the regulation of the frequency of use of language models are realized through token authentication, the verification of content generation is realized through the extraction of sensitive words and intent recognition of input content and the extraction of sensitive words of generated content, and the three tasks of intent recognition, sensitive word extraction and content generation are asynchronously executed in parallel to achieve efficient and risk-controlled content generation.
[0082] The beneficial effects brought about by the above-mentioned artificial intelligence content generation method are mainly reflected in the following aspects:
[0083] a) Increase access security: Use token-related technologies to authenticate the token in the service request based on the header information, signature information, and expiration time in the payload information to ensure the security and effectiveness of user access to content generation services.
[0084] b) Diversity of application scenarios: By adopting token-related technology, the language model and its usage frequency specified by the load information can be used to support the reasonable use of multiple language models, while adapting to application scenarios with multiple usage frequencies.
[0085] c) Avoid harmful generated content: Ensure that only safe and harmless generated content is output through intent recognition and sensitive word extraction.
[0086] d) Improve response efficiency: For situations where the input content contains sensitive words, the input content involves abnormal intentions, and the output content contains sensitive words, the content generation process can be quickly ended and a prompt can be given, without having to wait for the time-consuming and computationally intensive content generation process to end, thereby improving the response efficiency of the entire content generation service.
[0087] e) Lossless content generation efficiency: The use of a multi-task asynchronous parallel mechanism can ensure that the response time of normal content generation is not affected.
[0088] Based on the above-mentioned artificial intelligence content generation method, the embodiment of the present invention also provides an artificial intelligence content generation device, see Figure 5 As shown, the device may include the following modules:
[0089] The authentication module 502 is used to obtain the token and input content corresponding to the user and authenticate the token; wherein the token includes authentication information and load information, and the load information includes model call parameters.
[0090] The parallel processing module 504 is used to call the target language model based on the model calling parameters to perform intent recognition, first sensitive word extraction and content generation of the input content in parallel if the token authentication is passed; wherein the content generation includes: generating generated content corresponding to the input content, and performing second sensitive word extraction on the generated content.
[0091] The first output module 506 is used to terminate the intention recognition, the first sensitive word extraction and the content generation if the target termination condition is met, and the target language model outputs prompt information corresponding to the target termination condition; wherein the target termination condition includes at least one of the following: the intention of the input content is recognized to be abnormal during the intention recognition process, sensitive words are extracted from the input content during the first sensitive word extraction process, and sensitive words are extracted from the generated content during the second sensitive word extraction process.
[0092] The second output module 508 is used to, if the target termination condition is not met, after the intention recognition, the first sensitive word extraction and the content generation are completed, the target language model outputs the generated content.
[0093] By adopting the above-mentioned artificial intelligence content generation device, the security of the artificial intelligence content generation service can be ensured through token authentication, the input and output content of the model can be verified through intent recognition and sensitive word extraction, and efficient and risk-controlled artificial intelligence content generation can be achieved through asynchronous parallel execution of intent recognition, first sensitive word extraction and content generation, thereby ensuring the efficiency, legality and harmlessness of artificial intelligence content generation.
[0094] The above-mentioned authentication information may include header information and signature information, and the above-mentioned load information may also include expiration time; based on this, the above-mentioned authentication module 502 may also be used to: verify the header information and the signature information; if the header information and the signature information are verified, determine whether the token is expired based on the expiration time; if the token has not expired, the token authentication is passed; if the header information and the signature information are not verified or the token has expired, the token authentication is failed.
[0095] The above-mentioned model calling parameters may include parameter information and calling frequency of the target language model; based on this, the above-mentioned parallel processing module 504 can also be used to perform the following operations if the token authentication is passed: determine the target language model from multiple preset language models based on the parameter information; call the target language model according to the calling frequency to perform the intent recognition, the first sensitive word extraction and the content generation in parallel.
[0096] The above-mentioned intention recognition step may include: generating a prompt corresponding to the input content based on a preset prompt template; the target language model generates an answer corresponding to the prompt, and identifies the intention of the input content based on the answer to determine whether the intention is normal. Based on this, the above-mentioned parallel processing module 504 can also be used for: if the intention of the input content is identified as abnormal during the intention recognition process, the target language model generates a first prompt message based on the abnormal intention obtained by the intention recognition.
[0097] The step of extracting the first sensitive word may include: the target language model matches the input content with the sensitive words in the pre-built sensitive word library, and if the input content matches the corresponding sensitive words in the sensitive word library, the target language model extracts the sensitive words matching the input content. Based on this, the parallel processing module 504 may also be used to: if sensitive words are extracted from the input content during the first sensitive word extraction process, the target language model generates and outputs second prompt information based on the sensitive words extracted from the first sensitive word.
[0098] The step of extracting the second sensitive word may include: the target language model matches the generated content with the sensitive words in the sensitive word library, and if the generated content matches the corresponding sensitive words in the sensitive word library, the target language model extracts the sensitive words that match the generated content. Based on this, the parallel processing module 504 may also be used to: if sensitive words are extracted from the generated content during the second sensitive word extraction process, the target language model generates and outputs third prompt information based on the sensitive words extracted from the second sensitive word.
[0099] The artificial intelligence content generation device provided in the embodiment of the present invention has the same implementation principle and technical effects as those in the aforementioned artificial intelligence content generation method embodiment. For the sake of brief description, for matters not mentioned in the embodiment of the artificial intelligence content generation device, reference may be made to the corresponding contents in the aforementioned artificial intelligence content generation method embodiment.
[0100] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 61 and a memory 60, the memory 60 stores computer executable instructions that can be executed by the processor 61, and the processor 61 executes the computer executable instructions to implement the above-mentioned artificial intelligence content generation method.
[0101] exist Figure 6 In the illustrated embodiment, the electronic device further includes a bus 62 and a communication interface 63 , wherein the processor 61 , the communication interface 63 and the memory 60 are connected via the bus 62 .
[0102] Among them, the memory 60 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 63 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 62 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 62 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0103] The processor 61 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 61 or the instructions in the form of software. The above processor 61 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 61 reads the information in the memory and completes the steps of the artificial intelligence content generation method of the aforementioned embodiment in combination with its hardware.
[0104] An embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned artificial intelligence content generation method. The specific implementation can be found in the aforementioned method embodiment, which will not be repeated here.
[0105] The computer program products of the artificial intelligence content generation method, device and electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0106] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
[0107] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0108] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0109] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. An artificial intelligence content generation method, characterized in that: include: Obtaining a token and input content corresponding to the user, and authenticating the token; wherein the token includes authentication information and load information, and the load information includes model call parameters; If the token authentication is passed, the target language model is called based on the model calling parameters to perform intent recognition, first sensitive word extraction and content generation of the input content in parallel; wherein the content generation includes: generating generated content corresponding to the input content, and performing second sensitive word extraction on the generated content; If the target termination condition is met, the intent recognition, the first sensitive word extraction and the content generation are terminated, and the target language model outputs prompt information corresponding to the target termination condition; wherein the target termination condition includes at least one of the following: the intent of the input content is recognized to be abnormal during the intent recognition process, sensitive words are extracted from the input content during the first sensitive word extraction process, and sensitive words are extracted from the generated content during the second sensitive word extraction process; If the target termination condition is not met, then after the intent recognition, the first sensitive word extraction and the content generation are all completed, the target language model outputs the generated content.
2. The artificial intelligence content generation method according to claim 1, characterized in that: The authentication information includes header information and signature information, and the payload information also includes expiration time; Authenticating the token includes: Verifying the header information and the signature information; If the header information and the signature information are verified, determining whether the token is expired based on the expiration time; If the token has not expired, the token authentication is successful; If the header information and the signature information fail to be verified or the token has expired, the token authentication fails.
3. The artificial intelligence content generation method according to claim 1, characterized in that: The model calling parameters include parameter information and calling frequency of the target language model; Calling the target language model based on the model calling parameter to perform intent recognition, first sensitive word extraction, and content generation of the input content in parallel, including: Determining the target language model from a plurality of preset language models based on the parameter information; The target language model is called according to the calling frequency to perform the intent recognition, the first sensitive word extraction and the content generation in parallel.
4. The artificial intelligence content generation method according to claim 1, characterized in that: The intention recognition includes: Generate a prompt corresponding to the input content based on a preset prompt template; The target language model generates an answer corresponding to the prompt, and identifies the intention of the input content based on the answer to determine whether the intention is normal; The method further comprises: If the intention of the input content is identified as abnormal during the intention recognition process, the target language model generates first prompt information based on the abnormal intention obtained by the intention recognition.
5. The artificial intelligence content generation method according to claim 1, characterized in that: The first sensitive word extraction includes: The target language model matches the input content with sensitive words in a pre-built sensitive word library. If the input content matches the corresponding sensitive words in the sensitive word library, the target language model extracts the sensitive words matching the input content. The method further comprises: If sensitive words are extracted from the input content during the first sensitive word extraction process, the target language model generates and outputs second prompt information based on the sensitive words extracted from the first sensitive words.
6. The artificial intelligence content generation method according to claim 5, characterized in that: The second sensitive word extraction includes: The target language model matches the generated content with the sensitive words in the sensitive word library. If the generated content matches the corresponding sensitive words in the sensitive word library, the target language model extracts the sensitive words matching the generated content; The method further comprises: If sensitive words are extracted from the generated content during the second sensitive word extraction process, the target language model generates and outputs third prompt information based on the sensitive words extracted from the second sensitive words.
7. The artificial intelligence content generation method according to claim 3, characterized in that: The multiple language models include a small language model, a medium language model and a large language model; the parameter amount of the small language model is smaller than the parameter amount of the medium language model, and the parameter amount of the medium language model is smaller than the parameter amount of the large language model.
8. An artificial intelligence content generation device, characterized in that: include: An authentication module, used to obtain a token and input content corresponding to the user, and authenticate the token; wherein the token includes authentication information and load information, and the load information includes model call parameters; A parallel processing module, for invoking a target language model based on the model calling parameter to perform intention recognition, first sensitive word extraction and content generation of the input content in parallel if the token authentication is passed; wherein the content generation includes: generating generated content corresponding to the input content, and performing second sensitive word extraction on the generated content; A first output module, configured to terminate the intention recognition, the first sensitive word extraction and the content generation if a target termination condition is met, and the target language model outputs prompt information corresponding to the target termination condition; wherein the target termination condition includes at least one of the following: the intention of the input content is recognized to be abnormal during the intention recognition process, sensitive words are extracted from the input content during the first sensitive word extraction process, and sensitive words are extracted from the generated content during the second sensitive word extraction process; The second output module is used to, if the target termination condition is not met, after the intention recognition, the first sensitive word extraction and the content generation are completed, the target language model outputs the generated content.
9. An electronic device, characterized in that: It includes a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the artificial intelligence content generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions prompt the processor to implement the artificial intelligence content generation method described in any one of claims 1 to 7.