Language model risk detection method and device, equipment, medium and product

By performing risk detection on the intention and method description content of the language model input data, and combining the model output data for abnormal response detection, the problem of exponential growth in the number of samples caused by the combination of malicious intentions and attack methods in the existing technology is solved, and the system is improved. scalability and security.

CN118656822AActive Publication Date: 2024-09-17BEIJING VOLCANO ENGINE TECH CO LTD

Patent Information

Application Number
CN202410841701.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-17
Estimated Expiration
2044-06-26

AI Technical Summary

Technical Problem

When existing language model risk detection methods face combined attacks with malicious intentions and attack techniques, the number of samples that need to be learned increases exponentially with the increase in risk types, resulting in poor scalability, generalization, and timeliness.

Method used

By separately determining the intention description content and method description content from the input data of the language model, and performing intent risk detection and method risk detection on them, combined with the model output data for abnormal response detection, and comprehensively determining the risk detection results, thereby avoiding prompt injection risks , improve safety.

Benefits of technology

It achieves effective detection of malicious intentions and attack methods, avoids the exponential growth of the number of samples as risk types increase, improves the scalability, generalization and timeliness of the system, and enhances security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656822A
    Figure CN118656822A
Patent Text Reader

Abstract

The invention discloses a risk detection method and device for a language model, equipment, a medium and a product, and the method comprises the steps: firstly determining at least one of intention description content and manipulation description content from model input data after the model input data of a target language model is obtained; then, performing intention risk detection processing on the intention description content to obtain an intention risk detection result, and / or performing manipulation risk detection processing on the manipulation description content to obtain a manipulation risk detection result; and finally, according to the intention risk detection result and / or the manipulation risk detection result, determining a risk detection result of the target language model under the model input data, so that the risk detection result can express whether there is a risk, such as a Prompt injection risk, thereby effectively avoiding a safety problem caused by the risk, and improving the safety of the target language model. And the security of the business application based on the language model can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information security technology, and in particular to a risk detection method, device, equipment, medium, and product for a language model. Background Art

[0002] With the development of language model technology, language models are being applied in more and more scenarios, especially large language models (LLM). For example, language models can be applied to conversation scenarios or video generation scenarios.

[0003] In addition, in some application processes, it was found that the model may have some risks, such as prompt word injection risks, which makes the need for security defense against the model urgent. Summary of the invention

[0004] The present application provides a language model risk detection method, apparatus, device, medium, and product that can improve security.

[0005] In order to achieve the above objectives, the technical solutions provided by this application are as follows:

[0006] The present application provides a language model risk detection method, the method comprising:

[0007] Obtain model input data of the target language model;

[0008] Determining at least one of intention description content and technique description content from the model input data;

[0009] Performing intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or performing method risk detection processing on the determined method description content to obtain a method risk detection result;

[0010] Based on at least one of the obtained intention risk detection result and technique risk detection result, determine the risk detection result of the target language model applied to the model input data.

[0011] In a possible implementation manner, the model input data includes at least one prompt word;

[0012] The step of determining at least one of the intention description content and the technique description content from the model input data comprises:

[0013] According to different source types of each of the at least one prompt word, at least one of the intention description content and the technique description content is determined from the at least one prompt word.

[0014] In one possible implementation, the source type of each prompt word in the at least one prompt word includes: system prompt words and user prompt words; the intention description content is determined based on the system prompt words and user prompt words in the model input data; the technique description content is determined based on the user prompt words in the model input data.

[0015] In a possible implementation manner, the method further includes:

[0016] Performing abnormal response detection processing on the response description information to obtain an abnormal response detection result; the response description information is determined based on the model input data and / or the model output data of the target language model; the model output data is obtained by processing the model input data by the target language model;

[0017] The risk detection result of the target language model applied to the model input data is also determined based on the abnormal response detection result.

[0018] In one possible implementation, the model input data includes multiple data, and the source types of different data are different; the intention description content, the technique description content, and the response description information are determined based on the source types of the multiple data.

[0019] In one possible implementation, the multiple data include a plug-in response and at least one prompt word, the source type of the plug-in response is different from the source type of each of the prompt words, and different prompt words have different source types; the intention description content and the technique description content are determined based on the at least one prompt word and the source type of the at least one prompt word; the response description information is determined based on the plug-in response and / or the model output data.

[0020] In a possible implementation manner, the at least one prompt word includes a system prompt word; and the response description information is also determined based on the system prompt word.

[0021] In a possible implementation manner, the method further includes:

[0022] Get model detection constraint information;

[0023] Determine, from among the detection execution devices corresponding to the plurality of candidate constraint information, a detection execution device that matches the model detection constraint information;

[0024] The matching detection execution device is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or to perform technique risk detection processing on the determined technique description content to obtain a technique risk detection result.

[0025] In a possible implementation manner, the model detection constraint information includes at least one of scene constraint information, region constraint information, business constraint information, language constraint information, and detection item constraint information.

[0026] In one possible implementation, the matching detection execution device includes a detector corresponding to the intention description content and a detector corresponding to the technique description content; the detector corresponding to the intention description content is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result; the detector corresponding to the technique description content is used to perform technique risk detection processing on the determined technique description content to obtain a technique risk detection result.

[0027] In one possible implementation, the intent description content includes intent content from at least two source types; the detector corresponding to the intent description content includes detectors corresponding to intent content from various source types; for the detector corresponding to the intent content of any source type, the detector is used to perform intent risk detection processing on the intent content of that source type.

[0028] In a possible implementation manner, after determining the detection execution device that matches the model detection constraint information from the detection execution devices corresponding to the plurality of candidate constraint information, the method further includes:

[0029] Sending a detection request to the matched detection execution device; the matched detection execution device is used to perform intent risk detection processing on the intent description content carried in the detection request to obtain an intent risk detection result, and / or, performing technique risk detection processing on the technique description content carried in the detection request to obtain a technique risk detection result;

[0030] Receive feedback information from the matched detection execution device, where the feedback information includes the intention risk detection result and / or the technique risk detection result.

[0031] In one possible implementation, the matching detection execution device is also used to perform abnormal response detection processing on the response description information to obtain an abnormal response detection result; the response description information is determined based on the model input data and / or the model output data of the target language model; the model output data is obtained by processing the model input data by the target language model.

[0032] In a possible implementation manner, the detection execution devices corresponding to the plurality of candidate constraint information are constructed based on a pre-constructed detection set, wherein the detection set includes one or more of at least one detection rule, at least one detection vector, and at least one detection model;

[0033] After determining the risk detection result of the target language model applied to the model input data, the method further includes:

[0034] If the risk detection result of the target language model applied to the model input data indicates that there is a risk, the detection set is updated according to the model input data.

[0035] The present application provides a risk detection device for a language model, comprising:

[0036] A data acquisition unit, used to acquire model input data of a target language model;

[0037] a content determination unit, configured to determine at least one of intention description content and technique description content from the model input data;

[0038] A data detection unit is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or to perform method risk detection processing on the determined method description content to obtain a method risk detection result;

[0039] A result determination unit is used to determine the risk detection result of the target language model applied to the model input data based on at least one of the obtained intention risk detection result and technique risk detection result.

[0040] The present application provides an electronic device, the device comprising: a processor and a memory;

[0041] The memory is used to store instructions or computer programs;

[0042] The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the language model risk detection method provided in the present application.

[0043] The present application provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes the risk detection method of the language model provided in the present application.

[0044] The present application provides a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program codes for executing the risk detection method of the language model provided by the present application.

[0045] Compared with the related art, this application has at least the following advantages:

[0046] In the technical solution provided by the present application, after obtaining the model input data of the target language model, at least one of the intent description content and the technique description content is first determined from the model input data; then, the intent description content is subjected to intent risk detection processing to obtain an intent risk detection result, and / or, the technique description content is subjected to technique risk detection processing to obtain a technique risk detection result; finally, based on the intent risk detection result and / or the technique risk detection result, the risk detection result of the target language model under the model input data is determined, so that the risk detection result can indicate whether there is a risk, such as Prompt injection risk, etc., thereby effectively avoiding the security issues caused by the risk, and thus helping to improve security.

[0047] It can be seen that because the present application performs risk detection processing on the model input data from the two dimensions of intent and technique respectively, the present application can analyze whether there is a prompt injection risk from the two characteristics of malicious intent and attack technique respectively, so that the present application can not only detect the attack samples that have been learned in advance, but also detect the new attack requests composed of the malicious intent and attack techniques appearing in these attack samples, so that the number of samples required to be learned by the present application will not increase exponentially with the increase of risk types, thus making the present application have good scalability, generalization and timeliness. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 A flow chart of a risk detection method for a language model provided in an embodiment of the present application;

[0050] Figure 2 A schematic diagram of a detection processing logic provided in an embodiment of the present application;

[0051] Figure 3 A schematic diagram of a detection and processing framework provided in an embodiment of the present application;

[0052] Figure 4 A schematic diagram of a detection process provided in an embodiment of the present application;

[0053] Figure 5 A schematic diagram of a vector recall provided in an embodiment of the present application;

[0054] Figure 6 A schematic diagram of a classification process provided in an embodiment of the present application;

[0055] Figure 7 A schematic diagram of another classification process provided in an embodiment of the present application;

[0056] Figure 8 A schematic diagram of the structure of a risk detection device for a language model provided in an embodiment of the present application;

[0057] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0059] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.

[0060] Herein, unless explicitly stated, executing a step “in response to A” does not mean executing the step immediately after “A” but may include one or more intermediate steps.

[0061] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition, use, storage or deletion of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0062] It is understandable that before using the technical solutions disclosed in the various embodiments of the present disclosure, the types, scopes of use, usage scenarios, etc. of the information involved in the present disclosure should be informed to relevant users and their authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations. The relevant users may include any type of right holders, such as individuals, enterprises, and groups.

[0063] For example, in response to receiving an active request from a user, a prompt message is sent to the relevant user to clearly prompt the relevant user that the operation requested to be performed will require obtaining and using the information of the relevant user, so that the relevant user can independently choose whether to provide information to software or hardware such as an electronic device, application, server or storage medium that executes the operation of the technical solution of the present disclosure based on the prompt message.

[0064] As an optional but non-limiting implementation, in response to receiving an active request from a relevant user, a prompt message is sent to the relevant user, for example, in the form of a pop-up window, in which the prompt message may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to select "agree" or "disagree" to provide information to the electronic device.

[0065] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0066] The following is a detailed description of the solution of the present disclosure.

[0067] The inventors of the present disclosure have found through research that one security defense direction for the model is model detection and response, and the "model detection and response" is specifically: by detecting the input and output of the model, the internal calculation process of the model, and the actions of the downstream modules of the model, etc., to comprehensively determine whether there are risky operations, and intercept or filter the risky operations. It can be seen that for the security defense direction of "model detection and response", it can identify unexpected requests by detecting the input and output of the model. Based on this, it can be seen that a security defense idea for the model is to insert detection and filtering processes in the input and output links of the model to ensure the security of the content entering the model and the output content of the model, thereby protecting against prompt injection risks, etc.

[0068] The inventors of the present disclosure have also found that for some related solutions for detecting model input and output, these solutions can be combined with rule engines, small parameter models similar to natural language processing (NLP), vector retrieval, etc., to directly perform risk detection processing on the overall input and output of the model to solve risks such as direct injection attacks and language logic attacks. Among them, the rule engine refers to the use of rule engines similar to Yara to determine whether the input or output hits predefined rules, usually in regular form. The small parameter model refers to the risk classification of the model input or output by fine-tuning small parameter models similar to Bert. The vector retrieval refers to the use of known attack samples vectorized into the database to determine whether the model input or output hits similar attack samples.

[0069] The inventors of the present disclosure have further discovered that the related scheme shown in the previous paragraph has the following problems: since a model attack can be composed of two characteristics, malicious intent and attack techniques, such as the two characteristics shown in Table 1 below, so that the free combination of different characteristics can form a new model attack, the number of samples required to learn the related scheme implemented by performing risk detection on the Prompt as a whole will increase exponentially with the increase in risk types, thus resulting in the problems of poor scalability, poor generalization, and poor timeliness of the related scheme.

[0070]

[0071] Table 1 Different characteristics of model attacks

[0072] Based on the above findings, in order to better improve security, the present application provides a risk detection method for a language model, the method comprising: after obtaining the model input data of the target language model, first determining at least one of the intent description content and the technique description content from the model input data; then, performing intent risk detection processing on the intent description content to obtain an intent risk detection result, and / or, performing technique risk detection processing on the technique description content to obtain a technique risk detection result; finally, based on the intent risk detection result and / or the technique risk detection result, determining the risk detection result of the target language model under the model input data, so that the risk detection result can indicate whether there is a risk, such as Prompt injection risk, etc., thereby effectively avoiding the security issues caused by the risk, and thus helping to improve security. It can be seen that because the present application performs risk detection processing on the model input data from the two dimensions of intent and technique respectively, the present application can analyze whether there is a prompt injection risk from the two characteristics of malicious intent and attack technique respectively, so that the present application can not only detect the attack samples that have been learned in advance, but also detect the new attack requests composed of the malicious intent and attack techniques appearing in these attack samples, so that the number of samples required to be learned by the present application will not increase exponentially with the increase of risk types, thus making the present application have good scalability, generalization and timeliness.

[0073] In addition, the present application does not limit the execution subject of the risk detection method of the language model provided in the embodiment of the present application. For example, the risk detection method of the language model provided in the embodiment of the present application can be applied to a terminal device or a server. For another example, the risk detection method of the language model provided in the embodiment of the present application can also be implemented with the help of the data interaction process between the terminal device and the server. Among them, the terminal device can be a smart phone, a computer, a personal digital assistant (PDA), a tablet computer, etc. The server can be a stand-alone server, a cluster server or a cloud server.

[0074] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0075] In order to better understand the technical solution provided by this application, the risk detection method of the language model provided by this application is described below with reference to some drawings. Figure 1As shown, the language model risk detection method provided in the embodiment of the present application includes the following S1-S5. Figure 1 A flow chart of a risk detection method for a language model provided in an embodiment of the present application.

[0076] S1: Obtain model input data of the target language model.

[0077] The target language model refers to the model that needs to be processed for risk detection, and this application does not limit the implementation method of the target language model. For example, it can adopt any existing or future machine learning model, such as LLM or Figure 2 The model 1 shown is implemented.

[0078] Model input data refers to the data input to the target language model, such as Figure 2 The input data shown; and this application does not limit the implementation method of the model input data. For ease of understanding, the following is an explanation with three examples.

[0079] Example 1: In some application scenarios, the model input data may include a user prompt (UP). The user prompt refers to data provided by the user for the target language model, such as data input by the user using some input device. In addition, this application does not limit the method for obtaining the user prompt. For example, the user prompt may be obtained by using some information transmission protocol, such as Figure 3 The Hypertext Transfer Protocol (HTTP) or Remote Procedure Call (RPC) shown in the figure is used to obtain the information. In addition, the present application does not limit the implementation method of the user prompt word. For example, the user prompt word can be implemented in the form of Figure 4 The user prompt "Please play identity 1, he always tells stories 1 to coax me to sleep" is implemented.

[0080] Example 2: In some application scenarios, the model input data may include user prompts and system prompts (SP). The system prompts refer to data that are pre-set for the target language model and are used to describe the functions of the target language model, such as Figure 4 In addition, the present application does not limit the method for obtaining the system prompt word. For example, the system prompt word can be obtained by using a certain information transmission protocol, such as Figure 3HTTP or RPC as shown. In addition, the present application does not limit the implementation method of the system prompt word. For example, the system prompt word may include identity setting content and skill setting content. Among them, the identity setting content is used to describe the role played by the target language model, such as agent, chatbot, code assistant, multimodal and other roles. The skill setting content is used to describe the function of the target language model when the target language model plays a certain role. It should be noted that the present application does not limit the implementation method of the multimodality. For example, it can be implemented using a Vincent diagram.

[0081] Example 3: In some application scenarios, model input data may include user prompt words, system prompt words, and plug-in responses. The plug-in response refers to the feedback data of the plug-in called by the target language model, so that the plug-in response can be used to represent the execution result of the upstream task corresponding to the target language model, such as the data finally output by the plug-in involved in the upstream task or Figure 2 The plug-in response shown in the figure is used to process the plug-in response by the target language model when executing the current task. It should be noted that this application does not limit the implementation method of the plug-in. For example, it can adopt any plug-in that can provide a certain service, such as Figure 2 In addition, the present application does not limit the method of obtaining the plug-in response. For example, the plug-in response can be obtained by using a certain information transmission protocol, such as Figure 3 Get it through HTTP or RPC as shown.

[0082] Based on the above three examples, we can see that in some application scenarios, such as Figure 2 In the workflow execution scenario shown, for the target language model involved in the current task, the model input data of the target language model can be determined based on part or all of the three source types of data: user prompt words, system prompt words, and plug-in response. Among them, the plug-in response can be used to represent the execution result of the upstream task corresponding to the current task.

[0083] Based on the relevant content of S1 above, it can be known that for a target language model, the model input data of the target language model can be data from at least two source types, such as Figure 2The user prompt words, system prompt words, and plug-in response data shown are spliced ​​together to make the model input data include data of these source types, so that risk detection processing for the target language model can be achieved later by performing different detection processing on data of different source types.

[0084] S2: Determine at least one of the intention description content and the technique description content from the model input data.

[0085] Among them, the intent description content refers to the intent description part existing in the model input data, so that the intent description content can describe the purpose expressed by the model input data, such as the purpose of "telling a story 1".

[0086] The technique description content refers to the technique description part existing in the model input data, so that the technique description content can describe the skills used to achieve the purpose expressed by the model input data, such as the role-playing skill of "playing identity 1".

[0087] In addition, the present application does not limit the implementation method of S2 above. For example, it can be specifically: after obtaining the model input data of the target language model, the model input data can be split into different parts, one part is used as the intent description content, and the other part is used as the technique description content, so that the intent description content can express the intent features described by the model input data, and the technique description content can express the technique features described by the model input data.

[0088] The inventors of the present disclosure have discovered through research that data from different source types can be used to provide attack features in different dimensions. For example, user prompt words and system prompt words may provide an attack feature of malicious intent, and user prompt words may provide an attack feature of attack method.

[0089] Based on the above research, in order to better improve the detection effect, the present application also provides a possible implementation of S2 above. In this way, when the model input data above includes at least one prompt word, the S2 can be specifically: according to the different source types of each prompt word in the at least one prompt word, at least one of the intention description content and the technique description content is determined from the at least one prompt word. Among them, the at least one prompt word refers to the prompt words with different source types existing in the model input data; and the present application does not limit the implementation of the at least one prompt word. For example, the at least one prompt word can include system prompt words and user prompt words, so that the source type of each prompt word in the at least one prompt word can include system prompt words and user prompt words. It should be noted that the source type of the system prompt word is different from the source type of the user prompt word.

[0090] Based on the above two paragraphs, it can be known that in a possible implementation, when the above model input data includes system prompt words and user prompt words, the above S2 may include the following steps 11 and 12.

[0091] Step 11: Determine the intent description content based on the system prompt words and user prompt words in the above model input data, so that the intent description content includes part or all of the system prompt words, and the intent description content includes part or all of the user prompt words.

[0092] It should be noted that the present application does not limit the implementation method of the above step 11. For example, in order to ensure the integrity of the information, the step 11 can specifically be: after obtaining the system prompt words and user prompt words in the above model input data, directly determine the intention description content based on the system prompt words and the user prompt words, so that the intention description content includes the system prompt words and the user prompt words.

[0093] For another example, in order to improve efficiency, the above step 11 can be specifically as follows: after obtaining the system prompt words and user prompt words in the above model input data, first extract the system intent from the system prompt words, and extract the user intent from the user prompt words; then determine the intent description content based on the system intent and the user intent, so that the intent description content includes the system intent and the user intent. Among them, the system intent is used to describe the purpose expressed by the system prompt words, and the present application does not limit the implementation method of the system intent. For example, the system intent may include the intent description part existing in the system prompt words. The user intent is used to describe the purpose expressed by the user prompt words, and the present application does not limit the implementation method of the user intent. For example, the user intent may include the intent description part existing in the user prompt words.

[0094] Based on the relevant content of step 11 above, it can be known that in some application scenarios, when the above model input data includes prompt words of at least two source types, the intention description content is determined from these prompt words according to the intention determination method corresponding to different source types, so that the intention description content includes the intention content of the at least two source types, so that the intention description content can better describe the purpose expressed by the model input data. Among them, the prompt words of the at least two source types are used to represent the prompt words of different source types existing in the model input data. In addition, for any source type of the at least two source types, the intention content of the source type is determined from the prompt words of the source type by the intention determination method corresponding to the source type, so that the intention content of the source type can describe the purpose expressed by the prompt words of the source type; and the present application does not limit the implementation method of the intention content of the source type, for example, the intention content of the source type may include part or all of the content in the prompt words of the source type. In addition, the present application does not limit the implementation method of the intent determination method corresponding to the source type. For example, the intent determination method corresponding to the source type is determined based on the intent determination requirement corresponding to the source type, so that the intent content determined by the intent determination method corresponding to the source type meets the intent determination requirement, which is conducive to improving the intent determination effect, and thus is conducive to improving the malicious intent detection effect.

[0095] Step 12: Determine the technique description content based on the user prompt words in the above model input data, so that the technique description content includes part or all of the user prompt words.

[0096] It should be noted that the present application does not limit the implementation method of the above step 12. For example, in order to ensure information integrity, the step 12 can specifically be: after obtaining the user prompt word in the above model input data, directly determine the user prompt word as the technique description content, so that the technique description content includes the user prompt word.

[0097] For another example, in order to improve efficiency, step 12 may specifically be: after obtaining the user prompt word in the above model input data, extract the technique description part from the user prompt word, and use the technique description part as the technique description content, so that the technique description content includes the technique description part, and thus the technique description content includes part of the content in the user prompt word, thereby making the time consumed in the subsequent processing of the technique description content relatively short, which is conducive to improving efficiency.

[0098] It should be noted that the present application does not limit the correlation between the execution time of step 12 and the execution time of step 11, for example, the former is earlier than the latter. For example, the former is later than the latter. For example, the two are the same.

[0099] Based on the relevant content of steps 11 to 12 above, it can be known that in a possible implementation mode, when the above model input data includes system prompt words and user prompt words, the intent description content can be determined based on the system prompt words and the user prompt words, and the technique description content is determined based on the user prompt words, so that the intent description content and the technique description content can be respectively detected and processed accordingly to determine whether there are malicious intentions and attack techniques, so that whether there is a prompt injection risk can be comprehensively determined based on these results. This can effectively avoid the defects caused by detecting the model input data as a whole, thereby helping to improve the detection effect.

[0100] Based on the content of the previous paragraph, it can be known that in one possible implementation mode, when the above model input data includes at least one prompt word, and the source type of each prompt word in the at least one prompt word includes a system prompt word and a user prompt word, the above intention description content can be determined based on the system prompt words and user prompt words in the model input data; the above technique description content can be determined based on the user prompt words in the model input data.

[0101] Based on the relevant content of S2 above, it can be seen that for some application scenarios, such as Figure 2 For the scenario shown, after obtaining the model input data of the target language model, if the model input data is obtained by splicing data from multiple source types, it is possible to split the model input data into at least two dimensions, namely, intent description content and technique description content, based on the source types of different parts of the model input data, so that it can be subsequently determined whether the model input data has a prompt injection risk based on the risk detection results of these two dimensions.

[0102] S3: Perform intent risk detection on the determined intent description content to obtain an intent risk detection result.

[0103] Among them, the intent risk detection result is used to indicate whether there is malicious intent in the intent description content, such as the malicious intent shown in Table 2 below.

[0104] In addition, the present application does not limit the implementation method of the above intention risk detection process. For example, the intention risk detection process can be implemented by Figure 2-Figure 4 For example, the intention risk detection process can be implemented with the help of some pre-built rules and models, such as Figure 3 The rules and models shown are implemented.

[0105]

[0106] Table 2 Examples of malicious intent

[0107] It can be seen that in a possible implementation, in order to better improve the detection effect, the above S3 can specifically be: use a variety of intent detection means to perform intent risk detection on the above intent description content to obtain intent risk detection results. It should be noted that the present application is not limited to the multiple intent detection means. For example, the multiple intent detection means may include one or more of rule checking, vector recall, and classification methods. Among them, the rule check is used to determine whether the intent description content hits a predefined rule, such as a regular expression; and the present application does not limit the implementation method of the rule check. For example, the rule check can use a rule engine or Figure 4 The vector recall is used to determine whether the intent description content hits these attack samples based on the similarity between the vectorized features of the intent description content and the vectorized features of some attack samples stored in the pre-built vector library; and the present application does not limit the implementation method of the vector recall. For example, the vector recall can be adopted Figure 4 The vector recall shown is 1 or Figure 5 The classification method is used to classify the intent description content with the help of some classifiers, such as a small parameter model or a large parameter model, such as Figure 4 The classification process shown is 1. Figure 6 or Figure 7 It should be noted that the present application does not limit the implementation method of the small parameter model. For example, it can adopt a natural language processing (Natural Language Processing, NLP) model or Figure 6 In addition, the present application does not limit the implementation method of the large parameter model. For example, it can be implemented by using a few-shot LLM or a fine-tuned LLM.

[0108] In addition, the present application does not limit the execution conditions of the above S3. For example, it can be specifically: after determining that the intention description content is obtained, execute S3.

[0109] S4: Performing a technique risk detection process on the determined technique description content to obtain a technique risk detection result.

[0110] The technique risk detection result is used to indicate whether there is content used to describe the attack technique in the technique description content, such as the content shown in Table 3 below.

[0111] In addition, the present application does not limit the implementation method of the above-mentioned method risk detection processing. For example, the method risk detection processing can be implemented by Figure 2-Figure 4For example, the risk detection process of the attack method can be implemented by using some pre-built rules and models, such as Figure 3 The rules and models shown are implemented.

[0112] It can be seen that in a possible implementation, in order to better improve the detection effect, the above S4 can specifically be: use a variety of technique detection means to perform technique risk detection processing on the above technique description content to obtain technique risk detection results. It should be noted that the present application is not limited to the multiple technique detection means. For example, the multiple technique detection means may include one or more of rule checking, vector recall, and classification methods. Among them, the rule check is used to determine whether the technique description content hits a predefined rule, such as a regular expression; and the present application does not limit the implementation method of the rule check. For example, the rule check can use a rule engine or Figure 4 The vector recall is used to determine whether the technique description content hits these attack samples based on the similarity between the vectorized features of the technique description content and the vectorized features of some attack samples stored in the pre-built vector library; and the present application does not limit the implementation method of the vector recall. For example, the vector recall can be adopted Figure 4 The vector recall shown is 2 or Figure 5 The classification method is used to classify the description of the technique with the help of some classifiers, such as a small parameter model or a large parameter model, such as Figure 4 The classification process shown is 2, Figure 6 or Figure 7 Classification processing shown, etc.

[0113]

[0114] Table 3 Examples of attack techniques

[0115] In addition, the present application does not limit the execution condition of the above S4. For example, it may specifically be: after determining that the technique description content is obtained, S4 is executed.

[0116] Furthermore, when the execution conditions of S4 and S3 are met at the same time, the present application does not limit the correlation between the execution time of S4 and S3, for example, the former is earlier than the latter. For example, the former is later than the latter. For example, the two are the same.

[0117] S5: Determine the risk detection result of the target language model applied to the model input data based on at least one of the obtained intention risk detection result and technique risk detection result.

[0118] Among them, the risk detection result of the target language model applied to the model input data is used to indicate whether there is a prompt injection risk in the model input data.

[0119] In addition, the present application does not limit the implementation method of S5 above. For example, it can be specifically: after obtaining the intention risk detection results and the technique risk detection results, some summary processing can be performed on these results, such as Figure 2 The combined analysis shown, Figure 3 The aggregate analysis shown or Figure 4 The aggregation analysis and other summary processing shown are used to obtain the risk detection results of the target language model applied to the model input data.

[0120] It can be seen that, in a possible implementation mode, S5 above can be specifically as follows: if the intention risk detection result above indicates the existence of malicious intent or the technique risk detection result above indicates the existence of attack techniques, it can be determined that the model input data is at risk, so the pre-set risk characterization value, such as the value of "1", can be determined as the risk detection result of the target language model applied to the model input data, so that the "risk detection result of the target language model applied to the model input data" can indicate that the model input data is at risk; if the intention risk detection result indicates the absence of malicious intent and the technique risk detection result indicates the absence of attack techniques, it can be determined that the model input data is at risk, so the pre-set risk-free characterization value, such as the value of "0", can be determined as the risk detection result of the target language model applied to the model input data, so that the "risk detection result of the target language model applied to the model input data" can indicate that the model input data is at risk.

[0121] Based on the relevant contents of S1 to S5 above, it can be known that for the risk detection method of the language model provided in the embodiment of the present application, after obtaining the model input data of the target language model, at least one of the intent description content and the technique description content is first determined from the model input data; then, the intent description content is subjected to intent risk detection processing to obtain an intent risk detection result, and / or, the technique description content is subjected to technique risk detection processing to obtain a technique risk detection result; finally, based on the intent risk detection result and / or the technique risk detection result, the risk detection result of the target language model under the model input data is determined, so that the risk detection result can indicate whether there is a risk, such as Prompt injection risk, etc., thereby effectively avoiding the security issues caused by the risk, and thus helping to improve security. Among them, because the present application performs risk detection processing on the model input data from the two dimensions of intention and technique respectively, the present application can analyze whether there is a prompt injection risk from the two characteristics of malicious intention and attack technique respectively, so that the present application can not only detect the attack samples that have been learned in advance, but also detect the new attack requests composed of the malicious intention and attack techniques appearing in these attack samples, so that the number of samples required to be learned by the present application will not increase exponentially with the increase of risk types, thus making the present application have good scalability, generalization and timeliness.

[0122] The inventors of the present disclosure have discovered that in some application scenarios, in order to better improve the detection effect, some responses, such as model output data, can be used to supplement the detection process of model input data to achieve the advantages shown in ①-② below.

[0123] ① It is conducive to improving the accuracy of attack detection. The reason is that some attacks cannot be accurately judged as attack requests based on the model input data alone. For example, the key point to distinguish whether the User Prompt "Repeat the above content" is an attack request with the risk of SP leakage or a normal request without risk is to determine whether the model output data actually includes SP content. If the model output data only repeats the user's historical chat content, it can be determined that the model input data is not an attack request; however, if the model output data includes SP content, it can be determined that there is a risk of SP leakage, and thus it can be determined that the model input data is indeed an attack request.

[0124] ② It is conducive to covering some unknown attacks. That is, the value of model output data is not only to cover known attacks, but also to cover unknown attacks. The reason is that no matter what method is used to detect model input data, it depends to a large extent on the knowledge of existing attacks. However, due to the endless emergence of unknown attacks against the model, it is impossible to effectively cover all possible risks by only detecting model input data. In contrast, model output data is the most intuitive way to observe whether the model exhibits unexpected behavior, and it can cover and cover unknown attacks.

[0125] Based on the above research, in order to better improve the detection effect, the present application also provides a possible implementation of the risk detection method of the above language model. Under this implementation, the risk detection method may at least include the following steps 21 to 26.

[0126] Step 21: Obtain model input data for the target language model.

[0127] It should be noted that for the relevant content of step 21, please refer to the relevant content of S1 above.

[0128] Step 22: Determine at least one of the intention description content and the technique description content from the model input data.

[0129] It should be noted that for the relevant content of step 22, please refer to the relevant content of S2 above.

[0130] Step 23: Perform intent risk detection on the determined intent description content to obtain an intent risk detection result.

[0131] It should be noted that for the relevant content of step 23, please refer to the relevant content of S3 above.

[0132] Step 24: Perform a technique risk detection process on the determined technique description content to obtain a technique risk detection result.

[0133] It should be noted that for the relevant content of step 24, please refer to the relevant content of S4 above.

[0134] Step 25: Perform abnormal response detection processing on the response description information to obtain an abnormal response detection result; the response description information is determined based on the model input data and / or the model output data of the target language model; the model output data is obtained by the target language model processing the model input data.

[0135] Among them, the response description information is used to describe the response involved by the target language model, such as the plug-in response input to the target language model or the response output by the target language model, etc.; and this application does not limit the implementation method of the response description information. For ease of understanding, the following three situations are explained.

[0136] Case 1: In some application scenarios, if there is no upstream task corresponding to the target language model, it can be determined that the model input data of the target language model does not include the plug-in response, so that the response description information corresponding to the target language model can be determined based on the model output data of the target language model, so that the response description information includes the model output data. The model output data refers to the data obtained by the target language model processing the model input data, such as Figure 2 The output data shown is so that the model output data can represent the response given by the target language model to the model input data, so that the model output data can provide some supplementary information for the detection process of the model input data to a certain extent.

[0137] Case 2: In some application scenarios, if there is an upstream task corresponding to the target language model, it can be determined that the model input data of the target language model includes a plug-in response, so that it can be determined that the response description information corresponding to the target language model can be determined based on the plug-in response and the model output data of the target language model, so that the response description information includes the plug-in response and the model output data, so that these two responses can be used to assist the detection process of the model input data later.

[0138] Case 3: In some application scenarios, if there is an upstream task corresponding to the target language model, but the model output data of the target language model cannot provide supplementary information for risk detection processing, then in order to better improve efficiency, the response description information corresponding to the target language model can be determined based on the plug-in response, so that the response description information includes the plug-in response, so that this response can be used to assist the detection process of the model input data in the subsequent process.

[0139] Based on the relevant content of the above response description information, it can be known that, in one possible implementation manner, the response description information corresponding to the above target language model can be determined based on the plug-in response and / or the model output data of the target language model, so that the response description information can represent the response required for reference when performing risk detection on the model input data of the target language model.

[0140] In fact, in some application scenarios, such as the system prompt word leakage detection scenario, in order to better improve the detection effect, the present application also provides a possible implementation method of the above response description information. In this way, when the above model input data includes at least the system prompt word, the response description information is also determined based on the system prompt word, so that the system prompt word can participate in the subsequent abnormal response detection process, which is conducive to improving the abnormal response detection effect. It should be noted that the present application does not limit the determination process. For example, in some scenarios, the response description information can be determined based on the system prompt word and the plug-in response, so that the abnormal response detection process can be performed based on the system prompt word and the plug-in response. For another example, in some scenarios, the response description information can be determined based on the system prompt word and the model output data, so that the abnormal response detection process can be performed based on the system prompt word and the model output data. For another example, in some scenarios, the response description information can be determined based on the system prompt word, the plug-in response and the model output data, so that the abnormal response detection process can be performed based on the system prompt word, the plug-in response and the model output data.

[0141] The abnormal response detection result is used to indicate whether there is abnormal content in the response involved by the target language model, as shown in Table 4 below.

[0142]

[0143] Table 4 Examples of abnormal responses

[0144] In addition, the abnormal response detection result is obtained by performing abnormal response detection processing on the response description information corresponding to the target language model. It should be noted that the present application does not limit the implementation method of the abnormal response detection processing. For example, the abnormal response detection processing can be implemented by Figure 2-Figure 4 For example, the abnormal response detection process can be implemented by using some pre-built rules and models, such as Figure 3 The rules and models shown are implemented.

[0145] It can be seen that in a possible implementation, in order to better improve the detection effect, the above step 25 can be specifically: use a variety of response detection means to perform abnormal response detection processing on the above response description information to obtain abnormal response detection results. It should be noted that the present application is not limited to the multiple response detection means. For example, the multiple response detection means may include one or more of rule checking, vector recall, and classification methods. Among them, the rule check is used to determine whether the response description information hits a predefined rule, such as a regular expression; and the present application does not limit the implementation method of the rule check. For example, the rule check can use a rule engine or Figure 4The vector recall is used to determine whether the response description information hits these attack samples based on the similarity between the vectorized features of the response description information and the vectorized features of some attack samples stored in the pre-built vector library; and the present application does not limit the implementation method of the vector recall. For example, the vector recall can be adopted Figure 4 The vector recall shown is 3 or Figure 5 The classification method is used to classify the response description information with the help of some classifiers, such as a small parameter model or a large parameter model, such as Figure 4 The classification process shown is 3, Figure 6 or Figure 7 Classification processing shown, etc.

[0146] In addition, the present application does not limit the correlation between the execution time of step 25, the execution time of step 24, and the execution time of step 23, for example, the three are the same. For another example, the three satisfy a certain arrangement order. For another example, after executing step 24 and step 23, if the intention risk detection result determined by step 23 indicates that there is no risk and the method risk detection result determined by step 24 indicates that there is no risk, then step 25 is executed to achieve a bottom line, which is conducive to saving detection time and thus improving efficiency.

[0147] Step 26: Determine the risk detection result of the target language model applied to the model input data based on at least two of the above intention risk detection result, the above technique risk detection result, and the above abnormal response detection result.

[0148] It should be noted that the present application does not limit the implementation method of the above step 26. For example, it can be specifically as follows: after obtaining the intention risk detection results, the technique risk detection results, and the abnormal response detection results, these results can be aggregated in some way, such as Figure 2 The combined analysis shown, Figure 3 The aggregate analysis shown or Figure 4 The aggregation analysis and other summary processing shown are used to obtain the risk detection results of the target language model applied to the model input data.

[0149] It can be seen that, in one possible implementation, the above "risk detection result of the target language model applied to the model input data" is determined not only based on at least one of the above intention risk detection result and the above technique risk detection result, but also based on the above abnormal response detection result.

[0150] In fact, in some application scenarios, such as Figure 4In the scenario shown, in order to better improve the detection effect, the abnormal response detection result can be used as a backup. Based on this, the present application also provides a possible implementation method of step 26 above. Under this implementation method, step 26 can be specifically as follows: first determine whether the risk is hit based on the above intention risk detection result and the above technique risk detection result, such as determining whether the risk of malicious intent, attack technique, etc. is hit; if the risk is hit, the pre-set risk characterization value, such as the value of "1", can be determined as the risk detection result of the target language model applied to the model input data; if the risk is not hit, determine whether the abnormal response is hit based on the above abnormal response detection result, if the abnormal response is hit, the risk characterization value can be determined as the risk detection result of the target language model applied to the model input data; if the abnormal response is not hit, the pre-set risk-free characterization value, such as the value of "0", can be determined as the risk detection result of the target language model applied to the model input data.

[0151] Based on the relevant contents of steps 21 to 26 above, it can be known that in some application scenarios, the information of the three dimensions of intention description content, technique description content and response description information can be first determined based on the model input data and model output data of the target language model; then, based on the risk detection results of these three dimensions, the risk detection results of the target language model applied to the model input data are comprehensively determined, which is conducive to improving the risk detection effect.

[0152] In addition, the present application does not limit the method for determining the above-mentioned intention description content, technique description content and response description information. For example, in some application scenarios, in order to better improve the detection effect, when the above-mentioned model input data includes multiple data and the source types of different data are different, the intention description content, the technique description content, and the response description information are determined based on the source types of the multiple data. This is conducive to realizing different detection processing for data of different source types, thereby helping to improve the detection effect.

[0153] It can be seen that in a possible implementation mode, when the model input data above includes a plug-in response and at least one prompt word above, the source type of the plug-in response is different from the source type of each prompt word, and the source types of different prompt words are different, the response description information can be determined based on the plug-in response and / or the model output data above, and the above intention description content and the above technique description content are determined based on the at least one prompt word and the source type of the at least one prompt word. It should be noted that the determination process of the intention description content and the technique description content can be found above. In addition, the present application does not limit the implementation mode of the response description information. For example, in some application scenarios, such as the SP leakage risk scenario, if the at least one prompt word includes a system prompt word, the response description information can be determined based on the plug-in response, the system prompt word, and the model output data, so that abnormal response detection can be performed based on these three types of data later, such as detecting whether there is an SP leakage risk, etc., which is conducive to improving the detection effect.

[0154] Based on the above two paragraphs and related content, it can be known that under one possible implementation mode, after obtaining the model input data and model output data of the target language model, the model input data and the model output data can be spliced ​​into one data; so that the spliced ​​data can be subsequently split into intent description content, technique description content, and response description information according to the source type of each part of the spliced ​​data, so that malicious intent detection processing can be performed based on the intent description content, attack technique detection processing can be performed based on the technique description content, and abnormal response detection processing can be performed based on the response description information, so that the final risk detection result can be determined based on these three detection results.

[0155] It can be seen that in one possible implementation mode, when the detected data includes user prompt words, system prompt words, plug-in responses and model output data, the user prompt words and the system prompt words can participate in the intention risk detection process to determine whether there is malicious intent; the user prompt words can participate in the technique risk detection process to determine whether there is attack technique detection; the system prompt words, the plug-in response and the model output data can participate in the abnormal response detection process to determine whether there is an abnormal response, so that the final risk detection result can be determined based on these three detection results.

[0156] The inventors of the present disclosure have found through research that when the data to be detected includes data from multiple source types, the risk boundaries of data from different source types are different in different situations. For example, in the chatbot review scenario, it is necessary to detect whether the system prompt words are risky, but there is no need to detect whether the user prompt words are risky. For another example, in some cases, if the feature "introducing role settings" appears in the user prompt words, it can be determined as risky, but if the feature "introducing role settings" appears in the system prompt words, it can be determined as risk-free. For another example, in some cases, if the feature "making the model call component write information" appears in the plug-in response, it can be determined as risky, but if the feature "making the model call component write information" appears in the user prompt words, it can be determined as risk-free. It can be seen that in order to better improve the detection effect, differentiated distinctions can be made for different situations to effectively avoid problems such as false positives / missing negatives in different situations.

[0157] Based on the above research, it can be known that in order to better meet the risk detection needs in different situations, different detection items can be configured for data of different source types, which can effectively avoid the defects caused by using the same set of detection items for different situations or using the same set of detection items for data of different source types in the same situation, thereby helping to improve the detection effect. Based on this, the present application also provides a possible implementation method of the risk detection method of the above language model, in which the risk detection method can at least include the following steps 31-32.

[0158] Step 31: Obtain model detection constraint information.

[0159] Among them, the model detection constraint information is used to constrain the risk detection processing of the target language model, so that the model detection constraint information can describe the risk detection requirements that need to be met by the risk detection processing, such as which features need to be risk detected or what kind of detection needs to be performed on each feature.

[0160] In addition, the present application does not limit the implementation method of the model detection constraint information. For example, the model detection constraint information may include at least one of scene constraint information, region constraint information, business constraint information, language constraint information, and detection item constraint information. For ease of understanding, these constraint information are introduced below.

[0161] For the above scenario constraint information, the scenario constraint information is used to describe the scenario requirements of the risk detection processing of the target language model, such as application scenarios and / or usage scenarios; and the present application does not limit the implementation method of the scenario constraint information, for example, the scenario constraint information may include application scenario description information and / or usage scenario description information. Among them, the application scenario description information is used to describe the application scenario of the target language model; and the implementation method of the application scenario description information of the present application, for example, it can be implemented using the application scenario parameters pre-configured for the target language model and / or the application scenario parameters specified by the user. In addition, the present application does not limit the implementation method of the application scenario, for example, the application scenario can be implemented using a chatbot, an intelligent agent, a code assistant or multimodality. The usage scenario description information is used to describe the usage scenario of the target language model, so that the usage scenario description information can represent some usage situations of the target language model; and the implementation method of the usage scenario description information of the present application, for example, it can be implemented using the usage scenario parameters pre-configured for the target language model and / or the usage scenario parameters specified by the user. In addition, the present application does not limit the implementation method of this usage scenario. For example, this usage scenario can be implemented using Runtime or SpaAudit.

[0162] For the above-mentioned regional constraint information, the regional constraint information is used to describe the regional requirements of risk detection processing of the target language model, such as requirements of a certain region, a certain country or a certain continent; and the present application does not limit the implementation method of the regional constraint information. For example, it can be implemented using regional parameters pre-configured for the target language model and / or regional parameters specified by the user.

[0163] For the above-mentioned business constraint information, the business constraint information is used to describe the business requirements of risk detection processing of the target language model, such as business 1, business 2 or business 3 requirements; and the present application does not limit the implementation method of the business constraint information. For example, it can be implemented using business parameters pre-configured for the target language model and / or business parameters specified by the user.

[0164] For the above language constraint information, the language constraint information is used to describe the language requirements of the risk detection processing of the target language model, such as Chinese, English or Japanese requirements; and the present application does not limit the implementation method of the language constraint information. For example, it can be implemented using language parameters pre-configured for the target language model and / or language parameters specified by the user.

[0165] For the above detection item constraint information, the detection item constraint information is used to describe the detection item requirements of the risk detection processing of the target language model, such as the requirements for executing SP leakage detection items; and the present application does not limit the implementation method of the detection item constraint information. For example, it can be implemented using detection item parameters pre-configured for the target language model and / or detection item parameters specified by the user.

[0166] Based on the above related content of the model detection constraint information, it can be known that in a possible implementation mode, the model detection constraint information can be determined based on the user input and the configuration information pre-configured for the target language model, so that the model detection constraint information can represent some requirements that need to be met when performing risk detection processing on the target language model, such as Figure 3 The application scenarios, usage scenarios, regions, businesses, languages, and detection items shown in the figure can better complete the risk detection processing for the target language model based on these requirements in the future.

[0167] In addition, the present application does not limit the execution time of the above step 31, as long as the execution time of the step 31 is ensured to be earlier than the execution time of the following step 32.

[0168] Step 32: Determine a detection execution device that matches the above model detection constraint information from the detection execution devices corresponding to multiple candidate constraint information, so that the matching detection execution device is at least used to perform intent risk detection processing on the determined intent description content to obtain an intent risk detection result, and / or, perform technique risk detection processing on the determined technique description content to obtain a technique risk detection result.

[0169] Among them, multiple candidate constraint information refers to some pre-set optional constraint information, such as multiple application scenarios, multiple usage scenarios, multiple regions, multiple services, multiple languages, multiple detection items, etc. It can be seen that in a possible implementation, the multiple candidate constraint information may include part or all of at least one candidate application scenario, at least one candidate usage scenario, at least one candidate region, at least one candidate service, at least one candidate language, and at least one candidate detection item.

[0170] In addition, for the i-th candidate constraint information, the detection execution device corresponding to the i-th candidate constraint information refers to a device with detection function that is pre-configured for the i-th candidate constraint information, so that the detection execution device corresponding to the i-th candidate constraint information is used to perform detection processing that satisfies the i-th candidate constraint information, such as intention risk detection processing, technique risk detection processing, and abnormal response detection processing; and the present application does not limit the implementation method of the detection execution device corresponding to the i-th candidate constraint information. For example, the detection execution device corresponding to the i-th candidate constraint information may include part or all of a malicious intent detector, an attack technique detector, and an abnormal response detector. Among them, the malicious intent detector is used to perform intention risk detection processing that satisfies the i-th candidate constraint information to identify malicious intent in the case described by the i-th candidate constraint information. The attack technique detector is used to perform technique risk detection processing that satisfies the i-th candidate constraint information to identify the attack technique in the case described by the i-th candidate constraint information. The abnormal response detector is used to perform abnormal response detection processing that satisfies the i-th candidate constraint information to identify abnormal responses under the situation described by the i-th candidate constraint information. Wherein, i is a positive integer, i≤the number of information in the above multiple candidate constraint information.

[0171] In addition, in order to better improve the detection effect, the present application also provides a possible implementation of the above malicious intent detector, under which the malicious intent detector may include intent detectors corresponding to different source types, such as intent detectors corresponding to user prompt words and intent detectors corresponding to system prompt words, etc., to implement different intent risk detection processing for data of different source types, which is conducive to better meeting the intent detection requirements in the case described by the i-th candidate constraint information, thereby helping to improve the detection effect. Among them, the intent detector corresponding to the user prompt word is used to perform intent risk detection processing on the intent content determined based on the user prompt word to identify whether there is malicious intent in the intent content, which can meet the intent detection requirements for the user prompt word in this case. The intent detector corresponding to the system prompt word is used to perform intent risk detection processing on the intent content determined based on the system prompt word to identify whether there is malicious intent in the intent content, which can meet the intent detection requirements for the system prompt word in this case.

[0172] In addition, in order to better improve the detection effect, the present application also provides a possible implementation of the above abnormal response detector, under which the abnormal response detector may include response detectors corresponding to different source types, such as response detectors corresponding to plug-in responses and response detectors corresponding to model output data, etc., to implement different abnormal response detection processing for data of different source types, which is conducive to better meeting the response detection requirements in the case described by the i-th candidate constraint information, thereby helping to improve the detection effect. Among them, the response detector corresponding to the plug-in response is used to perform abnormal response detection processing on the plug-in response to identify whether there is abnormal content in the plug-in response, which can meet the response detection requirements for the plug-in response in the model input data in this case. The response detector corresponding to the model output data is used to perform abnormal response detection processing on the model output data to identify whether there is abnormal content in the model output data, which can meet the response detection requirements for the model output data in this case.

[0173] Based on the relevant content of the i-th candidate constraint information above, it can be known that in some application scenarios, the detection execution device corresponding to the i-th candidate constraint information may include detectors corresponding to data of different source types, so that these detectors can meet the detection requirements in the situation described by the i-th candidate constraint information, such as malicious intent detection requirements and / or abnormal response detection requirements. Among them, for data of any source type, the detector corresponding to the data is constructed according to the detection requirements set for the source type in the situation, such as using Figure 3 The rule library, vector library, small model library and large model library shown are constructed so that the detection process implemented by the detector corresponding to the data can better meet the detection requirements set for the source type in this case, thereby effectively meeting the different detection requirements of data of different source types in different situations, which is conducive to improving the detection effect.

[0174] In addition, the present application does not limit the implementation method of the detection execution device corresponding to the above i-th candidate constraint information. For example, it can be implemented by means of one or more of rule checking, vector recall, and classification. It can be seen that in one possible implementation method, the detection execution device corresponding to the i-th candidate constraint information is constructed by combining part or all of the rules in the rule library, part or all of the vectors in the vector library, part or all of the small parameter models in the small model library, and part or all of the large parameter models in the large model library to obtain the detection execution device corresponding to the i-th candidate constraint information to meet the detection requirements under the situation described by the i-th candidate constraint information. Among them, the rule library is used to record the rules required for rule checking. The vector library is used to record the vectorized features of the attack samples required for vector recall. The small model library is used to record the small parameter model with classification function required for classification. The large model library is used to record the large parameter model with classification function required for classification.

[0175] In addition, this application does not limit the construction method of the rule library, vector library, small model library and large model library in the above paragraph. For example, it can be specifically: first, collect business data through log embedding, offline data (Hive / ClickHouse), etc. to construct negative samples including UserPrompt, SystemPrompt, Tool and other data, such as Figure 3 The negative samples shown in the figure can represent samples without attack risks, and the attack data collected by open source data, online attacks, automatic generation, etc. are used to construct positive samples, such as Figure 3 The positive samples shown in the figure are selected to make the positive samples represent samples with attack risks; then, supervised fine-tuning (SFT), FewShot, vectorized storage, rule construction and other processing are performed based on these negative samples and positive samples to form rules and models for detecting different types of attack features, such as malicious intent, attack methods, abnormal responses and other features; finally, these rules and these models are stored in a database to obtain Figure 3 The rule library, vector library, small model library and large model library are shown, so that these libraries can be used to build detectors for detecting and processing data from different source types in different situations.

[0176] In addition, for the target language model mentioned above, after obtaining the model detection constraint information corresponding to the target language model, a detection execution device that matches the model detection constraint information can be determined from the detection execution devices corresponding to multiple candidate constraint information, such as a detection execution device that matches the scene constraint information, a detection execution device that matches the regional constraint information, a detection execution device that matches the business constraint information, a detection execution device that matches the language constraint information, and a detection execution device that matches the detection item constraint information, etc., so that the "detection execution device that matches the model detection constraint information" can meet the detection requirements described by the model detection constraint information, so that the "detection execution device that matches the model detection constraint information" can be used to subsequently implement detection processing of the model input data and / or model data for the target language model, such as intention risk detection processing, technique risk detection processing, and abnormal response detection processing.

[0177] It can be seen that for the above "detection execution device that matches the model detection constraint information", in some scenarios, such as the prompt word detection scenario, the "detection execution device that matches the model detection constraint information" can be used to perform intent risk detection on the intent description content to obtain intent risk detection results, and to perform technique risk detection on the technique description content to obtain technique risk detection results. In other scenarios, such as the prompt word and response detection scenarios, the "detection execution device that matches the model detection constraint information" can be used to perform intent risk detection on the intent description content to obtain intent risk detection results, perform technique risk detection on the technique description content to obtain technique risk detection results, and perform abnormal response detection on the response description information to obtain abnormal response detection results.

[0178] In addition, the present application does not limit the implementation method of the above-mentioned "detection execution device that matches the model detection constraint information". For example, in order to better improve the detection effect, when the "detection execution device that matches the model detection constraint information" is at least used to perform intent risk detection processing on the intent description content to obtain intent risk detection results, and to perform technique risk detection processing on the technique description content to obtain technique risk detection results, the "detection execution device that matches the model detection constraint information" may at least include: a detector corresponding to the intent description content and a detector corresponding to the technique description content. Among them, the detector corresponding to the intent description content is used to represent the malicious intent detector that matches the model detection constraint information, so that the detector corresponding to the intent description content can be used to perform intent risk detection processing on the intent description content to obtain intention risk detection results; the detector corresponding to the technique description content is used to represent the attack technique detector that matches the model detection constraint information, so that the detector corresponding to the technique description content can be used to perform technique risk detection processing on the technique description content to obtain technique risk detection results.

[0179] In addition, based on the relevant content of the malicious intent detector above, in order to better improve the detection effect, the present application also provides a possible implementation method of the above "detector corresponding to the intent description content". In this way, when the intent description content includes at least two source types of intent content, the "detector corresponding to the intent description content" may include detectors corresponding to various source types of intent content, such as intent detectors corresponding to user prompt words and intent detectors corresponding to system prompt words. Among them, for the detector corresponding to the intent content of any source type, the detector is used to perform intent risk detection processing on the intent content of the source type, so that the aforementioned "detector corresponding to the intent description content" can perform different malicious intent detection processing on intent content of different source types, which can better meet the different malicious intent detection requirements for intent content of different source types in the current situation, thereby helping to improve the detection effect.

[0180] Furthermore, the present application does not limit the implementation method of the above step 32. For example, it can be implemented by means of task distribution, such as Figure 3The task distribution method shown is implemented. It can be seen that under a possible implementation method, step 32 can be: first determine the detection execution device that matches the above model detection constraint information from the detection execution devices corresponding to multiple candidate constraint information; then send a detection request to the matching detection execution device, so that the matching detection execution device is at least used to perform intent risk detection processing on the intent description content carried by the detection request to obtain an intent risk detection result, and / or, perform technique risk detection processing on the technique description content carried by the detection request to obtain a technique risk detection result; then, receive feedback information from the matching detection execution device, so that the feedback information includes the intent risk detection result and / or the technique risk detection result. Among them, the detection request is used to request the matching detection execution device to perform detection processing on the data carried by the detection request, such as the intent description content, the technique description content and the above response description information.

[0181] Based on the relevant contents of steps 31 to 32 above, it can be seen that in some application scenarios, such as Figure 3 In the scenario shown, after obtaining the model input data and model output data of the target language model, the corresponding content in the model input data and model output data can be task distributed according to the application scenarios, usage scenarios, regions and other factors in the user-specified parameters and / or configuration parameters, so that the corresponding device can detect malicious intentions, attack methods, abnormal responses and other features by means of rule checking, vector recall and classification, and then summarize these three results to obtain the risk detection result of the target language model applied to the model input data. In this way, different detection processing can be achieved for data of different source types in different situations, so as to better meet the detection needs of data of different source types in different situations, thereby helping to improve the detection effect.

[0182] It should be noted that for the step in the previous paragraph "the corresponding device can detect malicious intent, attack methods, abnormal responses and other characteristics by means of rule checking, vector recall and classification", in some application scenarios, such as a large number of concurrent detection requests, during the execution of this step, Figure 3 The coarse screening and fine screening shown can identify requests with attack risks from these detection requests as quickly as possible, thereby helping to improve detection efficiency.

[0183] In fact, in order to better improve the detection effect, the present application also provides a possible implementation method of the risk detection method of the above language model. In this method, when the detection execution device corresponding to the above multiple candidate constraint information is constructed based on a pre-constructed detection set, and the detection set includes at least one detection rule, at least one detection vector, and one or more of at least one detection model, the risk detection method can at least include the above steps 31-32 and the following step 33.

[0184] Step 33: If the risk detection result of the target language model applied to the model input data indicates that there is a risk, the detection set is updated based on the model input data.

[0185] Among them, the detection set refers to the object required to build the detection execution device corresponding to multiple candidate constraint information, such as Figure 3 Objects shown include rules in the rule library, vectors in the vector library, models in the small model library, and models in the large model library.

[0186] In addition, for the above detection set, the detection set includes one or more of at least one detection rule, at least one detection vector, and at least one detection model. Among them, the detection rule refers to the rule required to be based on when performing detection processing; and the present application does not limit the at least one detection rule, for example, the at least one detection rule may include some or all rules in the rule library. The detection vector refers to the vector required to be based on when performing detection processing; and the present application does not limit the at least one detection vector, for example, the at least one detection vector may include some or all vectors in the vector library. The detection model refers to the model required to be based on when performing detection processing, such as a small parameter model or a large parameter model with a classification function; and the present application does not limit the at least one detection model, for example, the at least one detection model may include some or all models in the small model library, and some or all models in the large model library. It can be seen that in a possible implementation, the detection set may include at least one of a rule library, a vector library, a small model library, and a large model library.

[0187] In addition, the present application does not limit the implementation method of the above step 33. For example, it can be specifically as follows: if the risk detection result of the above target language model applied to the model input data indicates the existence of a risk, then based on the model input data as a positive sample, the detection set is updated so that when subsequent detection processing is performed based on the updated detection set, it can be accurately identified that the model input data has an attack risk.

[0188] Based on the relevant content of step 33 above, it can be known that after obtaining the risk detection result of the target language model applied to the model input data, if the risk detection result indicates the existence of a risk, the model input data can be used as an attack sample to update the rule library, vector library, small model library and large model library, etc., so as to improve the detection function of the detector built based on these libraries, so that the detection processing implemented based on these detectors can achieve better detection effects, which is conducive to improving the detection effect.

[0189] In fact, in order to better improve security, the present application also provides a possible implementation of the risk detection method of the above language model. In this implementation, the risk detection method may at least include the following step 41.

[0190] Step 41: If the risk detection result of the target language model applied to the model input data indicates that there is a risk, the model output data of the target language model is processed, such as interception processing, alarm processing or rewriting processing, to improve security.

[0191] In the present application, after obtaining the risk detection result of the target language model applied to the model input data, if the risk detection result indicates the existence of a risk, the model output data of the target language model can be intercepted, alarmed, or rewritten to overcome the security issues caused by the risk, which is conducive to improving security.

[0192] In addition, the present application does not limit the implementation method of the risk detection method of the above language model. For example, the risk detection method can adopt a detection module, such as a plug-in method, Figure 2 The analysis engine shown or Figure 3 The analysis engine shown is implemented in a manner such as the one shown, so that in the process of business interaction, the interface of the detection module can be called for detection before the model input data is input into the target language model and after the model output data is output by the target language model, so that the business can perform corresponding processing on the model output data based on the detection result fed back by the detection module, such as interception / alarm / rewriting / normal use, etc., so that protection can be achieved without changing the business process and the target language model, which is beneficial to avoid the impact of the protection on the business and the target language model, and further helps to improve the protection effect.

[0193] Based on the relevant content of the risk detection method based on the above language model, it can be seen that the technical solution provided by the present application has the advantages shown in (i) to (iii) below.

[0194] (I) This application performs risk detection on prompt words from the two dimensions of malicious intent and attack methods, and aggregates the detection results under these two dimensions by voting to obtain the final risk detection results. This detection method ensures that the number of rules and vector library samples of the technical solution of this application will not show exponential growth as the number of covered attack types increases, and has good scalability, generalization and timeliness.

[0195] (II) This application splits the data of different sources such as System Prompt, User Prompt, Plugin Response, etc. in the model input data, and uses different models and rules for differentiated detection to adapt to the risk boundaries of different scenarios, so that detection can be performed in different business scenarios.

[0196] (III) This application fully combines the model output data for detection and protection, and determines whether there is an attack risk from the actual output of the model, so as to effectively identify attack requests with unclear features and unknown attack requests.

[0197] Based on the language model risk detection method provided in the embodiment of the present application, the embodiment of the present application also provides a language model risk detection device. Figure 8 Explain and illustrate. Figure 8 This is a schematic diagram of the structure of a risk detection device for a language model provided in an embodiment of the present application. It should be noted that for the technical details of the risk detection device for a language model provided in an embodiment of the present application, please refer to the relevant content of the risk detection method for a language model above.

[0198] like Figure 8 As shown, the language model risk detection device 800 provided in the embodiment of the present application includes:

[0199] A data acquisition unit 801 is used to acquire model input data of a target language model;

[0200] A content determination unit 802, configured to determine at least one of intention description content and technique description content from the model input data;

[0201] The data detection unit 803 is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or to perform method risk detection processing on the determined method description content to obtain a method risk detection result;

[0202] The result determination unit 804 is used to determine the risk detection result of the target language model applied to the model input data based on at least one of the obtained intention risk detection result and technique risk detection result.

[0203] In a possible implementation manner, the model input data includes at least one prompt word;

[0204] The content determination unit 802 is specifically configured to determine at least one of intention description content and technique description content from the at least one prompt word according to different source types of each prompt word in the at least one prompt word.

[0205] In one possible implementation, the source type of each prompt word in the at least one prompt word includes: system prompt words and user prompt words; the intention description content is determined based on the system prompt words and user prompt words in the model input data; the technique description content is determined based on the user prompt words in the model input data.

[0206] In a possible implementation manner, the data detection unit 803 is further used to perform abnormal response detection processing on the response description information to obtain an abnormal response detection result; the response description information is determined based on the model input data and / or the model output data of the target language model; the model output data is obtained by the target language model processing the model input data;

[0207] The risk detection result of the target language model applied to the model input data is also determined based on the abnormal response detection result.

[0208] In one possible implementation, the model input data includes multiple data, and the source types of different data are different; the intention description content, the technique description content, and the response description information are determined based on the source types of the multiple data.

[0209] In one possible implementation, the multiple data include a plug-in response and at least one prompt word, the source type of the plug-in response is different from the source type of each of the prompt words, and different prompt words have different source types; the intention description content and the technique description content are determined based on the at least one prompt word and the source type of the at least one prompt word; the response description information is determined based on the plug-in response and / or the model output data.

[0210] In a possible implementation manner, the at least one prompt word includes a system prompt word; and the response description information is also determined based on the system prompt word.

[0211] In a possible implementation manner, the language model risk detection device 800 further includes:

[0212] A constraint acquisition unit, used to acquire model detection constraint information;

[0213] A device determining unit, configured to determine a detection execution device that matches the model detection constraint information from detection execution devices corresponding to a plurality of candidate constraint information;

[0214] The matching detection execution device is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or to perform technique risk detection processing on the determined technique description content to obtain a technique risk detection result.

[0215] In a possible implementation manner, the model detection constraint information includes at least one of scene constraint information, region constraint information, business constraint information, language constraint information, and detection item constraint information.

[0216] In one possible implementation, the matching detection execution device includes a detector corresponding to the intention description content and a detector corresponding to the technique description content; the detector corresponding to the intention description content is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result; the detector corresponding to the technique description content is used to perform technique risk detection processing on the determined technique description content to obtain a technique risk detection result.

[0217] In one possible implementation, the intent description content includes intent content from at least two source types; the detector corresponding to the intent description content includes detectors corresponding to intent content from various source types; for the detector corresponding to the intent content of any source type, the detector is used to perform intent risk detection processing on the intent content of that source type.

[0218] In a possible implementation manner, the data detection unit 803 is specifically configured to:

[0219] Sending a detection request to the matched detection execution device; the matched detection execution device is used to perform intent risk detection processing on the intent description content carried in the detection request to obtain an intent risk detection result, and / or, performing technique risk detection processing on the technique description content carried in the detection request to obtain a technique risk detection result;

[0220] Receive feedback information from the matched detection execution device, where the feedback information includes the intention risk detection result and / or the technique risk detection result.

[0221] In one possible implementation, the matching detection execution device is also used to perform abnormal response detection processing on the response description information to obtain an abnormal response detection result; the response description information is determined based on the model input data and / or the model output data of the target language model; the model output data is obtained by processing the model input data by the target language model.

[0222] In a possible implementation manner, the detection execution devices corresponding to the plurality of candidate constraint information are constructed based on a pre-constructed detection set, wherein the detection set includes one or more of at least one detection rule, at least one detection vector, and at least one detection model;

[0223] The language model risk detection device 800 further includes:

[0224] An updating unit is used to update the detection set according to the model input data after determining the risk detection result of the target language model applied to the model input data, if the risk detection result of the target language model applied to the model input data indicates the existence of risk.

[0225] Based on the relevant content of the risk detection device 800 of the above-mentioned language model, it can be known that the working principle of the risk detection device 800 of the language model provided in the present application is: after obtaining the model input data of the target language model, first determine at least one of the intent description content and the technique description content from the model input data; then, perform intent risk detection processing on the intent description content to obtain an intent risk detection result, and / or, perform technique risk detection processing on the technique description content to obtain a technique risk detection result; finally, based on the intent risk detection result and / or the technique risk detection result, determine the risk detection result of the target language model under the model input data, so that the risk detection result can indicate whether there is a risk, such as Prompt injection risk, etc., thereby effectively avoiding the security issues caused by the risk, and thus helping to improve security. It can be seen that because the risk detection device 800 of the language model performs risk detection processing on the model input data from the two dimensions of intention and technique, the risk detection device 800 of the language model can analyze whether there is a prompt injection risk from the two characteristics of malicious intention and attack technique, so that the risk detection device 800 of the language model can not only detect the attack samples that have been learned in advance, but also detect the new attack requests composed of the malicious intention and attack techniques appearing in these attack samples, so that the number of samples required to be learned by the risk detection device 800 of the language model will not increase exponentially with the increase of risk types, so that the risk detection device 800 of the language model has good scalability, generalization and timeliness.

[0226] In addition, an embodiment of the present application also provides an electronic device, which includes a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes any implementation of the risk detection method of the language model provided in the embodiment of the present application.

[0227] See also Fig. 9 , which shows a schematic diagram of the structure of an electronic device 900 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig. 9 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

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

[0229] Typically, the following devices may be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 908 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Although Fig. 9 The electronic device 900 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0230] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0231] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0232] An embodiment of the present application also provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes any implementation of the risk detection method of the language model provided in the embodiment of the present application.

[0233] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0234] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0235] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0236] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the method.

[0237] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code 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 and partially on a remote computer, or entirely on a remote computer or server. In cases involving 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., through the Internet using an Internet service provider).

[0238] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite 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 a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0239] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.

[0240] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

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

[0242] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0243] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0244] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0245] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0246] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A risk detection method for a language model, characterized in that: The method comprises: Obtain model input data of the target language model; Determining at least one of intention description content and technique description content from the model input data; Performing intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or performing method risk detection processing on the determined method description content to obtain a method risk detection result; Based on at least one of the obtained intention risk detection result and technique risk detection result, determine the risk detection result of the target language model applied to the model input data.

2. The method according to claim 1, characterized in that The model input data includes at least one prompt word; The step of determining at least one of the intention description content and the technique description content from the model input data comprises: According to different source types of each of the at least one prompt word, at least one of the intention description content and the technique description content is determined from the at least one prompt word.

3. The method according to claim 2, characterized in that The source type of each prompt word in the at least one prompt word includes: a system prompt word and a user prompt word; The intention description content is determined based on the system prompt words and user prompt words in the model input data; The technique description content is determined based on the user prompt words in the model input data.

4. The method according to claim 1, characterized in that: The method further comprises: Performing abnormal response detection processing on the response description information to obtain an abnormal response detection result; the response description information is determined based on the model input data and / or the model output data of the target language model; the model output data is obtained by processing the model input data by the target language model; The risk detection result of the target language model applied to the model input data is also determined based on the abnormal response detection result.

5. The method according to claim 4, characterized in that The model input data includes multiple data, and the source types of different data are different; The intention description content, the technique description content, and the response description information are determined according to the source types of the multiple data.

6. The method according to claim 5, characterized in that The plurality of data includes a plug-in response and at least one prompt word, the source type of the plug-in response is different from the source type of each of the prompt words, and the source types of different prompt words are different; The intention description content and the technique description content are determined according to the at least one prompt word and the source type of the at least one prompt word; The response description information is determined according to the plug-in response and / or the model output data.

7. The method according to claim 6, characterized in that The at least one prompt word includes a system prompt word; The response description information is also determined based on the system prompt word.

8. The method according to claim 1, characterized in that The method further comprises: Get model detection constraint information; Determine, from among the detection execution devices corresponding to the plurality of candidate constraint information, a detection execution device that matches the model detection constraint information; The matching detection execution device is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or to perform technique risk detection processing on the determined technique description content to obtain a technique risk detection result.

9. The method according to claim 8, characterized in that The model detection constraint information includes at least one of scene constraint information, region constraint information, business constraint information, language constraint information, and detection item constraint information.

10. The method according to claim 8, characterized in that The matching detection execution device includes a detector corresponding to the intention description content and a detector corresponding to the technique description content; The detector corresponding to the intention description content is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result; The detector corresponding to the technique description content is used to perform technique risk detection processing on the determined technique description content to obtain a technique risk detection result.

11. The method according to claim 10, characterized in that The intention description content includes intention content of at least two source types; The detector corresponding to the intent description content includes detectors corresponding to intent contents of various source types; For a detector corresponding to the intended content of any source type, the detector is used to perform intent risk detection processing on the intended content of the source type.

12. The method according to claim 8, characterized in that After determining the detection execution device that matches the model detection constraint information from the detection execution devices corresponding to the plurality of candidate constraint information, the method further includes: Sending a detection request to the matched detection execution device; the matched detection execution device is used to perform intent risk detection processing on the intent description content carried in the detection request to obtain an intent risk detection result, and / or, performing technique risk detection processing on the technique description content carried in the detection request to obtain a technique risk detection result; Receive feedback information from the matched detection execution device, where the feedback information includes the intention risk detection result and / or the technique risk detection result.

13. The method according to any one of claims 8 to 12, characterized in that: The matched detection execution device is further used to perform abnormal response detection processing on the response description information to obtain an abnormal response detection result; The response description information is determined based on the model input data and / or the model output data of the target language model; the model output data is obtained by the target language model processing the model input data.

14. The method according to claim 8, characterized in that The detection execution devices corresponding to the plurality of candidate constraint information are constructed based on a pre-constructed detection set, wherein the detection set includes one or more of at least one detection rule, at least one detection vector, and at least one detection model; After determining the risk detection result of the target language model applied to the model input data, the method further includes: If the risk detection result of the target language model applied to the model input data indicates that there is a risk, the detection set is updated according to the model input data.

15. A risk detection device for a language model, characterized in that: include: A data acquisition unit, used to acquire model input data of a target language model; a content determination unit, configured to determine at least one of intention description content and technique description content from the model input data; A data detection unit is used to perform intention risk detection processing on the determined intention description content to obtain an intention risk detection result, and / or to perform method risk detection processing on the determined method description content to obtain a method risk detection result; A result determination unit is used to determine the risk detection result of the target language model applied to the model input data based on at least one of the obtained intention risk detection result and technique risk detection result.

16. An electronic device, characterized in that: The device comprises: a processor and a memory; The memory is used to store instructions or computer programs; The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the method according to any one of claims 1 to 14.

17. A computer readable medium, characterized in that The computer-readable medium stores instructions or computer programs, and when the instructions or computer programs are executed on a device, the device executes the method according to any one of claims 1 to 14.

18. A computer program product, characterized in that It comprises a computer program carried on a non-transitory computer-readable medium, the computer program comprising a program code for executing the method according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Verbal skill determination method, device and equipment

    CN113837638A

  • Risk management method and device, equipment and storage medium

    CN115099680A

  • Large model risk assessment method and device, storage medium and electronic equipment

    CN117113339A

  • Risk prediction method and device, electronic equipment and storage medium

    CN117314658A

  • Risk data detection method and device

    CN117574410A

Cited By

  • Prompt word security reinforcement method and device for large model application, equipment and storage medium

    CN120805157A

  • Large model business risk detection method and device, medium, equipment and program product

    CN121414133A

  • Risk detection method and apparatus for language model, device, medium, and product

    EP4672078A1

  • Systems and methods for safeguarding user-facing artificial intelligence models

    EP4776166A1